Skip to content

Commit 853cacd

Browse files
authored
fix(aci): Limit error dataset to supported aggregates and fields (#97740)
1 parent 6988558 commit 853cacd

File tree

1 file changed

+51
-3
lines changed
  • static/app/views/detectors/datasetConfig

1 file changed

+51
-3
lines changed

static/app/views/detectors/datasetConfig/errors.tsx

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,68 @@
1+
import type {SelectValue} from 'sentry/types/core';
12
import type {EventsStats} from 'sentry/types/organization';
3+
import type {QueryFieldValue} from 'sentry/utils/discover/fields';
24
import {DiscoverDatasets} from 'sentry/utils/discover/types';
3-
import {ErrorsConfig} from 'sentry/views/dashboards/datasetConfig/errors';
5+
import {AggregationKey, FieldKey} from 'sentry/utils/fields';
46
import {EventsSearchBar} from 'sentry/views/detectors/datasetConfig/components/eventSearchBar';
57
import {
68
getDiscoverSeriesQueryOptions,
79
transformEventsStatsComparisonSeries,
810
transformEventsStatsToSeries,
911
} from 'sentry/views/detectors/datasetConfig/utils/discoverSeries';
12+
import {FieldValueKind, type FieldValue} from 'sentry/views/discover/table/types';
1013

1114
import type {DetectorDatasetConfig} from './base';
1215

1316
type ErrorsSeriesResponse = EventsStats;
1417

18+
const AGGREGATE_OPTIONS: Record<string, SelectValue<FieldValue>> = {
19+
'function:count': {
20+
label: 'count',
21+
value: {
22+
kind: FieldValueKind.FUNCTION,
23+
meta: {
24+
name: 'count',
25+
parameters: [],
26+
},
27+
},
28+
},
29+
'function:count_unique': {
30+
label: 'count_unique',
31+
value: {
32+
kind: FieldValueKind.FUNCTION,
33+
meta: {
34+
name: 'count_unique',
35+
parameters: [
36+
{
37+
kind: 'column',
38+
columnTypes: ['string'],
39+
defaultValue: FieldKey.USER,
40+
required: true,
41+
},
42+
],
43+
},
44+
},
45+
},
46+
'field:user': {
47+
label: 'user',
48+
value: {
49+
kind: FieldValueKind.FIELD,
50+
meta: {
51+
name: FieldKey.USER,
52+
dataType: 'string',
53+
},
54+
},
55+
},
56+
};
57+
58+
const DEFAULT_FIELD: QueryFieldValue = {
59+
function: [AggregationKey.COUNT, '', undefined, undefined],
60+
kind: FieldValueKind.FUNCTION,
61+
};
62+
1563
export const DetectorErrorsConfig: DetectorDatasetConfig<ErrorsSeriesResponse> = {
16-
defaultField: ErrorsConfig.defaultField,
17-
getAggregateOptions: ErrorsConfig.getTableFieldOptions,
64+
defaultField: DEFAULT_FIELD,
65+
getAggregateOptions: () => AGGREGATE_OPTIONS,
1866
SearchBar: EventsSearchBar,
1967
getSeriesQueryOptions: options =>
2068
getDiscoverSeriesQueryOptions({

0 commit comments

Comments
 (0)