Skip to content
Draft
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
8 changes: 6 additions & 2 deletions src/sentry/issues/highlights.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class HighlightPreset(TypedDict):
DEFAULT_HIGHLIGHT_CTX = {"trace": ["trace_id"]}

MOBILE_HIGHLIGHTS: HighlightPreset = {
"tags": DEFAULT_HIGHLIGHT_TAGS + ["mobile", "main_thread"],
"context": {**DEFAULT_HIGHLIGHT_CTX, "profile": ["profile_id"], "app": ["name"]},
"tags": DEFAULT_HIGHLIGHT_TAGS + ["device.class", "release", "main_thread", "user"],
"context": {
"device": ["low_memory", "locale"],
"app": ["in_foreground"],
"user": ["geo.country_code"],
},
}
FALLBACK_HIGHLIGHTS: HighlightPreset = {
"tags": DEFAULT_HIGHLIGHT_TAGS + ["url"],
Expand Down
29 changes: 29 additions & 0 deletions tests/sentry/core/endpoints/test_project_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,35 @@ def test_highlight_preset(self) -> None:
assert resp.data["highlightContext"] == expected_preset["context"]
assert resp.data["highlightTags"] == expected_preset["tags"]

def test_highlight_preset_mobile(self) -> None:
# Test mobile platform gets mobile-specific highlights
mobile_project = self.create_project(platform="react-native")
resp = self.get_success_response(mobile_project.organization.slug, mobile_project.slug)
expected_preset = get_highlight_preset_for_project(mobile_project)

# Verify mobile-specific tags are included
assert "device.class" in expected_preset["tags"]
assert "release" in expected_preset["tags"]
assert "main_thread" in expected_preset["tags"]
assert "user" in expected_preset["tags"]

# Verify mobile-specific context keys are included
assert "device" in expected_preset["context"]
assert "low_memory" in expected_preset["context"]["device"]
assert "locale" in expected_preset["context"]["device"]
assert "app" in expected_preset["context"]
assert "in_foreground" in expected_preset["context"]["app"]
assert "user" in expected_preset["context"]
assert "geo.country_code" in expected_preset["context"]["user"]

# Verify removed items are not present
assert "trace" not in expected_preset["context"]
assert "profile" not in expected_preset["context"]

assert resp.data["highlightPreset"] == expected_preset
assert resp.data["highlightContext"] == expected_preset["context"]
assert resp.data["highlightTags"] == expected_preset["tags"]

def test_is_dynamically_sampled_pan_rate(self) -> None:
# test with feature flags disabled
with self.feature("organizations:dynamic-sampling"):
Expand Down
Loading