Skip to content

✨ [RUM-19007] Attribute automatic click actions with element stacks - #5098

Open
amortemousque wants to merge 7 commits into
mainfrom
amortemousque/mfe-click-action-attribution
Open

amortemousque wants to merge 7 commits into
mainfrom
amortemousque/mfe-click-action-attribution

Conversation

@amortemousque

@amortemousque amortemousque commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Automatic click actions do not have an application handling stack identifying their microfrontend. Implement the recommended API from the click action attribution RFC.

Changes

  • Record static attach-element-stack API usage telemetry. Schema dependency: rum-events-format #456.

  • Add DD_RUM.attachElementStack(element) to RUM and RUM Slim. Capture the caller's stack at the public API entry point and immediately register it in an instance-owned WeakMap, including before init(). Registrations survive startup without buffering or retaining detached elements strongly.

  • Snapshot the closest registered target/ancestor stack at pointerdown, crossing shadow roots. Re-registration affects future actions; ongoing actions and rage-click groups retain their initial stack.

  • Resolve service/version through existing source-code metadata and expose context.elementStack in beforeSend for manual attribution. Keep stacks out of serialized events and preserve shell fallback.

  • Add unit and real build-plugin integration coverage, including registration before initialization, RUM Slim, shell fallback, and manual overrides. Implementation and tests were developed with AI assistance and independently reviewed.

Test instructions

  • Full unit suite: 5,301 passed; focused feature suites: 226 passed.
  • Chromium/Firefox microfrontend regression: 111 passed, 3 existing skips.
  • All 18 new scenarios passed across Chromium, Firefox, and WebKit, covering RUM and RUM Slim.
  • Typecheck, all TypeScript compatibility modes, changed-file ESLint/Prettier, and git diff --check passed.
  • Independent whole-branch review: no actionable findings.

The new scenarios can be run after building the SDK and test apps:

yarn build
yarn build:apps --app microfrontend --app vanilla
yarn test:e2e microfrontend.scenario.ts -g 'with element stacks' --project chromium --project firefox --project webkit

WebKit's existing unload-triggered intake delivery failure was reproduced with the pre-existing custom-action scenario. Diagnostics confirmed correct automatic attribution and normal periodic delivery. The new WebKit cases await regular intake delivery before navigating; production transport behavior is unchanged.

Local E2E validation used built SDK bundles and a temporary configuration that omits unrelated framework servers and allows validated fixture paths under the hidden .codex worktree. That configuration is not part of this PR.

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 (API JSDoc and approved design)

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Tests

✅ All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 76.47%
• Overall Coverage: 77.32% (-0.00%)

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

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce N/A 188.48 KiB N/A N/A N/A
Rum 188.07 KiB 188.46 KiB +395 B +0.21% ✅
Rum-salesforce Profiler N/A 8.35 KiB N/A N/A N/A
Rum Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum-salesforce Recorder N/A 32.04 KiB N/A N/A N/A
Rum Recorder 32.04 KiB 32.04 KiB 0 B 0.00% ✅
Logs 59.31 KiB 59.31 KiB 0 B 0.00% ✅
Rum Slim 145.69 KiB 146.06 KiB +376 B +0.25% ✅
Worker 22.96 KiB 22.96 KiB 0 B 0.00% ✅
Rum Shopify N/A 218.90 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.35 KiB N/A N/A N/A
Rum-shopify Recorder N/A 4.85 KiB N/A N/A N/A

@amortemousque amortemousque changed the title ✨ Attribute automatic click actions to microfrontend elements ✨ Attribute automatic click actions with element stacks Oct 15, 2026
@amortemousque
amortemousque force-pushed the amortemousque/mfe-click-action-attribution branch from 567a2bf to 65086b8 Compare October 16, 2026 08:41
@amortemousque
amortemousque marked this pull request as ready for review October 16, 2026 09:54
@amortemousque
amortemousque requested a review from a team as a code owner October 16, 2026 09:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T12:07:38.569642Z c13ff7b New commits
🔒 Security Review ✅ Completed 2026-10-16T12:08:21.425886Z c13ff7b 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.

@amortemousque amortemousque changed the title ✨ Attribute automatic click actions with element stacks ✨ [RUM-19007] Attribute automatic click actions with element stacks Oct 16, 2026

@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: 65086b87d4

ℹ️ 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 on lines +816 to +818
attachElementStack: (element) => {
const stack = createHandlingStack('element')
callMonitored(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Record attachElementStack API usage

issue: Whenever a customer calls this new public API, the registration is performed without invoking addTelemetryUsage, so usage telemetry cannot report adoption of attachElementStack while the surrounding public methods report their calls. Add a dedicated static usage feature for this API so these calls are observable.

AGENTS.md reference: AGENTS.md:L120-L123

Useful? React with 👍 / 👎.

@datadog-prod-us1-6 datadog-prod-us1-6 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

Element stacks are stored per SDK instance and snapshotted at pointerdown, preserving attribution for ongoing actions while keeping stacks out of serialized events. The completed static review found no reportable defects.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 65086b8

This branch has not been deployed

No deployments
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