diff --git a/extensions/typescript-language-features/src/configuration/configuration.ts b/extensions/typescript-language-features/src/configuration/configuration.ts index cab1cf4c819..2650d015d88 100644 --- a/extensions/typescript-language-features/src/configuration/configuration.ts +++ b/extensions/typescript-language-features/src/configuration/configuration.ts @@ -112,6 +112,7 @@ export interface TypeScriptServiceConfiguration { readonly useSyntaxServer: SyntaxServerConfiguration; readonly webProjectWideIntellisenseEnabled: boolean; readonly webProjectWideIntellisenseSuppressSemanticErrors: boolean; + readonly enableDiagnosticsTelemetry: boolean; readonly enableProjectDiagnostics: boolean; readonly maxTsServerMemory: number; readonly enablePromptUseWorkspaceTsdk: boolean; @@ -144,6 +145,7 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu useSyntaxServer: this.readUseSyntaxServer(configuration), webProjectWideIntellisenseEnabled: this.readWebProjectWideIntellisenseEnable(configuration), webProjectWideIntellisenseSuppressSemanticErrors: this.readWebProjectWideIntellisenseSuppressSemanticErrors(configuration), + enableDiagnosticsTelemetry: this.readEnableDiagnosticsTelemetry(configuration), enableProjectDiagnostics: this.readEnableProjectDiagnostics(configuration), maxTsServerMemory: this.readMaxTsServerMemory(configuration), enablePromptUseWorkspaceTsdk: this.readEnablePromptUseWorkspaceTsdk(configuration), @@ -197,6 +199,10 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu return SyntaxServerConfiguration.Never; } + protected readEnableDiagnosticsTelemetry(configuration: vscode.WorkspaceConfiguration): boolean { + return configuration.get('typescript.enableDiagnosticsTelemetry', false); + } + protected readEnableProjectDiagnostics(configuration: vscode.WorkspaceConfiguration): boolean { return configuration.get('typescript.tsserver.experimental.enableProjectDiagnostics', false); } diff --git a/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts b/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts index 4331278c4ff..d3694cafdb1 100644 --- a/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts +++ b/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts @@ -10,7 +10,7 @@ import { Disposable } from '../utils/dispose'; import { ResourceMap } from '../utils/resourceMap'; import { TelemetryReporter } from '../logging/telemetry'; import { URI } from 'vscode-uri'; -import { diff } from 'semver'; +import { TypeScriptServiceConfiguration } from '../configuration/configuration'; function diagnosticsEquals(a: vscode.Diagnostic, b: vscode.Diagnostic): boolean { if (a === b) { @@ -151,18 +151,6 @@ class DiagnosticSettings { } } -/* -const diagnostics = this.getDiagnostics(document.uri); - const diagnoticCodes = diagnostics.reduce(function (result: number[], d: vscode.Diagnostic) { - const code = d.code; - if (typeof code === 'string' || typeof code === 'number') { - result.push(Number(code)); - } else if (code !== undefined) { - result.push(Number(code.value)); - } - return result; - }, []); - */ class DiagnosticsTelemetryManager extends Disposable { private readonly _timeOutDiagnosticMaps = new Map(); @@ -245,6 +233,7 @@ export class DiagnosticsManager extends Disposable { constructor( owner: string, + configuration: TypeScriptServiceConfiguration, telemetryReporter: TelemetryReporter, onCaseInsensitiveFileSystem: boolean ) { @@ -253,7 +242,7 @@ export class DiagnosticsManager extends Disposable { this._pendingUpdates = new ResourceMap(undefined, { onCaseInsensitiveFileSystem }); this._currentDiagnostics = this._register(vscode.languages.createDiagnosticCollection(owner)); - if (Math.random() * 1000 <= 1) { + if (Math.random() * 1000 <= 1 || configuration.enableDiagnosticsTelemetry) { this._register(new DiagnosticsTelemetryManager(telemetryReporter, this.getDiagnostics)); } } diff --git a/extensions/typescript-language-features/src/typescriptServiceClient.ts b/extensions/typescript-language-features/src/typescriptServiceClient.ts index c165f82db40..e00bed60b3f 100644 --- a/extensions/typescript-language-features/src/typescriptServiceClient.ts +++ b/extensions/typescript-language-features/src/typescriptServiceClient.ts @@ -212,7 +212,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType } return this.apiVersion.fullVersionString; }); - this.diagnosticsManager = new DiagnosticsManager('typescript', this.telemetryReporter, onCaseInsenitiveFileSystem); + this.diagnosticsManager = new DiagnosticsManager('typescript', this._configuration, this.telemetryReporter, onCaseInsenitiveFileSystem); this.typescriptServerSpawner = new TypeScriptServerSpawner(this.versionProvider, this._versionManager, this.logDirectoryProvider, this.pluginPathsProvider, this.logger, this.telemetryReporter, this.tracer, this.processFactory); this._register(this.pluginManager.onDidUpdateConfig(update => {