Commit 3ad7fa8
feat(otel-web): emit browser.language and browser.timezone resource attributes (#267)
* feat(otel-web): emit browser.language and browser.timezone resource attributes
Add approximate locale/region signals to the browser RUM resource:
- browser.language (OTel semconv) from navigator.language, e.g. "en-US"
- browser.timezone (IANA zone) from Intl, e.g. "America/New_York"
These are honest proxies for a user's region, NOT IP geolocation — the
browser cannot determine country without a permission prompt; true geo
(geo.country.name, …) is derived in the collector from the client IP.
The resolver is split out (browserContext.ts) with the context injectable
so the attribute mapping is unit-tested without real browser globals, and
omits absent values so it never overwrites a user attribute with an empty
string. Wired into resourceAttrs before the user-provided
resourceAttributes so callers can override.
* test(otel-web): cover navigator.language and empty-string language branches
Adds two unit tests flagged in review of the RUM browser-context change:
- getBrowserContextResourceAttributes({ language: '' }) -> {} confirms an
empty-string language is treated as absent.
- resolveBrowserContext() reads navigator.language: mock navigator with a
fixed 'fr-FR' locale so the truthful branch is exercised deterministically,
independent of the host's locale (Node 22 defines navigator.language).
* refactor(otel-web): namespace the custom timezone attr as hyperdx.browser.timezone
Per review: the OTel browser resource semconv has no timezone attribute, so
the custom one was squatting in the reserved `browser.` namespace. Move it to
the vendor namespace `hyperdx.browser.timezone` to avoid a future collision.
`browser.language` is unchanged (it is the spec attribute). Updates the emit
site, docstring, changeset, and the two existing test assertions.
* fix(deno): import dnt from JSR to avoid deno.land brotli fetch errors
The unpinned https://deno.land/x/dnt import pulls ts_morph from
deno.land/x, which intermittently fails with 'error: brotli error'
on Deno 1.x in CI. The JSR-published dnt resolves its dependencies
from jsr.io instead, eliminating the failing fetch.
---------
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Warren Lee <5959690+wrn14897@users.noreply.github.com>1 parent 6eb530d commit 3ad7fa8
6 files changed
Lines changed: 133 additions & 2 deletions
File tree
- .changeset
- packages
- deno
- otel-web
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
| 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 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
550 | 555 | | |
551 | 556 | | |
552 | 557 | | |
| |||
| 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 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
0 commit comments