Skip to content

Commit 9a56b10

Browse files
committed
Fixing event
1 parent c96d371 commit 9a56b10

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

core-api/src/main/java/com/optimizely/ab/Optimizely.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ else if (userId == null) {
455455
variableKey,
456456
userId,
457457
attributes,
458-
LiveVariable.VariableType.BOOLEAN
458+
LiveVariable.VariableType.BOOLEAN,
459+
defaultValue
459460
);
460461
if (variableValue != null) {
461462
return Boolean.parseBoolean(variableValue);
@@ -503,7 +504,8 @@ else if (userId == null) {
503504
variableKey,
504505
userId,
505506
attributes,
506-
LiveVariable.VariableType.DOUBLE
507+
LiveVariable.VariableType.DOUBLE,
508+
defaultValue
507509
);
508510
if (variableValue != null) {
509511
try {
@@ -556,7 +558,8 @@ else if (userId == null) {
556558
variableKey,
557559
userId,
558560
attributes,
559-
LiveVariable.VariableType.INTEGER
561+
LiveVariable.VariableType.INTEGER,
562+
defaultValue
560563
);
561564
if (variableValue != null) {
562565
try {
@@ -609,7 +612,8 @@ else if (userId == null) {
609612
variableKey,
610613
userId,
611614
attributes,
612-
LiveVariable.VariableType.STRING);
615+
LiveVariable.VariableType.STRING,
616+
defaultValue);
613617

614618
if (variableValue != null) {
615619
return variableValue;
@@ -623,7 +627,8 @@ String getFeatureVariableValueForType(@Nonnull String featureKey,
623627
@Nonnull String variableKey,
624628
@Nonnull String userId,
625629
@Nonnull Map<String, String> attributes,
626-
@Nonnull LiveVariable.VariableType variableType) {
630+
@Nonnull LiveVariable.VariableType variableType,
631+
@Nonnull Object defaultValue) {
627632
if (featureKey == null) {
628633
logger.warn("The featureKey parameter must be nonnull.");
629634
return null;
@@ -640,15 +645,15 @@ else if (userId == null) {
640645
if (featureFlag == null) {
641646
logger.info("No feature flag was found for key \"{}\".", featureKey);
642647
logger.info("Sending event for \"{}\" to trigger feature and variable creation.", featureKey);
643-
sendEventForFeatureAndVariableCreation(featureKey, variableType.getVariableType(), variableKey, userId, attributes);
648+
sendEventForFeatureAndVariableCreation(featureKey, variableType.getVariableType(), variableKey + ":" + defaultValue.toString(), userId, attributes);
644649
return null;
645650
}
646651

647652
LiveVariable variable = featureFlag.getVariableKeyToLiveVariableMap().get(variableKey);
648653
if (variable == null) {
649654
logger.info("No feature variable was found for key \"{}\" in feature flag \"{}\".",
650655
variableKey, featureKey);
651-
sendEventForFeatureAndVariableCreation(featureKey, variableType.getVariableType(), variableKey, userId, attributes);
656+
sendEventForFeatureAndVariableCreation(featureKey, variableType.getVariableType(), variableKey + ":" + defaultValue.toString(), userId, attributes);
652657
return null;
653658
} else if (!variable.getType().equals(variableType)) {
654659
logger.info("The feature variable \"" + variableKey +

0 commit comments

Comments
 (0)