@@ -11,6 +11,7 @@ import { getUserEventsId } from '../events'
11
11
import type { ParsedUrlQuery } from 'querystring'
12
12
13
13
let experimentsInitialized = false
14
+ let userIsStaff = false
14
15
15
16
export function shouldShowExperiment (
16
17
experimentKey : ExperimentNames | { key : ExperimentNames } ,
@@ -45,6 +46,7 @@ export function shouldShowExperiment(
45
46
// If the user has staffonly cookie, and staff override is true, show the experiment
46
47
if ( experiment . alwaysShowForStaff ) {
47
48
if ( isStaff ) {
49
+ userIsStaff = true
48
50
console . log ( `Staff cookie is set, showing '${ experiment . key } ' experiment` )
49
51
return true
50
52
}
@@ -117,10 +119,11 @@ export function getExperimentVariationForContext(locale: string, version: string
117
119
if ( experiment . includeVariationInContext ) {
118
120
// If the user is using the URL param to view the experiment, include the variation in the context
119
121
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 )
124
127
) {
125
128
return TREATMENT_VARIATION
126
129
}
0 commit comments