Skip to content

Commit

Permalink
feat(uptime): Add uptime option to wizard (#77799)
Browse files Browse the repository at this point in the history
<img width="1080" alt="image"
src="https://github.com/user-attachments/assets/793ea578-3015-4a7c-8341-9bccb09d729c">

Maybe marketing/design can help us get a nice graphic in, and some
better copy
  • Loading branch information
davidenwang committed Sep 20, 2024
1 parent d160151 commit a5ff039
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
26 changes: 26 additions & 0 deletions static/app/views/alerts/wizard/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,30 @@ describe('AlertWizard', () => {
const alertGroups = screen.getAllByRole('radiogroup');
expect(alertGroups.length).toEqual(1);
});

it('shows uptime alert according to feature flag', () => {
const {organization, project, routerProps, router} = initializeOrg({
organization: {
features: [
'alert-crash-free-metrics',
'incidents',
'performance-view',
'crash-rate-alerts',
'uptime-api-create-update',
],
access: ['org:write', 'alerts:write'],
},
});

render(
<AlertWizard
organization={organization}
projectId={project.slug}
{...routerProps}
/>,
{router, organization}
);

expect(screen.getByText('Uptime Monitor')).toBeInTheDocument();
});
});
6 changes: 5 additions & 1 deletion static/app/views/alerts/wizard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ function AlertWizard({organization, params, location, projectId}: AlertWizardPro
priority="primary"
to={{
pathname: `/organizations/${organization.slug}/alerts/new/${
isMetricAlert ? AlertRuleType.METRIC : AlertRuleType.ISSUE
isMetricAlert
? AlertRuleType.METRIC
: alertOption === 'uptime_monitor'
? AlertRuleType.UPTIME
: AlertRuleType.ISSUE
}/`,
query: {
...(metricRuleTemplate ? metricRuleTemplate : {}),
Expand Down
12 changes: 10 additions & 2 deletions static/app/views/alerts/wizard/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export type AlertType =
| 'custom_metrics'
| 'llm_tokens'
| 'llm_cost'
| 'insights_metrics';
| 'insights_metrics'
| 'uptime_monitor';

export enum MEPAlertsQueryType {
ERROR = 0,
Expand All @@ -60,7 +61,7 @@ export enum MEPAlertsDataset {
METRICS_ENHANCED = 'metricsEnhanced',
}

export type MetricAlertType = Exclude<AlertType, 'issues'>;
export type MetricAlertType = Exclude<AlertType, 'issues' | 'uptime_monitor'>;

export const DatasetMEPAlertQueryTypes: Record<
Exclude<Dataset, 'search_issues' | Dataset.SESSIONS>, // IssuePlatform (search_issues) is not used in alerts, so we can exclude it here
Expand Down Expand Up @@ -90,6 +91,7 @@ export const AlertWizardAlertNames: Record<AlertType, string> = {
llm_cost: t('LLM cost'),
llm_tokens: t('LLM token usage'),
insights_metrics: t('Insights Metric'),
uptime_monitor: t('Uptime Monitor'),
};

type AlertWizardCategory = {
Expand Down Expand Up @@ -131,6 +133,12 @@ export const getAlertWizardCategories = (org: Organization) => {
options: ['llm_tokens', 'llm_cost'],
});
}
if (org.features.includes('uptime-api-create-update')) {
result.push({
categoryHeading: t('Uptime'),
options: ['uptime_monitor'],
});
}
result.push({
categoryHeading: hasCustomMetrics(org) ? t('Metrics') : t('Custom'),
options: [hasCustomMetrics(org) ? 'custom_metrics' : 'custom_transactions'],
Expand Down
4 changes: 4 additions & 0 deletions static/app/views/alerts/wizard/panelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,8 @@ export const AlertWizardPanelContent: Record<AlertType, PanelContent> = {
],
illustration: diagramCrashFreeUsers,
},
uptime_monitor: {
description: t('Monitor the availability and reliability of your web services.'),
examples: [t('When a URL is detected to be down, create an issue.')],
},
};

0 comments on commit a5ff039

Please sign in to comment.