@@ -5,10 +5,13 @@ import {Switch} from 'sentry/components/core/switch';
5
5
import { Tooltip } from 'sentry/components/core/tooltip' ;
6
6
import { t } from 'sentry/locale' ;
7
7
import { defined } from 'sentry/utils' ;
8
+ import { trackAnalytics } from 'sentry/utils/analytics' ;
9
+ import useOrganization from 'sentry/utils/useOrganization' ;
8
10
import usePageFilters from 'sentry/utils/usePageFilters' ;
9
11
import usePrevious from 'sentry/utils/usePrevious' ;
10
12
import { useLogsPageData } from 'sentry/views/explore/contexts/logs/logsPageData' ;
11
13
import {
14
+ useLogsAnalyticsPageSource ,
12
15
useLogsAutoRefresh ,
13
16
useLogsGroupBy ,
14
17
useLogsRefreshInterval ,
@@ -35,6 +38,8 @@ interface AutorefreshToggleProps {
35
38
export function AutorefreshToggle ( {
36
39
disabled : externallyDisabled ,
37
40
} : AutorefreshToggleProps ) {
41
+ const organization = useOrganization ( ) ;
42
+ const analyticsPageSource = useLogsAnalyticsPageSource ( ) ;
38
43
const checked = useLogsAutoRefresh ( ) ;
39
44
const setChecked = useSetLogsAutoRefresh ( ) ;
40
45
const sortBys = useLogsSortBys ( ) ;
@@ -113,8 +118,17 @@ export function AutorefreshToggle({
113
118
const timeSinceStart = Date . now ( ) - intervalStartTime . current ;
114
119
115
120
// Check if we've exceeded the absolute max timeout
116
- return timeSinceStart > ABSOLUTE_MAX_AUTO_REFRESH_TIME_MS ;
117
- } , [ ] ) ;
121
+ const hasTimedOut = timeSinceStart > ABSOLUTE_MAX_AUTO_REFRESH_TIME_MS ;
122
+
123
+ if ( hasTimedOut ) {
124
+ trackAnalytics ( 'logs.auto_refresh.timeout' , {
125
+ organization,
126
+ page_source : analyticsPageSource ,
127
+ } ) ;
128
+ }
129
+
130
+ return hasTimedOut ;
131
+ } , [ organization , analyticsPageSource ] ) ;
118
132
119
133
// Our querying is currently at 5000 max logs per page, and our default refresh interval is 5 seconds.
120
134
// This means each page if at it's max logs, we're getting 1000 logs per second.
@@ -273,11 +287,19 @@ export function AutorefreshToggle({
273
287
}
274
288
checked = { checked }
275
289
onChange = { ( ) => {
290
+ const newChecked = ! checked ;
291
+
292
+ trackAnalytics ( 'logs.auto_refresh.toggled' , {
293
+ enabled : newChecked ,
294
+ organization,
295
+ page_source : analyticsPageSource ,
296
+ } ) ;
297
+
276
298
if ( ! checked ) {
277
299
// When enabling auto-refresh, reset the disable reason
278
300
setDisableReason ( undefined ) ;
279
301
}
280
- setChecked ( ! checked ) ;
302
+ setChecked ( newChecked ) ;
281
303
} }
282
304
/>
283
305
</ Tooltip >
0 commit comments