Skip to content

♻️ Migrate browser-core monitoring/display to @datadog/js-core#4758

Open
thomas-lebeau wants to merge 6 commits into
worktree-migrate-build-to-tsdownfrom
thomas.lebeau/add-browser-core-agents-md
Open

♻️ Migrate browser-core monitoring/display to @datadog/js-core#4758
thomas-lebeau wants to merge 6 commits into
worktree-migrate-build-to-tsdownfrom
thomas.lebeau/add-browser-core-agents-md

Conversation

@thomas-lebeau

Copy link
Copy Markdown
Collaborator

Motivation

Continue extracting runtime-agnostic primitives out of browser-core into the stable @datadog/js-core package. This moves the monitoring and display utilities so they can be shared across Datadog JavaScript SDKs.

Changes

  • Add monitor and util sub-paths to @datadog/js-core, exposing monitor, display, and debug helpers.
  • Migrate browser-core monitoring/display tooling to consume the @datadog/js-core implementations.
  • Add unit tests for the new @datadog/js-core monitor and display utilities.
  • Add AGENTS.md documentation for the browser-core package and update @datadog/js-core docs.

Test instructions

  • yarn test:unit --spec packages/js-core/src/monitor.spec.ts
  • yarn test:unit --spec packages/js-core/src/util/display.spec.ts
  • yarn typecheck

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

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 10, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 172.44 KiB 172.81 KiB +386 B +0.22%
Rum Profiler 7.88 KiB 7.88 KiB 0 B 0.00%
Rum Recorder 21.23 KiB 21.23 KiB 0 B 0.00%
Logs 54.86 KiB 54.70 KiB -163 B -0.29%
Rum Slim 130.17 KiB 130.43 KiB +268 B +0.20%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 10, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 91.67%
Overall Coverage: 76.88% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2123255 | Docs | Datadog PR Page | Give us feedback!

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/add-browser-core-agents-md branch 2 times, most recently from ccba31a to af7a15d Compare June 12, 2026 08:26
@thomas-lebeau

Copy link
Copy Markdown
Collaborator Author

/trigger-ci

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 12, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-12 08:46:43 UTC ℹ️ Start processing command /trigger-ci


2026-06-12 08:46:58 UTC ℹ️ Branch synced on Gitlab

Branch thomas.lebeau/add-browser-core-agents-md was out-of-sync on Gitlab - it has been resynced


2026-06-12 08:47:01 UTC ℹ️ Gitlab pipeline started

Started pipeline #118369723

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/add-browser-core-agents-md branch 2 times, most recently from 7f7d2dc to 18ce6e4 Compare June 12, 2026 13:13
Documents that browser-core has no semver stability guarantee and breaking
changes are allowed, so review warnings about removed exports or signature
changes in this package should be disregarded.
- monitor: createMonitor(display, onMonitorErrorCollected) factory exposing
  a documented Monitor interface (monitor, callMonitored, monitored, monitorError)
- util: createDisplay + setDebugMode, with a debug-gated ifDebugEnabled facet
  on Display; util is a folder with a barrel index
- wire up exports, legacy fallbacks, and tsconfig paths for both sub-paths
- monitor.spec.ts: adapts the browser-core monitor spec to the createMonitor
  factory API, injecting a fake Display and a spy error callback
- util/display.spec.ts: covers each console method (always-on + ifDebugEnabled
  gating), asserting the prefixed console call; resets debug mode with afterEach
- make display.ifDebugEnabled delegate to the display's public methods so the
  gating is observable in tests (and respects method overrides)
- export originalConsoleMethods as a test seam (kept out of the util barrel)
- tidy monitor JSDoc to satisfy jsdoc lint rules
- Move debug-mode state out of `display.ts` into a dedicated `debug.ts`
  (`setDebugMode`/`getDebugMode`) and drop the `ifDebugEnabled` facet from
  `Display`
- Export `ConsoleApiName`, `globalConsole`, `originalConsoleMethods` from the
  `@datadog/js-core/util` barrel
- Re-implement browser-core `monitor`/`display` on top of `@datadog/js-core`
  (`createMonitor`, `createDisplay`) and update consumers across browser-core,
  browser-logs, browser-rum-core and browser-debugger to import from js-core
- Whitelist `@datadog/js-core/util` and `/monitor` as side-effect-free
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/add-browser-core-agents-md branch from 18ce6e4 to 2123255 Compare June 12, 2026 13:56
@thomas-lebeau thomas-lebeau marked this pull request as ready for review June 12, 2026 16:08
@thomas-lebeau thomas-lebeau requested review from a team as code owners June 12, 2026 16:08
@thomas-lebeau thomas-lebeau changed the base branch from main to worktree-migrate-build-to-tsdown June 12, 2026 16:16
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.

1 participant