diff --git a/.gitignore b/.gitignore index e13c7f2..833d261 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ +.vscode/ *.log *.DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index 07cb70e..6b3f4a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +### Version 5.1.0 (5th August 2020) +#### Added +- Added external device ID support. + +#### Fixed +- Fixed SDK initialization in IE11. + +--- + ### Version 5.0.0 (15th May 2020) #### Added - New major SDK update. diff --git a/Jenkinsfile b/Jenkinsfile index 5e39456..b7d014d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,12 +18,20 @@ pipeline { } } stage('Build Production') { + when { + branch "master" + } + steps { sh "npm run clean" sh "npm run build:demo" } } stage('Deploy Production') { + when { + branch "master" + } + steps { sh "rsync -e 'ssh -o StrictHostKeyChecking=no' -va --rsync-path='mkdir -p /home/dashboard/web-sdk-demo/current/public/ && rsync' --delete ./demo/ dashboard@jenkins-2.adjust.com://home/dashboard/web-sdk-demo/current/public/" } diff --git a/README.md b/README.md index 7484b1a..0f3d818 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ To lazy load the Adjust Web SDK through CDN paste the following snippet into the The Adjust Web SDK should be loaded only once per page and it should be initiated once per page load. -When loading the sdk through CDN we suggest using minified version. You can target specific version like `https://cdn.adjust.com/adjust-5.0.0.min.js`, or you can target latest version `https://cdn.adjust.com/adjust-latest.min.js` if you want automatic updates without need to change the target file. The sdk files are cached so they are served as fast as possible, and the cache is refreshed every half an hour. If you want updates immediately make sure to target specific version. +When loading the sdk through CDN we suggest using minified version. You can target specific version like `https://cdn.adjust.com/adjust-5.1.0.min.js`, or you can target latest version `https://cdn.adjust.com/adjust-latest.min.js` if you want automatic updates without need to change the target file. The sdk files are cached so they are served as fast as possible, and the cache is refreshed every half an hour. If you want updates immediately make sure to target specific version. It's also possible to install our sdk through NPM: diff --git a/VERSION b/VERSION index 0062ac9..831446c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.0 +5.1.0 diff --git a/dist/adjust-latest.js b/dist/adjust-latest.js index 9352ccb..2ed8265 100644 --- a/dist/adjust-latest.js +++ b/dist/adjust-latest.js @@ -91,7 +91,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 17); +/******/ return __webpack_require__(__webpack_require__.s = 16); /******/ }) /************************************************************************/ /******/ ([ @@ -140,11 +140,11 @@ module.exports = _objectSpread2; /* 1 */ /***/ (function(module, exports, __webpack_require__) { -var arrayWithHoles = __webpack_require__(5); +var arrayWithHoles = __webpack_require__(10); -var iterableToArrayLimit = __webpack_require__(14); +var iterableToArrayLimit = __webpack_require__(11); -var nonIterableRest = __webpack_require__(6); +var nonIterableRest = __webpack_require__(12); function _slicedToArray(arr, i) { return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest(); @@ -1351,17 +1351,17 @@ return Promise$1; //# sourceMappingURL=es6-promise.map -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(12), __webpack_require__(13))) +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(8), __webpack_require__(9))) /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { -var arrayWithoutHoles = __webpack_require__(15); +var arrayWithoutHoles = __webpack_require__(13); -var iterableToArray = __webpack_require__(7); +var iterableToArray = __webpack_require__(14); -var nonIterableSpread = __webpack_require__(16); +var nonIterableSpread = __webpack_require__(15); function _toConsumableArray(arr) { return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread(); @@ -1371,39 +1371,9 @@ module.exports = _toConsumableArray; /***/ }), /* 5 */ -/***/ (function(module, exports) { - -function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; -} - -module.exports = _arrayWithHoles; - -/***/ }), -/* 6 */ -/***/ (function(module, exports) { - -function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); -} - -module.exports = _nonIterableRest; - -/***/ }), -/* 7 */ -/***/ (function(module, exports) { - -function _iterableToArray(iter) { - if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); -} - -module.exports = _iterableToArray; - -/***/ }), -/* 8 */ /***/ (function(module, exports, __webpack_require__) { -var objectWithoutPropertiesLoose = __webpack_require__(11); +var objectWithoutPropertiesLoose = __webpack_require__(7); function _objectWithoutProperties(source, excluded) { if (source == null) return {}; @@ -1427,7 +1397,7 @@ function _objectWithoutProperties(source, excluded) { module.exports = _objectWithoutProperties; /***/ }), -/* 9 */ +/* 6 */ /***/ (function(module, exports) { function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } @@ -1449,23 +1419,7 @@ function _typeof(obj) { module.exports = _typeof; /***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { - -var arrayWithHoles = __webpack_require__(5); - -var iterableToArray = __webpack_require__(7); - -var nonIterableRest = __webpack_require__(6); - -function _toArray(arr) { - return arrayWithHoles(arr) || iterableToArray(arr) || nonIterableRest(); -} - -module.exports = _toArray; - -/***/ }), -/* 11 */ +/* 7 */ /***/ (function(module, exports) { function _objectWithoutPropertiesLoose(source, excluded) { @@ -1486,7 +1440,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { module.exports = _objectWithoutPropertiesLoose; /***/ }), -/* 12 */ +/* 8 */ /***/ (function(module, exports) { // shim for using process in browser @@ -1676,7 +1630,7 @@ process.umask = function() { return 0; }; /***/ }), -/* 13 */ +/* 9 */ /***/ (function(module, exports) { var g; @@ -1702,7 +1656,17 @@ module.exports = g; /***/ }), -/* 14 */ +/* 10 */ +/***/ (function(module, exports) { + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +module.exports = _arrayWithHoles; + +/***/ }), +/* 11 */ /***/ (function(module, exports) { function _iterableToArrayLimit(arr, i) { @@ -1738,7 +1702,17 @@ function _iterableToArrayLimit(arr, i) { module.exports = _iterableToArrayLimit; /***/ }), -/* 15 */ +/* 12 */ +/***/ (function(module, exports) { + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} + +module.exports = _nonIterableRest; + +/***/ }), +/* 13 */ /***/ (function(module, exports) { function _arrayWithoutHoles(arr) { @@ -1754,7 +1728,17 @@ function _arrayWithoutHoles(arr) { module.exports = _arrayWithoutHoles; /***/ }), -/* 16 */ +/* 14 */ +/***/ (function(module, exports) { + +function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); +} + +module.exports = _iterableToArray; + +/***/ }), +/* 15 */ /***/ (function(module, exports) { function _nonIterableSpread() { @@ -1764,7 +1748,7 @@ function _nonIterableSpread() { module.exports = _nonIterableSpread; /***/ }), -/* 17 */ +/* 16 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -1808,7 +1792,7 @@ var objectSpread2 = __webpack_require__(0); var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectWithoutProperties.js -var objectWithoutProperties = __webpack_require__(8); +var objectWithoutProperties = __webpack_require__(5); var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js @@ -1819,6 +1803,22 @@ var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); var toConsumableArray = __webpack_require__(4); var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray); +// CONCATENATED MODULE: ./src/sdk/globals.js +/*:: declare var __ADJUST__NAMESPACE: string*/ + +/*:: declare var __ADJUST__SDK_VERSION: string*/ + +/*:: declare var process: {| + env: {| + NODE_ENV: 'development' | 'production' | 'test' + |} +|}*/ +var Globals = { + namespace: "adjust-sdk" || false, + version: "5.1.0" || false, + env: "production" +}; +/* harmony default export */ var globals = (Globals); // CONCATENATED MODULE: ./src/sdk/constants.js var SECOND = 1000; var MINUTE = SECOND * 60; @@ -1840,7 +1840,7 @@ var defineProperty = __webpack_require__(2); var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/typeof.js -var helpers_typeof = __webpack_require__(9); +var helpers_typeof = __webpack_require__(6); var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof); // CONCATENATED MODULE: ./src/sdk/utilities.js @@ -2067,18 +2067,19 @@ function isEmptyEntry(value) { } -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/toArray.js -var toArray = __webpack_require__(10); -var toArray_default = /*#__PURE__*/__webpack_require__.n(toArray); - // CONCATENATED MODULE: ./src/sdk/logger.js - var _levels2; +/*:: import { type LogOptionsT } from './types';*/ + +/*:: type LogLevelT = $PropertyType*/ + +/*:: type MethodNameT = 'log' | 'info' | 'error' | 'warn'*/ + var LEVEL_NONE = 'none'; var LEVEL_ERROR = 'error'; var LEVEL_INFO = 'info'; @@ -2108,26 +2109,10 @@ var _envLogLevels = { production: LEVEL_ERROR, test: LEVEL_VERBOSE /** - * Available logger methods - * - * @type {Array} - * @private + * Current logger level */ }; -var _methods = [{ - name: 'log', - level: LEVEL_VERBOSE -}, { - name: 'info', - level: LEVEL_INFO -}, { - name: 'error', - level: LEVEL_ERROR -}]; -/** - * Current logger level - */ var _level = _getDefaultLogLevel(); /** @@ -2146,8 +2131,10 @@ var _output = ''; * @private */ -function _getDefaultLogLevel() { - return _envLogLevels["production"] || LEVEL_ERROR; +function _getDefaultLogLevel() +/*: LogLevelT*/ +{ + return _envLogLevels[globals.env] || LEVEL_ERROR; } /** * Set logger level, fallback to default log level @@ -2157,11 +2144,17 @@ function _getDefaultLogLevel() { */ -function setLogLevel(logLevel, logOutput) { +function setLogLevel(logLevel +/*: LogLevelT*/ +, logOutput +/*: string*/ +) +/*: void*/ +{ var exists = !logLevel || Object.keys(_levels).indexOf(logLevel) !== -1; if (!exists) { - _log('error', 'You must set one of the available log levels: verbose, info, error or none'); + _log('error', 'error', 'You must set one of the available log levels: verbose, info, error or none'); return; } @@ -2169,68 +2162,84 @@ function setLogLevel(logLevel, logOutput) { _level = logLevel || _getDefaultLogLevel(); _output = logOutput; - _log('info', "Log level set to ".concat(_level)); + _log('info', logLevel, "Log level set to ".concat(_level)); } /** * Output the message to the console * * @param {string} methodName - * @param {string} args + * @param {string} logLevel + * @param {Array} args * @private */ -function _log(methodName) { - var now = new Date().toISOString(); +function _log +/*:: */ +(methodName +/*: MethodNameT*/ +, logLevel +/*: LogLevelT*/ +) +/*: void*/ +{ + var _console; - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + if (_levels[_level] < _levels[logLevel]) { + return; } - var message = ["[".concat(config.namespace, "]"), now, "".concat(methodName.toUpperCase(), ":")].concat(args); + var time = new Date().toISOString(); + var spaces = methodName === 'log' ? ' ' : methodName === 'info' ? ' ' : ''; + var messagePrefix = ["[".concat(globals.namespace, "]"), time, "".concat(methodName.toUpperCase(), ":").concat(spaces)]; var outputContainer = _output ? document.querySelector(_output) : null; - console[methodName].apply(null, message); // eslint-disable-line + + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + (_console = console)[methodName].apply(_console, messagePrefix.concat(args)); // eslint-disable-line + if (outputContainer) { - var _message = toArray_default()(message), - namespace = _message[0], - time = _message[1], - prefix = _message[2], - rest = _message.slice(3); - - var spaces = methodName === 'log' ? ' ' : methodName === 'info' ? ' ' : ''; - outputContainer.textContent += "".concat(namespace, " ").concat(time, " ").concat(prefix).concat(spaces, " ").concat(rest.map(function (m) { + outputContainer.textContent += "".concat(messagePrefix.join(' '), " ").concat(args.map(function (m) { return isObject(m) ? JSON.stringify(m) : m; }).join(' '), "\n"); outputContainer.scrollTop = outputContainer.scrollHeight; } } +/** + * Apply predefined log level and return log method + * + * @param {string} name + * @param {string} logLevel + * @returns {Array} args + * @private + */ -var Logger = { - setLogLevel: setLogLevel -}; - -_methods.forEach(function (method) { - Object.defineProperty(Logger, method.name, { - writable: false, - value: function value() { - if (_levels[_level] >= _levels[method.level]) { - for (var _len2 = arguments.length, message = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - message[_key2] = arguments[_key2]; - } - _log.apply(void 0, [method.name].concat(message)); - } +function _applyLevel(name +/*: MethodNameT*/ +, logLevel +/*: LogLevelT*/ +) { + return function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - }); -}); + _log.apply(void 0, [name, logLevel].concat(args)); + }; +} + +var Logger = { + setLogLevel: setLogLevel, + log: _applyLevel('log', LEVEL_VERBOSE), + info: _applyLevel('info', LEVEL_INFO), + error: _applyLevel('error', LEVEL_ERROR) +}; /* harmony default export */ var logger = (Logger); // CONCATENATED MODULE: ./src/sdk/config.js -/*:: declare var __ADJUST__NAMESPACE: string*/ - -/*:: declare var __ADJUST__SDK_VERSION: string*/ - /*:: import { type BaseParamsT, type CustomConfigT, type InitOptionsT, type BaseParamsListT, type BaseParamsMandatoryListT, type CustomConfigListT } from './types';*/ @@ -2238,11 +2247,13 @@ _methods.forEach(function (method) { + /** * Base parameters set by client * - app token * - environment * - default tracker + * - external device ID * * @type {Object} * @private @@ -2282,7 +2293,7 @@ var _mandatory var _allowedParams /*: BaseParamsListT*/ -= [].concat(_mandatory, ['defaultTracker']); += [].concat(_mandatory, ['defaultTracker', 'externalDeviceId']); /** * Allowed configuration overrides * @@ -2308,12 +2319,13 @@ var _allowedConfig */ var _baseConfig = { - namespace: "adjust-sdk" || false, - version: "5.0.0" || false, sessionWindow: 30 * MINUTE, sessionTimerWindow: 60 * SECOND, requestValidityWindow: 28 * DAY, - baseUrl: false ? undefined : { + baseUrl: globals.env === 'test' ? { + app: 'app', + gdpr: 'gdpr' + } : { app: 'https://app.adjust.com', gdpr: 'https://gdpr.adjust.com' } @@ -2865,8 +2877,14 @@ var StoreNames = _getStoreNames(); * @returns {string} * @private */ -function _prependZero(value) { - var power = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; +function _prependZero(value +/*: number*/ +) +/*: string*/ +{ + var power + /*: number*/ + = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var formatted = value + ''; for (var i = 1; i <= power; i += 1) { @@ -2879,13 +2897,18 @@ function _prependZero(value) { } /** * Get formatted date (YYYY-MM-DD) + * * @param date * @returns {string} * @private */ -function _getDate(date) { +function _getDate(date +/*: Date*/ +) +/*: string*/ +{ var day = _prependZero(date.getDate()); var month = _prependZero(date.getMonth() + 1); @@ -2902,7 +2925,11 @@ function _getDate(date) { */ -function _getTime(date) { +function _getTime(date +/*: Date*/ +) +/*: string*/ +{ var hours = _prependZero(date.getHours(), 1); var minutes = _prependZero(date.getMinutes()); @@ -2922,7 +2949,11 @@ function _getTime(date) { */ -function _getTimezone(date) { +function _getTimezone(date +/*: Date*/ +) +/*: string*/ +{ var offsetInMinutes = date.getTimezoneOffset(); var hoursOffset = _prependZero(Math.floor(Math.abs(offsetInMinutes) / 60)); @@ -2940,7 +2971,11 @@ function _getTimezone(date) { */ -function getTimestamp(timestamp) { +function getTimestamp(timestamp +/*: number*/ +) +/*: string*/ +{ var d = timestamp ? new Date(timestamp) : new Date(); var date = _getDate(d); @@ -2960,7 +2995,13 @@ function getTimestamp(timestamp) { */ -function timePassed(d1, d2) { +function timePassed(d1 +/*: number*/ +, d2 +/*: number*/ +) +/*: number*/ +{ if (isNaN(d1) || isNaN(d2)) { return 0; } @@ -3592,7 +3633,7 @@ function decodeErrorMessage(_ref10) { -var _storageName = config.namespace; +var _storageName = globals.namespace; var _storeNames = scheme_map.storeNames.left; /** * Get the value for specified key @@ -3669,13 +3710,17 @@ Object.freeze(QuickStorage.stores); // CONCATENATED MODULE: ./src/sdk/pub-sub.js +/*:: type CallbackT = {| + id: string, + cb: (string, T) => mixed +|}*/ + /** * List of events with subscribed callbacks * * @type {Object} * @private */ - var _list = {}; /** * Reference to timeout ids so they can be cleared on destroy @@ -3692,7 +3737,9 @@ var _timeoutIds = []; * @private */ -function _getId() { +function _getId() +/*: string*/ +{ return 'id' + Math.random().toString(36).substr(2, 16); } /** @@ -3704,17 +3751,29 @@ function _getId() { */ -function subscribe(name, cb) { +function subscribe +/*:: */ +(name +/*: string*/ +, cb +/*: $PropertyType, 'cb'>*/ +) +/*: string*/ +{ var id = _getId(); + var callback + /*: CallbackT*/ + = { + id: id, + cb: cb + }; + if (!_list[name]) { _list[name] = []; } - _list[name].push({ - id: id, - cb: cb - }); + _list[name].push(callback); return id; } @@ -3725,7 +3784,11 @@ function subscribe(name, cb) { */ -function unsubscribe(id) { +function unsubscribe(id +/*: string*/ +) +/*: void*/ +{ if (!id) { return; } @@ -3734,7 +3797,11 @@ function unsubscribe(id) { var _ref2 = slicedToArray_default()(_ref, 2), callbacks = _ref2[1]; - return callbacks.some(function (callback, i) { + return callbacks.some(function (callback + /*: CallbackT*/ + , i + /*: number*/ + ) { if (callback.id === id) { callbacks.splice(i, 1); return true; @@ -3751,12 +3818,22 @@ function unsubscribe(id) { */ -function publish(name, args) { +function publish +/*:: */ +(name +/*: string*/ +, args +/*: T*/ +) +/*: void*/ +{ if (!_list[name]) { - return []; + return; } - _list[name].forEach(function (item) { + _list[name].forEach(function (item + /*: CallbackT*/ + ) { if (typeof item.cb === 'function') { _timeoutIds.push(setTimeout(function () { return item.cb(name, args); @@ -3769,7 +3846,9 @@ function publish(name, args) { */ -function pub_sub_destroy() { +function pub_sub_destroy() +/*: void*/ +{ _timeoutIds.forEach(clearTimeout); _timeoutIds = []; @@ -3929,7 +4008,7 @@ function reload() = (_preferences || {}).sdkDisabled || null; if (stored.sdkDisabled && !sdkDisabled) { - publish('sdk:shutdown', true); + publish('sdk:shutdown'); } _setPreferences(); @@ -3967,7 +4046,7 @@ var _Promise = typeof Promise === 'undefined' ? __webpack_require__(3).Promise : -var _dbName = config.namespace; +var _dbName = globals.namespace; var _dbVersion = 1; var _db; @@ -5260,7 +5339,7 @@ var storage_Promise = typeof Promise === 'undefined' ? __webpack_require__(3).Pr * @private */ -var storage_methods = { +var _methods = { getAll: _getAll, getFirst: _getFirst, getItem: _getItem, @@ -5543,7 +5622,7 @@ function _clear(storage, storeName) { function _augment(storage) { - return entries(storage_methods).map(function (_ref) { + return entries(_methods).map(function (_ref) { var _ref2 = slicedToArray_default()(_ref, 2), methodName = _ref2[0], method = _ref2[1]; @@ -5791,6 +5870,7 @@ var http_Promise = typeof Promise === 'undefined' ? __webpack_require__(3).Promi + /*:: type ParamsWithAttemptsT = $PropertyType*/ /** @@ -6041,7 +6121,7 @@ function _prepareHeaders(xhr /*: void*/ { var logHeader = 'REQUEST HEADERS:'; - var headers = [['Client-SDK', "js".concat(config.version)], ['Content-Type', method === 'POST' ? 'application/x-www-form-urlencoded' : 'application/json']]; + var headers = [['Client-SDK', "js".concat(globals.version)], ['Content-Type', method === 'POST' ? 'application/x-www-form-urlencoded' : 'application/json']]; logger.log(logHeader); headers.forEach(function (_ref13) { var _ref14 = slicedToArray_default()(_ref13, 2), @@ -6153,7 +6233,7 @@ function _interceptSuccess(result var optedOut = result.tracking_state === 'opted_out'; if (!isGdprRequest && optedOut) { - publish('sdk:gdpr-forget-me', true); + publish('sdk:gdpr-forget-me'); return result; } @@ -6166,7 +6246,7 @@ function _interceptSuccess(result } if (isThirdPartySharingOptOutRequest) { - publish('sdk:third-party-sharing-opt-out', true); + publish('sdk:third-party-sharing-opt-out'); return result; } @@ -8140,14 +8220,16 @@ function _handleVisibilityChange() /** * Handle session request finish; update installed state * - * @param {Object} e + * @param {string} e * @param {Object} result * @returns {Promise|void} * @private */ -function _handleSessionRequestFinish(e, result +function _handleSessionRequestFinish(e +/*: string*/ +, result /*: HttpSuccessResponseT | HttpErrorResponseT*/ ) /*: ?Promise*/ @@ -8514,7 +8596,7 @@ function forget(force gdpr_forget_device_request.send({ params: objectSpread2_default()({}, activity_state.getParams()) }).then(function () { - publish('sdk:gdpr-forget-me', true); + publish('sdk:gdpr-forget-me'); }); return true; @@ -9077,7 +9159,7 @@ var main_Promise = typeof Promise === 'undefined' ? __webpack_require__(3).Promi -/*:: type IntiConfigT = $ReadOnly<{|...InitOptionsT, ...LogOptionsT|}>*/ +/*:: type InitConfigT = $ReadOnly<{|...InitOptionsT, ...LogOptionsT|}>*/ /** * In-memory parameters to be used if restarting @@ -9523,6 +9605,7 @@ function main_error(error * @param {string} options.appToken * @param {string} options.environment * @param {string=} options.defaultTracker + * @param {string=} options.externalDeviceId * @param {string=} options.customUrl * @param {number=} options.eventDeduplicationListLimit * @param {Function=} options.attributionCallback diff --git a/dist/adjust-latest.min.js b/dist/adjust-latest.min.js index e8e05df..623a9ee 100644 --- a/dist/adjust-latest.min.js +++ b/dist/adjust-latest.min.js @@ -1,8 +1,8 @@ -!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()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=17)}([function(e,t,n){var r=n(2);function o(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}e.exports=function(e){for(var t=1;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}},function(e,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})(e)}function r(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=r=function(e){return n(e)}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)},r(t)}e.exports=r},function(e,t,n){var r=n(5),o=n(7),i=n(6);e.exports=function(e){return r(e)||o(e)||i()}},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var s,c=[],l=!1,f=-1;function d(){l&&s&&(l=!1,s.length?c=s.concat(c):f=-1,c.length&&m())}function m(){if(!l){var e=u(d);l=!0;for(var t=c.length;t;){for(s=c,c=[];++f1)for(var n=1;n0&&void 0!==arguments[0]?arguments[0]:[];return e.reduce((function(e,t){return a()({},e,v()({},t.key,t.value))}),{})}function P(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.filter((function(e){return-1!==t.indexOf(e)}))}function N(e,t){return new RegExp("\\/".concat(t,"(\\/.*|\\?.*){0,1}$")).test(e)}function _(e,t){var n=l()(t,2),r=n[0],o=n[1];return a()({},e,v()({},r,o))}function x(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,n={entries:function(t){return[t,e[t]]},values:function(t){return e[t]}};return Object[t]?Object[t](e):Object.keys(e).map(n[t])}function O(e){return x(e,"entries")}function j(e){return b(e)?!y(e):!!e||0===e}var I,T=n(10),A=n.n(T),E=(I={},v()(I,"none",-1),v()(I,"error",0),v()(I,"info",1),v()(I,"verbose",2),I),D="error",R=[{name:"log",level:"verbose"},{name:"info",level:"info"},{name:"error",level:"error"}],C=M(),L="";function M(){return D||"error"}function B(e){for(var t=(new Date).toISOString(),n=arguments.length,r=new Array(n>1?n-1:0),o=1;o=E[e.level]){for(var t=arguments.length,n=new Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:1,n=e+"",r=1;r<=t;r+=1)e0?"-":"+")+ue(Math.floor(Math.abs(t)/60))+ue(Math.abs(t)%60)}(t);return"".concat(n,"T").concat(r,"Z").concat(o)}function ce(e,t){return isNaN(e)||isNaN(t)?0:Math.abs(t-e)}var le={},fe=!1,de=!1;function me(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};le=fe?a()({},e):{}}function pe(){fe&&(le.lastInterval=function(){var e=le.lastActive;if(e)return Math.round(ce(e,Date.now())/1e3);return-1}(),le.lastActive=Date.now())}function ve(e){le=a()({},le,{},e)}function he(){de=!0}function ge(){var e=le.lastActive;return Math.round(ce(e,Date.now())/1e3)}function ye(){return(le.timeSpent||0)+(de?ge():0)}function be(){var e=ce(le.lastActive,Date.now())=0?le.lastInterval:0,n={timeSpent:le.timeSpent||0,sessionLength:le.sessionLength||0,sessionCount:le.sessionCount||1,lastInterval:t||0};return e&&N(e,"event")&&(n.eventCount=le.eventCount),n},updateParams:function(e,t){if(fe){var n={};n.timeSpent=ye(),n.sessionLength=be(),N(e,"session")&&(n.sessionCount=(le.sessionCount||0)+1),N(e,"event")&&(n.eventCount=(le.eventCount||0)+1),ve(n),t||pe()}},updateInstalled:function(){fe&&(le.installed||ve({installed:!0}))},updateSessionOffset:we,updateSessionLength:function(){fe&&(ve({sessionLength:be()}),pe())},resetSessionOffset:function(){fe&&ve({timeSpent:0,sessionLength:0})},updateLastActive:pe,destroy:function(){le={},fe=!1,de=!1}};function Se(e,t){return e&&void 0!==e[t]?e[t]:t}function Pe(e){var t=e.storeName,n=e.dir,r=e.record,o=e.scheme;if(r)return o=o||ae[n][Oe({storeName:t,dir:"right"})].fields,O(r).map((function(e){var r=l()(e,2),i=r[0],a=r[1];return function(e){var t=e.storeName,n=e.scheme,r=e.dir,o=e.key,i=e.value;if(!n)return[o,i];var a=n.key||n;return b(i)?[a,Pe({storeName:t,dir:r,record:i,scheme:n.keys})]:[a,Se(n.values,i)]}({storeName:t,scheme:o[i],dir:n,key:i,value:a})})).reduce((function(e,t){var n=l()(t,2),r=n[0],o=n[1];return a()({},e,v()({},r,o))}),{})}function Ne(e){var t=e.storeName,n=e.dir,r=e.records;return(void 0===r?[]:r).map((function(e){return Pe({storeName:t,dir:n,record:e})}))}function _e(e){var t=e.storeName,n=e.dir,r=e.target,o=ae[n][Oe({storeName:t,dir:"right"})],i=o.fields[o.keyPath],a=r instanceof Array?r.slice():[r],u=(i.composite||[o.keyPath]).map((function(e,t){return Se(o.fields[e].values,a[t])}));return 1===u.length?u[0]:u}function xe(e){return ae.values[e]||e}function Oe(e){var t=e.storeName,n=e.dir;return(ae.storeNames[n][t]||{}).name||t}function je(e){var t=e.storeName,n=e.error;return{name:n.name,message:n.message.replace('"'.concat(t,'"'),Oe({storeName:t,dir:"right"}))}}var Ie=z.namespace,Te=ae.storeNames.left;var Ae={storeNames:Te,stores:{},clear:function(){O(Te).forEach((function(e){var t=l()(e,2)[1];t.permanent||localStorage.removeItem("".concat(Ie,".").concat(t.name))}))}};O(Te).forEach((function(e){var t=l()(e,2)[1];Object.defineProperty(Ae.stores,t.name,{get:function(){return e=t.name,((n=JSON.parse(localStorage.getItem("".concat(Ie,".").concat(e))))instanceof Array?n:Pe({storeName:Te.preferences.name,dir:"right",record:n}))||null;var e,n},set:function(e){return function(e,t){t?localStorage.setItem("".concat(Ie,".").concat(e),JSON.stringify(t instanceof Array?t:Pe({storeName:Te.preferences.name,dir:"left",record:t}))):localStorage.removeItem("".concat(Ie,".").concat(e))}(t.name,e)}})})),Object.freeze(Ae.stores);var Ee=Ae,De={},Re=[];function Ce(e,t){var n="id"+Math.random().toString(36).substr(2,16);return De[e]||(De[e]=[]),De[e].push({id:n,cb:t}),n}function Le(e,t){if(!De[e])return[];De[e].forEach((function(n){"function"==typeof n.cb&&Re.push(setTimeout((function(){return n.cb(e,t)})))}))}var Me=Ee.storeNames.preferences.name,Be=qe();function qe(){return Be||Ke(),Be?a()({},Be):null}function Ke(){Be=Ee.stores[Me]}function Fe(){var e=qe();return e?e.sdkDisabled:null}function Ue(e){var t=e?a()({},e):null;Ee.stores[Me]=a()({},qe(),{sdkDisabled:t}),Ke()}function Ge(){var e=qe();return e?e.thirdPartySharingDisabled:null}function We(){var e=Ee.stores[Me]||{},t=(Be||{}).sdkDisabled||null;e.sdkDisabled&&!t&&Le("sdk:shutdown",!0),Ke()}function He(){Ee.stores[Me]||(Ee.stores[Me]=a()({},Be))}var Ye,Je="undefined"==typeof Promise?n(3).Promise:Promise,Ve=z.namespace;function ze(){var e=Qe(),t=!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform),n=!!e&&!t;return n||K.error("IndexedDB is not supported in this browser"),n}function Qe(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB}function Xe(){var e=Qe();return ze()?new Je((function(t,n){if(Ye)t({success:!0});else{var r=e.open(Ve,1);r.onupgradeneeded=function(e){return function(e,t){var n=e.target.result;e.target.transaction.onerror=t,e.target.transaction.onabort=t;var r=ae.storeNames.left,o=ke.current||{},i=o&&!y(o);O(r).filter((function(e){return!l()(e,2)[1].permanent})).forEach((function(e){var t=l()(e,2),a=t[0],u=t[1],s=ae.right[a],c=n.createObjectStore(u.name,{keyPath:s.keyPath,autoIncrement:s.autoIncrement||!1});s.index&&c.createIndex("".concat(s.index,"Index"),s.index),u.name===r.activityState.name&&i?(c.add(Pe({storeName:a,record:o,dir:"left"})),K.info("Activity state has been recovered")):Ee.stores[u.name]&&(Ee.stores[u.name].forEach((function(e){return c.add(e)})),K.info("Migration from localStorage done for ".concat(a," store")))})),He(),Ee.clear()}(e,n)},r.onsuccess=function(e){return function(e,t){Ye=e.target.result,t({success:!0}),Ye.onclose=yt}(e,t)},r.onerror=n}})):Je.reject({name:"IDBNotSupported",message:"IndexedDB is not supported"})}function Ze(e,t){var n,r=e.storeName,o=e.mode,i=Ye.transaction([r],o),a=i.objectStore(r),u=ae.right[Oe({storeName:r,dir:"right"})];return u.index&&(n=a.index("".concat(u.index,"Index"))),i.onerror=t,i.onabort=t,{transaction:i,store:a,index:n,options:u}}function $e(e,t){var n=t.target.error;return e({name:n.name,message:n.message})}function et(e){return e.fields[e.keyPath].composite||null}function tt(e,t,n){var r=-1!==["add","put"].indexOf(n),o=et(e);return o?r?a()(v()({},e.keyPath,o.map((function(e){return t[e]})).join("")),t):t?t.join(""):null:t}function nt(e,t){var n=et(e);return n&&b(t)?n.map((function(e){return t[e]})):null}function rt(e){var t=e.storeName,n=e.target,r=void 0===n?null:n,o=e.action,i=e.mode,a=void 0===i?"readonly":i;return Xe().then((function(){return new Je((function(e,n){var i=Ze({storeName:t,mode:a},n),u=i.store,s=i.options,c=u[o](tt(s,r,o)),l=nt(s,r);c.onsuccess=function(){"get"!==o||c.result?e(l||c.result||r):n({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(t,'" store')})},c.onerror=function(e){return $e(n,e)}}))}))}function ot(e){var t=e.storeName,n=e.action,r=void 0===n?"list":n,o=e.range,i=void 0===o?null:o,a=e.firstOnly,u=e.mode,s=void 0===u?"readonly":u;return Xe().then((function(){return new Je((function(e,n){var o=Ze({storeName:t,mode:s},n),u=o.transaction,c=o.store,l=o.index,f=o.options,d=(l||c).openCursor(i),m=[];u.oncomplete=function(){return e(a?m[0]:m)},d.onsuccess=function(e){var t=e.target.result;t&&("delete"===r?(t.delete(),m.push(nt(f,t.value)||t.value[f.keyPath])):m.push(t.value),a||t.continue())},d.onerror=function(e){return $e(n,e)}}))}))}function it(e,t){return ot({storeName:e,firstOnly:t})}function at(e){return it(e,!0)}function ut(e,t){return rt({storeName:e,target:t,action:"get"})}function st(e,t){return ot({storeName:e,range:IDBKeyRange.only(t)})}function ct(e,t){return rt({storeName:e,target:t,action:"add",mode:"readwrite"})}function lt(e,t,n){return function(e){var t=e.storeName,n=e.target,r=e.action,o=e.mode;return Xe().then((function(){return new Je((function(e,i){if(!n||n&&!n.length)return i({name:"NoTargetDefined",message:"No array provided to perform ".concat(r,' bulk operation into "').concat(t,'" store')});var a=Ze({storeName:t,mode:o},i),u=a.transaction,s=a.store,c=a.options,l=[],f=n[0];u.oncomplete=function(){return e(l)},function e(t){t.onerror=function(e){return $e(i,e)},t.onsuccess=function(){l.push(nt(c,f)||t.result),f=n[l.length],l.lengthe[r]:e[r]>t[r];return o?-1:i?1:0}(e,t,o)}),0)}))}function xt(e,t,n){var r=St(e);return r?a()(v()({},e.keyPath,r.map((function(e){return t[e]})).join("")),t):e.autoIncrement&&n?a()(v()({},e.keyPath,n),t):a()({},t)}function Ot(e,t){var n=St(e);return n&&b(t)?n.map((function(e){return t[e]})):t[e.keyPath]||t}function jt(e,t){var n=kt();return"error"===n.status?bt.reject(n.error):new bt((function(n,r){var o=Ee.stores[e];o instanceof Array?n(t?o[0]:_t(o,Pt(e))):r({name:"NotFoundError",message:"No objectStore named ".concat(e," in this database")})}))}function It(e){return jt(e,!0)}function Tt(e,t){return Nt({storeName:e,id:t},(function(t,n,r){var o=r.items,i=r.index,a=r.options;-1===i?n({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(e,'" store')}):t(xt(a,o[i]))}))}function At(e,t){return jt(e).then((function(n){return n.filter((function(n){return n[ae.right[Oe({storeName:e,dir:"right"})].index]===t}))}))}function Et(e,t){return Nt({storeName:e,item:t},(function(n,r,o){var i=o.items,a=o.index,u=o.options,s=o.lastId;-1!==a?r({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing item into "'.concat(e,'" store')}):(i.push(xt(u,t,s+1)),Ee.stores[e]=i,n(Ot(u,t)))}))}function Dt(e,t,n){return Nt({storeName:e},(function(r,o,i){var a=i.keys,u=i.items,s=i.options,c=i.lastId;if(!t||t&&!t.length)return o({name:"NoTargetDefined",message:'No array provided to perform add bulk operation into "'.concat(e,'" store')});var l=c,f=t.map((function(e){return xt(s,e,++l)})),m=f.filter((function(e){return-1!==k(u,a,e)})).map((function(e){return e[s.keyPath]})),p=n?u.filter((function(e){return-1===m.indexOf(e[s.keyPath])})):d()(u);m.length&&!n?o({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing items into "'.concat(e,'" store')}):(Ee.stores[e]=_t([].concat(d()(p),d()(f)),a),r(t.map((function(e){return Ot(s,e)}))))}))}function Rt(e,t){return Nt({storeName:e,item:t},(function(n,r,o){var i=o.items,a=o.index,u=o.options,s=o.lastId,c=xt(u,t,-1===a?s+1:null);-1===a?i.push(c):i.splice(a,1,c),Ee.stores[e]=i,n(Ot(u,t))}))}function Ct(e,t){return Nt({storeName:e,id:t},(function(n,r,o){var i=o.items,a=o.index;-1!==a&&(i.splice(a,1),Ee.stores[e]=i),n(t)}))}function Lt(e,t,n){return jt(e).then((function(r){var o=Pt(e),i=ae.right[Oe({storeName:e,dir:"right"})].index||o[0],a=_t(r,o,n?null:t),u=function(e,t,n){if(!e.length)return-1;for(var r={index:-1,value:isNaN(n)?"":0},o=0;o=r.value&&(r={value:e[o][t],index:o})}return r.index}(a,i,t);if(-1===u)return[];var s="lowerBound"===n?u:0,c=n&&"upperBound"!==n?a.length:u+1,l=a.splice(s,c).map((function(e){return 1===o.length?e[i]:o.map((function(t){return e[t]}))}));return Ee.stores[e]=a,l}))}function Mt(e,t){var n=kt(),r=ae.right[Oe({storeName:e,dir:"right"})];return"error"===n.status?bt.reject(n.error):jt(e).then((function(e){return e.length?e[t-1]:null})).then((function(t){return t?Lt(e,t[r.keyPath],"upperBound"):[]}))}function Bt(e){var t=kt();return"error"===t.status?bt.reject(t.error):bt.resolve(Ee.stores[e].length)}function qt(e){var t=kt();return"error"===t.status?bt.reject(t.error):new bt((function(t){Ee.stores[e]=[],t({})}))}function Kt(){}var Ft="undefined"==typeof Promise?n(3).Promise:Promise,Ut={getAll:function(e,t){return e.getAll(t).then((function(e){return Ne({storeName:t,dir:"right",records:e})}))},getFirst:function(e,t){return e.getFirst(t).then((function(e){return Pe({storeName:t,dir:"right",record:e})}))},getItem:function(e,t,n){return e.getItem(t,_e({storeName:t,dir:"left",target:n})).then((function(e){return Pe({storeName:t,dir:"right",record:e})})).catch((function(e){return Ft.reject(je({storeName:t,error:e}))}))},filterBy:function(e,t,n){return e.filterBy(t,xe(n)).then((function(e){return Ne({storeName:t,dir:"right",records:e})}))},addItem:function(e,t,n){return e.addItem(t,Pe({storeName:t,dir:"left",record:n})).then((function(e){return _e({storeName:t,dir:"right",target:e})})).catch((function(e){return Ft.reject(je({storeName:t,error:e}))}))},addBulk:function(e,t,n,r){return e.addBulk(t,Ne({storeName:t,dir:"left",records:n}),r).then((function(e){return e.map((function(e){return _e({storeName:t,dir:"right",target:e})}))})).catch((function(e){return Ft.reject(je({storeName:t,error:e}))}))},updateItem:function(e,t,n){return e.updateItem(t,Pe({storeName:t,dir:"left",record:n})).then((function(e){return _e({storeName:t,dir:"right",target:e})}))},deleteItem:function(e,t,n){return e.deleteItem(t,_e({storeName:t,dir:"left",target:n})).then((function(e){return _e({storeName:t,dir:"right",target:e})}))},deleteBulk:function(e,t,n,r){return e.deleteBulk(t,xe(n),r).then((function(e){return e.map((function(e){return _e({storeName:t,dir:"right",target: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)}};var Gt,Wt,Ht=(ze()?(Gt=r,Wt="indexedDB"):wt()&&(Gt=o,Wt="localStorage"),Wt?a()({type:Wt,isSupported:Gt.isSupported,destroy:Gt.destroy},function(e){return O(Ut).map((function(t){var n=l()(t,2),r=n[0],o=n[1];return[r,function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i2&&void 0!==arguments[2]&&arguments[2];return{status:"error",action:n?"CONTINUE":"RETRY",response:w(e.responseText)?JSON.parse(e.responseText):e.responseText,message:m[t],code:t}}function zt(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 Qt(e,t){var n=function(e){return e.replace(/([A-Z])/g,(function(e){return"_".concat(e.toLowerCase())}))},r=O(a()({},z.getBaseParams(),{},t,{},e)).map((function(e){var t=l()(e,2),r=t[0],o=t[1];return[n(r),o]}));return K.log("REQUEST PARAMETERS:"),r.filter((function(e){return j(l()(e,2)[1])})).map((function(e){var t=l()(e,2),n=t[0],r=t[1];return K.log(zt("REQUEST PARAMETERS:",n),r),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)),b(r)&&(i=encodeURIComponent(JSON.stringify(r)||"")),[o,i].join("=")}([n,r])})).join("&")}function Xt(e,t,n){var r=n.xhr,o=n.url;if(4===r.readyState){var i=r.status>=200&&r.status<300,a=w(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 N(t,"attribution")&&(r.attribution=n.attribution,r.message=n.message),O(r).filter((function(e){return!!l()(e,2)[1]})).reduce(_,{})}(r,o):Vt(r,"SERVER_CANNOT_PROCESS",!0)):e(Vt(r,i?"SERVER_MALFORMED_RESPONSE":"SERVER_INTERNAL_ERROR"));e(Vt(r,"NO_CONNECTION"))}}function Zt(e,t){var n=e.url,r=e.method,o=void 0===r?"GET":r,i=e.params,a=function(e,t){var n=e.url,r=e.method,o=Qt(e.params,t),i="/gdpr_forget_device"===n?"gdpr":"app";return{fullUrl:(z.getCustomConfig().customUrl||z.baseUrl[i])+n+("GET"===r?"?".concat(o):""),encodedParams:o}}({url:n,method:o,params:void 0===i?{}:i},t),u=a.fullUrl,s=a.encodedParams;return new Jt((function(e,t){var r=new XMLHttpRequest;r.open(o,u,!0),function(e,t){var n=[["Client-SDK","js".concat(z.version)],["Content-Type","POST"===t?"application/x-www-form-urlencoded":"application/json"]];K.log("REQUEST HEADERS:"),n.forEach((function(t){var n=l()(t,2),r=n[0],o=n[1];e.setRequestHeader(r,o),K.log(zt("REQUEST HEADERS:",r),o)}))}(r,o),r.onreadystatechange=function(){return Xt(t,e,{xhr:r,url:n})},r.onerror=function(){return t(Vt(r,"TRANSACTION_ERROR"))},r.send("GET"===o?void 0:s)}))}function $t(e,t){return"success"===e.status?function(e,t){var n=N(t,"gdpr_forget_device"),r=N(t,"attribution"),o=N(t,"session"),i=N(t,"disable_third_party_sharing"),a="opted_out"===e.tracking_state;if(!n&&a)return Le("sdk:gdpr-forget-me",!0),e;r||n||a||!e.ask_in||Le("attribution:check",e);o&&Le("session:finished",e);if(i)return Le("sdk:third-party-sharing-opt-out",!0),e;return e}(e,t):e}function en(e){return Yt().then((function(t){return Zt(e,t)})).then((function(t){return $t(t,e.url)}))}var tn={long:{delay:12e4,maxDelay:864e5,minRange:.5,maxRange:1},short:{delay:200,maxDelay:36e5,minRange:.5,maxRange:1},test:{delay:100,maxDelay:300}};function nn(e,t){var n,r,o=tn[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 rn=navigator.onLine;function on(){rn=!0}function an(){rn=!1}function un(e,t,n){e.addEventListener&&e.addEventListener(t,n,!1)}function sn(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}function cn(){return rn}var ln="undefined"==typeof Promise?n(3).Promise:Promise,fn=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.url,n=e.method,r=void 0===n?"GET":n,o=e.params,i=void 0===o?{}:o,u=e.continueCb,s=e.strategy,c=e.wait,f={url:t,method:r,params:i,continueCb:u},d=t,p=r,v=a()({},i),h=u,g=s,b=null,w={request:0,connection:0},k=P(c),S=null;function P(e){return(e=e||150)>2147483647?2147483647:e}function N(e){var t=e.url,n=e.method,r=e.params,o=e.continueCb;t&&(d=t),n&&(p=n),y(r)||(v=a()({},r)),v=a()({createdAt:se()},v),"function"==typeof o&&(h=o)}function x(e){if(!S)return!1;if(b){var t=k-(Date.now()-S);if(e&&t0&&void 0!==arguments[0]?arguments[0]:{},t=e.url,n=e.method,r=e.params,o=void 0===r?{}:r,i=e.continueCb,a=e.wait;return N({url:t,method:n,params:o,continueCb:i}),I({wait:a})}function B(){return!!b}function q(){b&&clearTimeout(b),b=null}function F(){var e=!!S;q(),S=null,e&&(k=150,w.request=0,w.connection=0,K.log("Previous ".concat(d||"unknown"," request attempt canceled")),E())}return{send:M,isRunning:B,clear:F}},dn=function(e){return"gdpr"===e?"GDPR disable":"disable"},mn=function(e){return{start:{inProgress:"Adjust SDK ".concat(dn(e)," process has already started"),done:"Adjust SDK ".concat(dn(e)," process is now started")},finish:{inProgress:"Adjust SDK ".concat(dn(e)," process has already finished"),done:"Adjust SDK ".concat(dn(e)," process is now finished")}}};function pn(e,t){var n=e.reason,r=e.pending,o=Fe()||{},i="start"===t&&o.pending?"start":"finish",a="start"===t&&o.reason,u="finish"===t&&o.reason&&!o.pending;return a||u?(K.log(mn(o.reason)[i].inProgress),!1):(K.log(mn(n)[i].done),Ue({reason:n||"general",pending:r}),!0)}function vn(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return pn({reason:e,pending:t||!1},"start")}function hn(){var e=Fe()||{};return"general"===e.reason||"gdpr"===e.reason&&!e.pending?"off":"gdpr"===e.reason&&e.pending?"paused":"on"}var gn="undefined"==typeof Promise?n(3).Promise:Promise,yn=!1;function bn(e){return e?"unknown"===e.uuid?(vn({reason:"gdpr"}),ke.destroy(),{exists:!0,stored:null}):(ke.init(e),{exists:!0,stored:e}):{exists:!1}}function wn(){return"off"!==hn()&&ke.isStarted()}function kn(){if(!wn())return gn.resolve(null);var e=a()({},ke.current,{lastActive:Date.now()});return Ht.updateItem("activityState",e).then((function(){return ke.current=e}))}var Sn="undefined"==typeof Promise?n(3).Promise:Promise,Pn=fn({strategy:"long",continueCb:function(e,t){var n=e&&e.continue_in||null;return _n.pause=n?{timestamp:Date.now(),wait:n}:null,Ht.getFirst("queue").then((function(e){return e?Ht.deleteItem("queue",e.timestamp):null})).then((function(){return t(),_n.running=!1,An({wait:n})}))}}),Nn=!1,_n={running:!1,timestamp:null,pause:null};function xn(){var e=Date.now();return _n.timestamp&&e<=_n.timestamp&&(e=_n.timestamp+1),_n.timestamp=e,e}function On(e){return N(e,"session")&&ke.resetSessionOffset(),ke.updateLastActive(),kn()}function jn(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;ke.updateParams(t,i);var s=O(r||{}).filter((function(e){return j(l()(e,2)[1])})).reduce(_,{}),c={timestamp:xn(),url:t,method:n,params:a()({},ke.getParams(t),{},s)};return u&&(c.createdAt=u),Ht.addItem("queue",c).then((function(){return On(t)})).then((function(){return _n.running?{}:An()}))}function In(){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=ke.current||{},c="/session"===r&&!s.installed,l=!r&&!o&&!i;return Nn&&!c||l?(_n.running=!1,Sn.resolve({})):Pn.send({url:r,method:o,params:a()({},i,{createdAt:se(n||t)}),wait:u||Tn()})}function Tn(){var e=_n.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;_n.running=!0;var r=Sn.resolve({});return t&&(r=r.then(Dn)),r.then((function(){return Ht.getFirst("queue")})).then((function(e){return In(e,n)}))}function En(e){if(void 0!==e)if(e!==Nn){var t=Nn;Nn=e,!e&&t&&An(),K.info("The app is now in ".concat(e?"offline":"online"," mode"))}else K.error("The app is already in ".concat(e?"offline":"online"," mode"));else K.error("State not provided, true or false has to be defined")}function Dn(){var e=Date.now()-z.requestValidityWindow;return Ht.deleteBulk("queue",e,"upperBound")}var Rn="undefined"==typeof Promise?n(3).Promise:Promise,Cn="No type provided",Ln="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 Bn(){return Rn.all([Ht.filterBy("globalParams","callback"),Ht.filterBy("globalParams","partner")]).then((function(e){var t=l()(e,2),n=t[0],r=t[1];return{callbackParams:Mn(n),partnerParams:Mn(r)}}))}function qn(e,t){if(void 0===t)return K.error(Ln),Rn.reject({message:Cn});var n=S(e),r=Object.keys(n).map((function(e){return{key:e,value:n[e],type:t}}));return Rn.all([Ht.filterBy("globalParams",t),Ht.addBulk("globalParams",r,!0)]).then((function(e){var n=l()(e,2),o=n[0],i=n[1],a=P(o.map((function(e){return e.key})),i.map((function(e){return e[0]})));return K.log("Following ".concat(t," parameters have been saved: ").concat(r.map((function(e){return"".concat(e.key,":").concat(e.value)})).join(", "))),a.length&&K.log("Keys: ".concat(a.join(", ")," already existed so their values have been updated")),i}))}function Kn(e,t){return void 0===t?(K.error(Ln),Rn.reject({message:Cn})):Ht.deleteItem("globalParams",[e,t]).then((function(n){return K.log("".concat(e," ").concat(t," parameter has been deleted")),n}))}function Fn(e){return void 0===e?(K.error(Ln),Rn.reject({message:Cn})):Ht.deleteBulk("globalParams",e).then((function(t){return K.log("All ".concat(e," parameters have been deleted")),t}))}var Un,Gn,Wn,Hn="undefined"==typeof Promise?n(3).Promise:Promise,Yn=!1,Jn=document;function Vn(){return Wn=function(){var e=document;if(void 0!==e.hidden)return{hidden:"hidden",visibilityChange:"visibilitychange"};for(var t=O({mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange",oHidden:"ovisibilitychange",webkitHidden:"webkitvisibilitychange"}),n=0;n0;return!n||n&&1e3*t>=z.sessionWindow?Bn().then((function(e){var t,n,r;jn({url:"/session",method:"POST",params:(t=e,n=t.callbackParams,r=t.partnerParams,{callbackParams:n.length?S(n):null,partnerParams:r.length?S(r):null})},{auto:!0})})):(Le("attribution:check"),kn())}var tr="undefined"==typeof Promise?n(3).Promise:Promise,nr=fn({url:"/attribution",strategy:"short",continueCb:function(e,t,n){if(!e||e&&"error"===e.status)return t(),tr.resolve({state:"unknown"});if(!e.ask_in)return t(),function(e){if(y(e)||!function(e){var t=e.adid,n=void 0===t?"":t,r=e.attribution,o=void 0===r?{}:r;return!!n&&!!P(rr,Object.keys(o)).length}(e)||function(e){var t=e.adid,n=e.attribution,r=ke.current.attribution||{};return!(n&&rr.some((function(e){return r[e]!==n[e]})))&&t===r.adid}(e))return tr.resolve({state:"same"});var t=O(e.attribution).filter((function(e){var t=l()(e,1)[0];return-1!==rr.indexOf(t)})).reduce(_,{adid:e.adid});return ke.current=a()({},ke.current,{attribution:t}),kn().then((function(){return Le("attribution:change",t),K.info("Attribution has been updated"),{state:"changed"}}))}(e);return n(e.ask_in)}}),rr=["tracker_token","tracker_name","network","campaign","adgroup","creative","click_label","state"];var or=fn({url:"/gdpr_forget_device",method:"POST",strategy:"short"}),ir={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 ar(e){var t=hn();return e||"on"===t?z.isInitialised()?(or.send({params:a()({},ke.getParams())}).then((function(){Le("sdk:gdpr-forget-me",!0)})),!0):(K.log(ir.pending),!0):(K.log(ir[t]),!1)}function ur(){return pn({reason:"gdpr",pending:!1},"finish")}var sr={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 cr(){var e=Ge()||{};return e.reason?e.pending?"pending":"off":"on"}function lr(e){var t=cr();return e||"on"===t?z.isInitialised()?(jn({url:"/disable_third_party_sharing",method:"POST"}),!0):(K.log(sr.delayed),!0):(K.log(sr[t]),!1)}function fr(e,t){var n,r,o=Ge()||{},i="start"===t&&e?"start":"finish",u="start"===t&&o.reason,s="finish"===t&&o.reason&&!o.pending;return u||s?(K.log(sr[i].inProgress),!1):(K.log(sr[i].done),r=(n={reason:"general",pending:e})?a()({},n):null,Ee.stores[Me]=a()({},qe(),{thirdPartySharingDisabled:r}),Ke(),!0)}function dr(){return fr(!1,"finish")}function mr(){"pending"===cr()&&(K.log(sr.running),lr(!0))}var pr=[];function vr(e,t){pr.push({method:e,description:t,timestamp:Date.now()})}function hr(){pr.forEach((function(e){"function"==typeof e.method&&(K.log("Delayed ".concat(e.description," task is running now")),e.method(e.timestamp))})),pr=[]}var gr="undefined"==typeof Promise?n(3).Promise:Promise;function yr(e,t){var n,r,o=t.callbackParams,i=t.partnerParams,u={},s=a()({eventToken:e.eventToken},(n=e.revenue,r=e.currency,isNaN(n)||(n=parseFloat(n))<0||!r?{}:{revenue:n.toFixed(5),currency:r})),c=a()({},S(o),{},S(e.callbackParams)),l=a()({},S(i),{},S(e.partnerParams));return y(c)||(u.callbackParams=c),y(l)||(u.partnerParams=l),a()({},s,{},u)}function br(e){return e?Ht.getAll("eventDeduplication").then((function(e){return e.map((function(e){return e.id}))})).then((function(t){return-1===t.indexOf(e)?function(e){var t=z.getCustomConfig().eventDeduplicationListLimit,n=t>0?t:10;return Ht.count("eventDeduplication").then((function(e){var t=gr.resolve();if(e>=n){var r=e-n+1;K.log("Event deduplication list limit has been reached. Oldest ids are about to be removed (".concat(r," of them)")),t=Ht.trimItems("eventDeduplication",r)}return t})).then((function(){return K.info("New event deduplication id is added to the list: ".concat(e)),Ht.addItem("eventDeduplication",{id:e})}))}(e):gr.reject({message:"Event won't be tracked, since it was previously tracked with the same deduplication id ".concat(e)})})):gr.resolve()}function wr(e){return{clickTime:se(),source:"web_referrer",referrer:decodeURIComponent(e)}}function kr(){var e=window.location.search.substring(1).split("&").map((function(e){return e.split("=")})).reduce(_,{}).adjust_referrer;e&&jn({url:"/sdk_click",method:"POST",params:wr(e)})}var Sr="undefined"==typeof Promise?n(3).Promise:Promise,Pr=null,Nr=!1;function _r(){lr()&&fr(!0,"start")}function xr(){var e;"paused"===hn()&&(ur(),Sr.all([(e={uuid:"unknown"},ke.current=e,Ht.clear("activityState").then((function(){return Ht.addItem("activityState",e)}))),Ht.clear("globalParams"),Ht.clear("queue")]).then(Ir))}function Or(){Nr=!1,pr=[],Pn.clear(),_n.running=!1,_n.timestamp=null,_n.pause=null,Yn=!1,ke.toBackground(),$n(),Wn&&(clearTimeout(Gn),sn(Jn,Wn.visibilityChange,Xn)),nr.clear()}function jr(e){e&&K.log("Adjust SDK has been shutdown due to asynchronous disable"),Or(),Re.forEach(clearTimeout),Re=[],De={},ke.destroy(),sn(window,"online",on),sn(window,"offline",an),Ht.destroy(),z.destroy()}function Ir(){jr(),or.clear(),Pr=null,K.log("Adjust SDK instance has been destroyed")}function Tr(e){K.log("Adjust SDK is starting with web_uuid set to ".concat(e.uuid));var t=ke.current.installed;"paused"===hn()&&(K.log(ir.running),ar(!0)),t||mr();var n=hn(),r=function(e){return"Adjust SDK start has been interrupted ".concat(e)};return"off"===n?(jr(),Sr.reject({interrupted:!0,message:r("due to complete async disable")})):"paused"===n?(Or(),Sr.reject({interrupted:!0,message:r("due to partial async disable")})):Nr?Sr.reject({interrupted:!0,message:r("due to multiple synchronous start attempt")}):(An({cleanUp:!0}),Vn().then((function(){Nr=!0,t&&mr()})))}function Ar(e){if(e.interrupted)K.log(e.message);else if(jr(),K.error("Adjust SDK start has been canceled due to an error",e),e.stack)throw e}function Er(e){"off"!==hn()?(z.set(e),un(window,"online",on),un(window,"offline",an),Ce("sdk:shutdown",(function(){return jr(!0)})),Ce("sdk:gdpr-forget-me",xr),Ce("sdk:third-party-sharing-opt-out",dr),Ce("attribution:check",(function(e,t){return n=t,r=ke.current,(o=(n||{}).ask_in)||!r.attribution&&r.installed?(nr.send({params:a()({initiatedBy:n?"backend":"sdk"},ke.getParams()),wait:o}),ke.updateSessionOffset(),kn()):tr.resolve(r);var n,r,o})),"function"==typeof e.attributionCallback&&Ce("attribution:change",e.attributionCallback),(yn?gn.reject({interrupted:!0,message:"Adjust SDK start already in progress"}):(yn=!0,Ht.getFirst("activityState").then(bn).then((function(e){if(e.exists)return yn=!1,e.stored;var t,n=y(ke.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)})))}:ke.current;return Ht.addItem("activityState",n).then((function(){return ke.init(n),We(),yn=!1,n}))})))).then(Tr).then(kr).then(hr).catch(Ar)):K.log("Adjust SDK is disabled, can not start the sdk")}function Dr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.schedule,o=n.stopBeforeInit;Ht?"on"===hn()?r&&o&&!z.isInitialised()?K.error("Adjust SDK can not ".concat(e,", sdk instance is not initialized")):"function"==typeof t&&(r&&!Nr&&(o||z.isInitialised())?(vr(t,e),K.log("Running ".concat(e," is delayed until Adjust SDK is up"))):t()):K.log("Adjust SDK is disabled, can not ".concat(e)):K.log("Adjust SDK can not ".concat(e,", no storage available"))}var Rr={initSdk:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.logLevel,n=e.logOutput,r=s()(e,["logLevel","logOutput"]);K.setLogLevel(t,n),Ht?(K.info("Available storage is ".concat(Ht.type)),z.isInitialised()?K.error("You already initiated your instance"):z.hasMissing(r)||(Pr=a()({},r),Er(r))):K.error("Adjust SDK can not start, there is no storage available")},trackEvent:function(e){Dr("track event",(function(t){return function(e,t){if(e&&(!e||!y(e)&&e.eventToken))return br(e.deduplicationId).then(Bn).then((function(n){jn({url:"/event",method:"POST",params:yr(e,n)},{timestamp:t})})).catch((function(e){e&&e.message&&K.error(e.message)}));K.error("You must provide event token in order to track event")}(e,t)}),{schedule:!0,stopBeforeInit:!0})},addGlobalCallbackParameters:function(e){Dr("add global callback parameters",(function(){return qn(e,"callback")}))},addGlobalPartnerParameters:function(e){Dr("add global partner parameters",(function(){return qn(e,"partner")}))},removeGlobalCallbackParameter:function(e){Dr("remove global callback parameter",(function(){return Kn(e,"callback")}))},removeGlobalPartnerParameter:function(e){Dr("remove global partner parameter",(function(){return Kn(e,"partner")}))},clearGlobalCallbackParameters:function(){Dr("remove all global callback parameters",(function(){return Fn("callback")}))},clearGlobalPartnerParameters:function(){Dr("remove all global partner parameters",(function(){return Fn("partner")}))},switchToOfflineMode:function(){Dr("set offline mode",(function(){return En(!0)}))},switchBackToOnlineMode:function(){Dr("set online mode",(function(){return En(!1)}))},stop:function(){vn()&&z.isInitialised()&&jr()},restart:function(){var e;("gdpr"===(e=Fe()||{}).reason?(K.log("Adjust SDK is disabled due to GDPR-Forget-Me request and it can not be re-enabled"),!1):e.reason?(K.log("Adjust SDK has been enabled"),Ue(null),!0):(K.log("Adjust SDK is already enabled"),!1))&&Pr&&Er(Pr)},gdprForgetMe:function(){var e=ar();e&&(e=vn("gdpr",!0))&&z.isInitialised()&&Or()},disableThirdPartySharing:function(){Dr("disable third-party sharing",_r,{schedule:!0,stopBeforeInit:!1})},__testonly__:{destroy:Ir}};t.default=Rr}]).default})); \ No newline at end of file + */var r;r=function(){"use strict";function e(e){return"function"==typeof e}var r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=0,i=void 0,a=void 0,u=function(e,t){p[o]=e,p[o+1]=t,2===(o+=2)&&(a?a(v):w())},s="undefined"!=typeof window?window:void 0,c=s||{},l=c.MutationObserver||c.WebKitMutationObserver,f="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),d="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function m(){var e=setTimeout;return function(){return e(v,1)}}var p=new Array(1e3);function v(){for(var e=0;e=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}},function(e,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})(e)}function r(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=r=function(e){return n(e)}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)},r(t)}e.exports=r},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var s,c=[],l=!1,f=-1;function d(){l&&s&&(l=!1,s.length?c=s.concat(c):f=-1,c.length&&m())}function m(){if(!l){var e=u(d);l=!0;for(var t=c.length;t;){for(s=c,c=[];++f1)for(var n=1;n0&&void 0!==arguments[0]?arguments[0]:[];return e.reduce((function(e,t){return u()({},e,g()({},t.key,t.value))}),{})}function _(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.filter((function(e){return-1!==t.indexOf(e)}))}function x(e,t){return new RegExp("\\/".concat(t,"(\\/.*|\\?.*){0,1}$")).test(e)}function j(e,t){var n=f()(t,2),r=n[0],o=n[1];return u()({},e,g()({},r,o))}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,n={entries:function(t){return[t,e[t]]},values:function(t){return e[t]}};return Object[t]?Object[t](e):Object.keys(e).map(n[t])}function I(e){return O(e,"entries")}function T(e){return k(e)?!w(e):!!e||0===e}var A=(i={},g()(i,"none",-1),g()(i,"error",0),g()(i,"info",1),g()(i,"verbose",2),i),E={development:"verbose",production:"error",test:"verbose"},D=C(),R="";function C(){return E[p.env]||"error"}function L(e,t){var n;if(!(A[D]2?u-2:0),c=2;c1&&void 0!==arguments[1]?arguments[1]:1,n=e+"",r=1;r<=t;r+=1)e0?"-":"+")+ie(Math.floor(Math.abs(t)/60))+ie(Math.abs(t)%60)}(t);return"".concat(n,"T").concat(r,"Z").concat(o)}function ue(e,t){return isNaN(e)||isNaN(t)?0:Math.abs(t-e)}var se={},ce=!1,le=!1;function fe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};se=ce?u()({},e):{}}function de(){ce&&(se.lastInterval=function(){var e=se.lastActive;if(e)return Math.round(ue(e,Date.now())/1e3);return-1}(),se.lastActive=Date.now())}function me(e){se=u()({},se,{},e)}function pe(){le=!0}function ve(){var e=se.lastActive;return Math.round(ue(e,Date.now())/1e3)}function he(){return(se.timeSpent||0)+(le?ve():0)}function ge(){var e=ue(se.lastActive,Date.now())=0?se.lastInterval:0,n={timeSpent:se.timeSpent||0,sessionLength:se.sessionLength||0,sessionCount:se.sessionCount||1,lastInterval:t||0};return e&&x(e,"event")&&(n.eventCount=se.eventCount),n},updateParams:function(e,t){if(ce){var n={};n.timeSpent=he(),n.sessionLength=ge(),x(e,"session")&&(n.sessionCount=(se.sessionCount||0)+1),x(e,"event")&&(n.eventCount=(se.eventCount||0)+1),me(n),t||de()}},updateInstalled:function(){ce&&(se.installed||me({installed:!0}))},updateSessionOffset:ye,updateSessionLength:function(){ce&&(me({sessionLength:ge()}),de())},resetSessionOffset:function(){ce&&me({timeSpent:0,sessionLength:0})},updateLastActive:de,destroy:function(){se={},ce=!1,le=!1}};function we(e,t){return e&&void 0!==e[t]?e[t]:t}function ke(e){var t=e.storeName,n=e.dir,r=e.record,o=e.scheme;if(r)return o=o||oe[n][_e({storeName:t,dir:"right"})].fields,I(r).map((function(e){var r=f()(e,2),i=r[0],a=r[1];return function(e){var t=e.storeName,n=e.scheme,r=e.dir,o=e.key,i=e.value;if(!n)return[o,i];var a=n.key||n;return k(i)?[a,ke({storeName:t,dir:r,record:i,scheme:n.keys})]:[a,we(n.values,i)]}({storeName:t,scheme:o[i],dir:n,key:i,value:a})})).reduce((function(e,t){var n=f()(t,2),r=n[0],o=n[1];return u()({},e,g()({},r,o))}),{})}function Se(e){var t=e.storeName,n=e.dir,r=e.records;return(void 0===r?[]:r).map((function(e){return ke({storeName:t,dir:n,record:e})}))}function Pe(e){var t=e.storeName,n=e.dir,r=e.target,o=oe[n][_e({storeName:t,dir:"right"})],i=o.fields[o.keyPath],a=r instanceof Array?r.slice():[r],u=(i.composite||[o.keyPath]).map((function(e,t){return we(o.fields[e].values,a[t])}));return 1===u.length?u[0]:u}function Ne(e){return oe.values[e]||e}function _e(e){var t=e.storeName,n=e.dir;return(oe.storeNames[n][t]||{}).name||t}function xe(e){var t=e.storeName,n=e.error;return{name:n.name,message:n.message.replace('"'.concat(t,'"'),_e({storeName:t,dir:"right"}))}}var je=p.namespace,Oe=oe.storeNames.left;var Ie={storeNames:Oe,stores:{},clear:function(){I(Oe).forEach((function(e){var t=f()(e,2)[1];t.permanent||localStorage.removeItem("".concat(je,".").concat(t.name))}))}};I(Oe).forEach((function(e){var t=f()(e,2)[1];Object.defineProperty(Ie.stores,t.name,{get:function(){return e=t.name,((n=JSON.parse(localStorage.getItem("".concat(je,".").concat(e))))instanceof Array?n:ke({storeName:Oe.preferences.name,dir:"right",record:n}))||null;var e,n},set:function(e){return function(e,t){t?localStorage.setItem("".concat(je,".").concat(e),JSON.stringify(t instanceof Array?t:ke({storeName:Oe.preferences.name,dir:"left",record:t}))):localStorage.removeItem("".concat(je,".").concat(e))}(t.name,e)}})})),Object.freeze(Ie.stores);var Te=Ie,Ae={},Ee=[];function De(e,t){var n="id"+Math.random().toString(36).substr(2,16),r={id:n,cb:t};return Ae[e]||(Ae[e]=[]),Ae[e].push(r),n}function Re(e,t){Ae[e]&&Ae[e].forEach((function(n){"function"==typeof n.cb&&Ee.push(setTimeout((function(){return n.cb(e,t)})))}))}var Ce=Te.storeNames.preferences.name,Le=Me();function Me(){return Le||Be(),Le?u()({},Le):null}function Be(){Le=Te.stores[Ce]}function qe(){var e=Me();return e?e.sdkDisabled:null}function Ke(e){var t=e?u()({},e):null;Te.stores[Ce]=u()({},Me(),{sdkDisabled:t}),Be()}function Fe(){var e=Me();return e?e.thirdPartySharingDisabled:null}function Ue(){var e=Te.stores[Ce]||{},t=(Le||{}).sdkDisabled||null;e.sdkDisabled&&!t&&Re("sdk:shutdown"),Be()}function Ge(){Te.stores[Ce]||(Te.stores[Ce]=u()({},Le))}var We,He="undefined"==typeof Promise?n(3).Promise:Promise,Ye=p.namespace;function Je(){var e=Ve(),t=!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform),n=!!e&&!t;return n||B.error("IndexedDB is not supported in this browser"),n}function Ve(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB}function ze(){var e=Ve();return Je()?new He((function(t,n){if(We)t({success:!0});else{var r=e.open(Ye,1);r.onupgradeneeded=function(e){return function(e,t){var n=e.target.result;e.target.transaction.onerror=t,e.target.transaction.onabort=t;var r=oe.storeNames.left,o=be.current||{},i=o&&!w(o);I(r).filter((function(e){return!f()(e,2)[1].permanent})).forEach((function(e){var t=f()(e,2),a=t[0],u=t[1],s=oe.right[a],c=n.createObjectStore(u.name,{keyPath:s.keyPath,autoIncrement:s.autoIncrement||!1});s.index&&c.createIndex("".concat(s.index,"Index"),s.index),u.name===r.activityState.name&&i?(c.add(ke({storeName:a,record:o,dir:"left"})),B.info("Activity state has been recovered")):Te.stores[u.name]&&(Te.stores[u.name].forEach((function(e){return c.add(e)})),B.info("Migration from localStorage done for ".concat(a," store")))})),Ge(),Te.clear()}(e,n)},r.onsuccess=function(e){return function(e,t){We=e.target.result,t({success:!0}),We.onclose=ht}(e,t)},r.onerror=n}})):He.reject({name:"IDBNotSupported",message:"IndexedDB is not supported"})}function Qe(e,t){var n,r=e.storeName,o=e.mode,i=We.transaction([r],o),a=i.objectStore(r),u=oe.right[_e({storeName:r,dir:"right"})];return u.index&&(n=a.index("".concat(u.index,"Index"))),i.onerror=t,i.onabort=t,{transaction:i,store:a,index:n,options:u}}function Xe(e,t){var n=t.target.error;return e({name:n.name,message:n.message})}function Ze(e){return e.fields[e.keyPath].composite||null}function $e(e,t,n){var r=-1!==["add","put"].indexOf(n),o=Ze(e);return o?r?u()(g()({},e.keyPath,o.map((function(e){return t[e]})).join("")),t):t?t.join(""):null:t}function et(e,t){var n=Ze(e);return n&&k(t)?n.map((function(e){return t[e]})):null}function tt(e){var t=e.storeName,n=e.target,r=void 0===n?null:n,o=e.action,i=e.mode,a=void 0===i?"readonly":i;return ze().then((function(){return new He((function(e,n){var i=Qe({storeName:t,mode:a},n),u=i.store,s=i.options,c=u[o]($e(s,r,o)),l=et(s,r);c.onsuccess=function(){"get"!==o||c.result?e(l||c.result||r):n({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(t,'" store')})},c.onerror=function(e){return Xe(n,e)}}))}))}function nt(e){var t=e.storeName,n=e.action,r=void 0===n?"list":n,o=e.range,i=void 0===o?null:o,a=e.firstOnly,u=e.mode,s=void 0===u?"readonly":u;return ze().then((function(){return new He((function(e,n){var o=Qe({storeName:t,mode:s},n),u=o.transaction,c=o.store,l=o.index,f=o.options,d=(l||c).openCursor(i),m=[];u.oncomplete=function(){return e(a?m[0]:m)},d.onsuccess=function(e){var t=e.target.result;t&&("delete"===r?(t.delete(),m.push(et(f,t.value)||t.value[f.keyPath])):m.push(t.value),a||t.continue())},d.onerror=function(e){return Xe(n,e)}}))}))}function rt(e,t){return nt({storeName:e,firstOnly:t})}function ot(e){return rt(e,!0)}function it(e,t){return tt({storeName:e,target:t,action:"get"})}function at(e,t){return nt({storeName:e,range:IDBKeyRange.only(t)})}function ut(e,t){return tt({storeName:e,target:t,action:"add",mode:"readwrite"})}function st(e,t,n){return function(e){var t=e.storeName,n=e.target,r=e.action,o=e.mode;return ze().then((function(){return new He((function(e,i){if(!n||n&&!n.length)return i({name:"NoTargetDefined",message:"No array provided to perform ".concat(r,' bulk operation into "').concat(t,'" store')});var a=Qe({storeName:t,mode:o},i),u=a.transaction,s=a.store,c=a.options,l=[],f=n[0];u.oncomplete=function(){return e(l)},function e(t){t.onerror=function(e){return Xe(i,e)},t.onsuccess=function(){l.push(et(c,f)||t.result),f=n[l.length],l.lengthe[r]:e[r]>t[r];return o?-1:i?1:0}(e,t,o)}),0)}))}function Nt(e,t,n){var r=wt(e);return r?u()(g()({},e.keyPath,r.map((function(e){return t[e]})).join("")),t):e.autoIncrement&&n?u()(g()({},e.keyPath,n),t):u()({},t)}function _t(e,t){var n=wt(e);return n&&k(t)?n.map((function(e){return t[e]})):t[e.keyPath]||t}function xt(e,t){var n=bt();return"error"===n.status?gt.reject(n.error):new gt((function(n,r){var o=Te.stores[e];o instanceof Array?n(t?o[0]:Pt(o,kt(e))):r({name:"NotFoundError",message:"No objectStore named ".concat(e," in this database")})}))}function jt(e){return xt(e,!0)}function Ot(e,t){return St({storeName:e,id:t},(function(t,n,r){var o=r.items,i=r.index,a=r.options;-1===i?n({name:"NotRecordFoundError",message:'Requested record not found in "'.concat(e,'" store')}):t(Nt(a,o[i]))}))}function It(e,t){return xt(e).then((function(n){return n.filter((function(n){return n[oe.right[_e({storeName:e,dir:"right"})].index]===t}))}))}function Tt(e,t){return St({storeName:e,item:t},(function(n,r,o){var i=o.items,a=o.index,u=o.options,s=o.lastId;-1!==a?r({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing item into "'.concat(e,'" store')}):(i.push(Nt(u,t,s+1)),Te.stores[e]=i,n(_t(u,t)))}))}function At(e,t,n){return St({storeName:e},(function(r,o,i){var a=i.keys,u=i.items,s=i.options,c=i.lastId;if(!t||t&&!t.length)return o({name:"NoTargetDefined",message:'No array provided to perform add bulk operation into "'.concat(e,'" store')});var l=c,f=t.map((function(e){return Nt(s,e,++l)})),d=f.filter((function(e){return-1!==P(u,a,e)})).map((function(e){return e[s.keyPath]})),p=n?u.filter((function(e){return-1===d.indexOf(e[s.keyPath])})):m()(u);d.length&&!n?o({name:"ConstraintError",message:'Constraint was not satisfied, trying to add existing items into "'.concat(e,'" store')}):(Te.stores[e]=Pt([].concat(m()(p),m()(f)),a),r(t.map((function(e){return _t(s,e)}))))}))}function Et(e,t){return St({storeName:e,item:t},(function(n,r,o){var i=o.items,a=o.index,u=o.options,s=o.lastId,c=Nt(u,t,-1===a?s+1:null);-1===a?i.push(c):i.splice(a,1,c),Te.stores[e]=i,n(_t(u,t))}))}function Dt(e,t){return St({storeName:e,id:t},(function(n,r,o){var i=o.items,a=o.index;-1!==a&&(i.splice(a,1),Te.stores[e]=i),n(t)}))}function Rt(e,t,n){return xt(e).then((function(r){var o=kt(e),i=oe.right[_e({storeName:e,dir:"right"})].index||o[0],a=Pt(r,o,n?null:t),u=function(e,t,n){if(!e.length)return-1;for(var r={index:-1,value:isNaN(n)?"":0},o=0;o=r.value&&(r={value:e[o][t],index:o})}return r.index}(a,i,t);if(-1===u)return[];var s="lowerBound"===n?u:0,c=n&&"upperBound"!==n?a.length:u+1,l=a.splice(s,c).map((function(e){return 1===o.length?e[i]:o.map((function(t){return e[t]}))}));return Te.stores[e]=a,l}))}function Ct(e,t){var n=bt(),r=oe.right[_e({storeName:e,dir:"right"})];return"error"===n.status?gt.reject(n.error):xt(e).then((function(e){return e.length?e[t-1]:null})).then((function(t){return t?Rt(e,t[r.keyPath],"upperBound"):[]}))}function Lt(e){var t=bt();return"error"===t.status?gt.reject(t.error):gt.resolve(Te.stores[e].length)}function Mt(e){var t=bt();return"error"===t.status?gt.reject(t.error):new gt((function(t){Te.stores[e]=[],t({})}))}function Bt(){}var qt="undefined"==typeof Promise?n(3).Promise:Promise,Kt={getAll:function(e,t){return e.getAll(t).then((function(e){return Se({storeName:t,dir:"right",records:e})}))},getFirst:function(e,t){return e.getFirst(t).then((function(e){return ke({storeName:t,dir:"right",record:e})}))},getItem:function(e,t,n){return e.getItem(t,Pe({storeName:t,dir:"left",target:n})).then((function(e){return ke({storeName:t,dir:"right",record:e})})).catch((function(e){return qt.reject(xe({storeName:t,error:e}))}))},filterBy:function(e,t,n){return e.filterBy(t,Ne(n)).then((function(e){return Se({storeName:t,dir:"right",records:e})}))},addItem:function(e,t,n){return e.addItem(t,ke({storeName:t,dir:"left",record:n})).then((function(e){return Pe({storeName:t,dir:"right",target:e})})).catch((function(e){return qt.reject(xe({storeName:t,error:e}))}))},addBulk:function(e,t,n,r){return e.addBulk(t,Se({storeName:t,dir:"left",records:n}),r).then((function(e){return e.map((function(e){return Pe({storeName:t,dir:"right",target:e})}))})).catch((function(e){return qt.reject(xe({storeName:t,error:e}))}))},updateItem:function(e,t,n){return e.updateItem(t,ke({storeName:t,dir:"left",record:n})).then((function(e){return Pe({storeName:t,dir:"right",target:e})}))},deleteItem:function(e,t,n){return e.deleteItem(t,Pe({storeName:t,dir:"left",target:n})).then((function(e){return Pe({storeName:t,dir:"right",target:e})}))},deleteBulk:function(e,t,n,r){return e.deleteBulk(t,Ne(n),r).then((function(e){return e.map((function(e){return Pe({storeName:t,dir:"right",target: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)}};var Ft,Ut,Gt=(Je()?(Ft=r,Ut="indexedDB"):yt()&&(Ft=o,Ut="localStorage"),Ut?u()({type:Ut,isSupported:Ft.isSupported,destroy:Ft.destroy},function(e){return I(Kt).map((function(t){var n=f()(t,2),r=n[0],o=n[1];return[r,function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i2&&void 0!==arguments[2]&&arguments[2];return{status:"error",action:n?"CONTINUE":"RETRY",response:S(e.responseText)?JSON.parse(e.responseText):e.responseText,message:v[t],code:t}}function Jt(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 Vt(e,t){var n=function(e){return e.replace(/([A-Z])/g,(function(e){return"_".concat(e.toLowerCase())}))},r=I(u()({},J.getBaseParams(),{},t,{},e)).map((function(e){var t=f()(e,2),r=t[0],o=t[1];return[n(r),o]}));return B.log("REQUEST PARAMETERS:"),r.filter((function(e){return T(f()(e,2)[1])})).map((function(e){var t=f()(e,2),n=t[0],r=t[1];return B.log(Jt("REQUEST PARAMETERS:",n),r),function(e){var t=f()(e,2),n=t[0],r=t[1],o=encodeURIComponent(n),i=r;return"string"==typeof r&&(i=encodeURIComponent(r)),k(r)&&(i=encodeURIComponent(JSON.stringify(r)||"")),[o,i].join("=")}([n,r])})).join("&")}function zt(e,t,n){var r=n.xhr,o=n.url;if(4===r.readyState){var i=r.status>=200&&r.status<300,a=S(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 x(t,"attribution")&&(r.attribution=n.attribution,r.message=n.message),I(r).filter((function(e){return!!f()(e,2)[1]})).reduce(j,{})}(r,o):Yt(r,"SERVER_CANNOT_PROCESS",!0)):e(Yt(r,i?"SERVER_MALFORMED_RESPONSE":"SERVER_INTERNAL_ERROR"));e(Yt(r,"NO_CONNECTION"))}}function Qt(e,t){var n=e.url,r=e.method,o=void 0===r?"GET":r,i=e.params,a=function(e,t){var n=e.url,r=e.method,o=Vt(e.params,t),i="/gdpr_forget_device"===n?"gdpr":"app";return{fullUrl:(J.getCustomConfig().customUrl||J.baseUrl[i])+n+("GET"===r?"?".concat(o):""),encodedParams:o}}({url:n,method:o,params:void 0===i?{}:i},t),u=a.fullUrl,s=a.encodedParams;return new Ht((function(e,t){var r=new XMLHttpRequest;r.open(o,u,!0),function(e,t){var n=[["Client-SDK","js".concat(p.version)],["Content-Type","POST"===t?"application/x-www-form-urlencoded":"application/json"]];B.log("REQUEST HEADERS:"),n.forEach((function(t){var n=f()(t,2),r=n[0],o=n[1];e.setRequestHeader(r,o),B.log(Jt("REQUEST HEADERS:",r),o)}))}(r,o),r.onreadystatechange=function(){return zt(t,e,{xhr:r,url:n})},r.onerror=function(){return t(Yt(r,"TRANSACTION_ERROR"))},r.send("GET"===o?void 0:s)}))}function Xt(e,t){return"success"===e.status?function(e,t){var n=x(t,"gdpr_forget_device"),r=x(t,"attribution"),o=x(t,"session"),i=x(t,"disable_third_party_sharing"),a="opted_out"===e.tracking_state;if(!n&&a)return Re("sdk:gdpr-forget-me"),e;r||n||a||!e.ask_in||Re("attribution:check",e);o&&Re("session:finished",e);if(i)return Re("sdk:third-party-sharing-opt-out"),e;return e}(e,t):e}function Zt(e){return Wt().then((function(t){return Qt(e,t)})).then((function(t){return Xt(t,e.url)}))}var $t={long:{delay:12e4,maxDelay:864e5,minRange:.5,maxRange:1},short:{delay:200,maxDelay:36e5,minRange:.5,maxRange:1},test:{delay:100,maxDelay:300}};function en(e,t){var n,r,o=$t[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 tn=navigator.onLine;function nn(){tn=!0}function rn(){tn=!1}function on(e,t,n){e.addEventListener&&e.addEventListener(t,n,!1)}function an(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}function un(){return tn}var sn="undefined"==typeof Promise?n(3).Promise:Promise,cn=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.url,n=e.method,r=void 0===n?"GET":n,o=e.params,i=void 0===o?{}:o,a=e.continueCb,s=e.strategy,c=e.wait,l={url:t,method:r,params:i,continueCb:a},d=t,m=r,p=u()({},i),h=a,g=s,y=null,b={request:0,connection:0},k=P(c),S=null;function P(e){return(e=e||150)>2147483647?2147483647:e}function N(e){var t=e.url,n=e.method,r=e.params,o=e.continueCb;t&&(d=t),n&&(m=n),w(r)||(p=u()({},r)),p=u()({createdAt:ae()},p),"function"==typeof o&&(h=o)}function _(e){if(!S)return!1;if(y){var t=k-(Date.now()-S);if(e&&t0&&void 0!==arguments[0]?arguments[0]:{},t=e.url,n=e.method,r=e.params,o=void 0===r?{}:r,i=e.continueCb,a=e.wait;return N({url:t,method:n,params:o,continueCb:i}),x({wait:a})}function q(){return!!y}function K(){y&&clearTimeout(y),y=null}function F(){var e=!!S;K(),S=null,e&&(k=150,b.request=0,b.connection=0,B.log("Previous ".concat(d||"unknown"," request attempt canceled")),E())}return{send:M,isRunning:q,clear:F}},ln=function(e){return"gdpr"===e?"GDPR disable":"disable"},fn=function(e){return{start:{inProgress:"Adjust SDK ".concat(ln(e)," process has already started"),done:"Adjust SDK ".concat(ln(e)," process is now started")},finish:{inProgress:"Adjust SDK ".concat(ln(e)," process has already finished"),done:"Adjust SDK ".concat(ln(e)," process is now finished")}}};function dn(e,t){var n=e.reason,r=e.pending,o=qe()||{},i="start"===t&&o.pending?"start":"finish",a="start"===t&&o.reason,u="finish"===t&&o.reason&&!o.pending;return a||u?(B.log(fn(o.reason)[i].inProgress),!1):(B.log(fn(n)[i].done),Ke({reason:n||"general",pending:r}),!0)}function mn(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return dn({reason:e,pending:t||!1},"start")}function pn(){var e=qe()||{};return"general"===e.reason||"gdpr"===e.reason&&!e.pending?"off":"gdpr"===e.reason&&e.pending?"paused":"on"}var vn="undefined"==typeof Promise?n(3).Promise:Promise,hn=!1;function gn(e){return e?"unknown"===e.uuid?(mn({reason:"gdpr"}),be.destroy(),{exists:!0,stored:null}):(be.init(e),{exists:!0,stored:e}):{exists:!1}}function yn(){return"off"!==pn()&&be.isStarted()}function bn(){if(!yn())return vn.resolve(null);var e=u()({},be.current,{lastActive:Date.now()});return Gt.updateItem("activityState",e).then((function(){return be.current=e}))}var wn="undefined"==typeof Promise?n(3).Promise:Promise,kn=cn({strategy:"long",continueCb:function(e,t){var n=e&&e.continue_in||null;return Pn.pause=n?{timestamp:Date.now(),wait:n}:null,Gt.getFirst("queue").then((function(e){return e?Gt.deleteItem("queue",e.timestamp):null})).then((function(){return t(),Pn.running=!1,In({wait:n})}))}}),Sn=!1,Pn={running:!1,timestamp:null,pause:null};function Nn(){var e=Date.now();return Pn.timestamp&&e<=Pn.timestamp&&(e=Pn.timestamp+1),Pn.timestamp=e,e}function _n(e){return x(e,"session")&&be.resetSessionOffset(),be.updateLastActive(),bn()}function xn(e){var t=e.url,n=e.method,r=e.params,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.auto,a=o.timestamp;be.updateParams(t,i);var s=I(r||{}).filter((function(e){return T(f()(e,2)[1])})).reduce(j,{}),c={timestamp:Nn(),url:t,method:n,params:u()({},be.getParams(t),{},s)};return a&&(c.createdAt=a),Gt.addItem("queue",c).then((function(){return _n(t)})).then((function(){return Pn.running?{}:In()}))}function jn(){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,a=arguments.length>1?arguments[1]:void 0,s=be.current||{},c="/session"===r&&!s.installed,l=!r&&!o&&!i;return Sn&&!c||l?(Pn.running=!1,wn.resolve({})):kn.send({url:r,method:o,params:u()({},i,{createdAt:ae(n||t)}),wait:a||On()})}function On(){var e=Pn.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;Pn.running=!0;var r=wn.resolve({});return t&&(r=r.then(An)),r.then((function(){return Gt.getFirst("queue")})).then((function(e){return jn(e,n)}))}function Tn(e){if(void 0!==e)if(e!==Sn){var t=Sn;Sn=e,!e&&t&&In(),B.info("The app is now in ".concat(e?"offline":"online"," mode"))}else B.error("The app is already in ".concat(e?"offline":"online"," mode"));else B.error("State not provided, true or false has to be defined")}function An(){var e=Date.now()-J.requestValidityWindow;return Gt.deleteBulk("queue",e,"upperBound")}var En="undefined"==typeof Promise?n(3).Promise:Promise,Dn="No type provided",Rn="Global parameter type not provided, `callback` or `partner` types are available";function Cn(e){return(e||[]).map((function(e){return{key:e.key,value:e.value}}))}function Ln(){return En.all([Gt.filterBy("globalParams","callback"),Gt.filterBy("globalParams","partner")]).then((function(e){var t=f()(e,2),n=t[0],r=t[1];return{callbackParams:Cn(n),partnerParams:Cn(r)}}))}function Mn(e,t){if(void 0===t)return B.error(Rn),En.reject({message:Dn});var n=N(e),r=Object.keys(n).map((function(e){return{key:e,value:n[e],type:t}}));return En.all([Gt.filterBy("globalParams",t),Gt.addBulk("globalParams",r,!0)]).then((function(e){var n=f()(e,2),o=n[0],i=n[1],a=_(o.map((function(e){return e.key})),i.map((function(e){return e[0]})));return B.log("Following ".concat(t," parameters have been saved: ").concat(r.map((function(e){return"".concat(e.key,":").concat(e.value)})).join(", "))),a.length&&B.log("Keys: ".concat(a.join(", ")," already existed so their values have been updated")),i}))}function Bn(e,t){return void 0===t?(B.error(Rn),En.reject({message:Dn})):Gt.deleteItem("globalParams",[e,t]).then((function(n){return B.log("".concat(e," ").concat(t," parameter has been deleted")),n}))}function qn(e){return void 0===e?(B.error(Rn),En.reject({message:Dn})):Gt.deleteBulk("globalParams",e).then((function(t){return B.log("All ".concat(e," parameters have been deleted")),t}))}var Kn,Fn,Un,Gn="undefined"==typeof Promise?n(3).Promise:Promise,Wn=!1,Hn=document;function Yn(){return Un=function(){var e=document;if(void 0!==e.hidden)return{hidden:"hidden",visibilityChange:"visibilitychange"};for(var t=I({mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange",oHidden:"ovisibilitychange",webkitHidden:"webkitvisibilitychange"}),n=0;n0;return!n||n&&1e3*t>=J.sessionWindow?Ln().then((function(e){var t,n,r;xn({url:"/session",method:"POST",params:(t=e,n=t.callbackParams,r=t.partnerParams,{callbackParams:n.length?N(n):null,partnerParams:r.length?N(r):null})},{auto:!0})})):(Re("attribution:check"),bn())}var $n="undefined"==typeof Promise?n(3).Promise:Promise,er=cn({url:"/attribution",strategy:"short",continueCb:function(e,t,n){if(!e||e&&"error"===e.status)return t(),$n.resolve({state:"unknown"});if(!e.ask_in)return t(),function(e){if(w(e)||!function(e){var t=e.adid,n=void 0===t?"":t,r=e.attribution,o=void 0===r?{}:r;return!!n&&!!_(tr,Object.keys(o)).length}(e)||function(e){var t=e.adid,n=e.attribution,r=be.current.attribution||{};return!(n&&tr.some((function(e){return r[e]!==n[e]})))&&t===r.adid}(e))return $n.resolve({state:"same"});var t=I(e.attribution).filter((function(e){var t=f()(e,1)[0];return-1!==tr.indexOf(t)})).reduce(j,{adid:e.adid});return be.current=u()({},be.current,{attribution:t}),bn().then((function(){return Re("attribution:change",t),B.info("Attribution has been updated"),{state:"changed"}}))}(e);return n(e.ask_in)}}),tr=["tracker_token","tracker_name","network","campaign","adgroup","creative","click_label","state"];var nr=cn({url:"/gdpr_forget_device",method:"POST",strategy:"short"}),rr={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 or(e){var t=pn();return e||"on"===t?J.isInitialised()?(nr.send({params:u()({},be.getParams())}).then((function(){Re("sdk:gdpr-forget-me")})),!0):(B.log(rr.pending),!0):(B.log(rr[t]),!1)}function ir(){return dn({reason:"gdpr",pending:!1},"finish")}var ar={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 ur(){var e=Fe()||{};return e.reason?e.pending?"pending":"off":"on"}function sr(e){var t=ur();return e||"on"===t?J.isInitialised()?(xn({url:"/disable_third_party_sharing",method:"POST"}),!0):(B.log(ar.delayed),!0):(B.log(ar[t]),!1)}function cr(e,t){var n,r,o=Fe()||{},i="start"===t&&e?"start":"finish",a="start"===t&&o.reason,s="finish"===t&&o.reason&&!o.pending;return a||s?(B.log(ar[i].inProgress),!1):(B.log(ar[i].done),r=(n={reason:"general",pending:e})?u()({},n):null,Te.stores[Ce]=u()({},Me(),{thirdPartySharingDisabled:r}),Be(),!0)}function lr(){return cr(!1,"finish")}function fr(){"pending"===ur()&&(B.log(ar.running),sr(!0))}var dr=[];function mr(e,t){dr.push({method:e,description:t,timestamp:Date.now()})}function pr(){dr.forEach((function(e){"function"==typeof e.method&&(B.log("Delayed ".concat(e.description," task is running now")),e.method(e.timestamp))})),dr=[]}var vr="undefined"==typeof Promise?n(3).Promise:Promise;function hr(e,t){var n,r,o=t.callbackParams,i=t.partnerParams,a={},s=u()({eventToken:e.eventToken},(n=e.revenue,r=e.currency,isNaN(n)||(n=parseFloat(n))<0||!r?{}:{revenue:n.toFixed(5),currency:r})),c=u()({},N(o),{},N(e.callbackParams)),l=u()({},N(i),{},N(e.partnerParams));return w(c)||(a.callbackParams=c),w(l)||(a.partnerParams=l),u()({},s,{},a)}function gr(e){return e?Gt.getAll("eventDeduplication").then((function(e){return e.map((function(e){return e.id}))})).then((function(t){return-1===t.indexOf(e)?function(e){var t=J.getCustomConfig().eventDeduplicationListLimit,n=t>0?t:10;return Gt.count("eventDeduplication").then((function(e){var t=vr.resolve();if(e>=n){var r=e-n+1;B.log("Event deduplication list limit has been reached. Oldest ids are about to be removed (".concat(r," of them)")),t=Gt.trimItems("eventDeduplication",r)}return t})).then((function(){return B.info("New event deduplication id is added to the list: ".concat(e)),Gt.addItem("eventDeduplication",{id:e})}))}(e):vr.reject({message:"Event won't be tracked, since it was previously tracked with the same deduplication id ".concat(e)})})):vr.resolve()}function yr(e){return{clickTime:ae(),source:"web_referrer",referrer:decodeURIComponent(e)}}function br(){var e=window.location.search.substring(1).split("&").map((function(e){return e.split("=")})).reduce(j,{}).adjust_referrer;e&&xn({url:"/sdk_click",method:"POST",params:yr(e)})}var wr="undefined"==typeof Promise?n(3).Promise:Promise,kr=null,Sr=!1;function Pr(){sr()&&cr(!0,"start")}function Nr(){var e;"paused"===pn()&&(ir(),wr.all([(e={uuid:"unknown"},be.current=e,Gt.clear("activityState").then((function(){return Gt.addItem("activityState",e)}))),Gt.clear("globalParams"),Gt.clear("queue")]).then(jr))}function _r(){Sr=!1,dr=[],kn.clear(),Pn.running=!1,Pn.timestamp=null,Pn.pause=null,Wn=!1,be.toBackground(),Xn(),Un&&(clearTimeout(Fn),an(Hn,Un.visibilityChange,zn)),er.clear()}function xr(e){e&&B.log("Adjust SDK has been shutdown due to asynchronous disable"),_r(),Ee.forEach(clearTimeout),Ee=[],Ae={},be.destroy(),an(window,"online",nn),an(window,"offline",rn),Gt.destroy(),J.destroy()}function jr(){xr(),nr.clear(),kr=null,B.log("Adjust SDK instance has been destroyed")}function Or(e){B.log("Adjust SDK is starting with web_uuid set to ".concat(e.uuid));var t=be.current.installed;"paused"===pn()&&(B.log(rr.running),or(!0)),t||fr();var n=pn(),r=function(e){return"Adjust SDK start has been interrupted ".concat(e)};return"off"===n?(xr(),wr.reject({interrupted:!0,message:r("due to complete async disable")})):"paused"===n?(_r(),wr.reject({interrupted:!0,message:r("due to partial async disable")})):Sr?wr.reject({interrupted:!0,message:r("due to multiple synchronous start attempt")}):(In({cleanUp:!0}),Yn().then((function(){Sr=!0,t&&fr()})))}function Ir(e){if(e.interrupted)B.log(e.message);else if(xr(),B.error("Adjust SDK start has been canceled due to an error",e),e.stack)throw e}function Tr(e){"off"!==pn()?(J.set(e),on(window,"online",nn),on(window,"offline",rn),De("sdk:shutdown",(function(){return xr(!0)})),De("sdk:gdpr-forget-me",Nr),De("sdk:third-party-sharing-opt-out",lr),De("attribution:check",(function(e,t){return n=t,r=be.current,(o=(n||{}).ask_in)||!r.attribution&&r.installed?(er.send({params:u()({initiatedBy:n?"backend":"sdk"},be.getParams()),wait:o}),be.updateSessionOffset(),bn()):$n.resolve(r);var n,r,o})),"function"==typeof e.attributionCallback&&De("attribution:change",e.attributionCallback),(hn?vn.reject({interrupted:!0,message:"Adjust SDK start already in progress"}):(hn=!0,Gt.getFirst("activityState").then(gn).then((function(e){if(e.exists)return hn=!1,e.stored;var t,n=w(be.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)})))}:be.current;return Gt.addItem("activityState",n).then((function(){return be.init(n),Ue(),hn=!1,n}))})))).then(Or).then(br).then(pr).catch(Ir)):B.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.stopBeforeInit;Gt?"on"===pn()?r&&o&&!J.isInitialised()?B.error("Adjust SDK can not ".concat(e,", sdk instance is not initialized")):"function"==typeof t&&(r&&!Sr&&(o||J.isInitialised())?(mr(t,e),B.log("Running ".concat(e," is delayed until Adjust SDK is up"))):t()):B.log("Adjust SDK is disabled, can not ".concat(e)):B.log("Adjust SDK can not ".concat(e,", no storage available"))}var Er={initSdk:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.logLevel,n=e.logOutput,r=c()(e,["logLevel","logOutput"]);B.setLogLevel(t,n),Gt?(B.info("Available storage is ".concat(Gt.type)),J.isInitialised()?B.error("You already initiated your instance"):J.hasMissing(r)||(kr=u()({},r),Tr(r))):B.error("Adjust SDK can not start, there is no storage available")},trackEvent:function(e){Ar("track event",(function(t){return function(e,t){if(e&&(!e||!w(e)&&e.eventToken))return gr(e.deduplicationId).then(Ln).then((function(n){xn({url:"/event",method:"POST",params:hr(e,n)},{timestamp:t})})).catch((function(e){e&&e.message&&B.error(e.message)}));B.error("You must provide event token in order to track event")}(e,t)}),{schedule:!0,stopBeforeInit:!0})},addGlobalCallbackParameters:function(e){Ar("add global callback parameters",(function(){return Mn(e,"callback")}))},addGlobalPartnerParameters:function(e){Ar("add global partner parameters",(function(){return Mn(e,"partner")}))},removeGlobalCallbackParameter:function(e){Ar("remove global callback parameter",(function(){return Bn(e,"callback")}))},removeGlobalPartnerParameter:function(e){Ar("remove global partner parameter",(function(){return Bn(e,"partner")}))},clearGlobalCallbackParameters:function(){Ar("remove all global callback parameters",(function(){return qn("callback")}))},clearGlobalPartnerParameters:function(){Ar("remove all global partner parameters",(function(){return qn("partner")}))},switchToOfflineMode:function(){Ar("set offline mode",(function(){return Tn(!0)}))},switchBackToOnlineMode:function(){Ar("set online mode",(function(){return Tn(!1)}))},stop:function(){mn()&&J.isInitialised()&&xr()},restart:function(){var e;("gdpr"===(e=qe()||{}).reason?(B.log("Adjust SDK is disabled due to GDPR-Forget-Me request and it can not be re-enabled"),!1):e.reason?(B.log("Adjust SDK has been enabled"),Ke(null),!0):(B.log("Adjust SDK is already enabled"),!1))&&kr&&Tr(kr)},gdprForgetMe:function(){var e=or();e&&(e=mn("gdpr",!0))&&J.isInitialised()&&_r()},disableThirdPartySharing:function(){Ar("disable third-party sharing",Pr,{schedule:!0,stopBeforeInit:!1})},__testonly__:{destroy:jr}};t.default=Er}]).default})); \ No newline at end of file diff --git a/docs/chinese/README.md b/docs/chinese/README.md index aa30c24..6151c75 100644 --- a/docs/chinese/README.md +++ b/docs/chinese/README.md @@ -38,7 +38,7 @@ Read this in other languages: [English][en-readme], [中文][zh-readme], [日本 Adjust Web SDK 在每个页面应当仅加载一次,每次页面加载应当初始化一次。 -在通过 CDN 加载 SDK 时,我们建议您使用精简版本。您可以定向特定版本,如 `https://cdn.adjust.com/adjust-5.0.0.min.js`;如果您需要自动更新,不想变更目标文件,也可以定向最新版本:`https://cdn.adjust.com/adjust-latest.min.js` 。SDK 文件均有缓存,因此能以最快速度获取,缓存每半小时刷新一次。如果您想立即获得更新,请务必定向特定版本。 +在通过 CDN 加载 SDK 时,我们建议您使用精简版本。您可以定向特定版本,如 `https://cdn.adjust.com/adjust-5.1.0.min.js`;如果您需要自动更新,不想变更目标文件,也可以定向最新版本:`https://cdn.adjust.com/adjust-latest.min.js` 。SDK 文件均有缓存,因此能以最快速度获取,缓存每半小时刷新一次。如果您想立即获得更新,请务必定向特定版本。 您也可以通过 NPM 安装我们的 SDK: diff --git a/docs/japanese/README.md b/docs/japanese/README.md index 7c5b904..3284caf 100644 --- a/docs/japanese/README.md +++ b/docs/japanese/README.md @@ -38,7 +38,7 @@ CDNでAdjustSDKを遅延ロードするためには、以下のコードを`/node_modules/', '/src/sdk/__tests__/_utils.js', + '/src/sdk/__tests__/_matchers.js', '/src/sdk/__tests__/main/main.suite.js', '/src/sdk/__tests__/storage/storage.suite.js' ], @@ -15,6 +16,9 @@ module.exports = { 'jest-localstorage-mock', '/src/sdk/__tests__/_utils.js' ], + setupFilesAfterEnv: [ + '/src/sdk/__tests__/_matchers.js' + ], globals: { __ADJUST__NAMESPACE: 'adjust-sdk', __ADJUST__SDK_VERSION: 'TEST' diff --git a/package-lock.json b/package-lock.json index 5c03d2f..d86473a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@adjustcom/adjust-web-sdk", - "version": "5.0.0", + "version": "5.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bc04063..1421790 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adjustcom/adjust-web-sdk", - "version": "5.0.0", + "version": "5.1.0", "description": "This is the guide to the Javascript SDK of Adjust™ for web sites or web apps. You can read more about Adjust™ at [adjust.com].", "scripts": { "build:demo": "webpack --mode production --config webpack.demo.config.js", diff --git a/src/demo.html b/src/demo.html index b36ffb3..6b5f14e 100644 --- a/src/demo.html +++ b/src/demo.html @@ -24,7 +24,8 @@ logLevel: 'verbose', // optional, default is 'error', other options are 'none', 'error', 'info', 'verbose' logOutput: '#output', // optional, outputs logs from sdk into provided container // defaultTracker: 'YOUR_DEFAULT_TRACKER_TOKEN', // optional - // customUrl: 'YOUR_CUSTOM_URL' // optional + // externalDeviceId: 'YOUR_EXTERNAL_DEVICE_ID', // optional + // customUrl: 'YOUR_CUSTOM_URL', // optional // eventDeduplicationListLimit: 'YOUR_EVENT_DEDUPLICATION_LIST_LIMIT' // optional, default set to 10 }); diff --git a/src/demo/tabs/tabs.html b/src/demo/tabs/tabs.html index 8714bb5..ade3847 100644 --- a/src/demo/tabs/tabs.html +++ b/src/demo/tabs/tabs.html @@ -31,12 +31,17 @@
- - + +
+
+ + +
+