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", etc).

static String getApptimizeSDKVersion ()

Get the current Apptimize SDK version for this platform.

Returns:

The Apptimize SDK version.

@:overloadstatic Bool getBool (String name, Bool defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Bool getBool (String name, Bool defaultValue, String userID)

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.

@:overloadstatic Dynamic getBoolArray (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getBoolArray (String name, Dynamic defaultValue, String userID)

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 Feature Variable, 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 or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Dynamic getBoolDictionary (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getBoolDictionary (String name, Dynamic defaultValue, String userID)

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 Feature Variable, or user is allocated to original variant.

userID

User ID to use when running this experiment or Feature Variable.

customAttributes

optional Custom Attributes dictionary to be used for this experiment or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Float getDouble (String name, Float defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Float getDouble (String name, Float defaultValue, String userID)

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 Feature Variable, or user is allocated to original variant.

userID

User ID to use when running this experiment or Feature Variable.

customAttributes

optional Custom Attributes dictionary to be used for this experiment or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Dynamic getDoubleArray (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getDoubleArray (String name, Dynamic defaultValue, String userID)

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 Feature Variable, or user is allocated to original variant.

userID

User ID to use when running this experiment or Feature Variable.

customAttributes

optional Custom Attributes dictionary to be used for this experiment or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Dynamic getDoubleDictionary (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getDoubleDictionary (String name, Dynamic defaultValue, String userID)

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 Feature Variable or user is allocated to original variant.

userID

User ID to use when running this experiment or Feature Variable.

customAttributes

optional Custom Attributes dictionary to be used for this experiment or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Int getInt (String name, Int defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Int getInt (String name, Int defaultValue, String userID)

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 Feature Variable, 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 or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Dynamic getIntArray (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getIntArray (String name, Dynamic defaultValue, String userID)

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.

@:overloadstatic Dynamic getIntDictionary (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getIntDictionary (String name, Dynamic defaultValue, String userID)

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 Feature Variable, or user is allocated to original variant.

userID

User ID to use when running this experiment or Feature Variable.

customAttributes

optional Custom Attributes dictionary to be used for this experiment or Feature Variable.

Returns:

The value of the Dynamic Variable.

static Int getMetadataSequenceNumber ()

Returns the sequence number of the most recently downloaded metadata. Returns 0 if no metadata has been downloaded yet. For troubleshooting purposes.

@:overloadstatic String getString (String name, String defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic String getString (String name, String defaultValue, String userID)

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 Feature Variable, 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 or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Dynamic getStringArray (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getStringArray (String name, Dynamic defaultValue, String userID)

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 Feature Variable, or user is allocated to original variant.

userID

User ID to use when running this experiment or Feature Variable.

customAttributes

optional Custom Attributes dictionary to be used for this experiment or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Dynamic getStringDictionary (String name, Dynamic defaultValue, String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getStringDictionary (String name, Dynamic defaultValue, String userID)

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 Feature Variable, or user is allocated to original variant.

userID

User ID to use when running this experiment or Feature Variable.

customAttributes

optional Custom Attributes dictionary to be used for this experiment or Feature Variable.

Returns:

The value of the Dynamic Variable.

@:overloadstatic Dynamic getVariantInfo (String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getVariantInfo (String userID)

Returns information about all Experiments, Feature Flags, and Feature Variables 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.

@:overloadstatic Dynamic getWinnerVariantInfo (String userID, Dynamic customAttributes)

@:overloadstatic Dynamic getWinnerVariantInfo (String userID)

Returns information about all Winning Experiments that the user is eligible to participate in. The list includes all of the winning 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 WinnerVariantInfo objects.

@:overloadstatic Bool isFeatureFlagEnabled (String name, String userID, Dynamic customAttributes)

@:overloadstatic Bool isFeatureFlagEnabled (String name, String userID)

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 }) @:overloadstatic Void runCodeBlock (String codeBlockVariableName, Dynamic callback, String userID, optional Null< Dynamic > customAttributes)

@:overloadstatic Void runCodeBlock (String codeBlockVariableName, Dynamic callback, String userID)

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 ( Dynamic 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 ( Dynamic 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 ( Dynamic 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 ( Dynamic 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)

@:overloadstatic Void setup (String appKey, Dynamic configAttributes)

@:overloadstatic Void setup (String appKey)

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
  • "apptimize_region": The server region to use.
    • Default value: "default"
    • Supported values:
      • "default"
      • "eucs"

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!

@:overloadstatic Void track (String eventName, String userID, Dynamic customAttributes)

@:overloadstatic Void track (String eventName, String userID)

Track an event for the user.

Parameters:

eventName

Name of the event.

userID

The User ID.

customAttributes

optional Custom Attributes dictionary for the event.

@:overloadstatic Void trackValue (String eventName, Float value, String userID, Dynamic customAttributes)

@:overloadstatic Void trackValue (String eventName, Float value, String userID)

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().