Skip to content

feat(shopify): Expand the app pixel session on checkout clicks - #5370

Open
BeltranBulbarellaDD wants to merge 4 commits into
beltran.bulbarella/shopify-session-storefrom
beltran.bulbarella/shopify-session-activity
Open

BeltranBulbarellaDD wants to merge 4 commits into
beltran.bulbarella/shopify-session-storefrom
beltran.bulbarella/shopify-session-activity

Conversation

@BeltranBulbarellaDD

@BeltranBulbarellaDD BeltranBulbarellaDD commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The app pixel runs the RUM SDK in a Web Worker, where the session manager sees no DOM activity (click, scroll, keydown…). The session shared with the storefront through browser.cookie (#5328) was therefore never expanded, and a long checkout would let it expire.

Stacked on #5328.

Refs: https://datadoghq.atlassian.net/wiki/spaces/RUMP/pages/7438730478/Sharing+the+storefront+session+in+the+Shopify+app+pixel

Changes

browser-core

  • startSessionManager takes an optional trackSessionActivity(expandOrRenew) last parameter. It runs alongside the DOM activity tracking, which still only runs outside workers, so callers that don't pass it (Logs, RUM on pages) are unchanged.

browser-rum-core

  • New trackSessionActivity option in RumPublicApiOptions, forwarded by preStartRum to the session manager.

browser-rum-shopify

  • trackShopifySessionActivity expands the session on Shopify clicked events on checkout pages.
  • The plugin now hands both api.browser and api.analytics to the session module.
  • The bundle entry only passes createSessionStore and trackSessionActivity in a worker. The setup from the public docs is not affected: the theme.liquid script runs on the page and the Custom Pixel in a sandboxed iframe, neither is a worker, so both keep the default cookie store and DOM activity tracking.
  • Removed the in-memory fallback when the Web Pixel browser API is missing: in a worker, RUM only starts with shopifyAppPixelPlugin, which sets the APIs before its onInit resolves. The memory fallback is kept for the two cases that can happen:
    • Shopify can't persist cookies (for example, the browser blocks them).
    • The cookie options can't be built. Remote configuration is applied after the plugin onInit, so it can enable trackSessionAcrossSubdomains again, and buildCookieOptions then returns undefined in the worker (getCurrentSite needs document.cookie).

e2e

  • The "dedicated web worker with worker rum" test now runs the real shopifyAppPixelPlugin() through a new createWorker().withShopifyAppPixel() helper, which fakes the Web Pixel sandbox (settings.rumConfig, a browser.cookie that persists nothing, a no-op analytics.subscribe). Before, it used a fake plugin name that skipped the Shopify session code. The test still only checks that the app pixel SDK starts in a worker without an unguarded browser API.

Not in this PR:

  • The app pixel still initializes on storefront pages (no isCheckoutPage gate on init), so it runs a session manager next to the storefront SDK there.
  • Only clicked expands the session; other Shopify checkout events could too.
  • No e2e test of the whole storefront --> checkout flow.

Test instructions

  • Unit tests: yarn test:unit packages/browser-rum-shopify packages/browser-core/src/domain/session packages/browser-rum-core/src/boot packages/browser-logs/src/boot
  • New test: checkout clicks expand the session.
  • E2E: yarn test:e2e -g "dedicated web worker" --project=chromium --project=firefox --project=webkit

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

The app pixel worker has no DOM activity, so its session was never
expanded. Add a `trackSessionActivity` option to the session manager,
used alongside the DOM activity tracking (pages only), and have the
Shopify bundle pass a tracker that expands the session on checkout
`clicked` events in the worker.

Also remove the in-memory fallback when the Web Pixel browser API is
missing: the app pixel plugin always sets it before RUM starts.
@BeltranBulbarellaDD
BeltranBulbarellaDD requested a review from a team as a code owner December 2, 2026 18:06
@cit-pr-commenter-54b7da

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

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 194.81 KiB 194.87 KiB +60 B +0.03% ✅
Rum 194.79 KiB 194.85 KiB +60 B +0.03% ✅
Rum Salesforce Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Rum Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Logs 60.54 KiB 60.58 KiB +35 B +0.06% ✅
Rum Slim 150.18 KiB 150.24 KiB +60 B +0.04% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 228.69 KiB 228.82 KiB +130 B +0.06% ✅
Rum Shopify Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅
Early Collection 309 B 309 B 0 B 0.00% ✅

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 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-12-02T21:26:32.108193Z dd7c26f New commits
🔒 Security Review ✅ Completed 2026-12-02T21:27:53.420424Z dd7c26f 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-prod-us1-4

datadog-prod-us1-4 Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 84.62%
• Overall Coverage: 78.09% (+0.01%)

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

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

Remote configuration can override the Shopify plugin’s cross-subdomain setting and make the app pixel fail to initialize. Restoring the removed cookie-options guard preserves the in-memory fallback.

Open Bits AI session

🤖 Bits Code Review · Commit 4bf52b9

…uilt

Remote configuration is applied after the app pixel plugin and can enable
trackSessionAcrossSubdomains again. In the worker, buildCookieOptions then
returns undefined, so restore the guard and fall back to a memory session.
Add a withShopifyAppPixel() worker helper that fakes the Web Pixel
sandbox and starts RUM with shopifyAppPixelPlugin(), instead of a fake
plugin name that skipped the Shopify session code.

@datadog-prod-us1-4 datadog-prod-us1-4 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 PR expands Shopify app-pixel sessions on checkout clicks while preserving standard page and iframe session handling. The latest commit restores the memory fallback, fixing the reported worker startup failure, and updates the worker smoke-test setup to use the Shopify plugin; no reportable findings remain open.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit dd7c26f

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