Commit 51b6bbd
feat(rewards): add targeted Sentry capture for rewards auth errors (MetaMask#29545)
## Summary
Adds `captureException` to six targeted catch blocks across the rewards
controller and hooks. Scoped intentionally to avoid noise — only errors
that are either user-facing, represent rare high-severity auth failures,
or are unexpected outer-catch escapes from flows with visible user
impact.
### Instrumented locations
| Location | Context tag | When it fires |
|---|---|---|
| `useCandidateSubscriptionId` catch |
`candidateSubscriptionId.fetch_failed` | Every time the auth-failed
modal is shown to the user |
| `RewardsController.performSilentAuth` non-401 branch |
`performSilentAuth.unexpected_error` | Unexpected server errors (e.g.
500s) during silent auth — rare |
| `RewardsController.#withAuthRetry` reauthError catch |
`withAuthRetry.reauth_failed` | 403 recovery itself throws, forcing
cache invalidation — very rare |
| `RewardsController.#optIn` outer catch | `optIn.unexpected_error` |
Unexpected failures after inner InvalidTimestamp/AlreadyRegistered
handling |
| `RewardsController.linkAccountToSubscriptionCandidate` catch |
`linkAccountToSubscriptionCandidate.failed` | Unexpected failures after
inner retry/recovery handling |
| `RewardsController.optOut` catch | `optOut.failed` | API 500s or
network errors during opt-out |
All events tagged `{ feature: 'rewards', context: '<location>' }`. The
three captures with an `InternalAccount` in scope also emit `extra: {
accountType }` (chain namespace, e.g. `eip155:eoa`) for filtering by
account kind without exposing PII.
## Changelog
CHANGELOG entry: null
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Primarily adds observability side effects in error paths without
changing success-path behavior; low risk aside from potential for minor
telemetry noise or additional overhead when failures occur.
>
> **Overview**
> Adds targeted Sentry error reporting to rewards flows by calling
`captureException` in select catch blocks across
`useCandidateSubscriptionId` and `RewardsController` (silent auth
unexpected failures, 403 reauth retry failures, opt-in/linking failures,
and opt-out failures), consistently tagged with `{ feature: 'rewards',
context: ... }` and including `accountType` as extra where available.
>
> Updates and extends unit tests to mock Sentry and assert the new
`captureException` calls (including new coverage for non-401 silent-auth
login errors and other unexpected failure cases).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ccf3146. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent e717be3 commit 51b6bbd
4 files changed
Lines changed: 149 additions & 0 deletions
File tree
- app
- components/UI/Rewards/hooks
- core/Engine/controllers/rewards-controller
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
108 | 122 | | |
109 | 123 | | |
110 | 124 | | |
| |||
157 | 171 | | |
158 | 172 | | |
159 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
160 | 180 | | |
161 | 181 | | |
162 | 182 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
| |||
Lines changed: 97 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| |||
4560 | 4564 | | |
4561 | 4565 | | |
4562 | 4566 | | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
| 4585 | + | |
| 4586 | + | |
| 4587 | + | |
| 4588 | + | |
| 4589 | + | |
| 4590 | + | |
| 4591 | + | |
| 4592 | + | |
| 4593 | + | |
| 4594 | + | |
| 4595 | + | |
| 4596 | + | |
| 4597 | + | |
| 4598 | + | |
| 4599 | + | |
| 4600 | + | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
| 4607 | + | |
| 4608 | + | |
4563 | 4609 | | |
4564 | 4610 | | |
4565 | 4611 | | |
| |||
5230 | 5276 | | |
5231 | 5277 | | |
5232 | 5278 | | |
| 5279 | + | |
| 5280 | + | |
| 5281 | + | |
| 5282 | + | |
| 5283 | + | |
| 5284 | + | |
| 5285 | + | |
| 5286 | + | |
5233 | 5287 | | |
5234 | 5288 | | |
5235 | 5289 | | |
| |||
10238 | 10292 | | |
10239 | 10293 | | |
10240 | 10294 | | |
| 10295 | + | |
| 10296 | + | |
| 10297 | + | |
| 10298 | + | |
| 10299 | + | |
| 10300 | + | |
| 10301 | + | |
10241 | 10302 | | |
10242 | 10303 | | |
10243 | 10304 | | |
| |||
11267 | 11328 | | |
11268 | 11329 | | |
11269 | 11330 | | |
| 11331 | + | |
| 11332 | + | |
| 11333 | + | |
| 11334 | + | |
| 11335 | + | |
| 11336 | + | |
| 11337 | + | |
| 11338 | + | |
| 11339 | + | |
| 11340 | + | |
| 11341 | + | |
| 11342 | + | |
| 11343 | + | |
| 11344 | + | |
| 11345 | + | |
| 11346 | + | |
| 11347 | + | |
| 11348 | + | |
| 11349 | + | |
| 11350 | + | |
| 11351 | + | |
| 11352 | + | |
| 11353 | + | |
| 11354 | + | |
| 11355 | + | |
| 11356 | + | |
| 11357 | + | |
| 11358 | + | |
| 11359 | + | |
11270 | 11360 | | |
11271 | 11361 | | |
11272 | 11362 | | |
| |||
13133 | 13223 | | |
13134 | 13224 | | |
13135 | 13225 | | |
| 13226 | + | |
| 13227 | + | |
| 13228 | + | |
| 13229 | + | |
| 13230 | + | |
| 13231 | + | |
| 13232 | + | |
13136 | 13233 | | |
13137 | 13234 | | |
13138 | 13235 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
950 | 951 | | |
951 | 952 | | |
952 | 953 | | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
953 | 957 | | |
954 | 958 | | |
955 | 959 | | |
| |||
1314 | 1318 | | |
1315 | 1319 | | |
1316 | 1320 | | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
1317 | 1328 | | |
1318 | 1329 | | |
1319 | 1330 | | |
| |||
2541 | 2552 | | |
2542 | 2553 | | |
2543 | 2554 | | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
2544 | 2559 | | |
2545 | 2560 | | |
2546 | 2561 | | |
| |||
3059 | 3074 | | |
3060 | 3075 | | |
3061 | 3076 | | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
3062 | 3084 | | |
3063 | 3085 | | |
3064 | 3086 | | |
| |||
3178 | 3200 | | |
3179 | 3201 | | |
3180 | 3202 | | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
3181 | 3206 | | |
3182 | 3207 | | |
3183 | 3208 | | |
| |||
0 commit comments