Skip to content

✨ Add browser tab ID to all RUM and Logs events#4184

Draft
mormubis wants to merge 4 commits intomainfrom
adlrb/context-tab-id
Draft

✨ Add browser tab ID to all RUM and Logs events#4184
mormubis wants to merge 4 commits intomainfrom
adlrb/context-tab-id

Conversation

@mormubis
Copy link
Contributor

Motivation

The Browser SDK shares session state across tabs via cookies/localStorage, but has no way to identify which specific tab produced a given event. Adding _dd.browser_tab_id enables distinguishing events from different tabs within the same session.

Changes

  • New tabContext module (packages/core/src/domain/contexts/tabContext.ts): Generates a UUID v4 per browser tab, persisted in sessionStorage so it survives page reloads. Falls back to in-memory UUID when sessionStorage is unavailable (Web Workers, sandboxed iframes).
  • Schema update: Added browser_tab_id to _dd properties in _common-schema.json and logsEvent.types.ts.
  • Wired into RUM and Logs: Both SDKs register the tab context via the Assemble hook, so every event includes _dd.browser_tab_id.
  • Unit tests: 8 tests covering hook output, ID consistency, sessionStorage persistence/reuse, and in-memory fallback.

Behavior

Scenario Behavior
New tab Generates UUID, persists to sessionStorage
Page reload Reuses existing UUID from sessionStorage
Tab duplication Both tabs share the same ID (accepted tradeoff)
sessionStorage unavailable In-memory UUID per page load

Test instructions

```bash
yarn test:unit --spec packages/core/src/domain/contexts/tabContext.spec.ts
yarn test:unit # full suite passes
yarn typecheck
yarn lint
```

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

claude and others added 4 commits February 13, 2026 16:24
- STACK.md - Technologies and dependencies
- ARCHITECTURE.md - System design and patterns
- STRUCTURE.md - Directory layout
- CONVENTIONS.md - Code style and patterns
- TESTING.md - Test structure
- INTEGRATIONS.md - External services
- CONCERNS.md - Technical debt and issues
Introduce tabContext that generates a UUID v4 per browser tab, persisted
in sessionStorage to survive reloads, with an in-memory fallback when
storage is unavailable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add _dd.browser_tab_id UUID field to the RUM common schema and the
Logs event types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Register tabContext in both RUM and Logs event assembly so every
event includes _dd.browser_tab_id.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (mormubis)[https://github.com/mormubis]
@claude
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants