Skip to content

fix: keep usage reporting off once it is turned off - #178

Merged
dmccoystephenson merged 1 commit into
mainfrom
fix/opt-out-fails-closed
Nov 19, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
fix/opt-out-fails-closed

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Usage reporting is made to stay off once it has been turned off, in the vendored client and in Apex's own settings handling.

Changes

  • The vendored trace client is updated from trace-client-python 0.4.1 to 0.5.0 (Make every opt-out fail closed (0.5.0) Stephenson-Software/trace-client-python#45), in which every opt-out fails closed: TRACE_USAGE_REPORTING set to anything but blank/true/on/yes/1, or DO_NOT_TRACK set to anything but blank/0/false/off/no, turns reporting off. The vendored test suite is updated to match (the two package-layout tests, which read pyproject.toml and the package __init__, are left out because a single vendored module has neither).
  • Fail-open paths fixed in UsageReportingService:
    • enabled was read with bool(), so "enabled": "false" or "off" reported. It is now read with the client's allows_reporting(): only true or an on-string reports.
    • "usage_reporting": false (or any non-object) fell back to the default block, i.e. on. It is now read as the switch itself.
    • A settings.json holding valid JSON that is not an object was treated as empty, so the first-run block (on) was written over it. It now leaves reporting off and the file untouched.
    • A first run under an environment opt-out wrote "enabled": true, so a later run without the variable reported without the on-notice ever having been shown. It now records "enabled": false, and the notice says so.
  • README opt-out section updated.

Tests

  • New tests for each path above; the first-run-under-environment test now expects "enabled": false.
  • python3 -m pytest tests: 608 passed, 3 skipped.

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Re-vendor trace-client-python 0.5.0 (every opt-out fails closed) and make
apex's own switch fail closed too:
- enabled is read with allows_reporting(), not bool(): "false"/"off" no longer report
- "usage_reporting": false (not a block) is read as the switch, not as defaults
- a settings.json that is not a JSON object is no longer rewritten with reporting on
- a first run under TRACE_USAGE_REPORTING/DO_NOT_TRACK records enabled: false

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dmccoystephenson
dmccoystephenson merged commit 5686c1e into main Nov 19, 2026
2 checks passed
@dmccoystephenson
dmccoystephenson deleted the fix/opt-out-fails-closed branch November 19, 2026 05:59
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