Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -63,6 +63,7 @@ export class ChatTelemetryController {
#tabTelemetryInfoByTabId: { [tabId: string]: ConversationTriggerInfo }
#currentTriggerByTabId: { [tabId: string]: TriggerType } = {}
#customizationInfoByTabAndMessageId: { [tabId: string]: { [messageId: string]: string } }
#programmingLanguageByTabId: { [tabId: string]: CodewhispererLanguage } = {}
#credentialsProvider: CredentialsProvider
#telemetry: Telemetry
#logging: Logging
Expand All @@ -73,6 +74,7 @@ export class ChatTelemetryController {
this.#tabTelemetryInfoByTabId = {}
this.#currentTriggerByTabId = {}
this.#customizationInfoByTabAndMessageId = {}
this.#programmingLanguageByTabId = {}
this.#telemetry = features.telemetry
this.#logging = features.logging
this.#credentialsProvider = features.credentialsProvider
Expand Down Expand Up @@ -103,6 +105,10 @@ export class ChatTelemetryController {
return tabId && messageId && this.#customizationInfoByTabAndMessageId[tabId]?.[messageId]
}

public getProgrammingLanguage(tabId: string) {
return this.#programmingLanguageByTabId[tabId]
}

public removeConversation(tabId: string) {
delete this.#tabTelemetryInfoByTabId[tabId]
delete this.#customizationInfoByTabAndMessageId[tabId]
Expand Down Expand Up @@ -309,6 +315,10 @@ export class ChatTelemetryController {
[metric.cwsprChatMessageId]: metric.codewhispererCustomizationArn,
}
}
// Store the programming language for this tab
if (metric.cwsprChatProgrammingLanguage) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This wont be accurate! as one conversation can have multiple programming languages.

this.#programmingLanguageByTabId[tabId] = metric.cwsprChatProgrammingLanguage as CodewhispererLanguage
}
return this.#telemetryService.emitChatAddMessage(
{
conversationId: conversationId,
Expand Down Expand Up @@ -555,6 +565,7 @@ export class ChatTelemetryController {
}
await this.#telemetryService.emitChatInteractWithMessage(voteData, {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you clarify when this event will be emitted?

conversationId: this.getConversationId(params.tabId),
programmingLanguage: this.getProgrammingLanguage(params.tabId),
})
break
case ChatUIEventName.InsertToCursorPosition:
Expand All @@ -581,6 +592,7 @@ export class ChatTelemetryController {
params.name === ChatUIEventName.InsertToCursorPosition
? params.code?.split('\n').length
: undefined,
programmingLanguage: this.getProgrammingLanguage(params.tabId),
})
break
case ChatUIEventName.LinkClick:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,29 @@
},
})
})

it('should send InteractWithMessage with programming language when provided', () => {
const metric = {
cwsprChatMessageId: 'message123',
cwsprChatInteractionType: ChatInteractionType.InsertAtCursor,
cwsprChatAcceptedCharactersLength: 100,
}
telemetryService.emitChatInteractWithMessage(metric, {
conversationId: 'conv123',
programmingLanguage: 'typescript',
})

sinon.assert.calledOnce(codeWhisperServiceStub.sendTelemetryEvent)
const call = codeWhisperServiceStub.sendTelemetryEvent.getCall(0)
const event = call?.args[0]?.telemetryEvent?.chatInteractWithMessageEvent

// Verify programming language is set correctly
if (event) {
sinon.assert.match(event.programmingLanguage, {

Check failure on line 548 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.test.ts

View workflow job for this annotation

GitHub Actions / Package

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 548 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.test.ts

View workflow job for this annotation

GitHub Actions / Test (Windows)

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 548 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.test.ts

View workflow job for this annotation

GitHub Actions / Package (Windows)

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 548 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.test.ts

View workflow job for this annotation

GitHub Actions / Test

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 548 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.test.ts

View workflow job for this annotation

GitHub Actions / Test public NPM packages

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.
languageName: 'typescript',
})
}
})
})

it('should emit CodeCoverageEvent event to STE and to the destination', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
options?: {
conversationId?: string
acceptedLineCount?: number
programmingLanguage?: CodewhispererLanguage
}
) {
if (options?.conversationId === undefined) {
Expand Down Expand Up @@ -351,6 +352,11 @@
if (metric.codewhispererCustomizationArn) {
event.customizationArn = metric.codewhispererCustomizationArn
}
if (options.programmingLanguage) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How did we evaluate the programmingLanguage?

event.programmingLanguage = {

Check failure on line 356 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

View workflow job for this annotation

GitHub Actions / Package

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 356 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

View workflow job for this annotation

GitHub Actions / Test (Windows)

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 356 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

View workflow job for this annotation

GitHub Actions / Package (Windows)

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 356 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

View workflow job for this annotation

GitHub Actions / Test

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.

Check failure on line 356 in server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

View workflow job for this annotation

GitHub Actions / Test public NPM packages

Property 'programmingLanguage' does not exist on type 'ChatInteractWithMessageEvent'.
languageName: getRuntimeLanguage(options.programmingLanguage),
}
}
return this.invokeSendTelemetryEvent({
chatInteractWithMessageEvent: event,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ export type InteractWithMessageEvent = {
cwsprChatCodeBlockIndex?: number
cwsprChatTotalCodeBlocks?: number
codewhispererCustomizationArn?: string
cwsprChatProgrammingLanguage?: string
}

export type StartConversationEvent = {
Expand Down
Loading