feat: implement proxy-based telemetry for VS Code extension#410
feat: implement proxy-based telemetry for VS Code extension#410markijbema merged 25 commits intodevfrom
Conversation
| 2. **Minimize changes to shared files** - When you must modify files that exist in upstream opencode, keep changes as small and isolated as possible. | ||
|
|
||
| 3. **Use `kilocode_change` markers** - When modifying shared code, mark your changes with `kilocode_change` comments so they can be easily identified during merges. | ||
| Do not use these markers in files within directories with kilo in the name |
There was a problem hiding this comment.
got annoyed by this
- Add POST /telemetry/capture endpoint to CLI server - Add TelemetryProxy singleton in extension (forwards to CLI) - Add webview telemetry helper (postMessage → extension → CLI) - Pass telemetry env vars (level, editor_name, platform, machineId) to CLI - Wire up KiloProvider as TelemetryPropertiesProvider - Replace TelemetryStub with real TelemetryProxy in autocomplete - 53 telemetry events covering tasks, LLM, tools, UI, autocomplete, etc.
1e13cc9 to
d862296
Compare
The PostHogSpanExporter and TracerSetup had hardcoded 'kilo-cli' and process.platform values, bypassing the env var overrides. Now appName, appVersion, and platform flow from Telemetry.init() through TracerSetup to PostHogSpanExporter, so $ai_generation events show correct values when CLI is spawned by VS Code.
- KILO_APP_NAME: product name ('kilo-code') — overrides appName
- KILO_EDITOR_NAME: IDE name (vscode.env.appName) — sets editorName only
- Previously both were set to the same 'Kilo VSCode (CLI)' value
- appName: 'kilo-code' (was vscode.env.appName which showed 'Visual Studio Code') - platform: 'vscode' (was process.platform which showed 'darwin') - editorName: vscode.env.appName (IDE name, e.g. 'Visual Studio Code') - vscodeVersion: vscode.version (e.g. '1.109.4')
Previously picked the first binary found in dist (often linux-x64-musl).
Now checks for cli-{platform}-{arch} first (e.g. cli-darwin-arm64).
- Added KILO_VSCODE_VERSION env var passed from extension to CLI - OTel span exporter now includes editorName and vscodeVersion - Removed all _debug_* temporary properties from track() and exportSpan()
|
|
||
| // Expected: packages/opencode/dist/@kilocode/cli-<platform>/bin/kilo | ||
| // But keep it flexible: find any dist/**/bin/kilo | ||
| // Prefer the binary matching the current platform (e.g. cli-darwin-arm64) |
There was a problem hiding this comment.
it was copying the linux build for me
Code Review SummaryStatus: No New Issues Found | Recommendation: Address existing comments before merge OverviewThis PR implements a telemetry proxy architecture where the VS Code extension forwards telemetry events to the CLI server via
The existing inline comments from reviewers cover the key issues. No additional bugs, security vulnerabilities, or runtime errors were found. Other Observations (not in diff)Issues found during review that are design considerations rather than bugs:
Files Reviewed (25 files)
|
9bbf55d to
fda8a5f
Compare
| } | ||
|
|
||
| const payload = JSON.stringify({ event, properties: merged }) | ||
| const auth = `Basic ${Buffer.from(`kilo:${this.password}`).toString("base64")}` |
There was a problem hiding this comment.
Why Basic and not Bearer?
There was a problem hiding this comment.
this is to the cli, not the api
Respects --disable-telemetry CLI flag, managed/policy settings, and other VS Code-level overrides that getConfiguration() misses.
Summary
Implements proxy-based telemetry for the VS Code extension, forwarding events through the CLI server to the kilo-telemetry package (PostHog).
Architecture
The extension never talks to PostHog directly. All telemetry flows through the CLI server, which owns the PostHog client via
@kilocode/kilo-telemetry.Limitations
I only added the telemetry for events which arent happening in the CLI; this means that some classical events are missing because the cli does not emit them. I think we need to look at how to get that more in sync between CLI and vscode, as i don't think we want that as a separate code path in the vscode extension.
Fixes #371