mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
add tsserver version property to every event (#37066)
* get and report version from tsserver * reset version on tsserver exit * fixup * use client-verison interface
This commit is contained in:
committed by
Matt Bierner
parent
af57f620e3
commit
85e479f1a5
@@ -116,8 +116,11 @@ class RequestQueue {
|
||||
}
|
||||
}
|
||||
|
||||
export interface IClientVersion {
|
||||
readonly clientVersion: string;
|
||||
}
|
||||
|
||||
export default class TypeScriptServiceClient implements ITypescriptServiceClient {
|
||||
export default class TypeScriptServiceClient implements ITypescriptServiceClient, IClientVersion {
|
||||
private static readonly WALK_THROUGH_SNIPPET_SCHEME = 'walkThroughSnippet';
|
||||
private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME}:`;
|
||||
|
||||
@@ -148,8 +151,15 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
private readonly _onDidEndInstallTypings = new EventEmitter<Proto.EndInstallTypesEventBody>();
|
||||
private readonly _onTypesInstallerInitializationFailed = new EventEmitter<Proto.TypesInstallerInitializationFailedEventBody>();
|
||||
|
||||
private _apiVersion: API;
|
||||
private telemetryReporter: TelemetryReporter;
|
||||
/**
|
||||
* API version obtained from the version picker after checking the corresponding path exists.
|
||||
*/
|
||||
private _apiVersion: API;
|
||||
/**
|
||||
* Version reported by currently-running tsserver.
|
||||
*/
|
||||
private _tsserverVersion: string | undefined;
|
||||
|
||||
private readonly disposables: Disposable[] = [];
|
||||
|
||||
@@ -178,6 +188,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
this.versionPicker = new TypeScriptVersionPicker(this.versionProvider, this.workspaceState);
|
||||
|
||||
this._apiVersion = API.defaultVersion;
|
||||
this._tsserverVersion = undefined;
|
||||
this.tracer = new Tracer(this.logger);
|
||||
|
||||
workspace.onDidChangeConfiguration(() => {
|
||||
@@ -199,7 +210,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
}
|
||||
}
|
||||
}, this, this.disposables);
|
||||
this.telemetryReporter = new TelemetryReporter();
|
||||
this.telemetryReporter = new TelemetryReporter(this);
|
||||
this.disposables.push(this.telemetryReporter);
|
||||
this.startService();
|
||||
}
|
||||
@@ -237,6 +248,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
this.info('Killing TS Server');
|
||||
this.isRestarting = true;
|
||||
cp.kill();
|
||||
this.resetClientVersion();
|
||||
}
|
||||
}).then(start);
|
||||
} else {
|
||||
@@ -268,6 +280,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
return this._apiVersion;
|
||||
}
|
||||
|
||||
public get clientVersion(): string {
|
||||
return this._tsserverVersion || this._apiVersion.versionString;
|
||||
}
|
||||
|
||||
public onReady(): Promise<void> {
|
||||
return this._onReady.promise;
|
||||
}
|
||||
@@ -337,6 +353,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
}
|
||||
*/
|
||||
this.logTelemetry('error', { message: err.message });
|
||||
this.resetClientVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -497,7 +514,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
this.tsServerLogFile = null;
|
||||
this.callbacks.destroy(new Error('Service died.'));
|
||||
this.callbacks = new CallbackMap();
|
||||
if (restart) {
|
||||
if (!restart) {
|
||||
this.resetClientVersion();
|
||||
}
|
||||
else {
|
||||
const diff = Date.now() - this.lastStart;
|
||||
this.numberRestarts++;
|
||||
let startService = true;
|
||||
@@ -518,6 +538,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
"serviceExited" : {}
|
||||
*/
|
||||
this.logTelemetry('serviceExited');
|
||||
this.resetClientVersion();
|
||||
} else if (diff < 60 * 1000 /* 1 Minutes */) {
|
||||
this.lastStart = Date.now();
|
||||
prompt = window.showWarningMessage<MyMessageItem>(
|
||||
@@ -808,6 +829,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (telemetryData.telemetryEventName === 'projectInfo') {
|
||||
this._tsserverVersion = properties['version'];
|
||||
}
|
||||
|
||||
/* __GDPR__
|
||||
"typingsInstalled" : {
|
||||
"installedPackages" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
|
||||
@@ -883,6 +908,11 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
private resetClientVersion() {
|
||||
this._apiVersion = API.defaultVersion;
|
||||
this._tsserverVersion = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as path from 'path';
|
||||
import VsCodeTelemetryReporter from 'vscode-extension-telemetry';
|
||||
import { IClientVersion } from '../typescriptServiceClient';
|
||||
|
||||
interface IPackageInfo {
|
||||
name: string;
|
||||
@@ -23,8 +24,16 @@ export default class TelemetryReporter {
|
||||
}
|
||||
}
|
||||
|
||||
constructor(private client: IClientVersion) {
|
||||
}
|
||||
|
||||
public logTelemetry(eventName: string, properties?: { [prop: string]: string }) {
|
||||
if (this.reporter) {
|
||||
if (!properties) {
|
||||
properties = {};
|
||||
}
|
||||
properties['version'] = this.client.clientVersion;
|
||||
|
||||
this.reporter.sendTelemetryEvent(eventName, properties);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user