Skip to content

docs(multi-project): adopt @weaverse/experiments for A/B testing#21

Open
paul-phan wants to merge 2 commits into
mainfrom
feat/ab-experiments-docs
Open

docs(multi-project): adopt @weaverse/experiments for A/B testing#21
paul-phan wants to merge 2 commits into
mainfrom
feat/ab-experiments-docs

Conversation

@paul-phan

Copy link
Copy Markdown
Member

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.

@mintlify

mintlify Bot commented Jun 19, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
weaverse 🟢 Ready View Preview Jun 19, 2026, 5:47 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@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: 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".

Comment on lines +634 to +635
<WeaverseExperiments
value={assignments}

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 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 👍 / 👎.

@paul-phan paul-phan force-pushed the feat/ab-experiments-docs branch from fbf7a02 to 87587a9 Compare June 19, 2026 08:11
@paul-phan

Copy link
Copy Markdown
Member Author

@codex review

@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: 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".

Comment thread guides/multi-project-architecture.mdx Outdated
<WeaverseExperiments
value={assignments}
onExpose={(assignment) => {
if (!canTrack()) return; // respect Customer Privacy consent

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 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 👍 / 👎.

Comment thread guides/multi-project-architecture.mdx Outdated
});

return { weaverseData, variant };
return data({ weaverseData }, { headers });

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 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.
@paul-phan paul-phan force-pushed the feat/ab-experiments-docs branch from 87587a9 to 55aec07 Compare June 19, 2026 08:21
@paul-phan

Copy link
Copy Markdown
Member Author

@codex review

@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: 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 });

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 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 👍 / 👎.

@paul-phan

Copy link
Copy Markdown
Member Author

@codex review

@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: 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.

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 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[];

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 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 👍 / 👎.

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