Repository navigation
Description
Filed as an issue rather than a pull request: PR creation from outside accounts is currently refused on this repo (GraphQL returns FORBIDDEN for CreatePullRequest), and no non-owner PR has been opened since 2026-06-11. Issue creation still works, so I'm following CONTRIBUTING's preference for issues anyway.
Depends on #892 (test isolation): without that fix the telemetry test suite fails on any opted-out machine, including the tests added here.
Branch with the change, if useful as a reference: feat/telemetry-cli
Problem
Telemetry state is only discoverable by reading TELEMETRY.md and checking for ~/.jcode/no_telemetry by hand, and the only documented opt-outs are an env var or touch. There is no way to ask jcode what it is currently doing.
The bug I hit while building it
This is the part worth reviewing even if you dislike the rest of it.
src/cli/startup.rs:116 calls record_install_if_first_run() before clap parses argv. So on a fresh machine:
jcode telemetry disable
created an install ID and transmitted an install event to the production endpoint, and only then honored the opt-out. The first thing a privacy-conscious user does on a new machine was the one command guaranteed to send telemetry before they could stop it.
It only reproduces on a machine that has never run jcode, which is why it is easy to miss. I found it with a sandboxed HOME and a local collector.
Fixed with is_telemetry_subcommand_invocation(), which reads argv directly because this runs before clap. It matches only the leading positional, so a prompt that happens to contain the word "telemetry" does not suppress telemetry. There are two tests covering exactly that distinction.
The feature
jcode telemetry status [--json]
jcode telemetry enable
jcode telemetry disable
Design notes:
statusis strictly read-only. It uses a newread_existing_id()rather thanget_or_create_id(), so asking "what is my telemetry state?" does not assign an install ID to a user who has never sent an event. Doing otherwise would mean the act of checking creates the thing you were checking for.TelemetryOptOutSourcedistinguishes env opt-outs from the marker file, because they are not equally reversible.enablereports when it removed the marker but an env var still disables telemetry, rather than printing a success that would not take effect.
Also fixes a non-exhaustive match in proctitle.rs surfaced by the new Command variant, and a stale path in TELEMETRY.md (the implementation moved to crates/jcode-telemetry-core/src/, the doc still pointed at src/telemetry.rs).
Verification
- 6 new tests (4 in telemetry-core for opt-out precedence and the read-only status snapshot, 2 in
cli::startupfor argv detection) - full jcode lib suite: 215 pass / 2 fail on master, 218 pass / 2 fail here, the same two pre-existing failures
- end-to-end with the built binary against a sandboxed
HOMEand a local collector, confirming the fresh-machine ordering bug is gone fmt,clippy -D warnings, and all five ratchets flag the same file set as master
The separate test: commit bumps the size and swallowed-error baselines. These are hard CI gates and this change grows four tracked entries, so without it CI fails. I bumped only the entries this change touches rather than running the scripts' --update, since master currently exceeds those baselines in unrelated files (jcode-desktop2, jcode-tui, acp.rs) and a blanket update would bake that drift in under this change.
Tradeoffs / where I would push back on myself
- The argv pre-scan duplicates a small amount of knowledge that clap otherwise owns. It is unavoidable given the ordering, but it is the thing most likely to rot if the CLI grows.
- I chose to make
enablewarn rather than fail when an env var still overrides. Failing is defensible too.
Disclosure: written with agent assistance, reviewed and verified by me. Understood from CONTRIBUTING that you may prefer to write your own version. The startup ordering bug and the sandboxed reproduction are the parts I would most want preserved.
Activity
1jehuang commentedon Aug 12, 2026
Implemented telemetry subcommands with startup pre-scan so a fresh-machine
telemetry disabledoes not emit install or upgrade telemetry first, in #907. Unit tests and a fresh scratch-home CLI workflow pass.— Jcode agent (automated triage), on behalf of @1jehuang
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)
chore: sync fork with upstream jcode (fresh merge onto current master) (
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)
fix: honor telemetry opt-out before install event (fixes 1jehuang#893)