@@ -108,7 +108,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
108
108
argumentCaptor<MetricEvent >().apply {
109
109
verify(batcher, atLeastOnce()).enqueue(capture())
110
110
assertEventsContainsFieldsAndCount(
111
- allValues, serviceInvocation, 1 ,
111
+ allValues,
112
+ serviceInvocation,
113
+ 1 ,
112
114
" result" to Result .Failed .toString()
113
115
)
114
116
}
@@ -156,15 +158,21 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
156
158
verify(batcher, atLeast(2 + count)).enqueue(capture())
157
159
assertEventsContainsFieldsAndCount(allValues, serviceInvocation, 1 )
158
160
assertEventsContainsFieldsAndCount(
159
- allValues, userModification, 1 ,
161
+ allValues,
162
+ userModification,
163
+ 1 ,
160
164
" codewhispererSessionId" to testSessionId
161
165
)
162
166
assertEventsContainsFieldsAndCount(
163
- allValues, userDecision, 1 ,
167
+ allValues,
168
+ userDecision,
169
+ 1 ,
164
170
codewhispererSuggestionState to CodewhispererSuggestionState .Accept .toString()
165
171
)
166
172
assertEventsContainsFieldsAndCount(
167
- allValues, userDecision, count - 1 ,
173
+ allValues,
174
+ userDecision,
175
+ count - 1 ,
168
176
codewhispererSuggestionState to CodewhispererSuggestionState .Unseen .toString()
169
177
)
170
178
}
@@ -185,15 +193,21 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
185
193
argumentCaptor<MetricEvent >().apply {
186
194
verify(batcher, atLeast(1 + count)).enqueue(capture())
187
195
assertEventsContainsFieldsAndCount(
188
- allValues, serviceInvocation, 1 ,
196
+ allValues,
197
+ serviceInvocation,
198
+ 1 ,
189
199
" result" to Result .Succeeded .toString()
190
200
)
191
201
assertEventsContainsFieldsAndCount(
192
- allValues, userDecision, 1 ,
202
+ allValues,
203
+ userDecision,
204
+ 1 ,
193
205
codewhispererSuggestionState to CodewhispererSuggestionState .Reject .toString()
194
206
)
195
207
assertEventsContainsFieldsAndCount(
196
- allValues, userDecision, count - 1 ,
208
+ allValues,
209
+ userDecision,
210
+ count - 1 ,
197
211
codewhispererSuggestionState to CodewhispererSuggestionState .Unseen .toString()
198
212
)
199
213
}
@@ -206,7 +220,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
206
220
argumentCaptor<MetricEvent >().apply {
207
221
verify(batcher, atLeastOnce()).enqueue(capture())
208
222
assertEventsContainsFieldsAndCount(
209
- allValues, serviceInvocation, 1 ,
223
+ allValues,
224
+ serviceInvocation,
225
+ 1 ,
210
226
" result" to Result .Succeeded .toString()
211
227
)
212
228
}
@@ -232,11 +248,15 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
232
248
argumentCaptor<MetricEvent >().apply {
233
249
verify(batcher, atLeast(1 + count)).enqueue(capture())
234
250
assertEventsContainsFieldsAndCount(
235
- allValues, serviceInvocation, 1 ,
251
+ allValues,
252
+ serviceInvocation,
253
+ 1 ,
236
254
" result" to Result .Succeeded .toString()
237
255
)
238
256
assertEventsContainsFieldsAndCount(
239
- allValues, userDecision, count,
257
+ allValues,
258
+ userDecision,
259
+ count,
240
260
codewhispererSuggestionState to CodewhispererSuggestionState .Discard .toString()
241
261
)
242
262
}
@@ -268,11 +288,15 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
268
288
argumentCaptor<MetricEvent >().apply {
269
289
verify(batcher, atLeast(1 + prefixNotMatchCount)).enqueue(capture())
270
290
assertEventsContainsFieldsAndCount(
271
- allValues, serviceInvocation, 1 ,
291
+ allValues,
292
+ serviceInvocation,
293
+ 1 ,
272
294
" result" to Result .Succeeded .toString()
273
295
)
274
296
assertEventsContainsFieldsAndCount(
275
- allValues, userDecision, prefixNotMatchCount,
297
+ allValues,
298
+ userDecision,
299
+ prefixNotMatchCount,
276
300
codewhispererSuggestionState to CodewhispererSuggestionState .Discard .toString()
277
301
)
278
302
}
@@ -293,7 +317,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
293
317
argumentCaptor<MetricEvent >().apply {
294
318
verify(batcher, atLeastOnce()).enqueue(capture())
295
319
assertEventsContainsFieldsAndCount(
296
- allValues, serviceInvocation, 1 ,
320
+ allValues,
321
+ serviceInvocation,
322
+ 1 ,
297
323
" codewhispererRequestId" to " " ,
298
324
" result" to Result .Failed .toString()
299
325
)
@@ -315,7 +341,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
315
341
argumentCaptor<MetricEvent >().apply {
316
342
verify(batcher, atLeastOnce()).enqueue(capture())
317
343
assertEventsContainsFieldsAndCount(
318
- allValues, serviceInvocation, 1 ,
344
+ allValues,
345
+ serviceInvocation,
346
+ 1 ,
319
347
" codewhispererRequestId" to testRequestIdForCodeWhispererException,
320
348
" result" to Result .Failed .toString()
321
349
)
@@ -332,7 +360,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
332
360
argumentCaptor<MetricEvent >().apply {
333
361
verify(batcher, atLeast(1 + pythonResponse.recommendations().size)).enqueue(capture())
334
362
assertEventsContainsFieldsAndCount(
335
- allValues, userDecision, pythonResponse.recommendations().size,
363
+ allValues,
364
+ userDecision,
365
+ pythonResponse.recommendations().size,
336
366
" codewhispererSuggestionState" to CodewhispererSuggestionState .Filter .toString()
337
367
)
338
368
}
@@ -345,7 +375,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
345
375
verify(batcher, atLeastOnce()).enqueue(capture())
346
376
pythonResponse.recommendations().forEach {
347
377
assertEventsContainsFieldsAndCount(
348
- allValues, userDecision, 1 ,
378
+ allValues,
379
+ userDecision,
380
+ 1 ,
349
381
" codewhispererSuggestionReferences" to Gson ().toJson(it.references().map { ref -> ref.licenseName() }.toSet()),
350
382
" codewhispererSuggestionReferenceCount" to it.references().size.toString(),
351
383
atLeast = true
@@ -363,7 +395,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
363
395
val metricCaptor = argumentCaptor<MetricEvent >()
364
396
verify(batcher, atLeastOnce()).enqueue(metricCaptor.capture())
365
397
assertEventsContainsFieldsAndCount(
366
- metricCaptor.allValues, serviceInvocation, 1 ,
398
+ metricCaptor.allValues,
399
+ serviceInvocation,
400
+ 1 ,
367
401
" codewhispererSessionId" to states.responseContext.sessionId,
368
402
" codewhispererRequestId" to states.recommendationContext.details[0 ].requestId
369
403
)
@@ -379,12 +413,46 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
379
413
val metricCaptor = argumentCaptor<MetricEvent >()
380
414
verify(batcher, atLeastOnce()).enqueue(metricCaptor.capture())
381
415
assertEventsContainsFieldsAndCount(
382
- metricCaptor.allValues, userDecision, states.recommendationContext.details.size,
416
+ metricCaptor.allValues,
417
+ userDecision,
418
+ states.recommendationContext.details.size,
383
419
" codewhispererSessionId" to states.responseContext.sessionId,
384
420
" codewhispererRequestId" to states.recommendationContext.details[0 ].requestId,
385
421
)
386
422
}
387
423
424
+ @Test
425
+ fun `test showing IntelliSense after triggering CodeWhisperer will send userDecision events of state Discard` () {
426
+ val codewhispererServiceSpy = spy(codewhispererService)
427
+ codewhispererServiceSpy.stub {
428
+ onGeneric {
429
+ canDoInvocation(any(), any())
430
+ } doAnswer {
431
+ true
432
+ }
433
+ }
434
+ ApplicationManager .getApplication().replaceService(CodeWhispererService ::class .java, codewhispererServiceSpy, disposableRule.disposable)
435
+ popupManagerSpy.stub {
436
+ onGeneric {
437
+ hasConflictingPopups(any())
438
+ } doAnswer {
439
+ true
440
+ }
441
+ }
442
+ invokeCodeWhispererService()
443
+
444
+ runInEdtAndWait {
445
+ val metricCaptor = argumentCaptor<MetricEvent >()
446
+ verify(batcher, atLeastOnce()).enqueue(metricCaptor.capture())
447
+ assertEventsContainsFieldsAndCount(
448
+ metricCaptor.allValues,
449
+ userDecision,
450
+ pythonResponse.recommendations().size,
451
+ codewhispererSuggestionState to CodewhispererSuggestionState .Discard .toString(),
452
+ )
453
+ }
454
+ }
455
+
388
456
@Test
389
457
fun `test codePercentage metric is correct - 1` () {
390
458
val project = projectRule.project
@@ -540,7 +608,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
540
608
val metricCaptor = argumentCaptor<MetricEvent >()
541
609
verify(batcher, atLeastOnce()).enqueue(metricCaptor.capture())
542
610
assertEventsContainsFieldsAndCount(
543
- metricCaptor.allValues, userDecision, 1 ,
611
+ metricCaptor.allValues,
612
+ userDecision,
613
+ 1 ,
544
614
" codewhispererSuggestionState" to CodewhispererSuggestionState .Empty .toString()
545
615
)
546
616
}
@@ -611,7 +681,9 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
611
681
val metricCaptor = argumentCaptor<MetricEvent >()
612
682
verify(batcher, atLeastOnce()).enqueue(metricCaptor.capture())
613
683
assertEventsContainsFieldsAndCount(
614
- metricCaptor.allValues, userDecision, numOfEmptyRecommendations,
684
+ metricCaptor.allValues,
685
+ userDecision,
686
+ numOfEmptyRecommendations,
615
687
" codewhispererSuggestionState" to CodewhispererSuggestionState .Empty .toString()
616
688
)
617
689
}
0 commit comments