Skip to content

jcode telemetry disable on a fresh machine sends an install event before honoring the opt-out #893

Closed

Description

@pleasedodisturb

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:

  • status is strictly read-only. It uses a new read_existing_id() rather than get_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.
  • TelemetryOptOutSource distinguishes env opt-outs from the marker file, because they are not equally reversible. enable reports 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::startup for 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 HOME and 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 enable warn 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

  1. added
    bug
    priority: high
    triage: reproducible
    autonomous: clear
    regression
    triage: fixed-pending-release
    on Aug 12, 2026
  2. 1jehuang commented on Aug 12, 2026

    @1jehuang
    Owner

    Implemented telemetry subcommands with startup pre-scan so a fresh-machine telemetry disable does 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

  3. added a commit that references this issue on Aug 12, 2026
    6fa94a8
  4. added a commit that references this issue on Aug 15, 2026
    a8e0afd
  5. added 5 commits that reference this issue on Aug 30, 2026
    45de355
    293cf55
    41b7fde
    bee5593
    ac1d5f5
  6. added a commit that references this issue on Sep 18, 2026
    0f675d8
  7. added a commit that references this issue on Oct 9, 2026
    9ebb77a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugpriority: highregressiontriage: fixed-pending-releasetriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions