Static methods

static Void flushTracking ()

Immediately send all tracked events and experiment participation to Apptimize's servers.

Apptimize will normally send all tracked events and experiment participation automatically on a regular schedule, however you can use this method to force events to be sent.

static String getApptimizeSDKPlatform ()

Get the name of the platform for this Apptimize SDK.

Returns:

The platform name (e.g. "JavaScript", "Python", "PHP", etc).

static String getApptimizeSDKVersion ()

Get the current Apptimize SDK version for this platform.

Returns:

The Apptimize SDK version.

static boolean getBool (String name, boolean defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a boolean Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static List<Boolean> getBoolArray (String name, List<Boolean> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a boolean array Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static Map<String,Boolean> getBoolDictionary (String name, Map<String,Boolean> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a boolean dictionary Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static double getDouble (String name, double defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a double-precision floating point number Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static List<Double> getDoubleArray (String name, List<Double> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a double-precision floating point number array Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static Map<String,Double> getDoubleDictionary (String name, Map<String,Double> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a double-precision floating point number dictionary Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static int getInt (String name, int defaultValue, String userID, optional Map<String,Object> customAttributes)

Get an integer Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static List<Integer> getIntArray (String name, List<Integer> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get an integer array Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static Map<String,Integer> getIntDictionary (String name, Map<String,Integer> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get an integer dictionary Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static String getString (String name, String defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a string Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static List<String> getStringArray (String name, List<String> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a string array Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static Map<String,String> getStringDictionary (String name, Map<String,String> defaultValue, String userID, optional Map<String,Object> customAttributes)

Get a string dictionary Dynamic Variable for the specified user.

Parameters:

name

Name of the Dynamic Variable to retrieve.

defaultValue

Value to return if the Dynamic Variable is not set by an experiment or user is allocated to original variant.

userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

Returns:

The value of the Dynamic Variable.

static List<VariantInfo> getVariantInfo (String userID, optional Map<String,Object> customAttributes)

Returns information about all Experiments and Feature Flags that the user is eligible to participate in. The list includes all of the variants that the user is allocated to (and does NOT include information about Experiments and Feature Flags the user is not eligible for).

Parameters:

userID

User ID to find list of variants for.

customAttributes

optional Custom Attributes dictionary to be used to find variants.

Returns:

A list of VariantInfo objects.

static boolean isFeatureFlagEnabled (String name, String userID, optional Map<String,Object> customAttributes)

Detect if a Feature Flag is enabled for the specified user.

Parameters:

name

The Feature Flag Variable name.

userID

User ID to use for this feature flag.

customAttributes

optional Custom Attributes dictionary to be used for this feature flag.

Returns:

true if the Feature Flag is enabled; false otherwise.

@:value({ customAttributes : null }) static Void runCodeBlock (String codeBlockVariableName, Object callback, String userID, optional Map<String,Object> customAttributes)

Run a Code Block A/B Experiment for the specified user.

Parameters:

codeBlockVariableName

The Code Block Variable name from the experiment configuration.

callback

A callback object with appropriately named methods:

class CallbackClass
{
    void baseline(){}
    void variation1(){}
    void variation2(){}
        ...
    void variationN(){}
}
userID

User ID to use when running this experiment.

customAttributes

optional Custom Attributes dictionary to be used for this experiment.

static Void setAppName (String name)

Set the app name for the current session. Used for targeting and results filtering.

Parameters:

name

A valid string name for the application.

static Void setAppVersion (String version)

Set the app version for the current session. Used for targeting and results filtering.

Parameters:

version

A Semantic Versioning 2.0 valid version. See Semantic Versioning.

static Void setOnApptimizeInitializedCallback ( OnApptimizeInitializedListener callback)

Set a callback listener to be called when Apptimize is fully initialized, metadata is downloaded, and tests are available.

Parameters:

callback

OnApptimizeInitializedListener to be called. Must override function onApptimizeInitialized()

static Void setOnMetadataUpdatedCallback ( OnMetadataUpdatedListener callback)

Set a callback listener to be called when new metadata has been downloaded.

Parameters:

callback

OnMetadataUpdatedListener to be called. Must override function onMetadataUpdated()

static Void setOnParticipatedInExperimentCallback ( OnParticipatedInExperimentListener callback)

Set a callback listener to be called when the user has participated in an experiment.

Parameters:

callback

OnParticipatedInExperimentListener to be called. Must override function onParticipatedInExperiment(VariantInfo variantInfo)

static Void setOnParticipationCallback ( OnParticipationListener callback)

Deprecated:

Method deprecated, please use setOnParticipatedInExperimentCallback instead.

Set a callback listener to be called when the user has participated in an experiment.

Parameters:

callback

OnParticipationListener object to be called. Must override onParticipation(experimentName : String, variantName : String)

static Void setup (String appKey, optional Map<String,Object> configAttributes)

Setup Apptimize to receive metadata, track participation and events.

Parameters:

appKey

The app key for your application. Can be found here.

configAttributes

optional A dictionary of Configuration Attributes for Apptimize.

Supported keys for configAttributes:

  • "log_level": The Apptimize SDK logging level.
    • Default value: "LOG_LEVEL_WARN"
    • Supported values:
      • "LOG_LEVEL_VERBOSE"
      • "LOG_LEVEL_DEBUG"
      • "LOG_LEVEL_INFO"
      • "LOG_LEVEL_WARN"
      • "LOG_LEVEL_ERROR"
      • "LOG_LEVEL_NONE"
  • "result_post_delay_ms": The time in milliseconds Apptimize should wait before posting results.
    • Default value: 60,000 (60s)
    • Results can be pushed before the timer runs if:
  • "react_native_storage": The storage object to use (React Native only).
    • Default value: React Native core AsyncStorage
    • Compatible with @react-native-community/async-storage v1

static Void shutdown ()

Shutdown Apptimize.

Saves all cached data into high latency memory including metadata and results. Stops sending and receiving all data. Should only be called from the main thread!

static Void track (String eventName, String userID, optional Map<String,Object> customAttributes)

Track an event for the user.

Parameters:

eventName

Name of the event.

userID

The User ID.

customAttributes

optional Custom Attributes dictionary for the event.

static Void trackValue (String eventName, double value, String userID, optional Map<String,Object> customAttributes)

Track an event for the user with a value.

Parameters:

eventName

Name of the event.

value

A double-precision floating point number value to track with the event.

userID

The User ID.

customAttributes

optional Custom Attributes dictionary for the event.

static Void updateApptimizeMetadataOnce ()

Force an update of the application metadata.

Can be useful for testing to get an update before Apptimize would automatically check for an update. If a new update is found, Apptimize will dispatch an event callback to the method set in setOnMetadataUpdatedCallback().