Skip to content

Commit

Permalink
Adding params for Q chat metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
laileni-aws committed Apr 20, 2024
1 parent f1c5d45 commit 7067cf7
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4315,7 +4315,7 @@
"@aws-sdk/property-provider": "3.46.0",
"@aws-sdk/smithy-client": "^3.46.0",
"@aws-sdk/util-arn-parser": "^3.46.0",
"@aws/mynah-ui": "^4.5.5",
"@aws/mynah-ui": "^4.5.6",
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
"@iarna/toml": "^2.2.5",
"@smithy/shared-ini-file-loader": "^2.2.8",
Expand Down
16 changes: 14 additions & 2 deletions packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export class Connector {
messageId: string,
code?: string,
type?: 'selection' | 'block',
codeReference?: CodeReference[]
codeReference?: CodeReference[],
eventId?: string,
codeBlockIndex?: number,
totalCodeBlocks?: number
): void => {
this.sendMessageToExtension({
tabID: tabID,
Expand All @@ -102,6 +105,9 @@ export class Connector {
tabType: 'cwc',
insertionTargetType: type,
codeReference,
eventId,
codeBlockIndex,
totalCodeBlocks,
})
}

Expand All @@ -110,7 +116,10 @@ export class Connector {
messageId: string,
code?: string,
type?: 'selection' | 'block',
codeReference?: CodeReference[]
codeReference?: CodeReference[],
eventId?: string,
codeBlockIndex?: number,
totalCodeBlocks?: number
): void => {
this.sendMessageToExtension({
tabID: tabID,
Expand All @@ -120,6 +129,9 @@ export class Connector {
tabType: 'cwc',
insertionTargetType: type,
codeReference,
eventId,
codeBlockIndex,
totalCodeBlocks,
})
}

Expand Down
32 changes: 28 additions & 4 deletions packages/core/src/amazonq/webview/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,23 @@ export class Connector {
messageId: string,
code?: string,
type?: 'selection' | 'block',
codeReference?: CodeReference[]
codeReference?: CodeReference[],
eventId?: string,
codeBlockIndex?: number,
totalCodeBlocks?: number
): void => {
switch (this.tabsStorage.getTab(tabID)?.type) {
case 'cwc':
this.cwChatConnector.onCodeInsertToCursorPosition(tabID, messageId, code, type, codeReference)
this.cwChatConnector.onCodeInsertToCursorPosition(
tabID,
messageId,
code,
type,
codeReference,
eventId,
codeBlockIndex,
totalCodeBlocks
)
break
case 'featuredev':
this.featureDevChatConnector.onCodeInsertToCursorPosition(tabID, code, type, codeReference)
Expand All @@ -223,11 +235,23 @@ export class Connector {
messageId: string,
code?: string,
type?: 'selection' | 'block',
codeReference?: CodeReference[]
codeReference?: CodeReference[],
eventId?: string,
codeBlockIndex?: number,
totalCodeBlocks?: number
): void => {
switch (this.tabsStorage.getTab(tabID)?.type) {
case 'cwc':
this.cwChatConnector.onCopyCodeToClipboard(tabID, messageId, code, type, codeReference)
this.cwChatConnector.onCopyCodeToClipboard(
tabID,
messageId,
code,
type,
codeReference,
eventId,
codeBlockIndex,
totalCodeBlocks
)
break
case 'featuredev':
this.featureDevChatConnector.onCopyCodeToClipboard(tabID, code, type, codeReference)
Expand Down
22 changes: 20 additions & 2 deletions packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,26 @@ export const createMynahUI = (ideApi: any, amazonQEnabled: boolean) => {
})
},
onCodeInsertToCursorPosition: connector.onCodeInsertToCursorPosition,
onCopyCodeToClipboard: (tabId, messageId, code, type, referenceTrackerInfo) => {
connector.onCopyCodeToClipboard(tabId, messageId, code, type, referenceTrackerInfo)
onCopyCodeToClipboard: (
tabId,
messageId,
code,
type,
referenceTrackerInfo,
eventId,
codeBlockIndex,
totalCodeBlocks
) => {
connector.onCopyCodeToClipboard(
tabId,
messageId,
code,
type,
referenceTrackerInfo,
eventId,
codeBlockIndex,
totalCodeBlocks
)
mynahUI.notify({
type: NotificationType.SUCCESS,
content: 'Selected code is copied to clipboard',
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/codewhispererChat/controllers/chat/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export interface InsertCodeAtCursorPosition {
code: string
insertionTargetType: string | undefined
codeReference: CodeReference[] | undefined
eventId: string
codeBlockIndex: number
totalCodeBlocks: number
}

export interface CopyCodeToClipboard {
Expand All @@ -50,6 +53,9 @@ export interface CopyCodeToClipboard {
code: string
insertionTargetType: string | undefined
codeReference: CodeReference[] | undefined
eventId: string
codeBlockIndex: number
totalCodeBlocks: number
}

export type ChatPromptCommandType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export class CWCTelemetryHelper {
cwsprChatAcceptedCharactersLength: message.code.length,
cwsprChatInteractionTarget: message.insertionTargetType,
cwsprChatHasReference: message.codeReference && message.codeReference.length > 0,
cwsprChatCodeBlockIndex: message.codeBlockIndex,
cwsprChatTotalCodeBlocks: message.totalCodeBlocks,
}
break
case 'code_was_copied_to_clipboard':
Expand All @@ -173,6 +175,8 @@ export class CWCTelemetryHelper {
cwsprChatAcceptedCharactersLength: message.code.length,
cwsprChatInteractionTarget: message.insertionTargetType,
cwsprChatHasReference: message.codeReference && message.codeReference.length > 0,
cwsprChatCodeBlockIndex: message.codeBlockIndex,
cwsprChatTotalCodeBlocks: message.totalCodeBlocks,
}
break
case 'follow-up-was-clicked':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export class UIMessageListener {
code: msg.code,
insertionTargetType: msg.insertionTargetType,
codeReference: msg.codeReference,
eventId: msg.eventId,
codeBlockIndex: msg.codeBlockIndex,
totalCodeBlocks: msg.totalCodeBlocks,
})
}

Expand All @@ -168,6 +171,9 @@ export class UIMessageListener {
code: msg.code,
insertionTargetType: msg.insertionTargetType,
codeReference: msg.codeReference,
eventId: msg.eventId,
codeBlockIndex: msg.codeBlockIndex,
totalCodeBlocks: msg.totalCodeBlocks,
})
}

Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/shared/telemetry/vscodeTelemetry.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@
"type": "string",
"description": "Identifies the entity within the message that user interacts with."
},
{
"name": "cwsprChatCodeBlockIndex",
"type": "int",
"description": "Index of the code block inside a message in the conversation."
},
{
"name": "cwsprChatTotalCodeBlocks",
"type": "int",
"description": "Total number of code blocks inside a message in the conversation."
},
{
"name": "cwsprChatAcceptedCharactersLength",
"type": "int",
Expand Down Expand Up @@ -823,6 +833,14 @@
{
"type": "cwsprChatHasReference",
"required": false
},
{
"type": "cwsprChatCodeBlockIndex",
"required": false
},
{
"type": "cwsprChatTotalCodeBlocks",
"required": false
}
]
},
Expand Down

0 comments on commit 7067cf7

Please sign in to comment.