@@ -11,6 +11,7 @@ import { getUserEventsId } from '../events'
1111import type { ParsedUrlQuery } from 'querystring'
1212
1313let experimentsInitialized = false
14+ let userIsStaff = false
1415
1516export function shouldShowExperiment (
1617 experimentKey : ExperimentNames | { key : ExperimentNames } ,
@@ -45,6 +46,7 @@ export function shouldShowExperiment(
4546 // If the user has staffonly cookie, and staff override is true, show the experiment
4647 if ( experiment . alwaysShowForStaff ) {
4748 if ( isStaff ) {
49+ userIsStaff = true
4850 console . log ( `Staff cookie is set, showing '${ experiment . key } ' experiment` )
4951 return true
5052 }
@@ -117,10 +119,11 @@ export function getExperimentVariationForContext(locale: string, version: string
117119 if ( experiment . includeVariationInContext ) {
118120 // If the user is using the URL param to view the experiment, include the variation in the context
119121 if (
120- experiment . turnOnWithURLParam &&
121- window . location ?. search
122- ?. toLowerCase ( )
123- . includes ( `feature=${ experiment . turnOnWithURLParam . toLowerCase ( ) } ` )
122+ ( experiment . turnOnWithURLParam &&
123+ window . location ?. search
124+ ?. toLowerCase ( )
125+ . includes ( `feature=${ experiment . turnOnWithURLParam . toLowerCase ( ) } ` ) ) ||
126+ ( experiment . alwaysShowForStaff && userIsStaff )
124127 ) {
125128 return TREATMENT_VARIATION
126129 }
0 commit comments