Skip to content

Commit c65fb5f

Browse files
authored
fix(aci): Fix bug where issue detail links weren't working (#102491)
# Description We were previously only check for alertRule information, but if we create a monitor only using the new api, there isn't a back reference to it. This will look at the occurrence and ensure it's a metric issue, then determine if it's a legacy or new alert before constructing the link, it prefers the legacy routing for now.
1 parent 66de818 commit c65fb5f

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

static/app/views/issueDetails/streamline/sidebar/detectorSection.tsx

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {Organization} from 'sentry/types/organization';
99
import type {Project} from 'sentry/types/project';
1010
import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
1111
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
12+
import {makeMonitorDetailsPathname} from 'sentry/views/detectors/pathnames';
1213
import {useIssueDetails} from 'sentry/views/issueDetails/streamline/context';
1314
import {SidebarSectionTitle} from 'sentry/views/issueDetails/streamline/sidebar/sidebar';
1415

@@ -34,18 +35,36 @@ export function getDetectorDetails({
3435
* for Alert Rule IDs. Hopefully we can consolidate this when we move to the detector system.
3536
* Ideally, this function wouldn't even check the event, but rather the group/issue.
3637
*/
37-
const metricAlertRuleId =
38-
event?.occurrence?.evidenceData?.alertId ||
39-
event?.contexts?.metric_alert?.alert_rule_id;
40-
if (metricAlertRuleId) {
38+
const isMetricAlert =
39+
!!event?.occurrence?.evidenceData?.alertId ||
40+
!!event?.contexts?.metric_alert?.alert_rule_id ||
41+
event?.occurrence?.type === 8001; // the issue type for metric issues is 8001
42+
43+
if (isMetricAlert) {
44+
const metricAlertRuleId =
45+
event?.occurrence?.evidenceData?.alertId ||
46+
event?.contexts?.metric_alert?.alert_rule_id;
47+
48+
if (metricAlertRuleId) {
49+
return {
50+
detectorType: 'metric_alert',
51+
detectorId: metricAlertRuleId,
52+
detectorPath: makeAlertsPathname({
53+
path: `/rules/details/${metricAlertRuleId}/`,
54+
organization,
55+
}),
56+
// TODO(issues): We can probably enrich this description with details from the alert itself.
57+
description: t(
58+
'This issue was created by a metric alert detector. View the detector details to learn more.'
59+
),
60+
};
61+
}
62+
63+
const detectorId = event.occurrence?.evidenceData.detectorId;
4164
return {
4265
detectorType: 'metric_alert',
43-
detectorId: metricAlertRuleId,
44-
detectorPath: makeAlertsPathname({
45-
path: `/rules/details/${metricAlertRuleId}/`,
46-
organization,
47-
}),
48-
// TODO(issues): We can probably enrich this description with details from the alert itself.
66+
detectorId,
67+
detectorPath: makeMonitorDetailsPathname(organization.slug, detectorId, 'monitors'),
4968
description: t(
5069
'This issue was created by a metric alert detector. View the detector details to learn more.'
5170
),

0 commit comments

Comments
 (0)