Skip to content

Commit cd4a74b

Browse files
authored
Merge pull request #5362 from Will-ShaoHua/chat-custom
feat(chat): chat customization telemetry
2 parents ee2c934 + e49d055 commit cd4a74b

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

packages/core/src/codewhisperer/client/user-service-2.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@
399399
"members": {
400400
"conversationId": { "shape": "ConversationId" },
401401
"messageId": { "shape": "MessageId" },
402+
"customizationArn": { "shape": "CustomizationArn" },
402403
"userIntent": { "shape": "UserIntent" },
403404
"hasCodeSnippet": { "shape": "Boolean" },
404405
"programmingLanguage": { "shape": "ProgrammingLanguage" },
@@ -425,6 +426,7 @@
425426
"members": {
426427
"conversationId": { "shape": "ConversationId" },
427428
"messageId": { "shape": "MessageId" },
429+
"customizationArn": { "shape": "CustomizationArn" },
428430
"interactionType": { "shape": "ChatMessageInteractionType" },
429431
"interactionTarget": { "shape": "ChatInteractWithMessageEventInteractionTargetString" },
430432
"acceptedCharacterCount": { "shape": "Integer" },
@@ -471,6 +473,7 @@
471473
"required": ["conversationId", "messageId", "modificationPercentage"],
472474
"members": {
473475
"conversationId": { "shape": "ConversationId" },
476+
"customizationArn": { "shape": "CustomizationArn" },
474477
"messageId": { "shape": "MessageId" },
475478
"programmingLanguage": { "shape": "ProgrammingLanguage" },
476479
"modificationPercentage": { "shape": "Double" },

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ 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 { getSelectedCustomization } from '../util/customizationUtil'
19+
import { undefinedIfEmpty } from '../../shared'
1820

1921
/**
2022
* This singleton class is mainly used for calculating the percentage of user modification.
@@ -88,6 +90,7 @@ export class CodeWhispererTracker {
8890

8991
public async emitTelemetryOnSuggestion(suggestion: AcceptedSuggestionEntry | InsertedCode) {
9092
let percentage = 1.0
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: undefinedIfEmpty(getSelectedCustomization().arn),
121125
},
122126
},
123127
})

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ 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 { getSelectedCustomization } from '../../../codewhisperer/util/customizationUtil'
38+
import { undefinedIfEmpty } from '../../../shared'
3739

3840
export function logSendTelemetryEventFailure(error: any) {
3941
let requestId: string | undefined
@@ -258,6 +260,7 @@ export class CWCTelemetryHelper {
258260
acceptedLineCount: event.cwsprChatAcceptedNumberOfLines,
259261
acceptedSnippetHasReference: false,
260262
hasProjectLevelContext: this.responseWithProjectContext.get(event.cwsprChatMessageId),
263+
customizationArn: undefinedIfEmpty(getSelectedCustomization().arn),
261264
},
262265
},
263266
})
@@ -381,6 +384,7 @@ export class CWCTelemetryHelper {
381384
hasProjectLevelContext: triggerPayload.relevantTextDocuments
382385
? triggerPayload.relevantTextDocuments.length > 0
383386
: false,
387+
customizationArn: undefinedIfEmpty(getSelectedCustomization().arn),
384388
},
385389
},
386390
})

0 commit comments

Comments
 (0)