Skip to content

✨ Add Browser RUM Salesforce package and support#4726

Open
BeltranBulbarellaDD wants to merge 4 commits into
mainfrom
beltran.bulbarella/browser-rum-salesforce-package
Open

✨ Add Browser RUM Salesforce package and support#4726
BeltranBulbarellaDD wants to merge 4 commits into
mainfrom
beltran.bulbarella/browser-rum-salesforce-package

Conversation

@BeltranBulbarellaDD
Copy link
Copy Markdown
Contributor

@BeltranBulbarellaDD BeltranBulbarellaDD commented Jun 4, 2026

Motivation

Make the SDK not crash when instrumenting in Salesforce lightning environments.

Changes

You can review commit by commit.

First commit

Adds a new browser-rum-salesforce private package. It uses rum-slim and contains set up instructions for customers.

Second commit.

Adds the support on the SDK so it not crashes on LWC environment.

The main idea of this is to use isEventSupported to patch the 3 listeners LWC does not support and make the SDK crash. By using isEventSupported we can try to assign the listener and it fails safely.
We do this check on 3 things: change event of CookieStore, unhandledrejection event and securitypolicyviolation event listener

The other 2 changes is to safely access globalObject.location instead of just location per Salesforce docs.

Test instructions

Don't forget to make in the Dev Extension: Event collection strategy to Requests

Lightning application URL
Username: 1780401668150_test-avrjsf381uzm@example.com
Password: Ufv7@chnbkeqmdssfjfn

Experience Cloud URL

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

@BeltranBulbarellaDD BeltranBulbarellaDD changed the title Beltran.bulbarella/browser rum salesforce package ✨ Add Browser RUM Salesforce package and support Jun 4, 2026
@datadog-official
Copy link
Copy Markdown

datadog-official Bot commented Jun 4, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 64.71%
Overall Coverage: 76.68% (-0.01%)

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

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

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

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 171.78 KiB 172.06 KiB +286 B +0.16%
Rum Profiler 7.88 KiB 7.88 KiB +2 B +0.02%
Rum Recorder 21.21 KiB 21.22 KiB +7 B +0.03%
Logs 54.30 KiB 54.50 KiB +211 B +0.38%
Rum Slim 129.68 KiB 129.89 KiB +211 B +0.16%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@BeltranBulbarellaDD BeltranBulbarellaDD force-pushed the beltran.bulbarella/browser-rum-salesforce-package branch from f4cc6bb to 5ce95a1 Compare June 4, 2026 09:43
@BeltranBulbarellaDD BeltranBulbarellaDD force-pushed the beltran.bulbarella/browser-rum-salesforce-package branch 2 times, most recently from 3260f6c to 288b9de Compare June 4, 2026 10:52
@BeltranBulbarellaDD BeltranBulbarellaDD force-pushed the beltran.bulbarella/browser-rum-salesforce-package branch from 288b9de to 8c6cd15 Compare June 4, 2026 11:48
@BeltranBulbarellaDD BeltranBulbarellaDD marked this pull request as ready for review June 4, 2026 12:11
@BeltranBulbarellaDD BeltranBulbarellaDD requested a review from a team as a code owner June 4, 2026 12:11
Copy link
Copy Markdown

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

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: 8c6cd15706

ℹ️ 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-salesforce/src/entries/main.ts Outdated
Comment thread packages/browser-rum-salesforce/package.json Outdated
Comment thread packages/browser-rum-core/src/domain/contexts/urlContexts.ts
Comment thread packages/browser-core/src/browser/addEventListener.ts Outdated
Comment thread packages/browser-rum-salesforce/src/entries/main.ts Outdated
Comment thread packages/browser-rum-slim/src/entries/main.ts Outdated
Comment on lines +49 to +52
// Salesforce LWS does not support the unhandledrejection event. https://developer.salesforce.com/tools/lws-distortion-viewer
if (!isEventSupported(globalObject.window, DOM_EVENT.UNHANDLED_REJECTION, noop)) {
return { stop: noop }
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thought: I understand that we want to test for cookieStore "change" event explicitly, because else the session manager won't work correctly.

However, for other events, I wonder if it wouldn't be simpler to wrap the addEventListener in a try/catch and ignore event silently.

Copy link
Copy Markdown
Contributor Author

@BeltranBulbarellaDD BeltranBulbarellaDD Jun 4, 2026

Choose a reason for hiding this comment

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

I think this way just makes it clearer we are trying to attach the event in Salesforce. If we were to wrap the addEventListener we might catch/fail on other things without realizing it?


export function instrumentUnhandledRejection(callback: UnhandledErrorCallback) {
// Salesforce LWS does not support the unhandledrejection event. https://developer.salesforce.com/tools/lws-distortion-viewer
if (!isEventSupported(globalObject.window, DOM_EVENT.UNHANDLED_REJECTION, noop)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: globalObject.window is a bit redundant

Suggested change
if (!isEventSupported(globalObject.window, DOM_EVENT.UNHANDLED_REJECTION, noop)) {
if (!isEventSupported(window, DOM_EVENT.UNHANDLED_REJECTION, noop)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually it breaks compatibility. Do you think there is another way?
Screenshot 2026-06-04 at 18 20 23

Copy link
Copy Markdown

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

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: 48f1282cc2

ℹ️ 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-core/src/browser/cookieAccess.ts Outdated
Comment thread packages/browser-rum-slim/src/salesforce/README.md Outdated
Comment thread packages/browser-rum-slim/src/salesforce/README.md
Comment thread packages/browser-rum-slim/src/salesforce/README.md
@BeltranBulbarellaDD BeltranBulbarellaDD force-pushed the beltran.bulbarella/browser-rum-salesforce-package branch from d6d99ef to a076a34 Compare June 4, 2026 16:14
@BeltranBulbarellaDD BeltranBulbarellaDD force-pushed the beltran.bulbarella/browser-rum-salesforce-package branch from a076a34 to 0fe7170 Compare June 4, 2026 16:20
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