From d82ec59b8d8579cb65c7383a6d0ce6592f2e517d Mon Sep 17 00:00:00 2001 From: Josh Callender <1569818+saponifi3d@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:05:10 -0700 Subject: [PATCH] Fix creating crash free session alerts, they were using a deprecated dataset --- static/app/views/alerts/wizard/index.tsx | 6 ++---- static/app/views/alerts/wizard/options.tsx | 9 +++------ static/app/views/alerts/wizard/utils.spec.tsx | 4 ++-- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/static/app/views/alerts/wizard/index.tsx b/static/app/views/alerts/wizard/index.tsx index f20e9eea5502d..e044c4fc615f9 100644 --- a/static/app/views/alerts/wizard/index.tsx +++ b/static/app/views/alerts/wizard/index.tsx @@ -60,10 +60,8 @@ function AlertWizard({organization, params, location, projectId}: AlertWizardPro const isMetricAlert = !!metricRuleTemplate; const isTransactionDataset = metricRuleTemplate?.dataset === Dataset.TRANSACTIONS; - if ( - organization.features.includes('alert-crash-free-metrics') && - metricRuleTemplate?.dataset === Dataset.SESSIONS - ) { + // If theres anything using the legacy sessions dataset, we need to convert it to metrics + if (metricRuleTemplate?.dataset === Dataset.SESSIONS) { metricRuleTemplate = {...metricRuleTemplate, dataset: Dataset.METRICS}; } diff --git a/static/app/views/alerts/wizard/options.tsx b/static/app/views/alerts/wizard/options.tsx index 7a2abad2719b2..4bcbdf1722633 100644 --- a/static/app/views/alerts/wizard/options.tsx +++ b/static/app/views/alerts/wizard/options.tsx @@ -65,14 +65,13 @@ export enum MEPAlertsDataset { export type MetricAlertType = Exclude; export const DatasetMEPAlertQueryTypes: Record< - Exclude, // IssuePlatform (search_issues) is not used in alerts, so we can exclude it here + Exclude, // IssuePlatform (search_issues) is not used in alerts, so we can exclude it here MEPAlertsQueryType > = { [Dataset.ERRORS]: MEPAlertsQueryType.ERROR, [Dataset.TRANSACTIONS]: MEPAlertsQueryType.PERFORMANCE, [Dataset.GENERIC_METRICS]: MEPAlertsQueryType.PERFORMANCE, [Dataset.METRICS]: MEPAlertsQueryType.CRASH_RATE, - [Dataset.SESSIONS]: MEPAlertsQueryType.CRASH_RATE, }; export const AlertWizardAlertNames: Record = { @@ -227,14 +226,12 @@ export const AlertWizardRuleTemplates: Record< }, crash_free_sessions: { aggregate: SessionsAggregate.CRASH_FREE_SESSIONS, - // TODO(scttcper): Use Dataset.Metric on GA of alert-crash-free-metrics - dataset: Dataset.SESSIONS, + dataset: Dataset.METRICS, eventTypes: EventTypes.SESSION, }, crash_free_users: { aggregate: SessionsAggregate.CRASH_FREE_USERS, - // TODO(scttcper): Use Dataset.Metric on GA of alert-crash-free-metrics - dataset: Dataset.SESSIONS, + dataset: Dataset.METRICS, eventTypes: EventTypes.USER, }, }; diff --git a/static/app/views/alerts/wizard/utils.spec.tsx b/static/app/views/alerts/wizard/utils.spec.tsx index 725f58def65ae..c7cd9c52aa51c 100644 --- a/static/app/views/alerts/wizard/utils.spec.tsx +++ b/static/app/views/alerts/wizard/utils.spec.tsx @@ -75,7 +75,7 @@ describe('Wizard utils', function () { expect( getAlertTypeFromAggregateDataset({ aggregate: SessionsAggregate.CRASH_FREE_SESSIONS, - dataset: Dataset.SESSIONS, + dataset: Dataset.METRICS, }) ).toEqual('crash_free_sessions'); }); @@ -84,7 +84,7 @@ describe('Wizard utils', function () { expect( getAlertTypeFromAggregateDataset({ aggregate: SessionsAggregate.CRASH_FREE_USERS, - dataset: Dataset.SESSIONS, + dataset: Dataset.METRICS, }) ).toEqual('crash_free_users'); });