11/**
22 * Which ad network gets first refusal on a sponsored slot.
33 *
4- * Imprezia reaches users two different ways, and the whole point of this
5- * module is that the two stay tellable apart:
4+ * Imprezia reaches users three ways, and this module keeps them tellable apart:
65 *
6+ * - Exclusively for the Imprezia team and our test account.
77 * - As the PRIMARY for a random {@link IMPREZIA_EXPERIMENT_PERCENT}% of users.
88 * This is the experiment arm — a clean random subset whose revenue can be
99 * compared against control.
@@ -52,7 +52,17 @@ export interface FirstPartyRoutingConfig {
5252 backfill : boolean
5353}
5454
55- export type AdExperimentArm = 'imprezia_first' | 'control'
55+ export type AdExperimentArm = 'imprezia_forced' | 'imprezia_first' | 'control'
56+
57+ export function isImpreziaAudienceEmail (
58+ email : string | null | undefined ,
59+ ) : boolean {
60+ if ( ! email ) return false
61+ const normalized = email . trim ( ) . toLowerCase ( )
62+ return (
63+ normalized === 'jahooma@gmail.com' || normalized . endsWith ( '@imprezia.ai' )
64+ )
65+ }
5666
5767/** FNV-1a 32-bit: tiny, dependency-free, stable across runtimes. */
5868export function fnv1a ( input : string ) : number {
@@ -65,17 +75,19 @@ export function fnv1a(input: string): number {
6575}
6676
6777/**
68- * Deterministic arm for a signed-in user. Stable across devices, sessions and
69- * products, because it is a pure function of the user id.
78+ * Deterministic arm for a signed-in user, stable across products and sessions.
7079 */
7180export function adExperimentArmForUser (
7281 userId : string | null | undefined ,
82+ userEmail ?: string | null ,
7383) : AdExperimentArm {
7484 // Every ad surface rejects unauthenticated callers, so a missing id means no
7585 // ad is served at all. Park those in control rather than letting them dilute
7686 // the arm with impressions that never happened.
7787 if ( ! userId ) return 'control'
7888
89+ if ( isImpreziaAudienceEmail ( userEmail ) ) return 'imprezia_forced'
90+
7991 const bucket = fnv1a ( `${ IMPREZIA_EXPERIMENT } :${ userId } ` ) % 100
8092 return bucket < IMPREZIA_EXPERIMENT_PERCENT ? 'imprezia_first' : 'control'
8193}
0 commit comments