@@ -3,7 +3,7 @@ import type {PageFilters} from 'sentry/types/core';
3
3
import { encodeSort } from 'sentry/utils/discover/eventView' ;
4
4
import type { Sort } from 'sentry/utils/discover/fields' ;
5
5
import { DiscoverDatasets } from 'sentry/utils/discover/types' ;
6
- import { useApiQuery } from 'sentry/utils/queryClient' ;
6
+ import { useApiQuery , type UseApiQueryOptions } from 'sentry/utils/queryClient' ;
7
7
import type { MutableSearch } from 'sentry/utils/tokenizeSearch' ;
8
8
import useOrganization from 'sentry/utils/useOrganization' ;
9
9
import usePageFilters from 'sentry/utils/usePageFilters' ;
@@ -48,6 +48,10 @@ interface UseFetchEventsTimeSeriesOptions<YAxis, Attribute> {
48
48
* Query to apply to the data set. Can be either a `MutableSearch` object (preferred) or a plain string.
49
49
*/
50
50
query ?: MutableSearch | string ;
51
+ /**
52
+ * Options to pass to `useApiQuery`
53
+ */
54
+ queryOptions ?: Partial < UseApiQueryOptions < EventsTimeSeriesResponse > > ;
51
55
/**
52
56
* Sampling mode. Only specify this if you're sure you require a specific sampling mode. In most cases, the backend will automatically decide this.
53
57
*/
@@ -78,27 +82,31 @@ export function useFetchSpanTimeSeries<
78
82
*/
79
83
export function useFetchEventsTimeSeries < YAxis extends string , Attribute extends string > (
80
84
dataset : DiscoverDatasets ,
81
- {
85
+ options : UseFetchEventsTimeSeriesOptions < YAxis , Attribute > ,
86
+ referrer : string
87
+ ) {
88
+ const {
82
89
yAxis,
83
90
excludeOther,
84
91
enabled,
85
92
groupBy,
86
- interval,
87
93
query,
88
94
sampling,
89
95
pageFilters,
90
96
sort,
91
97
topEvents,
92
- } : UseFetchEventsTimeSeriesOptions < YAxis , Attribute > ,
93
- referrer : string
94
- ) {
98
+ } = options ;
99
+
95
100
const organization = useOrganization ( ) ;
96
101
97
102
const { isReady : arePageFiltersReady , selection : defaultSelection } = usePageFilters ( ) ;
98
103
99
104
const hasCustomPageFilters = Boolean ( pageFilters ) ;
100
105
const selection = pageFilters ?? defaultSelection ;
101
106
107
+ const interval =
108
+ options . interval ?? getIntervalForTimeSeriesQuery ( yAxis , selection . datetime ) ;
109
+
102
110
if ( ! referrer ) {
103
111
throw new Error (
104
112
'`useFetchEventsTimeSeries` cannot accept an empty referrer string, please specify a referrer!'
@@ -118,7 +126,7 @@ export function useFetchEventsTimeSeries<YAxis extends string, Attribute extends
118
126
...normalizeDateTimeParams ( selection . datetime ) ,
119
127
project : selection . projects ,
120
128
environment : selection . environments ,
121
- interval : interval ?? getIntervalForTimeSeriesQuery ( yAxis , selection . datetime ) ,
129
+ interval,
122
130
query : query
123
131
? typeof query === 'string'
124
132
? query
@@ -137,6 +145,7 @@ export function useFetchEventsTimeSeries<YAxis extends string, Attribute extends
137
145
retryDelay : getRetryDelay ,
138
146
refetchOnWindowFocus : false ,
139
147
enabled : enabled && ( hasCustomPageFilters ? true : arePageFiltersReady ) ,
148
+ ...options . queryOptions ,
140
149
}
141
150
) ;
142
151
}
0 commit comments