@@ -25,6 +25,11 @@ import {
25
25
updateLocationWithAggregateSortBys ,
26
26
updateLocationWithLogSortBys ,
27
27
} from 'sentry/views/explore/contexts/logs/sortBys' ;
28
+ import {
29
+ getModeFromLocation ,
30
+ type Mode ,
31
+ updateLocationWithMode ,
32
+ } from 'sentry/views/explore/contexts/pageParamsContext/mode' ;
28
33
import { OurLogKnownFieldKey } from 'sentry/views/explore/logs/types' ;
29
34
import { useLogsQueryKeyWithInfinite } from 'sentry/views/explore/logs/useLogsQuery' ;
30
35
@@ -52,6 +57,7 @@ interface LogsPageParams {
52
57
readonly cursor : string ;
53
58
readonly fields : string [ ] ;
54
59
readonly isTableFrozen : boolean | undefined ;
60
+ readonly mode : Mode ;
55
61
readonly refreshInterval : number ;
56
62
readonly search : MutableSearch ;
57
63
/**
@@ -176,6 +182,7 @@ export function LogsPageParamsProvider({
176
182
...( groupBy ? [ groupBy ] : [ ] ) ,
177
183
aggregate ,
178
184
] ) ;
185
+ const mode = getModeFromLocation ( location ) ;
179
186
const pageFilters = usePageFilters ( ) ;
180
187
const projectIds = isTableFrozen
181
188
? ( limitToProjectIds ?? [ - 1 ] )
@@ -209,6 +216,7 @@ export function LogsPageParamsProvider({
209
216
groupBy,
210
217
aggregateFn,
211
218
aggregateParam,
219
+ mode,
212
220
..._testContext ,
213
221
} }
214
222
>
@@ -238,6 +246,7 @@ function setLogsPageParams(location: Location, pageParams: LogPageParamsUpdate)
238
246
updateNullableLocation ( target , LOGS_GROUP_BY_KEY , pageParams . groupBy ) ;
239
247
updateNullableLocation ( target , LOGS_AGGREGATE_FN_KEY , pageParams . aggregateFn ) ;
240
248
updateNullableLocation ( target , LOGS_AGGREGATE_PARAM_KEY , pageParams . aggregateParam ) ;
249
+ updateLocationWithMode ( target , pageParams . mode ) ; // Can be swapped with updateNullableLocation if we merge page params.
241
250
if ( ! pageParams . isTableFrozen ) {
242
251
updateLocationWithLogSortBys ( target , pageParams . sortBys ) ;
243
252
updateLocationWithAggregateSortBys ( target , pageParams . aggregateSortBys ) ;
@@ -475,6 +484,21 @@ export function useLogsAnalyticsPageSource() {
475
484
return analyticsPageSource ;
476
485
}
477
486
487
+ export function useLogsMode ( ) {
488
+ const { mode} = useLogsPageParams ( ) ;
489
+ return mode ;
490
+ }
491
+
492
+ export function useSetLogsMode ( ) {
493
+ const setPageParams = useSetLogsPageParams ( ) ;
494
+ return useCallback (
495
+ ( mode : Mode ) => {
496
+ setPageParams ( { mode} ) ;
497
+ } ,
498
+ [ setPageParams ]
499
+ ) ;
500
+ }
501
+
478
502
function getLogCursorFromLocation ( location : Location ) : string {
479
503
if ( ! location . query ?. [ LOGS_CURSOR_KEY ] ) {
480
504
return '' ;
0 commit comments