Commit 28c8587
fix: correct typeof comparisons in browser SDK
Fix typeof comparisons that compared against the value `undefined` instead
of the string `'undefined'`. Since typeof always returns a string, comparing
to the value `undefined` made these checks always truthy.
Affected functions:
- isDocument() and isWindow() in BrowserApi.ts now correctly return false
in service worker contexts where document/window are unavailable
- getCrypto() now correctly throws when crypto API is unavailable
- randomUuidV4() now correctly falls back when crypto.randomUUID is missing
Re-enables the valid-typeof ESLint rule to catch this class of bug.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent eca74c5 commit 28c8587
4 files changed
Lines changed: 6 additions & 6 deletions
File tree
- packages
- sdk/browser/src
- platform
- telemetry/browser-telemetry/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
0 commit comments