@@ -242,26 +242,31 @@ export class TestController {
242
242
// eslint-disable-next-line unicorn/no-null
243
243
this . messenger . sendUpdatePromptProgress ( data . tabID , null )
244
244
const session = this . sessionStorage . getSession ( )
245
- const isCancel = data . error . customerFacingMessage === unitTestGenerationCancelMessage
246
- TelemetryHelper . instance . sendTestGenerationToolkitEvent (
247
- session ,
248
- true ,
249
- isCancel ? 'Cancelled' : 'Failed' ,
250
- session . startTestGenerationRequestId ,
251
- performance . now ( ) - session . testGenerationStartTime ,
252
- getTelemetryReasonDesc ( data . error ) ,
253
- data . error . statusCode ?? '0' , // If status code is 0, need to investigate where this is originating from.
254
- session . isCodeBlockSelected ,
255
- session . artifactsUploadDuration ,
256
- session . srcPayloadSize ,
257
- session . srcZipFileSize
258
- )
245
+ const isCancel = data . error . uiMessage === unitTestGenerationCancelMessage
246
+ telemetry . amazonq_utgGenerateTests . emit ( {
247
+ cwsprChatProgrammingLanguage : session . fileLanguage ?? 'plaintext' ,
248
+ jobId : session . listOfTestGenerationJobId [ 0 ] , // For RIV, UTG does only one StartTestGeneration API call
249
+ jobGroup : session . testGenerationJobGroupName ,
250
+ requestId : session . startTestGenerationRequestId ,
251
+ hasUserPromptSupplied : session . hasUserPromptSupplied ,
252
+ isCodeBlockSelected : session . isCodeBlockSelected ,
253
+ buildPayloadBytes : session . srcPayloadSize ,
254
+ buildZipFileBytes : session . srcZipFileSize ,
255
+ artifactsUploadDuration : session . artifactsUploadDuration ,
256
+ perfClientLatency : performance . now ( ) - session . testGenerationStartTime ,
257
+ result : isCancel ? 'Cancelled' : 'Failed' ,
258
+ reasonDesc : getTelemetryReasonDesc ( data . error ) ,
259
+ isSupportedLanguage : true ,
260
+ credentialStartUrl : AuthUtil . instance . startUrl ,
261
+ httpStatusCode : data . error . statusCode ?? 0 , // If status code is 0, need to investigate where this is originating from.
262
+ reason : data . error . code ,
263
+ } )
259
264
if ( session . stopIteration ) {
260
265
// Error from Science
261
- this . messenger . sendMessage ( data . error . customerFacingMessage . replaceAll ( '```' , '' ) , data . tabID , 'answer' )
266
+ this . messenger . sendMessage ( data . error . uiMessage . replaceAll ( '```' , '' ) , data . tabID , 'answer' )
262
267
} else {
263
268
isCancel
264
- ? this . messenger . sendMessage ( data . error . customerFacingMessage , data . tabID , 'answer' )
269
+ ? this . messenger . sendMessage ( data . error . uiMessage , data . tabID , 'answer' )
265
270
: this . sendErrorMessage ( data )
266
271
}
267
272
await this . sessionCleanUp ( )
@@ -270,7 +275,7 @@ export class TestController {
270
275
// Client side error messages
271
276
private sendErrorMessage ( data : {
272
277
tabID : string
273
- error : { customerFacingMessage : string ; message : string ; code : string ; statusCode : string }
278
+ error : { uiMessage : string ; message : string ; code : string ; statusCode : string }
274
279
} ) {
275
280
const { error, tabID } = data
276
281
@@ -304,7 +309,7 @@ export class TestController {
304
309
}
305
310
} else {
306
311
// other unexpected errors (TODO enumerate all other failure cases)
307
- getLogger ( ) . error ( 'Other error message: %s' , error . customerFacingMessage )
312
+ getLogger ( ) . error ( 'Other error message: %s' , error . uiMessage )
308
313
this . messenger . sendErrorMessage ( '' , tabID )
309
314
}
310
315
}
@@ -715,6 +720,9 @@ export class TestController {
715
720
// this.messenger.sendMessage('Accepted', message.tabID, 'prompt')
716
721
telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_acceptDiff' } )
717
722
723
+ getLogger ( ) . info (
724
+ `Generated unit tests are accepted for ${ session . fileLanguage ?? 'plaintext' } language with jobId: ${ session . listOfTestGenerationJobId [ 0 ] } , jobGroupName: ${ session . testGenerationJobGroupName } , result: Succeeded`
725
+ )
718
726
TelemetryHelper . instance . sendTestGenerationToolkitEvent (
719
727
session ,
720
728
true ,
@@ -735,6 +743,29 @@ export class TestController {
735
743
session . linesOfCodeGenerated
736
744
)
737
745
746
+ telemetry . amazonq_utgGenerateTests . emit ( {
747
+ generatedCount : session . numberOfTestsGenerated ,
748
+ acceptedCount : session . numberOfTestsGenerated ,
749
+ generatedCharactersCount : session . charsOfCodeGenerated ,
750
+ acceptedCharactersCount : session . charsOfCodeAccepted ,
751
+ generatedLinesCount : session . linesOfCodeGenerated ,
752
+ acceptedLinesCount : session . linesOfCodeAccepted ,
753
+ cwsprChatProgrammingLanguage : session . fileLanguage ?? 'plaintext' ,
754
+ jobId : session . listOfTestGenerationJobId [ 0 ] , // For RIV, UTG does only one StartTestGeneration API call so jobId = session.listOfTestGenerationJobId[0]
755
+ jobGroup : session . testGenerationJobGroupName ,
756
+ requestId : session . startTestGenerationRequestId ,
757
+ buildPayloadBytes : session . srcPayloadSize ,
758
+ buildZipFileBytes : session . srcZipFileSize ,
759
+ artifactsUploadDuration : session . artifactsUploadDuration ,
760
+ hasUserPromptSupplied : session . hasUserPromptSupplied ,
761
+ isCodeBlockSelected : session . isCodeBlockSelected ,
762
+ perfClientLatency : session . latencyOfTestGeneration ,
763
+ isSupportedLanguage : true ,
764
+ credentialStartUrl : AuthUtil . instance . startUrl ,
765
+ result : 'Succeeded' ,
766
+ httpStatusCode : '200' ,
767
+ } )
768
+
738
769
await this . endSession ( message , FollowUpTypes . SkipBuildAndFinish )
739
770
return
740
771
0 commit comments