Skip to content

✨ [DEBUG-6444] Let SDKs add RUM plugins after init with addPlugin() - #5220

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
mainfrom
watson/DEBUG-6444/rum-add-plugin
Nov 19, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
mainfrom
watson/DEBUG-6444/rum-add-plugin

Conversation

@watson

@watson watson commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

DEBUG-6444

Exception Replay ships as a RUM plugin in the Live Debugger SDK (#5196). Today a plugin can only be passed to init(), so the Live Debugger SDK has to load before DD_RUM.init(). With the async CDN snippet, customers then have to call DD_RUM.init() from inside DD_DEBUGGER.onReady(). That makes RUM wait for a second script, and if that script fails to load, RUM never starts.

As discussed with the RUM team, this adds an API to add a plugin after init(), so an SDK that loads separately can attach itself to RUM. It's a draft, to see what the API looks like before deciding on it.

Changes

  • New experimental API: DD_RUM.addPlugin(plugin). The plugin's onInit gets the same options as the plugins passed to init(), so a plugin written for the plugins option works unchanged.
  • Can't abort init: if the plugin's onInit returns false, only its own onRumStart is skipped. Its errors and rejected promises are reported with monitorError, so they can't stop init() or the other plugins.
  • onRumStart: called once RUM has started and the plugin's onInit has resolved. If onInit throws or rejects, onRumStart isn't called, as RUM doesn't start when the onInit of an init() plugin fails. Plugins waiting for RUM to start are kept in their own list, so they can't be dropped from the 500-entry buffer of API calls made before RUM starts.
  • Before init(): the plugin waits until init() has accepted the configuration, then starts. If a plugin aborts init(), or validation rejects its configuration, it waits for a later init(). RUM waits for its onInit before starting, as for the init() plugins, so its hooks are registered before any event is assembled.
  • Late plugins miss events: RUM doesn't wait for a plugin added after init(), so it misses the events assembled before its hooks are registered.
  • No duplicates: a plugin whose name was already added, or passed to init(), is ignored with a warning, so an SDK that adds itself while the customer also passes it to init() isn't started twice.

Question for the RUM team: a plugin added with addPlugin isn't in the configuration telemetry, which is sent at init(). Should we report it some other way? A usage telemetry feature would need a change in rum-events-format.

This change was written with an AI agent.

Test instructions

yarn test:unit --spec packages/browser-rum-core/src/boot/preStartRum.spec.ts --spec packages/browser-rum-core/src/boot/rumPublicApi.spec.ts

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

Related PRs

Reviewed with sol-loop: 1 round with gpt-6.2-sol on high. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 192.85 KiB 193.61 KiB +787 B +0.40% ✅
Rum 192.82 KiB 193.59 KiB +787 B +0.40% ✅
Rum Salesforce Profiler 8.01 KiB 8.01 KiB 0 B 0.00% ✅
Rum Profiler 8.01 KiB 8.01 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Rum Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Logs 60.25 KiB 60.25 KiB 0 B 0.00% ✅
Rum Slim 148.67 KiB 149.41 KiB +759 B +0.50% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 224.18 KiB 224.96 KiB +794 B +0.35% ✅
Rum Shopify Profiler 8.00 KiB 8.00 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 80.39%
• Overall Coverage: 77.93% (+0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8a4872e | Docs | View more details | Give us feedback!

@watson
watson marked this pull request as ready for review November 3, 2026 11:53
@watson
watson requested a review from a team as a code owner November 3, 2026 11:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T12:03:36.413366Z 8a4872e New commits
🔒 Security Review ✅ Completed 2026-11-19T12:05:59.736972Z 8a4872e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

A plugin added before RUM starts can permanently miss onRumStart if 500 subsequent API calls overflow the startup buffer while consent is pending. RUM later starts without giving that plugin its event/error reporting callbacks.

Open Bits AI session

🤖 Bits Code Review · Commit 58d7089

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58d70891e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

watson added a commit that referenced this pull request Nov 3, 2026
Brings in the addPlugin() RUM API, and main with #5217. The conflict in
preStartRum.ts is resolved by adding registerEventCollectedHook to the
options that both the init plugins and the added plugins get.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
watson added a commit that referenced this pull request Nov 3, 2026
Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78563663b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

watson added a commit that referenced this pull request Nov 3, 2026
Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
watson added a commit that referenced this pull request Nov 3, 2026
Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26f17795be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@watson
watson added this pull request to stack #5229 November 3, 2026 14:02
watson added a commit that referenced this pull request Nov 3, 2026
…5220)

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
watson and others added 5 commits November 19, 2026 10:47
An SDK that loads separately, such as the Live Debugger SDK, can now
attach a plugin to RUM itself, so customers don't have to load it before
calling init().

- The plugin's onInit gets the same options as the plugins passed to
  init(). It can't abort the initialization, so what it returns is
  ignored, and its errors are reported without stopping init().
- Its onRumStart is called once RUM starts, or right away if it has
  already started.
- A plugin added before init() waits for init().

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Keep the added plugins waiting for RUM to start in their own list,
  rather than in the buffer of API calls made before RUM starts, which
  drops its oldest entries once it holds 500.
- Call an added plugin's onRumStart once its asynchronous onInit has
  resolved, and skip it when onInit fails, as RUM doesn't start when the
  onInit of an init() plugin fails.
- Add an example and the @hidden tag to the addPlugin() documentation,
  as docs/REVIEW.md requires for experimental public APIs.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RUM waits for the onInit of the plugins passed to init() before it
starts, so their hooks are registered before any event is assembled.
Wait for the onInit of the plugins added before init() as well, while
still ignoring what they return, so they can't abort init().

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Plugins added with addPlugin() now start only once the init() plugins
  have let init() continue. If one of them aborts init(), the added
  plugins wait for a later init(), instead of starting for an init()
  that never starts RUM.
- When the onInit of an added plugin returns false, skip its onRumStart,
  as when it fails. It still can't abort init().

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plugins added with addPlugin() started once the init() plugins let
init() continue, even if init() then rejected the configuration. A later
valid init() didn't start them again, so they kept the options of the
rejected one.

They now start once init() has accepted the configuration, which also
covers an init() aborted by a plugin. RUM waits for their asynchronous
onInit before starting, as for the init() plugins.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@watson
watson force-pushed the watson/DEBUG-6444/rum-add-plugin branch from 58a5ccd to 8ee97d3 Compare November 19, 2026 10:49

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The added-plugin path waits for asynchronous initialization before invoking onRumStart and isolates plugin failures. Static review found no actionable defects; runtime behavior remains unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 8ee97d3

addPlugin() started a plugin even when one with the same name was
already added or passed to init(), so an SDK that adds itself while the
customer also passes it to init() had its hooks and onRumStart called
twice. Such a plugin is now ignored with a warning, whether it's added
before or after init().

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit d626317 into main Nov 19, 2026
33 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the watson/DEBUG-6444/rum-add-plugin branch November 19, 2026 12:42
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants