Skip to content

Report usage to trace - #29

Merged
dmccoystephenson merged 1 commit into
mainfrom
trace/wiring
Sep 24, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
trace/wiring

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Patchwork was wired to trace in #26, but no program key was shipped: an event was only sent when PATCHWORK_USAGE_REPORTING_KEY was set, so no installation ever reported. The program's key is now shipped by default (keys identify a program and are not secrets, per trace's ADR 0001), the environment variable is kept as an override, and the first-run notice now says reporting is on instead of "available when ... is set". An environment-created event is also reported when a new environment is created through Viron. The opt-outs are unchanged: "usage_reporting": {"enabled": false} in settings.json, TRACE_USAGE_REPORTING=off and DO_NOT_TRACK=1.

  • usage_reporting.py: DEFAULT_KEY added and written into the first-run settings.json block; the key is taken from PATCHWORK_USAGE_REPORTING_KEY, then the settings block, then the shipped key, so a settings.json written before this change still reports; the notice uses the on-by-default wording used by apex.
  • main.py: the client returned by startUsageReporting reports environment-created after a new environment is recorded. Direct main() calls still report nothing.
  • tests/: the first-run block, the notice wording, the key precedence and the new event are covered; every test runs against a loopback stub or reports nothing.
  • README.md: the ## Usage reporting section describes reporting as on by default and lists both events and every opt-out.

Verified: python3 -m unittest discover -s tests passes (87 tests, Python 3.8). A local run against a loopback stub received startup (tag version) and environment-created for patchwork with the shipped key. One event tagged ci=true and verify=true was sent to production with the shipped key and was accepted with HTTP 201.

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Reporting only happened when PATCHWORK_USAGE_REPORTING_KEY was set, so in
practice patchwork never reported. The program key now ships in
usage_reporting.py and in the settings.json block written on first run;
the environment variable still overrides it. The first-run notice says
reporting is on, and creating a new environment reports
environment-created. The settings.json opt-out and the
TRACE_USAGE_REPORTING / DO_NOT_TRACK opt-outs are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012tRTngcEmZUaiHKcX2ErSS
@dmccoystephenson
dmccoystephenson merged commit 3d6aa7d into main Sep 24, 2026
@dmccoystephenson
dmccoystephenson deleted the trace/wiring branch September 24, 2026 05:22
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