Skip to content

Commit c4d3f0d

Browse files
[FSSDK-10766] decide option bug fix
1 parent 1a9a8af commit c4d3f0d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/optimizely/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,7 @@ export default class Optimizely implements Client {
14991499
return newErrorDecision(key, user, [DECISION_MESSAGES.SDK_NOT_READY]);
15001500
}
15011501

1502-
const filteredOptions = options.filter(option => option !== OptimizelyDecideOption.ENABLED_FLAGS_ONLY);
1503-
1504-
return this.decideForKeys(user, [key], filteredOptions)[key];
1502+
return this.decideForKeys(user, [key], options, true)[key];
15051503
}
15061504

15071505
/**
@@ -1553,15 +1551,15 @@ export default class Optimizely implements Client {
15531551
const experimentKey = decisionObj.experiment?.key ?? null;
15541552
const variationKey = decisionObj.variation?.key ?? null;
15551553
const flagEnabled: boolean = decision.getFeatureEnabledFromVariation(decisionObj);
1554+
const variablesMap: { [key: string]: unknown } = {};
1555+
let decisionEventDispatched = false;
15561556

15571557
if (flagEnabled) {
15581558
this.logger.log(LOG_LEVEL.INFO, LOG_MESSAGES.FEATURE_ENABLED_FOR_USER, MODULE_NAME, key, userId);
15591559
} else {
15601560
this.logger.log(LOG_LEVEL.INFO, LOG_MESSAGES.FEATURE_NOT_ENABLED_FOR_USER, MODULE_NAME, key, userId);
15611561
}
15621562

1563-
const variablesMap: { [key: string]: unknown } = {};
1564-
let decisionEventDispatched = false;
15651563

15661564
if (!options[OptimizelyDecideOption.EXCLUDE_VARIABLES]) {
15671565
feature.variables.forEach(variable => {
@@ -1631,7 +1629,8 @@ export default class Optimizely implements Client {
16311629
decideForKeys(
16321630
user: OptimizelyUserContext,
16331631
keys: string[],
1634-
options: OptimizelyDecideOption[] = []
1632+
options: OptimizelyDecideOption[] = [],
1633+
ignoreEnabledFlagOption?:boolean
16351634
): Record<string, OptimizelyDecision> {
16361635
const decisionMap: Record<string, OptimizelyDecision> = {};
16371636
const flagDecisions: Record<string, DecisionObj> = {};
@@ -1651,6 +1650,10 @@ export default class Optimizely implements Client {
16511650

16521651
const allDecideOptions = this.getAllDecideOptions(options);
16531652

1653+
if (ignoreEnabledFlagOption) {
1654+
delete allDecideOptions[OptimizelyDecideOption.ENABLED_FLAGS_ONLY];
1655+
}
1656+
16541657
for(const key of keys) {
16551658
const feature = configObj.featureKeyMap[key];
16561659
if (!feature) {

0 commit comments

Comments
 (0)