import { EventSubscription } from 'react-native'; import { CodeBlockCallback, PropertiesLoadedCallback, TaplyticsFeatureFlags, TaplyticsExperiments, TaplyticsVariableMap } from './experiments.types'; /** * `runCodeBlock` takes a callback that can be enabled or disabled depending on the variation. * If enabled, the code within the callback will be executed. * If disabled, the variation will not get the callback. * * By default, a code block will not run unless enabled on the Taplytics Dashboard. * It must be enabled for a Variation before it will run. * * @param name The name of the code block variable. * @param codeBlock A function that will run if the code block variable is activated. */ export declare const runCodeBlock: (name: string, codeBlock: CodeBlockCallback) => void; /** * @deprecated Use the `setTaplyticsNewSessionListener` instead. * * Use this method to ensure that all the feature flag and experiment variables * have been loaded from the server prior to utilizing them. The callback * returns back an event subscriber that can be used to cleanup the event * listener using the `remove` function. * * On iOS the callback is also triggered when a new session is generated or * if the user's `email` or `user_id` attributes have been updated using the * `setUserAttributes` method. * * @param callback A function that runs once properties have been loaded. * * @returns An event subscriber object is returned. Use the `remove` function to clean up the event listener. */ export declare const propertiesLoadedCallback: (callback: PropertiesLoadedCallback) => EventSubscription; /** * Called to determine which feature flags that are running on a given device. * * @returns A promise that resolves to an object with running feature flags' names and their associated key. */ export declare const getRunningFeatureFlags: () => Promise; /** * Determine if a particular feature flag is enabled. * * NOTE: The value of featureFlagEnabled will be determined immediately, ie. the SDK * will not wait for properties to be loaded from the server. Thus, if you want to ensure * that the variables have their correct values based on your experiment segmentation, * you must initialize them after the properties have been loaded from the server through * the `propertiesLoadedCallback` method. * * @param key The key of the feature flag. * * @returns A promise that resolves to a boolean. */ export declare const featureFlagEnabled: (key: string) => Promise; /** * Called to determine which variations and experiments are running on a given device. * * @returns A promise that resolves to an object of current experiments and their running variation. */ export declare const getRunningExperimentsAndVariations: () => Promise; /** * Use this function to register a listener for whenever an experiments' variable value is changed. * * @param listener A function that is invoked whenever an experiments' variable is updated. */ export declare const registerVariablesChangedListener: (listener: (variables: TaplyticsVariableMap) => void | Promise) => void; /** * This method returns an object with experiment variables' keys and values. It only keeps track of * variables that have been fetched by either `newAsyncVariable` or `newSyncVariable`. * * @returns An object that holds the key's and values of the experiment variables. */ export declare const getVariables: () => TaplyticsVariableMap; /** * This function ensures that the experiments have been loaded before returning a value. * This removes any danger of tainting the results of experiments with bad data. * However, this does mean that the value will not be set immediately. In the case that * the experiments fail to load, then the default value will be returned. * * @param name The name of the dynamic variable. * @param defaultValue Default value to be utilized for the dynamic variable. * @param callback A function that runs when the dynamic variable has been evaluated or updated, * it receives the dynamic variable value as the argument. * * @returns An event subscriber object is returned. Use the `remove` function to clean up the event listener. */ export declare const newAsyncVariable: (name: string, defaultValue: T, callback: (variable: T) => void) => EventSubscription; /** * This function is a synchronous means of retrieving a dynamic variables' value. * It guarantees to have the same value for the entire session and will have that * value immediately after construction. Ensure that the experiments have been loaded * in before utilizing this method via the `propertiesLoadedCallback` or `setTaplyticsNewSessionListener` * method, otherwise it will return the default value. * * @param name The name of the dynamic variable. * @param defaultValue Default value to be utilized for the dynamic variable. * * @returns A promise that resolves to the dynamic variable. */ export declare const newSyncVariable: (name: string, defaultValue: T) => Promise;