Skip to content

Commit

Permalink
Handle server error telemetry events (#2756)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Oct 22, 2024
1 parent 734e872 commit 3d365bd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ import { WorkspaceChannel } from "./workspaceChannel";

type EnabledFeatures = Record<string, boolean>;

interface ServerErrorTelemetryEvent {
type: "error";
errorMessage: string;
errorClass: string;
stack: string;
}

type ServerTelemetryEvent = ServerErrorTelemetryEvent;

// Get the executables to start the server based on the user's configuration
function getLspExecutables(
workspaceFolder: vscode.WorkspaceFolder,
Expand Down Expand Up @@ -319,6 +328,19 @@ export default class Client extends LanguageClient implements ClientInterface {
params.textDocument.text,
);
});

this.onTelemetry((event: ServerTelemetryEvent) => {
if (event.type === "error") {
this.telemetry.logError(
{
message: event.errorMessage,
name: event.errorClass,
stack: event.stack,
},
{ serverVersion: this.serverVersion },
);
}
});
}

async afterStart() {
Expand Down

0 comments on commit 3d365bd

Please sign in to comment.