diff --git a/src/sentry/integrations/slack/message_builder/prompt.py b/src/sentry/integrations/slack/message_builder/prompt.py index d7436dc21373ca..02421ccecc6532 100644 --- a/src/sentry/integrations/slack/message_builder/prompt.py +++ b/src/sentry/integrations/slack/message_builder/prompt.py @@ -4,7 +4,7 @@ from .base.block import BlockSlackMessageBuilder -LINK_IDENTITY_MESSAGE = "Link your Slack identity to Sentry to unfurl Discover charts." +LINK_IDENTITY_MESSAGE = "Link your Slack identity to Sentry to unfurl charts." class SlackPromptLinkMessageBuilder(BlockSlackMessageBuilder): diff --git a/src/sentry/integrations/slack/requests/event.py b/src/sentry/integrations/slack/requests/event.py index 6a3e4f31b0c25a..f29d1463cb51bd 100644 --- a/src/sentry/integrations/slack/requests/event.py +++ b/src/sentry/integrations/slack/requests/event.py @@ -40,6 +40,10 @@ def has_explore_links(links: list[str]) -> bool: return any(match_link(link)[0] == LinkType.EXPLORE for link in links) +def has_dashboard_links(links: list[str]) -> bool: + return any(match_link(link)[0] == LinkType.DASHBOARDS for link in links) + + def is_event_challenge(data: Mapping[str, Any]) -> bool: return data.get("type", "") == "url_verification" @@ -378,7 +382,11 @@ def validate_integration(self) -> None: if (self.text in COMMANDS) or ( self.type == "link_shared" - and (has_discover_links(self.links) or has_explore_links(self.links)) + and ( + has_discover_links(self.links) + or has_explore_links(self.links) + or has_dashboard_links(self.links) + ) ): self._validate_identity() diff --git a/src/sentry/integrations/slack/webhooks/event.py b/src/sentry/integrations/slack/webhooks/event.py index 4d732678273a0b..a4d0d0c69e3b76 100644 --- a/src/sentry/integrations/slack/webhooks/event.py +++ b/src/sentry/integrations/slack/webhooks/event.py @@ -128,7 +128,7 @@ def prompt_link(self, slack_request: SlackDMRequest) -> None: payload = { "channel": slack_request.channel_id, "user": slack_request.user_id, - "text": "Link your Slack identity to Sentry to unfurl Discover charts.", + "text": "Link your Slack identity to Sentry to unfurl charts.", **SlackPromptLinkMessageBuilder(associate_url).as_payload(), } @@ -225,6 +225,7 @@ def _get_unfurlable_links( feature_flag = { LinkType.DISCOVER: "organizations:discover-basic", LinkType.EXPLORE: "organizations:data-browsing-widget-unfurl", + LinkType.DASHBOARDS: "organizations:dashboards-widget-unfurl", }.get(link_type) if ( @@ -244,7 +245,9 @@ def _get_unfurlable_links( sentry_sdk.capture_exception(e) self.prompt_link(slack_request) - lifecycle.record_halt("Discover link requires identity", extra={"url": url}) + lifecycle.record_halt( + f"{link_type.value} link requires identity", extra={"url": url} + ) return {} # Don't unfurl the same thing multiple times diff --git a/tests/sentry/integrations/slack/webhooks/events/test_discover_link_shared.py b/tests/sentry/integrations/slack/webhooks/events/test_discover_link_shared.py index 2b0788e8ba0800..70ba67244a27ca 100644 --- a/tests/sentry/integrations/slack/webhooks/events/test_discover_link_shared.py +++ b/tests/sentry/integrations/slack/webhooks/events/test_discover_link_shared.py @@ -158,10 +158,7 @@ def test_share_discover_links_unlinked_user_sdk(self) -> None: blocks = orjson.loads(data["blocks"]) assert blocks[0]["type"] == "section" - assert ( - blocks[0]["text"]["text"] - == "Link your Slack identity to Sentry to unfurl Discover charts." - ) + assert blocks[0]["text"]["text"] == "Link your Slack identity to Sentry to unfurl charts." assert blocks[1]["type"] == "actions" assert len(blocks[1]["elements"]) == 2 diff --git a/tests/sentry/integrations/slack/webhooks/events/test_explore_link_shared.py b/tests/sentry/integrations/slack/webhooks/events/test_explore_link_shared.py index ec7e6eba104ace..92773b5f7cd6a8 100644 --- a/tests/sentry/integrations/slack/webhooks/events/test_explore_link_shared.py +++ b/tests/sentry/integrations/slack/webhooks/events/test_explore_link_shared.py @@ -98,10 +98,7 @@ def test_share_explore_links_unlinked_user(self) -> None: blocks = orjson.loads(data["blocks"]) assert blocks[0]["type"] == "section" - assert ( - blocks[0]["text"]["text"] - == "Link your Slack identity to Sentry to unfurl Discover charts." - ) + assert blocks[0]["text"]["text"] == "Link your Slack identity to Sentry to unfurl charts." assert blocks[1]["type"] == "actions" assert len(blocks[1]["elements"]) == 2