From 2d53de0dcb0af11b7384d38c6f4466e090b109e7 Mon Sep 17 00:00:00 2001 From: Jacob Chung Date: Wed, 16 Apr 2025 15:19:08 -0700 Subject: [PATCH] metric to calculate tool distribution --- package-lock.json | 8 ++++---- package.json | 2 +- .../controllers/chat/messenger/messenger.ts | 2 ++ .../controllers/chat/telemetryHelper.ts | 13 ++++++++++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index a52329b07aa..8b666ad7d9d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "vscode-nls-dev": "^4.0.4" }, "devDependencies": { - "@aws-toolkits/telemetry": "^1.0.315", + "@aws-toolkits/telemetry": "^1.0.316", "@playwright/browser-chromium": "^1.43.1", "@stylistic/eslint-plugin": "^2.11.0", "@types/he": "^1.2.3", @@ -10806,9 +10806,9 @@ } }, "node_modules/@aws-toolkits/telemetry": { - "version": "1.0.315", - "resolved": "https://registry.npmjs.org/@aws-toolkits/telemetry/-/telemetry-1.0.315.tgz", - "integrity": "sha512-BJniCka+nGWpLokN1sn4oXes7Rvq6V6Fr1qZlCHI/j1mOqQEWYPnOKd+HdLcuqHWQKr3o5znnBlg0CmY+7kdNg==", + "version": "1.0.316", + "resolved": "https://registry.npmjs.org/@aws-toolkits/telemetry/-/telemetry-1.0.316.tgz", + "integrity": "sha512-zyzubs7fnCLPqdNtfHdmmNXVWrwIWJHIr6LJqdvUtNfdGmN8PWxq/NdBgCP9QcPVZusuK7SHha1knl8vhped/w==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 68463ece306..c3005b11496 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "skippedTestReport": "ts-node ./scripts/skippedTestReport.ts ./packages/amazonq/test/e2e/" }, "devDependencies": { - "@aws-toolkits/telemetry": "^1.0.315", + "@aws-toolkits/telemetry": "^1.0.316", "@playwright/browser-chromium": "^1.43.1", "@stylistic/eslint-plugin": "^2.11.0", "@types/he": "^1.2.3", diff --git a/packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts b/packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts index 34e2ddc093c..bb027170a86 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts @@ -435,6 +435,8 @@ export class Messenger { { tabID } ) } + + this.telemetryHelper.recordToolUseSuggested(toolUse, messageID) } else { throw new Error('Tool not found') } diff --git a/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts b/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts index 157a0725107..51029d2e2fc 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import * as path from 'path' -import { UserIntent } from '@amzn/codewhisperer-streaming' +import { ToolUse, UserIntent } from '@amzn/codewhisperer-streaming' import { AmazonqAddMessage, AmazonqInteractWithMessage, @@ -217,6 +217,17 @@ export class CWCTelemetryHelper { telemetry.feedback_result.emit({ result: feedbackResult }) } + public recordToolUseSuggested(toolUse: ToolUse, messageId: string) { + telemetry.amazonq_toolUseSuggested.emit({ + result: 'Succeeded', + cwsprChatConversationId: messageId, + cwsprChatConversationType: 'AgenticChatWithToolUse', + credentialStartUrl: AuthUtil.instance.startUrl, + cwsprToolName: toolUse.name ?? '', + cwsprToolUseId: toolUse.toolUseId ?? '', + }) + } + public recordInteractionWithAgenticChat( interactionType: AgenticChatInteractionType, message: AcceptResponseMessage | CustomFormActionMessage | StopResponseMessage