Skip to content

Commit

Permalink
Add telemetry for launch failures (#2778)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Oct 30, 2024
1 parent d8e4c32 commit c328878
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function collectClientOptions(
outputChannel: WorkspaceChannel,
ruby: Ruby,
isMainWorkspace: boolean,
telemetry: vscode.TelemetryLogger,
): LanguageClientOptions {
const pullOn: "change" | "save" | "both" =
configuration.get("pullDiagnosticsOn")!;
Expand Down Expand Up @@ -204,7 +205,7 @@ function collectClientOptions(
outputChannel,
revealOutputChannelOn: RevealOutputChannelOn.Never,
diagnosticPullOptions,
errorHandler: new ClientErrorHandler(workspaceFolder),
errorHandler: new ClientErrorHandler(workspaceFolder, telemetry),
initializationOptions: {
enabledFeatures,
experimentalFeaturesEnabled: configuration.get(
Expand All @@ -221,9 +222,14 @@ function collectClientOptions(

class ClientErrorHandler implements ErrorHandler {
private readonly workspaceFolder: vscode.WorkspaceFolder;
private readonly telemetry: vscode.TelemetryLogger;

constructor(workspaceFolder: vscode.WorkspaceFolder) {
constructor(
workspaceFolder: vscode.WorkspaceFolder,
telemetry: vscode.TelemetryLogger,
) {
this.workspaceFolder = workspaceFolder;
this.telemetry = telemetry;
}

error(
Expand All @@ -235,6 +241,19 @@ class ClientErrorHandler implements ErrorHandler {
}

async closed(): Promise<CloseHandlerResult> {
const label = vscode.workspace
.getConfiguration("rubyLsp")
.get("useLauncher")
? "launcher"
: "direct";

this.telemetry.logUsage("ruby_lsp.launch_failure", {
type: "counter",
attributes: {
label,
},
});

const answer = await vscode.window.showErrorMessage(
`Launching the Ruby LSP failed. This typically happens due to an error with version manager
integration or Bundler issues.
Expand Down Expand Up @@ -310,6 +329,7 @@ export default class Client extends LanguageClient implements ClientInterface {
outputChannel,
ruby,
isMainWorkspace,
telemetry,
),
debugMode,
);
Expand Down

0 comments on commit c328878

Please sign in to comment.