@@ -10,7 +10,7 @@ import { parsePatch, applyPatches, ParsedDiff } from 'diff'
1010import path from 'path'
1111import vscode from 'vscode'
1212import { ExportIntent } from '@amzn/codewhisperer-streaming'
13- import { TransformByQReviewStatus , transformByQState } from '../../models/model'
13+ import { TransformationType , TransformByQReviewStatus , transformByQState } from '../../models/model'
1414import { ExportResultArchiveStructure , downloadExportResultArchive } from '../../../shared/utilities/download'
1515import { getLogger } from '../../../shared/logger'
1616import { telemetry } from '../../../shared/telemetry/telemetry'
@@ -20,6 +20,7 @@ import * as CodeWhispererConstants from '../../models/constants'
2020import { createCodeWhispererChatStreamingClient } from '../../../shared/clients/codewhispererChatClient'
2121import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSession'
2222import { setContext } from '../../../shared/vscode/setContext'
23+ import * as codeWhisperer from '../../client/codewhisperer'
2324
2425export abstract class ProposedChangeNode {
2526 abstract readonly resourcePath : string
@@ -402,6 +403,33 @@ export class ProposedTransformationExplorer {
402403 `${ CodeWhispererConstants . errorDeserializingDiffNotification } ${ deserializeErrorMessage } `
403404 )
404405 }
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+ }
405433 } )
406434
407435 vscode . commands . registerCommand ( 'aws.amazonq.transformationHub.reviewChanges.acceptChanges' , async ( ) => {
0 commit comments