From 222614851f6ca54a6de9e79d6f05ff8354e9ccd6 Mon Sep 17 00:00:00 2001 From: Tai Lai Date: Fri, 13 Dec 2024 21:39:38 +0000 Subject: [PATCH] telemetry(amazonq): generateFix metric result (#5199) --- .../codescan/CodeWhispererCodeScanIssueDetailsPanel.kt | 10 +++++++++- .../telemetry/CodeWhispererTelemetryService.kt | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanIssueDetailsPanel.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanIssueDetailsPanel.kt index 0d6caed871..3a1f7791a8 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanIssueDetailsPanel.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanIssueDetailsPanel.kt @@ -40,6 +40,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhisperer import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings import software.aws.toolkits.resources.message import software.aws.toolkits.telemetry.Component +import software.aws.toolkits.telemetry.MetricResult import java.awt.BorderLayout import java.awt.Dimension import java.awt.datatransfer.StringSelection @@ -88,6 +89,13 @@ internal class CodeWhispererCodeScanIssueDetailsPanel( scrollToReference("fixFailureSection") } } + CodeWhispererTelemetryService.getInstance().sendCodeScanIssueGenerateFix( + Component.Webview, + issue, + isRegenerate, + MetricResult.Failed, + codeFixResponse.failureResponse + ) } else { val isReferenceAllowed = CodeWhispererSettings.getInstance().isIncludeCodeWithReference() var suggestedFix = SuggestedFix( @@ -141,7 +149,7 @@ internal class CodeWhispererCodeScanIssueDetailsPanel( if (suggestedFix.code.isNotBlank()) { sendCodeFixGeneratedTelemetryToServiceAPI(issue, false) } - CodeWhispererTelemetryService.getInstance().sendCodeScanIssueGenerateFix(Component.Webview, issue, isRegenerate) + CodeWhispererTelemetryService.getInstance().sendCodeScanIssueGenerateFix(Component.Webview, issue, isRegenerate, MetricResult.Succeeded) } } } diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt index 4ff3c95cfb..086c4c351e 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt @@ -49,6 +49,7 @@ import software.aws.toolkits.telemetry.CodewhispererTelemetry import software.aws.toolkits.telemetry.CodewhispererTriggerType import software.aws.toolkits.telemetry.Component import software.aws.toolkits.telemetry.CredentialSourceId +import software.aws.toolkits.telemetry.MetricResult import software.aws.toolkits.telemetry.Result import java.time.Duration import java.time.Instant @@ -382,6 +383,8 @@ class CodeWhispererTelemetryService { component: Component, issue: CodeWhispererCodeScanIssue, isRefresh: Boolean, + result: MetricResult, + reason: String? = null, ) { CodewhispererTelemetry.codeScanIssueGenerateFix( component = component, @@ -389,7 +392,9 @@ class CodeWhispererTelemetryService { findingId = issue.findingId, detectorId = issue.detectorId, ruleId = issue.ruleId, - variant = if (isRefresh) "refresh" else null + variant = if (isRefresh) "refresh" else null, + result = result, + reason = reason ) }