From 28ae4ef2d6248388aa86e58457f6a9a0fabb1823 Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Tue, 23 Sep 2025 10:24:13 -0700 Subject: [PATCH] fix: canonical test assignment for polyinstantiated tests --- app/[locale]/page.tsx | 21 ++++++++++++++++----- src/components/AB/TestWrapper.tsx | 4 +++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 57aac0b0867..e48ae1b97cf 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -87,6 +87,7 @@ import IndexPageJsonLD from "./page-jsonld" import { getActivity, getUpcomingEvents } from "./utils" import { routing } from "@/i18n/routing" +import { getABTestAssignment } from "@/lib/ab-testing/server" import { fetchCommunityEvents } from "@/lib/api/calendarEvents" import { fetchEthPrice } from "@/lib/api/fetchEthPrice" import { fetchGrowThePie } from "@/lib/api/fetchGrowThePie" @@ -162,6 +163,9 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => { const tCommon = await getTranslations({ locale, namespace: "common" }) const { direction: dir, isRtl } = getDirection(locale) + const DEVCONNECT_TEST_KEY = "2025-09-devconnect-banner" + const devconnectAssignment = await getABTestAssignment(DEVCONNECT_TEST_KEY) + const [ ethPrice, totalEthStaked, @@ -432,8 +436,13 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => { , <>]} + testKey={DEVCONNECT_TEST_KEY} + variants={[ + , + , + ]} + serverVariantIndex={devconnectAssignment?.variantIndex} + enableAllLocales />
@@ -478,11 +487,13 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
, - , + , + , ]} + serverVariantIndex={devconnectAssignment?.variantIndex} + enableAllLocales />
diff --git a/src/components/AB/TestWrapper.tsx b/src/components/AB/TestWrapper.tsx index 34b1f6f4e61..f9d424eb4d5 100644 --- a/src/components/AB/TestWrapper.tsx +++ b/src/components/AB/TestWrapper.tsx @@ -17,6 +17,7 @@ type ABTestWrapperProps = { variants: ABTestVariants fallback?: ReactNode enableAllLocales?: boolean + serverVariantIndex?: number // Only required if testKey instantiates more than one ABTestWrapper } const ABTestWrapper = async ({ @@ -24,6 +25,7 @@ const ABTestWrapper = async ({ variants, fallback, enableAllLocales, + serverVariantIndex, }: ABTestWrapperProps) => { const locale = await getLocale() if (locale !== DEFAULT_LOCALE && !enableAllLocales) @@ -36,7 +38,7 @@ const ABTestWrapper = async ({ if (!assignment) throw new Error("No AB test assignment found") // Use assignment's variant index directly - const variantIndex = assignment.variantIndex + const variantIndex = serverVariantIndex ?? assignment.variantIndex // Extract labels from React element keys or fall back to defaults const availableVariants = variants.map((variant, i) => {