@@ -24,6 +24,23 @@ interface CodeWhispererToken {
24
24
accepted : number
25
25
}
26
26
27
+ interface UserInputDetail {
28
+ count : number
29
+ total : number
30
+ }
31
+
32
+ interface UserInputDetails {
33
+ lt1 : UserInputDetail
34
+ lt50 : UserInputDetail
35
+ lt100 : UserInputDetail
36
+ lt200 : UserInputDetail
37
+ lt300 : UserInputDetail
38
+ lt400 : UserInputDetail
39
+ lt500 : UserInputDetail
40
+ lt1000 : UserInputDetail
41
+ gt1000 : UserInputDetail
42
+ }
43
+
27
44
const autoClosingKeystrokeInputs = [ '[]' , '{}' , '()' , '""' , "''" ]
28
45
29
46
/**
@@ -37,12 +54,25 @@ export class CodeWhispererCodeCoverageTracker {
37
54
private _language : CodewhispererLanguage
38
55
private _serviceInvocationCount : number
39
56
57
+ private _userInputDetails : UserInputDetails
58
+
40
59
private constructor ( language : CodewhispererLanguage ) {
41
60
this . _acceptedTokens = { }
42
61
this . _totalTokens = { }
43
62
this . _startTime = 0
44
63
this . _language = language
45
64
this . _serviceInvocationCount = 0
65
+ this . _userInputDetails = {
66
+ lt1 : { count : 0 , total : 0 } ,
67
+ lt50 : { count : 0 , total : 0 } ,
68
+ lt100 : { count : 0 , total : 0 } ,
69
+ lt200 : { count : 0 , total : 0 } ,
70
+ lt300 : { count : 0 , total : 0 } ,
71
+ lt400 : { count : 0 , total : 0 } ,
72
+ lt500 : { count : 0 , total : 0 } ,
73
+ lt1000 : { count : 0 , total : 0 } ,
74
+ gt1000 : { count : 0 , total : 0 } ,
75
+ }
46
76
}
47
77
48
78
public get serviceInvocationCount ( ) : number {
@@ -110,7 +140,7 @@ export class CodeWhispererCodeCoverageTracker {
110
140
}
111
141
// the accepted characters without counting user modification
112
142
let acceptedTokens = 0
113
- // the accepted characters after calculating user modificaiton
143
+ // the accepted characters after calculating user modification
114
144
let unmodifiedAcceptedTokens = 0
115
145
for ( const filename in this . _acceptedTokens ) {
116
146
this . _acceptedTokens [ filename ] . forEach ( v => {
@@ -136,6 +166,7 @@ export class CodeWhispererCodeCoverageTracker {
136
166
codewhispererUserGroup : CodeWhispererUserGroupSettings . getUserGroup ( ) . toString ( ) ,
137
167
codewhispererCustomizationArn : selectedCustomization . arn === '' ? undefined : selectedCustomization . arn ,
138
168
credentialStartUrl : AuthUtil . instance . startUrl ,
169
+ codewhispererUserInputDetails : JSON . stringify ( this . _userInputDetails ) ,
139
170
} )
140
171
141
172
client
@@ -206,6 +237,17 @@ export class CodeWhispererCodeCoverageTracker {
206
237
this . _acceptedTokens = { }
207
238
this . _startTime = 0
208
239
this . _serviceInvocationCount = 0
240
+ this . _userInputDetails = {
241
+ lt1 : { count : 0 , total : 0 } ,
242
+ lt50 : { count : 0 , total : 0 } ,
243
+ lt100 : { count : 0 , total : 0 } ,
244
+ lt200 : { count : 0 , total : 0 } ,
245
+ lt300 : { count : 0 , total : 0 } ,
246
+ lt400 : { count : 0 , total : 0 } ,
247
+ lt500 : { count : 0 , total : 0 } ,
248
+ lt1000 : { count : 0 , total : 0 } ,
249
+ gt1000 : { count : 0 , total : 0 } ,
250
+ }
209
251
}
210
252
211
253
private closeTimer ( ) {
@@ -287,9 +329,54 @@ export class CodeWhispererCodeCoverageTracker {
287
329
if ( this . isFromUserKeystroke ( e ) ) {
288
330
this . tryStartTimer ( )
289
331
this . addTotalTokens ( e . document . fileName , 1 )
332
+ this . _userInputDetails . lt1 . count += 1
333
+ this . _userInputDetails . lt1 . total += 1
290
334
} else if ( this . getCharacterCountFromComplexEvent ( e ) !== 0 ) {
291
335
this . tryStartTimer ( )
292
- this . addTotalTokens ( e . document . fileName , this . getCharacterCountFromComplexEvent ( e ) )
336
+ const characterIncrease = this . getCharacterCountFromComplexEvent ( e )
337
+ this . addTotalTokens ( e . document . fileName , characterIncrease )
338
+ this . _userInputDetails . lt1 . count += 1
339
+ this . _userInputDetails . lt1 . total += characterIncrease
340
+ }
341
+ // also include multi character input within 500 characters (not from CWSPR)
342
+ else if (
343
+ e . contentChanges . length === 1 &&
344
+ e . contentChanges [ 0 ] . text . length > 1 &&
345
+ TelemetryHelper . instance . lastSuggestionInDisplay !== e . contentChanges [ 0 ] . text
346
+ ) {
347
+ const multiCharInputSize = e . contentChanges [ 0 ] . text . length
348
+
349
+ // select 500 as the cut-off threshold for counting user input.
350
+ if ( multiCharInputSize < 500 ) {
351
+ this . addTotalTokens ( e . document . fileName , multiCharInputSize )
352
+ }
353
+
354
+ // report multiple user input patterns for adjusting the threshold
355
+ if ( multiCharInputSize < 50 ) {
356
+ this . _userInputDetails . lt50 . total += multiCharInputSize
357
+ this . _userInputDetails . lt50 . count += 1
358
+ } else if ( multiCharInputSize < 100 ) {
359
+ this . _userInputDetails . lt100 . total += multiCharInputSize
360
+ this . _userInputDetails . lt100 . count += 1
361
+ } else if ( multiCharInputSize < 200 ) {
362
+ this . _userInputDetails . lt200 . total += multiCharInputSize
363
+ this . _userInputDetails . lt200 . count += 1
364
+ } else if ( multiCharInputSize < 300 ) {
365
+ this . _userInputDetails . lt300 . total += multiCharInputSize
366
+ this . _userInputDetails . lt300 . count += 1
367
+ } else if ( multiCharInputSize < 400 ) {
368
+ this . _userInputDetails . lt400 . total += multiCharInputSize
369
+ this . _userInputDetails . lt400 . count += 1
370
+ } else if ( multiCharInputSize < 500 ) {
371
+ this . _userInputDetails . lt500 . total += multiCharInputSize
372
+ this . _userInputDetails . lt500 . count += 1
373
+ } else if ( multiCharInputSize < 1000 ) {
374
+ this . _userInputDetails . lt1000 . total += multiCharInputSize
375
+ this . _userInputDetails . lt1000 . count += 1
376
+ } else {
377
+ this . _userInputDetails . gt1000 . total += multiCharInputSize
378
+ this . _userInputDetails . gt1000 . count += 1
379
+ }
293
380
}
294
381
}
295
382
0 commit comments