Skip to content

Commit d03b7d1

Browse files
authored
fix(codewhisperer): use stored session id in aggregated user decision events #3684
Problem: The session id can be empty in the aggregated user decision events. To reproduce it: invoke, and keep pressing Esc. When you press Esc frequently, multiple clear state function can be run in parallel, causing race conditions that set the session id to empty string. Solution: Use the pre-existing, stored, non-empty session id in the aggregated user decision events. This solution only works for aggregated user decision events, it does not solve the global state problem in this code base.
1 parent f874184 commit d03b7d1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/codewhisperer/util/telemetryHelper.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class TelemetryHelper {
219219
(this.lastRequestId && this.lastRequestId === requestId) ||
220220
(this.sessionDecisions.length && this.sessionDecisions.length === this.numberOfRequests)
221221
) {
222-
this.sendUserTriggerDecisionTelemetry(sessionId, supplementalContextMetadata)
222+
this.sendUserTriggerDecisionTelemetry(supplementalContextMetadata)
223223
}
224224
}
225225

@@ -260,7 +260,6 @@ export class TelemetryHelper {
260260
}
261261

262262
private sendUserTriggerDecisionTelemetry(
263-
sessionId: string,
264263
supplementalContextMetadata?: Omit<CodeWhispererSupplementalContext, 'supplementalContextItems'> | undefined
265264
) {
266265
// the user trigger decision will aggregate information from request level user decisions within one session
@@ -273,7 +272,7 @@ export class TelemetryHelper {
273272
const autoTriggerType = this.sessionDecisions[0].codewhispererAutomatedTriggerType
274273
const language = this.sessionDecisions[0].codewhispererLanguage
275274
const aggregated: CodewhispererUserTriggerDecision = {
276-
codewhispererSessionId: sessionId,
275+
codewhispererSessionId: this.sessionDecisions[0].codewhispererSessionId,
277276
codewhispererFirstRequestId: this.sessionDecisions[0].codewhispererFirstRequestId,
278277
credentialStartUrl: this.sessionDecisions[0].credentialStartUrl,
279278
codewhispererCompletionType: this.getAggregatedCompletionType(this.sessionDecisions),

0 commit comments

Comments
 (0)