730
731
private _updateRestrictedTelemetry(githubToken: string | undefined): void {
732
>
// Safe default synchronously: keep restricted/enhanced telemetry disabled until the minted
copilotAgent.ts
733
>
// CAPI Copilot session token confirms the `rt=1` opt-in. The GitHub token here carries no
734
>
// `rt`/`tid` claims — those live in the Copilot session token, which the API service mints —
735
>
// so the real values are resolved asynchronously below. Mirrors how the Copilot extension
736
>
// reads `rt`/`tid` off its `CopilotToken` rather than the GitHub token.
737
>
this._applyRestrictedTelemetry(undefined);
738
>
if (githubToken) {
739
>
void this._resolveRestrictedTelemetry(githubToken);
740
>
}
741
>
}
742
743
private async _resolveRestrictedTelemetry(githubToken: string): Promise<void> {
745
>
const ctx = await this._copilotApiService.resolveRestrictedTelemetryContext(githubToken);
746
>
if (this._githubToken !== githubToken) {
747
return; // token changed while resolving; a newer call owns the state
748
}
750
>
...ctx,
751
>
telemetryEndpoint: toRestrictedTelemetryEndpoint(ctx.telemetryEndpoint),
752
>
});
753
>
} catch (err) {
754
this._logService.debug(`[Copilot] Restricted telemetry resolution failed: ${err instanceof Error ? err.message : String(err)}`);
755
}
757
758
private _applyRestrictedTelemetry(context: IRestrictedTelemetryContext | undefined): void {
759
>
const rtEnabled = context?.restrictedTelemetryEnabled === true;
copilotAgent.ts
760
>
if (rtEnabled !== this._restrictedTelemetryEnabled) {
761
this._restrictedTelemetryEnabled = rtEnabled;
762
this._logService.info(`[Copilot] Enhanced (restricted) telemetry ${rtEnabled ? 'enabled for this account' : 'disabled'}`);
763
this._onDidChangeRestrictedTelemetry.fire();
764
}
765
>
// Push the token-derived telemetry policy/identity to the restricted sender: `rt` gates
copilotAgent.ts
766
>
// enhanced GH telemetry (kept off for public users), `tid` becomes `copilot_trackingId`, and
767
>
// the endpoint routes at the user's CAPI telemetry host (dotcom, GHE, or proxy).
768
>
if (isAgentHostTelemetryService(this._telemetryService)) {
769
this._telemetryService.setRestrictedTelemetryEnabled(rtEnabled);
770
this._telemetryService.setCopilotTrackingId(context?.trackingId);
771
this._telemetryService.setRestrictedTelemetryEndpoint(context?.telemetryEndpoint);
772
}
774
775
private async _routeGitHubTelemetry(notification: GitHubTelemetryNotification): Promise<void> {