Commit 21b6e38
Set anonymous Sentry user so alerts report users affected (#2840)
* Set anonymous Sentry user so alerts report users affected
Sentry alerts showed "Users: 0" because no user context was ever
attached to events. On @sentry/browser v9, sendDefaultPii defaults to
false (no IP), and the extension never called Sentry.setUser, so every
event arrived with an empty user and could not be attributed.
Attach the existing persisted anonymous analytics id (the same one
Amplitude uses) via Sentry.setUser, gated on the existing data-sharing
consent. No PII or wallet address — just an opaque per-install id, so
Sentry and Amplitude user counts stay aligned. Mirrors freighter-mobile.
Also harden generateRandomUserId: Math.random() can yield values < 1e-6
(exponential notation) or exactly 0, where split(".")[1] is undefined;
fall back to "0" so we never hand Sentry/Amplitude an undefined id.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Address review: clear Sentry user on opt-out, stub getUserId in jest mock
- Clear the per-install user id (Sentry.setUser(null)) before Sentry.close
on data-sharing opt-out. Sentry.close may still report (anonymized) until
the next refresh; without this those reports would keep the id attached.
- Add getUserId to the helpers/metrics jest mock in setupTests so rendering
ErrorTracking under test doesn't call an undefined mock.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 4112516 commit 21b6e38
3 files changed
Lines changed: 20 additions & 4 deletions
File tree
- config/jest
- extension/src
- helpers
- popup/components/ErrorTracking
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| |||
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | | - | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
48 | 56 | | |
49 | 57 | | |
50 | 58 | | |
51 | | - | |
52 | | - | |
| 59 | + | |
| 60 | + | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
| |||
0 commit comments