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/unfurl/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def map_explore_query_args(url: str, args: Mapping[str, str | None]) -> Mapping[
except (json.JSONDecodeError, TypeError, AttributeError):
pass

visualize_fields = raw_query.getlist("visualize") or raw_query.getlist("aggregateField")
visualize_fields = raw_query.getlist("aggregateField") or raw_query.getlist("visualize")
for field_json in visualize_fields:
try:
parsed = json.loads(field_json)
Expand Down
16 changes: 16 additions & 0 deletions tests/sentry/integrations/slack/test_unfurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,22 @@ def test_unfurl_explore_non_dict_aggregate_field(self) -> None:
assert args is not None
assert args["query"].getlist("yAxis") == ["count(span.duration)"]

def test_unfurl_explore_aggregate_field_takes_precedence_over_visualize(self) -> None:
url = (
"https://sentry.io/organizations/org1/explore/traces/"
"?aggregateField=%7B%22groupBy%22%3A%22gen_ai.tool.name%22%7D"
"&aggregateField=%7B%22yAxes%22%3A%5B%22count(span.duration)%22%5D%2C%22chartType%22%3A0%7D"
"&visualize=%7B%22chartType%22%3A0%2C%22yAxes%22%3A%5B%22count_unique(user.id)%22%5D%7D"
"&project=1&query=user.id%1234&statsPeriod=30d"
)
link_type, args = match_link(url)

assert link_type == LinkType.EXPLORE
assert args is not None
assert args["query"].getlist("yAxis") == ["count(span.duration)"]
assert args["query"].getlist("groupBy") == ["gen_ai.tool.name"]
assert args["chart_type"] == 0

def test_unfurl_explore_multi_aggregate_uses_first_chart(self) -> None:
# Two charts: count with chartType=2 (area, first) and avg (second).
# The unfurl must render only the first chart and not merge avg's
Expand Down
Loading