Skip to content

Commit db9a612

Browse files
committed
(GH-355) Re-add Telemetry
This commit re-adds the version details to the telemetry implementation, but not in the same exact place. This adds the capture to the closing statement for the connection manager, which is called when the extension stops. This allows us to send one event per 'session', and since we include time spent we will be able to differentiate in appinsights.
1 parent 4dbd2db commit db9a612

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/connection.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { RubyHelper } from './rubyHelper';
88
import { PuppetStatusBar } from './PuppetStatusBar';
99
import { PuppetLanguageClient } from './PuppetLanguageClient';
1010
import { ConnectionConfiguration } from './configuration';
11+
import { reporter } from './telemetry/telemetry';
12+
import { PuppetVersionRequest } from './messages';
1113

1214
const langID = 'puppet'; // don't change this
1315
const documentSelector = { scheme: 'file', language: langID };
@@ -28,13 +30,15 @@ export class ConnectionManager implements IConnectionManager {
2830
private languageServerClient: LanguageClient;
2931
private languageServerProcess: cp.ChildProcess;
3032
private puppetLanguageClient: PuppetLanguageClient;
33+
private timeSpent:number;
3134

3235
constructor(
3336
context: vscode.ExtensionContext,
3437
logger: ILogger,
3538
statusBar: PuppetStatusBar,
3639
connectionConfiguration: IConnectionConfiguration
3740
) {
41+
this.timeSpent = Date.now();
3842
this.logger = logger;
3943
this.extensionContext = context;
4044
this.connectionStatus = ConnectionStatus.NotStarted;
@@ -77,6 +81,18 @@ export class ConnectionManager implements IConnectionManager {
7781

7882
this.connectionStatus = ConnectionStatus.Stopping;
7983

84+
if (this.languageServerClient !== undefined) {
85+
this.timeSpent = Date.now() - this.timeSpent;
86+
this.languageServerClient.sendRequest(PuppetVersionRequest.type).then(versionDetails => {
87+
reporter.sendTelemetryEvent('data', {
88+
'timeSpent' : this.timeSpent.toString(),
89+
'puppetVersion' : versionDetails.puppetVersion,
90+
'facterVersion' : versionDetails.facterVersion,
91+
'languageServerVersion': versionDetails.languageServerVersion,
92+
});
93+
});
94+
}
95+
8096
// Close the language server client
8197
if (this.languageServerClient !== undefined) {
8298
this.languageServerClient.stop();

0 commit comments

Comments
 (0)