Repository navigation
feat(shopify): Expand the app pixel session on checkout clicks - #5370
BeltranBulbarellaDD wants to merge 4 commits into
Conversation
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.
Bundles Sizes Evolution
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: dd7c26f | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
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.
🤖 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.
There was a problem hiding this comment.
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.
🤖 Bits Code Review · Commit dd7c26f
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
startSessionManagertakes an optionaltrackSessionActivity(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
trackSessionActivityoption inRumPublicApiOptions, forwarded bypreStartRumto the session manager.browser-rum-shopify
trackShopifySessionActivityexpands the session on Shopifyclickedevents on checkout pages.api.browserandapi.analyticsto the session module.createSessionStoreandtrackSessionActivityin a worker. The setup from the public docs is not affected: thetheme.liquidscript 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.browserAPI is missing: in a worker, RUM only starts withshopifyAppPixelPlugin, which sets the APIs before itsonInitresolves. The memory fallback is kept for the two cases that can happen:onInit, so it can enabletrackSessionAcrossSubdomainsagain, andbuildCookieOptionsthen returnsundefinedin the worker (getCurrentSiteneedsdocument.cookie).e2e
shopifyAppPixelPlugin()through a newcreateWorker().withShopifyAppPixel()helper, which fakes the Web Pixel sandbox (settings.rumConfig, abrowser.cookiethat persists nothing, a no-opanalytics.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:
isCheckoutPagegate on init), so it runs a session manager next to the storefront SDK there.clickedexpands the session; other Shopify checkout events could too.Test instructions
yarn test:unit packages/browser-rum-shopify packages/browser-core/src/domain/session packages/browser-rum-core/src/boot packages/browser-logs/src/bootyarn test:e2e -g "dedicated web worker" --project=chromium --project=firefox --project=webkitChecklist