Skip to content

Commit 989ad78

Browse files
feat(amazonq): emit metrics for explainIssue and applyFix
1 parent 25603bc commit 989ad78

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/amazonq/src/lsp/chat/commands.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import { Commands, globals } from 'aws-core-vscode/shared'
77
import { window } from 'vscode'
88
import { AmazonQChatViewProvider } from './webviewProvider'
9-
import { CodeScanIssue } from 'aws-core-vscode/codewhisperer'
9+
import { CodeScanIssue, AuthUtil } from 'aws-core-vscode/codewhisperer'
1010
import { getLogger } from 'aws-core-vscode/shared'
1111
import * as vscode from 'vscode'
1212
import * as path from 'path'
1313
import { codeReviewInChat } from '../../app/amazonqScan/models/constants'
14+
import { telemetry, AmazonqCodeReviewTool } from 'aws-core-vscode/telemetry'
1415

1516
/**
1617
* TODO: Re-enable these once we can figure out which path they're going to live in
@@ -30,7 +31,8 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
3031
filePath,
3132
'Explain',
3233
'Provide a small description of the issue. You must not attempt to fix the issue. You should only give a small summary of it to the user.',
33-
provider
34+
provider,
35+
'explainIssue'
3436
)
3537
),
3638
Commands.register('aws.amazonq.generateFix', (issue: CodeScanIssue, filePath: string) =>
@@ -39,7 +41,8 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
3941
filePath,
4042
'Fix',
4143
'Generate a fix for the following code issue. You must not explain the issue, just generate and explain the fix. The user should have the option to accept or reject the fix before any code is changed.',
42-
provider
44+
provider,
45+
'applyFix'
4346
)
4447
),
4548
Commands.register('aws.amazonq.sendToPrompt', (data) => {
@@ -74,7 +77,8 @@ async function handleIssueCommand(
7477
filePath: string,
7578
action: string,
7679
contextPrompt: string,
77-
provider: AmazonQChatViewProvider
80+
provider: AmazonQChatViewProvider,
81+
metricName: string
7882
) {
7983
await focusAmazonQPanel()
8084

@@ -98,6 +102,16 @@ async function handleIssueCommand(
98102
autoSubmit: true,
99103
},
100104
})
105+
106+
telemetry.amazonq_codeReviewTool.emit({
107+
findingId: issue.findingId,
108+
detectorId: issue.detectorId,
109+
ruleId: issue.ruleId,
110+
credentialStartUrl: AuthUtil.instance.startUrl,
111+
autoDetected: issue.autoDetected,
112+
result: 'Succeeded',
113+
reason: metricName,
114+
} as AmazonqCodeReviewTool)
101115
}
102116

103117
async function openFileWithSelection(issue: CodeScanIssue, filePath: string) {

0 commit comments

Comments
 (0)