Skip to content

Add walkthrough telemetry command #4138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@
"title": "Invoke Registered Editor Command",
"category": "PowerShell"
},
{
"command": "PowerShell.WalkthroughTelemetry",
"title": "Walkthrough Telemetry",
"category": "PowerShell"
},
{
"command": "PowerShell.ClosePanel",
"title": "Close panel",
Expand Down
30 changes: 18 additions & 12 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import net = require("net");
import path = require("path");
import * as semver from "semver";
import vscode = require("vscode");
import TelemetryReporter from "@vscode/extension-telemetry";
import TelemetryReporter, { TelemetryEventProperties, TelemetryEventMeasurements } from "@vscode/extension-telemetry";
import { Message } from "vscode-jsonrpc";
import { Logger } from "./logging";
import { PowerShellProcess } from "./process";
Expand Down Expand Up @@ -505,6 +505,11 @@ Type 'help' to get help.
vscode.workspace.onDidChangeConfiguration(async () => { await this.onConfigurationUpdated(); }),
vscode.commands.registerCommand(
"PowerShell.ShowSessionConsole", (isExecute?: boolean) => { this.showSessionConsole(isExecute); }),
vscode.commands.registerCommand(
"PowerShell.WalkthroughTelemetry", (satisfaction: number) => {
this.sendTelemetryEvent("powershellWalkthroughSatisfaction", null, { level: satisfaction });
}
)
];
}

Expand Down Expand Up @@ -571,6 +576,12 @@ Type 'help' to get help.
}
}

private async sendTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measures?: TelemetryEventMeasurements) {
if (this.extensionContext.extensionMode === vscode.ExtensionMode.Production) {
this.telemetryReporter.sendTelemetryEvent(eventName, properties, measures);
}
}

private async startLanguageClient(sessionDetails: IEditorServicesSessionDetails) {
this.log.write(`Connecting to language service on pipe: ${sessionDetails.languageServicePipeName}`);
this.log.write("Session details: " + JSON.stringify(sessionDetails));
Expand Down Expand Up @@ -622,13 +633,11 @@ Type 'help' to get help.
// This enables handling Semantic Highlighting messages in PowerShell Editor Services
this.languageClient.registerProposedFeatures();

if (this.extensionContext.extensionMode === vscode.ExtensionMode.Production) {
this.languageClient.onTelemetry((event) => {
const eventName: string = event.eventName ? event.eventName : "PSESEvent";
const data: any = event.data ? event.data : event
this.telemetryReporter.sendTelemetryEvent(eventName, data);
});
}
this.languageClient.onTelemetry((event) => {
const eventName: string = event.eventName ? event.eventName : "PSESEvent";
const data: any = event.data ? event.data : event
this.sendTelemetryEvent(eventName, data);
});

// Send the new LanguageClient to extension features
// so that they can register their message handlers
Expand Down Expand Up @@ -661,10 +670,7 @@ Type 'help' to get help.

this.versionDetails = await this.languageClient.sendRequest(PowerShellVersionRequestType);

if (this.extensionContext.extensionMode === vscode.ExtensionMode.Production) {
this.telemetryReporter.sendTelemetryEvent("powershellVersionCheck",
{ powershellVersion: this.versionDetails.version });
}
this.sendTelemetryEvent("powershellVersionCheck", { powershellVersion: this.versionDetails.version });

this.setSessionVersion(this.versionDetails.architecture === "x86"
? `${this.versionDetails.displayVersion} (${this.versionDetails.architecture})`
Expand Down