UNPKG

@apptimize/apptimize-server-sdk

Version:

Apptimize Server SDK for Node.js

1,086 lines 396 kB
// Copyright (c) Apptimize, Inc. | https://sdk.apptimize.com/license (function ($hx_exports, $global) { "use strict"; var $hxClasses = {},$estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; function $extend(from, fields) { var proto = Object.create(from); for (var name in fields) proto[name] = fields[name]; if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; return proto; } var apptimize_Apptimize = $hx_exports["Apptimize"] = function() { }; $hxClasses["apptimize.Apptimize"] = apptimize_Apptimize; apptimize_Apptimize.__name__ = "apptimize.Apptimize"; apptimize_Apptimize._isInitialized = function() { return apptimize_ApptimizeInternal._isInitialized(); }; apptimize_Apptimize._getApptimizeAnonUserId = function() { var anonUserId = apptimize_support_persistence_ABTPersistence.loadString(apptimize_support_persistence_ABTPersistence.kAnonymousGuidKey); if(anonUserId == null || anonUserId == "" || !apptimize_api_ABTUserGuid.isValidGuid(anonUserId)) { anonUserId = apptimize_api_ABTUserGuid.generateUserGuid(); apptimize_support_persistence_ABTPersistence.saveString(apptimize_support_persistence_ABTPersistence.kAnonymousGuidKey,anonUserId); } return anonUserId; }; apptimize_Apptimize.setAppVersion = $hx_exports["setAppVersion"] = function(version) { apptimize_support_properties_ABTApplicationProperties.sharedInstance().setProperty("app_version",version); var app_version = apptimize_support_properties_ABTApplicationProperties.sharedInstance().valueForProperty("app_version"); apptimize_ABTLogger.v("App Version set to: " + app_version,{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 267, className : "apptimize.Apptimize", methodName : "setAppVersion"}); }; apptimize_Apptimize.setAppName = $hx_exports["setAppName"] = function(name) { apptimize_support_properties_ABTApplicationProperties.sharedInstance().setProperty("app_name",name); var app_name = apptimize_support_properties_ABTApplicationProperties.sharedInstance().valueForProperty("app_name"); apptimize_ABTLogger.v("App Name set to: " + app_name,{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 278, className : "apptimize.Apptimize", methodName : "setAppName"}); }; apptimize_Apptimize.setOnParticipationCallback = $hx_exports["setOnParticipationCallback"] = function(callback) { apptimize_events_ABTEventManager.setOnParticipationCallback(callback); apptimize_ABTLogger.w("setOnParticipationCallback is deprecated - please use setOnParticipatedInExperimentCallback.",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 299, className : "apptimize.Apptimize", methodName : "setOnParticipationCallback"}); }; apptimize_Apptimize.setOnMetadataUpdatedCallback = $hx_exports["setOnMetadataUpdatedCallback"] = function(callback) { apptimize_events_ABTEventManager.setOnMetadataUpdatedCallback(callback); apptimize_ABTLogger.v("OnMetadataProcessedCallback set!",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 318, className : "apptimize.Apptimize", methodName : "setOnMetadataUpdatedCallback"}); }; apptimize_Apptimize.setOnApptimizeInitializedCallback = $hx_exports["setOnApptimizeInitializedCallback"] = function(callback) { apptimize_events_ABTEventManager.setOnApptimizeInitializedCallback(callback); apptimize_ABTLogger.v("OnApptimizeInitializedCallback set!",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 339, className : "apptimize.Apptimize", methodName : "setOnApptimizeInitializedCallback"}); }; apptimize_Apptimize.setOnParticipatedInExperimentCallback = $hx_exports["setOnParticipatedInExperimentCallback"] = function(callback) { apptimize_events_ABTEventManager.setOnParticipatedInExperimentCallback(callback); apptimize_ABTLogger.v("OnParticipatedInExperimentCallback set!",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 357, className : "apptimize.Apptimize", methodName : "setOnParticipatedInExperimentCallback"}); }; apptimize_Apptimize.setup = $hx_exports["setup"] = function(appKey,configAttributes) { if(appKey == null || appKey == "") { apptimize_ABTLogger.c("Unable to initialize Apptimize due to missing app key.",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 413, className : "apptimize.Apptimize", methodName : "setup"}); return; } else if(apptimize_ABTDataStore.getAppKey() != null && apptimize_ABTDataStore.getAppKey() == appKey) { apptimize_ABTLogger.w("Apptimize is already initialized with app key: \"" + appKey + "\".",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 416, className : "apptimize.Apptimize", methodName : "setup"}); return; } apptimize_ApptimizeInternal._setup(appKey,configAttributes,function() { if(apptimize_ABTDataStore.getAppKey() != null && apptimize_ABTDataStore.getAppKey() != appKey) { apptimize_ABTDataStore.clear(); } apptimize_ABTLogger.v("Set Anonymous User ID: " + apptimize_Apptimize._getApptimizeAnonUserId(),{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 427, className : "apptimize.Apptimize", methodName : "setup"}); apptimize_ABTLogger.i("Apptimize " + apptimize_Apptimize.getApptimizeSDKPlatform() + " SDK initialized.\nApptimize SDK Version: " + apptimize_Apptimize.getApptimizeSDKVersion(),{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 428, className : "apptimize.Apptimize", methodName : "setup"}); apptimize_Apptimize._initialize(appKey); }); }; apptimize_Apptimize.shutdown = $hx_exports["shutdown"] = function() { apptimize_ApptimizeInternal.shutdown(); }; apptimize_Apptimize.updateApptimizeMetadataOnce = $hx_exports["updateApptimizeMetadataOnce"] = function() { try { apptimize_ABTDataStore.checkForUpdatedMetaData(true); } catch( _g ) { haxe_NativeStackTrace.lastError = _g; var e = haxe_Exception.caught(_g).unwrap(); apptimize_ABTLogger.e("Failed to update Metadata: " + Std.string(e),{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 460, className : "apptimize.Apptimize", methodName : "updateApptimizeMetadataOnce"}); } }; apptimize_Apptimize.flushTracking = $hx_exports["flushTracking"] = function() { if(apptimize_Apptimize._isInitialized()) { apptimize_ABTDataStore.sharedInstance().flushTracking(); } else { apptimize_ABTLogger.w("Tracking can only be flushed after setup().",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 475, className : "apptimize.Apptimize", methodName : "flushTracking"}); } }; apptimize_Apptimize.getApptimizeSDKVersion = $hx_exports["getApptimizeSDKVersion"] = function() { return "1.2.44"; }; apptimize_Apptimize.getApptimizeSDKPlatform = $hx_exports["getApptimizeSDKPlatform"] = function() { var sdkPlatform = "N/A"; return "Node.js"; }; apptimize_Apptimize._initialize = function(appKey) { apptimize_ABTDataStore.sharedInstance().loadMetaData(appKey); apptimize_ApptimizeInternal.setState(2); if(apptimize_ABTDataStore.sharedInstance().hasMetadata(apptimize_ABTDataStore.getAppKey()) && apptimize_support_properties_ABTConfigProperties.sharedInstance().valueForProperty(apptimize_support_properties_ABTConfigProperties.REFRESH_META_DATA_ON_SETUP) == false && apptimize_ApptimizeInternal._trySetReady()) { apptimize_events_ABTEventManager.dispatchOnApptimizeInitialized(); apptimize_ABTLogger.i("Apptimize initialized with app key \"" + appKey + "\".",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 532, className : "apptimize.Apptimize", methodName : "_initialize"}); } }; apptimize_Apptimize._getAlterations = function(userID,customAttributes) { apptimize_ABTDataStore._checkForUpdatedMetadataIfNecessary(); if(apptimize_Apptimize._isInitialized()) { var envParams = new apptimize_filter_ABTFilterEnvParams(userID,apptimize_Apptimize._getApptimizeAnonUserId(),customAttributes,apptimize_ABTDataStore.getAppKey(),apptimize_support_properties_ABTApplicationProperties.sharedInstance(),apptimize_support_properties_ABTInternalProperties.sharedInstance()); return apptimize_ApptimizeInternal._getAlterations(envParams); } return []; }; apptimize_Apptimize._getCodeBlockMethod = function(codeBlockVariableName,userID,customAttributes) { apptimize_ABTDataStore._checkForUpdatedMetadataIfNecessary(); var envParams = new apptimize_filter_ABTFilterEnvParams(userID,apptimize_Apptimize._getApptimizeAnonUserId(),customAttributes,apptimize_ABTDataStore.getAppKey(),apptimize_support_properties_ABTApplicationProperties.sharedInstance(),apptimize_support_properties_ABTInternalProperties.sharedInstance()); return apptimize_ApptimizeInternal._getCodeBlockMethod(envParams,codeBlockVariableName); }; apptimize_Apptimize.runCodeBlock = $hx_exports["runCodeBlock"] = function(codeBlockVariableName,callback,userID,customAttributes) { if(userID != null) { if(!apptimize_util_ABTTypes.isString(userID) || StringTools.ltrim(userID) == "") { apptimize_ABTLogger.w("The `userID` argument cannot be set to a non-string value, be empty or be whitespace only, setting to null instead.",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 47, className : "apptimize.Apptimize", methodName : "runCodeBlock"}); userID = null; } } if(userID == null) { apptimize_ABTLogger.c("The parameter " + "userID" + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 53, className : "apptimize.Apptimize", methodName : "runCodeBlock"}); } if(customAttributes == null && false) { apptimize_ABTLogger.c("The parameter " + null + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 59, className : "apptimize.Apptimize", methodName : "runCodeBlock"}); } var attrs = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(customAttributes); var methodName = apptimize_Apptimize._getCodeBlockMethod(codeBlockVariableName,userID,attrs); var callbackMap = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(callback); if(methodName == null || methodName == "") { apptimize_ABTLogger.w("No Code Block with variable name " + codeBlockVariableName + " found, skipping callback.",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 627, className : "apptimize.Apptimize", methodName : "runCodeBlock"}); return; } else if(callback == null || callbackMap.h[methodName] == null) { var method = Reflect.getProperty(callback,methodName); if(method != null) { method.apply(callback,[]); } else { apptimize_ABTLogger.w("Supplied callbacks do not include method: " + methodName,{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 635, className : "apptimize.Apptimize", methodName : "runCodeBlock"}); } } else { apptimize_ABTLogger.v("Calling callback method: " + methodName,{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 638, className : "apptimize.Apptimize", methodName : "runCodeBlock"}); var func = callbackMap.h[methodName]; if(!Reflect.isFunction(func)) { apptimize_ABTLogger.e("runCodeBlock() called with callback that isn't a function/method.",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 642, className : "apptimize.Apptimize", methodName : "runCodeBlock"}); return; } func(); } }; apptimize_Apptimize.isFeatureFlagEnabled = $hx_exports["isFeatureFlagEnabled"] = function(name,userID,customAttributes) { return apptimize_Apptimize.getBool(name,false,userID,customAttributes); }; apptimize_Apptimize.getString = $hx_exports["getString"] = function(name,defaultValue,userID,customAttributes) { var stringValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.String,null,customAttributes); if(stringValue == null) { return defaultValue; } return stringValue; }; apptimize_Apptimize.getBool = $hx_exports["getBool"] = function(name,defaultValue,userID,customAttributes) { var boolValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Boolean,null,customAttributes); if(boolValue == null) { return defaultValue; } return boolValue; }; apptimize_Apptimize.getInt = $hx_exports["getInt"] = function(name,defaultValue,userID,customAttributes) { var intValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Integer,null,customAttributes); if(intValue == null) { return defaultValue; } return intValue; }; apptimize_Apptimize.getDouble = $hx_exports["getDouble"] = function(name,defaultValue,userID,customAttributes) { var floatValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Double,null,customAttributes); if(floatValue == null) { return defaultValue; } return floatValue; }; apptimize_Apptimize.getStringArray = $hx_exports["getStringArray"] = function(name,defaultValue,userID,customAttributes) { var stringArrayValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Array,apptimize_ABTApptimizeVariableType.String,customAttributes); if(stringArrayValue == null) { return defaultValue; } return apptimize_util_ABTUtilArray.toNativeArray(stringArrayValue,apptimize_util_ArrayType.String); }; apptimize_Apptimize.getBoolArray = $hx_exports["getBoolArray"] = function(name,defaultValue,userID,customAttributes) { var boolArrayValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Array,apptimize_ABTApptimizeVariableType.Boolean,customAttributes); if(boolArrayValue == null) { return defaultValue; } return apptimize_util_ABTUtilArray.toNativeArray(boolArrayValue,apptimize_util_ArrayType.Bool); }; apptimize_Apptimize.getIntArray = $hx_exports["getIntArray"] = function(name,defaultValue,userID,customAttributes) { var intArrayValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Array,apptimize_ABTApptimizeVariableType.Integer,customAttributes); if(intArrayValue == null) { return defaultValue; } return apptimize_util_ABTUtilArray.toNativeArray(intArrayValue,apptimize_util_ArrayType.Int); }; apptimize_Apptimize.getDoubleArray = $hx_exports["getDoubleArray"] = function(name,defaultValue,userID,customAttributes) { var doubleArrayValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Array,apptimize_ABTApptimizeVariableType.Double,customAttributes); if(doubleArrayValue == null) { return defaultValue; } return apptimize_util_ABTUtilArray.toNativeArray(doubleArrayValue,apptimize_util_ArrayType.Double); }; apptimize_Apptimize.getStringDictionary = $hx_exports["getStringDictionary"] = function(name,defaultValue,userID,customAttributes) { var stringDictionaryValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Dictionary,apptimize_ABTApptimizeVariableType.String,customAttributes); if(stringDictionaryValue == null) { return defaultValue; } return stringDictionaryValue; }; apptimize_Apptimize.getBoolDictionary = $hx_exports["getBoolDictionary"] = function(name,defaultValue,userID,customAttributes) { var boolDictionaryValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Dictionary,apptimize_ABTApptimizeVariableType.Boolean,customAttributes); if(boolDictionaryValue == null) { return defaultValue; } return boolDictionaryValue; }; apptimize_Apptimize.getIntDictionary = $hx_exports["getIntDictionary"] = function(name,defaultValue,userID,customAttributes) { var intDictionaryValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Dictionary,apptimize_ABTApptimizeVariableType.Integer,customAttributes); if(intDictionaryValue == null) { return defaultValue; } return intDictionaryValue; }; apptimize_Apptimize.getDoubleDictionary = $hx_exports["getDoubleDictionary"] = function(name,defaultValue,userID,customAttributes) { var doubleDictionaryValue = apptimize_Apptimize._getValue(name,userID,apptimize_ABTApptimizeVariableType.Dictionary,apptimize_ABTApptimizeVariableType.Double,customAttributes); if(doubleDictionaryValue == null) { return defaultValue; } return doubleDictionaryValue; }; apptimize_Apptimize._getValue = function(name,userID,type,nestedType,customAttributes) { if(!apptimize_Apptimize._isInitialized()) { return null; } if(userID != null) { if(!apptimize_util_ABTTypes.isString(userID) || StringTools.ltrim(userID) == "") { apptimize_ABTLogger.w("The `userID` argument cannot be set to a non-string value, be empty or be whitespace only, setting to null instead.",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 47, className : "apptimize.Apptimize", methodName : "_getValue"}); userID = null; } } if(userID == null) { apptimize_ABTLogger.c("The parameter " + "userID" + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 53, className : "apptimize.Apptimize", methodName : "_getValue"}); } if(customAttributes == null && false) { apptimize_ABTLogger.c("The parameter " + null + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 59, className : "apptimize.Apptimize", methodName : "_getValue"}); } var attrMap = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(customAttributes); var envParams = new apptimize_filter_ABTFilterEnvParams(userID,apptimize_Apptimize._getApptimizeAnonUserId(),attrMap,apptimize_ABTDataStore.getAppKey(),apptimize_support_properties_ABTApplicationProperties.sharedInstance(),apptimize_support_properties_ABTInternalProperties.sharedInstance()); return apptimize_ABTApptimizeVariable.getValue(envParams,name,type,nestedType); }; apptimize_Apptimize.getVariantInfo = $hx_exports["getVariantInfo"] = function(userID,customAttributes) { if(userID != null) { if(!apptimize_util_ABTTypes.isString(userID) || StringTools.ltrim(userID) == "") { apptimize_ABTLogger.w("The `userID` argument cannot be set to a non-string value, be empty or be whitespace only, setting to null instead.",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 47, className : "apptimize.Apptimize", methodName : "getVariantInfo"}); userID = null; } } if(userID == null) { apptimize_ABTLogger.c("The parameter " + "userID" + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 53, className : "apptimize.Apptimize", methodName : "getVariantInfo"}); } if(customAttributes == null && false) { apptimize_ABTLogger.c("The parameter " + null + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 59, className : "apptimize.Apptimize", methodName : "getVariantInfo"}); } var variantInfos = []; var anonID = apptimize_Apptimize._getApptimizeAnonUserId(); var attrMap = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(customAttributes); var envParams = new apptimize_filter_ABTFilterEnvParams(userID,anonID,attrMap,apptimize_ABTDataStore.getAppKey(),apptimize_support_properties_ABTApplicationProperties.sharedInstance(),apptimize_support_properties_ABTInternalProperties.sharedInstance()); var _g = 0; var _g1 = apptimize_ApptimizeInternal._getVariants(envParams,false); while(_g < _g1.length) { var variant = _g1[_g]; ++_g; variantInfos.push(apptimize_VariantInfo.initWithVariant(variant,userID,anonID)); } return apptimize_util_ABTUtilArray.toNativeArray(variantInfos,apptimize_util_ArrayType.VariantInfo); }; apptimize_Apptimize.getWinnerVariantInfo = $hx_exports["getWinnerVariantInfo"] = function(userID,customAttributes) { return apptimize_ApptimizeInternal.getWinnerVariantInfo(userID,apptimize_Apptimize._getApptimizeAnonUserId(),customAttributes); }; apptimize_Apptimize._getVariantInfoForAlteration = function(name,userID,customAttributes) { var anonID = apptimize_Apptimize._getApptimizeAnonUserId(); var _g = 0; var _g1 = apptimize_Apptimize._getAlterations(userID,customAttributes); while(_g < _g1.length) { var alteration = _g1[_g]; ++_g; if(alteration.getKey() == name) { return apptimize_VariantInfo.initWithVariant(alteration.getVariant(),userID,anonID); } } return null; }; apptimize_Apptimize._getVariantInfoForDynamicVariable = function(name,userID,customAttributes) { if(userID != null) { if(!apptimize_util_ABTTypes.isString(userID) || StringTools.ltrim(userID) == "") { apptimize_ABTLogger.w("The `userID` argument cannot be set to a non-string value, be empty or be whitespace only, setting to null instead.",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 47, className : "apptimize.Apptimize", methodName : "_getVariantInfoForDynamicVariable"}); userID = null; } } if(userID == null) { apptimize_ABTLogger.c("The parameter " + "userID" + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 53, className : "apptimize.Apptimize", methodName : "_getVariantInfoForDynamicVariable"}); } if(customAttributes == null && false) { apptimize_ABTLogger.c("The parameter " + null + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 59, className : "apptimize.Apptimize", methodName : "_getVariantInfoForDynamicVariable"}); } var attrMap = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(customAttributes); return apptimize_Apptimize._getVariantInfoForAlteration(name,userID,attrMap); }; apptimize_Apptimize._getVariantInfoForExperiment = function(name,userID,customAttributes) { if(userID != null) { if(!apptimize_util_ABTTypes.isString(userID) || StringTools.ltrim(userID) == "") { apptimize_ABTLogger.w("The `userID` argument cannot be set to a non-string value, be empty or be whitespace only, setting to null instead.",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 47, className : "apptimize.Apptimize", methodName : "_getVariantInfoForExperiment"}); userID = null; } } if(userID == null) { apptimize_ABTLogger.c("The parameter " + "userID" + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 53, className : "apptimize.Apptimize", methodName : "_getVariantInfoForExperiment"}); } if(customAttributes == null && false) { apptimize_ABTLogger.c("The parameter " + null + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 59, className : "apptimize.Apptimize", methodName : "_getVariantInfoForExperiment"}); } var anonID = apptimize_Apptimize._getApptimizeAnonUserId(); var attrMap = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(customAttributes); var envParams = new apptimize_filter_ABTFilterEnvParams(userID,anonID,attrMap,apptimize_ABTDataStore.getAppKey(),apptimize_support_properties_ABTApplicationProperties.sharedInstance(),apptimize_support_properties_ABTInternalProperties.sharedInstance()); var _g = 0; var _g1 = apptimize_ApptimizeInternal._getVariants(envParams); while(_g < _g1.length) { var variant = _g1[_g]; ++_g; if(variant.getExperimentName() == name) { return apptimize_VariantInfo.initWithVariant(variant,userID,anonID); } } return null; }; apptimize_Apptimize.track = $hx_exports["track"] = function(eventName,userID,customAttributes) { if(apptimize_Apptimize._isInitialized()) { if(userID != null) { if(!apptimize_util_ABTTypes.isString(userID) || StringTools.ltrim(userID) == "") { apptimize_ABTLogger.w("The `userID` argument cannot be set to a non-string value, be empty or be whitespace only, setting to null instead.",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 47, className : "apptimize.Apptimize", methodName : "track"}); userID = null; } } if(userID == null) { apptimize_ABTLogger.c("The parameter " + "userID" + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 53, className : "apptimize.Apptimize", methodName : "track"}); } if(customAttributes == null && false) { apptimize_ABTLogger.c("The parameter " + null + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 59, className : "apptimize.Apptimize", methodName : "track"}); } var attrMap = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(customAttributes); var envParams = new apptimize_filter_ABTFilterEnvParams(userID,apptimize_Apptimize._getApptimizeAnonUserId(),attrMap,apptimize_ABTDataStore.getAppKey(),apptimize_support_properties_ABTApplicationProperties.sharedInstance(),apptimize_support_properties_ABTInternalProperties.sharedInstance()); apptimize_ApptimizeInternal.generateTrackEvent(envParams,eventName,null); } else { apptimize_ABTLogger.w("Events can only be tracked after setup() has been called.",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 1253, className : "apptimize.Apptimize", methodName : "track"}); } }; apptimize_Apptimize.trackValue = $hx_exports["trackValue"] = function(eventName,value,userID,customAttributes) { if(apptimize_Apptimize._isInitialized()) { if(userID != null) { if(!apptimize_util_ABTTypes.isString(userID) || StringTools.ltrim(userID) == "") { apptimize_ABTLogger.w("The `userID` argument cannot be set to a non-string value, be empty or be whitespace only, setting to null instead.",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 47, className : "apptimize.Apptimize", methodName : "trackValue"}); userID = null; } } if(userID == null) { apptimize_ABTLogger.c("The parameter " + "userID" + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 53, className : "apptimize.Apptimize", methodName : "trackValue"}); } if(customAttributes == null && false) { apptimize_ABTLogger.c("The parameter " + null + " is required",{ fileName : "src/apptimize/macros/ABTClientMacro.hx", lineNumber : 59, className : "apptimize.Apptimize", methodName : "trackValue"}); } if(typeof(value) != "number" && !js_Boot.__instanceof(value,apptimize_util_ArrayType.Int)) { apptimize_ABTLogger.w("trackValue() called with a non-float value. Event not logged.",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 1284, className : "apptimize.Apptimize", methodName : "trackValue"}); return; } var attrMap = apptimize_util_ABTUtilDictionary.nativeObjectToStringMap(customAttributes); var envParams = new apptimize_filter_ABTFilterEnvParams(userID,apptimize_Apptimize._getApptimizeAnonUserId(),attrMap,apptimize_ABTDataStore.getAppKey(),apptimize_support_properties_ABTApplicationProperties.sharedInstance(),apptimize_support_properties_ABTInternalProperties.sharedInstance()); apptimize_ApptimizeInternal.generateTrackEvent(envParams,eventName,value); } else { apptimize_ABTLogger.w("Events can only be tracked after setup() has been called.",{ fileName : "src/apptimize/Apptimize.hx", lineNumber : 1292, className : "apptimize.Apptimize", methodName : "trackValue"}); } }; apptimize_Apptimize.getMetadataSequenceNumber = $hx_exports["getMetadataSequenceNumber"] = function() { var store = apptimize_ABTDataStore.sharedInstance(); var md = store.getMetaData(apptimize_ABTDataStore.getAppKey()); if(md != null) { return md.getSequenceNumber(); } return 0; }; var Apptimize = function() { }; $hxClasses["Apptimize"] = Apptimize; Apptimize.__name__ = "Apptimize"; Apptimize.__super__ = apptimize_Apptimize; Apptimize.prototype = $extend(apptimize_Apptimize.prototype,{ __class__: Apptimize }); var apptimize_VariantInfo = $hx_exports["VariantInfo"] = function(variantId,variantName,experimentId,experimentName,experimentType,cycle,currentPhase,participationPhase,userId,anonymousUserId,userHasParticipated) { this._variantId = variantId; this._variantName = variantName; this._experimentId = experimentId; this._experimentName = experimentName; this._experimentType = apptimize_VariantInfo.apptimizeExperimentTypeForString(experimentType); this._experimentTypeName = experimentType; this._cycle = cycle; this._currentPhase = currentPhase; this._participationPhase = participationPhase; this._userId = userId; this._anonymousUserId = anonymousUserId; this._userHasParticipated = userHasParticipated; }; $hxClasses["apptimize.VariantInfo"] = apptimize_VariantInfo; apptimize_VariantInfo.__name__ = "apptimize.VariantInfo"; apptimize_VariantInfo.initWithVariant = function(variant,userId,anonymousUserId) { var participationPhase = 0; var variantString = "v" + variant.getVariantID() + "_" + variant.getCycle(); var userHasParticipated = false; return new apptimize_VariantInfo(variant.getVariantID(),variant.getVariantName(),variant.getExperimentID(),variant.getExperimentName(),variant.getExperimentType(),variant.getCycle(),variant.getPhase(),participationPhase,userId,anonymousUserId,userHasParticipated); }; apptimize_VariantInfo.apptimizeExperimentTypeForString = function(stringType) { var type = stringType.toLowerCase(); switch(type) { case "code-block": return apptimize_ApptimizeExperimentType.CodeBlock; case "double-value": return apptimize_ApptimizeExperimentType.DynamicVariables; case "feature-config": return apptimize_ApptimizeExperimentType.FeatureVariables; case "feature-flag": return apptimize_ApptimizeExperimentType.FeatureFlag; case "int-value": return apptimize_ApptimizeExperimentType.DynamicVariables; case "string-value": return apptimize_ApptimizeExperimentType.DynamicVariables; case "variables": return apptimize_ApptimizeExperimentType.DynamicVariables; case "wysiwyg": return apptimize_ApptimizeExperimentType.Visual; default: return apptimize_ApptimizeExperimentType.Unknown; } }; apptimize_VariantInfo.prototype = { _variantId: null ,_variantName: null ,_experimentId: null ,_experimentName: null ,_experimentType: null ,_experimentTypeName: null ,_currentPhase: null ,_participationPhase: null ,_cycle: null ,_userId: null ,_anonymousUserId: null ,_userHasParticipated: null ,getVariantId: function() { return this._variantId; } ,getVariantName: function() { return this._variantName; } ,getExperimentId: function() { return this._experimentId; } ,getExperimentName: function() { return this._experimentName; } ,getExperimentType: function() { return this._experimentType; } ,getExperimentTypeName: function() { return this._experimentTypeName; } ,getCurrentPhase: function() { return this._currentPhase; } ,getParticipationPhase: function() { return this._participationPhase; } ,getCycle: function() { return this._cycle; } ,getUserId: function() { return this._userId; } ,getAnonymousUserId: function() { return this._anonymousUserId; } ,__class__: apptimize_VariantInfo }; var VariantInfo = function(variantId,variantName,experimentId,experimentName,experimentType,cycle,currentPhase,participationPhase,userId,anonymousUserId,userHasParticipated) { apptimize_VariantInfo.call(this,variantId,variantName,experimentId,experimentName,experimentType,cycle,currentPhase,participationPhase,userId,anonymousUserId,userHasParticipated); }; $hxClasses["VariantInfo"] = VariantInfo; VariantInfo.__name__ = "VariantInfo"; VariantInfo.__super__ = apptimize_VariantInfo; VariantInfo.prototype = $extend(apptimize_VariantInfo.prototype,{ __class__: VariantInfo }); var EReg = function(r,opt) { this.r = new RegExp(r,opt.split("u").join("")); }; $hxClasses["EReg"] = EReg; EReg.__name__ = "EReg"; EReg.prototype = { r: null ,match: function(s) { if(this.r.global) { this.r.lastIndex = 0; } this.r.m = this.r.exec(s); this.r.s = s; return this.r.m != null; } ,matched: function(n) { if(this.r.m != null && n >= 0 && n < this.r.m.length) { return this.r.m[n]; } else { throw haxe_Exception.thrown("EReg::matched"); } } ,matchedPos: function() { if(this.r.m == null) { throw haxe_Exception.thrown("No string matched"); } return { pos : this.r.m.index, len : this.r.m[0].length}; } ,matchSub: function(s,pos,len) { if(len == null) { len = -1; } if(this.r.global) { this.r.lastIndex = pos; this.r.m = this.r.exec(len < 0 ? s : HxOverrides.substr(s,0,pos + len)); var b = this.r.m != null; if(b) { this.r.s = s; } return b; } else { var b = this.match(len < 0 ? HxOverrides.substr(s,pos,null) : HxOverrides.substr(s,pos,len)); if(b) { this.r.s = s; this.r.m.index += pos; } return b; } } ,map: function(s,f) { var offset = 0; var buf_b = ""; while(true) { if(offset >= s.length) { break; } else if(!this.matchSub(s,offset)) { buf_b += Std.string(HxOverrides.substr(s,offset,null)); break; } var p = this.matchedPos(); buf_b += Std.string(HxOverrides.substr(s,offset,p.pos - offset)); buf_b += Std.string(f(this)); if(p.len == 0) { buf_b += Std.string(HxOverrides.substr(s,p.pos,1)); offset = p.pos + 1; } else { offset = p.pos + p.len; } if(!this.r.global) { break; } } if(!this.r.global && offset > 0 && offset < s.length) { buf_b += Std.string(HxOverrides.substr(s,offset,null)); } return buf_b; } ,__class__: EReg }; var HxOverrides = function() { }; $hxClasses["HxOverrides"] = HxOverrides; HxOverrides.__name__ = "HxOverrides"; HxOverrides.dateStr = function(date) { var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var mi = date.getMinutes(); var s = date.getSeconds(); return date.getFullYear() + "-" + (m < 10 ? "0" + m : "" + m) + "-" + (d < 10 ? "0" + d : "" + d) + " " + (h < 10 ? "0" + h : "" + h) + ":" + (mi < 10 ? "0" + mi : "" + mi) + ":" + (s < 10 ? "0" + s : "" + s); }; HxOverrides.strDate = function(s) { switch(s.length) { case 8: var k = s.split(":"); var d = new Date(); d["setTime"](0); d["setUTCHours"](k[0]); d["setUTCMinutes"](k[1]); d["setUTCSeconds"](k[2]); return d; case 10: var k = s.split("-"); return new Date(k[0],k[1] - 1,k[2],0,0,0); case 19: var k = s.split(" "); var y = k[0].split("-"); var t = k[1].split(":"); return new Date(y[0],y[1] - 1,y[2],t[0],t[1],t[2]); default: throw haxe_Exception.thrown("Invalid date format : " + s); } }; HxOverrides.cca = function(s,index) { var x = s.charCodeAt(index); if(x != x) { return undefined; } return x; }; HxOverrides.substr = function(s,pos,len) { if(len == null) { len = s.length; } else if(len < 0) { if(pos == 0) { len = s.length + len; } else { return ""; } } return s.substr(pos,len); }; HxOverrides.remove = function(a,obj) { var i = a.indexOf(obj); if(i == -1) { return false; } a.splice(i,1); return true; }; HxOverrides.now = function() { return Date.now(); }; var Lambda = function() { }; $hxClasses["Lambda"] = Lambda; Lambda.__name__ = "Lambda"; Lambda.array = function(it) { var a = []; var i = $getIterator(it); while(i.hasNext()) { var i1 = i.next(); a.push(i1); } return a; }; Math.__name__ = "Math"; var Reflect = function() { }; $hxClasses["Reflect"] = Reflect; Reflect.__name__ = "Reflect"; Reflect.field = function(o,field) { try { return o[field]; } catch( _g ) { haxe_NativeStackTrace.lastError = _g; return null; } }; Reflect.getProperty = function(o,field) { var tmp; if(o == null) { return null; } else { var tmp1; if(o.__properties__) { tmp = o.__properties__["get_" + field]; tmp1 = tmp; } else { tmp1 = false; } if(tmp1) { return o[tmp](); } else { return o[field]; } } }; Reflect.fields = function(o) { var a = []; if(o != null) { var hasOwnProperty = Object.prototype.hasOwnProperty; for( var f in o ) { if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) { a.push(f); } } } return a; }; Reflect.isFunction = function(f) { if(typeof(f) == "function") { return !(f.__name__ || f.__ename__); } else { return false; } }; Reflect.deleteField = function(o,field) { if(!Object.prototype.hasOwnProperty.call(o,field)) { return false; } delete(o[field]); return true; }; var Std = function() { }; $hxClasses["Std"] = Std; Std.__name__ = "Std"; Std.string = function(s) { return js_Boot.__string_rec(s,""); }; Std.parseInt = function(x) { if(x != null) { var _g = 0; var _g1 = x.length; while(_g < _g1) { var i = _g++; var c = x.charCodeAt(i); if(c <= 8 || c >= 14 && c != 32 && c != 45) { var nc = x.charCodeAt(i + 1); var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10); if(isNaN(v)) { return null; } else { return v; } } } } return null; }; var StringBuf = function() { this.b = ""; }; $hxClasses["StringBuf"] = StringBuf; StringBuf.__name__ = "StringBuf"; StringBuf.prototype = { b: null ,__class__: StringBuf }; var StringTools = function() { }; $hxClasses["StringTools"] = StringTools; StringTools.__name__ = "StringTools"; StringTools.isSpace = function(s,pos) { var c = HxOverrides.cca(s,pos); if(!(c > 8 && c < 14)) { return c == 32; } else { return true; } }; StringTools.ltrim = function(s) { var l = s.length; var r = 0; while(r < l && StringTools.isSpace(s,r)) ++r; if(r > 0) { return HxOverrides.substr(s,r,l - r); } else { return s; } }; StringTools.rtrim = function(s) { var l = s.length; var r = 0; while(r < l && StringTools.isSpace(s,l - r - 1)) ++r; if(r > 0) { return HxOverrides.substr(s,0,l - r); } else { return s; } }; StringTools.trim = function(s) { return StringTools.ltrim(StringTools.rtrim(s)); }; StringTools.lpad = function(s,c,l) { if(c.length <= 0) { return s; } var buf_b = ""; l -= s.length; while(buf_b.length < l) buf_b += c == null ? "null" : "" + c; buf_b += s == null ? "null" : "" + s; return buf_b; }; StringTools.replace = function(s,sub,by) { return s.split(sub).join(by); }; StringTools.hex = function(n,digits) { var s = ""; var hexChars = "0123456789ABCDEF"; while(true) { s = hexChars.charAt(n & 15) + s; n >>>= 4; if(!(n > 0)) { break; } } if(digits != null) { while(s.length < digits) s = "0" + s; } return s; }; var ValueType = $hxEnums["ValueType"] = { __ename__:"ValueType",__constructs__:null ,TNull: {_hx_name:"TNull",_hx_index:0,__enum__:"ValueType",toString:$estr} ,TInt: {_hx_name:"TInt",_hx_index:1,__enum__:"ValueType",toString:$estr} ,TFloat: {_hx_name:"TFloat",_hx_index:2,__enum__:"ValueType",toString:$estr} ,TBool: {_hx_name:"TBool",_hx_index:3,__enum__:"ValueType",toString:$estr} ,TObject: {_hx_name:"TObject",_hx_index:4,__enum__:"ValueType",toString:$estr} ,TFunction: {_hx_name:"TFunction",_hx_index:5,__enum__:"ValueType",toString:$estr} ,TClass: ($_=function(c) { return {_hx_index:6,c:c,__enum__:"ValueType",toString:$estr}; },$_._hx_name="TClass",$_.__params__ = ["c"],$_) ,TEnum: ($_=function(e) { return {_hx_index:7,e:e,__enum__:"ValueType",toString:$estr}; },$_._hx_name="TEnum",$_.__params__ = ["e"],$_) ,TUnknown: {_hx_name:"TUnknown",_hx_index:8,__enum__:"ValueType",toString:$estr} }; ValueType.__constructs__ = [ValueType.TNull,ValueType.TInt,ValueType.TFloat,ValueType.TBool,ValueType.TObject,ValueType.TFunction,ValueType.TClass,ValueType.TEnum,ValueType.TUnknown]; var Type = function() { }; $hxClasses["Type"] = Type; Type.__name__ = "Type"; Type.createInstance = function(cl,args) { var ctor = Function.prototype.bind.apply(cl,[null].concat(args)); return new (ctor); }; Type.createEnum = function(e,constr,params) { var f = Reflect.field(e,constr); if(f == null) { throw haxe_Exception.thrown("No such constructor " + constr); } if(Reflect.isFunction(f)) { if(params == null) { throw haxe_Exception.thrown("Constructor " + constr + " need parameters"); } return f.apply(e,params); } if(params != null && params.length != 0) { throw haxe_Exception.thrown("Constructor " + constr + " does not need parameters"); } return f; }; Type.getInstanceFields = function(c) { var a = []; for(var i in c.prototype) a.push(i); HxOverrides.remove(a,"__class__"); HxOverrides.remove(a,"__properties__"); return a; }; Type.typeof = function(v) { switch(typeof(v)) { case "boolean": return ValueType.TBool; case "function": if(v.__name__ || v.__ename__) { return ValueType.TObject; } return ValueType.TFunction; case "number": if(Math.ceil(v) == v % 2147483648.0) { return ValueType.TInt; } return ValueType.TFloat; case "object": if(v == null) { return ValueType.TNull; } var e = v.__enum__; if(e != null) { return ValueType.TEnum($hxEnums[e]); } var c = js_Boot.getClass(v); if(c != null) { return ValueType.TClass(c); } return ValueType.TObject; case "string": return ValueType.TClass(String); case "undefined": return ValueType.TNull; default: return ValueType.TUnknown; } }; Type.enumParameters = function(e) { var enm = $hxEnums[e.__enum__]; var params = enm.__constructs__[e._hx_index].__params__; if(params != null) { var _g = []; var _g1 = 0; while(_g1 < params.length) { var p = params[_g1]; ++_g1; _g.push(e[p]); } return _g; } else { return []; } }; var apptimize_ABTApptimizeVariableType = $hxEnums["apptimize.ABTApptimizeVariableType"] = { __ename__:"apptimize.ABTApptimizeVariableType",__constructs__:null ,Invalid: {_hx_name:"Invalid",_hx_index:0,__enum__:"apptimize.ABTApptimizeVariableType",toString:$estr} ,String: {_hx_name:"String",_hx_index:1,__enum__:"apptimize.ABTApptimizeVariableType",toString:$estr} ,Double: {_hx_name:"Double",_hx_index:2,__enum__:"apptimize.ABTApptimizeVariableType",toString:$estr} ,Integer: {_hx_name:"Integer",_hx_index:3,__enum__:"apptimize.ABTApptimizeVariableType",toString:$estr} ,Boolean: {_hx_name:"Boolean",_hx_index:4,__enum__:"apptimize.ABTApptimizeVariableType",toString:$estr} ,Array: {_hx_name:"Array",_hx_index:5,__enum__:"apptimize.ABTApptimizeVariableType",toString:$estr} ,Dictionary: {_hx_name:"Dictionary",_hx_index:6,__enum__:"apptimize.ABTApptimizeVariableType",toString:$estr} }; apptimize_ABTApptimizeVariableType.__constructs__ = [apptimize_ABTApptimizeVariableType.Invalid,apptimize_ABTApptimizeVariableType.String,apptimize_ABTApptimizeVariableType.Double,apptimize_ABTApptimizeVariableType.Integer,apptimize_ABTApptimizeVariableType.Boolean,apptimize_ABTApptimizeVariableType.Array,apptimize_ABTApptimizeVariableType.Dictionary]; var apptimize_ABTApptimizeVariable = function() { }; $hxClasses["apptimize.ABTApptimizeVariable"] = apptimize_ABTApptimizeVariable; apptimize_ABTApptimizeVariable.__name__ = "apptimize.ABTApptimizeVariable"; apptimize_ABTApptimizeVariable.getValue = function(params,name,type,nestedType) { apptimize_ABTDataStore._checkForUpdatedMetadataIfNecessary(); var store = apptimize_ABTDataStore.sharedInstance(); var metadata = store.getMetaData(params.appkey); if(metadata == null) { return null; } var env = store.makeEnvironment(params); var alterations = metadata.selectAlterationsIntoArray(env); var _g = 0; while(_g < alterations.length) { var alteration = alterations[_g]; ++_g; if(alteration.getKey() == name) { var valueAlteration = ((alteration) instanceof apptimize_models_ABTValueAlteration) ? alteration : null; if(valueAlteration == null) { apptimize_ABTLogger.v("Alteration found for key \"" + alteration.getKey() + "\" isn't a value alteration.",{ fileName : "src/apptimize/ABTApptimizeVariable.hx", lineNumber : 41, className : "apptimize.ABTApptimizeVariable", methodName : "getValue"}); return null; } var alterationType = apptimize_ABTApptimizeVariable.apptimizeVariableTypeForString(valueAlteration.getType()); var alterationNestedType = null; if(valueAlteration.getNestedType() != null) { alterationNestedType = apptimize_ABTApptimizeVariable.apptimizeVariableTypeForString(valueAlteration.getNestedType()); } if(alterationType == type && alterationNestedType == nestedType) { var variant = valueAlteration.getVariant(); apptimize_ABTDataStore.sharedInstance().incrementVariantRunCount(params,variant); if(!valueAlteration.useDefaultValue()) { return valueAlteration.getValue(); } } } } apptimize_ABTLogger.v("No alteration found for dynamic variable \"" + name + "\".",{ fileName : "src/apptimize/ABTApptimizeVariable.hx", lineNumber : 63, className : "apptimize.ABTApptimizeVariable", methodName : "getValue"}); return null; }; apptimize_ABTApptimizeVariable.apptimizeVariableTypeForString = function(stringType) { var type = stringType.toLowerCase(); if(type == "string") { return apptimize_ABTApptimizeVariableType.String; } else if(type == "double") { return apptimize_ABTApptimizeVariableType.Double; } else if(type == "int") { return apptimize_ABTApptimizeVariableType.Integer; } else if(type == "boolean") { return apptimize_ABTApptimizeVariableType.Boolean; } else if(type == "list") { return apptimize_ABTApptimizeVariableType.Array; } else if(type == "dictionary") { return apptimize_ABTApptimizeVariableType.Dictionary; } else { return apptimize_ABTApptimizeVariableType.Invalid; } }; var apptimize_util_PlatformLock = function() { }; $hxClasses["apptimize.util.PlatformLock"] = apptimize_util_PlatformLock; apptimize_util_PlatformLock.__name__ = "apptimize.util.PlatformLock"; apptimize_util_PlatformLock.__isInterface__ = true; apptimize_util_PlatformLock.prototype = { acquire: null ,release: null ,__class__: apptimize_util_PlatformLock }; var apptimize_util_DefaultPlatformLock = function() { }; $hxClasses["apptimize.util.DefaultPlatformLock"] = apptimize_util_DefaultPlatformLock; apptimize_util_DefaultPlatformLock.__name__ = "apptimize.util.DefaultPlatformLock"; apptimize_util_DefaultPlatformLock.__interfaces__ = [apptimize_util_PlatformLock]; apptimize_util_DefaultPlatformLock.prototype = { acquire: function() { return true; } ,release: function() { return; } ,hxUnserialize: function(u) { } ,__class__: apptimize_util_DefaultPlatformLock }; var apptimize_util_ABTDataLock = function() { }; $hxClasses["apptimize.util.ABTDataLock"] = apptimize_util_ABTDataLock; apptimize_util_ABTDataLock.__name__ = "apptimize.util.ABTDataLock"; apptimize_util_ABTDataLock.getNewLock = function(lockName) { return new apptimize_util_DefaultPlatformLock(); }; var apptimize_ABTDataStore = function() { this.sdkParameters = new apptimize_models_ABTSdkParameters(null); this.resultDispatchQueue = new apptimize_util_ABTDispatch("Results Logging Dispatch Queue"); this.resultDispatchQueue.start(); this.newMdFetcher = new apptimize_api_ABTSecondaryValuesClient(); this.propChangeFetcher = new apptimize_api_ABTSecondaryValuesClient(); this.metaDataCache = new haxe_ds_StringMap(); }; $hxClasses["apptimize.ABTDataStore"] = apptimize_ABTDataStore; apptimize_ABTDataStore.__name__ = "apptimize.ABTDataStore"; apptimize_ABTDataStore.sharedInstance = function() { if(apptimize_ABTDataStore._instance == null) { apptimize_ABTDataStore._instance = new apptimize_ABTDataStore(); } return apptimize_ABTDataStore._instance; }; apptimize_ABTDataStore.clear = function() { apptimize_support_persistence_ABTPersistence.clear(); apptimize_ABTDataStore._instance = null; }; apptimize_ABTDataStore.shutdown = function() { apptimize_ABTDataStore._instance = null; apptimize_ABTDataStore.appKey = null; apptimize_ABTDataStore.serverGuid = null; }; apptimize_ABTDataStore._getLastCheckTime = function() { var lastCheckTime = apptimize_support_persistence_ABTPersistence.loadString(apptimize_support_persistence_ABTPersistence.kMetadataLastCheckTimeKey); if(lastCheckTime != null) { return parseFloat(lastCheckTime); } return -10000.0; }; apptimize_ABTDataStore._updateLastCheckTime = function(checkTime) { apptimize_support_persistence_ABTPersistence.saveString(apptimize_support_persistence_ABTPersistence.kMetadataLastCheckTimeKey,checkTime == null ? "null" : "" + checkTime); }; apptimize_ABTDataStore._resetCheckTimeIfNeeded = function() { var resetClock = false; apptimize_util_ABTDataLock.CHECK_TIME_LOCK.acquire(); try { var timeout = parseFloat(apptimize_support_properties_ABTConfigProperties.sharedInstance().valueForProperty(apptimize_support_properties_ABTConfigProperties.METADATA_POLLING_INTERVAL_MS_KEY)); var currentTime = new Date().getTime(); var timeSinceLastCheck = currentTime - apptimize_ABTDataStore._getLastCheckTime(); if(timeSinceLastCheck > timeout) { apptimize_ABTDataStore._updateLastCheckTime(currentTime); resetClock = true; } } catch( _g ) { haxe_NativeStackTrace.lastError = _g; var e = haxe_Exception.caught(_g).unwrap(); apptimize_util_ABTDataLock.CHECK_TIME_LOCK.release(); throw haxe_Exception.thrown(e); } apptimize_util_ABTDataLock.CHECK_TIME_LOCK.release(); return resetClock; }; apptimize_ABTDataStore._getLastSubmitTime = function() { var lastSubmitCheckTime = apptimize_support_persistence_ABTPersistence.loadString(apptimize_support_persistence_ABTPersistence.kResultLastSubmitTimeKey); if(lastSubmitCheckTime != null) { return parseFloat(lastSubmitCheckTime); } return -10000.0; }; apptimize_ABTDataStore._updateLastSubmitTime = function(checkTime) { apptimize_support_persistence_ABTPersistence.saveString(apptimize_support_persistence_ABTPersistence.kResultLastSubmitTimeKey,checkTime == null ? "null" : "" + checkTime); }; apptimize_ABTDataStore.getAppKey = function() { return apptimize_ABTDataStore.appKey; }; apptimize_ABTDataStore.checkForUpdatedMetaData = function(checkImmediately) { if(checkImmediately == null) { checkImmediately = false; } if(apptimize_ABTDataStore.shouldDisable()) { apptimize_ABTLogger.w("This SDK version disabled; not checking for updated metadata",{ fileName : "src/apptimize/ABTDataStore.hx", lineNumber : 223, className : "apptimize.ABTDataStore", methodName : "checkForUpdatedMetaData"}); return; } apptimize_ABTLogger.v("Checking for updated metadata...",{ fileName : "src/apptimize/ABTDataStore.hx", lineNumber : 226, className : "apptimize.ABTDataStore", methodName : "checkForUpdatedMetaData"}); if(apptimize_Apptimize._isInitialized() && (apptimize_ABTDataStore._resetCheckTimeIfNeeded() || checkImmediately)) { apptimize_api_ABTApiClient.sharedInstance().downloadMetaDataForKey(apptimize_ABTDataStore.getAppKey(),apptimize_ABTDataStore.sharedInstance()._getCurrentEtag(apptimize_ABTDataStore.getAppKey())); } }; apptimize_ABTDataStore._checkForUpdatedMetadataIfNecessary = function() { if(!apptimize_api_ABTMetadataPoller.isPolling() && apptimize_support_pr