Repository navigation
feat(telemetry): daily aggregate WSL usage snapshot on Windows - #31406
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
Adds a main-owned wsl_usage_snapshot event through the existing PostHog track() pipeline (same consent, opt-out, build gate and validator): WSL installed/version, distro counts (installed, running, WSL1/2), WSL-backed project counts (distro fs vs Windows drive, git vs folder), distinct project distros, and the internal WSL-hosts gate. Counts are bucketed; no paths or names leave the machine. At most once per 24h per install, Windows only.
Stamp before gathering so a failing gather isn't repaid hourly, treat a future stamp as due, resolve 'default distro' to its name for distinct counts, narrow the store type, and cover the running-probe choice and the closed WSL-hosts gate in tests.
37c48f1 to
463affe
Compare
ELI5
We want to know how many Windows users use WSL, and how they use it. Orca already sends anonymous usage events when telemetry is on. This adds one more: once a day, on Windows only, Orca sends a small summary of counts, such as "has WSL, version 2.4, 2–5 distros, 1 project inside a distro". It never sends anything that names a path, distro, repo or user.
What Changed
Before: Orca had only a few WSL signals, each a field on some other event:
workspace_created.execution_host,codex_trust_grant.host_kind, and the onboarding default-shell bucket. Nothing measured how many users have WSL installed or how their projects use it.After: a new main-process event,
wsl_usage_snapshot, goes through the existingtrack()insrc/main/telemetry/client.ts. So it uses the same PostHog project and the same consent rules as every other event:DO_NOT_TRACKandORCA_TELEMETRY_DISABLEDIt also passes through the same official-build gate, burst cap and strict zod validator. There is no new endpoint and no new consent surface. Only the main process can send the event, so the renderer can't emit or spoof it over IPC.
Exactly what is collected. Every count is a bucket:
0,1,2-5,6-20,21+.wsl_installedwsl_version2.4); left out for inbox/Store WSL or when it can't be readdistro_registry_readable0distros can be told apart from "unknown"distros_installed,distros_runningdistros_wsl1,distros_wsl2projects_wsl_totalprojects_wsl_distro_fs\\wsl$/\\wsl.localhost, or a Linux path on a WSL host)projects_wsl_windows_driveC:\project whose runtime is WSL, or/mnt/<x>on a WSL host)projects_wsl_git,projects_wsl_folderproject_distros_usedwsl_hosts_gate_openfalse)Never sent: paths, distro names, repo names, usernames, or the raw version string. Distro names stay in memory only, to count how many distinct ones there are.
How it works:
src/shared/telemetry-wsl-usage-event-schemas.ts: the strict schema and the bucketing.src/main/telemetry/wsl-usage-snapshot.ts: pure classification and aggregation.src/main/telemetry/wsl-usage-reporter.ts: gathering, scheduling, and the daily stamp file<userData>/wsl-usage-telemetry.json, which holds{ lastSentAt }.Cost: nothing runs off Windows or when telemetry is off. Otherwise each send (at most once per 24h) costs:
HKLM\...\Lxss\MSI\Version, which the WSL MSI installer writes. No process is started, and it replaceswsl --version.listWslHostDistrospath, which is one boundedreg.exe queryof the Lxss key with a 5s timeout.wsl --list --runningprobe, which never boots a distro. It is skipped when no user distro is registered.resolveLocalWorkspaceRuntime, which starts no process. WSL-host environments are read only when the internal gate is open.Why
The owner needs to know how many Windows users have WSL before deciding how much to invest in it. Reusing the existing pipeline keeps every opt-out rule in one place.
Alternatives considered:
app_opened: it fires on every launch and would put a process start on the boot path.wsl --list --verboseandwsl --version: their output is localized UTF-16 and they cost extra process starts. The registry already answers both, and it is what "Add WSL host" reads today.Linked Issue
N/A (maintainer request).
Visual Proof
N/A. There is no UI change; this is a background telemetry event.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
src/main/telemetry/wsl-usage-snapshot.test.tscovers:/mnt/<x>projects, including WSL projects waiting on a repairsrc/main/telemetry/wsl-usage-reporter.test.tscovers:Passing locally on macOS:
pnpm tc:node, the telemetry/IPC test suites, oxlint, oxfmt, andcheck:code-quality:changed. Windows behavior is covered by injected platform and registry seams; it has not been run on a real Windows machine.Review
An adversarial review focused on privacy and cost found no blockers and judged the change low risk.
Confirmed:
^\d{1,3}\.\d{1,3}$.reg.exeand one sharedwsl --list --runningper day.Fixed in the second commit:
Verified separately:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\MSIVersion; seemsipackage/package.wix.inin microsoft/WSL.Accepted as-is:
distros_runningcan reuse a running list Orca cached earlier in the session rather than probing fresh.\\wsl$share are not counted.Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)