Skip to content

Commit eb05e64

Browse files
authored
[AI Search] Put staff ship in treatment group (#55359)
1 parent fb8bfa3 commit eb05e64

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/events/components/experiments/experiment.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getUserEventsId } from '../events'
1111
import type { ParsedUrlQuery } from 'querystring'
1212

1313
let experimentsInitialized = false
14+
let userIsStaff = false
1415

1516
export 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

Comments
 (0)