From 3d365bdd9e29453b937927a2e4e28a4ed619e396 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Tue, 22 Oct 2024 15:56:03 -0400 Subject: [PATCH] Handle server error telemetry events (#2756) --- vscode/src/client.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vscode/src/client.ts b/vscode/src/client.ts index a5598a960..9def4acea 100644 --- a/vscode/src/client.ts +++ b/vscode/src/client.ts @@ -41,6 +41,15 @@ import { WorkspaceChannel } from "./workspaceChannel"; type EnabledFeatures = Record; +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, @@ -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() {