Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sentry/integrations/slack/message_builder/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 9 additions & 1 deletion src/sentry/integrations/slack/requests/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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()

Expand Down
7 changes: 5 additions & 2 deletions src/sentry/integrations/slack/webhooks/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}

Expand Down Expand Up @@ -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 (
Expand All @@ -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}
)
Comment thread
cursor[bot] marked this conversation as resolved.
return {}

# Don't unfurl the same thing multiple times
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading