@@ -242,22 +242,20 @@ export class TestController {
242242 this . messenger . sendUpdatePromptProgress ( data . tabID , null )
243243 const session = this . sessionStorage . getSession ( )
244244 const isCancel = data . error . message === unitTestGenerationCancelMessage
245- telemetry . amazonq_utgGenerateTests . emit ( {
246- cwsprChatProgrammingLanguage : session . fileLanguage ?? 'plaintext' ,
247- jobId : session . listOfTestGenerationJobId [ 0 ] , // For RIV, UTG does only one StartTestGeneration API call
248- jobGroup : session . testGenerationJobGroupName ,
249- requestId : session . startTestGenerationRequestId ,
250- hasUserPromptSupplied : session . hasUserPromptSupplied ,
251- isCodeBlockSelected : session . isCodeBlockSelected ,
252- buildPayloadBytes : session . srcPayloadSize ,
253- buildZipFileBytes : session . srcZipFileSize ,
254- artifactsUploadDuration : session . artifactsUploadDuration ,
255- perfClientLatency : performance . now ( ) - session . testGenerationStartTime ,
256- result : isCancel ? 'Cancelled' : 'Failed' ,
257- reasonDesc : getTelemetryReasonDesc ( data . error ) ,
258- isSupportedLanguage : true ,
259- credentialStartUrl : AuthUtil . instance . startUrl ,
260- } )
245+
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+ session . isCodeBlockSelected ,
254+ session . artifactsUploadDuration ,
255+ session . srcPayloadSize ,
256+ session . srcZipFileSize
257+ )
258+
261259 if ( session . stopIteration ) {
262260 // Error from Science
263261 this . messenger . sendMessage ( data . error . message . replaceAll ( '```' , '' ) , data . tabID , 'answer' )
@@ -716,27 +714,25 @@ export class TestController {
716714 // TODO: send the message once again once build is enabled
717715 // this.messenger.sendMessage('Accepted', message.tabID, 'prompt')
718716 telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_acceptDiff' } )
719- telemetry . amazonq_utgGenerateTests . emit ( {
720- generatedCount : session . numberOfTestsGenerated ,
721- acceptedCount : session . numberOfTestsGenerated ,
722- generatedCharactersCount : session . charsOfCodeGenerated ,
723- acceptedCharactersCount : session . charsOfCodeAccepted ,
724- generatedLinesCount : session . linesOfCodeGenerated ,
725- acceptedLinesCount : session . linesOfCodeAccepted ,
726- cwsprChatProgrammingLanguage : session . fileLanguage ?? 'plaintext' ,
727- jobId : session . listOfTestGenerationJobId [ 0 ] , // For RIV, UTG does only one StartTestGeneration API call so jobId = session.listOfTestGenerationJobId[0]
728- jobGroup : session . testGenerationJobGroupName ,
729- requestId : session . startTestGenerationRequestId ,
730- buildPayloadBytes : session . srcPayloadSize ,
731- buildZipFileBytes : session . srcZipFileSize ,
732- artifactsUploadDuration : session . artifactsUploadDuration ,
733- hasUserPromptSupplied : session . hasUserPromptSupplied ,
734- isCodeBlockSelected : session . isCodeBlockSelected ,
735- perfClientLatency : session . latencyOfTestGeneration ,
736- isSupportedLanguage : true ,
737- credentialStartUrl : AuthUtil . instance . startUrl ,
738- result : 'Succeeded' ,
739- } )
717+
718+ TelemetryHelper . instance . sendTestGenerationToolkitEvent (
719+ session ,
720+ true ,
721+ 'Succeeded' ,
722+ session . startTestGenerationRequestId ,
723+ session . latencyOfTestGeneration ,
724+ undefined ,
725+ session . isCodeBlockSelected ,
726+ session . artifactsUploadDuration ,
727+ session . srcPayloadSize ,
728+ session . srcZipFileSize ,
729+ session . charsOfCodeAccepted ,
730+ session . numberOfTestsGenerated ,
731+ session . linesOfCodeAccepted ,
732+ session . charsOfCodeGenerated ,
733+ session . numberOfTestsGenerated ,
734+ session . linesOfCodeGenerated
735+ )
740736
741737 await this . endSession ( message , FollowUpTypes . SkipBuildAndFinish )
742738 await this . sessionCleanUp ( )
@@ -840,27 +836,25 @@ export class TestController {
840836 private async endSession ( data : any , step : FollowUpTypes ) {
841837 const session = this . sessionStorage . getSession ( )
842838 if ( step === FollowUpTypes . RejectCode ) {
843- telemetry . amazonq_utgGenerateTests . emit ( {
844- generatedCount : session . numberOfTestsGenerated ,
845- acceptedCount : 0 ,
846- generatedCharactersCount : session . charsOfCodeGenerated ,
847- acceptedCharactersCount : 0 ,
848- generatedLinesCount : session . linesOfCodeGenerated ,
849- acceptedLinesCount : 0 ,
850- cwsprChatProgrammingLanguage : session . fileLanguage ?? 'plaintext' ,
851- jobId : session . listOfTestGenerationJobId [ 0 ] , // For RIV, UTG does only one StartTestGeneration API call so jobId = session.listOfTestGenerationJobId[0]
852- jobGroup : session . testGenerationJobGroupName ,
853- requestId : session . startTestGenerationRequestId ,
854- buildPayloadBytes : session . srcPayloadSize ,
855- buildZipFileBytes : session . srcZipFileSize ,
856- artifactsUploadDuration : session . artifactsUploadDuration ,
857- hasUserPromptSupplied : session . hasUserPromptSupplied ,
858- isCodeBlockSelected : session . isCodeBlockSelected ,
859- perfClientLatency : session . latencyOfTestGeneration ,
860- isSupportedLanguage : true ,
861- credentialStartUrl : AuthUtil . instance . startUrl ,
862- result : 'Succeeded' ,
863- } )
839+ TelemetryHelper . instance . sendTestGenerationToolkitEvent (
840+ session ,
841+ true ,
842+ 'Succeeded' ,
843+ session . startTestGenerationRequestId ,
844+ session . latencyOfTestGeneration ,
845+ undefined ,
846+ session . isCodeBlockSelected ,
847+ session . artifactsUploadDuration ,
848+ session . srcPayloadSize ,
849+ session . srcZipFileSize ,
850+ 0 ,
851+ 0 ,
852+ 0 ,
853+ session . charsOfCodeGenerated ,
854+ session . numberOfTestsGenerated ,
855+ session . linesOfCodeGenerated
856+ )
857+
864858 telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_rejectDiff' } )
865859 }
866860
0 commit comments