Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uptime): Add uptime option to wizard #77799

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.')],
},
};
Loading