@@ -6,7 +6,8 @@ import {ComboBox} from 'sentry/components/comboBox';
6
6
import type { ComboBoxOption } from 'sentry/components/comboBox/types' ;
7
7
import type { SelectOption } from 'sentry/components/compactSelect' ;
8
8
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' ;
10
11
import { t } from 'sentry/locale' ;
11
12
import { space } from 'sentry/styles/space' ;
12
13
import type { MetricMeta , MetricsOperation , MRI } from 'sentry/types' ;
@@ -109,9 +110,15 @@ export const QueryBuilder = memo(function QueryBuilder({
109
110
[ projectIds , projects ]
110
111
) ;
111
112
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 ] ) ;
115
122
116
123
const displayedMetrics = useMemo ( ( ) => {
117
124
const isSelected = ( metric : MetricMeta ) => metric . mri === metricsQuery . mri ;
@@ -196,7 +203,10 @@ export const QueryBuilder = memo(function QueryBuilder({
196
203
( query : string ) => {
197
204
trackAnalytics ( 'ddm.widget.filter' , { organization} ) ;
198
205
incrementQueryMetric ( 'ddm.widget.filter' , { query} ) ;
199
- onChange ( { query} ) ;
206
+
207
+ onChange ( {
208
+ query,
209
+ } ) ;
200
210
} ,
201
211
[ incrementQueryMetric , onChange , organization ]
202
212
) ;
@@ -287,10 +297,10 @@ export const QueryBuilder = memo(function QueryBuilder({
287
297
multiple
288
298
size = "md"
289
299
triggerProps = { { prefix : t ( 'Group by' ) } }
290
- options = { tags . map ( tag => ( {
300
+ options = { groupByOptions . map ( tag => ( {
291
301
label : tag . key ,
292
302
value : tag . key ,
293
- trailingItems : (
303
+ trailingItems : tag . trailingItems ?? (
294
304
< Fragment >
295
305
{ tag . key === 'release' && < IconReleases size = "xs" /> }
296
306
{ tag . key === 'transaction' && < IconLightning size = "xs" /> }
@@ -317,6 +327,22 @@ export const QueryBuilder = memo(function QueryBuilder({
317
327
) ;
318
328
} ) ;
319
329
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
+
320
346
const CustomMetricInfoText = styled ( 'span' ) `
321
347
color: ${ p => p . theme . subText } ;
322
348
` ;
0 commit comments