Skip to content

fix: remove repoId from MSFT telemetry and optimize repo info for external users#4018

Merged
zhichli merged 2 commits intomainfrom
zhichli/remove-repoid-optimize-repo-telemetry
Feb 26, 2026
Merged

fix: remove repoId from MSFT telemetry and optimize repo info for external users#4018
zhichli merged 2 commits intomainfrom
zhichli/remove-repoid-optimize-repo-telemetry

Conversation

@zhichli
Copy link
Member

@zhichli zhichli commented Feb 26, 2026

Follow-up to #3956:

  • Remove repoId from external MSFT telemetry (sensitive data)
  • Gate diff computation behind isInternal check — external users only get lightweight metadata (repoType + headCommitHash)
  • Extract shared _resolveRepoContext() to deduplicate repo context resolution
  • Update all 34 tests for new copilotTokenStore parameter

…ernal users

- Remove repoId from sendMSFTTelemetryEvent (sensitive data)
- Gate diff computation behind isInternal check so external users
  only get lightweight metadata (repoType + headCommitHash)
- Extract shared _resolveRepoContext() to deduplicate repo context
  resolution between _getRepoMetadata() and _getRepoInfoTelemetry()
- Update tests to pass copilotTokenStore and fix assertions
Copilot AI review requested due to automatic review settings February 26, 2026 00:35
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 26, 2026
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 adjusts repository telemetry emission to avoid sending sensitive repoId to external Microsoft telemetry and to reduce overhead for non-internal users by skipping diff computation and related work.

Changes:

  • Gate full repo diff collection + internal telemetry behind ICopilotTokenStore.copilotToken.isInternal.
  • For non-internal users, send a lightweight external telemetry payload containing only repo type + upstream commit hash (no repoId, no diffs).
  • Update unit tests to pass the new copilotTokenStore dependency and to assert repoId is absent from external telemetry.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/extension/prompt/node/repoInfoTelemetry.ts Adds internal-user gating via token store and introduces _resolveRepoContext() + _getRepoMetadata() to avoid diff work for external users.
src/extension/prompt/node/test/repoInfoTelemetry.spec.ts Updates constructor arguments and adjusts assertions for external telemetry payload + internal telemetry gating.
Comments suppressed due to low confidence (1)

src/extension/prompt/node/repoInfoTelemetry.ts:170

  • For non-internal users, _sendRepoInfoTelemetry always returns undefined, so sendBeginTelemetryIfNeeded never sets _beginTelemetryResult. As a result, sendEndTelemetry() will always skip sending the location: 'end' event for external users, even when begin telemetry was successfully sent. Consider returning a minimal RepoInfoTelemetryData (or separately tracking a success flag/result) for the external path so the end event can be emitted consistently when appropriate.
	private async _sendRepoInfoTelemetry(location: 'begin' | 'end'): Promise<RepoInfoTelemetryData | undefined> {
		const isInternal = !!this._copilotTokenStore.copilotToken?.isInternal;

		if (isInternal) {
			const repoInfo = await this._getRepoInfoTelemetry();
			if (!repoInfo) {
				return undefined;
			}

			const internalProperties: RepoInfoInternalTelemetryProperties = {
				...repoInfo.properties,
				location,
				telemetryMessageId: this._telemetryMessageId
			};
			this._telemetryService.sendInternalMSFTTelemetryEvent('request.repoInfo', internalProperties, repoInfo.measurements);

			return repoInfo;
		}

		const metadata = await this._getRepoMetadata();
		if (metadata) {
			this._telemetryService.sendMSFTTelemetryEvent('request.repoInfo', {
				repoType: metadata.repoType,
				headCommitHash: metadata.headCommitHash,
				location,
				telemetryMessageId: this._telemetryMessageId,
			});
		}

		return undefined;

karthiknadig
karthiknadig previously approved these changes Feb 26, 2026
this._telemetryService.sendInternalMSFTTelemetryEvent('request.repoInfo', internalProperties, repoInfo.measurements);
const metadata = await this._getRepoMetadata();
if (metadata) {
this._telemetryService.sendMSFTTelemetryEvent('request.repoInfo', {
Copy link
Member

Choose a reason for hiding this comment

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

Quick question (that I don't know the answer to off hand) would you need a new name for this event? They might go into totally different tables, which would be ok. Just don't want the folks watching the existing request.repoInfo to get confused by a new event with less properties / data.

if (metadata) {
this._telemetryService.sendMSFTTelemetryEvent('request.repoInfo', {
repoType: metadata.repoType,
headCommitHash: metadata.headCommitHash,
Copy link
Member

Choose a reason for hiding this comment

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

Is this still useful information without the id?

Copy link
Member

@IanMatthewHuff IanMatthewHuff left a comment

Choose a reason for hiding this comment

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

Added a comment or two, but the code change should resolve the perf issue as I saw it.

@zhichli zhichli added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit adeae82 Feb 26, 2026
19 checks passed
@zhichli zhichli deleted the zhichli/remove-repoid-optimize-repo-telemetry branch February 26, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants