Skip to content

Commit

Permalink
chore(integrations): Add metrics coverage for unfurl_discover (#78806)
Browse files Browse the repository at this point in the history
Follow-up to #78626
  • Loading branch information
RyanSkonnord authored Oct 10, 2024
1 parent c6ec3ef commit 890e629
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/sentry/integrations/messaging/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
17 changes: 17 additions & 0 deletions src/sentry/integrations/slack/unfurl/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 890e629

Please sign in to comment.