Commit 2988043
feat(trial): auto-prompt for Seer trial + sentry trial list/start commands (#399)
## Summary
When Seer commands (`issue explain`, `issue plan`) fail with a budget or
enablement error in an interactive terminal, the CLI now checks for an
available Seer product trial, prompts the user, and retries the command
on success. Additionally, new `sentry trial list` and `sentry trial
start` commands give users proactive control over product trials.
## Auto-prompt flow
Mirrors the existing `executeWithAutoAuth` middleware pattern:
```
main() → executeWithAutoAuth() → executeWithSeerTrialPrompt() → runCommand()
```
1. Seer command fails with `SeerError` (`no_budget` or `not_enabled`)
2. `isTrialEligible()` checks: eligible reason + org slug available +
interactive TTY
3. Fetches trial availability via `GET /api/0/customers/{org}/` (control
silo)
4. Finds an unstarted Seer trial (prefers `seerUsers`, falls back to
`seerAutofix`)
5. Prompts user with consola confirm
6. Starts trial via `PUT /api/0/customers/{org}/product-trial/`
7. Retries the original command through the full middleware chain
Non-eligible errors (`ai_disabled`, missing org slug, non-TTY, API
failures) pass through unchanged.
## Trial commands
### `sentry trial list [org]`
Lists all product trials for an org with status indicators:
- ○ Available (cyan) — not yet started
- ● Active (green) — started, with days remaining
- − Expired (muted) — ended
Supports `--json` and `--fields` for machine consumption.
### `sentry trial start <name> [org]`
Starts a named product trial. Supported names: `seer`, `replays`,
`performance`, `spans`, `profiling`, `logs`.
Features smart argument swap detection — `sentry trial start my-org
seer` works the same as `sentry trial start seer my-org`.
## Key design decisions
- **`isTrialEligible()` accepts `unknown`** — does the `instanceof
SeerError` check internally so callers don't need to narrow first
- **Control silo routing** — `/customers/` is a billing endpoint, uses
`getControlSiloUrl()` not region URLs
- **Consola logger** — all user-facing output uses
`log.info()`/`log.warn()`/`log.success()` per project conventions (no
raw `stderr.write`)
- **Graceful degradation** — API failures during trial check silently
fall through to the normal error display
- **`ai_disabled` excluded** — admin's explicit choice to disable AI;
trial wouldn't override it
- **UTC timezone** — `getTrialStatus()` uses `setUTCHours()` for
consistent date comparison
- **Soft trial hints in error messages** — `SeerError.format()` says
"You may be eligible" + `sentry trial list` (not a direct "start" since
trial may not exist)
## New files
| File | Description |
|------|-------------|
| `src/lib/seer-trial.ts` | `isTrialEligible()` +
`promptAndStartTrial()` |
| `src/lib/trials.ts` | Trial name mapping, status helpers,
`findAvailableTrial()` |
| `src/commands/trial/index.ts` | Route map for trial subcommands |
| `src/commands/trial/list.ts` | `sentry trial list` command |
| `src/commands/trial/start.ts` | `sentry trial start` command |
| `src/lib/arg-parsing.ts` | `detectSwappedTrialArgs()` |
## Modified files
| File | Changes |
|------|---------|
| `src/lib/api-client.ts` | `getProductTrials()` + `startProductTrial()`
using control silo |
| `src/lib/errors.ts` | Soft trial hint in `SeerError.format()` |
| `src/bin.ts` | `executeWithSeerTrialPrompt()` middleware |
| `src/app.ts` | Register trial routes + `trials` alias |
| `src/types/sentry.ts` | `ProductTrialSchema`,
`CustomerTrialInfoSchema` |
## Tests
- **20 unit tests** for trial prompt flow (`seer-trial.test.ts`)
- **10 unit tests** for trial API client
(`api-client.seer-trial.test.ts`)
- **30 unit tests** for trial helpers (`trials.test.ts`)
- **4 property-based tests** for eligibility invariants
(`seer-trial.property.test.ts`)
- **9 unit tests** for `trial list` command (`trial/list.test.ts`)
- **10 unit tests** for `trial start` command (`trial/start.test.ts`)
- **4 unit tests** for `detectSwappedTrialArgs` (`arg-parsing.test.ts`)
- 87 trial-related tests total, all passing
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>1 parent 809ef5f commit 2988043
File tree
22 files changed
+2268
-30
lines changed- plugins/sentry-cli/skills/sentry-cli
- src
- commands/trial
- lib
- types
- test
- commands/trial
- lib
22 files changed
+2268
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
646 | | - | |
| 646 | + | |
| 647 | + | |
647 | 648 | | |
648 | | - | |
649 | | - | |
| 649 | + | |
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| |||
689 | 689 | | |
690 | 690 | | |
691 | 691 | | |
692 | | - | |
| 692 | + | |
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
670 | 690 | | |
671 | 691 | | |
672 | 692 | | |
| |||
794 | 814 | | |
795 | 815 | | |
796 | 816 | | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
797 | 829 | | |
798 | 830 | | |
799 | 831 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| 54 | + | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| |||
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| |||
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| 81 | + | |
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | | - | |
| 54 | + | |
41 | 55 | | |
42 | | - | |
43 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
44 | 83 | | |
45 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
46 | 87 | | |
47 | | - | |
| 88 | + | |
48 | 89 | | |
49 | | - | |
| 90 | + | |
50 | 91 | | |
51 | | - | |
52 | 92 | | |
53 | 93 | | |
54 | 94 | | |
| |||
71 | 111 | | |
72 | 112 | | |
73 | 113 | | |
74 | | - | |
| 114 | + | |
75 | 115 | | |
76 | 116 | | |
77 | 117 | | |
78 | | - | |
79 | | - | |
| 118 | + | |
80 | 119 | | |
81 | 120 | | |
82 | 121 | | |
83 | 122 | | |
84 | | - | |
85 | 123 | | |
86 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
87 | 161 | | |
88 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
89 | 166 | | |
90 | 167 | | |
91 | 168 | | |
| |||
108 | 185 | | |
109 | 186 | | |
110 | 187 | | |
111 | | - | |
| 188 | + | |
112 | 189 | | |
113 | 190 | | |
114 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments