Skip to content

Commit e0c460e

Browse files
authored
telemetry(amazonq chat): params for Q chat aws#4714
Problem: - Missing parameters in `onCopyCodeToClipboard` and `onCodeInsertToCursorPosition` events for telemetry. Solution: - Added `cwsprChatCodeBlockIndex` and `cwsprChatTotalCodeBlocks` parameters to the `onCopyCodeToClipboard` and `onCodeInsertToCursorPosition` events. - `cwsprChatCodeBlockIndex` - Provides the index of that code block, when a user interacts with a code block within a message in the conversation, - `cwsprChatTotalCodeBlocks` - Total number of code blocks inside a generated message. - Passed these two parameters to `insert_code_at_cursor_position` and `code_was_copied_to_clipboard` telemetry events.
1 parent f1c5d45 commit e0c460e

File tree

9 files changed

+101
-13
lines changed

9 files changed

+101
-13
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4315,7 +4315,7 @@
43154315
"@aws-sdk/property-provider": "3.46.0",
43164316
"@aws-sdk/smithy-client": "^3.46.0",
43174317
"@aws-sdk/util-arn-parser": "^3.46.0",
4318-
"@aws/mynah-ui": "^4.5.5",
4318+
"@aws/mynah-ui": "^4.5.6",
43194319
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
43204320
"@iarna/toml": "^2.2.5",
43214321
"@smithy/shared-ini-file-loader": "^2.2.8",

packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ export class Connector {
9292
messageId: string,
9393
code?: string,
9494
type?: 'selection' | 'block',
95-
codeReference?: CodeReference[]
95+
codeReference?: CodeReference[],
96+
eventId?: string,
97+
codeBlockIndex?: number,
98+
totalCodeBlocks?: number
9699
): void => {
97100
this.sendMessageToExtension({
98101
tabID: tabID,
@@ -102,6 +105,9 @@ export class Connector {
102105
tabType: 'cwc',
103106
insertionTargetType: type,
104107
codeReference,
108+
eventId,
109+
codeBlockIndex,
110+
totalCodeBlocks,
105111
})
106112
}
107113

@@ -110,7 +116,10 @@ export class Connector {
110116
messageId: string,
111117
code?: string,
112118
type?: 'selection' | 'block',
113-
codeReference?: CodeReference[]
119+
codeReference?: CodeReference[],
120+
eventId?: string,
121+
codeBlockIndex?: number,
122+
totalCodeBlocks?: number
114123
): void => {
115124
this.sendMessageToExtension({
116125
tabID: tabID,
@@ -120,6 +129,9 @@ export class Connector {
120129
tabType: 'cwc',
121130
insertionTargetType: type,
122131
codeReference,
132+
eventId,
133+
codeBlockIndex,
134+
totalCodeBlocks,
123135
})
124136
}
125137

packages/core/src/amazonq/webview/ui/connector.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,23 @@ export class Connector {
206206
messageId: string,
207207
code?: string,
208208
type?: 'selection' | 'block',
209-
codeReference?: CodeReference[]
209+
codeReference?: CodeReference[],
210+
eventId?: string,
211+
codeBlockIndex?: number,
212+
totalCodeBlocks?: number
210213
): void => {
211214
switch (this.tabsStorage.getTab(tabID)?.type) {
212215
case 'cwc':
213-
this.cwChatConnector.onCodeInsertToCursorPosition(tabID, messageId, code, type, codeReference)
216+
this.cwChatConnector.onCodeInsertToCursorPosition(
217+
tabID,
218+
messageId,
219+
code,
220+
type,
221+
codeReference,
222+
eventId,
223+
codeBlockIndex,
224+
totalCodeBlocks
225+
)
214226
break
215227
case 'featuredev':
216228
this.featureDevChatConnector.onCodeInsertToCursorPosition(tabID, code, type, codeReference)
@@ -223,11 +235,23 @@ export class Connector {
223235
messageId: string,
224236
code?: string,
225237
type?: 'selection' | 'block',
226-
codeReference?: CodeReference[]
238+
codeReference?: CodeReference[],
239+
eventId?: string,
240+
codeBlockIndex?: number,
241+
totalCodeBlocks?: number
227242
): void => {
228243
switch (this.tabsStorage.getTab(tabID)?.type) {
229244
case 'cwc':
230-
this.cwChatConnector.onCopyCodeToClipboard(tabID, messageId, code, type, codeReference)
245+
this.cwChatConnector.onCopyCodeToClipboard(
246+
tabID,
247+
messageId,
248+
code,
249+
type,
250+
codeReference,
251+
eventId,
252+
codeBlockIndex,
253+
totalCodeBlocks
254+
)
231255
break
232256
case 'featuredev':
233257
this.featureDevChatConnector.onCopyCodeToClipboard(tabID, code, type, codeReference)

packages/core/src/amazonq/webview/ui/main.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,26 @@ export const createMynahUI = (ideApi: any, amazonQEnabled: boolean) => {
367367
})
368368
},
369369
onCodeInsertToCursorPosition: connector.onCodeInsertToCursorPosition,
370-
onCopyCodeToClipboard: (tabId, messageId, code, type, referenceTrackerInfo) => {
371-
connector.onCopyCodeToClipboard(tabId, messageId, code, type, referenceTrackerInfo)
370+
onCopyCodeToClipboard: (
371+
tabId,
372+
messageId,
373+
code,
374+
type,
375+
referenceTrackerInfo,
376+
eventId,
377+
codeBlockIndex,
378+
totalCodeBlocks
379+
) => {
380+
connector.onCopyCodeToClipboard(
381+
tabId,
382+
messageId,
383+
code,
384+
type,
385+
referenceTrackerInfo,
386+
eventId,
387+
codeBlockIndex,
388+
totalCodeBlocks
389+
)
372390
mynahUI.notify({
373391
type: NotificationType.SUCCESS,
374392
content: 'Selected code is copied to clipboard',

packages/core/src/codewhispererChat/controllers/chat/model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export interface InsertCodeAtCursorPosition {
4141
code: string
4242
insertionTargetType: string | undefined
4343
codeReference: CodeReference[] | undefined
44+
eventId: string
45+
codeBlockIndex: number
46+
totalCodeBlocks: number
4447
}
4548

4649
export interface CopyCodeToClipboard {
@@ -50,6 +53,9 @@ export interface CopyCodeToClipboard {
5053
code: string
5154
insertionTargetType: string | undefined
5255
codeReference: CodeReference[] | undefined
56+
eventId: string
57+
codeBlockIndex: number
58+
totalCodeBlocks: number
5359
}
5460

5561
export type ChatPromptCommandType =

packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ export class CWCTelemetryHelper {
160160
cwsprChatAcceptedCharactersLength: message.code.length,
161161
cwsprChatInteractionTarget: message.insertionTargetType,
162162
cwsprChatHasReference: message.codeReference && message.codeReference.length > 0,
163+
cwsprChatCodeBlockIndex: message.codeBlockIndex,
164+
cwsprChatTotalCodeBlocks: message.totalCodeBlocks,
163165
}
164166
break
165167
case 'code_was_copied_to_clipboard':
@@ -173,6 +175,8 @@ export class CWCTelemetryHelper {
173175
cwsprChatAcceptedCharactersLength: message.code.length,
174176
cwsprChatInteractionTarget: message.insertionTargetType,
175177
cwsprChatHasReference: message.codeReference && message.codeReference.length > 0,
178+
cwsprChatCodeBlockIndex: message.codeBlockIndex,
179+
cwsprChatTotalCodeBlocks: message.totalCodeBlocks,
176180
}
177181
break
178182
case 'follow-up-was-clicked':

packages/core/src/codewhispererChat/view/messages/messageListener.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ export class UIMessageListener {
157157
code: msg.code,
158158
insertionTargetType: msg.insertionTargetType,
159159
codeReference: msg.codeReference,
160+
eventId: msg.eventId,
161+
codeBlockIndex: msg.codeBlockIndex,
162+
totalCodeBlocks: msg.totalCodeBlocks,
160163
})
161164
}
162165

@@ -168,6 +171,9 @@ export class UIMessageListener {
168171
code: msg.code,
169172
insertionTargetType: msg.insertionTargetType,
170173
codeReference: msg.codeReference,
174+
eventId: msg.eventId,
175+
codeBlockIndex: msg.codeBlockIndex,
176+
totalCodeBlocks: msg.totalCodeBlocks,
171177
})
172178
}
173179

packages/core/src/shared/telemetry/vscodeTelemetry.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@
256256
"type": "string",
257257
"description": "Identifies the entity within the message that user interacts with."
258258
},
259+
{
260+
"name": "cwsprChatCodeBlockIndex",
261+
"type": "int",
262+
"description": "Index of the code block inside a message in the conversation."
263+
},
264+
{
265+
"name": "cwsprChatTotalCodeBlocks",
266+
"type": "int",
267+
"description": "Total number of code blocks inside a message in the conversation."
268+
},
259269
{
260270
"name": "cwsprChatAcceptedCharactersLength",
261271
"type": "int",
@@ -823,6 +833,14 @@
823833
{
824834
"type": "cwsprChatHasReference",
825835
"required": false
836+
},
837+
{
838+
"type": "cwsprChatCodeBlockIndex",
839+
"required": false
840+
},
841+
{
842+
"type": "cwsprChatTotalCodeBlocks",
843+
"required": false
826844
}
827845
]
828846
},

0 commit comments

Comments
 (0)