Fix cycle in ts telemtry reporter

This commit is contained in:
Matt Bierner
2017-10-30 17:02:26 -07:00
parent e06abc84c1
commit ebe55bfae3
2 changed files with 6 additions and 14 deletions

View File

@@ -116,11 +116,7 @@ class RequestQueue {
}
}
export interface IClientVersion {
readonly clientVersion: string;
}
export default class TypeScriptServiceClient implements ITypescriptServiceClient, IClientVersion {
export default class TypeScriptServiceClient implements ITypescriptServiceClient {
private static readonly WALK_THROUGH_SNIPPET_SCHEME = 'walkThroughSnippet';
private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME}:`;
@@ -210,7 +206,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
}
}, this, this.disposables);
this.telemetryReporter = new TelemetryReporter(this);
this.telemetryReporter = new TelemetryReporter(() => this._tsserverVersion || this._apiVersion.versionString);
this.disposables.push(this.telemetryReporter);
this.startService();
}
@@ -280,10 +276,6 @@ 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;
}

View File

@@ -5,7 +5,6 @@
import * as path from 'path';
import VsCodeTelemetryReporter from 'vscode-extension-telemetry';
import { IClientVersion } from '../typescriptServiceClient';
interface IPackageInfo {
name: string;
@@ -24,15 +23,16 @@ export default class TelemetryReporter {
}
}
constructor(private client: IClientVersion) {
}
constructor(
private readonly clientVersionDelegate: () => string
) { }
public logTelemetry(eventName: string, properties?: { [prop: string]: string }) {
if (this.reporter) {
if (!properties) {
properties = {};
}
properties['version'] = this.client.clientVersion;
properties['version'] = this.clientVersionDelegate();
this.reporter.sendTelemetryEvent(eventName, properties);
}