|
22 | 22 | import com.optimizely.ab.config.Attribute;
|
23 | 23 | import com.optimizely.ab.config.EventType;
|
24 | 24 | import com.optimizely.ab.config.Experiment;
|
25 |
| -import com.optimizely.ab.config.LiveVariable; |
26 |
| -import com.optimizely.ab.config.LiveVariableUsageInstance; |
27 | 25 | import com.optimizely.ab.config.ProjectConfig;
|
28 | 26 | import com.optimizely.ab.config.Variation;
|
29 | 27 | import com.optimizely.ab.config.parser.ConfigParseException;
|
|
38 | 36 | import com.optimizely.ab.event.internal.EventBuilderV2;
|
39 | 37 | import com.optimizely.ab.event.internal.payload.Event.ClientEngine;
|
40 | 38 | import com.optimizely.ab.internal.EventTagUtils;
|
41 |
| -import com.optimizely.ab.internal.ReservedEventKey; |
42 | 39 | import com.optimizely.ab.notification.NotificationBroadcaster;
|
43 | 40 | import com.optimizely.ab.notification.NotificationListener;
|
44 | 41 | import org.slf4j.Logger;
|
@@ -283,139 +280,6 @@ public void track(@Nonnull String eventName,
|
283 | 280 | conversionEvent);
|
284 | 281 | }
|
285 | 282 |
|
286 |
| - //======== live variable getters ========// |
287 |
| - |
288 |
| - @Deprecated |
289 |
| - public @Nullable |
290 |
| - String getVariableString(@Nonnull String variableKey, |
291 |
| - @Nonnull String userId, |
292 |
| - boolean activateExperiment) throws UnknownLiveVariableException { |
293 |
| - return getVariableString(variableKey, userId, Collections.<String, String>emptyMap(), activateExperiment); |
294 |
| - } |
295 |
| - |
296 |
| - @Deprecated |
297 |
| - public @Nullable |
298 |
| - String getVariableString(@Nonnull String variableKey, |
299 |
| - @Nonnull String userId, |
300 |
| - @Nonnull Map<String, String> attributes, |
301 |
| - boolean activateExperiment) |
302 |
| - throws UnknownLiveVariableException { |
303 |
| - |
304 |
| - LiveVariable variable = getLiveVariableOrThrow(projectConfig, variableKey); |
305 |
| - if (variable == null) { |
306 |
| - return null; |
307 |
| - } |
308 |
| - |
309 |
| - List<Experiment> experimentsUsingLiveVariable = |
310 |
| - projectConfig.getLiveVariableIdToExperimentsMapping().get(variable.getId()); |
311 |
| - Map<String, Map<String, LiveVariableUsageInstance>> variationToLiveVariableUsageInstanceMapping = |
312 |
| - projectConfig.getVariationToLiveVariableUsageInstanceMapping(); |
313 |
| - |
314 |
| - if (experimentsUsingLiveVariable == null) { |
315 |
| - logger.warn("No experiment is using variable \"{}\".", variable.getKey()); |
316 |
| - return variable.getDefaultValue(); |
317 |
| - } |
318 |
| - |
319 |
| - for (Experiment experiment : experimentsUsingLiveVariable) { |
320 |
| - Variation variation; |
321 |
| - if (activateExperiment) { |
322 |
| - variation = activate(experiment, userId, attributes); |
323 |
| - } else { |
324 |
| - variation = getVariation(experiment, userId, attributes); |
325 |
| - } |
326 |
| - |
327 |
| - if (variation != null) { |
328 |
| - LiveVariableUsageInstance usageInstance = |
329 |
| - variationToLiveVariableUsageInstanceMapping.get(variation.getId()).get(variable.getId()); |
330 |
| - return usageInstance.getValue(); |
331 |
| - } |
332 |
| - } |
333 |
| - |
334 |
| - return variable.getDefaultValue(); |
335 |
| - } |
336 |
| - |
337 |
| - @Deprecated |
338 |
| - public @Nullable |
339 |
| - Boolean getVariableBoolean(@Nonnull String variableKey, |
340 |
| - @Nonnull String userId, |
341 |
| - boolean activateExperiment) throws UnknownLiveVariableException { |
342 |
| - return getVariableBoolean(variableKey, userId, Collections.<String, String>emptyMap(), activateExperiment); |
343 |
| - } |
344 |
| - |
345 |
| - @Deprecated |
346 |
| - public @Nullable |
347 |
| - Boolean getVariableBoolean(@Nonnull String variableKey, |
348 |
| - @Nonnull String userId, |
349 |
| - @Nonnull Map<String, String> attributes, |
350 |
| - boolean activateExperiment) |
351 |
| - throws UnknownLiveVariableException { |
352 |
| - |
353 |
| - String variableValueString = getVariableString(variableKey, userId, attributes, activateExperiment); |
354 |
| - if (variableValueString != null) { |
355 |
| - return Boolean.parseBoolean(variableValueString); |
356 |
| - } |
357 |
| - |
358 |
| - return null; |
359 |
| - } |
360 |
| - |
361 |
| - @Deprecated |
362 |
| - public @Nullable |
363 |
| - Integer getVariableInteger(@Nonnull String variableKey, |
364 |
| - @Nonnull String userId, |
365 |
| - boolean activateExperiment) throws UnknownLiveVariableException { |
366 |
| - return getVariableInteger(variableKey, userId, Collections.<String, String>emptyMap(), activateExperiment); |
367 |
| - } |
368 |
| - |
369 |
| - @Deprecated |
370 |
| - public @Nullable |
371 |
| - Integer getVariableInteger(@Nonnull String variableKey, |
372 |
| - @Nonnull String userId, |
373 |
| - @Nonnull Map<String, String> attributes, |
374 |
| - boolean activateExperiment) |
375 |
| - throws UnknownLiveVariableException { |
376 |
| - |
377 |
| - String variableValueString = getVariableString(variableKey, userId, attributes, activateExperiment); |
378 |
| - if (variableValueString != null) { |
379 |
| - try { |
380 |
| - return Integer.parseInt(variableValueString); |
381 |
| - } catch (NumberFormatException e) { |
382 |
| - logger.error("Variable value \"{}\" for live variable \"{}\" is not an integer.", variableValueString, |
383 |
| - variableKey); |
384 |
| - } |
385 |
| - } |
386 |
| - |
387 |
| - return null; |
388 |
| - } |
389 |
| - |
390 |
| - @Deprecated |
391 |
| - public @Nullable |
392 |
| - Double getVariableDouble(@Nonnull String variableKey, |
393 |
| - @Nonnull String userId, |
394 |
| - boolean activateExperiment) throws UnknownLiveVariableException { |
395 |
| - return getVariableDouble(variableKey, userId, Collections.<String, String>emptyMap(), activateExperiment); |
396 |
| - } |
397 |
| - |
398 |
| - @Deprecated |
399 |
| - public @Nullable |
400 |
| - Double getVariableDouble(@Nonnull String variableKey, |
401 |
| - @Nonnull String userId, |
402 |
| - @Nonnull Map<String, String> attributes, |
403 |
| - boolean activateExperiment) |
404 |
| - throws UnknownLiveVariableException { |
405 |
| - |
406 |
| - String variableValueString = getVariableString(variableKey, userId, attributes, activateExperiment); |
407 |
| - if (variableValueString != null) { |
408 |
| - try { |
409 |
| - return Double.parseDouble(variableValueString); |
410 |
| - } catch (NumberFormatException e) { |
411 |
| - logger.error("Variable value \"{}\" for live variable \"{}\" is not a double.", variableValueString, |
412 |
| - variableKey); |
413 |
| - } |
414 |
| - } |
415 |
| - |
416 |
| - return null; |
417 |
| - } |
418 |
| - |
419 | 283 | //======== FeatureFlag APIs ========//
|
420 | 284 |
|
421 | 285 | /**
|
@@ -739,37 +603,6 @@ private EventType getEventTypeOrThrow(ProjectConfig projectConfig, String eventN
|
739 | 603 | return eventType;
|
740 | 604 | }
|
741 | 605 |
|
742 |
| - /** |
743 |
| - * Helper method to retrieve the {@link LiveVariable} for the given variable key. |
744 |
| - * If {@link RaiseExceptionErrorHandler} is provided, either a live variable is returned, or an exception is |
745 |
| - * thrown. |
746 |
| - * If {@link NoOpErrorHandler} is used, either a live variable or {@code null} is returned. |
747 |
| - * |
748 |
| - * @param projectConfig the current project config |
749 |
| - * @param variableKey the key for the live variable being retrieved from the current project config |
750 |
| - * @return the live variable to retrieve for the given variable key |
751 |
| - * |
752 |
| - * @throws UnknownLiveVariableException if there are no event types in the current project config with the given |
753 |
| - * name |
754 |
| - */ |
755 |
| - @Deprecated |
756 |
| - private LiveVariable getLiveVariableOrThrow(ProjectConfig projectConfig, String variableKey) |
757 |
| - throws UnknownLiveVariableException { |
758 |
| - |
759 |
| - LiveVariable liveVariable = projectConfig |
760 |
| - .getLiveVariableKeyMapping() |
761 |
| - .get(variableKey); |
762 |
| - |
763 |
| - if (liveVariable == null) { |
764 |
| - String unknownLiveVariableKeyError = |
765 |
| - String.format("Live variable \"%s\" is not in the datafile.", variableKey); |
766 |
| - logger.error(unknownLiveVariableKeyError); |
767 |
| - errorHandler.handleError(new UnknownLiveVariableException(unknownLiveVariableKeyError)); |
768 |
| - } |
769 |
| - |
770 |
| - return liveVariable; |
771 |
| - } |
772 |
| - |
773 | 606 | /**
|
774 | 607 | * Helper method to verify that the given attributes map contains only keys that are present in the
|
775 | 608 | * {@link ProjectConfig}.
|
|
0 commit comments