diff --git a/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt b/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt index 929f92510d..6a3a660df6 100644 --- a/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt +++ b/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt @@ -440,7 +440,7 @@ class CodeWhispererService { false, false, "", - CodewhispererCompletionType.Unknown + CodewhispererCompletionType.Line ), -1, CodewhispererSuggestionState.Empty, diff --git a/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt b/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt index 26ec48c606..8ba2f8a02f 100644 --- a/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt +++ b/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt @@ -209,12 +209,7 @@ class CodeWhispererTelemetryService { val classifierThreshold = CodeWhispererAutoTriggerService.getThreshold() val supplementalContext = requestContext.supplementalContext - val completionType = if (recommendationContext.details.any { - it.completionType == CodewhispererCompletionType.Block - } - ) { - CodewhispererCompletionType.Block - } else CodewhispererCompletionType.Line + val completionType = if (recommendationContext.details.isEmpty()) CodewhispererCompletionType.Line else recommendationContext.details[0].completionType // only send if it's a pro tier user projectCoroutineScope(project).launch { diff --git a/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererUtil.kt b/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererUtil.kt index 1e9fc1760f..90df347c28 100644 --- a/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererUtil.kt +++ b/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererUtil.kt @@ -146,7 +146,7 @@ object CodeWhispererUtil { val nonBlankLines = content.split("\n").count { it.isNotBlank() } return when { - content.isEmpty() -> CodewhispererCompletionType.Unknown + content.isEmpty() -> CodewhispererCompletionType.Line nonBlankLines > 1 -> CodewhispererCompletionType.Block else -> CodewhispererCompletionType.Line } diff --git a/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryServiceTest.kt b/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryServiceTest.kt index 39baf09326..97054ea5b8 100644 --- a/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryServiceTest.kt +++ b/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryServiceTest.kt @@ -46,7 +46,6 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.CodeWhis import software.aws.toolkits.jetbrains.services.telemetry.NoOpPublisher import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService import software.aws.toolkits.jetbrains.settings.AwsSettings -import software.aws.toolkits.telemetry.CodewhispererCompletionType import software.aws.toolkits.telemetry.CodewhispererPreviousSuggestionState import software.aws.toolkits.telemetry.CodewhispererSuggestionState import java.time.Duration @@ -265,7 +264,7 @@ class CodeWhispererTelemetryServiceTest { 1, "codewhispererSessionId" to responseContext.sessionId, "codewhispererFirstRequestId" to requestContext.latencyContext.firstRequestId, - "codewhispererCompletionType" to CodewhispererCompletionType.Line, + "codewhispererCompletionType" to recommendationContext.details[0].completionType, "codewhispererLanguage" to requestContext.fileContextInfo.programmingLanguage.toTelemetryType(), "codewhispererTriggerType" to requestContext.triggerTypeInfo.triggerType, "codewhispererAutomatedTriggerType" to requestContext.triggerTypeInfo.automatedTriggerType.telemetryType, @@ -467,12 +466,7 @@ class CodeWhispererTelemetryServiceTest { val expectedSuggestionReferenceCount = 1 val expectedGeneratedLineCount = 50 val expectedCharCount = 100 - val expectedCompletionType = if (expectedRecommendationContext.details.any { - it.completionType == CodewhispererCompletionType.Block - } - ) { - CodewhispererCompletionType.Block - } else CodewhispererCompletionType.Line + val expectedCompletionType = expectedRecommendationContext.details[0].completionType sut.sendUserTriggerDecisionEvent( expectedRequestContext, expectedResponseContext, diff --git a/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryTest.kt b/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryTest.kt index e619ef743d..0ae5acb995 100644 --- a/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryTest.kt +++ b/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTelemetryTest.kt @@ -819,7 +819,8 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() { metricCaptor.allValues, userDecision, numOfEmptyRecommendations, - "codewhispererSuggestionState" to CodewhispererSuggestionState.Empty.toString() + "codewhispererSuggestionState" to CodewhispererSuggestionState.Empty.toString(), + "codewhispererCompletionType" to CodewhispererCompletionType.Line.toString() ) } } diff --git a/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestUtil.kt b/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestUtil.kt index cc72297709..029bd057de 100644 --- a/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestUtil.kt +++ b/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestUtil.kt @@ -310,13 +310,13 @@ fun aRecommendationContextAndSessionContext(decisions: List val toAdd = if (decision == CodewhispererSuggestionState.Empty) { val completion = aCompletion("", true, 0, 0) - DetailContext(aString(), completion, completion, Random.nextBoolean(), Random.nextBoolean(), aString(), CodewhispererCompletionType.Unknown) + DetailContext(aString(), completion, completion, Random.nextBoolean(), Random.nextBoolean(), aString(), CodewhispererCompletionType.Line) } else if (decision == CodewhispererSuggestionState.Discard) { val completion = aCompletion() - DetailContext(aString(), completion, completion, true, Random.nextBoolean(), aString(), CodewhispererCompletionType.Unknown) + DetailContext(aString(), completion, completion, true, Random.nextBoolean(), aString(), CodewhispererCompletionType.Line) } else { val completion = aCompletion() - DetailContext(aString(), completion, completion, false, Random.nextBoolean(), aString(), CodewhispererCompletionType.Unknown) + DetailContext(aString(), completion, completion, false, Random.nextBoolean(), aString(), CodewhispererCompletionType.Line) } details.add(toAdd)