Skip to content

feat(vscode): wire the extension into the shared telemetry pipeline - #3852

Merged
Grapedge merged 4 commits into
mainfrom
vsc-telemetry
Sep 17, 2026
Merged

Grapedge merged 4 commits into
mainfrom
vsc-telemetry

Conversation

@Grapedge

Copy link
Copy Markdown
Collaborator

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 web users (which already share one pipeline, one format, one endpoint).

What changed

  • Extension composition root (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 by finally so a failing engine shutdown cannot skip the flush.
  • Three-layer consent gate (AND): KIMI_DISABLE_TELEMETRY, config.toml telemetry = false, and VS Code's global telemetry setting (isTelemetryEnabled, followed live via onDidChangeTelemetryEnabled). No extension-specific setting is added — Marketplace policy only mandates respecting the global switch.
  • Zero new event types: harness session_started + SDK-forwarded engine events + the default system_metrics heartbeat + the existing first_launch.
  • No crash handlers in the shared extension host (they would attribute other extensions' crashes to us).
  • @moonshot-ai/kimi-telemetry: new soft switch setTelemetryEnabled (pauses intake and drops buffered events without detaching the sink) and an initiallyEnabled bootstrap option (starts intake paused and skips the disk-spool replay until the host opens its gate). The previous hard disable() is renamed teardown() to make the hard/soft distinction explicit; it had no callers outside the package.
  • Packaging: workspace dependency + tsdown alias so the bundle embeds the telemetry singleton.

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 and enable() 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_launch is dropped, not deferred, when the global switch is off at first activation — same semantics as the CLI under its static gate.
  • A disk-spool replay already in flight is not aborted mid-flight if the switch is turned off at that exact moment (window: seconds; the events were collected under consent). Replays only start at activation and are gated there.
  • Remote development (extensionKind: ["workspace"]): the device id belongs to the remote host.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (internal initiative; see above).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update (the docs site covers the CLI; the extension follows VS Code's platform-native telemetry setting).

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-bot

changeset-bot Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2508c5c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kimi-telemetry Minor
kimi-code Minor

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@2508c5c
npx https://pkg.pr.new/@moonshot-ai/kimi-code@2508c5c

commit: 2508c5c

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/telemetry/src/client.ts Resolved
@Grapedge

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/telemetry/src/bootstrap.ts Resolved
@Grapedge

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/vscode/src/runtime/kimi-runtime.ts Resolved
@Grapedge
Grapedge merged commit bbcdde0 into main Sep 17, 2026
15 checks passed
@Grapedge
Grapedge deleted the vsc-telemetry branch September 17, 2026 05:46
@github-actions github-actions Bot mentioned this pull request Sep 17, 2026
7723qqq added a commit to 7723qqq/kimi-code that referenced this pull request Sep 17, 2026
…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.
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.

1 participant