Skip to content

Commit 2e15dac

Browse files
committed
send customization arn for chat telemetry
1 parent 6acf1e4 commit 2e15dac

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

packages/core/src/codewhisperer/tracker/codewhispererTracker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { InsertedCode } from '../../codewhispererChat/controllers/chat/model'
1515
import { codeWhispererClient } from '../client/codewhisperer'
1616
import { logSendTelemetryEventFailure } from '../../codewhispererChat/controllers/chat/telemetryHelper'
1717
import { Timeout } from '../../shared/utilities/timeoutUtils'
18+
import { activeCustomizationOrNull } from '../util/customizationUtil'
1819

1920
/**
2021
* This singleton class is mainly used for calculating the percentage of user modification.
@@ -88,6 +89,8 @@ export class CodeWhispererTracker {
8889

8990
public async emitTelemetryOnSuggestion(suggestion: AcceptedSuggestionEntry | InsertedCode) {
9091
let percentage = 1.0
92+
const customization = activeCustomizationOrNull()
93+
9194
try {
9295
if (suggestion.fileUrl?.scheme !== '') {
9396
const document = await vscode.workspace.openTextDocument(suggestion.fileUrl)
@@ -118,6 +121,7 @@ export class CodeWhispererTracker {
118121
conversationId: event.cwsprChatConversationId,
119122
messageId: event.cwsprChatMessageId,
120123
modificationPercentage: event.cwsprChatModificationPercentage,
124+
customizationArn: customization?.arn,
121125
},
122126
},
123127
})

packages/core/src/codewhisperer/util/customizationUtil.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ export const getSelectedCustomization = (): Customization => {
122122
}
123123
}
124124

125+
// codewhisperer service will throw validation exception if arn is empty string, thus we need to specifically pass undefined if it's base customization
126+
export function activeCustomizationOrNull(): Customization | undefined {
127+
const customization = getSelectedCustomization()
128+
if (customization === baseCustomization) {
129+
return undefined
130+
}
131+
132+
return customization
133+
}
134+
125135
export const setSelectedCustomization = async (customization: Customization) => {
126136
if (!AuthUtil.instance.isValidEnterpriseSsoInUse() || !AuthUtil.instance.conn) {
127137
return

packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { isAwsError } from '../../../shared/errors'
3434
import { ChatMessageInteractionType } from '../../../codewhisperer/client/codewhispereruserclient'
3535
import { supportedLanguagesList } from '../chat/chatRequest/converter'
3636
import { AuthUtil } from '../../../codewhisperer/util/authUtil'
37+
import { activeCustomizationOrNull } from '../../../codewhisperer/util/customizationUtil'
3738

3839
export function logSendTelemetryEventFailure(error: any) {
3940
let requestId: string | undefined
@@ -258,6 +259,7 @@ export class CWCTelemetryHelper {
258259
acceptedLineCount: event.cwsprChatAcceptedNumberOfLines,
259260
acceptedSnippetHasReference: false,
260261
hasProjectLevelContext: this.responseWithProjectContext.get(event.cwsprChatMessageId),
262+
customizationArn: activeCustomizationOrNull()?.arn,
261263
},
262264
},
263265
})
@@ -381,6 +383,7 @@ export class CWCTelemetryHelper {
381383
hasProjectLevelContext: triggerPayload.relevantTextDocuments
382384
? triggerPayload.relevantTextDocuments.length > 0
383385
: false,
386+
customizationArn: activeCustomizationOrNull()?.arn,
384387
},
385388
},
386389
})

0 commit comments

Comments
 (0)