✨ Add @datadog/browser-native isolation layer for browser APIs#4245
Draft
✨ Add @datadog/browser-native isolation layer for browser APIs#4245
Conversation
- 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
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I have read the CLA Document and I hereby sign the CLA 1 out of 2 committers have signed the CLA. |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 08b9c07 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Create a clean isolation layer between SDK code and native browser APIs. The long-term goal is to scope BrowserStack unit tests exclusively to this package — all other packages can then run without real-browser testing since their browser API access goes through testable wrappers.
Changes
New package:
@datadog/browser-nativeZero-dependency package at the base of the dependency graph (below
@datadog/browser-core). Exposes native browser API callsites as standalone named functions, matching browser API names where applicable and using a getter/setter convention for property accesses.Exports:
fetch/sendBeacon— network APIs (with Zone.js bypass forfetch)addEventListener/removeEventListener— event APIs (with Zone.js bypass +EventTarget.prototypepattern)getCookie/setCookie—document.cookieaccessorgetReadyState—document.readyStategetVisibilityState—document.visibilityStatenow—performance.now()Migration:
packages/core/src/browser/Updated all direct native callsites in
core/src/browser/to import from@datadog/browser-nativeinstead:fetch.ts→ re-exportsfetchfrom@datadog/browser-nativecookie.ts→ usesgetCookie/setCookieaddEventListener.ts→ usesaddEventListener/removeEventListener(removes manuallistenerTargetcomputation andgetZoneJsOriginalValuecalls)runOnReadyState.ts→ usesgetReadyStatepageMayExitObservable.ts→ usesgetVisibilityStateTest instructions
All unit tests (3226), typecheck, and lint pass.
Checklist