docs(multi-project): adopt @weaverse/experiments for A/B testing#21
docs(multi-project): adopt @weaverse/experiments for A/B testing#21paul-phan wants to merge 2 commits into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbf7a02a01
ℹ️ 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".
| <WeaverseExperiments | ||
| value={assignments} |
There was a problem hiding this comment.
Wrap the app with the experiments provider
With this placement, <WeaverseExperiments> is mounted only as a self-closing exposure helper, so it does not provide its context to <Outlet />. In apps that follow the later instruction to call useExperiment("green-theme-test") from route/components, the hook will read the default empty context and return undefined; wrap the routed content (or the whole Analytics.Provider children) in WeaverseExperiments while keeping the exposure callback attached.
Useful? React with 👍 / 👎.
fbf7a02 to
87587a9
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87587a97a6
ℹ️ 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".
| <WeaverseExperiments | ||
| value={assignments} | ||
| onExpose={(assignment) => { | ||
| if (!canTrack()) return; // respect Customer Privacy consent |
There was a problem hiding this comment.
Avoid consuming exposures before consent is available
When canTrack() is false on the first client render, such as before Shopify Customer Privacy resolves or before an opt-in banner is accepted, this callback returns after WeaverseExperiments has already treated the assignment as exposed. A later consent change will not republish the impression, silently excluding those visitors from exposure analytics; make the callback absent until tracking is allowed, or only de-dupe after a publish succeeds.
Useful? React with 👍 / 👎.
| }); | ||
|
|
||
| return { weaverseData, variant }; | ||
| return data({ weaverseData }, { headers }); |
There was a problem hiding this comment.
Return route-level assignments for analytics
If users copy this loader for a route-level PDP experiment, the selected project is applied but the assignment from getExperiments is never returned or merged into the analytics flow described above. That means pdp-layout-test cannot be added to customData, onExpose cannot fire for it, and useExperiment will remain undefined for the route; return the assignment or otherwise pass it into the client analytics context.
Useful? React with 👍 / 👎.
Replace the manual cookie recipe with the deterministic, framework-agnostic @weaverse/experiments helper (sticky without a per-experiment cookie). Add Hydrogen analytics integration: Analytics.Provider customData segmentation + useAnalytics publish for exposure, gated on canTrack(). Pairs with Weaverse/weaverse#467.
87587a9 to
55aec07
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55aec076c8
ℹ️ 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".
|
|
||
| return { weaverse, experimentVariant: variant }; | ||
| // `headers` already includes the seed `Set-Cookie` when one is needed. | ||
| return data({ assignments }, { headers }); |
There was a problem hiding this comment.
Return the analytics inputs consumed by App
This loader only serializes assignments, but the root App example immediately below reads cart, shop, and consent from useLoaderData<typeof loader>() and passes them into Analytics.Provider. Copying the guide as written leaves those required analytics inputs undefined (or produces type errors), so the exposure/analytics setup cannot initialize; include the usual Hydrogen cart, shop, and consent values in this response or remove them from the example.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a6bbf9669
ℹ️ 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".
|
|
||
| export default function App() { | ||
| let { experimentVariant, experimentId } = useLoaderData<typeof loader>(); | ||
| `getExperiments` is Studio-aware: when it sees `weaverseProjectId` on the request it **defers to Studio** instead of applying the hashed assignment. It returns the pinned project as `projectId`, forces the matching variant so `useExperiment(...)` and analytics `customData` reflect what you are viewing, and skips minting a visitor cookie — so the loader code above needs no special casing. |
There was a problem hiding this comment.
Honor Studio project pins before using assignments
This paragraph says getExperiments handles weaverseProjectId, but the companion getExperiments implementation only resolves a seed from config/cookie/new UUID and does not inspect the request URL. In Studio preview requests that include ?weaverseProjectId=..., the examples above will still pass the hashed experiment projectId into WeaverseClient/loadPage, so editors can be pinned to the visitor bucket instead of the project they opened. Document explicit query-param handling, or implement that behavior before telling users no special casing is needed.
Useful? React with 👍 / 👎.
| assignments, | ||
| children, | ||
| }: { | ||
| assignments: Assignment[]; |
There was a problem hiding this comment.
Import Assignment in the root snippet
In this copyable app/root.tsx example the only type import is ReactNode, but the Experiments props use Assignment. A TypeScript Hydrogen app that follows the snippet will fail with Cannot find name 'Assignment'; add a type import from @weaverse/experiments (or remove the explicit annotation) in the snippet.
Useful? React with 👍 / 👎.
Replaces the manual cookie-based A/B recipe in the multi-project guide with the new @weaverse/experiments package — deterministic, framework-agnostic, sticky without a per-experiment cookie. Adds Hydrogen analytics integration (Analytics.Provider customData segmentation + useAnalytics exposure, gated on canTrack). Pairs with Weaverse/weaverse#467.