Skip to content

✨ support asynchronous beforeSend callbacks - #4964

Open
BenoitZugmeyer wants to merge 1 commit into
mainfrom
benoit/async-before-send
Open

✨ support asynchronous beforeSend callbacks#4964
BenoitZugmeyer wants to merge 1 commit into
mainfrom
benoit/async-before-send

Conversation

@BenoitZugmeyer

Copy link
Copy Markdown
Member

Motivation

Allow RUM and Logs beforeSend callbacks to perform asynchronous enrichment or filtering before an event is sent—for example, reading a fetch response from the resource event domain context.

Changes

  • Support Promise<boolean> results from RUM and Logs beforeSend callbacks while preserving synchronous callback behavior.
  • Centralize callback execution, error handling, and RUM field-modification enforcement in Browser Core.
  • Add unit coverage and an E2E scenario that enriches a RUM resource event from its fetch response.

Test instructions

  1. In the sandbox, initialize RUM with an async beforeSend callback.
  2. For fetch resource events, read context.response.text() and add the result to the event context.
  3. Make a fetch request and verify that the resulting RUM resource event contains the added context value.

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

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 19, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 74.36%
Overall Coverage: 77.24% (+0.04%)

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

@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/async-before-send branch from de2cd10 to 650935c Compare August 19, 2026 14:35
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 19, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 180.54 KiB 180.81 KiB +274 B +0.15%
Rum Profiler 8.43 KiB 8.43 KiB 0 B 0.00%
Rum Recorder 21.12 KiB 21.12 KiB 0 B 0.00%
Logs 57.04 KiB 57.17 KiB +141 B +0.24%
Rum Salesforce N/A 138.75 KiB N/A N/A N/A
Rum Slim 138.49 KiB 138.75 KiB +267 B +0.19%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%
Rum Shopify N/A 200.38 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.43 KiB N/A N/A N/A
Rum-shopify Recorder N/A 3.72 KiB N/A N/A N/A

@BenoitZugmeyer
BenoitZugmeyer marked this pull request as ready for review August 20, 2026 08:59
@BenoitZugmeyer
BenoitZugmeyer requested a review from a team as a code owner August 20, 2026 08:59

@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: 650935c9a5

ℹ️ 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".

Comment thread packages/browser-rum-core/src/domain/assembly.ts
Comment thread packages/browser-rum-core/src/domain/assembly.ts
Comment thread test/e2e/scenario/rum/init.scenario.ts
@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/async-before-send branch from 650935c to 7243a4b Compare August 20, 2026 09:19

@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: 7243a4b61a

ℹ️ 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".

Comment thread packages/browser-logs/src/domain/assembly.ts
@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/async-before-send branch from 7243a4b to eb3d440 Compare August 20, 2026 15:46

@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: eb3d440f0b

ℹ️ 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".

Comment thread packages/browser-rum-core/src/transport/startRumBatch.ts Outdated
@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/async-before-send branch from eb3d440 to 24b825a Compare August 20, 2026 16:20

@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: 24b825af7c

ℹ️ 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".

Comment thread packages/browser-rum-core/src/transport/startRumBatch.ts
@sbarrio
sbarrio requested a review from rgaignault August 21, 2026 07:06
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