diff --git a/src/sentry/integrations/messaging/metrics.py b/src/sentry/integrations/messaging/metrics.py index f78863c35ccb0..6c0a8e33f0a3b 100644 --- a/src/sentry/integrations/messaging/metrics.py +++ b/src/sentry/integrations/messaging/metrics.py @@ -37,6 +37,7 @@ class MessagingInteractionType(Enum): # Automatic behaviors UNFURL_ISSUES = "UNFURL_ISSUES" UNFURL_METRIC_ALERTS = "UNFURL_METRIC_ALERTS" + UNFURL_DISCOVER = "UNFURL_DISCOVER" def __str__(self) -> str: return self.value.lower() diff --git a/src/sentry/integrations/slack/unfurl/discover.py b/src/sentry/integrations/slack/unfurl/discover.py index 61a2be526cefd..eccb01927e41a 100644 --- a/src/sentry/integrations/slack/unfurl/discover.py +++ b/src/sentry/integrations/slack/unfurl/discover.py @@ -15,9 +15,14 @@ from sentry.charts import backend as charts from sentry.charts.types import ChartType from sentry.discover.arithmetic import is_equation +from sentry.integrations.messaging.metrics import ( + MessagingInteractionEvent, + MessagingInteractionType, +) from sentry.integrations.models.integration import Integration from sentry.integrations.services.integration import integration_service from sentry.integrations.slack.message_builder.discover import SlackDiscoverMessageBuilder +from sentry.integrations.slack.spec import SlackMessagingSpec from sentry.integrations.slack.unfurl.types import Handler, UnfurlableUrl, UnfurledUrl from sentry.models.apikey import ApiKey from sentry.models.organization import Organization @@ -115,6 +120,18 @@ def unfurl_discover( integration: Integration, links: list[UnfurlableUrl], user: User | None = None, +) -> UnfurledUrl: + event = MessagingInteractionEvent( + MessagingInteractionType.UNFURL_DISCOVER, SlackMessagingSpec(), user=user + ) + with event.capture(): + return _unfurl_discover(integration, links, user) + + +def _unfurl_discover( + integration: Integration, + links: list[UnfurlableUrl], + user: User | None = None, ) -> UnfurledUrl: org_integrations = integration_service.get_organization_integrations( integration_id=integration.id