fix(marketing): bootstrap hero experiment flag for instant, sticky assignment
Why
The landing-hero-positioning experiment evaluates its flag client-side after the /flags network round trip, so first-time visitors see the control hero flash before the variant swaps in, and events fired before the response lands don't carry the $feature property.
What
- New
hero-flag-bootstrap.ts: computes the variant synchronously atposthog.initusing PostHog's cross-SDK deterministic assignment hash (sha1("<flag>.<distinct_id>variant")first 15 hex digits /2^60-1, mapped over the 50/50 variant rollouts), seeded from the existingsupersetcookie identity — or a freshly generated UUID that posthog-js adopts viabootstrap.distinctIDand persists, so refreshes always hash the same identity and can never flip buckets. instrumentation-client.tspasses the bootstrap intoposthog.init, souseFeatureFlagVariantKeyresolves at hydration instead of after the network round trip.HeroSectionimports the flag key from the new module (single source of truth).
Verification
- Assignment equivalence proven against production: 25+ random distinct_ids computed locally all matched the live
us.i.posthog.com/flagsresponse variant exactly. bun run lintclean;turbo typecheck --filter=@superset/marketingclean.
Caveat
The variant order + 50/50 split are mirrored from the flag config (noted in a code comment). If the experiment's rollout changes, drift is safe — behavior falls back to today's swap-on-response — but the bootstrap constant should be updated alongside.
https://claude.ai/code/session_013HwZR8BoCF3QBis8b3x7pm
Summary by cubic
Bootstraps the landing-hero-positioning flag at posthog-js init so the hero renders the right variant during hydration. Removes the control-to-variant flash and ensures the first pageview includes $feature.
-
Bug Fixes
- Computes the variant synchronously using PostHog’s deterministic hash (
sha1("<flag>.<distinct_id>variant")), seeded from thesupersetcookie or a new UUID adopted viabootstrap.distinctIDfor sticky assignment. - Passes the bootstrap to
posthog.init, and centralizes the flag key inhero-flag-bootstrapwithHeroSectionimporting it as the single source of truth.
- Computes the variant synchronously using PostHog’s deterministic hash (
-
Migration
- If the experiment’s rollout or variant order changes, update
VARIANTSinhero-flag-bootstrap.tsto keep parity; otherwise behavior safely falls back to server-evaluated swapping.
- If the experiment’s rollout or variant order changes, update
Summary by CodeRabbit
-
New Features
- Added consistent assignment for the landing page hero experience, supporting controlled variants such as Control and Capability Mac.
-
Bug Fixes
- Improved hero experiment initialization so visitors receive a stable variant during page loading.