diff --git a/dist/INTEGRITY b/dist/INTEGRITY index c130395..25f3862 100644 --- a/dist/INTEGRITY +++ b/dist/INTEGRITY @@ -1 +1 @@ -sha384-6ypaiRbayulK9Pc5tI+DbtfndaV381c5P1cjXBG9Z37D4lCW87Oxb/d81aXLKGiK \ No newline at end of file +sha384-WE6fJqvcE0mjcC/fPYooIQAOhsHpTDVYjC52i6Asn3LECEpjHyI5zUwD8/5esthg \ No newline at end of file diff --git a/dist/adjust-latest.js b/dist/adjust-latest.js index 063ead7..05ca403 100644 --- a/dist/adjust-latest.js +++ b/dist/adjust-latest.js @@ -137,6 +137,47 @@ function _objectWithoutProperties(source, excluded) { } return target; } +;// CONCATENATED MODULE: ./src/sdk/constants.ts +var SECOND = 1000; +var MINUTE = SECOND * 60; +var HOUR = MINUTE * 60; +var DAY = HOUR * 24; +var DISABLE_REASONS = /*#__PURE__*/function (DISABLE_REASONS) { + DISABLE_REASONS["REASON_GENERAL"] = "general"; + DISABLE_REASONS["REASON_GDPR"] = "gdpr"; + return DISABLE_REASONS; +}({}); +var HTTP_ERRORS = { + 'TRANSACTION_ERROR': 'XHR transaction failed due to an error', + 'SERVER_MALFORMED_RESPONSE': 'Response from server is malformed', + 'SERVER_INTERNAL_ERROR': 'Internal error occurred on the server', + 'SERVER_CANNOT_PROCESS': 'Server was not able to process the request, probably due to error coming from the client', + 'NO_CONNECTION': 'No internet connectivity', + 'SKIP': 'Skipping slower attempt', + 'MISSING_URL': 'Url is not provided' +}; +var STORAGE_TYPES = /*#__PURE__*/function (STORAGE_TYPES) { + STORAGE_TYPES["NO_STORAGE"] = "noStorage"; + STORAGE_TYPES["INDEXED_DB"] = "indexedDB"; + STORAGE_TYPES["LOCAL_STORAGE"] = "localStorage"; + return STORAGE_TYPES; +}({}); +var ENDPOINTS = { + default: 'adjust.com', + india: 'adjust.net.in', + china: 'adjust.world', + world: 'adjust.world', + EU: 'eu.adjust.com', + TR: 'tr.adjust.com', + US: 'us.adjust.com' +}; +var BASE_URL_PREFIX = 'https://app.'; +var GDPR_URL_PREFIX = 'https://gdpr.'; +var BASE_URL_NO_SUB_DOMAIN_PREFIX = 'https://'; +var PUB_SUB_EVENTS = { + WEB_UUID_CREATED: 'activity:web_uuid', + ATTRIBUTION_RECEIVED: 'activity:attribution' +}; ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; @@ -197,84 +238,6 @@ function _nonIterableRest() { function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js - -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return _arrayLikeToArray(arr); -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js -function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js - - - - -function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); -} -;// CONCATENATED MODULE: ./src/sdk/constants.js -var SECOND = 1000; -var MINUTE = SECOND * 60; -var HOUR = MINUTE * 60; -var DAY = HOUR * 24; -var REASON_GENERAL = 'general'; -var REASON_GDPR = 'gdpr'; -var HTTP_ERRORS = { - 'TRANSACTION_ERROR': 'XHR transaction failed due to an error', - 'SERVER_MALFORMED_RESPONSE': 'Response from server is malformed', - 'SERVER_INTERNAL_ERROR': 'Internal error occurred on the server', - 'SERVER_CANNOT_PROCESS': 'Server was not able to process the request, probably due to error coming from the client', - 'NO_CONNECTION': 'No internet connectivity', - 'SKIP': 'Skipping slower attempt', - 'MISSING_URL': 'Url is not provided' -}; -var STORAGE_TYPES = { - NO_STORAGE: 'noStorage', - INDEXED_DB: 'indexedDB', - LOCAL_STORAGE: 'localStorage' -}; -var ENDPOINTS = { - default: { - endpointName: 'Default', - app: 'https://app.adjust.com', - gdpr: 'https://gdpr.adjust.com' - }, - india: { - endpointName: 'Indian', - app: 'https://app.adjust.net.in', - gdpr: 'https://gdpr.adjust.net.in' - }, - china: { - endpointName: 'Chinese', - app: 'https://app.adjust.world', - gdpr: 'https://gdpr.adjust.world' - }, - EU: { - endpointName: 'EU', - app: 'https://app.eu.adjust.com', - gdpr: 'https://gdpr.eu.adjust.com' - }, - TR: { - endpointName: 'TR', - app: 'https://app.tr.adjust.com', - gdpr: 'https://gdpr.tr.adjust.com' - }, - US: { - endpointName: 'US', - app: 'https://app.us.adjust.com', - gdpr: 'https://gdpr.us.adjust.com' - } -}; -var PUB_SUB_EVENTS = { - WEB_UUID_CREATED: 'activity:web_uuid', - ATTRIBUTION_RECEIVED: 'activity:attribution' -}; ;// CONCATENATED MODULE: ./src/sdk/utilities.ts @@ -438,7 +401,7 @@ function isLocalStorageSupported() /*: boolean*/{ |}*/ var Globals = { namespace: "adjust-sdk" || 0, - version: "5.6.0" || 0, + version: "5.7.0" || 0, env: "production" }; /* harmony default export */ const globals = (Globals); @@ -586,142 +549,80 @@ var Logger = { error: _applyLevel('error', LEVEL_ERROR) }; /* harmony default export */ const logger = (Logger); -;// CONCATENATED MODULE: ./src/sdk/config.js - +;// CONCATENATED MODULE: ./src/sdk/config.ts -/*:: // -import { type BaseParamsT, type CustomConfigT, type InitOptionsT, type BaseParamsListT, type BaseParamsMandatoryListT, type CustomConfigListT } from './types';*/ +/** Base parameters set by client */ -/** - * Base parameters set by client - * - app token - * - environment - * - default tracker - * - external device ID - * - * @type {Object} - * @private - */ -var _baseParams /*: BaseParamsT*/ = {}; - -/** - * Custom config set by client - * - url override - * - event deduplication list limit - * - * @type {Object} - * @private - */ -var _customConfig /*: CustomConfigT*/ = {}; - -/** - * Mandatory fields to set for sdk initialization - * - * @type {string[]} - * @private - */ -var _mandatory /*: BaseParamsMandatoryListT*/ = ['appToken', 'environment']; +/** Custom config set by client */ +/*:: export type InitOptions = BaseParams & CustomConfig & { + attributionCallback: (eventName: string, attribution: Attribution) => unknown +}*/ +var _baseParams /*: BaseParams | null*/ = null; +var _customConfig /*: CustomConfig | null*/ = null; -/** - * Allowed params to be sent with each request - * - * @type {string[]} - * @private - */ -var _allowedParams /*: BaseParamsListT*/ = [].concat(_mandatory, ['defaultTracker', 'externalDeviceId']); +/** Mandatory fields to set for sdk initialization */ +var _mandatory /*: Array<(keyof MandatoryParams)>*/ = ['appToken', 'environment']; -/** - * Allowed configuration overrides - * - * @type {string[]} - * @private - */ -var _allowedConfig /*: CustomConfigListT*/ = ['customUrl', 'dataResidency', 'urlStrategy', 'eventDeduplicationListLimit', 'namespace']; +/** Allowed params to be sent with each request */ +var _allowedParams /*: Array<(keyof BaseParams)>*/ = [].concat(_mandatory, ['defaultTracker', 'externalDeviceId']); -/** - * Global configuration object used across the sdk - * - * @type {{ - * namespace: string, - * version: string, - * sessionWindow: number, - * sessionTimerWindow: number, - * requestValidityWindow: number - * }} - */ -var _baseConfig = { - sessionWindow: 30 * MINUTE, - sessionTimerWindow: 60 * SECOND, - requestValidityWindow: 28 * DAY -}; +/** Allowed configuration overrides */ +var _allowedConfig /*: Array<(keyof CustomConfig)>*/ = ['customUrl', 'dataResidency', 'urlStrategy', 'eventDeduplicationListLimit', 'namespace']; /** * Check of configuration has been initialized - * - * @returns {boolean} */ function isInitialised() /*: boolean*/{ return _mandatory.reduce(function (acc, key) { - return acc && !!_baseParams[key]; + return acc && !!_baseParams && !!_baseParams[key]; }, true); } -/** - * Get base params set by client - * - * @returns {Object} - */ -function getBaseParams() /*: BaseParamsT*/{ - return _objectSpread2({}, _baseParams); -} - /** * Set base params and custom config for the sdk to run - * - * @param {Object} options */ -function set(options /*: InitOptionsT*/) /*: void*/{ +function set(options /*: InitOptions*/) /*: void*/{ if (hasMissing(options)) { return; } - var filteredParams = [].concat(_toConsumableArray(_allowedParams), _allowedConfig).filter(function (key) { + _baseParams = _allowedParams.filter(function (key) { + return !!options[key]; + }).map(function (key) { + return [key, options[key]]; + }).reduce(function (acc, item) { + return reducer(acc, item); + }, {}); + _customConfig = _allowedConfig.filter(function (key) { return !!options[key]; }).map(function (key) { return [key, options[key]]; - }); - _baseParams = filteredParams.filter(function (_ref) { - var _ref2 = _slicedToArray(_ref, 1), - key = _ref2[0]; - return _allowedParams.indexOf(key) !== -1; - }).reduce(reducer, {}); - _customConfig = filteredParams.filter(function (_ref3) { - var _ref4 = _slicedToArray(_ref3, 1), - key = _ref4[0]; - return _allowedConfig.indexOf(key) !== -1; }).reduce(reducer, {}); } +/** + * Get base params set by client + */ +function getBaseParams() /*: Partial*/{ + return _baseParams ? _objectSpread2({}, _baseParams) // intentionally returns a copy + : {}; +} + /** * Get custom config set by client - * - * @returns {Object} */ -function getCustomConfig() /*: CustomConfigT*/{ - return _objectSpread2({}, _customConfig); +function getCustomConfig() /*: CustomConfig*/{ + return _customConfig ? _objectSpread2({}, _customConfig) // intentionally returns a copy + : {}; } /** * Check if there are missing mandatory parameters - * - * @param {Object} params - * @returns {boolean} - * @private */ -function hasMissing(params /*: BaseParamsT*/) /*: boolean*/{ +function hasMissing(params /*: BaseParams*/) /*: boolean*/{ var missing = _mandatory.filter(function (value) { return !params[value]; }); @@ -736,18 +637,21 @@ function hasMissing(params /*: BaseParamsT*/) /*: boolean*/{ * Restore config to its default state */ function destroy() /*: void*/{ - _baseParams = {}; - _customConfig = {}; + _baseParams = null; + _customConfig = null; } -var Config = _objectSpread2(_objectSpread2({}, _baseConfig), {}, { +var Config = { + sessionWindow: 30 * MINUTE, + sessionTimerWindow: 60 * SECOND, + requestValidityWindow: 28 * DAY, set: set, getBaseParams: getBaseParams, getCustomConfig: getCustomConfig, isInitialised: isInitialised, hasMissing: hasMissing, destroy: destroy -}); -/* harmony default export */ const config = (Config); +}; +/* harmony default export */ const sdk_config = (Config); ;// CONCATENATED MODULE: ./src/sdk/storage/scheme.ts @@ -907,7 +811,7 @@ var _preferencesScheme /*: StoreOptionsOptionalKey*/ = { keys: { reason: { key: 'r', - values: _defineProperty({}, REASON_GENERAL, 1) + values: _defineProperty({}, DISABLE_REASONS.REASON_GENERAL, 1) }, pending: { key: 'p', @@ -923,7 +827,7 @@ var _preferencesScheme /*: StoreOptionsOptionalKey*/ = { keys: { reason: { key: 'r', - values: _defineProperty(_defineProperty({}, REASON_GENERAL, 1), REASON_GDPR, 2) + values: _defineProperty(_defineProperty({}, DISABLE_REASONS.REASON_GENERAL, 1), DISABLE_REASONS.REASON_GDPR, 2) }, pending: { key: 'p', @@ -1618,7 +1522,7 @@ function _getTimeSpent() /*: number*/{ */ function _getSessionLength() /*: number*/{ var lastActive = _activityState.lastActive; - var withinWindow = timePassed(lastActive, Date.now()) < config.sessionWindow; + var withinWindow = timePassed(lastActive, Date.now()) < sdk_config.sessionWindow; var withOffset = _active || !_active && withinWindow; return (_activityState.sessionLength || 0) + (withOffset ? _getOffset() : 0); } @@ -1985,39 +1889,21 @@ var QuickStorage = /*#__PURE__*/function () { }]); }(); /* harmony default export */ const quick_storage = (new QuickStorage()); -;// CONCATENATED MODULE: ./src/sdk/preferences.js - +;// CONCATENATED MODULE: ./src/sdk/preferences.ts -/*:: type SdkDisabledT = {| - reason: REASON_GENERAL | REASON_GDPR, - pending: boolean -|}*/ -/*:: type ThirdPartySharingDisabledT = {| - reason: REASON_GENERAL, - pending: boolean -|}*/ -/*:: type PreferencesT = {| - thirdPartySharingDisabled?: ?ThirdPartySharingDisabledT, - sdkDisabled?: ?SdkDisabledT -|}*/ /** * Name of the store used by preferences - * - * @type {string} - * @private */ var _storeName /*: string*/ = storage_scheme.preferences.name; /** * Local reference to be used for recovering preserved state - * - * @type {Object} - * @private */ -var _preferences /*: ?PreferencesT*/ = _getPreferences(); +var _preferences /*: PreferencesT | null*/ = null; +_preferences = _getPreferences(); /** * Get preferences stored in the localStorage @@ -2025,7 +1911,7 @@ var _preferences /*: ?PreferencesT*/ = _getPreferences(); * @returns {Object} * @private */ -function _getPreferences() /*: ?PreferencesT*/{ +function _getPreferences() /*: PreferencesT | null*/{ if (!_preferences) { _setPreferences(); } @@ -2046,9 +1932,9 @@ function _setPreferences() /*: void*/{ * * @returns {Object|null} */ -function getDisabled() /*: ?SdkDisabledT*/{ +function getDisabled() /*: SdkDisabledT | null*/{ var preferences = _getPreferences(); - return preferences ? preferences.sdkDisabled : null; + return preferences && preferences.sdkDisabled || null; } /** @@ -2056,7 +1942,7 @@ function getDisabled() /*: ?SdkDisabledT*/{ * * @param {Object|null} value */ -function setDisabled(value /*: ?SdkDisabledT*/) /*: void*/{ +function setDisabled(value /*: SdkDisabledT | null*/) /*: void*/{ var sdkDisabled = value ? _objectSpread2({}, value) : null; quick_storage.stores[_storeName] = _objectSpread2(_objectSpread2({}, _getPreferences()), {}, { sdkDisabled: sdkDisabled @@ -2064,37 +1950,12 @@ function setDisabled(value /*: ?SdkDisabledT*/) /*: void*/{ _setPreferences(); } -/** - * Get current third-party-sharing disabled state - * - * @returns {Object} - * @private - */ -function getThirdPartySharing() /*: ?ThirdPartySharingDisabledT*/{ - var preferences = _getPreferences(); - return preferences ? preferences.thirdPartySharingDisabled : null; -} - -/** - * Set current third-party-sharing disabled state - * - * @param {Object=} value - * @private - */ -function setThirdPartySharing(value /*: ?ThirdPartySharingDisabledT*/) /*: void*/{ - var thirdPartySharingDisabled = value ? _objectSpread2({}, value) : null; - quick_storage.stores[_storeName] = _objectSpread2(_objectSpread2({}, _getPreferences()), {}, { - thirdPartySharingDisabled: thirdPartySharingDisabled - }); - _setPreferences(); -} - /** * Reload current preferences from localStorage if changed outside of current scope (e.g. tab) */ function reload() /*: void*/{ var stored /*: PreferencesT*/ = quick_storage.stores[_storeName] || {}; - var sdkDisabled /*: ?SdkDisabledT*/ = (_preferences || {}).sdkDisabled || null; + var sdkDisabled /*: SdkDisabledT | null*/ = (_preferences || {}).sdkDisabled || null; if (stored.sdkDisabled && !sdkDisabled) { publish('sdk:shutdown'); } @@ -2105,7 +1966,7 @@ function reload() /*: void*/{ * Recover preferences from memory if storage was lost */ function recover() /*: void*/{ - var stored /*: ?PreferencesT*/ = quick_storage.stores[_storeName]; + var stored /*: PreferencesT*/ = quick_storage.stores[_storeName]; if (!stored) { quick_storage.stores[_storeName] = _objectSpread2({}, _preferences); } @@ -2931,6 +2792,27 @@ _defineProperty(IndexedDBWrapper, "dbValidationName", 'validate-db-openable'); */ _defineProperty(IndexedDBWrapper, "isSupportedPromise", null); +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + + + + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} ;// CONCATENATED MODULE: ./src/sdk/storage/localstorage.ts @@ -3928,6 +3810,9 @@ function _encodeParam(_ref3 /*:: */) /*: string*/{ if (isObject(value)) { encodedValue = encodeURIComponent(JSON.stringify(value) || ''); } + if (key === 'granular_third_party_sharing_options' || key === 'partner_sharing_settings') { + return [encodedKey, encodedValue].join(encodeURIComponent('=')); + } return [encodedKey, encodedValue].join('='); } @@ -3961,7 +3846,7 @@ function _encodeParams(params /*: ParamsWithAttemptsT*/, defaultParams /*: Defau return "_".concat($1.toLowerCase()); }); }; - var allParams = entries(_objectSpread2(_objectSpread2(_objectSpread2({}, config.getBaseParams()), defaultParams), params)).map(function (_ref5 /*:: */) { + var allParams = entries(_objectSpread2(_objectSpread2(_objectSpread2({}, sdk_config.getBaseParams()), defaultParams), params)).map(function (_ref5 /*:: */) { var _ref6 = _slicedToArray(_ref5 /*:: */, 2), key = _ref6[0], value = _ref6[1]; @@ -4125,7 +4010,6 @@ function _interceptSuccess(result /*: HttpSuccessResponseT*/, url) /*: HttpSucce var isGdprRequest = isRequest(url, 'gdpr_forget_device'); var isAttributionRequest = isRequest(url, 'attribution'); var isSessionRequest = isRequest(url, 'session'); - var isThirdPartySharingOptOutRequest = isRequest(url, 'disable_third_party_sharing'); var optedOut = result.tracking_state === 'opted_out'; if (!isGdprRequest && optedOut) { publish('sdk:gdpr-forget-me'); @@ -4137,10 +4021,6 @@ function _interceptSuccess(result /*: HttpSuccessResponseT*/, url) /*: HttpSucce if (isSessionRequest) { publish('session:finished', result); } - if (isThirdPartySharingOptOutRequest) { - publish('sdk:third-party-sharing-opt-out'); - return result; - } return result; } @@ -4332,11 +4212,82 @@ function listeners_destroy() /*: void*/{ off(window, 'offline', _handleOffline); } +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; + if (!it) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + var F = function F() {}; + return { + s: F, + n: function n() { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function e(_e) { + throw _e; + }, + f: F + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + var normalCompletion = true, + didErr = false, + err; + return { + s: function s() { + it = it.call(o); + }, + n: function n() { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function e(_e2) { + didErr = true; + err = _e2; + }, + f: function f() { + try { + if (!normalCompletion && it["return"] != null) it["return"](); + } finally { + if (didErr) throw err; + } + } + }; +} ;// CONCATENATED MODULE: ./src/sdk/url-strategy.ts + +/*:: export interface UrlStrategyConfig { + /** The country or countries of data residence, or the endpoints to which you want to send SDK traffic. *-/ + domains: Array; + + /** Whether the source should prefix a subdomain. *-/ + useSubdomains: boolean; + + /** Whether the domain should be used for data residency. *-/ + isDataResidency?: boolean; +}*/ +function getDefaultUrlStrategyConfig(endpoints /*: Record*/) { + return { + domains: [endpoints.default, endpoints.world], + useSubdomains: true, + isDataResidency: false + }; +} var UrlStrategy = /*#__PURE__*/function (UrlStrategy) { UrlStrategy["Default"] = "default"; UrlStrategy["India"] = "india"; @@ -4354,53 +4305,111 @@ function incorrectOptionIgnoredMessage(higherPriority /*: string*/, lowerPriorit } /** - * Returns a map of base URLs or a list of endpoint names depending on SDK configuration + * In case if deprecated parameters or no urlStrategy provided returns the most appropriate UrlStrategyConfig, + * and `null` otherwise */ -function getEndpointPreference() /*: BaseUrlsMap | EndpointName[]*/{ - var _Config$getCustomConf = config.getCustomConfig(), +function transfromDeprecatedParamsToUrlStrategyConfig(endpoints /*: Record*/) /*: UrlStrategyConfig | null*/{ + var _Config$getCustomConf = sdk_config.getCustomConfig(), customUrl = _Config$getCustomConf.customUrl, urlStrategy = _Config$getCustomConf.urlStrategy, dataResidency = _Config$getCustomConf.dataResidency; if (customUrl) { // If custom URL is set then send all requests there + logger.warn('customUrl is deprecated, use urlStrategy instead'); if (dataResidency || urlStrategy) { incorrectOptionIgnoredMessage('customUrl', dataResidency ? 'dataResidency' : 'urlStrategy'); } return { - app: customUrl, - gdpr: customUrl + domains: [customUrl], + useSubdomains: false, + isDataResidency: false }; } if (dataResidency && urlStrategy) { incorrectOptionIgnoredMessage('dataResidency', 'urlStrategy'); } if (dataResidency) { - return [dataResidency]; + logger.warn('dataResidency is deprecated, use urlStrategy instead'); + return { + domains: [endpoints[dataResidency]], + useSubdomains: true, + isDataResidency: true + }; } - if (urlStrategy === UrlStrategy.India) { - return [UrlStrategy.India, UrlStrategy.Default]; + if (typeof urlStrategy === 'string') { + logger.warn('urlStrategy string literals (\'china\' and \'india\') are deprected, use UrlStartegyConfig instead'); + if (urlStrategy === UrlStrategy.India) { + return { + domains: [endpoints.india, endpoints.default], + useSubdomains: true, + isDataResidency: false + }; + } + if (urlStrategy === UrlStrategy.China) { + return { + domains: [endpoints.china, endpoints.default], + useSubdomains: true, + isDataResidency: false + }; + } } - if (urlStrategy === UrlStrategy.China) { - return [UrlStrategy.China, UrlStrategy.Default]; + if (!urlStrategy) { + return getDefaultUrlStrategyConfig(endpoints); } - return [UrlStrategy.Default, UrlStrategy.India, UrlStrategy.China]; + return null; } -var endpointMap /*: Record*/ = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, UrlStrategy.Default, ENDPOINTS.default), UrlStrategy.India, ENDPOINTS.india), UrlStrategy.China, ENDPOINTS.china), DataResidency.EU, ENDPOINTS.EU), DataResidency.TR, ENDPOINTS.TR), DataResidency.US, ENDPOINTS.US); -function getPreferredUrls(endpoints /*: Partial>*/) /*: BaseUrlsMap[]*/{ - var preference = getEndpointPreference(); - if (!Array.isArray(preference)) { - return [preference]; - } else { - var res = preference.map(function (strategy) { - return endpoints[strategy] || null; - }).filter(function (i) { - return /*: i is BaseUrlsMap*/!!i; - }); - return res; + +/** + * Checks if passed UrlStrategyConfig is valid and returns it, returns `DEFAULT_URL_STRATEGY_CONFIG` otherwise + */ +function validateUrlStrategyConfig(endpoints /*: Record*/) /*: UrlStrategyConfig*/{ + var _Config$getCustomConf2 = sdk_config.getCustomConfig(), + urlStrategy = _Config$getCustomConf2.urlStrategy; + if (urlStrategy && _typeof(urlStrategy) === 'object') { + var config = urlStrategy; + if (!config.domains || !Array.isArray(config.domains) || config.domains.length < 1) { + logger.warn('Invalid urlStartegy: `domains` should be a non-empty array'); + return getDefaultUrlStrategyConfig(endpoints); + } + return { + domains: config.domains, + useSubdomains: !!config.useSubdomains, + isDataResidency: !!config.isDataResidency + }; } + return getDefaultUrlStrategyConfig(endpoints); +} +function getUrlStrategyConfig(endpoints /*: Record*/) /*: UrlStrategyConfig*/{ + return transfromDeprecatedParamsToUrlStrategyConfig(endpoints) || validateUrlStrategyConfig(endpoints); +} +function getPreferredUrls(endpoints /*: Record*/) /*: BaseUrlsMap[]*/{ + var urlStrategyConfig /*: UrlStrategyConfig*/ = getUrlStrategyConfig(endpoints); + var urls = []; + + //if (urlStrategyConfig.isDataResidency) { } + var _iterator = _createForOfIteratorHelper(urlStrategyConfig.domains), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var domain = _step.value; + var map = urlStrategyConfig.useSubdomains ? { + app: "".concat(BASE_URL_PREFIX).concat(domain), + gdpr: "".concat(GDPR_URL_PREFIX).concat(domain) + } : { + app: "".concat(BASE_URL_NO_SUB_DOMAIN_PREFIX).concat(domain), + gdpr: "".concat(BASE_URL_NO_SUB_DOMAIN_PREFIX).concat(domain) + }; + urls.push(map); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + return urls; } function getBaseUrlsIterator() /*: BaseUrlsIterator*/{ - var endpoints /*: Partial>*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : endpointMap; + var endpoints /*: Record*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ENDPOINTS; var _urls = getPreferredUrls(endpoints); var _counter = 0; return { @@ -4920,17 +4929,10 @@ var Request = function Request() { }; }; /* harmony default export */ const request = (Request); -;// CONCATENATED MODULE: ./src/sdk/disable.js +;// CONCATENATED MODULE: ./src/sdk/disable.ts -/*:: type StatusT = 'on' | 'off' | 'paused'*/ -/*:: type ReasonT = REASON_GDPR | REASON_GENERAL*/ -/*:: type PendingT = boolean*/ -/*:: type ReasonMapT = {| - reason: ReasonT, - pending: PendingT -|}*/ /** * Get the disable action name depending on the reason * @@ -4939,7 +4941,7 @@ var Request = function Request() { * @private */ var _disableReason = function _disableReason(reason /*: ReasonT*/) { - return reason === REASON_GDPR ? 'GDPR disable' : 'disable'; + return reason === DISABLE_REASONS.REASON_GDPR ? 'GDPR disable' : 'disable'; }; /** @@ -4974,17 +4976,19 @@ var _logMessages = function _logMessages(reason /*: ReasonT*/) { function _disable(_ref /*:: */, expectedAction /*: 'start' | 'finish'*/) /*: boolean*/{ var reason = _ref /*:: */.reason, pending = _ref /*:: */.pending; - var disabled = getDisabled() || {}; - var action = expectedAction === 'start' && disabled.pending ? 'start' : 'finish'; - var shouldNotStart = expectedAction === 'start' && disabled.reason; - var shouldNotFinish = expectedAction === 'finish' && disabled.reason && !disabled.pending; + var _ref2 = getDisabled() || {}, + savedReason = _ref2.reason, + savedPending = _ref2.pending; + var action = expectedAction === 'start' && savedPending ? 'start' : 'finish'; + var shouldNotStart = expectedAction === 'start' && savedReason; + var shouldNotFinish = expectedAction === 'finish' && savedReason && !savedPending; if (shouldNotStart || shouldNotFinish) { - logger.log(_logMessages(disabled.reason)[action].inProgress); + logger.log(_logMessages(savedReason)[action].inProgress); return false; } logger.log(_logMessages(reason)[action].done); setDisabled({ - reason: reason || REASON_GENERAL, + reason: reason || DISABLE_REASONS.REASON_GENERAL, pending: pending }); return true; @@ -4997,11 +5001,11 @@ function _disable(_ref /*:: */, expectedAction /*: 'start' | 'finish'*/) /*: boo * @param {boolean} pending * @private */ -function disable(reason /*: ?ReasonT*/) /*: boolean*/{ - var pending /*: ?PendingT*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; +function disable(reason /*: ReasonT*/) /*: boolean*/{ + var pending = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; return _disable({ reason: reason, - pending: pending || false + pending: pending }, 'start'); } @@ -5022,12 +5026,13 @@ function finish(reason /*: ReasonT*/) /*: boolean*/{ * Enable sdk if not GDPR forgotten */ function restore() /*: boolean*/{ - var disabled = getDisabled() || {}; - if (disabled.reason === REASON_GDPR) { + var _ref3 = getDisabled() || {}, + reason = _ref3.reason; + if (reason === DISABLE_REASONS.REASON_GDPR) { logger.log('Adjust SDK is disabled due to GDPR-Forget-Me request and it can not be re-enabled'); return false; } - if (!disabled.reason) { + if (!reason) { logger.log('Adjust SDK is already enabled'); return false; } @@ -5045,10 +5050,12 @@ function restore() /*: boolean*/{ * @returns {string} */ function disable_status() /*: StatusT*/{ - var disabled = getDisabled() || {}; - if (disabled.reason === REASON_GENERAL || disabled.reason === REASON_GDPR && !disabled.pending) { + var _ref4 = getDisabled() || {}, + reason = _ref4.reason, + pending = _ref4.pending; + if (reason === DISABLE_REASONS.REASON_GENERAL || reason === DISABLE_REASONS.REASON_GDPR && !pending) { return 'off'; - } else if (disabled.reason === REASON_GDPR && disabled.pending) { + } else if (reason === DISABLE_REASONS.REASON_GDPR && pending) { return 'paused'; } return 'on'; @@ -5088,9 +5095,7 @@ function _intercept(stored /*: ActivityStateMapT*/) /*: InterceptT*/{ }; } if (stored.uuid === 'unknown') { - disable({ - reason: REASON_GDPR - }); + disable(DISABLE_REASONS.REASON_GDPR); activity_state.destroy(); return { exists: true, @@ -5129,9 +5134,11 @@ function start() /*: Promise*/{ _starting = false; return activityState; }); - }).then(function (activityState /*: ActivityStateMapT*/) { + }).then(function (activityState /*: ActivityStateMapT | null*/) { if (activityState) { publish(PUB_SUB_EVENTS.WEB_UUID_CREATED, activityState.uuid); + } else { + publish(PUB_SUB_EVENTS.WEB_UUID_CREATED, 'gdpr_forgotten'); } return activityState; }); @@ -5472,7 +5479,7 @@ function setOffline(state /*: boolean*/) /*: void*/{ * @returns {Promise} */ function _cleanUp() /*: Promise*/{ - var upperBound = Date.now() - config.requestValidityWindow; + var upperBound = Date.now() - sdk_config.requestValidityWindow; return storage.deleteBulk(queue_storeName, upperBound, 'upperBound'); } @@ -5845,7 +5852,7 @@ function _startTimer() /*: void*/{ _idInterval = setInterval(function () { activity_state.updateSessionOffset(); return persist(); - }, config.sessionTimerWindow); + }, sdk_config.sessionTimerWindow); } /** @@ -5902,7 +5909,7 @@ function _checkSession() /*: Promise*/{ var lastInterval = activityState.lastInterval; var isEnqueued = activityState.sessionCount > 0; var currentWindow = lastInterval * SECOND; - if (!isEnqueued || isEnqueued && currentWindow >= config.sessionWindow) { + if (!isEnqueued || isEnqueued && currentWindow >= sdk_config.sessionWindow) { return _trackSession(); } publish('attribution:check'); @@ -6060,7 +6067,7 @@ function attribution_destroy() /*: void*/{ attribution_request.clear(); } -;// CONCATENATED MODULE: ./src/sdk/gdpr-forget-device.js +;// CONCATENATED MODULE: ./src/sdk/gdpr-forget-device.ts @@ -6107,7 +6114,7 @@ function forget(force /*: boolean*/) /*: boolean*/{ logger.log(gdpr_forget_device_logMessages[sdkStatus]); return false; } - if (!config.isInitialised()) { + if (!sdk_config.isInitialised()) { logger.log(gdpr_forget_device_logMessages.pending); return true; } @@ -6125,7 +6132,7 @@ function forget(force /*: boolean*/) /*: boolean*/{ * @returns {boolean} */ function gdpr_forget_device_disable() { - return disable(REASON_GDPR, true); + return disable(DISABLE_REASONS.REASON_GDPR, true); } /** @@ -6134,7 +6141,7 @@ function gdpr_forget_device_disable() { * @returns {boolean} */ function gdpr_forget_device_finish() { - return finish(REASON_GDPR); + return finish(DISABLE_REASONS.REASON_GDPR); } /** @@ -6154,124 +6161,89 @@ function gdpr_forget_device_destroy() /*: void*/{ gdpr_forget_device_request.clear(); } -;// CONCATENATED MODULE: ./src/sdk/third-party-sharing.js +;// CONCATENATED MODULE: ./src/sdk/track-third-party-sharing.ts -/*:: type ThirdPartySharingStatusT = 'pending' | 'on' | 'off'*/ -/** - * Log messages used in different scenarios - * - * @type {Object} - * @private - */ -var third_party_sharing_logMessages = { - running: 'Adjust SDK is running pending third-party sharing opt-out request', - delayed: 'Adjust SDK will run third-party sharing opt-out request after initialisation', - pending: 'Adjust SDK already queued third-party sharing opt-out request', - off: 'Third-party sharing opt-out is already done', - start: { - inProgress: 'Third-party sharing opt-out has already started', - done: 'Third-party sharing opt-out is now started' - }, - finish: { - inProgress: 'Third-party sharing opt-out has already finished', - done: 'Third-party sharing opt-out is now finished' - } -}; -/** - * Get the status of the third-party sharing - * - * @returns {string} - * @private - */ -function _status() /*: ThirdPartySharingStatusT*/{ - var disabled = getThirdPartySharing() || {}; - if (disabled.reason) { - return disabled.pending ? 'pending' : 'off'; - } - return 'on'; -} - -/** - * Request third-party sharing opt-out request - * - * @param {boolean} force - * @returns {boolean} - */ -function optOut(force /*: boolean*/) { - var status = _status(); - if (!force && status !== 'on') { - logger.log(third_party_sharing_logMessages[status]); - return false; +/*:: export interface ThirdPartySharingOptions { + isEnabled: boolean; + granularOptions: Record>; + partnerSharingSettings: Record>; +}*/ +var ThirdPartySharing = /*#__PURE__*/function () { + function ThirdPartySharing(isEnabled /*: boolean*/) { + _classCallCheck(this, ThirdPartySharing); + _defineProperty(this, "_granularOptions", {}); + _defineProperty(this, "_partnerSharingSettings", {}); + if (typeof isEnabled !== 'boolean') { + logger.warn("isEnabled should be boolean, converting ".concat(isEnabled, " results ").concat(!!isEnabled)); + } + this._isEnabled = !!isEnabled; } - if (!config.isInitialised()) { - logger.log(third_party_sharing_logMessages.delayed); - return true; + return _createClass(ThirdPartySharing, [{ + key: "isEnabled", + get: function get() /*: boolean*/{ + return this._isEnabled; + } + }, { + key: "granularOptions", + get: function get() /*: Record>*/{ + return this._granularOptions; + } + }, { + key: "partnerSharingSettings", + get: function get() /*: Record>*/{ + return this._partnerSharingSettings; + } + }, { + key: "addGranularOption", + value: function addGranularOption(partnerName /*: string*/, key /*: string*/, value /*: string*/) { + if (!partnerName || !key || value === undefined) { + logger.error('Cannot add granular option, partnerName, key and value are mandatory'); + return; + } + var pair = _defineProperty({}, key, value); + if (this.granularOptions[partnerName]) { + this.granularOptions[partnerName] = _objectSpread2(_objectSpread2({}, this.granularOptions[partnerName]), pair); + } else { + this.granularOptions[partnerName] = pair; + } + } + }, { + key: "addPartnerSharingSetting", + value: function addPartnerSharingSetting(partnerName /*: string*/, key /*: string*/, value /*: boolean*/) { + if (!partnerName || !key || value === undefined) { + logger.error('Cannot add partner sharing setting, partnerName, key and value are mandatory'); + return; + } + var pair = _defineProperty({}, key, value); + if (this.partnerSharingSettings[partnerName]) { + this.partnerSharingSettings[partnerName] = _objectSpread2(_objectSpread2({}, this.partnerSharingSettings[partnerName]), pair); + } else { + this.partnerSharingSettings[partnerName] = pair; + } + } + }]); +}(); +function trackThirdPartySharing(adjustThirdPartySharing /*: ThirdPartySharingOptions*/) { + if (!adjustThirdPartySharing || adjustThirdPartySharing.isEnabled === undefined) { + logger.error('Can not track third-party sharing without parameters'); + return; } + var params = { + sharing: adjustThirdPartySharing.isEnabled ? 'enable' : 'disable', + granularThirdPartySharingOptions: adjustThirdPartySharing.granularOptions, + partnerSharingSettings: adjustThirdPartySharing.partnerSharingSettings + }; push({ - url: '/disable_third_party_sharing', - method: 'POST' + url: '/third_party_sharing', + method: 'POST', + params: params }); - return true; } - -/** - * Start or finish thrid-party sharing disable process - * - * @param {boolean} pending - * @param {string} expectedAction - * @returns {boolean} - * @private - */ -function third_party_sharing_disable(pending /*: boolean*/, expectedAction /*: 'start' | 'finish'*/) /*: boolean*/{ - var disabled = getThirdPartySharing() || {}; - var action = expectedAction === 'start' && pending ? 'start' : 'finish'; - var shouldNotStart = expectedAction === 'start' && disabled.reason; - var shouldNotFinish = expectedAction === 'finish' && disabled.reason && !disabled.pending; - if (shouldNotStart || shouldNotFinish) { - logger.log(third_party_sharing_logMessages[action].inProgress); - return false; - } - logger.log(third_party_sharing_logMessages[action].done); - setThirdPartySharing({ - reason: REASON_GENERAL, - pending: pending - }); - return true; -} - -/** - * Start the third-party sharing disable process - * - * @returns {boolean} - */ -function sdk_third_party_sharing_disable() /*: boolean*/{ - return third_party_sharing_disable(true, 'start'); -} - -/** - * Finalize the third-party sharing process - * - * @returns {boolean} - */ -function third_party_sharing_finish() { - return third_party_sharing_disable(false, 'finish'); -} - -/** - * Check if there s pending third-party sharing opt-out request - */ -function third_party_sharing_check() /*: void*/{ - if (_status() === 'pending') { - logger.log(third_party_sharing_logMessages.running); - optOut(true); - } -} - ;// CONCATENATED MODULE: ./src/sdk/scheduler.js /*:: type TaskT = {| @@ -6422,7 +6394,7 @@ function _getEventDeduplicationIds() /*: Promise>*/{ * @private */ function _pushEventDeduplicationId(id /*: string*/) /*: Promise*/{ - var customLimit = config.getCustomConfig().eventDeduplicationListLimit; + var customLimit = sdk_config.getCustomConfig().eventDeduplicationListLimit; var limit = customLimit > 0 ? customLimit : DEFAULT_EVENT_DEDUPLICATION_LIST_LIMIT; return storage.count(event_storeName).then(function (count) { var chain = Promise.resolve(); @@ -6618,7 +6590,7 @@ function initSdk() /*: void*/{ logger.error('You already initiated your instance'); return; } - if (config.hasMissing(options)) { + if (sdk_config.hasMissing(options)) { return; } _isInitialising = true; @@ -6788,7 +6760,7 @@ function switchBackToOnlineMode() /*: void*/{ */ function stop() /*: void*/{ var done = disable(); - if (done && config.isInitialised()) { + if (done && sdk_config.isInitialised()) { _shutdown(); } } @@ -6812,17 +6784,35 @@ function gdprForgetMe() /*: void*/{ return; } done = gdpr_forget_device_disable(); - if (done && config.isInitialised()) { + if (done && sdk_config.isInitialised()) { _pause(); } } /** * Disable third party sharing + * + * @deprecated Use {@link trackThirdPartySharing} instead */ function disableThirdPartySharing() /*: void*/{ - _preCheck('disable third-party sharing', _handleDisableThirdPartySharing, { - schedule: true + main_trackThirdPartySharing({ + isEnabled: false + }); +} + +/** + * Track third party sharing + */ +function main_trackThirdPartySharing(adjustThirdPartySharing /*: ThirdPartySharingOptions*/) /*: void*/{ + var callback = function callback() { + return activity_state.waitForWebUUID() // ensure we have web_uuid to be sent with request + .then(function () { + return trackThirdPartySharing(adjustThirdPartySharing); + }); + }; + _preCheck('third-party sharing', callback, { + schedule: false, + optionalInit: true }); } @@ -6841,19 +6831,6 @@ function hideSmartBanner() /*: void*/{ logger.error('function `hideSmartBanner` is deprecated'); } -/** - * Handle third party sharing disable - * - * @private - */ -function _handleDisableThirdPartySharing() /*: void*/{ - var done = optOut(); - if (!done) { - return; - } - sdk_third_party_sharing_disable(); -} - /** * Handle GDPR-Forget-Me response * @@ -6873,7 +6850,7 @@ function _handleGdprForgetMe() /*: void*/{ * @private */ function _isInitialised() /*: boolean*/{ - return _isInitialising || config.isInitialised(); + return _isInitialising || sdk_config.isInitialised(); } /** @@ -6906,7 +6883,7 @@ function _shutdown(async) /*: void*/{ identity_destroy(); listeners_destroy(); storage.destroy(); - config.destroy(); + sdk_config.destroy(); } /** @@ -6933,9 +6910,6 @@ function main_continue(activityState /*: ActivityStateMapT*/) /*: Promise* logger.log("Adjust SDK is starting with web_uuid set to ".concat(activityState.uuid)); var isInstalled = activity_state.current.installed; gdpr_forget_device_check(); - if (!isInstalled) { - third_party_sharing_check(); - } var sdkStatus = disable_status(); var message = function message(rest) { return "Adjust SDK start has been interrupted ".concat(rest); @@ -6968,7 +6942,6 @@ function main_continue(activityState /*: ActivityStateMapT*/) /*: Promise* _isStarted = true; if (isInstalled) { _handleSdkInstalled(); - third_party_sharing_check(); } }); } @@ -7026,14 +6999,13 @@ function _start(options /*: InitOptionsT*/) /*: void*/{ logger.log('Adjust SDK is disabled, can not start the sdk'); return; } - config.set(options); + sdk_config.set(options); register(); subscribe('sdk:installed', _handleSdkInstalled); subscribe('sdk:shutdown', function () { return _shutdown(true); }); subscribe('sdk:gdpr-forget-me', _handleGdprForgetMe); - subscribe('sdk:third-party-sharing-opt-out', third_party_sharing_finish); subscribe('attribution:check', function (e, result) { return check(result); }); @@ -7134,6 +7106,8 @@ var Adjust = { restart: restart, gdprForgetMe: gdprForgetMe, disableThirdPartySharing: disableThirdPartySharing, + trackThirdPartySharing: main_trackThirdPartySharing, + ThirdPartySharing: ThirdPartySharing, initSmartBanner: initSmartBanner, showSmartBanner: showSmartBanner, hideSmartBanner: hideSmartBanner, diff --git a/dist/adjust-latest.min.js b/dist/adjust-latest.min.js index 6b38953..3be11e3 100644 --- a/dist/adjust-latest.min.js +++ b/dist/adjust-latest.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Adjust=t():e.Adjust=t()}(self,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function o(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nyr});var f=1e3,m=60*f,p=60*m,h=24*p,v="general",g="gdpr",y={TRANSACTION_ERROR:"XHR transaction failed due to an error",SERVER_MALFORMED_RESPONSE:"Response from server is malformed",SERVER_INTERNAL_ERROR:"Internal error occurred on the server",SERVER_CANNOT_PROCESS:"Server was not able to process the request, probably due to error coming from the client",NO_CONNECTION:"No internet connectivity",SKIP:"Skipping slower attempt",MISSING_URL:"Url is not provided"},b={NO_STORAGE:"noStorage",INDEXED_DB:"indexedDB",LOCAL_STORAGE:"localStorage"},k={endpointName:"Default",app:"https://app.adjust.com",gdpr:"https://gdpr.adjust.com"},w={endpointName:"Indian",app:"https://app.adjust.net.in",gdpr:"https://gdpr.adjust.net.in"},P={endpointName:"Chinese",app:"https://app.adjust.world",gdpr:"https://gdpr.adjust.world"},S={endpointName:"EU",app:"https://app.eu.adjust.com",gdpr:"https://gdpr.eu.adjust.com"},D={endpointName:"TR",app:"https://app.tr.adjust.com",gdpr:"https://gdpr.tr.adjust.com"},I={endpointName:"US",app:"https://app.us.adjust.com",gdpr:"https://gdpr.us.adjust.com"},x={WEB_UUID_CREATED:"activity:web_uuid",ATTRIBUTION_RECEIVED:"activity:attribution"};function N(e){return!Object.keys(e).length&&e.constructor===Object}function O(e){return"object"===n(e)&&null!==e&&!(e instanceof Array)}function A(e){try{return O(JSON.parse(e))}catch(e){return!1}}function E(e,t,n){function r(e){return Array.isArray(t)?t.every((function(t){return e[t]===n[t]})):e[t]===n}for(var o=0;o0&&void 0!==arguments[0]?arguments[0]:[]).reduce((function(e,t){return a(a({},e),{},o({},t.key,t.value))}),{})}function C(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter((function(t){return-1!==e.indexOf(t)}))}function R(e,t){return new RegExp("\\/".concat(t,"(\\/.*|\\?.*){0,1}$")).test(e)}function T(e,t){var n=l(t,2),r=n[0],i=n[1];return a(a({},e),{},o({},r,i))}function _(e){return Object.keys(e).map((function(t){return[t,e[t]]}))}function B(e){return Object.keys(e).map((function(t){return e[t]}))}function U(e){return O(e)?!N(e):!!e||0===e}function K(){try{var e=(new Date).toString(),t=window.localStorage;t.setItem(e,e);var n=t.getItem(e)===e;return t.removeItem(e),!(!n||!t)}catch(e){return!1}}const L={namespace:"adjust-sdk",version:"5.6.0",env:"production"};var q="error",M="warning",F="info",G="verbose",W=o(o(o(o(o({},"none",-1),q,0),M,1),F,2),G,3),V={log:" ",info:" ",warn:" ",error:""},H={development:G,production:q,test:G},Y=J(),z="";function J(){return H[L.env]||q}function Q(e,t){var n;if(!(W[Y]2?u-2:0),c=2;c2&&void 0!==arguments[2]?arguments[2]:[]).map((function(n){return Ee(e,t,n)}))}function Ce(e,t,n){var r=Se[t][Te(e,Oe.right)],o=r.fields[r.keyPath],i=n instanceof Array?n.slice():[n],a=(fe(o)?o.composite:[r.keyPath]).map((function(e,t){var n=r.fields[e];return Ae(le(n)?n.values:null,i[t])}));return 1===a.length?a[0]:a}function Re(e){return Se.values[e]||e}function Te(e,t){return(Se.storeNames[t][e]||{}).name||e}function _e(e,t){return{name:t.name,message:t.message.replace('"'.concat(e,'"'),Te(e,Oe.right))}}function Be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ue(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:1,n=e+"",r=1;r<=t;r+=1)e0?"-":"+")+Le(Math.floor(Math.abs(t)/60))+Le(Math.abs(t)%60)}(t);return"".concat(n,"T").concat(r,"Z").concat(o)}function Me(e,t){return isNaN(e)||isNaN(t)?0:Math.abs(t-e)}var Fe={},Ge=[];function We(e,t){var n="id"+Math.random().toString(36).substring(2,16),r={id:n,cb:t};return Fe[e]||(Fe[e]=[]),Fe[e].push(r),n}function Ve(e,t){Fe[e]&&Fe[e].forEach((function(n){"function"==typeof n.cb&&Ge.push(setTimeout((function(){return n.cb(e,t)})))}))}var He={},Ye=!1,ze=!1;function Je(){He=Ye?a({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}):{}}function Qe(){Ye&&(He.lastInterval=function(){var e=He.lastActive;if(e)return Math.round(Me(e,Date.now())/f);return-1}(),He.lastActive=Date.now())}function Xe(e){He=a(a({},He),e)}function Ze(){ze=!0}function $e(){var e=He.lastActive;return Math.round(Me(e,Date.now())/f)}function et(){return(He.timeSpent||0)+(ze?$e():0)}function tt(){var e=Me(He.lastActive,Date.now())=0?He.lastInterval:0,n={timeSpent:He.timeSpent||0,sessionLength:He.sessionLength||0,sessionCount:He.sessionCount||1,lastInterval:t||0};return e&&R(e,"event")&&(n.eventCount=He.eventCount),n},updateParams:function(e,t){if(Ye){var n={};n.timeSpent=et(),n.sessionLength=tt(),R(e,"session")&&(n.sessionCount=(He.sessionCount||0)+1),R(e,"event")&&(n.eventCount=(He.eventCount||0)+1),Xe(n),t||Qe()}},updateInstalled:function(){Ye&&(He.installed||Xe({installed:!0}))},updateSessionOffset:nt,updateSessionLength:function(){Ye&&(Xe({sessionLength:tt()}),Qe())},resetSessionOffset:function(){Ye&&Xe({timeSpent:0,sessionLength:0})},updateLastActive:Qe,destroy:function(){He={},Ye=!1,ze=!1},getAttribution:function(){return Ye?He.attribution?He.attribution:(Z.log("No attribution data yet"),null):null},getWebUUID:function(){return Ye?He.uuid:null},waitForAttribution:function(){return He.attribution?Promise.resolve(He.attribution):new Promise((function(e){return We(x.ATTRIBUTION_RECEIVED,(function(t,n){return e(n)}))}))},waitForWebUUID:function(){return He.uuid?Promise.resolve(He.uuid):new Promise((function(e){return We(x.WEB_UUID_CREATED,(function(t,n){return e(n)}))}))}};var ot=function(){return Ke((function e(){Be(this,e),o(this,"items",{})}),[{key:"getItem",value:function(e){return Object.prototype.hasOwnProperty.call(this.items,e)?this.items[e]:null}},{key:"removeItem",value:function(e){delete this.items[e]}},{key:"setItem",value:function(e,t){this.items[e]=t}}])}();const it=new(function(){return Ke((function e(){var t=this;Be(this,e),o(this,"defaultName",L.namespace),o(this,"storageName",this.defaultName),o(this,"storeNames",Se.storeNames.left),this.storesMap={},K()?this.storage=window.localStorage:this.storage=new ot;var n=this.read.bind(this),r=this.write.bind(this);B(this.storeNames).forEach((function(e){var o=e.name;Object.defineProperty(t.storesMap,o,{get:function(){return n(o)},set:function(e){r(o,e)}})})),Object.freeze(this.storesMap)}),[{key:"read",value:function(e){var t=this.storage.getItem("".concat(this.storageName,".").concat(e)),n=t?JSON.parse(t):null;return e===se.Preferences&&n?Ee(se.Preferences,Oe.right,n):n}},{key:"write",value:function(e,t){t?this.storage.setItem("".concat(this.storageName,".").concat(e),JSON.stringify(t instanceof Array?t:Ee(se.Preferences,Oe.left,t))):this.storage.removeItem("".concat(this.storageName,".").concat(e))}},{key:"clear",value:function(){this.deleteData()}},{key:"deleteData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];B(this.storeNames).forEach((function(n){!t&&n.permanent||e.storage.removeItem("".concat(e.storageName,".").concat(n.name))}))}},{key:"setCustomName",value:function(e){var t=this;if(e&&e.length){var n="".concat(L.namespace,"-").concat(e);B(this.storeNames).forEach((function(e){var r=e.name,o=t.storage.getItem("".concat(t.storageName,".").concat(r));o&&t.storage.setItem("".concat(n,".").concat(r),o)})),this.deleteData(!0),this.storageName=n}}},{key:"stores",get:function(){return this.storesMap}}])}());var at=pe.preferences.name,ut=st();function st(){return ut||ct(),ut?a({},ut):null}function ct(){ut=it.stores[at]}function lt(){var e=st();return e?e.sdkDisabled:null}function dt(e){var t=e?a({},e):null;it.stores[at]=a(a({},st()),{},{sdkDisabled:t}),ct()}function ft(){var e=st();return e?e.thirdPartySharingDisabled:null}function mt(){var e=it.stores[at]||{},t=(ut||{}).sdkDisabled||null;e.sdkDisabled&&!t&&Ve("sdk:shutdown"),ct()}function pt(){it.stores[at]||(it.stores[at]=a({},ut))}var ht=function(e){return e.add="add",e.put="put",e.get="get",e.list="list",e.clear="clear",e.delete="delete",e}(ht||{}),vt=function(e){return e.readonly="readonly",e.readwrite="readwrite",e}(vt||{}),gt=function(){function e(){Be(this,e),o(this,"dbDefaultName",L.namespace),o(this,"dbName",this.dbDefaultName),o(this,"dbVersion",1),o(this,"indexedDbConnection",null),o(this,"notSupportedError",{name:"IDBNotSupported",message:"IndexedDB is not supported"}),o(this,"databaseOpenError",{name:"CannotOpenDatabaseError",message:"Cannot open a database"}),o(this,"noConnectionError",{name:"NoDatabaseConnection",message:"Cannot open a transaction"});var t=e.getIndexedDB();if(!t)throw this.notSupportedError;this.idbFactory=t}return Ke(e,[{key:"setCustomName",value:function(e){return e&&e.length>0?(this.dbName="".concat(L.namespace,"-").concat(e),this.migrateDb(this.dbDefaultName,this.dbName)):Promise.resolve()}},{key:"openDatabase",value:function(t,n,r){var o=this;return e.isSupported().then((function(e){return e?new Promise((function(e,i){var a=o.idbFactory.open(t,r);n&&(a.onupgradeneeded=function(e){return n(e,i)}),a.onsuccess=function(t){var n=t.target.result;n?e(n):i(o.databaseOpenError)},a.onerror=i})):Promise.reject(o.notSupportedError)}))}},{key:"databaseExists",value:function(e){var t=this;return new Promise((function(n){var r=!0;t.openDatabase(e,(function(){r=!1})).then((function(n){if(n.close(),!r)return t.deleteDatabaseByName(e)})).then((function(){return n(r)}))}))}},{key:"cloneData",value:function(e,t){var n=this;return B(Se.storeNames.left).map((function(e){return e.name})).filter((function(e){return"p"!==e})).map((function(r){return function(){return o=r,i=n.indexedDbConnection,n.indexedDbConnection=e,n.getAll(o).then((function(e){if(n.indexedDbConnection=t,!(e.length<1))return n.addBulk(o,e,!0)})).then((function(){n.indexedDbConnection=i}));var o,i}})).reduce((function(e,t){return e.then(t)}),Promise.resolve())}},{key:"migrateDb",value:function(e,t){var n=this;return this.databaseExists(e).then((function(r){return r?Promise.all([n.openDatabase(e,n.handleUpgradeNeeded,n.dbVersion),n.openDatabase(t,n.handleUpgradeNeeded,n.dbVersion)]).then((function(t){var r=l(t,2),o=r[0],i=r[1];return n.cloneData(o,i).then((function(){return n.indexedDbConnection=i,o.close(),n.deleteDatabaseByName(e)}))})).then((function(){return Z.info("Database migration finished")})):n.openDatabase(t,n.handleUpgradeNeeded,n.dbVersion).then((function(e){n.indexedDbConnection=e}))}))}},{key:"handleUpgradeNeeded",value:function(e,t){var n=e.target.result;e.target.transaction.onerror=t,e.target.transaction.onabort=t;var r=Se.storeNames.left,o=rt.current||{},i=o&&!N(o);_(r).filter((function(e){return!l(e,2)[1].permanent})).forEach((function(e){var t=l(e,2),r=t[0],a=t[1].name,u=Se.right[r],s=n.createObjectStore(a,{keyPath:u.keyPath,autoIncrement:u.autoIncrement||!1});if(u.index&&s.createIndex("".concat(u.index,"Index"),u.index),a===ue.ActivityState&&i)return s.add(Ee(r,Oe.left,o)),void Z.info("Activity state has been recovered");var c=it.stores[a];c&&(c.forEach((function(e){return s.add(e)})),Z.info("Migration from localStorage done for ".concat(r," store")))})),pt(),it.clear()}},{key:"open",value:function(){var e=this;return this.indexedDbConnection?Promise.resolve({success:!0}):this.openDatabase(this.dbName,this.handleUpgradeNeeded,this.dbVersion).then((function(t){return e.indexedDbConnection=t,e.indexedDbConnection.onclose=function(){return e.destroy},{success:!0}}))}},{key:"getTransactionStore",value:function(e,t,n){var r,o=e.storeName,i=e.mode,a=n.transaction([o],i),u=a.objectStore(o),s=Se.right[Te(o,Oe.right)];return s.index&&(r=u.index("".concat(s.index,"Index"))),a.onerror=t,a.onabort=t,{transaction:a,store:u,index:r,options:s}}},{key:"overrideError",value:function(e,t){var n=t.target.error;return e({name:n.name,message:n.message})}},{key:"getCompositeKeys",value:function(e){var t=e.fields[e.keyPath];return fe(t)?t.composite:null}},{key:"targetIsObject",value:function(e){return O(e)}},{key:"prepareTarget",value:function(e,t,n){if(n===ht.clear||!t)return null;var r=this.getCompositeKeys(e);return-1!==[ht.add,ht.put].indexOf(n)?this.targetIsObject(t)?r?a(o({},e.keyPath,r.map((function(e){return t[e]})).join("")),t):t:null:t instanceof Array?t.join(""):t}},{key:"prepareResult",value:function(e,t){var n=this.getCompositeKeys(e);return n&&this.targetIsObject(t)?n.map((function(e){return t[e]})):null}},{key:"initRequest",value:function(e){var t=this,n=e.storeName,r=e.target,o=void 0===r?null:r,i=e.action,a=e.mode,u=void 0===a?vt.readonly:a;return this.open().then((function(){return new Promise((function(e,r){if(t.indexedDbConnection){var a=t.getTransactionStore({storeName:n,mode:u},r,t.indexedDbConnection),s=a.store,c=a.options,l=s[i](t.prepareTarget(c,o,i)),d=t.prepareResult(c,o);l.onsuccess=function(){i!==ht.get||l.result?e(d||l.result||o):r({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(n,'" store')})},l.onerror=function(e){return t.overrideError(r,e)}}else r(t.noConnectionError)}))}))}},{key:"initBulkRequest",value:function(e){var t=this,n=e.storeName,r=e.target,o=e.action,i=e.mode,a=void 0===i?vt.readwrite:i;return!r||r&&!r.length?Promise.reject({name:"NoTargetDefined",message:"No array provided to perform ".concat(o,' bulk operation into "').concat(n,'" store')}):this.open().then((function(){return new Promise((function(e,i){if(t.indexedDbConnection){var u=t.getTransactionStore({storeName:n,mode:a},i,t.indexedDbConnection),s=u.transaction,c=u.store,l=u.options,d=new Array,f=r[0];s.oncomplete=function(){return e(d)};!function e(n){n.onerror=function(e){return t.overrideError(i,e)},n.onsuccess=function(){d.push(t.prepareResult(l,f)||n.result),f=r[d.length],d.length1&&void 0!==arguments[1]&&arguments[1];return this.openCursor({storeName:e,action:ht.list,firstOnly:t})}},{key:"getFirst",value:function(e){return this.getAll(e,!0).then((function(e){return e.length?e[0]:void 0}))}},{key:"getItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ht.get})}},{key:"filterBy",value:function(e,t){var n=IDBKeyRange.only(t);return this.openCursor({storeName:e,action:ht.list,range:n})}},{key:"addItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ht.add,mode:vt.readwrite})}},{key:"addBulk",value:function(e,t,n){return this.initBulkRequest({storeName:e,target:t,action:n?ht.put:ht.add,mode:vt.readwrite})}},{key:"updateItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ht.put,mode:vt.readwrite})}},{key:"deleteItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ht.delete,mode:vt.readwrite})}},{key:"deleteBulk",value:function(e,t,n){var r=n?IDBKeyRange[n](t):IDBKeyRange.only(t);return this.openCursor({storeName:e,action:ht.delete,range:r,mode:vt.readwrite})}},{key:"trimItems",value:function(e,t){var n=this,r=Se.right[Te(e,Oe.right)];return this.getAll(e).then((function(e){return e.length?e[t-1]:null})).then((function(t){return t?n.deleteBulk(e,t[r.keyPath],xe.UpperBound):[]}))}},{key:"count",value:function(e){var t=this;return this.open().then((function(){return new Promise((function(n,r){if(t.indexedDbConnection){var o=t.getTransactionStore({storeName:e,mode:vt.readonly},r,t.indexedDbConnection).store.count();o.onsuccess=function(){return n(o.result)},o.onerror=function(e){return t.overrideError(r,e)}}else r(t.noConnectionError)}))}))}},{key:"clear",value:function(e){return this.initRequest({storeName:e,action:ht.clear,mode:vt.readwrite})}},{key:"destroy",value:function(){this.indexedDbConnection&&this.indexedDbConnection.close(),this.indexedDbConnection=null}},{key:"deleteDatabase",value:function(){return this.destroy(),this.deleteDatabaseByName(this.dbName)}}],[{key:"tryOpen",value:function(t){return new Promise((function(n){try{var r=t.open(e.dbValidationName);r.onsuccess=function(){r.result.close(),t.deleteDatabase(e.dbValidationName),n(!0)},r.onerror=function(){return n(!1)}}catch(e){n(!1)}}))}},{key:"isSupported",value:function(){if(e.isSupportedPromise)return e.isSupportedPromise;var t="IndexedDB is not supported in this browser";return e.isSupportedPromise=new Promise((function(n){var r=e.getIndexedDB(),o=!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform);!r||o?(Z.warn(t),n(!1)):n(e.tryOpen(r).then((function(e){return e||Z.warn(t),e})))})),e.isSupportedPromise}},{key:"getIndexedDB",value:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB}}])}();o(gt,"dbValidationName","validate-db-openable"),o(gt,"isSupportedPromise",null);var yt=function(){function e(){Be(this,e)}return Ke(e,[{key:"open",value:function(){return e.isSupported().then((function(e){if(!e)return{status:"error",error:{name:"LSNotSupported",message:"LocalStorage is not supported"}};var t=Se.storeNames.left,n=rt.current||{},r=n&&!N(n);return _(t).filter((function(e){return!l(e,2)[1].permanent})).forEach((function(e){var t=l(e,2),o=t[0],i=t[1].name;i!==ue.ActivityState||it.stores[i]?it.stores[i]||(it.stores[i]=[]):it.stores[i]=r?[Ee(o,Oe.left,n)]:[]})),pt(),{status:"success"}}))}},{key:"getCompositeKeys",value:function(e){var t=e.fields[e.keyPath];return fe(t)?t.composite:null}},{key:"getKeys",value:function(e){var t=Te(e,Oe.right),n=Se.right[t];return this.getCompositeKeys(n)||[n.keyPath]}},{key:"nextIndex",value:function(e){return"number"==typeof e?e+1:void 0}},{key:"initRequest",value:function(e,t){var n=this,r=e.storeName,o=e.id,i=e.item,u=Se.right[Te(r,Oe.right)];return this.open().then((function(e){return"error"===e.status?Promise.reject(e.error):new Promise((function(e,s){var c,l=it.stores[r],d=n.getKeys(r),f=(l[l.length-1]||{})[u.keyPath]||0;if(o){var m=Array.isArray(o)?o.slice():[o];c=d.map((function(e,t){return[e,m[t]]})).reduce(T,{})}else c=a({},i);var p=c?E(l,d,c):0;return t(e,s,{keys:d,items:l,index:p,options:u,lastId:f})}))}))}},{key:"sort",value:function(e,t,n){var r=d(e),o=t.slice().reverse();return r.sort((function(e,t){return o.reduce((function(r,o){return r||function(e,t,r){var o=n?n===e[r]:e[r]e[r]:e[r]>t[r];return o?-1:i?1:0}(e,t,o)}),0)}))}},{key:"prepareTarget",value:function(e,t,n){var r=this.getCompositeKeys(e);return r?a(o({},e.keyPath,r.map((function(e){return t[e]})).join("")),t):e.autoIncrement&&n?a(o({},e.keyPath,n),t):a({},t)}},{key:"prepareResult",value:function(e,t){var n=this.getCompositeKeys(e);return n?n.map((function(e){return t[e]})).filter((function(e){return!Ne(e)})):t[e.keyPath]}},{key:"getAll",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.open().then((function(r){return"error"===r.status?Promise.reject(r.error):new Promise((function(r,o){var i=it.stores[e];i instanceof Array?r(n?[i[0]]:t.sort(i,t.getKeys(e))):o({name:"NotFoundError",message:"No objectStore named ".concat(e," in this database")})}))}))}},{key:"getFirst",value:function(e){return this.getAll(e,!0).then((function(e){return e.length?e[0]:void 0}))}},{key:"getItem",value:function(e,t){var n=this;return this.initRequest({storeName:e,id:t},(function(t,r,o){var i=o.items,a=o.index,u=o.options;-1===a?r({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(e,'" store')}):t(n.prepareTarget(u,i[a]))}))}},{key:"filterBy",value:function(e,t){return this.getAll(e).then((function(n){return n.filter((function(n){var r=Se.right[Te(e,Oe.right)];return(r.index&&n[r.index])===t}))}))}},{key:"addItem",value:function(e,t){var n=this;return this.initRequest({storeName:e,item:t},(function(r,o,i){var a=i.items,u=i.index,s=i.options,c=i.lastId;-1!==u?o({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing item into "'.concat(e,'" store')}):(a.push(n.prepareTarget(s,t,n.nextIndex(c))),it.stores[e]=a,r(n.prepareResult(s,t)))}))}},{key:"addBulk",value:function(e,t,n){var r=this;return this.initRequest({storeName:e},(function(o,i,a){var u=a.keys,s=a.items,c=a.options,l=a.lastId;if(!t||t&&!t.length)i({name:"NoTargetDefined",message:'No array provided to perform add bulk operation into "'.concat(e,'" store')});else{var f=l,m=t.map((function(e){return r.prepareTarget(c,e,f=r.nextIndex(f))})),p=m.filter((function(e){return-1!==E(s,u,e)})).map((function(e){return e[c.keyPath]})),h=n?s.filter((function(e){return-1===p.indexOf(e[c.keyPath])})):d(s);if(p.length&&!n)i({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing items into "'.concat(e,'" store')});else it.stores[e]=r.sort([].concat(d(h),d(m)),u),o(t.map((function(e){return r.prepareResult(c,e)})))}}))}},{key:"updateItem",value:function(e,t){var n=this;return this.initRequest({storeName:e,item:t},(function(r,o,i){var a=i.items,u=i.index,s=i.options,c=i.lastId,l=-1===u?n.nextIndex(c):void 0,d=n.prepareTarget(s,t,l);-1===u?a.push(d):a.splice(u,1,d),it.stores[e]=a,r(n.prepareResult(s,t))}))}},{key:"deleteItem",value:function(e,t){return this.initRequest({storeName:e,id:t},(function(n,r,o){var i=o.items,a=o.index;-1!==a&&(i.splice(a,1),it.stores[e]=i),n(t)}))}},{key:"findMax",value:function(e,t,n){if(!e.length)return-1;for(var r={index:-1,value:"string"==typeof n?"":0},o=0;o=r.value&&(r={value:e[o][t],index:o})}return r.index}},{key:"deleteBulk",value:function(e,t,n){var r=this;return this.getAll(e).then((function(o){var i=r.getKeys(e),a=Se.right[Te(e,Oe.right)].index||i[0],u=n?null:t,s=r.sort(o,i,u),c=r.findMax(s,a,t);if(-1===c)return[];var l=n===xe.LowerBound?c:0,d=n&&n!==xe.UpperBound?s.length:c+1,f=s.splice(l,d).map((function(e){return 1===i.length?e[a]:i.map((function(t){return e[t]}))}));return it.stores[e]=s,f}))}},{key:"trimItems",value:function(e,t){var n=this,r=Te(e,Oe.right),o=Se.right[r];return this.getAll(e).then((function(e){return e.length?e[t-1]:null})).then((function(t){return t?n.deleteBulk(e,t[o.keyPath],xe.UpperBound):[]}))}},{key:"count",value:function(e){return this.open().then((function(t){if("error"===t.status)return Promise.reject(t.error);var n=it.stores[e];return Promise.resolve(n instanceof Array?n.length:1)}))}},{key:"clear",value:function(e){return this.open().then((function(t){return"error"===t.status?Promise.reject(t.error):new Promise((function(t){it.stores[e]=[],t()}))}))}},{key:"destroy",value:function(){}},{key:"deleteDatabase",value:function(){}}],[{key:"isSupported",value:function(){return e.isSupportedPromise||(e.isSupportedPromise=new Promise((function(e){var t=K();t||Z.warn("LocalStorage is not supported in this browser"),e(t)}))),e.isSupportedPromise}}])}();o(yt,"isSupportedPromise",null);var bt,kt=function(e){return e[e.noStorage=b.NO_STORAGE]="noStorage",e[e.indexedDB=b.INDEXED_DB]="indexedDB",e[e.localStorage=b.LOCAL_STORAGE]="localStorage",e}(kt||{}),wt={getAll:function(e,t,n){return e.getAll(t,n).then((function(e){return je(t,Oe.right,e)}))},getFirst:function(e,t){return e.getFirst(t).then((function(e){return Ee(t,Oe.right,e)}))},getItem:function(e,t,n){return e.getItem(t,Ce(t,Oe.left,n)).then((function(e){return Ee(t,Oe.right,e)})).catch((function(e){return Promise.reject(_e(t,e))}))},filterBy:function(e,t,n){return e.filterBy(t,Re(n)).then((function(e){return je(t,Oe.right,e)}))},addItem:function(e,t,n){var r=Ee(t,Oe.left,n);return e.addItem(t,r).then((function(e){return Ce(t,Oe.right,e)})).catch((function(e){return Promise.reject(_e(t,e))}))},addBulk:function(e,t,n,r){var o=je(t,Oe.left,n);return e.addBulk(t,o,r).then((function(e){return e.map((function(e){return Ce(t,Oe.right,e)}))})).catch((function(e){return Promise.reject(_e(t,e))}))},updateItem:function(e,t,n){var r=Ee(t,Oe.left,n);return e.updateItem(t,r).then((function(e){return Ce(t,Oe.right,e)}))},deleteItem:function(e,t,n){return e.deleteItem(t,Ce(t,Oe.left,n)).then((function(e){return Ce(t,Oe.right,e)}))},deleteBulk:function(e,t,n,r){return e.deleteBulk(t,Re(n),r).then((function(e){return e.map((function(e){return Ce(t,Oe.right,e)}))}))},trimItems:function(e,t,n){return e.trimItems(t,n)},count:function(e,t){return e.count(t)},clear:function(e,t){return e.clear(t)},destroy:function(e){return e.destroy()},deleteDatabase:function(e){return e.deleteDatabase()}};var Pt=null;function St(e){var t=null;return null!==Pt?Pt:Pt=Promise.all([gt.isSupported(),yt.isSupported()]).then((function(n){var r=l(n,2),o=r[0],i=r[1];if(it.setCustomName(e),o){bt=kt.indexedDB;var a=new gt;return a.setCustomName(e).then((function(){return t=a}))}return i?(bt=kt.localStorage,t=new yt,Promise.resolve(t)):(Z.error("There is no storage available, app will run with minimum set of features"),bt=kt.noStorage,t=null,Promise.resolve(t))})).then((function(){return{type:bt,storage:t}}))}const Dt=a({init:St,getType:function(){return bt}},(It=_(wt).map((function(e){var t=l(e,2),n=t[0],r=t[1];return[n,function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o2&&void 0!==arguments[2]&&arguments[2]?"CONTINUE":"RETRY",response:A(e.responseText)?JSON.parse(e.responseText):e.responseText,message:y[t],code:t}}function Ot(e,t){var n=e.slice(0,e.length-t.length-1).split("").reduce((function(e){return e.concat(" ")}),"");return"".concat(t).concat(n,":")}function At(e,t){var n="REQUEST PARAMETERS:",r=function(e){return e.replace(/([A-Z])/g,(function(e){return"_".concat(e.toLowerCase())}))},o=_(a(a(a({},ie.getBaseParams()),t),e)).map((function(e){var t=l(e,2),n=t[0],o=t[1];return[r(n),o]}));return Z.log(n),o.filter((function(e){return U(l(e,2)[1])})).map((function(e){var t=l(e,2),r=t[0],o=t[1];return Z.log(Ot(n,r),o),function(e){var t=l(e,2),n=t[0],r=t[1],o=encodeURIComponent(n),i=r;return"string"==typeof r&&(i=encodeURIComponent(r)),O(r)&&(i=encodeURIComponent(JSON.stringify(r)||"")),[o,i].join("=")}([r,o])})).join("&")}function Et(e,t,n){var r=n.xhr,o=n.url;if(4===r.readyState){var i=r.status>=200&&r.status<300,a=A(r.responseText);if(0!==r.status)return a?t(i?function(e,t){var n=JSON.parse(e.responseText),r={status:"success",adid:n.adid,timestamp:n.timestamp,ask_in:n.ask_in,retry_in:n.retry_in,continue_in:n.continue_in,tracking_state:n.tracking_state,attribution:void 0,message:void 0};return R(t,"attribution")&&(r.attribution=n.attribution,r.message=n.message),_(r).filter((function(e){return!!l(e,2)[1]})).reduce(T,{})}(r,o):Nt(r,"SERVER_CANNOT_PROCESS",!0)):e(Nt(r,i?"SERVER_MALFORMED_RESPONSE":"SERVER_INTERNAL_ERROR"));e(Nt(r,"NO_CONNECTION"))}}function jt(e,t){var n=e.endpoint,r=e.url,o=e.method,i=void 0===o?"GET":o,a=e.params,u=function(e,t){var n=e.endpoint,r=e.url,o=e.method,i=At(e.params,t);return{fullUrl:n+r+("GET"===o?"?".concat(i):""),encodedParams:i}}({endpoint:n,url:r,method:i,params:void 0===a?{}:a},t),s=u.fullUrl,c=u.encodedParams;return new Promise((function(e,t){var n=new XMLHttpRequest;n.open(i,s,!0),function(e,t){var n="REQUEST HEADERS:",r=[["Client-SDK","js".concat(L.version)],["Content-Type","POST"===t?"application/x-www-form-urlencoded":"application/json"]];Z.log(n),r.forEach((function(t){var r=l(t,2),o=r[0],i=r[1];e.setRequestHeader(o,i),Z.log(Ot(n,o),i)}))}(n,i),n.onreadystatechange=function(){return Et(t,e,{xhr:n,url:r})},n.onerror=function(){return t(Nt(n,"TRANSACTION_ERROR"))},n.send("GET"===i?void 0:c)}))}function Ct(e,t){return"success"===e.status?function(e,t){var n=R(t,"gdpr_forget_device"),r=R(t,"attribution"),o=R(t,"session"),i=R(t,"disable_third_party_sharing"),a="opted_out"===e.tracking_state;if(!n&&a)return Ve("sdk:gdpr-forget-me"),e;r||n||a||!e.ask_in||Ve("attribution:check",e);o&&Ve("session:finished",e);if(i)return Ve("sdk:third-party-sharing-opt-out"),e;return e}(e,t):e}var Rt={long:{delay:2*m,maxDelay:h,minRange:.5,maxRange:1},short:{delay:200,maxDelay:p,minRange:.5,maxRange:1},test:{delay:100,maxDelay:300}};function Tt(e,t){var n,r,o=Rt[t=t||"long"],i=o.delay*Math.pow(2,e-1);return i=Math.min(i,o.maxDelay),o.minRange&&o.maxRange&&(i*=(n=o.minRange,r=o.maxRange,Math.random()*(r-n)+n)),Math.round(i)}var _t=navigator.onLine;function Bt(){_t=!0}function Ut(){_t=!1}function Kt(e,t,n){e.addEventListener&&e.addEventListener(t,n,!1)}function Lt(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}var qt=function(e){return e.Default="default",e.India="india",e.China="china",e}(qt||{}),Mt=function(e){return e.EU="EU",e.TR="TR",e.US="US",e}(Mt||{});function Ft(e,t){Z.warn("Both ".concat(e," and ").concat(t," are set in config, ").concat(t," will be ignored"))}var Gt=o(o(o(o(o(o({},qt.Default,k),qt.India,w),qt.China,P),Mt.EU,S),Mt.TR,D),Mt.US,I);function Wt(e){var t,n,r,o,i=(t=ie.getCustomConfig(),n=t.customUrl,r=t.urlStrategy,o=t.dataResidency,n?((o||r)&&Ft("customUrl",o?"dataResidency":"urlStrategy"),{app:n,gdpr:n}):(o&&r&&Ft("dataResidency","urlStrategy"),o?[o]:r===qt.India?[qt.India,qt.Default]:r===qt.China?[qt.China,qt.Default]:[qt.Default,qt.India,qt.China]));return Array.isArray(i)?i.map((function(t){return e[t]||null})).filter((function(e){return!!e})):[i]}var Vt=150,Ht=2147483647,Yt=60*f;const zt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.url,o=n.method,i=void 0===o?"GET":o,u=n.params,s=void 0===u?{}:u,c=n.continueCb,d=n.strategy,f=n.wait,m={url:r,method:i,params:s,continueCb:c},p=r,h=i,v=a({},s),g=c,b=d,k=function(){e.reset(),t=e.next()},w=function(e,t){return e["/gdpr_forget_device"===t?"gdpr":"app"]},P=null,S={request:0,connection:0},D=x(f),I=null;function x(e){return(e=e||Vt)>Ht?Ht:e}function O(n){var r=n.wait,o=n.retrying;return e||(e=function(){var e=Wt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Gt),t=0;return{next:function(){return t0&&void 0!==arguments[0]?arguments[0]:{},t=e.url,n=e.method,r=e.params,o=void 0===r?{}:r,i=e.continueCb,u=e.wait;return function(e){var t=e.url,n=e.method,r=e.params,o=e.continueCb;t&&(p=t),n&&(h=n),N(r)||(v=a({},r)),v=a({createdAt:qe()},v),"function"==typeof o&&(g=o)}({url:t,method:n,params:o,continueCb:i}),O({wait:u})},isRunning:function(){return!!P},clear:B}};var Jt=function(e){return e===g?"GDPR disable":"disable"},Qt=function(e){return{start:{inProgress:"Adjust SDK ".concat(Jt(e)," process has already started"),done:"Adjust SDK ".concat(Jt(e)," process is now started")},finish:{inProgress:"Adjust SDK ".concat(Jt(e)," process has already finished"),done:"Adjust SDK ".concat(Jt(e)," process is now finished")}}};function Xt(e,t){var n=e.reason,r=e.pending,o=lt()||{},i="start"===t&&o.pending?"start":"finish",a="start"===t&&o.reason,u="finish"===t&&o.reason&&!o.pending;return a||u?(Z.log(Qt(o.reason)[i].inProgress),!1):(Z.log(Qt(n)[i].done),dt({reason:n||v,pending:r}),!0)}function Zt(e){return Xt({reason:e,pending:arguments.length>1&&void 0!==arguments[1]&&arguments[1]||!1},"start")}function $t(){var e=lt()||{};return e.reason===v||e.reason===g&&!e.pending?"off":e.reason===g&&e.pending?"paused":"on"}var en=ae.ActivityState,tn=!1;function nn(e){return e?"unknown"===e.uuid?(Zt({reason:g}),rt.destroy(),{exists:!0,stored:null}):(rt.init(e),{exists:!0,stored:e}):{exists:!1}}function rn(){return"off"!==$t()&&rt.isStarted()}function on(){if(!rn())return Promise.resolve(null);var e=a(a({},rt.current),{},{lastActive:Date.now()});return Dt.updateItem(en,e).then((function(){return rt.current=e}))}var an=zt({strategy:"long",continueCb:function(e,t){var n=e&&e.continue_in||null;return cn.pause=n?{timestamp:Date.now(),wait:n}:null,Dt.getFirst(sn).then((function(e){return e?Dt.deleteItem(sn,e.timestamp):null})).then((function(){return t(),cn.running=!1,mn({wait:n})}))}}),un=!1,sn="queue",cn={running:!1,timestamp:null,pause:null};function ln(){var e=Date.now();return cn.timestamp&&e<=cn.timestamp&&(e=cn.timestamp+1),cn.timestamp=e,e}function dn(e){var t=e.url,n=e.method,r=e.params,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.auto,u=o.timestamp;rt.updateParams(t,i);var s=_(r||{}).filter((function(e){return U(l(e,2)[1])})).reduce(T,{}),c={timestamp:ln(),url:t,method:n,params:a(a({},rt.getParams(t)),s)};return u&&(c.createdAt=u),Dt.addItem(sn,c).then((function(){return function(e){return R(e,"session")&&rt.resetSessionOffset(),rt.updateLastActive(),on()}(t)})).then((function(){return cn.running?{}:mn()}))}function fn(){var e=cn.pause||{},t=e.timestamp,n=e.wait,r=Date.now()-(t||0);return r0&&void 0!==arguments[0]?arguments[0]:{},t=e.cleanUp,n=e.wait;if(cn.running)return Promise.resolve({});cn.running=!0;var r=Promise.resolve({});return t&&(r=r.then(hn)),r.then((function(){return Dt.getFirst(sn)})).then((function(e){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.timestamp,n=e.createdAt,r=e.url,o=e.method,i=e.params,u=arguments.length>1?arguments[1]:void 0,s=rt.current||{},c="/session"===r&&!s.installed;return un&&!c||!r&&!o&&!i?(cn.running=!1,Promise.resolve({})):an.send({url:r,method:o,params:a(a({},i),{},{createdAt:qe(n||t)}),wait:u||fn()})}(e,n)}))}function pn(e){if(void 0!==e)if(e!==un){var t=un;un=e,!e&&t&&mn(),Z.info("The app is now in ".concat(e?"offline":"online"," mode"))}else Z.error("The app is already in ".concat(e?"offline":"online"," mode"));else Z.error("State not provided, true or false has to be defined")}function hn(){var e=Date.now()-ie.requestValidityWindow;return Dt.deleteBulk(sn,e,"upperBound")}var vn="globalParams",gn={short:"No type provided",long:"Global parameter type not provided, `callback` or `partner` types are available"};function yn(e){return(e||[]).map((function(e){return{key:e.key,value:e.value}}))}function bn(){return Promise.all([Dt.filterBy(vn,"callback"),Dt.filterBy(vn,"partner")]).then((function(e){var t=l(e,2),n=t[0],r=t[1];return{callbackParams:yn(n),partnerParams:yn(r)}}))}function kn(e,t){if(void 0===t)return Z.error(gn.long),Promise.reject({message:gn.short});var n=j(e),r=Object.keys(n).map((function(e){return{key:e,value:n[e],type:t}}));return Promise.all([Dt.filterBy(vn,t),Dt.addBulk(vn,r,!0)]).then((function(e){var n=l(e,2),o=n[0],i=n[1],a=C(o.map((function(e){return e.key})),i.map((function(e){return e[0]})));return Z.log("Following ".concat(t," parameters have been saved: ").concat(r.map((function(e){return"".concat(e.key,":").concat(e.value)})).join(", "))),a.length&&Z.log("Keys: ".concat(a.join(", ")," already existed so their values have been updated")),i}))}function wn(e,t){return void 0===t?(Z.error(gn.long),Promise.reject({message:gn.short})):Dt.deleteItem(vn,[e,t]).then((function(n){return Z.log("".concat(e," ").concat(t," parameter has been deleted")),n}))}function Pn(e){return void 0===e?(Z.error(gn.long),Promise.reject({message:gn.short})):Dt.deleteBulk(vn,e).then((function(t){return Z.log("All ".concat(e," parameters have been deleted")),t}))}var Sn,Dn,In,xn=!1,Nn=document;function On(){return In=function(){var e=document;if(void 0!==e.hidden)return{hidden:"hidden",visibilityChange:"visibilitychange"};for(var t=_({mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange",oHidden:"ovisibilitychange",webkitHidden:"webkitvisibilitychange"}),n=0;n0;return!n||n&&t*f>=ie.sessionWindow?bn().then((function(e){var t,n,r;dn({url:"/session",method:"POST",params:(t=e,n=t.callbackParams,r=t.partnerParams,{callbackParams:n.length?j(n):null,partnerParams:r.length?j(r):null})},{auto:!0})})):(Ve("attribution:check"),on())}var Bn=zt({url:"/attribution",strategy:"short",continueCb:function(e,t,n){if(!e||e&&"error"===e.status)return t(),Promise.resolve({state:"unknown"});if(!e.ask_in)return t(),function(e){if(N(e)||!function(e){var t=e.adid,n=void 0===t?"":t,r=e.attribution,o=void 0===r?{}:r;return!!n&&!!C(Un,Object.keys(o)).length}(e)||function(e){var t=e.adid,n=e.attribution,r=rt.current.attribution||{},o=n&&Un.some((function(e){return r[e]!==n[e]}));return!o&&t===r.adid}(e))return Promise.resolve({state:"same"});var t=_(e.attribution).filter((function(e){var t=l(e,1)[0];return-1!==Un.indexOf(t)})).reduce(T,{adid:e.adid});return rt.current=a(a({},rt.current),{},{attribution:t}),on().then((function(){return Ve("attribution:change",t),Ve(x.ATTRIBUTION_RECEIVED,t),Z.info("Attribution has been updated"),{state:"changed"}}))}(e);return n(e.ask_in)}}),Un=["tracker_token","tracker_name","network","campaign","adgroup","creative","click_label","state"];var Kn=zt({url:"/gdpr_forget_device",method:"POST",strategy:"short"}),Ln={running:"Adjust SDK is running pending GDPR Forget Me request",pending:"Adjust SDK will run GDPR Forget Me request after initialisation",paused:"Adjust SDK is already prepared to send GDPR Forget Me request",off:"Adjust SDK is already disabled"};function qn(e){var t=$t();return e||"on"===t?ie.isInitialised()?(Kn.send({params:a({},rt.getParams())}).then((function(){Ve("sdk:gdpr-forget-me")})),!0):(Z.log(Ln.pending),!0):(Z.log(Ln[t]),!1)}function Mn(){return Xt({reason:g,pending:!1},"finish")}var Fn={running:"Adjust SDK is running pending third-party sharing opt-out request",delayed:"Adjust SDK will run third-party sharing opt-out request after initialisation",pending:"Adjust SDK already queued third-party sharing opt-out request",off:"Third-party sharing opt-out is already done",start:{inProgress:"Third-party sharing opt-out has already started",done:"Third-party sharing opt-out is now started"},finish:{inProgress:"Third-party sharing opt-out has already finished",done:"Third-party sharing opt-out is now finished"}};function Gn(){var e=ft()||{};return e.reason?e.pending?"pending":"off":"on"}function Wn(e){var t=Gn();return e||"on"===t?ie.isInitialised()?(dn({url:"/disable_third_party_sharing",method:"POST"}),!0):(Z.log(Fn.delayed),!0):(Z.log(Fn[t]),!1)}function Vn(e,t){var n,r,o=ft()||{},i="start"===t&&e?"start":"finish",u="start"===t&&o.reason,s="finish"===t&&o.reason&&!o.pending;return u||s?(Z.log(Fn[i].inProgress),!1):(Z.log(Fn[i].done),r=(n={reason:v,pending:e})?a({},n):null,it.stores[at]=a(a({},st()),{},{thirdPartySharingDisabled:r}),ct(),!0)}function Hn(){return Vn(!1,"finish")}function Yn(){"pending"===Gn()&&(Z.log(Fn.running),Wn(!0))}var zn=[];function Jn(e,t){zn.push({method:e,description:t,timestamp:Date.now()})}var Qn=10,Xn="eventDeduplication";function Zn(e,t){var n,r,o=t.callbackParams,i=t.partnerParams,u={},s=a({eventToken:e.eventToken,deduplicationId:e.deduplicationId},(n=e.revenue,r=e.currency,isNaN(n)||(n=parseFloat(n))<0||!r?{}:{revenue:n.toFixed(5),currency:r})),c=a(a({},j(o)),j(e.callbackParams)),l=a(a({},j(i)),j(e.partnerParams));return N(c)||(u.callbackParams=c),N(l)||(u.partnerParams=l),a(a({},s),u)}function $n(e){return e?Dt.getAll(Xn).then((function(e){return e.map((function(e){return e.id}))})).then((function(t){return-1===t.indexOf(e)?function(e){var t=ie.getCustomConfig().eventDeduplicationListLimit,n=t>0?t:Qn;return Dt.count(Xn).then((function(e){var t=Promise.resolve();if(e>=n){var r=e-n+1;Z.log("Event deduplication list limit has been reached. Oldest ids are about to be removed (".concat(r," of them)")),t=Dt.trimItems(Xn,r)}return t})).then((function(){return Z.info("New event deduplication id is added to the list: ".concat(e)),Dt.addItem(Xn,{id:e})}))}(e):Promise.reject({message:"Event won't be tracked, since it was previously tracked with the same deduplication id ".concat(e)})})):Promise.resolve()}function er(e){return{clickTime:qe(),source:"web_referrer",referrer:decodeURIComponent(e)}}function tr(e,t){var n;(n=e||window.location.search.substring(1).split("&").map((function(e){return e.split("=")})).reduce(T,{}).adjust_referrer)&&dn({url:"/sdk_click",method:"POST",params:er(n)},{timestamp:t})}var nr=["logLevel","logOutput"],rr=null,or=!1,ir=!1,ar=!1;function ur(){Wn()&&Vn(!0,"start")}function sr(){var e;"paused"===$t()&&(Mn(),Promise.all([(e={uuid:"unknown"},rt.current=e,Dt.clear(en).then((function(){return Dt.addItem(en,e)}))),Dt.clear(vn),Dt.clear(sn)]).then(fr))}function cr(){return or||ie.isInitialised()}function lr(){or=!1,ir=!1,zn=[],an.clear(),cn.running=!1,cn.timestamp=null,cn.pause=null,xn=!1,rt.toBackground(),Tn(),In&&(clearTimeout(Dn),Lt(Nn,In.visibilityChange,jn),Kt(Nn,In.visibilityChange,Cn)),Bn.clear()}function dr(e){e&&Z.log("Adjust SDK has been shutdown due to asynchronous disable"),lr(),Ge.forEach(clearTimeout),Ge=[],Fe={},rt.destroy(),Lt(window,"online",Bt),Lt(window,"offline",Ut),Dt.destroy(),ie.destroy()}function fr(){ar=!1,dr(),Kn.clear(),rr=null,Z.log("Adjust SDK instance has been destroyed")}function mr(e){Z.log("Adjust SDK is starting with web_uuid set to ".concat(e.uuid));var t=rt.current.installed;"paused"===$t()&&(Z.log(Ln.running),qn(!0)),t||Yn();var n=$t(),r=function(e){return"Adjust SDK start has been interrupted ".concat(e)};return"off"===n?(dr(),Promise.reject({interrupted:!0,message:r("due to complete async disable")})):"paused"===n?(lr(),Promise.reject({interrupted:!0,message:r("due to partial async disable")})):ir?Promise.reject({interrupted:!0,message:r("due to multiple synchronous start attempt")}):(mn({cleanUp:!0}),On().then((function(){or=!1,ir=!0,t&&(pr(),Yn())})))}function pr(){var e;ar=!0,zn.forEach((function(e){"function"==typeof e.method&&(Z.log("Delayed ".concat(e.description," task is running now")),e.method(e.timestamp))})),zn=[],(e="sdk:installed")&&_(Fe).some((function(t){var n=l(t,2)[1];return n.some((function(t,r){t.id===e&&n.splice(r,1)}))}))}function hr(e){if(e.interrupted)Z.log(e.message);else if(dr(),Z.error("Adjust SDK start has been canceled due to an error",e),e.stack)throw e}function vr(e){"off"!==$t()?(ie.set(e),Kt(window,"online",Bt),Kt(window,"offline",Ut),We("sdk:installed",pr),We("sdk:shutdown",(function(){return dr(!0)})),We("sdk:gdpr-forget-me",sr),We("sdk:third-party-sharing-opt-out",Hn),We("attribution:check",(function(e,t){return n=t,r=rt.current,(o=(n||{}).ask_in)||!r.attribution&&r.installed?(Bn.send({params:a({initiatedBy:n?"backend":"sdk"},rt.getParams()),wait:o}),rt.updateSessionOffset(),on()):Promise.resolve(r);var n,r,o})),"function"==typeof e.attributionCallback&&We("attribution:change",e.attributionCallback),(tn?Promise.reject({interrupted:!0,message:"Adjust SDK start already in progress"}):(tn=!0,Dt.getFirst(en).then(nn).then((function(e){if(e.exists)return tn=!1,e.stored;var t,n=N(rt.current)?{uuid:(t=Date.now(),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?n:11&n).toString(16)})))}:rt.current;return Dt.addItem(en,n).then((function(){return rt.init(n),mt(),tn=!1,n}))})).then((function(e){return e&&Ve(x.WEB_UUID_CREATED,e.uuid),e})))).then(mr).then(tr).catch(hr)):Z.log("Adjust SDK is disabled, can not start the sdk")}function gr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.schedule,o=n.waitForInitFinished,i=n.optionalInit;if(Dt.getType()!==b.NO_STORAGE)if("on"===$t())if(i||cr()||!o){if("function"==typeof t){if(!r||ar&&ir||!i&&!cr())return t();Jn(t,e),Z.log("Running ".concat(e," is delayed until Adjust SDK is up"))}}else Z.error("Adjust SDK can not ".concat(e,", sdk instance is not initialized"));else Z.log("Adjust SDK is disabled, can not ".concat(e));else Z.log("Adjust SDK can not ".concat(e,", no storage available"))}const yr={initSdk:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.logLevel,n=e.logOutput,r=u(e,nr);Z.setLogLevel(t,n),cr()?Z.error("You already initiated your instance"):ie.hasMissing(r)||(or=!0,Dt.init(r.namespace).then((function(e){e.type!==b.NO_STORAGE?(Z.info("Available storage is ".concat(e.type)),rr=a({},r),vr(r)):Z.error("Adjust SDK can not start, there is no storage available")})))},getAttribution:function(){return gr("get attribution",(function(){return rt.getAttribution()}))},getWebUUID:function(){return gr("get web_uuid",(function(){return rt.getWebUUID()}))},waitForAttribution:function(){return gr("get attribution",(function(){return rt.waitForAttribution()}),{schedule:!1})},waitForWebUUID:function(){return gr("get web_uuid",(function(){return rt.waitForWebUUID()}),{schedule:!1})},setReferrer:function(e){e&&"string"==typeof e?gr("setting reftag",(function(t){return tr(e,t)}),{schedule:!0,waitForInitFinished:!0,optionalInit:!0}):Z.error("You must provide a string referrer")},trackEvent:function(e){return function(e){if(Dt.getType()===b.NO_STORAGE){var t="Adjust SDK can not track event, no storage available";return Z.log(t),Promise.reject(t)}if("on"!==$t()){var n="Adjust SDK is disabled, can not track event";return Z.log(n),Promise.reject(n)}if(!cr()){var r="Adjust SDK can not track event, sdk instance is not initialized";return Z.error(r),Promise.reject(r)}return new Promise((function(t){var n=function(n){return t(function(e,t){if(!e||e&&(N(e)||!e.eventToken)){var n="You must provide event token in order to track event";return Z.error(n),Promise.reject(n)}return $n(e.deduplicationId).then(bn).then((function(n){return dn({url:"/event",method:"POST",params:Zn(e,n)},{timestamp:t})})).catch((function(e){return e&&e.message&&Z.error(e.message),Promise.reject(e)}))}(e,n))};!ar||!ir&&cr()?(Jn(n,"track event"),Z.log("Running track event is delayed until Adjust SDK is up")):n()}))}(e)},addGlobalCallbackParameters:function(e){gr("add global callback parameters",(function(){return kn(e,"callback")}))},addGlobalPartnerParameters:function(e){gr("add global partner parameters",(function(){return kn(e,"partner")}))},removeGlobalCallbackParameter:function(e){gr("remove global callback parameter",(function(){return wn(e,"callback")}))},removeGlobalPartnerParameter:function(e){gr("remove global partner parameter",(function(){return wn(e,"partner")}))},clearGlobalCallbackParameters:function(){gr("remove all global callback parameters",(function(){return Pn("callback")}))},clearGlobalPartnerParameters:function(){gr("remove all global partner parameters",(function(){return Pn("partner")}))},switchToOfflineMode:function(){gr("set offline mode",(function(){return pn(!0)}))},switchBackToOnlineMode:function(){gr("set online mode",(function(){return pn(!1)}))},stop:function(){Zt()&&ie.isInitialised()&&dr()},restart:function(){var e;((e=lt()||{}).reason===g?(Z.log("Adjust SDK is disabled due to GDPR-Forget-Me request and it can not be re-enabled"),!1):e.reason?(Z.log("Adjust SDK has been enabled"),dt(null),!0):(Z.log("Adjust SDK is already enabled"),!1))&&rr&&vr(rr)},gdprForgetMe:function(){var e=qn();e&&(e=Zt(g,!0))&&ie.isInitialised()&&lr()},disableThirdPartySharing:function(){gr("disable third-party sharing",ur,{schedule:!0})},initSmartBanner:function(){Z.error("function `initSmartBanner` is deprecated")},showSmartBanner:function(){Z.error("function `showSmartBanner` is deprecated")},hideSmartBanner:function(){Z.error("function `hideSmartBanner` is deprecated")},__testonly__:{destroy:fr,clearDatabase:function(){return Dt.deleteDatabase()}},__internal__:{restartAfterAsyncEnable:function(){Z.log("Adjust SDK has been restarted due to asynchronous enable"),rr&&vr(rr)}}};return t=t.default})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Adjust=t():e.Adjust=t()}(self,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function o(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}e.d(t,{default:()=>ur});var s=1e3,c=60*s,l=60*c,d=24*l,f=function(e){return e.REASON_GENERAL="general",e.REASON_GDPR="gdpr",e}({}),m={TRANSACTION_ERROR:"XHR transaction failed due to an error",SERVER_MALFORMED_RESPONSE:"Response from server is malformed",SERVER_INTERNAL_ERROR:"Internal error occurred on the server",SERVER_CANNOT_PROCESS:"Server was not able to process the request, probably due to error coming from the client",NO_CONNECTION:"No internet connectivity",SKIP:"Skipping slower attempt",MISSING_URL:"Url is not provided"},p=function(e){return e.NO_STORAGE="noStorage",e.INDEXED_DB="indexedDB",e.LOCAL_STORAGE="localStorage",e}({}),v={default:"adjust.com",india:"adjust.net.in",china:"adjust.world",world:"adjust.world",EU:"eu.adjust.com",TR:"tr.adjust.com",US:"us.adjust.com"},h="https://app.",g="https://gdpr.",y="https://",b={WEB_UUID_CREATED:"activity:web_uuid",ATTRIBUTION_RECEIVED:"activity:attribution"};function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:[]).reduce((function(e,t){return a(a({},e),{},o({},t.key,t.value))}),{})}function I(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter((function(t){return-1!==e.indexOf(t)}))}function R(e,t){return new RegExp("\\/".concat(t,"(\\/.*|\\?.*){0,1}$")).test(e)}function A(e,t){var n=w(t,2),r=n[0],i=n[1];return a(a({},e),{},o({},r,i))}function x(e){return Object.keys(e).map((function(t){return[t,e[t]]}))}function C(e){return Object.keys(e).map((function(t){return e[t]}))}function j(e){return D(e)?!P(e):!!e||0===e}function T(){try{var e=(new Date).toString(),t=window.localStorage;t.setItem(e,e);var n=t.getItem(e)===e;return t.removeItem(e),!(!n||!t)}catch(e){return!1}}const _={namespace:"adjust-sdk",version:"5.7.0",env:"production"};var B="error",U="warning",L="info",K="verbose",q=o(o(o(o(o({},"none",-1),B,0),U,1),L,2),K,3),G={log:" ",info:" ",warn:" ",error:""},M={development:K,production:B,test:K},F=V(),W="";function V(){return M[_.env]||B}function H(e,t){var n;if(!(q[F]2?u-2:0),c=2;c2&&void 0!==arguments[2]?arguments[2]:[]).map((function(n){return Ne(e,t,n)}))}function Oe(e,t,n){var r=be[t][Re(e,Pe.right)],o=r.fields[r.keyPath],i=n instanceof Array?n.slice():[n],a=(se(o)?o.composite:[r.keyPath]).map((function(e,t){var n=r.fields[e];return De(ae(n)?n.values:null,i[t])}));return 1===a.length?a[0]:a}function Ie(e){return be.values[e]||e}function Re(e,t){return(be.storeNames[t][e]||{}).name||e}function Ae(e,t){return{name:t.name,message:t.message.replace('"'.concat(e,'"'),Re(e,Pe.right))}}function xe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ce(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:1,n=e+"",r=1;r<=t;r+=1)e0?"-":"+")+Te(Math.floor(Math.abs(t)/60))+Te(Math.abs(t)%60)}(t);return"".concat(n,"T").concat(r,"Z").concat(o)}function Be(e,t){return isNaN(e)||isNaN(t)?0:Math.abs(t-e)}var Ue={},Le=[];function Ke(e,t){var n="id"+Math.random().toString(36).substring(2,16),r={id:n,cb:t};return Ue[e]||(Ue[e]=[]),Ue[e].push(r),n}function qe(e,t){Ue[e]&&Ue[e].forEach((function(n){"function"==typeof n.cb&&Le.push(setTimeout((function(){return n.cb(e,t)})))}))}var Ge={},Me=!1,Fe=!1;function We(){Ge=Me?a({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}):{}}function Ve(){Me&&(Ge.lastInterval=function(){var e=Ge.lastActive;if(e)return Math.round(Be(e,Date.now())/s);return-1}(),Ge.lastActive=Date.now())}function He(e){Ge=a(a({},Ge),e)}function Ye(){Fe=!0}function ze(){var e=Ge.lastActive;return Math.round(Be(e,Date.now())/s)}function Je(){return(Ge.timeSpent||0)+(Fe?ze():0)}function Qe(){var e=Be(Ge.lastActive,Date.now())=0?Ge.lastInterval:0,n={timeSpent:Ge.timeSpent||0,sessionLength:Ge.sessionLength||0,sessionCount:Ge.sessionCount||1,lastInterval:t||0};return e&&R(e,"event")&&(n.eventCount=Ge.eventCount),n},updateParams:function(e,t){if(Me){var n={};n.timeSpent=Je(),n.sessionLength=Qe(),R(e,"session")&&(n.sessionCount=(Ge.sessionCount||0)+1),R(e,"event")&&(n.eventCount=(Ge.eventCount||0)+1),He(n),t||Ve()}},updateInstalled:function(){Me&&(Ge.installed||He({installed:!0}))},updateSessionOffset:Xe,updateSessionLength:function(){Me&&(He({sessionLength:Qe()}),Ve())},resetSessionOffset:function(){Me&&He({timeSpent:0,sessionLength:0})},updateLastActive:Ve,destroy:function(){Ge={},Me=!1,Fe=!1},getAttribution:function(){return Me?Ge.attribution?Ge.attribution:(z.log("No attribution data yet"),null):null},getWebUUID:function(){return Me?Ge.uuid:null},waitForAttribution:function(){return Ge.attribution?Promise.resolve(Ge.attribution):new Promise((function(e){return Ke(b.ATTRIBUTION_RECEIVED,(function(t,n){return e(n)}))}))},waitForWebUUID:function(){return Ge.uuid?Promise.resolve(Ge.uuid):new Promise((function(e){return Ke(b.WEB_UUID_CREATED,(function(t,n){return e(n)}))}))}};var $e=function(){return je((function e(){xe(this,e),o(this,"items",{})}),[{key:"getItem",value:function(e){return Object.prototype.hasOwnProperty.call(this.items,e)?this.items[e]:null}},{key:"removeItem",value:function(e){delete this.items[e]}},{key:"setItem",value:function(e,t){this.items[e]=t}}])}();const et=new(function(){return je((function e(){var t=this;xe(this,e),o(this,"defaultName",_.namespace),o(this,"storageName",this.defaultName),o(this,"storeNames",be.storeNames.left),this.storesMap={},T()?this.storage=window.localStorage:this.storage=new $e;var n=this.read.bind(this),r=this.write.bind(this);C(this.storeNames).forEach((function(e){var o=e.name;Object.defineProperty(t.storesMap,o,{get:function(){return n(o)},set:function(e){r(o,e)}})})),Object.freeze(this.storesMap)}),[{key:"read",value:function(e){var t=this.storage.getItem("".concat(this.storageName,".").concat(e)),n=t?JSON.parse(t):null;return e===oe.Preferences&&n?Ne(oe.Preferences,Pe.right,n):n}},{key:"write",value:function(e,t){t?this.storage.setItem("".concat(this.storageName,".").concat(e),JSON.stringify(t instanceof Array?t:Ne(oe.Preferences,Pe.left,t))):this.storage.removeItem("".concat(this.storageName,".").concat(e))}},{key:"clear",value:function(){this.deleteData()}},{key:"deleteData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];C(this.storeNames).forEach((function(n){!t&&n.permanent||e.storage.removeItem("".concat(e.storageName,".").concat(n.name))}))}},{key:"setCustomName",value:function(e){var t=this;if(e&&e.length){var n="".concat(_.namespace,"-").concat(e);C(this.storeNames).forEach((function(e){var r=e.name,o=t.storage.getItem("".concat(t.storageName,".").concat(r));o&&t.storage.setItem("".concat(n,".").concat(r),o)})),this.deleteData(!0),this.storageName=n}}},{key:"stores",get:function(){return this.storesMap}}])}());var tt=le.preferences.name,nt=null;function rt(){return nt||ot(),nt?a({},nt):null}function ot(){nt=et.stores[tt]}function it(){var e=rt();return e&&e.sdkDisabled||null}function at(e){var t=e?a({},e):null;et.stores[tt]=a(a({},rt()),{},{sdkDisabled:t}),ot()}function ut(){var e=et.stores[tt]||{},t=(nt||{}).sdkDisabled||null;e.sdkDisabled&&!t&&qe("sdk:shutdown"),ot()}function st(){et.stores[tt]||(et.stores[tt]=a({},nt))}nt=rt();var ct=function(e){return e.add="add",e.put="put",e.get="get",e.list="list",e.clear="clear",e.delete="delete",e}(ct||{}),lt=function(e){return e.readonly="readonly",e.readwrite="readwrite",e}(lt||{}),dt=function(){function e(){xe(this,e),o(this,"dbDefaultName",_.namespace),o(this,"dbName",this.dbDefaultName),o(this,"dbVersion",1),o(this,"indexedDbConnection",null),o(this,"notSupportedError",{name:"IDBNotSupported",message:"IndexedDB is not supported"}),o(this,"databaseOpenError",{name:"CannotOpenDatabaseError",message:"Cannot open a database"}),o(this,"noConnectionError",{name:"NoDatabaseConnection",message:"Cannot open a transaction"});var t=e.getIndexedDB();if(!t)throw this.notSupportedError;this.idbFactory=t}return je(e,[{key:"setCustomName",value:function(e){return e&&e.length>0?(this.dbName="".concat(_.namespace,"-").concat(e),this.migrateDb(this.dbDefaultName,this.dbName)):Promise.resolve()}},{key:"openDatabase",value:function(t,n,r){var o=this;return e.isSupported().then((function(e){return e?new Promise((function(e,i){var a=o.idbFactory.open(t,r);n&&(a.onupgradeneeded=function(e){return n(e,i)}),a.onsuccess=function(t){var n=t.target.result;n?e(n):i(o.databaseOpenError)},a.onerror=i})):Promise.reject(o.notSupportedError)}))}},{key:"databaseExists",value:function(e){var t=this;return new Promise((function(n){var r=!0;t.openDatabase(e,(function(){r=!1})).then((function(n){if(n.close(),!r)return t.deleteDatabaseByName(e)})).then((function(){return n(r)}))}))}},{key:"cloneData",value:function(e,t){var n=this;return C(be.storeNames.left).map((function(e){return e.name})).filter((function(e){return"p"!==e})).map((function(r){return function(){return o=r,i=n.indexedDbConnection,n.indexedDbConnection=e,n.getAll(o).then((function(e){if(n.indexedDbConnection=t,!(e.length<1))return n.addBulk(o,e,!0)})).then((function(){n.indexedDbConnection=i}));var o,i}})).reduce((function(e,t){return e.then(t)}),Promise.resolve())}},{key:"migrateDb",value:function(e,t){var n=this;return this.databaseExists(e).then((function(r){return r?Promise.all([n.openDatabase(e,n.handleUpgradeNeeded,n.dbVersion),n.openDatabase(t,n.handleUpgradeNeeded,n.dbVersion)]).then((function(t){var r=w(t,2),o=r[0],i=r[1];return n.cloneData(o,i).then((function(){return n.indexedDbConnection=i,o.close(),n.deleteDatabaseByName(e)}))})).then((function(){return z.info("Database migration finished")})):n.openDatabase(t,n.handleUpgradeNeeded,n.dbVersion).then((function(e){n.indexedDbConnection=e}))}))}},{key:"handleUpgradeNeeded",value:function(e,t){var n=e.target.result;e.target.transaction.onerror=t,e.target.transaction.onabort=t;var r=be.storeNames.left,o=Ze.current||{},i=o&&!P(o);x(r).filter((function(e){return!w(e,2)[1].permanent})).forEach((function(e){var t=w(e,2),r=t[0],a=t[1].name,u=be.right[r],s=n.createObjectStore(a,{keyPath:u.keyPath,autoIncrement:u.autoIncrement||!1});if(u.index&&s.createIndex("".concat(u.index,"Index"),u.index),a===re.ActivityState&&i)return s.add(Ne(r,Pe.left,o)),void z.info("Activity state has been recovered");var c=et.stores[a];c&&(c.forEach((function(e){return s.add(e)})),z.info("Migration from localStorage done for ".concat(r," store")))})),st(),et.clear()}},{key:"open",value:function(){var e=this;return this.indexedDbConnection?Promise.resolve({success:!0}):this.openDatabase(this.dbName,this.handleUpgradeNeeded,this.dbVersion).then((function(t){return e.indexedDbConnection=t,e.indexedDbConnection.onclose=function(){return e.destroy},{success:!0}}))}},{key:"getTransactionStore",value:function(e,t,n){var r,o=e.storeName,i=e.mode,a=n.transaction([o],i),u=a.objectStore(o),s=be.right[Re(o,Pe.right)];return s.index&&(r=u.index("".concat(s.index,"Index"))),a.onerror=t,a.onabort=t,{transaction:a,store:u,index:r,options:s}}},{key:"overrideError",value:function(e,t){var n=t.target.error;return e({name:n.name,message:n.message})}},{key:"getCompositeKeys",value:function(e){var t=e.fields[e.keyPath];return se(t)?t.composite:null}},{key:"targetIsObject",value:function(e){return D(e)}},{key:"prepareTarget",value:function(e,t,n){if(n===ct.clear||!t)return null;var r=this.getCompositeKeys(e);return-1!==[ct.add,ct.put].indexOf(n)?this.targetIsObject(t)?r?a(o({},e.keyPath,r.map((function(e){return t[e]})).join("")),t):t:null:t instanceof Array?t.join(""):t}},{key:"prepareResult",value:function(e,t){var n=this.getCompositeKeys(e);return n&&this.targetIsObject(t)?n.map((function(e){return t[e]})):null}},{key:"initRequest",value:function(e){var t=this,n=e.storeName,r=e.target,o=void 0===r?null:r,i=e.action,a=e.mode,u=void 0===a?lt.readonly:a;return this.open().then((function(){return new Promise((function(e,r){if(t.indexedDbConnection){var a=t.getTransactionStore({storeName:n,mode:u},r,t.indexedDbConnection),s=a.store,c=a.options,l=s[i](t.prepareTarget(c,o,i)),d=t.prepareResult(c,o);l.onsuccess=function(){i!==ct.get||l.result?e(d||l.result||o):r({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(n,'" store')})},l.onerror=function(e){return t.overrideError(r,e)}}else r(t.noConnectionError)}))}))}},{key:"initBulkRequest",value:function(e){var t=this,n=e.storeName,r=e.target,o=e.action,i=e.mode,a=void 0===i?lt.readwrite:i;return!r||r&&!r.length?Promise.reject({name:"NoTargetDefined",message:"No array provided to perform ".concat(o,' bulk operation into "').concat(n,'" store')}):this.open().then((function(){return new Promise((function(e,i){if(t.indexedDbConnection){var u=t.getTransactionStore({storeName:n,mode:a},i,t.indexedDbConnection),s=u.transaction,c=u.store,l=u.options,d=new Array,f=r[0];s.oncomplete=function(){return e(d)};!function e(n){n.onerror=function(e){return t.overrideError(i,e)},n.onsuccess=function(){d.push(t.prepareResult(l,f)||n.result),f=r[d.length],d.length1&&void 0!==arguments[1]&&arguments[1];return this.openCursor({storeName:e,action:ct.list,firstOnly:t})}},{key:"getFirst",value:function(e){return this.getAll(e,!0).then((function(e){return e.length?e[0]:void 0}))}},{key:"getItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ct.get})}},{key:"filterBy",value:function(e,t){var n=IDBKeyRange.only(t);return this.openCursor({storeName:e,action:ct.list,range:n})}},{key:"addItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ct.add,mode:lt.readwrite})}},{key:"addBulk",value:function(e,t,n){return this.initBulkRequest({storeName:e,target:t,action:n?ct.put:ct.add,mode:lt.readwrite})}},{key:"updateItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ct.put,mode:lt.readwrite})}},{key:"deleteItem",value:function(e,t){return this.initRequest({storeName:e,target:t,action:ct.delete,mode:lt.readwrite})}},{key:"deleteBulk",value:function(e,t,n){var r=n?IDBKeyRange[n](t):IDBKeyRange.only(t);return this.openCursor({storeName:e,action:ct.delete,range:r,mode:lt.readwrite})}},{key:"trimItems",value:function(e,t){var n=this,r=be.right[Re(e,Pe.right)];return this.getAll(e).then((function(e){return e.length?e[t-1]:null})).then((function(t){return t?n.deleteBulk(e,t[r.keyPath],Se.UpperBound):[]}))}},{key:"count",value:function(e){var t=this;return this.open().then((function(){return new Promise((function(n,r){if(t.indexedDbConnection){var o=t.getTransactionStore({storeName:e,mode:lt.readonly},r,t.indexedDbConnection).store.count();o.onsuccess=function(){return n(o.result)},o.onerror=function(e){return t.overrideError(r,e)}}else r(t.noConnectionError)}))}))}},{key:"clear",value:function(e){return this.initRequest({storeName:e,action:ct.clear,mode:lt.readwrite})}},{key:"destroy",value:function(){this.indexedDbConnection&&this.indexedDbConnection.close(),this.indexedDbConnection=null}},{key:"deleteDatabase",value:function(){return this.destroy(),this.deleteDatabaseByName(this.dbName)}}],[{key:"tryOpen",value:function(t){return new Promise((function(n){try{var r=t.open(e.dbValidationName);r.onsuccess=function(){r.result.close(),t.deleteDatabase(e.dbValidationName),n(!0)},r.onerror=function(){return n(!1)}}catch(e){n(!1)}}))}},{key:"isSupported",value:function(){if(e.isSupportedPromise)return e.isSupportedPromise;var t="IndexedDB is not supported in this browser";return e.isSupportedPromise=new Promise((function(n){var r=e.getIndexedDB(),o=!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform);!r||o?(z.warn(t),n(!1)):n(e.tryOpen(r).then((function(e){return e||z.warn(t),e})))})),e.isSupportedPromise}},{key:"getIndexedDB",value:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB}}])}();function ft(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}o(dt,"dbValidationName","validate-db-openable"),o(dt,"isSupportedPromise",null);var mt=function(){function e(){xe(this,e)}return je(e,[{key:"open",value:function(){return e.isSupported().then((function(e){if(!e)return{status:"error",error:{name:"LSNotSupported",message:"LocalStorage is not supported"}};var t=be.storeNames.left,n=Ze.current||{},r=n&&!P(n);return x(t).filter((function(e){return!w(e,2)[1].permanent})).forEach((function(e){var t=w(e,2),o=t[0],i=t[1].name;i!==re.ActivityState||et.stores[i]?et.stores[i]||(et.stores[i]=[]):et.stores[i]=r?[Ne(o,Pe.left,n)]:[]})),st(),{status:"success"}}))}},{key:"getCompositeKeys",value:function(e){var t=e.fields[e.keyPath];return se(t)?t.composite:null}},{key:"getKeys",value:function(e){var t=Re(e,Pe.right),n=be.right[t];return this.getCompositeKeys(n)||[n.keyPath]}},{key:"nextIndex",value:function(e){return"number"==typeof e?e+1:void 0}},{key:"initRequest",value:function(e,t){var n=this,r=e.storeName,o=e.id,i=e.item,u=be.right[Re(r,Pe.right)];return this.open().then((function(e){return"error"===e.status?Promise.reject(e.error):new Promise((function(e,s){var c,l=et.stores[r],d=n.getKeys(r),f=(l[l.length-1]||{})[u.keyPath]||0;if(o){var m=Array.isArray(o)?o.slice():[o];c=d.map((function(e,t){return[e,m[t]]})).reduce(A,{})}else c=a({},i);var p=c?E(l,d,c):0;return t(e,s,{keys:d,items:l,index:p,options:u,lastId:f})}))}))}},{key:"sort",value:function(e,t,n){var r=ft(e),o=t.slice().reverse();return r.sort((function(e,t){return o.reduce((function(r,o){return r||function(e,t,r){var o=n?n===e[r]:e[r]e[r]:e[r]>t[r];return o?-1:i?1:0}(e,t,o)}),0)}))}},{key:"prepareTarget",value:function(e,t,n){var r=this.getCompositeKeys(e);return r?a(o({},e.keyPath,r.map((function(e){return t[e]})).join("")),t):e.autoIncrement&&n?a(o({},e.keyPath,n),t):a({},t)}},{key:"prepareResult",value:function(e,t){var n=this.getCompositeKeys(e);return n?n.map((function(e){return t[e]})).filter((function(e){return!we(e)})):t[e.keyPath]}},{key:"getAll",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.open().then((function(r){return"error"===r.status?Promise.reject(r.error):new Promise((function(r,o){var i=et.stores[e];i instanceof Array?r(n?[i[0]]:t.sort(i,t.getKeys(e))):o({name:"NotFoundError",message:"No objectStore named ".concat(e," in this database")})}))}))}},{key:"getFirst",value:function(e){return this.getAll(e,!0).then((function(e){return e.length?e[0]:void 0}))}},{key:"getItem",value:function(e,t){var n=this;return this.initRequest({storeName:e,id:t},(function(t,r,o){var i=o.items,a=o.index,u=o.options;-1===a?r({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(e,'" store')}):t(n.prepareTarget(u,i[a]))}))}},{key:"filterBy",value:function(e,t){return this.getAll(e).then((function(n){return n.filter((function(n){var r=be.right[Re(e,Pe.right)];return(r.index&&n[r.index])===t}))}))}},{key:"addItem",value:function(e,t){var n=this;return this.initRequest({storeName:e,item:t},(function(r,o,i){var a=i.items,u=i.index,s=i.options,c=i.lastId;-1!==u?o({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing item into "'.concat(e,'" store')}):(a.push(n.prepareTarget(s,t,n.nextIndex(c))),et.stores[e]=a,r(n.prepareResult(s,t)))}))}},{key:"addBulk",value:function(e,t,n){var r=this;return this.initRequest({storeName:e},(function(o,i,a){var u=a.keys,s=a.items,c=a.options,l=a.lastId;if(!t||t&&!t.length)i({name:"NoTargetDefined",message:'No array provided to perform add bulk operation into "'.concat(e,'" store')});else{var d=l,f=t.map((function(e){return r.prepareTarget(c,e,d=r.nextIndex(d))})),m=f.filter((function(e){return-1!==E(s,u,e)})).map((function(e){return e[c.keyPath]})),p=n?s.filter((function(e){return-1===m.indexOf(e[c.keyPath])})):ft(s);if(m.length&&!n)i({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing items into "'.concat(e,'" store')});else et.stores[e]=r.sort([].concat(ft(p),ft(f)),u),o(t.map((function(e){return r.prepareResult(c,e)})))}}))}},{key:"updateItem",value:function(e,t){var n=this;return this.initRequest({storeName:e,item:t},(function(r,o,i){var a=i.items,u=i.index,s=i.options,c=i.lastId,l=-1===u?n.nextIndex(c):void 0,d=n.prepareTarget(s,t,l);-1===u?a.push(d):a.splice(u,1,d),et.stores[e]=a,r(n.prepareResult(s,t))}))}},{key:"deleteItem",value:function(e,t){return this.initRequest({storeName:e,id:t},(function(n,r,o){var i=o.items,a=o.index;-1!==a&&(i.splice(a,1),et.stores[e]=i),n(t)}))}},{key:"findMax",value:function(e,t,n){if(!e.length)return-1;for(var r={index:-1,value:"string"==typeof n?"":0},o=0;o=r.value&&(r={value:e[o][t],index:o})}return r.index}},{key:"deleteBulk",value:function(e,t,n){var r=this;return this.getAll(e).then((function(o){var i=r.getKeys(e),a=be.right[Re(e,Pe.right)].index||i[0],u=n?null:t,s=r.sort(o,i,u),c=r.findMax(s,a,t);if(-1===c)return[];var l=n===Se.LowerBound?c:0,d=n&&n!==Se.UpperBound?s.length:c+1,f=s.splice(l,d).map((function(e){return 1===i.length?e[a]:i.map((function(t){return e[t]}))}));return et.stores[e]=s,f}))}},{key:"trimItems",value:function(e,t){var n=this,r=Re(e,Pe.right),o=be.right[r];return this.getAll(e).then((function(e){return e.length?e[t-1]:null})).then((function(t){return t?n.deleteBulk(e,t[o.keyPath],Se.UpperBound):[]}))}},{key:"count",value:function(e){return this.open().then((function(t){if("error"===t.status)return Promise.reject(t.error);var n=et.stores[e];return Promise.resolve(n instanceof Array?n.length:1)}))}},{key:"clear",value:function(e){return this.open().then((function(t){return"error"===t.status?Promise.reject(t.error):new Promise((function(t){et.stores[e]=[],t()}))}))}},{key:"destroy",value:function(){}},{key:"deleteDatabase",value:function(){}}],[{key:"isSupported",value:function(){return e.isSupportedPromise||(e.isSupportedPromise=new Promise((function(e){var t=T();t||z.warn("LocalStorage is not supported in this browser"),e(t)}))),e.isSupportedPromise}}])}();o(mt,"isSupportedPromise",null);var pt,vt=function(e){return e[e.noStorage=p.NO_STORAGE]="noStorage",e[e.indexedDB=p.INDEXED_DB]="indexedDB",e[e.localStorage=p.LOCAL_STORAGE]="localStorage",e}(vt||{}),ht={getAll:function(e,t,n){return e.getAll(t,n).then((function(e){return Ee(t,Pe.right,e)}))},getFirst:function(e,t){return e.getFirst(t).then((function(e){return Ne(t,Pe.right,e)}))},getItem:function(e,t,n){return e.getItem(t,Oe(t,Pe.left,n)).then((function(e){return Ne(t,Pe.right,e)})).catch((function(e){return Promise.reject(Ae(t,e))}))},filterBy:function(e,t,n){return e.filterBy(t,Ie(n)).then((function(e){return Ee(t,Pe.right,e)}))},addItem:function(e,t,n){var r=Ne(t,Pe.left,n);return e.addItem(t,r).then((function(e){return Oe(t,Pe.right,e)})).catch((function(e){return Promise.reject(Ae(t,e))}))},addBulk:function(e,t,n,r){var o=Ee(t,Pe.left,n);return e.addBulk(t,o,r).then((function(e){return e.map((function(e){return Oe(t,Pe.right,e)}))})).catch((function(e){return Promise.reject(Ae(t,e))}))},updateItem:function(e,t,n){var r=Ne(t,Pe.left,n);return e.updateItem(t,r).then((function(e){return Oe(t,Pe.right,e)}))},deleteItem:function(e,t,n){return e.deleteItem(t,Oe(t,Pe.left,n)).then((function(e){return Oe(t,Pe.right,e)}))},deleteBulk:function(e,t,n,r){return e.deleteBulk(t,Ie(n),r).then((function(e){return e.map((function(e){return Oe(t,Pe.right,e)}))}))},trimItems:function(e,t,n){return e.trimItems(t,n)},count:function(e,t){return e.count(t)},clear:function(e,t){return e.clear(t)},destroy:function(e){return e.destroy()},deleteDatabase:function(e){return e.deleteDatabase()}};var gt=null;function yt(e){var t=null;return null!==gt?gt:gt=Promise.all([dt.isSupported(),mt.isSupported()]).then((function(n){var r=w(n,2),o=r[0],i=r[1];if(et.setCustomName(e),o){pt=vt.indexedDB;var a=new dt;return a.setCustomName(e).then((function(){return t=a}))}return i?(pt=vt.localStorage,t=new mt,Promise.resolve(t)):(z.error("There is no storage available, app will run with minimum set of features"),pt=vt.noStorage,t=null,Promise.resolve(t))})).then((function(){return{type:pt,storage:t}}))}const bt=a({init:yt,getType:function(){return pt}},(kt=x(ht).map((function(e){var t=w(e,2),n=t[0],r=t[1];return[n,function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o2&&void 0!==arguments[2]&&arguments[2]?"CONTINUE":"RETRY",response:N(e.responseText)?JSON.parse(e.responseText):e.responseText,message:m[t],code:t}}function Pt(e,t){var n=e.slice(0,e.length-t.length-1).split("").reduce((function(e){return e.concat(" ")}),"");return"".concat(t).concat(n,":")}function Dt(e,t){var n="REQUEST PARAMETERS:",r=function(e){return e.replace(/([A-Z])/g,(function(e){return"_".concat(e.toLowerCase())}))},o=x(a(a(a({},te.getBaseParams()),t),e)).map((function(e){var t=w(e,2),n=t[0],o=t[1];return[r(n),o]}));return z.log(n),o.filter((function(e){return j(w(e,2)[1])})).map((function(e){var t=w(e,2),r=t[0],o=t[1];return z.log(Pt(n,r),o),function(e){var t=w(e,2),n=t[0],r=t[1],o=encodeURIComponent(n),i=r;return"string"==typeof r&&(i=encodeURIComponent(r)),D(r)&&(i=encodeURIComponent(JSON.stringify(r)||"")),[o,i].join("granular_third_party_sharing_options"===n||"partner_sharing_settings"===n?encodeURIComponent("="):"=")}([r,o])})).join("&")}function Nt(e,t,n){var r=n.xhr,o=n.url;if(4===r.readyState){var i=r.status>=200&&r.status<300,a=N(r.responseText);if(0!==r.status)return a?t(i?function(e,t){var n=JSON.parse(e.responseText),r={status:"success",adid:n.adid,timestamp:n.timestamp,ask_in:n.ask_in,retry_in:n.retry_in,continue_in:n.continue_in,tracking_state:n.tracking_state,attribution:void 0,message:void 0};return R(t,"attribution")&&(r.attribution=n.attribution,r.message=n.message),x(r).filter((function(e){return!!w(e,2)[1]})).reduce(A,{})}(r,o):wt(r,"SERVER_CANNOT_PROCESS",!0)):e(wt(r,i?"SERVER_MALFORMED_RESPONSE":"SERVER_INTERNAL_ERROR"));e(wt(r,"NO_CONNECTION"))}}function Et(e,t){var n=e.endpoint,r=e.url,o=e.method,i=void 0===o?"GET":o,a=e.params,u=function(e,t){var n=e.endpoint,r=e.url,o=e.method,i=Dt(e.params,t);return{fullUrl:n+r+("GET"===o?"?".concat(i):""),encodedParams:i}}({endpoint:n,url:r,method:i,params:void 0===a?{}:a},t),s=u.fullUrl,c=u.encodedParams;return new Promise((function(e,t){var n=new XMLHttpRequest;n.open(i,s,!0),function(e,t){var n="REQUEST HEADERS:",r=[["Client-SDK","js".concat(_.version)],["Content-Type","POST"===t?"application/x-www-form-urlencoded":"application/json"]];z.log(n),r.forEach((function(t){var r=w(t,2),o=r[0],i=r[1];e.setRequestHeader(o,i),z.log(Pt(n,o),i)}))}(n,i),n.onreadystatechange=function(){return Nt(t,e,{xhr:n,url:r})},n.onerror=function(){return t(wt(n,"TRANSACTION_ERROR"))},n.send("GET"===i?void 0:c)}))}function Ot(e,t){return"success"===e.status?function(e,t){var n=R(t,"gdpr_forget_device"),r=R(t,"attribution"),o=R(t,"session"),i="opted_out"===e.tracking_state;if(!n&&i)return qe("sdk:gdpr-forget-me"),e;r||n||i||!e.ask_in||qe("attribution:check",e);o&&qe("session:finished",e);return e}(e,t):e}var It={long:{delay:2*c,maxDelay:d,minRange:.5,maxRange:1},short:{delay:200,maxDelay:l,minRange:.5,maxRange:1},test:{delay:100,maxDelay:300}};function Rt(e,t){var n,r,o=It[t=t||"long"],i=o.delay*Math.pow(2,e-1);return i=Math.min(i,o.maxDelay),o.minRange&&o.maxRange&&(i*=(n=o.minRange,r=o.maxRange,Math.random()*(r-n)+n)),Math.round(i)}var At=navigator.onLine;function xt(){At=!0}function Ct(){At=!1}function jt(e,t,n){e.addEventListener&&e.addEventListener(t,n,!1)}function Tt(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}function _t(e){return{domains:[e.default,e.world],useSubdomains:!0,isDataResidency:!1}}var Bt=function(e){return e.Default="default",e.India="india",e.China="china",e}(Bt||{});function Ut(e,t){z.warn("Both ".concat(e," and ").concat(t," are set in config, ").concat(t," will be ignored"))}function Lt(e){return function(e){var t=te.getCustomConfig(),n=t.customUrl,r=t.urlStrategy,o=t.dataResidency;if(n)return z.warn("customUrl is deprecated, use urlStrategy instead"),(o||r)&&Ut("customUrl",o?"dataResidency":"urlStrategy"),{domains:[n],useSubdomains:!1,isDataResidency:!1};if(o&&r&&Ut("dataResidency","urlStrategy"),o)return z.warn("dataResidency is deprecated, use urlStrategy instead"),{domains:[e[o]],useSubdomains:!0,isDataResidency:!0};if("string"==typeof r){if(z.warn("urlStrategy string literals ('china' and 'india') are deprected, use UrlStartegyConfig instead"),r===Bt.India)return{domains:[e.india,e.default],useSubdomains:!0,isDataResidency:!1};if(r===Bt.China)return{domains:[e.china,e.default],useSubdomains:!0,isDataResidency:!1}}return r?null:_t(e)}(e)||function(e){var t=te.getCustomConfig().urlStrategy;if(t&&"object"===n(t)){var r=t;return!r.domains||!Array.isArray(r.domains)||r.domains.length<1?(z.warn("Invalid urlStartegy: `domains` should be a non-empty array"),_t(e)):{domains:r.domains,useSubdomains:!!r.useSubdomains,isDataResidency:!!r.isDataResidency}}return _t(e)}(e)}function Kt(e){var t,n=Lt(e),r=[],o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=S(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}(n.domains);try{for(o.s();!(t=o.n()).done;){var i=t.value,a=n.useSubdomains?{app:"".concat(h).concat(i),gdpr:"".concat(g).concat(i)}:{app:"".concat(y).concat(i),gdpr:"".concat(y).concat(i)};r.push(a)}}catch(e){o.e(e)}finally{o.f()}return r}var qt=150,Gt=2147483647,Mt=60*s;const Ft=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.url,o=n.method,i=void 0===o?"GET":o,u=n.params,s=void 0===u?{}:u,c=n.continueCb,l=n.strategy,d=n.wait,f={url:r,method:i,params:s,continueCb:c},p=r,h=i,g=a({},s),y=c,b=l,k=function(){e.reset(),t=e.next()},S=function(e,t){return e["/gdpr_forget_device"===t?"gdpr":"app"]},D=null,N={request:0,connection:0},E=I(d),O=null;function I(e){return(e=e||qt)>Gt?Gt:e}function R(n){var r=n.wait,o=n.retrying;return e||(e=function(){var e=Kt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:v),t=0;return{next:function(){return t0&&void 0!==arguments[0]?arguments[0]:{},t=e.url,n=e.method,r=e.params,o=void 0===r?{}:r,i=e.continueCb,u=e.wait;return function(e){var t=e.url,n=e.method,r=e.params,o=e.continueCb;t&&(p=t),n&&(h=n),P(r)||(g=a({},r)),g=a({createdAt:_e()},g),"function"==typeof o&&(y=o)}({url:t,method:n,params:o,continueCb:i}),R({wait:u})},isRunning:function(){return!!D},clear:L}};var Wt=function(e){return e===f.REASON_GDPR?"GDPR disable":"disable"},Vt=function(e){return{start:{inProgress:"Adjust SDK ".concat(Wt(e)," process has already started"),done:"Adjust SDK ".concat(Wt(e)," process is now started")},finish:{inProgress:"Adjust SDK ".concat(Wt(e)," process has already finished"),done:"Adjust SDK ".concat(Wt(e)," process is now finished")}}};function Ht(e,t){var n=e.reason,r=e.pending,o=it()||{},i=o.reason,a=o.pending,u="start"===t&&a?"start":"finish";return"start"===t&&i||"finish"===t&&i&&!a?(z.log(Vt(i)[u].inProgress),!1):(z.log(Vt(n)[u].done),at({reason:n||f.REASON_GENERAL,pending:r}),!0)}function Yt(e){return Ht({reason:e,pending:arguments.length>1&&void 0!==arguments[1]&&arguments[1]},"start")}function zt(){var e=it()||{},t=e.reason,n=e.pending;return t===f.REASON_GENERAL||t===f.REASON_GDPR&&!n?"off":t===f.REASON_GDPR&&n?"paused":"on"}var Jt=ne.ActivityState,Qt=!1;function Xt(e){return e?"unknown"===e.uuid?(Yt(f.REASON_GDPR),Ze.destroy(),{exists:!0,stored:null}):(Ze.init(e),{exists:!0,stored:e}):{exists:!1}}function Zt(){return"off"!==zt()&&Ze.isStarted()}function $t(){if(!Zt())return Promise.resolve(null);var e=a(a({},Ze.current),{},{lastActive:Date.now()});return bt.updateItem(Jt,e).then((function(){return Ze.current=e}))}var en=Ft({strategy:"long",continueCb:function(e,t){var n=e&&e.continue_in||null;return rn.pause=n?{timestamp:Date.now(),wait:n}:null,bt.getFirst(nn).then((function(e){return e?bt.deleteItem(nn,e.timestamp):null})).then((function(){return t(),rn.running=!1,sn({wait:n})}))}}),tn=!1,nn="queue",rn={running:!1,timestamp:null,pause:null};function on(){var e=Date.now();return rn.timestamp&&e<=rn.timestamp&&(e=rn.timestamp+1),rn.timestamp=e,e}function an(e){var t=e.url,n=e.method,r=e.params,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.auto,u=o.timestamp;Ze.updateParams(t,i);var s=x(r||{}).filter((function(e){return j(w(e,2)[1])})).reduce(A,{}),c={timestamp:on(),url:t,method:n,params:a(a({},Ze.getParams(t)),s)};return u&&(c.createdAt=u),bt.addItem(nn,c).then((function(){return function(e){return R(e,"session")&&Ze.resetSessionOffset(),Ze.updateLastActive(),$t()}(t)})).then((function(){return rn.running?{}:sn()}))}function un(){var e=rn.pause||{},t=e.timestamp,n=e.wait,r=Date.now()-(t||0);return r0&&void 0!==arguments[0]?arguments[0]:{},t=e.cleanUp,n=e.wait;if(rn.running)return Promise.resolve({});rn.running=!0;var r=Promise.resolve({});return t&&(r=r.then(ln)),r.then((function(){return bt.getFirst(nn)})).then((function(e){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.timestamp,n=e.createdAt,r=e.url,o=e.method,i=e.params,u=arguments.length>1?arguments[1]:void 0,s=Ze.current||{},c="/session"===r&&!s.installed;return tn&&!c||!r&&!o&&!i?(rn.running=!1,Promise.resolve({})):en.send({url:r,method:o,params:a(a({},i),{},{createdAt:_e(n||t)}),wait:u||un()})}(e,n)}))}function cn(e){if(void 0!==e)if(e!==tn){var t=tn;tn=e,!e&&t&&sn(),z.info("The app is now in ".concat(e?"offline":"online"," mode"))}else z.error("The app is already in ".concat(e?"offline":"online"," mode"));else z.error("State not provided, true or false has to be defined")}function ln(){var e=Date.now()-te.requestValidityWindow;return bt.deleteBulk(nn,e,"upperBound")}var dn="globalParams",fn={short:"No type provided",long:"Global parameter type not provided, `callback` or `partner` types are available"};function mn(e){return(e||[]).map((function(e){return{key:e.key,value:e.value}}))}function pn(){return Promise.all([bt.filterBy(dn,"callback"),bt.filterBy(dn,"partner")]).then((function(e){var t=w(e,2),n=t[0],r=t[1];return{callbackParams:mn(n),partnerParams:mn(r)}}))}function vn(e,t){if(void 0===t)return z.error(fn.long),Promise.reject({message:fn.short});var n=O(e),r=Object.keys(n).map((function(e){return{key:e,value:n[e],type:t}}));return Promise.all([bt.filterBy(dn,t),bt.addBulk(dn,r,!0)]).then((function(e){var n=w(e,2),o=n[0],i=n[1],a=I(o.map((function(e){return e.key})),i.map((function(e){return e[0]})));return z.log("Following ".concat(t," parameters have been saved: ").concat(r.map((function(e){return"".concat(e.key,":").concat(e.value)})).join(", "))),a.length&&z.log("Keys: ".concat(a.join(", ")," already existed so their values have been updated")),i}))}function hn(e,t){return void 0===t?(z.error(fn.long),Promise.reject({message:fn.short})):bt.deleteItem(dn,[e,t]).then((function(n){return z.log("".concat(e," ").concat(t," parameter has been deleted")),n}))}function gn(e){return void 0===e?(z.error(fn.long),Promise.reject({message:fn.short})):bt.deleteBulk(dn,e).then((function(t){return z.log("All ".concat(e," parameters have been deleted")),t}))}var yn,bn,kn,Sn=!1,wn=document;function Pn(){return kn=function(){var e=document;if(void 0!==e.hidden)return{hidden:"hidden",visibilityChange:"visibilitychange"};for(var t=x({mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange",oHidden:"ovisibilitychange",webkitHidden:"webkitvisibilitychange"}),n=0;n0;return!n||n&&t*s>=te.sessionWindow?pn().then((function(e){var t,n,r;an({url:"/session",method:"POST",params:(t=e,n=t.callbackParams,r=t.partnerParams,{callbackParams:n.length?O(n):null,partnerParams:r.length?O(r):null})},{auto:!0})})):(qe("attribution:check"),$t())}var xn=Ft({url:"/attribution",strategy:"short",continueCb:function(e,t,n){if(!e||e&&"error"===e.status)return t(),Promise.resolve({state:"unknown"});if(!e.ask_in)return t(),function(e){if(P(e)||!function(e){var t=e.adid,n=void 0===t?"":t,r=e.attribution,o=void 0===r?{}:r;return!!n&&!!I(Cn,Object.keys(o)).length}(e)||function(e){var t=e.adid,n=e.attribution,r=Ze.current.attribution||{},o=n&&Cn.some((function(e){return r[e]!==n[e]}));return!o&&t===r.adid}(e))return Promise.resolve({state:"same"});var t=x(e.attribution).filter((function(e){var t=w(e,1)[0];return-1!==Cn.indexOf(t)})).reduce(A,{adid:e.adid});return Ze.current=a(a({},Ze.current),{},{attribution:t}),$t().then((function(){return qe("attribution:change",t),qe(b.ATTRIBUTION_RECEIVED,t),z.info("Attribution has been updated"),{state:"changed"}}))}(e);return n(e.ask_in)}}),Cn=["tracker_token","tracker_name","network","campaign","adgroup","creative","click_label","state"];var jn=Ft({url:"/gdpr_forget_device",method:"POST",strategy:"short"}),Tn={running:"Adjust SDK is running pending GDPR Forget Me request",pending:"Adjust SDK will run GDPR Forget Me request after initialisation",paused:"Adjust SDK is already prepared to send GDPR Forget Me request",off:"Adjust SDK is already disabled"};function _n(e){var t=zt();return e||"on"===t?te.isInitialised()?(jn.send({params:a({},Ze.getParams())}).then((function(){qe("sdk:gdpr-forget-me")})),!0):(z.log(Tn.pending),!0):(z.log(Tn[t]),!1)}function Bn(){return Ht({reason:f.REASON_GDPR,pending:!1},"finish")}var Un=[];function Ln(e,t){Un.push({method:e,description:t,timestamp:Date.now()})}var Kn=10,qn="eventDeduplication";function Gn(e,t){var n,r,o=t.callbackParams,i=t.partnerParams,u={},s=a({eventToken:e.eventToken,deduplicationId:e.deduplicationId},(n=e.revenue,r=e.currency,isNaN(n)||(n=parseFloat(n))<0||!r?{}:{revenue:n.toFixed(5),currency:r})),c=a(a({},O(o)),O(e.callbackParams)),l=a(a({},O(i)),O(e.partnerParams));return P(c)||(u.callbackParams=c),P(l)||(u.partnerParams=l),a(a({},s),u)}function Mn(e){return e?bt.getAll(qn).then((function(e){return e.map((function(e){return e.id}))})).then((function(t){return-1===t.indexOf(e)?function(e){var t=te.getCustomConfig().eventDeduplicationListLimit,n=t>0?t:Kn;return bt.count(qn).then((function(e){var t=Promise.resolve();if(e>=n){var r=e-n+1;z.log("Event deduplication list limit has been reached. Oldest ids are about to be removed (".concat(r," of them)")),t=bt.trimItems(qn,r)}return t})).then((function(){return z.info("New event deduplication id is added to the list: ".concat(e)),bt.addItem(qn,{id:e})}))}(e):Promise.reject({message:"Event won't be tracked, since it was previously tracked with the same deduplication id ".concat(e)})})):Promise.resolve()}function Fn(e){return{clickTime:_e(),source:"web_referrer",referrer:decodeURIComponent(e)}}function Wn(e,t){var n;(n=e||window.location.search.substring(1).split("&").map((function(e){return e.split("=")})).reduce(A,{}).adjust_referrer)&&an({url:"/sdk_click",method:"POST",params:Fn(n)},{timestamp:t})}var Vn=["logLevel","logOutput"],Hn=null,Yn=!1,zn=!1,Jn=!1;function Qn(e){ar("third-party sharing",(function(){return Ze.waitForWebUUID().then((function(){return function(e){e&&void 0!==e.isEnabled?an({url:"/third_party_sharing",method:"POST",params:{sharing:e.isEnabled?"enable":"disable",granularThirdPartySharingOptions:e.granularOptions,partnerSharingSettings:e.partnerSharingSettings}}):z.error("Can not track third-party sharing without parameters")}(e)}))}),{schedule:!1,optionalInit:!0})}function Xn(){var e;"paused"===zt()&&(Bn(),Promise.all([(e={uuid:"unknown"},Ze.current=e,bt.clear(Jt).then((function(){return bt.addItem(Jt,e)}))),bt.clear(dn),bt.clear(nn)]).then(tr))}function Zn(){return Yn||te.isInitialised()}function $n(){Yn=!1,zn=!1,Un=[],en.clear(),rn.running=!1,rn.timestamp=null,rn.pause=null,Sn=!1,Ze.toBackground(),Rn(),kn&&(clearTimeout(bn),Tt(wn,kn.visibilityChange,En),jt(wn,kn.visibilityChange,On)),xn.clear()}function er(e){e&&z.log("Adjust SDK has been shutdown due to asynchronous disable"),$n(),Le.forEach(clearTimeout),Le=[],Ue={},Ze.destroy(),Tt(window,"online",xt),Tt(window,"offline",Ct),bt.destroy(),te.destroy()}function tr(){Jn=!1,er(),jn.clear(),Hn=null,z.log("Adjust SDK instance has been destroyed")}function nr(e){z.log("Adjust SDK is starting with web_uuid set to ".concat(e.uuid));var t=Ze.current.installed;"paused"===zt()&&(z.log(Tn.running),_n(!0));var n=zt(),r=function(e){return"Adjust SDK start has been interrupted ".concat(e)};return"off"===n?(er(),Promise.reject({interrupted:!0,message:r("due to complete async disable")})):"paused"===n?($n(),Promise.reject({interrupted:!0,message:r("due to partial async disable")})):zn?Promise.reject({interrupted:!0,message:r("due to multiple synchronous start attempt")}):(sn({cleanUp:!0}),Pn().then((function(){Yn=!1,zn=!0,t&&rr()})))}function rr(){var e;Jn=!0,Un.forEach((function(e){"function"==typeof e.method&&(z.log("Delayed ".concat(e.description," task is running now")),e.method(e.timestamp))})),Un=[],(e="sdk:installed")&&x(Ue).some((function(t){var n=w(t,2)[1];return n.some((function(t,r){t.id===e&&n.splice(r,1)}))}))}function or(e){if(e.interrupted)z.log(e.message);else if(er(),z.error("Adjust SDK start has been canceled due to an error",e),e.stack)throw e}function ir(e){"off"!==zt()?(te.set(e),jt(window,"online",xt),jt(window,"offline",Ct),Ke("sdk:installed",rr),Ke("sdk:shutdown",(function(){return er(!0)})),Ke("sdk:gdpr-forget-me",Xn),Ke("attribution:check",(function(e,t){return n=t,r=Ze.current,(o=(n||{}).ask_in)||!r.attribution&&r.installed?(xn.send({params:a({initiatedBy:n?"backend":"sdk"},Ze.getParams()),wait:o}),Ze.updateSessionOffset(),$t()):Promise.resolve(r);var n,r,o})),"function"==typeof e.attributionCallback&&Ke("attribution:change",e.attributionCallback),(Qt?Promise.reject({interrupted:!0,message:"Adjust SDK start already in progress"}):(Qt=!0,bt.getFirst(Jt).then(Xt).then((function(e){if(e.exists)return Qt=!1,e.stored;var t,n=P(Ze.current)?{uuid:(t=Date.now(),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?n:11&n).toString(16)})))}:Ze.current;return bt.addItem(Jt,n).then((function(){return Ze.init(n),ut(),Qt=!1,n}))})).then((function(e){return qe(b.WEB_UUID_CREATED,e?e.uuid:"gdpr_forgotten"),e})))).then(nr).then(Wn).catch(or)):z.log("Adjust SDK is disabled, can not start the sdk")}function ar(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.schedule,o=n.waitForInitFinished,i=n.optionalInit;if(bt.getType()!==p.NO_STORAGE)if("on"===zt())if(i||Zn()||!o){if("function"==typeof t){if(!r||Jn&&zn||!i&&!Zn())return t();Ln(t,e),z.log("Running ".concat(e," is delayed until Adjust SDK is up"))}}else z.error("Adjust SDK can not ".concat(e,", sdk instance is not initialized"));else z.log("Adjust SDK is disabled, can not ".concat(e));else z.log("Adjust SDK can not ".concat(e,", no storage available"))}const ur={initSdk:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.logLevel,n=e.logOutput,r=u(e,Vn);z.setLogLevel(t,n),Zn()?z.error("You already initiated your instance"):te.hasMissing(r)||(Yn=!0,bt.init(r.namespace).then((function(e){e.type!==p.NO_STORAGE?(z.info("Available storage is ".concat(e.type)),Hn=a({},r),ir(r)):z.error("Adjust SDK can not start, there is no storage available")})))},getAttribution:function(){return ar("get attribution",(function(){return Ze.getAttribution()}))},getWebUUID:function(){return ar("get web_uuid",(function(){return Ze.getWebUUID()}))},waitForAttribution:function(){return ar("get attribution",(function(){return Ze.waitForAttribution()}),{schedule:!1})},waitForWebUUID:function(){return ar("get web_uuid",(function(){return Ze.waitForWebUUID()}),{schedule:!1})},setReferrer:function(e){e&&"string"==typeof e?ar("setting reftag",(function(t){return Wn(e,t)}),{schedule:!0,waitForInitFinished:!0,optionalInit:!0}):z.error("You must provide a string referrer")},trackEvent:function(e){return function(e){if(bt.getType()===p.NO_STORAGE){var t="Adjust SDK can not track event, no storage available";return z.log(t),Promise.reject(t)}if("on"!==zt()){var n="Adjust SDK is disabled, can not track event";return z.log(n),Promise.reject(n)}if(!Zn()){var r="Adjust SDK can not track event, sdk instance is not initialized";return z.error(r),Promise.reject(r)}return new Promise((function(t){var n=function(n){return t(function(e,t){if(!e||e&&(P(e)||!e.eventToken)){var n="You must provide event token in order to track event";return z.error(n),Promise.reject(n)}return Mn(e.deduplicationId).then(pn).then((function(n){return an({url:"/event",method:"POST",params:Gn(e,n)},{timestamp:t})})).catch((function(e){return e&&e.message&&z.error(e.message),Promise.reject(e)}))}(e,n))};!Jn||!zn&&Zn()?(Ln(n,"track event"),z.log("Running track event is delayed until Adjust SDK is up")):n()}))}(e)},addGlobalCallbackParameters:function(e){ar("add global callback parameters",(function(){return vn(e,"callback")}))},addGlobalPartnerParameters:function(e){ar("add global partner parameters",(function(){return vn(e,"partner")}))},removeGlobalCallbackParameter:function(e){ar("remove global callback parameter",(function(){return hn(e,"callback")}))},removeGlobalPartnerParameter:function(e){ar("remove global partner parameter",(function(){return hn(e,"partner")}))},clearGlobalCallbackParameters:function(){ar("remove all global callback parameters",(function(){return gn("callback")}))},clearGlobalPartnerParameters:function(){ar("remove all global partner parameters",(function(){return gn("partner")}))},switchToOfflineMode:function(){ar("set offline mode",(function(){return cn(!0)}))},switchBackToOnlineMode:function(){ar("set online mode",(function(){return cn(!1)}))},stop:function(){Yt()&&te.isInitialised()&&er()},restart:function(){var e;((e=(it()||{}).reason)===f.REASON_GDPR?(z.log("Adjust SDK is disabled due to GDPR-Forget-Me request and it can not be re-enabled"),!1):e?(z.log("Adjust SDK has been enabled"),at(null),!0):(z.log("Adjust SDK is already enabled"),!1))&&Hn&&ir(Hn)},gdprForgetMe:function(){var e=_n();e&&(e=Yt(f.REASON_GDPR,!0))&&te.isInitialised()&&$n()},disableThirdPartySharing:function(){Qn({isEnabled:!1})},trackThirdPartySharing:Qn,ThirdPartySharing:function(){return je((function e(t){xe(this,e),o(this,"_granularOptions",{}),o(this,"_partnerSharingSettings",{}),"boolean"!=typeof t&&z.warn("isEnabled should be boolean, converting ".concat(t," results ").concat(!!t)),this._isEnabled=!!t}),[{key:"isEnabled",get:function(){return this._isEnabled}},{key:"granularOptions",get:function(){return this._granularOptions}},{key:"partnerSharingSettings",get:function(){return this._partnerSharingSettings}},{key:"addGranularOption",value:function(e,t,n){if(e&&t&&void 0!==n){var r=o({},t,n);this.granularOptions[e]?this.granularOptions[e]=a(a({},this.granularOptions[e]),r):this.granularOptions[e]=r}else z.error("Cannot add granular option, partnerName, key and value are mandatory")}},{key:"addPartnerSharingSetting",value:function(e,t,n){if(e&&t&&void 0!==n){var r=o({},t,n);this.partnerSharingSettings[e]?this.partnerSharingSettings[e]=a(a({},this.partnerSharingSettings[e]),r):this.partnerSharingSettings[e]=r}else z.error("Cannot add partner sharing setting, partnerName, key and value are mandatory")}}])}(),initSmartBanner:function(){z.error("function `initSmartBanner` is deprecated")},showSmartBanner:function(){z.error("function `showSmartBanner` is deprecated")},hideSmartBanner:function(){z.error("function `hideSmartBanner` is deprecated")},__testonly__:{destroy:tr,clearDatabase:function(){return bt.deleteDatabase()}},__internal__:{restartAfterAsyncEnable:function(){z.log("Adjust SDK has been restarted due to asynchronous enable"),Hn&&ir(Hn)}}};return t=t.default})())); \ No newline at end of file diff --git a/dist/sdk.snippet-sri.min.js b/dist/sdk.snippet-sri.min.js index 22dc7a2..eb9abf8 100644 --- a/dist/sdk.snippet-sri.min.js +++ b/dist/sdk.snippet-sri.min.js @@ -1 +1 @@ -!function(a,e,t,r,n,o,i,l,s,c,d){var m=i+"_q";a[i]=a[i]||{},a[m]=a[m]||[];for(var b=0;b