Skip to content

Commit

Permalink
feat: Enable metric alerts on dev
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-shorpo committed Dec 5, 2023
1 parent ff38d75 commit 1d7bc35
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
42 changes: 21 additions & 21 deletions packages/app/src/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ export const SlackChannelForm = ({

return (
<>
{hasSlackWebhooks && (
<div className="mt-3">
<Form.Label className="text-muted">Slack Webhook</Form.Label>
<Form.Select
className="bg-black border-0 mb-1 px-3"
required
id="webhookId"
size="sm"
{...webhookSelectProps}
>
{/* Ensure user selects a slack webhook before submitting form */}
<option value="" disabled>
Select a Slack Webhook
<div className="mt-3">
<Form.Label className="text-muted">Slack Webhook</Form.Label>
<Form.Select
className="bg-black border-0 mb-1 px-3"
required
id="webhookId"
size="sm"
{...webhookSelectProps}
>
{/* Ensure user selects a slack webhook before submitting form */}
<option value="" disabled selected>
{hasSlackWebhooks
? 'Select a Slack Webhook'
: 'No Slack Webhooks available'}
</option>
{slackWebhooks?.data.map((sw: any) => (
<option key={sw._id} value={sw._id}>
{sw.name}
</option>
{slackWebhooks.data.map((sw: any) => (
<option key={sw._id} value={sw._id}>
{sw.name}
</option>
))}
</Form.Select>
</div>
)}
))}
</Form.Select>
</div>

<div className="mb-2">
<a
Expand Down
6 changes: 5 additions & 1 deletion packages/app/src/EditChartForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import EditChartFormAlerts from './EditChartFormAlerts';
import HDXNumberChart from './HDXNumberChart';
import HDXTableChart from './HDXTableChart';
import { intervalToGranularity } from './Alert';
import { METRIC_ALERTS_ENABLED } from './config';

export type Chart = {
id: string;
Expand Down Expand Up @@ -867,6 +868,9 @@ export const EditLineChartForm = ({
return null;
}

const isChartAlertsFeatureEnabled =
editedChart.series[0].table === 'logs' || METRIC_ALERTS_ENABLED;

return (
<form
onSubmit={e => {
Expand Down Expand Up @@ -970,7 +974,7 @@ export const EditLineChartForm = ({
}}
/>

{editedChart.series[0].table === 'logs' && (
{isChartAlertsFeatureEnabled && (
<div className="mt-4 border-top border-bottom border-grey p-2 py-3">
{isLocalDashboard ? (
<span className="text-gray-600 fs-8">
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/TeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export default function TeamPage() {
name="name"
placeholder="My Slack Webhook"
className="border-0 mb-4 px-3"
required
/>
<Form.Label className="text-start text-muted fs-7 mb-2 mt-2">
Webhook URL
Expand All @@ -351,6 +352,7 @@ export default function TeamPage() {
name="url"
placeholder="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
className="border-0 mb-4 px-3"
required
/>
<Button
variant="brand-primary"
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ export const HDX_COLLECTOR_URL =
'http://localhost:4318';

export const IS_OSS = process.env.NEXT_PUBLIC_IS_OSS ?? 'true' === 'true';

// Features in development
export const METRIC_ALERTS_ENABLED = process.env.NODE_ENV === 'development';

0 comments on commit 1d7bc35

Please sign in to comment.