Skip to content

fix(aci): Link metric alert notifications to the metric issue - #131012

Draft
kcons wants to merge 3 commits into
masterfrom
kcons/nooldlonk
Draft

kcons wants to merge 3 commits into
masterfrom
kcons/nooldlonk

Conversation

@kcons

@kcons kcons commented Nov 12, 2026

Copy link
Copy Markdown
Member

Metric alert notifications (Slack, Discord, MS Teams, PagerDuty, Opsgenie, Sentry apps) now link directly to the metric issue and open period, instead of a legacy alert rule URL built from deprecated AlertRule/Incident IDs that only worked via a frontend redirect.

Click tracking still counts these links as alert clicks. Existing links in old notifications keep working through the legacy redirect.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 12, 2026
Metric alert notification links were built from legacy AlertRule and Incident IDs and relied on a frontend redirect to reach the issue. Link directly to the metric issue and open period instead.
@kcons

kcons commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 974e70a. Configure here.

return NotificationLink.ISSUE_WITH_SEER
# Metric alert notifications link to the metric issue rather than the monitor.
if query.get("referrer", [""])[0].startswith("metric_alert"):
return NotificationLink.ALERT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click tracking misclassifies metric alert links

Medium Severity

classify_link treats an issue URL as an alert only when referrer starts with metric_alert. Notification-platform decoration rewrites that query param to metric-alert-{provider} before the user clicks, so page-load tracking records issue while send-time classification recorded alert. Click-through for these notifications will not match.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 974e70a. Configure here.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link change itself looks right. The new URL matches what the frontend redirect in workflowEngineRedirects.tsx already builds (/issues/<group>/?…&openPeriod=<id>), and it matches the email path, which already links to the issue with openPeriod. Dropping the AlertRuleDetector/IncidentGroupOpenPeriod lookups also removes two queries per notification.

One thing to fix before this lands. The new classify_link branch in notifications/platform/tracking.py only matches the undecorated referrer, so a click on the link gets counted as an issue click, not an alert click.

NotificationLinkDecorator.decorate_url calls classify_link on the raw URL (referrer=metric_alert_slack), which gives ALERT. Then it replaces referrer with <source>-<provider>. For metric alerts that is metric-alert-slack, because NotificationSource.METRIC_ALERT == "metric-alert". On click, notification_tracking middleware runs classify_link(request.get_full_path()) on the decorated URL. "metric-alert-slack".startswith("metric_alert") is false, so the click comes back as ISSUE. I checked locally on this branch:

classify_link(".../issues/1/?referrer=metric_alert_slack&openPeriod=5")   -> alert
classify_link(".../issues/1/?openPeriod=5&referrer=metric-alert-slack&notification_uuid=x") -> issue

Before this PR the link went to /alerts/rules/details/…, which the path check classifies as ALERT on both sides. So this breaks the "click tracking still counts these as alert clicks" claim for Discord and MS Teams, where the metric alert renderers decorate title_link. The page-load dedupe key also includes link, so the sent and clicked kinds stop lining up.

To fix it, also match the decorated form, e.g. parse_referrer(...) returning source == NotificationSource.METRIC_ALERT, or a prefix check on f"{NotificationSource.METRIC_ALERT}-". Then add a decorated-URL case (referrer=metric-alert-discord&notification_uuid=…) to the test_tracking.py parametrization next to the one you added.

Link decoration rewrites the referrer to metric-alert-<provider>, so clicks on metric issue links were classified as issue clicks while sends were classified as alert links.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant