From ef3ced592490214af916174a69740a5646482f26 Mon Sep 17 00:00:00 2001 From: Mingxuan Wang Date: Wed, 6 Aug 2025 12:01:13 -0700 Subject: [PATCH 1/4] add change log --- .../Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json diff --git a/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json b/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json new file mode 100644 index 00000000000..386908256e0 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json @@ -0,0 +1,4 @@ +{ + "type": "Feature", + "description": "add Amazon Q error fix/explain on hover/right-click for VSCode error indicators and messages" +} From ac1e682839806ecc366c95ca36d7f580a5e9cb6c Mon Sep 17 00:00:00 2001 From: Mingxuan Wang Date: Wed, 6 Aug 2025 12:27:42 -0700 Subject: [PATCH 2/4] edit change log --- .../Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json b/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json index 386908256e0..0f5dc6d01d3 100644 --- a/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json +++ b/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json @@ -1,4 +1,4 @@ { "type": "Feature", - "description": "add Amazon Q error fix/explain on hover/right-click for VSCode error indicators and messages" + "description": "Amazon Q Chat provides error explanations and fixes when hovering or right-clicking on error indicators and messages" } From 75d2777cf37a31c72991196a678894dc3a3591c1 Mon Sep 17 00:00:00 2001 From: Mingxuan Wang Date: Wed, 6 Aug 2025 18:33:19 -0700 Subject: [PATCH 3/4] add telemetry support for auto debug --- .../src/lsp/chat/autoDebug/commands.ts | 24 ++++++- .../src/lsp/chat/autoDebug/controller.ts | 10 +-- .../src/lsp/chat/autoDebug/telemetry.ts | 71 +++++++++++++++++++ .../src/shared/telemetry/vscodeTelemetry.json | 46 ++++++++++++ 4 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 packages/amazonq/src/lsp/chat/autoDebug/telemetry.ts diff --git a/packages/amazonq/src/lsp/chat/autoDebug/commands.ts b/packages/amazonq/src/lsp/chat/autoDebug/commands.ts index 54dfd06a1dc..29003a9c6e8 100644 --- a/packages/amazonq/src/lsp/chat/autoDebug/commands.ts +++ b/packages/amazonq/src/lsp/chat/autoDebug/commands.ts @@ -6,6 +6,7 @@ import * as vscode from 'vscode' import { Commands, getLogger, messages } from 'aws-core-vscode/shared' import { AutoDebugController } from './controller' +import { autoDebugTelemetry } from './telemetry' /** * Auto Debug commands for Amazon Q @@ -72,6 +73,16 @@ export class AutoDebugCommands implements vscode.Disposable { return await action() } catch (error) { this.logger.error(`AutoDebugCommands: Error in ${logContext}: %s`, error) + + // Record telemetry failure based on context + const commandType = + logContext === 'fixWithAmazonQ' + ? 'fixWithQ' + : logContext === 'fixAllWithAmazonQ' + ? 'fixAllWithQ' + : 'explainProblem' + autoDebugTelemetry.recordCommandFailure(commandType, String(error)) + void messages.showMessage('error', 'Amazon Q was not able to fix or explain the problem. Try again shortly') } } @@ -91,6 +102,9 @@ export class AutoDebugCommands implements vscode.Disposable { * Fix with Amazon Q - fixes only the specific issues the user selected */ private async fixWithAmazonQ(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise { + const problemCount = diagnostics?.length + autoDebugTelemetry.recordCommandInvocation('fixWithQ', problemCount) + await this.executeWithErrorHandling( async () => { const editor = this.checkActiveEditor() @@ -98,6 +112,7 @@ export class AutoDebugCommands implements vscode.Disposable { return } await this.controller.fixSpecificProblems(range, diagnostics) + autoDebugTelemetry.recordCommandSuccess('fixWithQ', problemCount) }, 'Fix with Amazon Q', 'fixWithAmazonQ' @@ -108,13 +123,16 @@ export class AutoDebugCommands implements vscode.Disposable { * Fix All with Amazon Q - processes all errors in the current file */ private async fixAllWithAmazonQ(): Promise { + autoDebugTelemetry.recordCommandInvocation('fixAllWithQ') + await this.executeWithErrorHandling( async () => { const editor = this.checkActiveEditor() if (!editor) { return } - await this.controller.fixAllProblemsInFile(10) // 10 errors per batch + const problemCount = await this.controller.fixAllProblemsInFile(10) // 10 errors per batch + autoDebugTelemetry.recordCommandSuccess('fixAllWithQ', problemCount) }, 'Fix All with Amazon Q', 'fixAllWithAmazonQ' @@ -125,6 +143,9 @@ export class AutoDebugCommands implements vscode.Disposable { * Explains the problem using Amazon Q */ private async explainProblem(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise { + const problemCount = diagnostics?.length + autoDebugTelemetry.recordCommandInvocation('explainProblem', problemCount) + await this.executeWithErrorHandling( async () => { const editor = this.checkActiveEditor() @@ -132,6 +153,7 @@ export class AutoDebugCommands implements vscode.Disposable { return } await this.controller.explainProblems(range, diagnostics) + autoDebugTelemetry.recordCommandSuccess('explainProblem', problemCount) }, 'Explain Problem', 'explainProblem' diff --git a/packages/amazonq/src/lsp/chat/autoDebug/controller.ts b/packages/amazonq/src/lsp/chat/autoDebug/controller.ts index 0a0f8e10622..66dcc83b21d 100644 --- a/packages/amazonq/src/lsp/chat/autoDebug/controller.ts +++ b/packages/amazonq/src/lsp/chat/autoDebug/controller.ts @@ -110,32 +110,34 @@ export class AutoDebugController implements vscode.Disposable { /** * Fix with Amazon Q - sends up to 15 error messages one time when user clicks the button */ - public async fixAllProblemsInFile(maxProblems: number = 15): Promise { + public async fixAllProblemsInFile(maxProblems: number = 15): Promise { try { const editor = vscode.window.activeTextEditor if (!editor) { void messages.showMessage('warn', 'No active editor found') - return + return 0 } // Get all diagnostics for the current file const allDiagnostics = vscode.languages.getDiagnostics(editor.document.uri) const errorDiagnostics = this.filterErrorDiagnostics(allDiagnostics) if (errorDiagnostics.length === 0) { - return + return 0 } // Take up to maxProblems errors (15 by default) const diagnosticsToFix = errorDiagnostics.slice(0, maxProblems) const result = await this.getProblemsFromDiagnostics(undefined, diagnosticsToFix) if (!result) { - return + return 0 } const fixMessage = this.createFixMessage(result.editor.document.uri.fsPath, result.problems) await this.sendMessageToChat(fixMessage) + return result.problems.length } catch (error) { this.logger.error('AutoDebugController: Error in fix process: %s', error) + throw error } } diff --git a/packages/amazonq/src/lsp/chat/autoDebug/telemetry.ts b/packages/amazonq/src/lsp/chat/autoDebug/telemetry.ts new file mode 100644 index 00000000000..dec3f424c5a --- /dev/null +++ b/packages/amazonq/src/lsp/chat/autoDebug/telemetry.ts @@ -0,0 +1,71 @@ +/*! + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { telemetry } from 'aws-core-vscode/telemetry' + +/** + * Auto Debug command types for telemetry tracking + */ +export type AutoDebugCommandType = 'fixWithQ' | 'fixAllWithQ' | 'explainProblem' + +/** + * Telemetry interface for Auto Debug feature + * Tracks usage counts and success rates for the three main commands + */ +export interface AutoDebugTelemetry { + /** + * Record when an auto debug command is invoked + */ + recordCommandInvocation(commandType: AutoDebugCommandType, problemCount?: number): void + + /** + * Record when an auto debug command succeeds + */ + recordCommandSuccess(commandType: AutoDebugCommandType, problemCount?: number): void + + /** + * Record when an auto debug command fails + */ + recordCommandFailure(commandType: AutoDebugCommandType, error?: string, problemCount?: number): void +} + +/** + * Implementation of Auto Debug telemetry tracking + */ +export class AutoDebugTelemetryImpl implements AutoDebugTelemetry { + recordCommandInvocation(commandType: AutoDebugCommandType, problemCount?: number): void { + telemetry.amazonq_autoDebugCommand.emit({ + amazonqAutoDebugCommandType: commandType, + amazonqAutoDebugAction: 'invoked', + amazonqAutoDebugProblemCount: problemCount, + result: 'Succeeded', + }) + } + + recordCommandSuccess(commandType: AutoDebugCommandType, problemCount?: number): void { + telemetry.amazonq_autoDebugCommand.emit({ + amazonqAutoDebugCommandType: commandType, + amazonqAutoDebugAction: 'completed', + amazonqAutoDebugProblemCount: problemCount, + result: 'Succeeded', + }) + } + + recordCommandFailure(commandType: AutoDebugCommandType, error?: string, problemCount?: number): void { + telemetry.amazonq_autoDebugCommand.emit({ + amazonqAutoDebugCommandType: commandType, + amazonqAutoDebugAction: 'completed', + amazonqAutoDebugProblemCount: problemCount, + result: 'Failed', + reason: error ? 'Error' : 'Unknown', + reasonDesc: error?.substring(0, 200), // Truncate to 200 chars as recommended + }) + } +} + +/** + * Global instance of auto debug telemetry + */ +export const autoDebugTelemetry: AutoDebugTelemetry = new AutoDebugTelemetryImpl() diff --git a/packages/core/src/shared/telemetry/vscodeTelemetry.json b/packages/core/src/shared/telemetry/vscodeTelemetry.json index 1128eef8ab6..8cddfb9cba4 100644 --- a/packages/core/src/shared/telemetry/vscodeTelemetry.json +++ b/packages/core/src/shared/telemetry/vscodeTelemetry.json @@ -238,6 +238,23 @@ "name": "executedCount", "type": "int", "description": "The number of executed operations" + }, + { + "name": "amazonqAutoDebugCommandType", + "type": "string", + "allowedValues": ["fixWithQ", "fixAllWithQ", "explainProblem"], + "description": "The type of auto debug command executed" + }, + { + "name": "amazonqAutoDebugAction", + "type": "string", + "allowedValues": ["invoked", "completed"], + "description": "The action performed (invoked or completed)" + }, + { + "name": "amazonqAutoDebugProblemCount", + "type": "int", + "description": "Number of problems being processed" } ], "metrics": [ @@ -1257,6 +1274,35 @@ "required": false } ] + }, + { + "name": "amazonq_autoDebugCommand", + "description": "Tracks usage of Amazon Q auto debug commands (fixWithQ, fixAllWithQ, explainProblem)", + "metadata": [ + { + "type": "amazonqAutoDebugCommandType", + "required": true + }, + { + "type": "amazonqAutoDebugAction", + "required": true + }, + { + "type": "amazonqAutoDebugProblemCount", + "required": false + }, + { + "type": "result" + }, + { + "type": "reason", + "required": false + }, + { + "type": "reasonDesc", + "required": false + } + ] } ] } From 62f607f26a27fb0f8546d0689c151c7836861fb9 Mon Sep 17 00:00:00 2001 From: Mingxuan Wang Date: Wed, 6 Aug 2025 18:40:53 -0700 Subject: [PATCH 4/4] revert unnecessary file changes --- .../Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json diff --git a/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json b/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json deleted file mode 100644 index 0f5dc6d01d3..00000000000 --- a/packages/amazonq/.changes/next-release/Feature-a517b202-5a1c-42c7-b7a4-06bae2a38e8f.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "Feature", - "description": "Amazon Q Chat provides error explanations and fixes when hovering or right-clicking on error indicators and messages" -}