class Apptimize
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", "PHP", 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. Overrides the current Custom Attributes, if set. |
Returns:
The value of the Dynamic Variable.
static String getString (String name, String defaultValue, optional String userID, optional Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. 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 Dynamic 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 | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | optional Custom Attributes dictionary to be used for this experiment. Overrides the current Custom Attributes, if set. |
Returns:
The value of the Dynamic Variable.
static Dynamic getVariantInfo (optional String userID, optional Dynamic 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 | optional User ID to find list of variants for. Overrides the current Anonymous ID or Customer User ID, if set. |
---|---|
customAttributes | optional Custom Attributes dictionary to be used to find variants. Overrides the current Custom Attributes, if set. |
Returns:
A list of VariantInfo objects.
static Bool isFeatureFlagEnabled (String name, optional String userID, optional Dynamic customAttributes)
Detect if a Feature Flag is enabled for the specified user.
Parameters:
name | The Feature Flag Variable name. |
---|---|
userID | optional User ID to use for this feature flag. Overrides the current Customer User ID, if set. |
customAttributes | 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.
static Void runCodeBlock (String codeBlockVariableName, Dynamic callback, optional String userID, optional Dynamic 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 dictionary of callback methods. The dictionary keys should be as follows:
|
userID | optional User ID to use when running this experiment. Overrides the current Customer User ID, if set. |
customAttributes | 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 setOnMetadataUpdatedCallback ( OnMetadataProcessedCallback callback)
Set a callback method to be called when new metadata has been downloaded.
Parameters:
callback | Callback method to be called. Should have signature
|
---|
static Void setOnParticipationCallback ( OnParticipationCallback 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
|
---|
static Void setup (String appKey, optional 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.
|
static Void track (String eventName, optional String userID, optional Dynamic customAttributes)
Track an event for the user.
Parameters:
eventName | Name of the event. |
---|---|
userID | optional The User ID. Overrides the current Customer User ID, if set. |
customAttributes | 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 Dynamic customAttributes)
Track an event for the user with a value.
Parameters:
eventName | Name of the event. |
---|---|
value | Double value to track with the event. |
userID | optional The User ID. Overrides the current Customer User ID, if set. |
customAttributes | 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()
.