Commit 78e2a20
authored
feat(telemetry): report unknown commands to Sentry (#563)
When Stricli's route scanner rejects an unrecognized subcommand (e.g.,
`sentry issue helpp`), it handles the error internally — writing to
stderr
and setting exitCode to 251 (UnknownCommand) without throwing. This
means
the error was invisible to Sentry telemetry.
Adds `reportUnknownCommand()` inside `runCommand` (within the
`withTelemetry`
scope) that detects `ExitCode.UnknownCommand` after `run()` completes
and
reports via `Sentry.captureMessage()` with rich context:
- **User context**: Already set by `initTelemetryContext()` in the
`withTelemetry` scope — user ID, email, instance ID, runtime, etc.
- **Org context**: Default organization from SQLite cache (no API call)
- **Fuzzy suggestions**: Runs `resolveCommandPath()` from the
introspection
system to find the unknown token and fuzzy-matched alternatives
- **Full argv**: For pattern analysis
This covers **nested route typos** like `sentry issue helpp` or
`sentry dashboard creat`. Top-level typos like `sentry isseu list` are
routed through the help command's fuzzy matching via `defaultCommand:
"help"`.
### Changes
- **`src/bin.ts`**: Import `ExitCode`, add `reportUnknownCommand()` that
detects unknown command exit code, walks the route tree for fuzzy
suggestions, reads default org from SQLite, and captures a Sentry
message event with structured context.1 parent 92e472e commit 78e2a20
0 commit comments