759
const rtEnabled = context?.restrictedTelemetryEnabled === true;
760
if (rtEnabled !== this._restrictedTelemetryEnabled) {
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
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);
copilotAgent.ts
770
>
this._telemetryService.setCopilotTrackingId(context?.trackingId);
771
>
this._telemetryService.setRestrictedTelemetryEndpoint(context?.telemetryEndpoint);
772
>
}
773
}
774
775
private async _routeGitHubTelemetry(notification: GitHubTelemetryNotification): Promise<void> {
777
>
if (!router?.isTarget(notification)) {
778
this._gitHubTelemetryForwarder.forward(notification);
779
return;
780
}
782
router.route(notification);
783
return;
784
}
786
>
const sessionId = notification.sessionId;
787
>
const githubToken = this._githubToken;
788
>
if (!githubToken) {
789
router.route(notification);
790
return;
791
}
793
>
try {
794
>
const context = await this._copilotApiService.resolveRestrictedTelemetryContext(githubToken);
795
>
if (this._githubToken !== githubToken) {
796
return;
797
}
799
>
restrictedTelemetryEnabled: context.restrictedTelemetryEnabled,
800
>
trackingId: context.trackingId,
801
>
telemetryEndpoint: toRestrictedTelemetryEndpoint(context.telemetryEndpoint),
802
>
isInternal: context.isInternal === true,
803
>
userName: context.userName,
804
>
isVscodeTeamMember: context.isVscodeTeamMember === true,
805
>
});
806
>
} catch (error) {
807
this._logService.debug(`[Copilot:${sessionId}] Restricted telemetry context resolution failed; dropping ${notification.event.kind}: ${error instanceof Error ? error.message : String(error)}`);
808
}
810
811
/**