Просмотр исходного кода

feat(workflow): Add referrer to slack incident links (#35199)

Scott Cooper 2 лет назад
Родитель
Сommit
105e246efb

+ 3 - 1
src/sentry/integrations/slack/message_builder/incidents.py

@@ -52,5 +52,7 @@ class SlackIncidentsMessageBuilder(BlockSlackMessageBuilder):
             blocks.append(self.get_image_block(self.chart_url, alt="Metric Alert Chart"))
 
         color = LEVEL_TO_COLOR.get(INCIDENT_COLOR_MAPPING.get(data["status"], ""))
-        fallback_text = f"<{data['title_link']}|*{escape_slack_text(data['title'])}*>"
+        fallback_text = (
+            f"<{data['title_link']}&referrer=slack|*{escape_slack_text(data['title'])}*>"
+        )
         return self._build_blocks(*blocks, fallback_text=fallback_text, color=color)

+ 3 - 3
tests/sentry/integrations/slack/test_message_builder.py

@@ -159,7 +159,7 @@ class BuildIncidentAttachmentTest(TestCase):
                     },
                 )
             )
-            + f"?alert={incident.identifier}"
+            + f"?alert={incident.identifier}&referrer=slack"
         )
         assert SlackIncidentsMessageBuilder(incident, IncidentStatus.CLOSED).build() == {
             "blocks": [
@@ -199,7 +199,7 @@ class BuildIncidentAttachmentTest(TestCase):
                     },
                 )
             )
-            + f"?alert={incident.identifier}"
+            + f"?alert={incident.identifier}&referrer=slack"
         )
         # This should fail because it pulls status from `action` instead of `incident`
         assert SlackIncidentsMessageBuilder(
@@ -239,7 +239,7 @@ class BuildIncidentAttachmentTest(TestCase):
                     },
                 )
             )
-            + f"?alert={incident.identifier}"
+            + f"?alert={incident.identifier}&referrer=slack"
         )
         assert SlackIncidentsMessageBuilder(
             incident, IncidentStatus.CLOSED, chart_url="chart-url"