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

Get the Apptimize-generated Anonymous User ID.

This Anonymous User ID will be used if-and-only-if the Customer User ID is null. If the Customer User ID is set to a non-null value, then set back to null, Apptimize will use the same Anonymous User ID as before.

Returns:

The Anonymous User ID for this session.

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.

static Bool getBool (String name, Bool defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

userID

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getBoolArray (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getBoolDictionary (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getCustomAttributes ()

Get the existing Custom Attributes set for this user/device.

Returns:

A dictionary of Custom Attributes.

static String getCustomerUserId ()

Get the Customer User ID that has been set by the client.

Returns:

The Customer User ID set. Returns null if not set.

static Float getDouble (String name, Float defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getDoubleArray (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getDoubleDictionary (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Int getInt (String name, Int defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getIntArray (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

userID

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getIntDictionary (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

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.

static String getPilotTargetingId ()

Get the Pilot Targeting identifier set for this user/device.

Returns:

The Pilot Targeting Identifier. Returns null if not set.

static String getString (String name, String defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getStringArray (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getStringDictionary (String name, Dynamic defaultValue, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to use when running this experiment or Feature Variable. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment or Feature Variable. Overrides the current Custom Attributes, if set.

Returns:

The value of the Dynamic Variable.

static Dynamic getVariantInfo (optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

deprecated, optional User ID to find list of variants for. Overrides the current Anonymous ID or Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used to find variants. Overrides the current Custom Attributes, if set.

Returns:

A list of VariantInfo objects.

static Dynamic getWinnerVariantInfo ()

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

Returns:

A list of WinnerVariantInfo objects.

static Bool isFeatureFlagEnabled (String name, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

Parameters:

name

The Feature Flag Variable name.

userID

deprecated, optional User ID to use for this feature flag. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this feature flag. Overrides the current Custom Attributes, if set.

Returns:

true if the Feature Flag is enabled; false otherwise.

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

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

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

Parameters:

codeBlockVariableName

The Code Block Variable name from the experiment configuration.

callback

A dictionary of callback methods. The dictionary keys should be as follows:

{
    "baseline" : myBaselineMethod,
    "variation1" : myVariantMethod1,
    "variation2" : myVariantMethod2,
        ...
    "variationN" : myVariantMethodN
}
userID

deprecated, optional User ID to use when running this experiment. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary to be used for this experiment. Overrides the current Custom Attributes, if set.

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

Set the Custom Attributes for this user/device.

Custom Attributes are applied to all calls and persisted between sessions. When set, the attributes object will replace all existing attributes that have been previously set. In other methods, the object passed as the optional customAttributes parameter will override these Custom Attributes for that call only.

Parameters:

attributes

A dictionary of attribute keys and values. Simple value types are supported.

static Void setCustomerUserId (String id)

Set the Customer User ID for the user.

This ID should be unique to each user and is used for tracking. Replaces the Anonymous ID each session is given by default. Experiment participation can change if the user participated previously with a different User ID or as an Anonymous User.

Parameters:

id

The customer-specified ID to be used for this user. Can be set to null in order to to remove the User ID and use the Anonymous ID.

static Void setOnApptimizeInitializedCallback ( Dynamic callback)

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

Parameters:

callback

Callback method to be called. Should have signature function onApptimizeInitialized()

static Void setOnEnrolledInExperimentCallback ( Dynamic callback)

Set a callback method to be called when a user has become enrolled in an experiment.

Parameters:

callback

Callback method to be called. Should have signature function onEnrolledInExperimentCallback(VariantInfo variantInfo)

static Void setOnMetadataUpdatedCallback ( Dynamic callback)

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

Parameters:

callback

Callback method to be called. Should have signature function onMetadataUpdated()

static Void setOnParticipatedInExperimentCallback ( Dynamic callback)

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

Parameters:

callback

Callback method to be called. Should have signature function onParticipatedInExperiment(VariantInfo variantInfo)

static Void setOnParticipationCallback ( Dynamic callback)

Deprecated:

Method deprecated, please use setOnParticipatedInExperimentCallback instead.

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

Parameters:

callback

Callback method to be called. Should have signature function onParticipation(string ExperimentName, string VariantName)

static Void setOnUnenrolledInExperimentCallback ( Dynamic callback)

Set a callback method to be called when a user has become unenrolled in an experiment.

Parameters:

callback

Callback method to be called. Should have signature function onUnenrolledInExperimentCallback(VariantInfo variantInfo, UnenrollmentReason unenrollmentReason)

static Void setPilotTargetingId (String id)

Set the Pilot Targeting identifier for this user/device.

Typically the same as CustomerUserId, but must be separately set to opt-in to pilot targeting.

Pilot targeting allows you to select specific pilot targeting IDs and groups of pilot targeting IDs in the Apptimize web dashboard for the purposes of targeting experiments, feature flags, or feature variables to specific app/user instances.

Setting this value will cause pilot targeting to be recalculated if applicable. This operation is asynchronous, and will trigger enrollment callbacks.

Parameters:

pilotTargetingID

The string ID to use for targeting pilot users.

static Void setup (String appKey, optional Null< Dynamic > 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
  • "apptimize_region": The server region to use.
    • Default value: "default"
    • Supported values:
      • "default"
      • "eucs"

static Void track (String eventName, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

Track an event for the user.

Parameters:

eventName

Name of the event.

userID

deprecated, optional The User ID. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary for the event. Overrides the current Custom Attributes, if set.

static Void trackValue (String eventName, Float value, optional String userID, optional Null< Dynamic > customAttributes)

Deprecated:

The userID argument is deprecated. Please use the setCustomerUserId() method instead.
The customAttributes argument is deprecated. Please use the setCustomAttributes() method instead.

Track an event for the user with a value.

Parameters:

eventName

Name of the event.

value

Double value to track with the event.

userID

deprecated, optional The User ID. Overrides the current Customer User ID, if set.

customAttributes

deprecated, optional Custom Attributes dictionary for the event. Overrides the current Custom Attributes, if set.

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