Skip to content

Conversation

@vijayupadya
Copy link
Contributor

Fixes https://github.com/microsoft/vscode-internalbacklog/issues/6678

Fixes missing copilotTracking ID (tid) values in error telemetry events (e.g., [response.error] for quotaExceeded, badRequest).

When the Copilot token is reset due to HTTP 401/402/403 responses, the telemetry sender was clearing the tid value immediately. Since error telemetry is sent after the token reset, these events were missing the tracking ID.

The fix preserves the last known tid value instead of clearing it when the token becomes undefined, ensuring error events can still be correlated with the user session that made the request.

@vijayupadya vijayupadya added the bug Issue identified by VS Code Team member as probable bug label Jan 30, 2026
@vijayupadya vijayupadya added this to the January 2026 milestone Jan 30, 2026
@vijayupadya vijayupadya marked this pull request as ready for review January 30, 2026 02:26
Copilot AI review requested due to automatic review settings January 30, 2026 02:26
@vijayupadya vijayupadya enabled auto-merge January 30, 2026 02:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes missing copilotTracking ID (tid) values in error telemetry events by preserving the last known tid when the Copilot token is reset to undefined.

Changes:

  • Modified processToken to preserve the tid value when a token becomes undefined, rather than clearing it immediately
  • Added conditional logic to only update tid when a new valid value is available

Comment on lines +117 to +121
// Only update tid if we have a new valid value - preserve last known tid for error telemetry where token may be undefined
const newTid = token?.getTokenValue('tid');
if (newTid) {
this._tid = newTid;
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The preservation of tid creates an asymmetry with how username and sku are handled when the token becomes undefined. Consider documenting why tid requires different treatment compared to other token-derived fields. This will help future maintainers understand that tid serves as a session correlation identifier that should persist across temporary token unavailability, while username and sku represent current state that can be cleared.

Copilot uses AI. Check for mistakes.
@vijayupadya vijayupadya added this pull request to the merge queue Jan 30, 2026
Merged via the queue into main with commit 9f2323b Jan 30, 2026
25 checks passed
@vijayupadya vijayupadya deleted the vijayu/preserveTidForErrors branch January 30, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants