|
| 1 | +import type {SelectValue} from 'sentry/types/core'; |
1 | 2 | import type {EventsStats} from 'sentry/types/organization';
|
| 3 | +import type {QueryFieldValue} from 'sentry/utils/discover/fields'; |
2 | 4 | import {DiscoverDatasets} from 'sentry/utils/discover/types';
|
3 |
| -import {ErrorsConfig} from 'sentry/views/dashboards/datasetConfig/errors'; |
| 5 | +import {AggregationKey, FieldKey} from 'sentry/utils/fields'; |
4 | 6 | import {EventsSearchBar} from 'sentry/views/detectors/datasetConfig/components/eventSearchBar';
|
5 | 7 | import {
|
6 | 8 | getDiscoverSeriesQueryOptions,
|
7 | 9 | transformEventsStatsComparisonSeries,
|
8 | 10 | transformEventsStatsToSeries,
|
9 | 11 | } from 'sentry/views/detectors/datasetConfig/utils/discoverSeries';
|
| 12 | +import {FieldValueKind, type FieldValue} from 'sentry/views/discover/table/types'; |
10 | 13 |
|
11 | 14 | import type {DetectorDatasetConfig} from './base';
|
12 | 15 |
|
13 | 16 | type ErrorsSeriesResponse = EventsStats;
|
14 | 17 |
|
| 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 | + |
15 | 63 | export const DetectorErrorsConfig: DetectorDatasetConfig<ErrorsSeriesResponse> = {
|
16 |
| - defaultField: ErrorsConfig.defaultField, |
17 |
| - getAggregateOptions: ErrorsConfig.getTableFieldOptions, |
| 64 | + defaultField: DEFAULT_FIELD, |
| 65 | + getAggregateOptions: () => AGGREGATE_OPTIONS, |
18 | 66 | SearchBar: EventsSearchBar,
|
19 | 67 | getSeriesQueryOptions: options =>
|
20 | 68 | getDiscoverSeriesQueryOptions({
|
|
0 commit comments