Skip to content

Commit 8f572ff

Browse files
[FSSDK-10586] rollout experiment key returns wrong decision (#949)
1 parent 3eea753 commit 8f572ff

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

lib/core/decision_service/index.tests.js

+4
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,7 @@ describe('lib/core/decision_service', function() {
16751675
status: 'Not started',
16761676
key: '594031',
16771677
id: '594031',
1678+
isRollout: true,
16781679
variations: [
16791680
{
16801681
id: '594032',
@@ -1812,6 +1813,7 @@ describe('lib/core/decision_service', function() {
18121813
status: 'Not started',
18131814
key: '594037',
18141815
id: '594037',
1816+
isRollout: true,
18151817
variations: [
18161818
{
18171819
id: '594038',
@@ -1996,6 +1998,7 @@ describe('lib/core/decision_service', function() {
19961998
status: 'Not started',
19971999
key: '594037',
19982000
id: '594037',
2001+
isRollout: true,
19992002
variations: [
20002003
{
20012004
id: '594038',
@@ -2150,6 +2153,7 @@ describe('lib/core/decision_service', function() {
21502153
layerId: '599055',
21512154
forcedVariations: {},
21522155
audienceIds: [],
2156+
isRollout: true,
21532157
variations: [
21542158
{
21552159
key: '599057',

lib/core/project_config/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export const createProjectConfig = function(datafileObj?: JSON, datafileStr: str
167167
projectConfig.rolloutIdMap = keyBy(projectConfig.rollouts || [], 'id');
168168
objectValues(projectConfig.rolloutIdMap || {}).forEach(rollout => {
169169
(rollout.experiments || []).forEach(experiment => {
170+
experiment.isRollout = true
170171
projectConfig.experiments.push(experiment);
171172
// Creates { <variationKey>: <variation> } map inside of the experiment
172173
experiment.variationKeyMap = keyBy(experiment.variations, 'key');

lib/optimizely/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ export default class Optimizely implements Client {
479479
}
480480

481481
const experiment = configObj.experimentKeyMap[experimentKey];
482-
if (!experiment) {
482+
if (!experiment || experiment.isRollout) {
483483
this.logger.log(LOG_LEVEL.DEBUG, ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey);
484484
return null;
485485
}

lib/shared_types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export interface Experiment {
178178
audienceIds: string[];
179179
trafficAllocation: TrafficAllocation[];
180180
forcedVariations?: { [key: string]: string };
181+
isRollout?: boolean;
181182
}
182183

183184
export enum VariableType {

lib/tests/test_data.js

+5
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,7 @@ export var datafileWithFeaturesExpectedData = {
16471647
status: 'Not started',
16481648
key: '599056',
16491649
id: '599056',
1650+
isRollout: true,
16501651
variationKeyMap: {
16511652
599057: {
16521653
key: '599057',
@@ -1711,6 +1712,7 @@ export var datafileWithFeaturesExpectedData = {
17111712
],
17121713
key: '594031',
17131714
id: '594031',
1715+
isRollout: true,
17141716
variationKeyMap: {
17151717
594032: {
17161718
variables: [
@@ -1783,6 +1785,7 @@ export var datafileWithFeaturesExpectedData = {
17831785
],
17841786
key: '594037',
17851787
id: '594037',
1788+
isRollout: true,
17861789
variationKeyMap: {
17871790
594038: {
17881791
variables: [
@@ -1856,6 +1859,7 @@ export var datafileWithFeaturesExpectedData = {
18561859
],
18571860
key: '594060',
18581861
id: '594060',
1862+
isRollout: true,
18591863
variationKeyMap: {
18601864
594061: {
18611865
variables: [
@@ -1920,6 +1924,7 @@ export var datafileWithFeaturesExpectedData = {
19201924
],
19211925
key: '594066',
19221926
id: '594066',
1927+
isRollout: true,
19231928
variationKeyMap: {
19241929
594067: {
19251930
variables: [

0 commit comments

Comments
 (0)