Repository navigation
feat(vscode): wire the extension into the shared telemetry pipeline - #3852
Conversation
Initialize the shared v1 telemetry client at activation with extension identity (ui_mode=vscode), the shared device id, and the region-aware endpoint, and pass it into the SDK harness so engine events flow into the existing pipeline. Sending is gated on all three of: KIMI_DISABLE_TELEMETRY, config.toml telemetry=false, and VS Code's global telemetry setting (followed live). No new event types, no crash handlers in the shared extension host. kimi-telemetry gains a soft enable switch (pauses intake without detaching the sink) and an initiallyEnabled bootstrap option that skips the disk-spool replay while the host gate starts closed; the previous hard disable() is renamed teardown() to make the distinction explicit.
🦋 Changeset detectedLatest commit: 2508c5c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80bc1a0710
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fe94d6ef0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ced35a7e8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…runtimes Two product commits landed on upstream/main after the 2.0.0 tag; the tag was already merged, so these are applied on top. install-desktop rename (MoonshotAI#3864): `kimi install-app` becomes `kimi install-desktop` with the old name kept as a hidden alias, matching upstream's rename; the description goes through t() and the bilingual reference docs and the slash-commands tables are synced. VS Code extension joins the shared telemetry pipeline (MoonshotAI#3852): the shared telemetry package gains the initiallyEnabled bootstrap option and the enable/disable API from upstream, a new apps/vscode telemetry module wires the extension to it (first-launch tracking, config + VS Code telemetry settings, region-derived endpoint), and the runtime passes the telemetry client into the SDK session. That commit also retargeted the telemetry crash tests at an API the merge had already renamed, and three of its in-process tests pin Node's synchronous rethrow out of process.emit('unhandledRejection') — a semantic Bun does not have (it defers the rethrow to uncaughtException). The fork's gate runs the suite under Bun, so: the crash-worker subprocess now explicitly resolves a real Node executable (skipping Bun's `bun-node-*` PATH shims, which also masquerade as process.execPath under `bun --bun`) and resolves tsx from the workspace's own node_modules so Node can find esbuild there; the three Node-only rethrow assertions early-return on a Bun runtime and stay fully active when the suite runs under Node (86/86 there). The abort-does-not-crash coverage (MoonshotAI#2801) that upstream's rewrite dropped is restored as a subprocess test, which also replaces a Windows-timer-sensitive polling helper. MoonshotAI#3694 is recorded not-applicable in the delta allowlist: the minidb half (the lock-aware wipe) shipped with the 2.0.0 merge itself, and the agent-core-v2 half (rebuilding session/search indexes on storage failures) has no counterpart — the engine's search is a SQL LIKE query over the messages table and the transcript is re-folded from the event store on read, so there is no derived index to go stale. Verification: bun --bun run test 8311 passed / 0 failed; the telemetry package also passes 86/86 under plain Node; tsc clean for apps/vscode and apps/kimi-code; parity, delta, no-legacy-engine and locale gates all pass.
Related Issue
Internal initiative (no linked issue): make VS Code extension usage visible in the existing telemetry pipeline.
Problem
The VS Code extension emits no telemetry at all: engine events produced in-process are dropped, so we cannot count extension users, nor distinguish them from CLI /
kimi webusers (which already share one pipeline, one format, one endpoint).What changed
apps/vscode/src/telemetry.ts): initializes the shared v1 telemetry client at activation with extension identity (appName: kimi-code-vscode,ui_mode: vscode), the shared device id, the region-aware endpoint (same resolution as the CLI), and the extension's OAuth token source;deactivate()flushes with a 2s timeout, guarded byfinallyso a failing engine shutdown cannot skip the flush.KIMI_DISABLE_TELEMETRY,config.tomltelemetry = false, and VS Code's global telemetry setting (isTelemetryEnabled, followed live viaonDidChangeTelemetryEnabled). No extension-specific setting is added — Marketplace policy only mandates respecting the global switch.session_started+ SDK-forwarded engine events + the defaultsystem_metricsheartbeat + the existingfirst_launch.@moonshot-ai/kimi-telemetry: new soft switchsetTelemetryEnabled(pauses intake and drops buffered events without detaching the sink) and aninitiallyEnabledbootstrap option (starts intake paused and skips the disk-spool replay until the host opens its gate). The previous harddisable()is renamedteardown()to make the hard/soft distinction explicit; it had no callers outside the package.Spec deviation note
The spec said the dynamic gate should "delegate to the client's existing
enable()/disable()". That pair does not support the spec's own "no sink rebuild on re-enable" requirement —disable()tears the sink down andenable()never re-attaches it, so events accepted after a re-enable would sit in an in-memory queue forever. The soft switch is the faithful reading of the decision; confirmed by a three-axis local review (standards / spec / defects).Known limitations (accepted)
first_launchis dropped, not deferred, when the global switch is off at first activation — same semantics as the CLI under its static gate.extensionKind: ["workspace"]): the device id belongs to the remote host.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update (the docs site covers the CLI; the extension follows VS Code's platform-native telemetry setting).