Repository navigation
feat(shopify): Start the app pixel only on checkout pages - #5374
Open
BeltranBulbarellaDD wants to merge 2 commits into
Open
BeltranBulbarellaDD wants to merge 2 commits into
BeltranBulbarellaDD wants to merge 2 commits into
Conversation
Shopify also runs the app Web Pixel on storefront pages, where the storefront SDK already collects the data and writes the session cookie. Check the page URL from the Web Pixel init context when the pixel renders, and abort the init outside checkout, so the storefront keeps a single session cookie writer.
Run the storefront and checkout flow on a dev store with the Datadog Shopify app installed, serving the local SDK build in place of the staging CDN bundle and forwarding the real intake requests to the test intake. Check that the storefront and checkout share one session and one session cookie, and that the SDK is not loaded twice. withShopifyApp() now accepts a store URL and password, and the scheduled e2e-shopify-scheduled job runs the scenario with the other Shopify test.
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. |
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: b4d1b85 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
More details
The checkout guard stops storefront app pixels before session-cookie setup, preventing them from competing with the theme embed as session writers. Checkout initialization remains reachable.
🤖 Bits Code Review · Commit b4d1b85
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Shopify runs the app Web Pixel on every page, including the storefront pages where the theme app embed already runs the storefront SDK. On those pages the pixel started its own session manager and wrote the shared
_dd_s_v2cookie throughbrowser.cookie, next to the storefront SDK. Two writers can create two session IDs when no session exists yet.Stacked on #5370.
Refs: https://datadoghq.atlassian.net/wiki/spaces/RUMP/pages/7494435347/Deploying+the+Datadog+Shopify+app
Changes
browser-rum-shopify
shopifyAppPixelPluginreads the page URL from the Web Pixel init context (api.init.context.document.location.href) when the pixel renders, and aborts the init outside checkout pages (CHECKOUT_PATH_PATTERN). The URL is available synchronously, so nopage_viewedwait is needed.e2e
shopifyAppPixel.scenario.ts: runs on a dev store with the Datadog Shopify app installed (theme app embed + app Web Pixel). Flow: storefront → product → add to cart → checkout → click → back to the storefront. It checks the views and clicks on both surfaces, a single session, a single_dd_s_v2cookie, and no "loaded more than once" / "already initialized" warning.shopifySetupserves the localbrowser-rum-shopifybuild in place of the staging CDNdeploy-featurebundle the store loads, and forwards the real intake requests (routed on the browser context, so the pixel worker's requests are included) to the test intake.withShopifyApp()takes an optional store URL and password; the existing scenario keeps thecustom-pixel-e2estore and its SSM password.e2e-shopify-scheduledjob with the other Shopify test.Note: the dev store URL and its storefront password are hardcoded in the scenario for now.
Test instructions
yarn test:unit packages/browser-rum-shopify(new test: init aborts outside checkout pages).yarn test:e2e -g "dedicated web worker" --project=chromium --project=firefox --project=webkit(cd packages/browser-rum-shopify && yarn build:bundle) && yarn test:e2e -g "shopify app tracks" --project=chromiumChecklist