Skip to content

Commit 38f4fb7

Browse files
set variableType = variable.type to avoid changes downstream
1 parent f5de452 commit 38f4fb7

File tree

1 file changed

+6
-4
lines changed
  • packages/optimizely-sdk/lib/optimizely

1 file changed

+6
-4
lines changed

packages/optimizely-sdk/lib/optimizely/index.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,10 @@ Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableK
719719
if (!variable) {
720720
return null;
721721
}
722-
723-
if (variableType && variable.type !== variableType) {
722+
723+
if (!variableType) {
724+
variableType = variable.type;
725+
} else if (variable.type !== variableType) {
724726
this.logger.log(
725727
LOG_LEVEL.WARNING,
726728
sprintf(LOG_MESSAGES.VARIABLE_REQUESTED_WITH_WRONG_TYPE, MODULE_NAME, variableType, variable.type)
@@ -759,7 +761,7 @@ Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableK
759761
}
760762
}
761763

762-
var typeCastedValue = projectConfig.getTypeCastValue(variableValue, variable.type, this.logger);
764+
var typeCastedValue = projectConfig.getTypeCastValue(variableValue, variableType, this.logger);
763765
this.notificationCenter.sendNotifications(
764766
NOTIFICATION_TYPES.DECISION,
765767
{
@@ -772,7 +774,7 @@ Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableK
772774
source: decision.decisionSource,
773775
variableKey: variableKey,
774776
variableValue: typeCastedValue,
775-
variableType: variable.type,
777+
variableType: variableType,
776778
sourceInfo: sourceInfo,
777779
}
778780
}

0 commit comments

Comments
 (0)