Skip to content

feat(telemetry): daily aggregate WSL usage snapshot on Windows - #31406

Merged
nwparker merged 2 commits into
mainfrom
feat/wsl-usage-telemetry
Oct 22, 2026
Merged

nwparker merged 2 commits into
mainfrom
feat/wsl-usage-telemetry

Conversation

@nwparker

@nwparker nwparker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​358 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​358
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​396 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​394

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 existing track() in src/main/telemetry/client.ts. So it uses the same PostHog project and the same consent rules as every other event:

  • DO_NOT_TRACK and ORCA_TELEMETRY_DISABLED
  • CI detection
  • the Privacy opt-out
  • the pending first-launch notice

It 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+.

Field Meaning
wsl_installed boolean
wsl_version WSL package major.minor (e.g. 2.4); left out for inbox/Store WSL or when it can't be read
distro_registry_readable boolean, so 0 distros can be told apart from "unknown"
distros_installed, distros_running user distros (Docker Desktop's internal ones excluded)
distros_wsl1, distros_wsl2 per WSL version
projects_wsl_total Orca projects backed by WSL
projects_wsl_distro_fs inside the distro filesystem (\\wsl$ / \\wsl.localhost, or a Linux path on a WSL host)
projects_wsl_windows_drive on a Windows drive opened through WSL (a C:\ project whose runtime is WSL, or /mnt/<x> on a WSL host)
projects_wsl_git, projects_wsl_folder git repos vs folder workspaces
project_distros_used number of distinct distros those projects use
wsl_hosts_gate_open the internal WSL-hosts gate (expected false)

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 }.
  • The reporter starts after the first window shows. A timer checks an in-memory timestamp every hour, so a session that stays open for days still sends once a day. The timer is unref'd, so it never keeps the app alive.

Cost: nothing runs off Windows or when telemetry is off. Otherwise each send (at most once per 24h) costs:

  • WSL version: one in-process native registry read of HKLM\...\Lxss\MSI\Version, which the WSL MSI installer writes. No process is started, and it replaces wsl --version.
  • Distros and WSL1/2: the existing listWslHostDistros path, which is one bounded reg.exe query of the Lxss key with a 5s timeout.
  • Running count: the cached running-distro list when Orca has one. Otherwise one call to the existing shared wsl --list --running probe, which never boots a distro. It is skipped when no user distro is registered.
  • Projects: read from the in-memory repo/project store through the existing 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:

  • Adding WSL fields to app_opened: it fires on every launch and would put a process start on the boot path.
  • Running wsl --list --verbose and wsl --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.ts covers:

    • bucketing, and trimming the version to major.minor
    • classifying UNC vs Windows-drive vs /mnt/<x> projects, including WSL projects waiting on a repair
    • the payload passing the real validator, and the validator rejecting a distro name, a free-form version, or an unbucketed count
  • src/main/telemetry/wsl-usage-reporter.test.ts covers:

    • sending once, then not again within 24h, across restarts
    • gathering nothing off Windows or with telemetry off
    • stamping a dropped send, so the gather isn't repeated every hour
    • a corrupt stamp file
    • a failed gather never throwing
  • Passing locally on macOS: pnpm tc:node, the telemetry/IPC test suites, oxlint, oxfmt, and check: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:

  • Consent: the existing consent check runs before any registry read or process start.
  • Payload: the schema is strict, counts are buckets only, and the version must match ^\d{1,3}\.\d{1,3}$.
  • Spoofing: only the main process can send the event.
  • Cost: at most one reg.exe and one shared wsl --list --running per day.

Fixed in the second commit:

  • A failed gather was retried every hour. The stamp is now written before gathering.
  • A stamp from the future (clock moved back) blocked sending. It now counts as due.
  • A project on the default distro was counted as a separate distro. "Default distro" now resolves to its real name before counting.
  • The store type was narrowed, which removed a type assertion in the tests.
  • New tests cover the cached-list / probe / no-probe choice and the closed-gate skip.

Verified separately:

  • The WSL installer writes HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\MSI Version; see msipackage/package.wix.in in microsoft/WSL.

Accepted as-is:

  • distros_running can reuse a running list Orca cached earlier in the session rather than probing fresh.
  • Only the project's own kind (git or folder) is counted. Folder workspaces in project groups whose path is a \\wsl$ share are not counted.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security and privacy: only aggregate buckets leave the machine, the schema is strict, and only the main process can send the event.
  • Cross-platform: Windows only. macOS and Linux return before doing any work.
  • SSH: SSH repos are not counted, and nothing runs on remote hosts.
  • Backwards compatibility: this is a new, additive event. Older clients simply don't send it.
  • Performance: see the cost list above.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d8d06d9b-aed1-4f5c-bcbc-2a2ff9d5c4af
📥 Commits

Reviewing files that changed from the base of the PR and between 37c48f1 and 463affe.

📒 Files selected for processing: 2
  • src/main/startup/main-process-ready-runtime.ts
  • src/shared/telemetry-event-registry.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The change adds a strict, bucketed WSL usage telemetry schema and snapshot aggregation. A Windows-only reporter gathers WSL and project usage data, persists reporting attempts, and sends eligible snapshots on a daily schedule. Startup schedules the reporter after the first window is shown. The telemetry registry validates the event, and the IPC guard prevents renderer-originated tracking of this main-owned event.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 463af

No actionable merge-blocking risk is established for this telemetry change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: a daily aggregate WSL usage snapshot for Windows telemetry.
Description check Passed The description is complete and focused. It covers the purpose, implementation, privacy controls, testing, limitations, cross-platform impact, and checklist. The linked issue is marked N/A with a main…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete and focused. It covers the purpose, implementation, privacy controls, testing, limitations, cross-platform impact, and checklist. The linked issue is marked N/A with a maintainer rationale, and automated testing is documented.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
@nwparker
nwparker force-pushed the feat/wsl-usage-telemetry branch from 37c48f1 to 463affe Compare October 22, 2026 09:25
@nwparker
nwparker merged commit 6a9a80a into main Oct 22, 2026
49 checks passed
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