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 344
344
"timeBetweenChunks" : { "shape" : " TimeBetweenChunks" },
345
345
"fullResponselatency" : { "shape" : " Double" },
346
346
"requestLength" : { "shape" : " Integer" },
347
- "responseLength" : { "shape" : " Integer" }
347
+ "responseLength" : { "shape" : " Integer" },
348
+ "numberOfCodeBlocks" : { "shape" : " Integer" }
348
349
}
349
350
},
350
351
"ChatHistory" : {
Original file line number Diff line number Diff line change @@ -89,6 +89,16 @@ export class Messenger {
89
89
)
90
90
)
91
91
}
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
+
92
102
public async sendAIResponse (
93
103
response : GenerateAssistantResponseCommandOutput ,
94
104
session : ChatSession ,
@@ -265,6 +275,7 @@ export class Messenger {
265
275
messageID,
266
276
responseCode,
267
277
codeReferenceCount : codeReference . length ,
278
+ totalNumberOfCodeBlocksInResponse : this . countTotalNumberOfCodeBlocks ( message ) ,
268
279
} )
269
280
} )
270
281
}
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ export interface PromptAnswer {
76
76
messageID : string
77
77
responseCode : number
78
78
codeReferenceCount : number
79
+ totalNumberOfCodeBlocksInResponse : number
79
80
}
80
81
81
82
export interface StopResponseMessage {
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ export class CWCTelemetryHelper {
321
321
cwsprChatProgrammingLanguage : triggerPayload . fileLanguage ,
322
322
cwsprChatActiveEditorTotalCharacters : triggerPayload . fileText ?. length ,
323
323
cwsprChatActiveEditorImportCount : triggerPayload . codeQuery ?. fullyQualifiedNames ?. used ?. length ,
324
- cwsprChatResponseCodeSnippetCount : 0 , // TODO
324
+ cwsprChatResponseCodeSnippetCount : message . totalNumberOfCodeBlocksInResponse ,
325
325
cwsprChatResponseCode : message . responseCode ,
326
326
cwsprChatSourceLinkCount : message . suggestionCount ,
327
327
cwsprChatReferencesCount : message . codeReferenceCount ,
@@ -353,6 +353,7 @@ export class CWCTelemetryHelper {
353
353
fullResponselatency : event . cwsprChatFullResponseLatency ,
354
354
requestLength : event . cwsprChatRequestLength ,
355
355
responseLength : event . cwsprChatResponseLength ,
356
+ numberOfCodeBlocks : event . cwsprChatResponseCodeSnippetCount ,
356
357
} ,
357
358
} ,
358
359
} )
You can’t perform that action at this time.
0 commit comments