Skip to content
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
42 changes: 42 additions & 0 deletions core-api/src/main/java/com/optimizely/ab/Optimizely.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@ public void track(@Nonnull String eventName,
@Nonnull String variableKey,
@Nonnull String userId,
@Nonnull Map<String, String> attributes) {
String variableValue = getFeatureVariableValueForType(
featureKey,
variableKey,
userId,
attributes,
LiveVariable.VariableType.BOOLEAN
);
if (variableValue != null) {
return Boolean.parseBoolean(variableValue);
}
return null;
}

Expand Down Expand Up @@ -413,6 +423,22 @@ public void track(@Nonnull String eventName,
@Nonnull String variableKey,
@Nonnull String userId,
@Nonnull Map<String, String> attributes) {
String variableValue = getFeatureVariableValueForType(
featureKey,
variableKey,
userId,
attributes,
LiveVariable.VariableType.DOUBLE
);
if (variableValue != null) {
try {
return Double.parseDouble(variableValue);
}
catch (NumberFormatException exception) {
logger.error("NumberFormatException while trying to parse \"" + variableValue +
"\" as Double. " + exception);
}
}
return null;
}

Expand Down Expand Up @@ -443,6 +469,22 @@ public void track(@Nonnull String eventName,
@Nonnull String variableKey,
@Nonnull String userId,
@Nonnull Map<String, String> attributes) {
String variableValue = getFeatureVariableValueForType(
featureKey,
variableKey,
userId,
attributes,
LiveVariable.VariableType.INTEGER
);
if (variableValue != null) {
try {
return Integer.parseInt(variableValue);
}
catch (NumberFormatException exception) {
logger.error("NumberFormatException while trying to parse \"" + variableValue +
"\" as Integer. " + exception.toString());
}
}
return null;
}

Expand Down
Loading