Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ export class DefaultClient implements Client {
languageClient = new LanguageClient(`cpptools`, serverOptions, clientOptions);
languageClient.onNotification(DebugProtocolNotification, logDebugProtocol);
languageClient.onNotification(DebugLogNotification, logLocalized);
languageClient.onNotification(LogTelemetryNotification, (e) => this.logTelemetry(e));
languageClient.onNotification(LogTelemetryNotification, (e) => void this.logTelemetry(e));
languageClient.onNotification(ShowMessageWindowNotification, showMessageWindow);
languageClient.registerProposedFeatures();
await languageClient.start();
Expand Down Expand Up @@ -2778,10 +2778,38 @@ export class DefaultClient implements Client {
}
}

private logTelemetry(notificationBody: TelemetryPayload): void {
private excessiveFilesWarningShown: boolean = false;
private async logTelemetry(notificationBody: TelemetryPayload): Promise<void> {
if (notificationBody.event === "includeSquiggles" && this.configurationProvider && notificationBody.properties) {
notificationBody.properties["providerId"] = this.configurationProvider;
}

const showExcessiveFilesWarning = new PersistentWorkspaceState<boolean>('CPP.showExcessiveFilesWarning', true);
if (!this.excessiveFilesWarningShown && showExcessiveFilesWarning.Value && notificationBody.event === 'ParsingStats') {
const filesDiscovered = notificationBody.metrics?.filesDiscovered ?? 0;
const parsableFiles = notificationBody.metrics?.parsableFiles ?? 0;
if (filesDiscovered > 250000 || parsableFiles > 100000) {
// According to telemetry, less than 3% of workspaces have this many files so it seems like a reasonable threshold.

const message = localize(
"parsing.stats.large.project",
'Enumerated {0} files with {1} C/C++ source files detected. You may want to consider excluding some files for better performance.',
filesDiscovered,
parsableFiles);
const learnMore = localize('learn.more', 'Learn More');
const dontShowAgain = localize('dont.show.again', 'Don\'t Show Again');

// We only want to show this once per session.
this.excessiveFilesWarningShown = true;
const response = await vscode.window.showInformationMessage(message, learnMore, dontShowAgain);

if (response === dontShowAgain) {
showExcessiveFilesWarning.Value = false;
} else if (response === learnMore) {
void vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://go.microsoft.com/fwlink/?linkid=2333292'));
}
}
}
telemetry.logLanguageServerEvent(notificationBody.event, notificationBody.properties, notificationBody.metrics);
}

Expand Down