Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credential
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.SsoProfileData
import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings
import java.util.concurrent.CompletableFuture
import migration.software.aws.toolkits.jetbrains.settings.AwsSettings

/**
* Concrete implementation of [AmazonQLanguageClient] to handle messages sent from server
Expand Down Expand Up @@ -87,6 +88,13 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
)
)
}
AmazonQLspConstants.LSP_Q_CONFIGURATION_KEY -> {
add(
AmazonQLspConfiguration(
optOutTelemetry = AwsSettings.getInstance().isTelemetryEnabled
)
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.services.amazonq.lsp

import com.google.gson.annotations.SerializedName

data class AmazonQLspConfiguration(
@SerializedName(AmazonQLspConstants.LSP_OPT_OUT_TELEMETRY_CONFIGURATION_KEY)
val optOutTelemetry: Boolean? = null,

@SerializedName(AmazonQLspConstants.LSP_ENABLE_TELEMETRY_EVENTS_CONFIGURATION_KEY)
Copy link
Contributor Author

@samgst-amazon samgst-amazon Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag enableTelemetryEventsToDestination is set to true temporarily. It's value will be determined through destination configuration post all events migration to STE. It'll be replaced by qConfig['enableTelemetryEventsToDestination'] === true

This is not currently being used but will be in future migrations. not exactly sure what it should be pointing to in current codebase

val enableTelemetryEvents: Boolean? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ object AmazonQLspConstants {
const val LSP_CW_CONFIGURATION_KEY = "aws.codeWhisperer"
const val LSP_CW_OPT_OUT_KEY = "shareCodeWhispererContentWithAWS"
const val LSP_CODE_REFERENCES_OPT_OUT_KEY = "includeSuggestionsWithCodeReferences"
const val LSP_Q_CONFIGURATION_KEY = "aws.q"
const val LSP_OPT_OUT_TELEMETRY_CONFIGURATION_KEY = "optOutTelemetry"
const val LSP_ENABLE_TELEMETRY_EVENTS_CONFIGURATION_KEY = "enableTelemetryEventsToDestination"
const val LSP_CUSTOMIZATION_CONFIGURATION_KEY = "customization";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not sure what value this was tracking -- on the server side I see
if (qConfig) { fallbackCodeWhispererService.customizationArn = textUtils.undefinedIfEmpty(qConfig.customization) codePercentageTracker.customizationArn = textUtils.undefinedIfEmpty(qConfig.customization)

Does this mean the customization value we are sending should just be this:

?



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.eclipse.lsp4j.ConfigurationItem
import org.eclipse.lsp4j.ConfigurationParams
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import migration.software.aws.toolkits.jetbrains.settings.AwsSettings
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
Expand Down Expand Up @@ -107,6 +108,44 @@ class AmazonQLanguageClientImplTest {
)
}

@Test
fun `configuration for Amazon Q respects telemetry enabled`() {
AwsSettings.getInstance().isTelemetryEnabled = true
assertThat(sut.configuration(configurationParams("aws.q")).get())
.singleElement()
.isEqualTo(
AmazonQLspConfiguration(
optOutTelemetry = true
)
)
}

@Test
fun `configuration for Amazon Q respects telemetry disabled`() {
AwsSettings.getInstance().isTelemetryEnabled = false
assertThat(sut.configuration(configurationParams("aws.q")).get())
.singleElement()
.isEqualTo(
AmazonQLspConfiguration(
optOutTelemetry = false
)
)
}

@Test
fun `Gson serializes AmazonQLspConfiguration correctly`() {
val sut = AmazonQLspConfiguration(
optOutTelemetry = true
)
assertThat(Gson().toJson(sut)).isEqualToIgnoringWhitespace(
"""
{
"optOutTelemetry": true
}
""".trimIndent()
)
}

private fun configurationParams(vararg attributes: String) = ConfigurationParams(
attributes.map {
ConfigurationItem().apply {
Expand Down
Loading