Skip to content

Commit 99b8097

Browse files
authored
feat(metrics): group by tag warning icon (#68982)
1 parent 91712ae commit 99b8097

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

static/app/views/metrics/queryBuilder.tsx

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {ComboBox} from 'sentry/components/comboBox';
66
import type {ComboBoxOption} from 'sentry/components/comboBox/types';
77
import type {SelectOption} from 'sentry/components/compactSelect';
88
import {CompactSelect} from 'sentry/components/compactSelect';
9-
import {IconLightning, IconReleases} from 'sentry/icons';
9+
import {Tooltip} from 'sentry/components/tooltip';
10+
import {IconLightning, IconReleases, IconWarning} from 'sentry/icons';
1011
import {t} from 'sentry/locale';
1112
import {space} from 'sentry/styles/space';
1213
import type {MetricMeta, MetricsOperation, MRI} from 'sentry/types';
@@ -109,9 +110,15 @@ export const QueryBuilder = memo(function QueryBuilder({
109110
[projectIds, projects]
110111
);
111112

112-
const tags = useMemo(() => {
113-
return uniqBy(tagsData, 'key');
114-
}, [tagsData]);
113+
const groupByOptions = useMemo(() => {
114+
return uniqBy(tagsData, 'key').map(tag => ({
115+
key: tag.key,
116+
// So that we don't have to parse the query to determine if the tag is used
117+
trailingItems: metricsQuery.query?.includes(`${tag.key}:`) ? (
118+
<TagWarningIcon />
119+
) : undefined,
120+
}));
121+
}, [tagsData, metricsQuery.query]);
115122

116123
const displayedMetrics = useMemo(() => {
117124
const isSelected = (metric: MetricMeta) => metric.mri === metricsQuery.mri;
@@ -196,7 +203,10 @@ export const QueryBuilder = memo(function QueryBuilder({
196203
(query: string) => {
197204
trackAnalytics('ddm.widget.filter', {organization});
198205
incrementQueryMetric('ddm.widget.filter', {query});
199-
onChange({query});
206+
207+
onChange({
208+
query,
209+
});
200210
},
201211
[incrementQueryMetric, onChange, organization]
202212
);
@@ -287,10 +297,10 @@ export const QueryBuilder = memo(function QueryBuilder({
287297
multiple
288298
size="md"
289299
triggerProps={{prefix: t('Group by')}}
290-
options={tags.map(tag => ({
300+
options={groupByOptions.map(tag => ({
291301
label: tag.key,
292302
value: tag.key,
293-
trailingItems: (
303+
trailingItems: tag.trailingItems ?? (
294304
<Fragment>
295305
{tag.key === 'release' && <IconReleases size="xs" />}
296306
{tag.key === 'transaction' && <IconLightning size="xs" />}
@@ -317,6 +327,22 @@ export const QueryBuilder = memo(function QueryBuilder({
317327
);
318328
});
319329

330+
function TagWarningIcon() {
331+
return (
332+
<TooltipIconWrapper>
333+
<Tooltip
334+
title={t('This tag appears in filter conditions, some groups may be omitted.')}
335+
>
336+
<IconWarning size="xs" color="warning" />
337+
</Tooltip>
338+
</TooltipIconWrapper>
339+
);
340+
}
341+
342+
const TooltipIconWrapper = styled('span')`
343+
margin-top: ${space(0.25)};
344+
`;
345+
320346
const CustomMetricInfoText = styled('span')`
321347
color: ${p => p.theme.subText};
322348
`;

0 commit comments

Comments
 (0)