Repository navigation
Conversation
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.
a8117a3 to
974e70a
Compare
|
bugbot review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 974e70a. Configure here.
There was a problem hiding this comment.
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¬ification_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¬ification_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.


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/IncidentIDs 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.