Skip to content

Commit 69c87bd

Browse files
[FSSDK-10586] rollout experiment key returns wrong decision (#949)
1 parent 6105336 commit 69c87bd

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

lib/core/decision_service/index.tests.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,7 @@ describe('lib/core/decision_service', function() {
16791679
status: 'Not started',
16801680
key: '594031',
16811681
id: '594031',
1682+
isRollout: true,
16821683
variations: [
16831684
{
16841685
id: '594032',
@@ -1816,6 +1817,7 @@ describe('lib/core/decision_service', function() {
18161817
status: 'Not started',
18171818
key: '594037',
18181819
id: '594037',
1820+
isRollout: true,
18191821
variations: [
18201822
{
18211823
id: '594038',
@@ -2000,6 +2002,7 @@ describe('lib/core/decision_service', function() {
20002002
status: 'Not started',
20012003
key: '594037',
20022004
id: '594037',
2005+
isRollout: true,
20032006
variations: [
20042007
{
20052008
id: '594038',
@@ -2154,6 +2157,7 @@ describe('lib/core/decision_service', function() {
21542157
layerId: '599055',
21552158
forcedVariations: {},
21562159
audienceIds: [],
2160+
isRollout: true,
21572161
variations: [
21582162
{
21592163
key: '599057',

lib/optimizely/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ export default class Optimizely implements Client {
489489
}
490490

491491
const experiment = configObj.experimentKeyMap[experimentKey];
492-
if (!experiment) {
492+
if (!experiment || experiment.isRollout) {
493493
this.logger.log(LOG_LEVEL.DEBUG, ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey);
494494
return null;
495495
}

lib/project_config/project_config.ts

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

lib/shared_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export interface Experiment {
171171
audienceIds: string[];
172172
trafficAllocation: TrafficAllocation[];
173173
forcedVariations?: { [key: string]: string };
174+
isRollout?: boolean;
174175
}
175176

176177
export enum VariableType {

lib/tests/test_data.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,7 @@ export var datafileWithFeaturesExpectedData = {
16491649
status: 'Not started',
16501650
key: '599056',
16511651
id: '599056',
1652+
isRollout: true,
16521653
variationKeyMap: {
16531654
599057: {
16541655
key: '599057',
@@ -1713,6 +1714,7 @@ export var datafileWithFeaturesExpectedData = {
17131714
],
17141715
key: '594031',
17151716
id: '594031',
1717+
isRollout: true,
17161718
variationKeyMap: {
17171719
594032: {
17181720
variables: [
@@ -1785,6 +1787,7 @@ export var datafileWithFeaturesExpectedData = {
17851787
],
17861788
key: '594037',
17871789
id: '594037',
1790+
isRollout: true,
17881791
variationKeyMap: {
17891792
594038: {
17901793
variables: [
@@ -1858,6 +1861,7 @@ export var datafileWithFeaturesExpectedData = {
18581861
],
18591862
key: '594060',
18601863
id: '594060',
1864+
isRollout: true,
18611865
variationKeyMap: {
18621866
594061: {
18631867
variables: [
@@ -1922,6 +1926,7 @@ export var datafileWithFeaturesExpectedData = {
19221926
],
19231927
key: '594066',
19241928
id: '594066',
1929+
isRollout: true,
19251930
variationKeyMap: {
19261931
594067: {
19271932
variables: [

0 commit comments

Comments
 (0)