Skip to content

feat(analytics): report structured error causes instead of error text - #101

Merged
aarthy-dk merged 2 commits into
mainfrom
feat/analytics-outcome-fields
Nov 19, 2026
Merged

aarthy-dk merged 2 commits into
mainfrom
feat/analytics-outcome-fields

Conversation

@aarthy-dk

Copy link
Copy Markdown
Contributor

Summary

  • No more error text in events. The error property carried the exception message chain, including home-directory paths, user names, and command lines. Events now describe failures with codes and names:
    • abort_reason: every AbortAction has a reason from AbortReason, found anywhere in the exception chain.
    • failed_step: the step that failed, or that the user interrupted with Ctrl+C.
    • failed_optional_steps: optional steps that failed, such as demo data generation, without failing the action.
    • error_types: the exception class at each link of the chain. This also fixes every link being labeled with the outer exception's class.
    • failed_cmd and cmd_exit_code: the failed command's program and leading subcommands only, with no path or arguments (for example testgen standalone-setup), and its exit code.
    • step_durations and skipped_steps for multi-step actions.
  • Fewer junk events.
    • Nothing is sent while pytest runs.
    • Nothing is sent for commands the installer didn't register itself.
    • CLAUDE.md asks coding agents to run the installer with DK_INSTALLER_ANALYTICS=no, because the Mixpanel token is public.
  • A version for the .exe. The build stamps the MD5 of the committed script into the bundle, so the .exe reports the same version as the .py from the same commit. Events also carry is_exe.
  • Pip mode:
    • Every testgen command gets the installer's instance ID (TG_INSTANCE_ID), so TestGen's own events can be matched to the install.
    • An opt-out reaches TestGen: TG_ANALYTICS=no goes in the environment, and config.env is rewritten after setup and on upgrade. TG_ANALYTICS=yes is never set in the environment, because it would override an earlier opt-out.
    • Install and start send their success event once the app is ready, not when it stops. The event no longer depends on the user pressing Ctrl+C, and elapsed measures install time instead of how long the app ran.

Test plan

  • ruff check / ruff format --check clean
  • pytest: 300 passed, on Python 3.13 and 3.9
  • New tests cover what must not be sent (message text, paths, secrets), no sending under pytest or for unregistered commands, one success event even when the app is later interrupted, every raise AbortAction carrying a reason, and a pip opt-out reaching TestGen
  • Ran tg start and tg upgrade with no install, with sending replaced by a print: aborted with abort_reason: no_install and no error text
  • Ran the version-stamp commands locally on a copy of the script
  • The Windows build job stamps the version and the smoke test passes

🤖 Generated with Claude Code

@rboni-dk rboni-dk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UvToolUpgradeStep runs uv --no-cache tool upgrade …, and since get_command_name stops at the first option, that failure reports failed_cmd: "uv". uv tool upgrade --no-cache … would give us uv tool upgrade.

aarthy-dk and others added 2 commits November 19, 2026 00:01
Events no longer carry the exception message chain, which held home
directory paths, user names, and command lines. Failures and aborts are
described by codes instead: abort_reason (every AbortAction has one),
failed_step, failed_optional_steps, error_types, failed_cmd (program and
subcommand only), and cmd_exit_code. Multi-step actions also report
step_durations and skipped_steps.

- No events are sent while pytest runs, or for commands the installer
  does not register.
- The Windows .exe reports the MD5 of the script it bundles, matching the
  .py from the same commit, and every event carries is_exe.
- Pip mode passes the installer's instance ID to TestGen so its events
  can be matched to the install, and an opt-out now reaches TestGen
  through the environment and config.env.
- Pip install and start report success once the app is ready, not when
  it stops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ubuntu-latest moved to Ubuntu 26.04, which setup-python has no Python 3.9
build for, so lint and tests failed before running. 3.9 is still the
installer's minimum, so pin the runner instead of raising the version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aarthy-dk
aarthy-dk force-pushed the feat/analytics-outcome-fields branch from ad7e3ea to fd47c2c Compare November 19, 2026 05:11
@aarthy-dk

Copy link
Copy Markdown
Contributor Author

Thanks. Fixed in f822ef1: UvToolUpgradeStep now runs uv tool upgrade --no-cache …, so a failure reports failed_cmd: "uv tool upgrade". The command-name test case is updated to match.

@aarthy-dk
aarthy-dk merged commit c8570de into main Nov 19, 2026
4 checks passed
@aarthy-dk
aarthy-dk deleted the feat/analytics-outcome-fields branch November 19, 2026 17:23
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.

2 participants