Skip to content

Commit 6ecd14b

Browse files
ArthurKnausmatejminar
authored andcommitted
feat(metrics): Show custom tags first (#68963)
- closes #68876 --------- Co-authored-by: Matej Minar <[email protected]>
1 parent b4c0863 commit 6ecd14b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

static/app/views/metrics/metricListItemDetails.tsx

+21-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import useOrganization from 'sentry/utils/useOrganization';
1919
const MAX_PROJECTS_TO_SHOW = 3;
2020
const MAX_TAGS_TO_SHOW = 5;
2121

22+
const STANDARD_TAGS = ['release', 'environment', 'transaction'];
23+
2224
export function MetricListItemDetails({
2325
metric,
2426
selectedProjects,
@@ -66,7 +68,25 @@ export function MetricListItemDetails({
6668
);
6769

6870
const truncatedProjects = metricProjects.slice(0, MAX_PROJECTS_TO_SHOW);
69-
const truncatedTags = tagsData.slice(0, MAX_TAGS_TO_SHOW);
71+
// Display custom tags first, then sort alphabetically
72+
const sortedTags = useMemo(
73+
() =>
74+
tagsData.toSorted((a, b) => {
75+
const aIsStandard = STANDARD_TAGS.includes(a.key);
76+
const bIsStandard = STANDARD_TAGS.includes(b.key);
77+
78+
if (aIsStandard && !bIsStandard) {
79+
return 1;
80+
}
81+
if (!aIsStandard && bIsStandard) {
82+
return -1;
83+
}
84+
85+
return a.key.localeCompare(b.key);
86+
}),
87+
[tagsData]
88+
);
89+
const truncatedTags = sortedTags.slice(0, MAX_TAGS_TO_SHOW);
7090

7191
return (
7292
<DetailsWrapper>

0 commit comments

Comments
 (0)