File tree Expand file tree Collapse file tree 5 files changed +20
-2
lines changed
codewhispererChat/controllers/chat Expand file tree Collapse file tree 5 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "type" : " Feature" ,
3+ "description" : " Amazon Q Chat: Added metric parameters to recordAddMessage telemetry event."
4+ }
Original file line number Diff line number Diff line change 344344 "timeBetweenChunks" : { "shape" : " TimeBetweenChunks" },
345345 "fullResponselatency" : { "shape" : " Double" },
346346 "requestLength" : { "shape" : " Integer" },
347- "responseLength" : { "shape" : " Integer" }
347+ "responseLength" : { "shape" : " Integer" },
348+ "numberOfCodeBlocks" : { "shape" : " Integer" }
348349 }
349350 },
350351 "ChatHistory" : {
Original file line number Diff line number Diff line change @@ -89,6 +89,16 @@ export class Messenger {
8989 )
9090 )
9191 }
92+
93+ public countTotalNumberOfCodeBlocks ( message : string ) : number {
94+ if ( message === undefined ) {
95+ return 0
96+ }
97+ const countOfCodeBlocks = message . match ( / ^ ` ` ` / gm)
98+ const numberOfTripleBackTicksInMarkdown = countOfCodeBlocks ? countOfCodeBlocks . length : 0
99+ return Math . floor ( numberOfTripleBackTicksInMarkdown / 2 )
100+ }
101+
92102 public async sendAIResponse (
93103 response : GenerateAssistantResponseCommandOutput ,
94104 session : ChatSession ,
@@ -265,6 +275,7 @@ export class Messenger {
265275 messageID,
266276 responseCode,
267277 codeReferenceCount : codeReference . length ,
278+ totalNumberOfCodeBlocksInResponse : this . countTotalNumberOfCodeBlocks ( message ) ,
268279 } )
269280 } )
270281 }
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ export interface PromptAnswer {
7676 messageID : string
7777 responseCode : number
7878 codeReferenceCount : number
79+ totalNumberOfCodeBlocksInResponse : number
7980}
8081
8182export interface StopResponseMessage {
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ export class CWCTelemetryHelper {
321321 cwsprChatProgrammingLanguage : triggerPayload . fileLanguage ,
322322 cwsprChatActiveEditorTotalCharacters : triggerPayload . fileText ?. length ,
323323 cwsprChatActiveEditorImportCount : triggerPayload . codeQuery ?. fullyQualifiedNames ?. used ?. length ,
324- cwsprChatResponseCodeSnippetCount : 0 , // TODO
324+ cwsprChatResponseCodeSnippetCount : message . totalNumberOfCodeBlocksInResponse ,
325325 cwsprChatResponseCode : message . responseCode ,
326326 cwsprChatSourceLinkCount : message . suggestionCount ,
327327 cwsprChatReferencesCount : message . codeReferenceCount ,
@@ -353,6 +353,7 @@ export class CWCTelemetryHelper {
353353 fullResponselatency : event . cwsprChatFullResponseLatency ,
354354 requestLength : event . cwsprChatRequestLength ,
355355 responseLength : event . cwsprChatResponseLength ,
356+ numberOfCodeBlocks : event . cwsprChatResponseCodeSnippetCount ,
356357 } ,
357358 } ,
358359 } )
You can’t perform that action at this time.
0 commit comments