Skip to content

[FSSDK-10586] rollout experiment key returns wrong decision #949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/core/decision_service/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,7 @@ describe('lib/core/decision_service', function() {
status: 'Not started',
key: '594031',
id: '594031',
isRollout: true,
variations: [
{
id: '594032',
Expand Down Expand Up @@ -1812,6 +1813,7 @@ describe('lib/core/decision_service', function() {
status: 'Not started',
key: '594037',
id: '594037',
isRollout: true,
variations: [
{
id: '594038',
Expand Down Expand Up @@ -1996,6 +1998,7 @@ describe('lib/core/decision_service', function() {
status: 'Not started',
key: '594037',
id: '594037',
isRollout: true,
variations: [
{
id: '594038',
Expand Down Expand Up @@ -2150,6 +2153,7 @@ describe('lib/core/decision_service', function() {
layerId: '599055',
forcedVariations: {},
audienceIds: [],
isRollout: true,
variations: [
{
key: '599057',
Expand Down
1 change: 1 addition & 0 deletions lib/core/project_config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export const createProjectConfig = function(datafileObj?: JSON, datafileStr: str
projectConfig.rolloutIdMap = keyBy(projectConfig.rollouts || [], 'id');
objectValues(projectConfig.rolloutIdMap || {}).forEach(rollout => {
(rollout.experiments || []).forEach(experiment => {
experiment.isRollout = true
projectConfig.experiments.push(experiment);
// Creates { <variationKey>: <variation> } map inside of the experiment
experiment.variationKeyMap = keyBy(experiment.variations, 'key');
Expand Down
2 changes: 1 addition & 1 deletion lib/optimizely/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export default class Optimizely implements Client {
}

const experiment = configObj.experimentKeyMap[experimentKey];
if (!experiment) {
if (!experiment || experiment.isRollout) {
this.logger.log(LOG_LEVEL.DEBUG, ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey);
return null;
}
Expand Down
1 change: 1 addition & 0 deletions lib/shared_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export interface Experiment {
audienceIds: string[];
trafficAllocation: TrafficAllocation[];
forcedVariations?: { [key: string]: string };
isRollout?: boolean;
}

export enum VariableType {
Expand Down
5 changes: 5 additions & 0 deletions lib/tests/test_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,7 @@ export var datafileWithFeaturesExpectedData = {
status: 'Not started',
key: '599056',
id: '599056',
isRollout: true,
variationKeyMap: {
599057: {
key: '599057',
Expand Down Expand Up @@ -1711,6 +1712,7 @@ export var datafileWithFeaturesExpectedData = {
],
key: '594031',
id: '594031',
isRollout: true,
variationKeyMap: {
594032: {
variables: [
Expand Down Expand Up @@ -1783,6 +1785,7 @@ export var datafileWithFeaturesExpectedData = {
],
key: '594037',
id: '594037',
isRollout: true,
variationKeyMap: {
594038: {
variables: [
Expand Down Expand Up @@ -1856,6 +1859,7 @@ export var datafileWithFeaturesExpectedData = {
],
key: '594060',
id: '594060',
isRollout: true,
variationKeyMap: {
594061: {
variables: [
Expand Down Expand Up @@ -1920,6 +1924,7 @@ export var datafileWithFeaturesExpectedData = {
],
key: '594066',
id: '594066',
isRollout: true,
variationKeyMap: {
594067: {
variables: [
Expand Down
Loading