Skip to content

Conversation

@DanielRosenwasser
Copy link
Member

This change adds telemetry reporting infrastructure to help capture usage and error information. It follows VS Code's guidelines for extension authors in order to respect user preferences (through using @vscode/extension-telemetry which takes care of all of that).

While most events are triggered via the client, the server now pushes events on recovered request failures. At a broad level, server telemetry lines up with the information our reporters take: an event name, properties, and measurements, along with the purpose (used to respect user preferences).

In the future we'll likely want to keep track of measurements on specific language server commands to keep an eye on performance issues, along with certain other server-recovered crashes.

@DanielRosenwasser DanielRosenwasser marked this pull request as ready for review January 29, 2026 22:01
Copilot AI review requested due to automatic review settings January 29, 2026 22:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces telemetry reporting across the native TypeScript language server and its VS Code preview extension, and adds a stack trace sanitizer to avoid leaking local paths or other sensitive details in error telemetry. It wires the server to emit structured telemetry on recovered panics and updates the extension to forward those events to VS Code’s telemetry pipeline alongside a small set of client-side usage/error events.

Changes:

  • Add sanitizeStackTrace plus tests and baselines to normalize and redact stack traces before they are logged or sent over telemetry.
  • Extend the LSP protocol layer with TelemetryEvent, TelemetryPurpose, and RequestFailureTelemetryProperties, and emit languageServer.errorResponse telemetry from Server.recover.
  • Integrate the VS Code extension with @vscode/extension-telemetry via a strongly-typed TelemetryReporter, forwarding server-side telemetry and reporting extension-initiated events (startup, connection errors, enable/disable/restart/report-issue).

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testdata/baselines/reference/lsp/stackSanitizer/completionsReleaseStackTrace.md Reference baseline for release-stack trace sanitization of completion-related panics.
testdata/baselines/reference/lsp/stackSanitizer/completionsDebugStackTrace.md Reference baseline for debug-stack trace sanitization of completion-related panics.
package-lock.json Locks in @vscode/extension-telemetry and its transitive dependencies and updates some metadata (e.g. tslib flags) to reflect the new extension build.
internal/lsp/stack_sanitizer_test.go Adds baseline tests for stack trace sanitization using representative debug and release stack samples.
internal/lsp/stack_sanitizer.go Implements sanitizeStackTrace and writeSanitizedModuleOrPath, trimming leading non-runtime frames and redacting non-typescript-go frames while normalizing our own frames.
internal/lsp/server.go On recovered panics, emits a telemetry/event notification (languageServer.errorResponse) with TelemetryPurposeError and sanitized stack trace before sending the LSP error response.
internal/lsp/lsproto/lsp_generated.go Introduces TelemetryEvent, RequestFailureTelemetryProperties, and TelemetryPurpose enum; updates unmarshalParams and TelemetryEventInfo mapping so telemetry/event is typed.
internal/lsp/lsproto/_generate/generate.mts Extends the lsproto code generator with custom structures/enums for telemetry and patches the model so TelemetryEventNotification uses TelemetryEvent as its params type.
internal/core/core.go Adds a generic Enumerate helper to turn an iter.Seq[T] into an iter.Seq2[int, T], used by the stack sanitizer to track line numbers.
_extension/tsconfig.json Bumps the extension’s TypeScript compilation target from es2020 to es2023, aligning with modern Node/VS Code capabilities.
_extension/src/util.ts Adds the telemetry connection string constant used to construct the VS Code telemetry reporter.
_extension/src/telemetryReporting.ts Defines a typed TelemetryReporter interface and adapter over @vscode/extension-telemetry, with typed events for server lifecycle and connection issues plus untyped forwarding helpers.
_extension/src/extension.ts Initializes the telemetry reporter on activation, registers enablement commands with telemetry, and passes the reporter into the language client initialization pipeline.
_extension/src/commands.ts Updates enable/disable/restart/report-issue commands to record corresponding telemetry events via the injected reporter.
_extension/src/client.ts Extends the language client to send languageServer.start telemetry, forward server telemetry/event notifications to the reporter based on telemetryPurpose, and use a custom ReportingErrorHandler that logs connection errors/closures via error telemetry.
_extension/package.json Declares @vscode/extension-telemetry as a runtime dependency for the extension.

Comment on lines +185 to +188
const _: never = d.telemetryPurpose;
this.telemetryReporter.sendTelemetryErrorEvent("languageServer.unexpectedTelemetryPurpose", {
telemetryPurpose: String(d.telemetryPurpose),
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be random data; do we actually need to collect this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't sure - but it indicates some sort of mismatch between client/server and it'd be nice to find out about it somehow without going crazy to keep client/server in sync.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably err on the side of not doing anything; whatever we do will have to be forward compatible anyway...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants