@@ -10,7 +10,7 @@ import { parsePatch, applyPatches, ParsedDiff } from 'diff'
10
10
import path from 'path'
11
11
import vscode from 'vscode'
12
12
import { ExportIntent } from '@amzn/codewhisperer-streaming'
13
- import { TransformByQReviewStatus , transformByQState } from '../../models/model'
13
+ import { TransformationType , TransformByQReviewStatus , transformByQState } from '../../models/model'
14
14
import { ExportResultArchiveStructure , downloadExportResultArchive } from '../../../shared/utilities/download'
15
15
import { getLogger } from '../../../shared/logger'
16
16
import { telemetry } from '../../../shared/telemetry/telemetry'
@@ -20,6 +20,7 @@ import * as CodeWhispererConstants from '../../models/constants'
20
20
import { createCodeWhispererChatStreamingClient } from '../../../shared/clients/codewhispererChatClient'
21
21
import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSession'
22
22
import { setContext } from '../../../shared/vscode/setContext'
23
+ import * as codeWhisperer from '../../client/codewhisperer'
23
24
24
25
export abstract class ProposedChangeNode {
25
26
abstract readonly resourcePath : string
@@ -402,6 +403,33 @@ export class ProposedTransformationExplorer {
402
403
`${ CodeWhispererConstants . errorDeserializingDiffNotification } ${ deserializeErrorMessage } `
403
404
)
404
405
}
406
+
407
+ try {
408
+ const metricsPath = path . join ( pathContainingArchive , ExportResultArchiveStructure . PathToMetrics )
409
+ const metricsData = JSON . parse ( fs . readFileSync ( metricsPath , 'utf8' ) )
410
+
411
+ await codeWhisperer . codeWhispererClient . sendTelemetryEvent ( {
412
+ telemetryEvent : {
413
+ transformEvent : {
414
+ jobId : transformByQState . getJobId ( ) ,
415
+ timestamp : new Date ( ) ,
416
+ ideCategory : 'VSCODE' ,
417
+ programmingLanguage : {
418
+ languageName :
419
+ transformByQState . getTransformationType ( ) === TransformationType . LANGUAGE_UPGRADE
420
+ ? 'JAVA'
421
+ : 'SQL' ,
422
+ } ,
423
+ linesOfCodeChanged : metricsData . linesOfCodeChanged ,
424
+ charsOfCodeChanged : metricsData . charactersOfCodeChanged ,
425
+ linesOfCodeSubmitted : transformByQState . getLinesOfCodeSubmitted ( ) , // currently unavailable for SQL conversions
426
+ } ,
427
+ } ,
428
+ } )
429
+ } catch ( err : any ) {
430
+ // log error, but continue to show user diff.patch with results
431
+ getLogger ( ) . error ( `CodeTransformation: SendTelemetryEvent error = ${ err . message } ` )
432
+ }
405
433
} )
406
434
407
435
vscode . commands . registerCommand ( 'aws.amazonq.transformationHub.reviewChanges.acceptChanges' , async ( ) => {
0 commit comments