Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit chat and inline events to destination #574

Merged
merged 11 commits into from
Nov 8, 2024
Merged

Conversation

pras0131
Copy link
Contributor

@pras0131 pras0131 commented Nov 5, 2024

Problem

Reference: https://issues.amazon.com/issues/AWS-Cloud9-28780, https://issues.amazon.com/issues/AWS-Cloud9-28679
Report chat and inline completion events to destination based on the flag sent by the destination enableTelemetryEventsToDestination

UPD: in this PR we do not enable the configuration enableTelemetryEventsToDestination flag, and we always emit events with LSP and to SendTelemetryEvent API.

We will introduce the flag to disable telemetry, when all events are migrated to SendTelemetryEvent.

Solution

All the respective chat events are moved to TelemetryService, so it being a single point to emit events to STE or destination.
The PR also removes the call where they were being called before, so they are only called based on the condition now.
For emitChatAddMessage method in telemetry service, the arguments have been divided into params and additionalParams..additionalParams are only needed for event emit to destination. So in future when emitting events to destination has to be removed, the struct can be removed all together.
There is a change in TelemetryService constructor to set the default value of enableTelemetryEventsToDestination flag to false.
Test cases in the telemetry service have been updated to make sure if the flag is on, the respective event to destination is also emitted.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@pras0131 pras0131 requested review from a team as code owners November 5, 2024 14:40
@@ -185,6 +191,16 @@ export class TelemetryService extends CodeWhispererServiceToken {
if (options?.conversationId === undefined) {
return
}
if (this.enableTelemetryEventsToDestination) {
Copy link
Contributor

@viktorsaws viktorsaws Nov 6, 2024

Choose a reason for hiding this comment

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

Let's add an unit test for this condition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is already a unit test update for this when I am setting telemetryService.updateTelemetryEventsToDestination to true.

@@ -209,6 +225,18 @@ export class TelemetryService extends CodeWhispererServiceToken {
modificationPercentage: number
customizationArn?: string
}) {
if (this.enableTelemetryEventsToDestination) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to set enableTelemetryEventsToDestination to false as default value explicitly where it is first defined first https://github.com/aws/language-servers/pull/574/files#diff-9651c5ce85ab6404bc20ff59b61b93254f540d5e677f455b75e3d17ce5c07f08R36

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll set as default false in the constructor itself.

@pras0131 pras0131 changed the title Emit chat events to destination based on client flag Emit chat and inline events to destination based on client flag Nov 7, 2024
@viktorsaws
Copy link
Contributor

As we are introducing flag, which disables telemetry sent back to destination over LSP, we need to make sure all telemetry events respect the flag value.
Currently, there are events that are still sent to destination: e.g. in CodeWhispererServer we have codewhisperer_serviceInvocation, codewhisperer_perceivedLatency and codewhisperer_userDecision. In ChatController we have amazonq_sendFeedback.
And there's whole bunch of them in netTransform server.

We need to review and make sure they also are disabled on flag.

@@ -132,6 +140,43 @@ export class TelemetryService extends CodeWhispererServiceToken {
}

public emitUserTriggerDecision(session: CodeWhispererSession, timeSinceLastUserModification?: number) {
if (this.enableTelemetryEventsToDestination) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We still need explicit unit test for cases when enableTelemetryEventsToDestination is false. Currently we don't have test that would verify that this codepath is not called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the same.

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
*/
const enableTelemetryEventsToDestination = true
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd disable this call completely and rely on default value set in TelemetryService class. Did it in last commit.

@viktorsaws viktorsaws changed the title Emit chat and inline events to destination based on client flag Emit chat and inline events to destination Nov 8, 2024
@viktorsaws viktorsaws merged commit 2124762 into main Nov 8, 2024
5 checks passed
@viktorsaws viktorsaws deleted the chatEventsToDestination branch November 8, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants