1
1
import { useEffect , useRef } from 'react' ;
2
2
import * as Sentry from '@sentry/react' ;
3
3
4
+ import { useOrganizationSeerSetup } from 'sentry/components/events/autofix/useOrganizationSeerSetup' ;
4
5
import { defined } from 'sentry/utils' ;
5
6
import { trackAnalytics } from 'sentry/utils/analytics' ;
6
7
import type { LogsAnalyticsPageSource } from 'sentry/utils/analytics/logsAnalyticsEvent' ;
@@ -86,18 +87,30 @@ function useTrackAnalytics({
86
87
const chartError = timeseriesResult . error ?. message ?? '' ;
87
88
const query_status = tableError || chartError ? 'error' : 'success' ;
88
89
90
+ const { setupAcknowledgement : seerSetup , isLoading : isLoadingSeerSetup } =
91
+ useOrganizationSeerSetup ( {
92
+ enabled : ! organization . hideAiFeatures ,
93
+ } ) ;
94
+
89
95
useEffect ( ( ) => {
90
96
if (
91
97
queryType !== 'aggregate' ||
92
98
aggregatesTableResult . result . isPending ||
93
99
timeseriesResult . isPending ||
94
- isLoadingSubscriptionDetails
100
+ isLoadingSubscriptionDetails ||
101
+ isLoadingSeerSetup
95
102
) {
96
103
return ;
97
104
}
98
105
99
106
const search = new MutableSearch ( query ) ;
100
107
const columns = aggregatesTableResult . eventView . getColumns ( ) as unknown as string [ ] ;
108
+ const gaveSeerConsent = organization . hideAiFeatures
109
+ ? 'gen_ai_features_disabled'
110
+ : seerSetup ?. orgHasAcknowledged
111
+ ? 'given'
112
+ : 'not_given' ;
113
+
101
114
trackAnalytics ( 'trace.explorer.metadata' , {
102
115
organization,
103
116
dataset,
@@ -122,6 +135,7 @@ function useTrackAnalytics({
122
135
has_exceeded_performance_usage_limit : hasExceededPerformanceUsageLimit ,
123
136
page_source,
124
137
interval,
138
+ gave_seer_consent : gaveSeerConsent ,
125
139
} ) ;
126
140
127
141
/* eslint-disable @typescript-eslint/no-base-to-string */
@@ -139,43 +153,51 @@ function useTrackAnalytics({
139
153
visualizes_count: ${ String ( String ( visualizes ) . length ) }
140
154
has_exceeded_performance_usage_limit: ${ String ( hasExceededPerformanceUsageLimit ) }
141
155
page_source: ${ page_source }
156
+ gave_seer_consent: ${ gaveSeerConsent }
142
157
` ,
143
158
{ isAnalytics : true }
144
159
) ;
145
160
/* eslint-enable @typescript-eslint/no-base-to-string */
146
161
} , [
147
- organization ,
148
- dataset ,
149
- fields ,
150
- query ,
151
- visualizes ,
152
- title ,
153
- queryType ,
154
- aggregatesTableResult . result . isPending ,
155
- aggregatesTableResult . result . status ,
156
- aggregatesTableResult . result . data ?. length ,
157
162
aggregatesTableResult . eventView ,
158
- timeseriesResult . isPending ,
159
- timeseriesResult . data ,
163
+ aggregatesTableResult . result . data ?. length ,
164
+ aggregatesTableResult . result . isPending ,
165
+ dataset ,
160
166
hasExceededPerformanceUsageLimit ,
161
- isLoadingSubscriptionDetails ,
162
- query_status ,
163
- page_source ,
164
167
interval ,
168
+ isLoadingSeerSetup ,
169
+ isLoadingSubscriptionDetails ,
165
170
isTopN ,
171
+ organization ,
172
+ page_source ,
173
+ query ,
174
+ queryType ,
175
+ query_status ,
176
+ seerSetup ?. orgHasAcknowledged ,
177
+ timeseriesResult . data ,
178
+ timeseriesResult . isPending ,
179
+ title ,
180
+ visualizes ,
166
181
] ) ;
167
182
168
183
useEffect ( ( ) => {
169
184
if (
170
185
queryType !== 'samples' ||
171
186
spansTableResult . result . isPending ||
172
187
timeseriesResult . isPending ||
173
- isLoadingSubscriptionDetails
188
+ isLoadingSubscriptionDetails ||
189
+ isLoadingSeerSetup
174
190
) {
175
191
return ;
176
192
}
177
193
178
194
const search = new MutableSearch ( query ) ;
195
+ const gaveSeerConsent = organization . hideAiFeatures
196
+ ? 'gen_ai_features_disabled'
197
+ : seerSetup ?. orgHasAcknowledged
198
+ ? 'given'
199
+ : 'not_given' ;
200
+
179
201
trackAnalytics ( 'trace.explorer.metadata' , {
180
202
organization,
181
203
dataset,
@@ -200,6 +222,7 @@ function useTrackAnalytics({
200
222
has_exceeded_performance_usage_limit : hasExceededPerformanceUsageLimit ,
201
223
page_source,
202
224
interval,
225
+ gave_seer_consent : gaveSeerConsent ,
203
226
} ) ;
204
227
205
228
info ( fmt `trace.explorer.metadata:
@@ -215,26 +238,28 @@ function useTrackAnalytics({
215
238
visualizes_count: ${ String ( visualizes . length ) }
216
239
has_exceeded_performance_usage_limit: ${ String ( hasExceededPerformanceUsageLimit ) }
217
240
page_source: ${ page_source }
241
+ gave_seer_consent: ${ gaveSeerConsent }
218
242
` ) ;
219
243
} , [
220
- organization ,
221
244
dataset ,
222
245
fields ,
246
+ hasExceededPerformanceUsageLimit ,
247
+ interval ,
248
+ isLoadingSeerSetup ,
249
+ isLoadingSubscriptionDetails ,
250
+ isTopN ,
251
+ organization ,
252
+ page_source ,
223
253
query ,
224
- visualizes ,
225
- title ,
226
254
queryType ,
227
- spansTableResult . result . isPending ,
228
- spansTableResult . result . status ,
255
+ query_status ,
256
+ seerSetup ?. orgHasAcknowledged ,
229
257
spansTableResult . result . data ?. length ,
230
- timeseriesResult . isPending ,
258
+ spansTableResult . result . isPending ,
231
259
timeseriesResult . data ,
232
- hasExceededPerformanceUsageLimit ,
233
- isLoadingSubscriptionDetails ,
234
- query_status ,
235
- page_source ,
236
- interval ,
237
- isTopN ,
260
+ timeseriesResult . isPending ,
261
+ title ,
262
+ visualizes ,
238
263
] ) ;
239
264
240
265
const tracesTableResultDefined = defined ( tracesTableResult ) ;
@@ -245,7 +270,8 @@ function useTrackAnalytics({
245
270
queryType !== 'traces' ||
246
271
tracesTableResult . result . isPending ||
247
272
timeseriesResult . isPending ||
248
- isLoadingSubscriptionDetails
273
+ isLoadingSubscriptionDetails ||
274
+ isLoadingSeerSetup
249
275
) {
250
276
return ;
251
277
}
@@ -262,6 +288,11 @@ function useTrackAnalytics({
262
288
const resultMissingRoot =
263
289
tracesTableResult ?. result ?. data ?. data ?. filter ( trace => ! defined ( trace . name ) )
264
290
. length ?? 0 ;
291
+ const gaveSeerConsent = organization . hideAiFeatures
292
+ ? 'gen_ai_features_disabled'
293
+ : seerSetup ?. orgHasAcknowledged
294
+ ? 'given'
295
+ : 'not_given' ;
265
296
266
297
trackAnalytics ( 'trace.explorer.metadata' , {
267
298
organization,
@@ -287,27 +318,28 @@ function useTrackAnalytics({
287
318
has_exceeded_performance_usage_limit : hasExceededPerformanceUsageLimit ,
288
319
page_source,
289
320
interval,
321
+ gave_seer_consent : gaveSeerConsent ,
290
322
} ) ;
291
323
} , [
292
- organization ,
293
324
dataset ,
294
- fields ,
295
- query ,
296
- visualizes ,
297
- title ,
298
- queryType ,
299
- tracesTableResult ?. result . isPending ,
300
- tracesTableResult ?. result . status ,
301
- tracesTableResult ?. result . data ?. data ,
302
- timeseriesResult . isPending ,
303
- timeseriesResult . data ,
304
325
hasExceededPerformanceUsageLimit ,
326
+ interval ,
327
+ isLoadingSeerSetup ,
305
328
isLoadingSubscriptionDetails ,
306
- query_status ,
329
+ isTopN ,
330
+ organization ,
307
331
page_source ,
332
+ query ,
333
+ queryType ,
334
+ query_status ,
335
+ seerSetup ?. orgHasAcknowledged ,
336
+ timeseriesResult . data ,
337
+ timeseriesResult . isPending ,
338
+ title ,
339
+ tracesTableResult ?. result . data ?. data ,
340
+ tracesTableResult ?. result . isPending ,
308
341
tracesTableResultDefined ,
309
- interval ,
310
- isTopN ,
342
+ visualizes ,
311
343
] ) ;
312
344
}
313
345
0 commit comments