Skip to content

Commit c53f672

Browse files
authored
fix: emit acceptedLineCount metric and AgenticCodeAccepted interaction type (aws#2167)
1 parent 1c9e8a1 commit c53f672

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,19 @@ export class AgenticChatController implements ChatHandlers {
20762076
this.#abTestingAllocation?.experimentName,
20772077
this.#abTestingAllocation?.userVariation
20782078
)
2079+
// Emit acceptedLineCount when write tool is used and code changes are accepted
2080+
const beforeLines = cachedToolUse?.fileChange?.before?.split('\n').length ?? 0
2081+
const afterLines = doc?.getText()?.split('\n').length ?? 0
2082+
const acceptedLineCount = afterLines - beforeLines
2083+
await this.#telemetryController.emitInteractWithMessageMetric(
2084+
tabId,
2085+
{
2086+
cwsprChatMessageId: chatResult.messageId ?? toolUse.toolUseId,
2087+
cwsprChatInteractionType: ChatInteractionType.AgenticCodeAccepted,
2088+
codewhispererCustomizationArn: this.#customizationArn,
2089+
},
2090+
acceptedLineCount
2091+
)
20792092
await chatResultStream.writeResultBlock(chatResult)
20802093
break
20812094
case CodeReview.toolName:

server/aws-lsp-codewhisperer/src/language-server/chat/telemetry/chatTelemetryController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,12 @@ export class ChatTelemetryController {
421421

422422
public emitInteractWithMessageMetric(
423423
tabId: string,
424-
metric: Omit<InteractWithMessageEvent, 'cwsprChatConversationId'>
424+
metric: Omit<InteractWithMessageEvent, 'cwsprChatConversationId'>,
425+
acceptedLineCount?: number
425426
) {
426427
return this.#telemetryService.emitChatInteractWithMessage(metric, {
427428
conversationId: this.getConversationId(tabId),
429+
acceptedLineCount,
428430
})
429431
}
430432

server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class TelemetryService {
6666
[ChatInteractionType.Upvote]: 'UPVOTE',
6767
[ChatInteractionType.Downvote]: 'DOWNVOTE',
6868
[ChatInteractionType.ClickBodyLink]: 'CLICK_BODY_LINK',
69+
[ChatInteractionType.AgenticCodeAccepted]: 'AGENTIC_CODE_ACCEPTED',
6970
}
7071

7172
constructor(

server/aws-lsp-codewhisperer/src/shared/telemetry/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ export enum ChatInteractionType {
429429
Upvote = 'upvote',
430430
Downvote = 'downvote',
431431
ClickBodyLink = 'clickBodyLink',
432+
AgenticCodeAccepted = 'agenticCodeAccepted',
432433
}
433434

434435
export enum ChatHistoryActionType {

0 commit comments

Comments
 (0)