Skip to content

Commit d4b734d

Browse files
Allow enrollment in experiments and rollouts via devtools
When we were checking for a previous enrollment, we weren't checking for the right type of enrollment (rollout vs experiment) so if there was an active experiment you couldn't enroll in a rollout without triggering unenrollment of the experiment (and vice versa). As a result we also got the name of the enrollment we were trying to enroll incorrect in the dialog. Fixes #101
1 parent cc2307e commit d4b734d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/apis/nimbus.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,19 @@ var nimbus = class extends ExtensionAPI {
3737
nimbus: {
3838
async enrollInExperiment(jsonData, forceEnroll) {
3939
try {
40+
const { slug, isRollout = false } = jsonData;
41+
4042
const slugExistsInStore = lazy.ExperimentManager.store
4143
.getAll()
42-
.some((experiment) => experiment.slug === jsonData.slug);
44+
.some((experiment) => experiment.slug === slug);
4345
const activeEnrollment =
4446
lazy.ExperimentManager.store
4547
.getAll()
4648
.find(
4749
(experiment) =>
48-
experiment.slug === jsonData.slug && experiment.active,
50+
experiment.slug === slug &&
51+
experiment.isRollout === isRollout &&
52+
experiment.active,
4953
)?.slug ?? null;
5054
if (slugExistsInStore || activeEnrollment) {
5155
if (!forceEnroll) {
@@ -124,6 +128,7 @@ var nimbus = class extends ExtensionAPI {
124128
.find(
125129
(experiment) =>
126130
experiment.featureIds.includes(featureId) &&
131+
experiment.isRollout === isRollout &&
127132
experiment.active,
128133
)?.slug ?? null;
129134

0 commit comments

Comments
 (0)