mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
Closes DOCS-1464 ## Problem The new docs navigation, Option 1, needs an A/B test against today's navigation. The docs app has no flag that switches the navigation per visitor. `docs:*` keys in this repo are build-time toggles from `enabled-features`. They are the same for every visitor, so they can't run an A/B. The flag is `docs-ia-mvp-v1`, a PostHog multivariate flag, like `docs-search-v2`. ## Solution - **Variant hook:** `useIaNavVariant` reads `docs-ia-mvp-v1` and returns `control` or `option-1`. It copies `useSearchV2Variant`. It returns `control` until the flag resolves, records exposure once resolved, and respects consent. - **Query param override:** `?docs-ia-mvp-v1=option-1` or `?docs-ia-mvp-v1=control` forces a variant for dogfooding and evals. A forced variant records no exposure. - **Option 1 config:** `features/IaNav/option1.constants.ts` re-exports today's navigation constants. An export defined in that file replaces the re-exported one, so Option 1 in DOCS-1469 overrides only what changes. - **Consumers:** The top nav, the mobile menu, and the guide sidebar read from `useNavItems`, which picks the config for the variant. **Not changed:** Reference sidebars, breadcrumbs, and hub pages. Breadcrumbs and hub pages can read `useIaNavVariant` in DOCS-1470 and DOCS-1471. **PostHog:** The flag doesn't exist in PostHog yet. Until it does, every visitor gets `control`, and the query param still works. ## Manual testing 1. Open [Auth with Option 1 forced](https://docs-git-docs-ia-nav-flag-supabase.vercel.app/docs/guides/auth?docs-ia-mvp-v1=option-1). The top nav and sidebar match today's navigation, because the Option 1 config is a copy. Locally, you can make a change to see the variant. 2. Open [Auth with no param](https://docs-git-docs-ia-nav-flag-supabase.vercel.app/docs/guides/auth). The navigation is unchanged.
15 lines
469 B
TypeScript
15 lines
469 B
TypeScript
'use client'
|
|
|
|
import * as option1NavItems from './option1.constants'
|
|
import { useIaNavVariant } from './useIaNavVariant'
|
|
import * as currentNavItems from '@/components/Navigation/NavigationMenu/NavigationMenu.constants'
|
|
|
|
/**
|
|
* Returns the navigation config for the visitor's `docs-ia-mvp-v1` variant.
|
|
*/
|
|
export function useNavItems(): typeof currentNavItems {
|
|
const variant = useIaNavVariant()
|
|
|
|
return variant === 'option-1' ? option1NavItems : currentNavItems
|
|
}
|