diff --git a/CHANGELOG.md b/CHANGELOG.md index 84410aaf..7da792c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 4.4.0 (July 25, 2018) + +* Add options to disable automatic tracking of fields like platform, language, os_version, ip_address, city, etc + ### 4.3.0 (July 16, 2018) * Add more context to the 'No request sent' responses diff --git a/README.md b/README.md index 6997bfc5..2d5a85ed 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Please see our [installation guide](https://amplitude.zendesk.com/hc/en-us/artic [![npm version](https://badge.fury.io/js/amplitude-js.svg)](https://badge.fury.io/js/amplitude-js) [![Bower version](https://badge.fury.io/bo/amplitude-js.svg)](https://badge.fury.io/bo/amplitude-js) -[4.3.0 - Released on July 16, 2018](https://github.com/amplitude/Amplitude-JavaScript/releases/latest) +[4.4.0 - Released on July 25, 2018](https://github.com/amplitude/Amplitude-JavaScript/releases/latest) # JavaScript SDK Reference # diff --git a/amplitude-snippet.min.js b/amplitude-snippet.min.js index 2d08bcfb..52f71988 100644 --- a/amplitude-snippet.min.js +++ b/amplitude-snippet.min.js @@ -1,6 +1,6 @@ (function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script") ;r.type="text/javascript";r.async=true -;r.src="https://cdn.amplitude.com/libs/amplitude-4.3.0-min.gz.js" +;r.src="https://cdn.amplitude.com/libs/amplitude-4.4.0-min.gz.js" ;r.onload=function(){if(e.amplitude.runQueuedFunctions){ e.amplitude.runQueuedFunctions()}else{ console.log("[Amplitude] Error: could not load SDK")}} diff --git a/amplitude.js b/amplitude.js index df605190..847a26ff 100644 --- a/amplitude.js +++ b/amplitude.js @@ -3074,6 +3074,260 @@ var md5 = createCommonjsModule(function (module) { })(commonjsGlobal); }); +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +var _listCacheClear = listCacheClear; + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +var eq_1 = eq; + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq_1(array[length][0], key)) { + return length; + } + } + return -1; +} + +var _assocIndexOf = assocIndexOf; + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +var _listCacheDelete = listCacheDelete; + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +var _listCacheGet = listCacheGet; + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return _assocIndexOf(this.__data__, key) > -1; +} + +var _listCacheHas = listCacheHas; + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +var _listCacheSet = listCacheSet; + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = _listCacheClear; +ListCache.prototype['delete'] = _listCacheDelete; +ListCache.prototype.get = _listCacheGet; +ListCache.prototype.has = _listCacheHas; +ListCache.prototype.set = _listCacheSet; + +var _ListCache = ListCache; + +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new _ListCache; + this.size = 0; +} + +var _stackClear = stackClear; + +/** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; +} + +var _stackDelete = stackDelete; + +/** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function stackGet(key) { + return this.__data__.get(key); +} + +var _stackGet = stackGet; + +/** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function stackHas(key) { + return this.__data__.has(key); +} + +var _stackHas = stackHas; + /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; @@ -3093,17 +3347,17 @@ var Symbol$1 = _root.Symbol; var _Symbol = Symbol$1; /** Used for built-in method references. */ -var objectProto$3 = Object.prototype; +var objectProto$1 = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty$3 = objectProto$3.hasOwnProperty; +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ -var nativeObjectToString = objectProto$3.toString; +var nativeObjectToString = objectProto$1.toString; /** Built-in value references. */ var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; @@ -3116,7 +3370,7 @@ var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; * @returns {string} Returns the raw `toStringTag`. */ function getRawTag(value) { - var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), + var isOwn = hasOwnProperty$1.call(value, symToStringTag$1), tag = value[symToStringTag$1]; try { @@ -3138,14 +3392,14 @@ function getRawTag(value) { var _getRawTag = getRawTag; /** Used for built-in method references. */ -var objectProto$4 = Object.prototype; +var objectProto$2 = Object.prototype; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ -var nativeObjectToString$1 = objectProto$4.toString; +var nativeObjectToString$1 = objectProto$2.toString; /** * Converts `value` to a string using `Object.prototype.toString`. @@ -3314,17 +3568,17 @@ var reIsHostCtor = /^\[object .+?Constructor\]$/; /** Used for built-in method references. */ var funcProto = Function.prototype; -var objectProto$2 = Object.prototype; +var objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ -var hasOwnProperty$2 = objectProto$2.hasOwnProperty; +var hasOwnProperty = objectProto.hasOwnProperty; /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&') + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); @@ -3375,481 +3629,580 @@ function getNative(object, key) { var _getNative = getNative; -var defineProperty = (function() { - try { - var func = _getNative(Object, 'defineProperty'); - func({}, '', {}); - return func; - } catch (e) {} -}()); +/* Built-in method references that are verified to be native. */ +var Map = _getNative(_root, 'Map'); -var _defineProperty = defineProperty; +var _Map = Map; + +/* Built-in method references that are verified to be native. */ +var nativeCreate = _getNative(Object, 'create'); + +var _nativeCreate = nativeCreate; /** - * The base implementation of `assignValue` and `assignMergeValue` without - * value checks. + * Removes all key-value entries from the hash. * * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. + * @name clear + * @memberOf Hash */ -function baseAssignValue(object, key, value) { - if (key == '__proto__' && _defineProperty) { - _defineProperty(object, key, { - 'configurable': true, - 'enumerable': true, - 'value': value, - 'writable': true - }); - } else { - object[key] = value; - } +function hashClear() { + this.__data__ = _nativeCreate ? _nativeCreate(null) : {}; + this.size = 0; } -var _baseAssignValue = baseAssignValue; +var _hashClear = hashClear; /** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false + * Removes `key` and its value from the hash. * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +var _hashDelete = hashDelete; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$3.hasOwnProperty; + +/** + * Gets the hash value for `key`. * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (_nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty$2.call(data, key) ? data[key] : undefined; } -var eq_1 = eq; +var _hashGet = hashGet; /** Used for built-in method references. */ -var objectProto$1 = Object.prototype; +var objectProto$4 = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty$1 = objectProto$1.hasOwnProperty; +var hasOwnProperty$3 = objectProto$4.hasOwnProperty; /** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. + * Checks if a hash value for `key` exists. * * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty$1.call(object, key) && eq_1(objValue, value)) || - (value === undefined && !(key in object))) { - _baseAssignValue(object, key, value); - } + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key); } -var _assignValue = assignValue; +var _hashHas = hashHas; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; /** - * Copies properties of `source` to `object`. + * Sets the hash `key` to `value`. * * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ -function copyObject(source, props, object, customizer) { - var isNew = !object; - object || (object = {}); + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value; + return this; +} + +var _hashSet = hashSet; +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { var index = -1, - length = props.length; + length = entries == null ? 0 : entries.length; + this.clear(); while (++index < length) { - var key = props[index]; + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} - var newValue = customizer - ? customizer(object[key], source[key], key, object, source) - : undefined; +// Add methods to `Hash`. +Hash.prototype.clear = _hashClear; +Hash.prototype['delete'] = _hashDelete; +Hash.prototype.get = _hashGet; +Hash.prototype.has = _hashHas; +Hash.prototype.set = _hashSet; - if (newValue === undefined) { - newValue = source[key]; - } - if (isNew) { - _baseAssignValue(object, key, newValue); - } else { - _assignValue(object, key, newValue); - } - } - return object; +var _Hash = Hash; + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new _Hash, + 'map': new (_Map || _ListCache), + 'string': new _Hash + }; } -var _copyObject = copyObject; +var _mapCacheClear = mapCacheClear; /** - * This method returns the first argument it receives. + * Checks if `value` is suitable for use as unique object key. * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +var _isKeyable = isKeyable; + +/** + * Gets the data for `map`. * - * var object = { 'a': 1 }; + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return _isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +var _getMapData = getMapData; + +/** + * Removes `key` and its value from the map. * - * console.log(_.identity(object) === object); - * // => true + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = _getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +var _mapCacheDelete = mapCacheDelete; + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -function identity(value) { - return value; +function mapCacheGet(key) { + return _getMapData(this, key).get(key); } -var identity_1 = identity; +var _mapCacheGet = mapCacheGet; /** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. + * Checks if a map value for `key` exists. * * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} args The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function apply(func, thisArg, args) { - switch (args.length) { - case 0: return func.call(thisArg); - case 1: return func.call(thisArg, args[0]); - case 2: return func.call(thisArg, args[0], args[1]); - case 3: return func.call(thisArg, args[0], args[1], args[2]); - } - return func.apply(thisArg, args); +function mapCacheHas(key) { + return _getMapData(this, key).has(key); } -var _apply = apply; +var _mapCacheHas = mapCacheHas; -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = _getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +var _mapCacheSet = mapCacheSet; /** - * A specialized version of `baseRest` which transforms the rest array. + * Creates a map cache object to store key-value pairs. * * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @param {Function} transform The rest array transform. - * @returns {Function} Returns the new function. + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function overRest(func, start, transform) { - start = nativeMax(start === undefined ? (func.length - 1) : start, 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - array = Array(length); +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; - while (++index < length) { - array[index] = args[start + index]; - } - index = -1; - var otherArgs = Array(start + 1); - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = transform(array); - return _apply(func, this, otherArgs); - }; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } -var _overRest = overRest; +// Add methods to `MapCache`. +MapCache.prototype.clear = _mapCacheClear; +MapCache.prototype['delete'] = _mapCacheDelete; +MapCache.prototype.get = _mapCacheGet; +MapCache.prototype.has = _mapCacheHas; +MapCache.prototype.set = _mapCacheSet; + +var _MapCache = MapCache; + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; /** - * Creates a function that returns `value`. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {*} value The value to return from the new function. - * @returns {Function} Returns the new constant function. - * @example - * - * var objects = _.times(2, _.constant({ 'a': 1 })); + * Sets the stack `key` to `value`. * - * console.log(objects); - * // => [{ 'a': 1 }, { 'a': 1 }] + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ +function stackSet(key, value) { + var data = this.__data__; + if (data instanceof _ListCache) { + var pairs = data.__data__; + if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new _MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; +} + +var _stackSet = stackSet; + +/** + * Creates a stack cache object to store key-value pairs. * - * console.log(objects[0] === objects[1]); - * // => true + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function constant(value) { - return function() { - return value; - }; +function Stack(entries) { + var data = this.__data__ = new _ListCache(entries); + this.size = data.size; } -var constant_1 = constant; +// Add methods to `Stack`. +Stack.prototype.clear = _stackClear; +Stack.prototype['delete'] = _stackDelete; +Stack.prototype.get = _stackGet; +Stack.prototype.has = _stackHas; +Stack.prototype.set = _stackSet; + +var _Stack = Stack; + +var defineProperty = (function() { + try { + var func = _getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +var _defineProperty = defineProperty; /** - * The base implementation of `setToString` without support for hot loop shorting. + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. * * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. */ -var baseSetToString = !_defineProperty ? identity_1 : function(func, string) { - return _defineProperty(func, 'toString', { - 'configurable': true, - 'enumerable': false, - 'value': constant_1(string), - 'writable': true - }); -}; +function baseAssignValue(object, key, value) { + if (key == '__proto__' && _defineProperty) { + _defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} -var _baseSetToString = baseSetToString; +var _baseAssignValue = baseAssignValue; -/** Used to detect hot functions by number of calls within a span of milliseconds. */ -var HOT_COUNT = 800; -var HOT_SPAN = 16; +/** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq_1(object[key], value)) || + (value === undefined && !(key in object))) { + _baseAssignValue(object, key, value); + } +} -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeNow = Date.now; +var _assignMergeValue = assignMergeValue; /** - * Creates a function that'll short out and invoke `identity` instead - * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` - * milliseconds. + * Creates a base function for methods like `_.forIn` and `_.forOwn`. * * @private - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new shortable function. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. */ -function shortOut(func) { - var count = 0, - lastCalled = 0; - - return function() { - var stamp = nativeNow(), - remaining = HOT_SPAN - (stamp - lastCalled); +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; - lastCalled = stamp; - if (remaining > 0) { - if (++count >= HOT_COUNT) { - return arguments[0]; + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; } - } else { - count = 0; } - return func.apply(undefined, arguments); + return object; }; } -var _shortOut = shortOut; +var _createBaseFor = createBaseFor; /** - * Sets the `toString` method of `func` to return `string`. + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. * * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. */ -var setToString = _shortOut(_baseSetToString); +var baseFor = _createBaseFor(); -var _setToString = setToString; +var _baseFor = baseFor; + +var _cloneBuffer = createCommonjsModule(function (module, exports) { +/** Detect free variable `exports`. */ +var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Built-in value references. */ +var Buffer = moduleExports ? _root.Buffer : undefined, + allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined; /** - * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * Creates a clone of `buffer`. * * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. */ -function baseRest(func, start) { - return _setToString(_overRest(func, start, identity_1), func + ''); +function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; } -var _baseRest = baseRest; +module.exports = cloneBuffer; +}); -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; +/** Built-in value references. */ +var Uint8Array = _root.Uint8Array; + +var _Uint8Array = Uint8Array; /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * Creates a clone of `arrayBuffer`. * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new _Uint8Array(result).set(new _Uint8Array(arrayBuffer)); + return result; } -var isLength_1 = isLength; +var _cloneArrayBuffer = cloneArrayBuffer; /** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example + * Creates a clone of `typedArray`. * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. */ -function isArrayLike(value) { - return value != null && isLength_1(value.length) && !isFunction_1(value); +function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } -var isArrayLike_1 = isArrayLike; - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER$1 = 9007199254740991; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; +var _cloneTypedArray = cloneTypedArray; /** - * Checks if `value` is a valid array-like index. + * Copies the values of `source` to `array`. * * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. */ -function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER$1 : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); +function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; } -var _isIndex = isIndex; +var _copyArray = copyArray; + +/** Built-in value references. */ +var objectCreate = Object.create; /** - * Checks if the given arguments are from an iteratee call. + * The base implementation of `_.create` without support for assigning + * properties to the created object. * * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ -function isIterateeCall(value, index, object) { - if (!isObject_1(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike_1(object) && _isIndex(index, object.length)) - : (type == 'string' && index in object) - ) { - return eq_1(object[index], value); - } - return false; -} + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. + */ +var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject_1(proto)) { + return {}; + } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; +}()); -var _isIterateeCall = isIterateeCall; +var _baseCreate = baseCreate; /** - * Creates a function like `_.assign`. + * Creates a unary function that invokes `func` with its argument transformed. * * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. */ -function createAssigner(assigner) { - return _baseRest(function(object, sources) { - var index = -1, - length = sources.length, - customizer = length > 1 ? sources[length - 1] : undefined, - guard = length > 2 ? sources[2] : undefined; +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} - customizer = (assigner.length > 3 && typeof customizer == 'function') - ? (length--, customizer) - : undefined; +var _overArg = overArg; - if (guard && _isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - object = Object(object); - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, index, customizer); - } - } - return object; - }); -} +/** Built-in value references. */ +var getPrototype = _overArg(Object.getPrototypeOf, Object); -var _createAssigner = createAssigner; +var _getPrototype = getPrototype; /** Used for built-in method references. */ var objectProto$5 = Object.prototype; @@ -3871,25 +4224,19 @@ function isPrototype(value) { var _isPrototype = isPrototype; /** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. + * Initializes an object clone. * * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; +function initCloneObject(object) { + return (typeof object.constructor == 'function' && !_isPrototype(object)) + ? _baseCreate(_getPrototype(object)) + : {}; } -var _baseTimes = baseTimes; +var _initCloneObject = initCloneObject; /** * Checks if `value` is object-like. A value is object-like if it's not `null` @@ -3938,13 +4285,13 @@ function baseIsArguments(value) { var _baseIsArguments = baseIsArguments; /** Used for built-in method references. */ -var objectProto$7 = Object.prototype; +var objectProto$6 = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty$5 = objectProto$7.hasOwnProperty; +var hasOwnProperty$4 = objectProto$6.hasOwnProperty; /** Built-in value references. */ -var propertyIsEnumerable = objectProto$7.propertyIsEnumerable; +var propertyIsEnumerable = objectProto$6.propertyIsEnumerable; /** * Checks if `value` is likely an `arguments` object. @@ -3965,7 +4312,7 @@ var propertyIsEnumerable = objectProto$7.propertyIsEnumerable; * // => false */ var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) { - return isObjectLike_1(value) && hasOwnProperty$5.call(value, 'callee') && + return isObjectLike_1(value) && hasOwnProperty$4.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; @@ -3998,6 +4345,104 @@ var isArray = Array.isArray; var isArray_1 = isArray; +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +var isLength_1 = isLength; + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength_1(value.length) && !isFunction_1(value); +} + +var isArrayLike_1 = isArrayLike; + +/** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ +function isArrayLikeObject(value) { + return isObjectLike_1(value) && isArrayLike_1(value); +} + +var isArrayLikeObject_1 = isArrayLikeObject; + /** * This method returns `false`. * @@ -4056,25 +4501,84 @@ module.exports = isBuffer; }); /** `Object#toString` result references. */ -var argsTag$1 = '[object Arguments]'; -var arrayTag = '[object Array]'; -var boolTag = '[object Boolean]'; -var dateTag = '[object Date]'; -var errorTag = '[object Error]'; -var funcTag$1 = '[object Function]'; -var mapTag = '[object Map]'; -var numberTag = '[object Number]'; var objectTag = '[object Object]'; -var regexpTag = '[object RegExp]'; -var setTag = '[object Set]'; -var stringTag = '[object String]'; -var weakMapTag = '[object WeakMap]'; -var arrayBufferTag = '[object ArrayBuffer]'; -var dataViewTag = '[object DataView]'; -var float32Tag = '[object Float32Array]'; -var float64Tag = '[object Float64Array]'; -var int8Tag = '[object Int8Array]'; +/** Used for built-in method references. */ +var funcProto$2 = Function.prototype; +var objectProto$7 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$2 = funcProto$2.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$5 = objectProto$7.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString$2.call(Object); + +/** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ +function isPlainObject(value) { + if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) { + return false; + } + var proto = _getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString$2.call(Ctor) == objectCtorString; +} + +var isPlainObject_1 = isPlainObject; + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]'; +var arrayTag = '[object Array]'; +var boolTag = '[object Boolean]'; +var dateTag = '[object Date]'; +var errorTag = '[object Error]'; +var funcTag$1 = '[object Function]'; +var mapTag = '[object Map]'; +var numberTag = '[object Number]'; +var objectTag$1 = '[object Object]'; +var regexpTag = '[object RegExp]'; +var setTag = '[object Set]'; +var stringTag = '[object String]'; +var weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]'; +var dataViewTag = '[object DataView]'; +var float32Tag = '[object Float32Array]'; +var float64Tag = '[object Float64Array]'; +var int8Tag = '[object Int8Array]'; var int16Tag = '[object Int16Array]'; var int32Tag = '[object Int32Array]'; var uint8Tag = '[object Uint8Array]'; @@ -4094,7 +4598,7 @@ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = -typedArrayTags[objectTag] = typedArrayTags[regexpTag] = +typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; @@ -4175,10 +4679,118 @@ var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsType var isTypedArray_1 = isTypedArray; /** Used for built-in method references. */ -var objectProto$6 = Object.prototype; +var objectProto$8 = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty$4 = objectProto$6.hasOwnProperty; +var hasOwnProperty$6 = objectProto$8.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty$6.call(object, key) && eq_1(objValue, value)) || + (value === undefined && !(key in object))) { + _baseAssignValue(object, key, value); + } +} + +var _assignValue = assignValue; + +/** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ +function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = customizer + ? customizer(object[key], source[key], key, object, source) + : undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + _baseAssignValue(object, key, newValue); + } else { + _assignValue(object, key, newValue); + } + } + return object; +} + +var _copyObject = copyObject; + +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +var _baseTimes = baseTimes; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$1 = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER$1 : length; + return !!length && + (typeof value == 'number' || reIsUint.test(value)) && + (value > -1 && value % 1 == 0 && value < length); +} + +var _isIndex = isIndex; + +/** Used for built-in method references. */ +var objectProto$9 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$7 = objectProto$9.hasOwnProperty; /** * Creates an array of the enumerable property names of the array-like `value`. @@ -4198,7 +4810,7 @@ function arrayLikeKeys(value, inherited) { length = result.length; for (var key in value) { - if ((inherited || hasOwnProperty$4.call(value, key)) && + if ((inherited || hasOwnProperty$7.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode. key == 'length' || @@ -4218,139 +4830,515 @@ function arrayLikeKeys(value, inherited) { var _arrayLikeKeys = arrayLikeKeys; /** - * Creates a unary function that invokes `func` with its argument transformed. + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. * * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; +} + +var _nativeKeysIn = nativeKeysIn; + +/** Used for built-in method references. */ +var objectProto$10 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$8 = objectProto$10.hasOwnProperty; + +/** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeysIn(object) { + if (!isObject_1(object)) { + return _nativeKeysIn(object); + } + var isProto = _isPrototype(object), + result = []; + + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) { + result.push(key); + } + } + return result; +} + +var _baseKeysIn = baseKeysIn; + +/** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ +function keysIn(object) { + return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object); +} + +var keysIn_1 = keysIn; + +/** + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ +function toPlainObject(value) { + return _copyObject(value, keysIn_1(value)); +} + +var toPlainObject_1 = toPlainObject; + +/** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = object[key], + srcValue = source[key], + stacked = stack.get(srcValue); + + if (stacked) { + _assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; + + var isCommon = newValue === undefined; + + if (isCommon) { + var isArr = isArray_1(srcValue), + isBuff = !isArr && isBuffer_1(srcValue), + isTyped = !isArr && !isBuff && isTypedArray_1(srcValue); + + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray_1(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject_1(objValue)) { + newValue = _copyArray(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = _cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = _cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject_1(srcValue) || isArguments_1(srcValue)) { + newValue = objValue; + if (isArguments_1(objValue)) { + newValue = toPlainObject_1(objValue); + } + else if (!isObject_1(objValue) || (srcIndex && isFunction_1(objValue))) { + newValue = _initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + _assignMergeValue(object, key, newValue); +} + +var _baseMergeDeep = baseMergeDeep; + +/** + * The base implementation of `_.merge` without support for multiple sources. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + _baseFor(source, function(srcValue, key) { + if (isObject_1(srcValue)) { + stack || (stack = new _Stack); + _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(object[key], srcValue, (key + ''), object, source, stack) + : undefined; + + if (newValue === undefined) { + newValue = srcValue; + } + _assignMergeValue(object, key, newValue); + } + }, keysIn_1); +} + +var _baseMerge = baseMerge; + +/** + * This method returns the first argument it receives. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'a': 1 }; + * + * console.log(_.identity(object) === object); + * // => true + */ +function identity(value) { + return value; +} + +var identity_1 = identity; + +/** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ +function apply(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); +} + +var _apply = apply; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * A specialized version of `baseRest` which transforms the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. * @returns {Function} Returns the new function. */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); +function overRest(func, start, transform) { + start = nativeMax(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + array = Array(length); + + while (++index < length) { + array[index] = args[start + index]; + } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return _apply(func, this, otherArgs); }; } -var _overArg = overArg; +var _overRest = overRest; + +/** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. + * @example + * + * var objects = _.times(2, _.constant({ 'a': 1 })); + * + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); + * // => true + */ +function constant(value) { + return function() { + return value; + }; +} + +var constant_1 = constant; + +/** + * The base implementation of `setToString` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var baseSetToString = !_defineProperty ? identity_1 : function(func, string) { + return _defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant_1(string), + 'writable': true + }); +}; + +var _baseSetToString = baseSetToString; + +/** Used to detect hot functions by number of calls within a span of milliseconds. */ +var HOT_COUNT = 800; +var HOT_SPAN = 16; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = _overArg(Object.keys, Object); +var nativeNow = Date.now; -var _nativeKeys = nativeKeys; +/** + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. + * + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. + */ +function shortOut(func) { + var count = 0, + lastCalled = 0; -/** Used for built-in method references. */ -var objectProto$8 = Object.prototype; + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; +} + +var _shortOut = shortOut; + +/** + * Sets the `toString` method of `func` to return `string`. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var setToString = _shortOut(_baseSetToString); + +var _setToString = setToString; + +/** + * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + */ +function baseRest(func, start) { + return _setToString(_overRest(func, start, identity_1), func + ''); +} -/** Used to check objects for own properties. */ -var hasOwnProperty$6 = objectProto$8.hasOwnProperty; +var _baseRest = baseRest; /** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * Checks if the given arguments are from an iteratee call. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. */ -function baseKeys(object) { - if (!_isPrototype(object)) { - return _nativeKeys(object); +function isIterateeCall(value, index, object) { + if (!isObject_1(object)) { + return false; } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty$6.call(object, key) && key != 'constructor') { - result.push(key); - } + var type = typeof index; + if (type == 'number' + ? (isArrayLike_1(object) && _isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq_1(object[index], value); } - return result; + return false; } -var _baseKeys = baseKeys; +var _isIterateeCall = isIterateeCall; /** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) + * Creates a function like `_.assign`. * - * _.keys('hi'); - * // => ['0', '1'] + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. */ -function keys(object) { - return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object); -} +function createAssigner(assigner) { + return _baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; -var keys_1 = keys; + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; -/** Used for built-in method references. */ -var objectProto = Object.prototype; + if (guard && _isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); +} -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +var _createAssigner = createAssigner; /** - * Assigns own enumerable string keyed properties of source objects to the - * destination object. Source objects are applied from left to right. - * Subsequent sources overwrite property assignments of previous sources. + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. * - * **Note:** This method mutates `object` and is loosely based on - * [`Object.assign`](https://mdn.io/Object/assign). + * **Note:** This method mutates `object`. * * @static * @memberOf _ - * @since 0.10.0 + * @since 0.5.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. * @returns {Object} Returns `object`. - * @see _.assignIn * @example * - * function Foo() { - * this.a = 1; - * } - * - * function Bar() { - * this.c = 3; - * } + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; * - * Foo.prototype.b = 2; - * Bar.prototype.d = 4; + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; * - * _.assign({ 'a': 0 }, new Foo, new Bar); - * // => { 'a': 1, 'c': 3 } + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } */ -var assign = _createAssigner(function(object, source) { - if (_isPrototype(source) || isArrayLike_1(source)) { - _copyObject(source, keys_1(source), object); - return; - } - for (var key in source) { - if (hasOwnProperty.call(source, key)) { - _assignValue(object, key, source[key]); - } - } +var merge = _createAssigner(function(object, source, srcIndex) { + _baseMerge(object, source, srcIndex); }); -var assign_1$1 = assign; +var merge_1$1 = merge; // Copyright Joyent, Inc. and other Node contributors. // @@ -4377,7 +5365,7 @@ var assign_1$1 = assign; // If obj.hasOwnProperty has been overridden, then calling // obj.hasOwnProperty(prop) will break. // See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty$7(obj, prop) { +function hasOwnProperty$9(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } var isArray$2 = Array.isArray || function (xs) { @@ -4481,7 +5469,7 @@ function parse$2(qs, sep, eq, options) { k = decodeURIComponent(kstr); v = decodeURIComponent(vstr); - if (!hasOwnProperty$7(obj, k)) { + if (!hasOwnProperty$9(obj, k)) { obj[k] = v; } else if (isArray$2(obj[k])) { obj[k].push(v); @@ -5627,7 +6615,7 @@ var uuid$1 = function uuid(a) { ); }; -var version = '4.3.0'; +var version = '4.4.0'; var getLanguage = function getLanguage() { return navigator && (navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage) || undefined; @@ -5640,9 +6628,15 @@ var language = { // default options var DEFAULT_OPTIONS = { apiEndpoint: 'api.amplitude.com', + batchEvents: false, cookieExpiration: 365 * 10, cookieName: 'amplitude_id', + deviceIdFromUrlParam: false, domain: '', + eventUploadPeriodMillis: 30 * 1000, // 30s + eventUploadThreshold: 30, + forceHttps: true, + includeGclid: false, includeReferrer: false, includeUtm: false, language: language.language, @@ -5651,17 +6645,24 @@ var DEFAULT_OPTIONS = { platform: 'Web', savedMaxCount: 1000, saveEvents: true, + saveParamsReferrerOncePerSession: true, sessionTimeout: 30 * 60 * 1000, + trackingOptions: { + city: true, + country: true, + device_model: true, + dma: true, + ip_address: true, + language: true, + os_name: true, + os_version: true, + platform: true, + region: true, + version_name: true + }, unsentKey: 'amplitude_unsent', unsentIdentifyKey: 'amplitude_unsent_identify', - uploadBatchSize: 100, - batchEvents: false, - eventUploadThreshold: 30, - eventUploadPeriodMillis: 30 * 1000, // 30s - forceHttps: true, - includeGclid: false, - saveParamsReferrerOncePerSession: true, - deviceIdFromUrlParam: false + uploadBatchSize: 100 }; /** @@ -5677,7 +6678,7 @@ var AmplitudeClient = function AmplitudeClient(instanceName) { this._unsentEvents = []; this._unsentIdentifys = []; this._ua = new uaParser(navigator.userAgent).getResult(); - this.options = assign_1$1({}, DEFAULT_OPTIONS); + this.options = merge_1$1({}, DEFAULT_OPTIONS); this.cookieStorage = new cookieStorage().getStorage(); this._q = []; // queue for proxied functions before script load this._sending = false; @@ -5717,7 +6718,11 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o try { this.options.apiKey = apiKey; this._storageSuffix = '_' + apiKey + this._legacyStorageSuffix; + _parseConfig(this.options, opt_config); + var trackingOptions = _generateApiPropertiesTrackingConfig(this); + this._apiPropertiesTrackingOptions = Object.keys(trackingOptions).length > 0 ? { tracking_options: trackingOptions } : {}; + this.cookieStorage.options({ expirationDays: this.options.cookieExpiration, domain: this.options.domain @@ -5810,12 +6815,12 @@ var _parseConfig = function _parseConfig(options, config) { // validates config value is defined, is the correct type, and some additional value sanity checks var parseValidateAndLoad = function parseValidateAndLoad(key) { - if (!DEFAULT_OPTIONS.hasOwnProperty(key)) { + if (!options.hasOwnProperty(key)) { return; // skip bogus config values } var inputValue = config[key]; - var expectedType = type(DEFAULT_OPTIONS[key]); + var expectedType = type(options[key]); if (!utils.validateInput(inputValue, key + ' option', expectedType)) { return; } @@ -5823,6 +6828,8 @@ var _parseConfig = function _parseConfig(options, config) { options[key] = !!inputValue; } else if (expectedType === 'string' && !utils.isEmptyString(inputValue) || expectedType === 'number' && inputValue > 0) { options[key] = inputValue; + } else if (expectedType === 'object') { + _parseConfig(options[key], inputValue); } }; @@ -6534,7 +7541,8 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert _saveCookieData(this); userProperties = userProperties || {}; - apiProperties = apiProperties || {}; + var trackingOptions = merge_1$1({}, this._apiPropertiesTrackingOptions); + apiProperties = merge_1$1(trackingOptions, apiProperties || {}); eventProperties = eventProperties || {}; groups = groups || {}; var event = { @@ -6544,12 +7552,12 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert event_id: eventId, session_id: this._sessionId || -1, event_type: eventType, - version_name: this.options.versionName || null, - platform: this.options.platform, - os_name: this._ua.browser.name || null, - os_version: this._ua.browser.major || null, - device_model: this._ua.os.name || null, - language: this.options.language, + version_name: _shouldTrackField(this, 'version_name') ? this.options.versionName || null : null, + platform: _shouldTrackField(this, 'platform') ? this.options.platform : null, + os_name: _shouldTrackField(this, 'os_name') ? this._ua.browser.name || null : null, + os_version: _shouldTrackField(this, 'os_version') ? this._ua.browser.major || null : null, + device_model: _shouldTrackField(this, 'device_model') ? this._ua.os.name || null : null, + language: _shouldTrackField(this, 'language') ? this.options.language : null, api_properties: apiProperties, event_properties: utils.truncate(utils.validateProperties(eventProperties)), user_properties: utils.truncate(utils.validateProperties(userProperties)), @@ -6561,7 +7569,6 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert sequence_number: sequenceNumber, // for ordering events and identifys groups: utils.truncate(utils.validateGroups(groups)), user_agent: this._userAgent - // country: null }; if (eventType === constants.IDENTIFY_EVENT) { @@ -6586,6 +7593,23 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert } }; +var _shouldTrackField = function _shouldTrackField(scope, field) { + return !!scope.options.trackingOptions[field]; +}; + +var _generateApiPropertiesTrackingConfig = function _generateApiPropertiesTrackingConfig(scope) { + // to limit size of config payload, only send fields that have been disabled + var fields = ['city', 'country', 'dma', 'ip_address', 'region']; + var config = {}; + for (var i = 0; i < fields.length; i++) { + var field = fields[i]; + if (!_shouldTrackField(scope, field)) { + config[field] = false; + } + } + return config; +}; + /** * Remove old events from the beginning of the array if too many have accumulated. Default limit is 1000 events. * @private @@ -6934,6 +7958,125 @@ AmplitudeClient.prototype.setGlobalUserProperties = function setGlobalUserProper */ AmplitudeClient.prototype.__VERSION__ = version; +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = _overArg(Object.keys, Object); + +var _nativeKeys = nativeKeys; + +/** Used for built-in method references. */ +var objectProto$12 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$11 = objectProto$12.hasOwnProperty; + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!_isPrototype(object)) { + return _nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty$11.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +var _baseKeys = baseKeys; + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object); +} + +var keys_1 = keys; + +/** Used for built-in method references. */ +var objectProto$11 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$10 = objectProto$11.hasOwnProperty; + +/** + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object` and is loosely based on + * [`Object.assign`](https://mdn.io/Object/assign). + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assignIn + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assign({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'c': 3 } + */ +var assign = _createAssigner(function(object, source) { + if (_isPrototype(source) || isArrayLike_1(source)) { + _copyObject(source, keys_1(source), object); + return; + } + for (var key in source) { + if (hasOwnProperty$10.call(source, key)) { + _assignValue(object, key, source[key]); + } + } +}); + +var assign_1$1 = assign; + /** * Amplitude SDK API - instance manager. * Function calls directly on amplitude have been deprecated. Please call methods on the default shared instance: amplitude.getInstance() instead. diff --git a/amplitude.min.js b/amplitude.min.js index 41c7fbe3..8498397a 100644 --- a/amplitude.min.js +++ b/amplitude.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.amplitude=t()}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t,n){if(!(e0&&u>a&&(u=a);for(var c=0;c=0?(p=h.substr(0,g),l=h.substr(g+1)):(p=h,l=""),f=decodeURIComponent(p),d=decodeURIComponent(l),i(o,f)?jt(o[f])?o[f].push(d):o[f]=[o[f],d]:o[f]=d}return o}var p,l="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f=(e(function(e,t){(function(){function n(e,t){function o(e){if(o[e]!==v)return o[e];var n;if("bug-string-char-index"==e)n="a"!="a"[0];else if("json"==e)n=o("json-stringify")&&o("json-parse");else{var r,i='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if("json-stringify"==e){var u=t.stringify,p="function"==typeof u&&_;if(p){(r=function(){return 1}).toJSON=r;try{p="0"===u(0)&&"0"===u(new s)&&'""'==u(new a)&&u(m)===v&&u(v)===v&&u()===v&&"1"===u(r)&&"[1]"==u([r])&&"[null]"==u([v])&&"null"==u(null)&&"[null,null,null]"==u([v,m,null])&&u({a:[r,!0,!1,null,"\0\b\n\f\r\t"]})==i&&"1"===u(null,r)&&"[\n 1,\n 2\n]"==u([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==u(new c(-864e13))&&'"+275760-09-13T00:00:00.000Z"'==u(new c(864e13))&&'"-000001-01-01T00:00:00.000Z"'==u(new c(-621987552e5))&&'"1969-12-31T23:59:59.999Z"'==u(new c(-1))}catch(e){p=!1}}n=p}if("json-parse"==e){var l=t.parse;if("function"==typeof l)try{if(0===l("0")&&!l(!1)){var f=5==(r=l(i)).a.length&&1===r.a[0];if(f){try{f=!l('"\t"')}catch(e){}if(f)try{f=1!==l("01")}catch(e){}if(f)try{f=1!==l("1.")}catch(e){}}}}catch(e){f=!1}n=f}}return o[e]=!!n}e||(e=i.Object()),t||(t=i.Object());var s=e.Number||i.Number,a=e.String||i.String,u=e.Object||i.Object,c=e.Date||i.Date,p=e.SyntaxError||i.SyntaxError,l=e.TypeError||i.TypeError,f=e.Math||i.Math,d=e.JSON||i.JSON;"object"==typeof d&&d&&(t.stringify=d.stringify,t.parse=d.parse);var h,g,v,y=u.prototype,m=y.toString,_=new c(-0xc782b5b800cec);try{_=-109252==_.getUTCFullYear()&&0===_.getUTCMonth()&&1===_.getUTCDate()&&10==_.getUTCHours()&&37==_.getUTCMinutes()&&6==_.getUTCSeconds()&&708==_.getUTCMilliseconds()}catch(e){}if(!o("json")){var b=o("bug-string-char-index");if(!_)var w=f.floor,I=[0,31,59,90,120,151,181,212,243,273,304,334],E=function(e,t){return I[t]+365*(e-1970)+w((e-1969+(t=+(t>1)))/4)-w((e-1901+t)/100)+w((e-1601+t)/400)};if((h=y.hasOwnProperty)||(h=function(e){var t,n={};return(n.__proto__=null,n.__proto__={toString:1},n).toString!=m?h=function(e){var t=this.__proto__,n=e in(this.__proto__=null,this);return this.__proto__=t,n}:(t=n.constructor,h=function(e){var n=(this.constructor||t).prototype;return e in this&&!(e in n&&this[e]===n[e])}),n=null,h.call(this,e)}),g=function(e,t){var n,o,i,s=0;(n=function(){this.valueOf=0}).prototype.valueOf=0,o=new n;for(i in o)h.call(o,i)&&s++;return n=o=null,s?g=2==s?function(e,t){var n,r={},o="[object Function]"==m.call(e);for(n in e)o&&"prototype"==n||h.call(r,n)||!(r[n]=1)||!h.call(e,n)||t(n)}:function(e,t){var n,r,o="[object Function]"==m.call(e);for(n in e)o&&"prototype"==n||!h.call(e,n)||(r="constructor"===n)||t(n);(r||h.call(e,n="constructor"))&&t(n)}:(o=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],g=function(e,t){var n,i,s="[object Function]"==m.call(e),a=!s&&"function"!=typeof e.constructor&&r[typeof e.hasOwnProperty]&&e.hasOwnProperty||h;for(n in e)s&&"prototype"==n||!a.call(e,n)||t(n);for(i=o.length;n=o[--i];a.call(e,n)&&t(n));}),g(e,t)},!o("json-stringify")){var S={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},C=function(e,t){return("000000"+(t||0)).slice(-e)},N=function(e){for(var t='"',n=0,r=e.length,o=!b||r>10,i=o&&(b?e.split(""):e);n-1/0&&a<1/0){if(E){for(f=w(a/864e5),c=w(f/365.2425)+1970-1;E(c+1,0)<=f;c++);for(p=w((f-E(c,0))/30.42);E(c,p+1)<=f;p++);f=1+f-E(c,p),y=w((d=(a%864e5+864e5)%864e5)/36e5)%24,_=w(d/6e4)%60,b=w(d/1e3)%60,I=d%1e3}else c=a.getUTCFullYear(),p=a.getUTCMonth(),f=a.getUTCDate(),y=a.getUTCHours(),_=a.getUTCMinutes(),b=a.getUTCSeconds(),I=a.getUTCMilliseconds();a=(c<=0||c>=1e4?(c<0?"-":"+")+C(6,c<0?-c:c):C(4,c))+"-"+C(2,p+1)+"-"+C(2,f)+"T"+C(2,y)+":"+C(2,_)+":"+C(2,b)+"."+C(3,I)+"Z"}else a=null;if(n&&(a=n.call(t,e,a)),null===a)return"null";if("[object Boolean]"==(u=m.call(a)))return""+a;if("[object Number]"==u)return a>-1/0&&a<1/0?""+a:"null";if("[object String]"==u)return N(""+a);if("object"==typeof a){for(x=s.length;x--;)if(s[x]===a)throw l();if(s.push(a),S=[],j=i,i+=o,"[object Array]"==u){for(T=0,x=a.length;T0)for(o="",n>10&&(n=10);o.length=48&&o<=57||o>=97&&o<=102||o>=65&&o<=70||k();e+=x("0x"+i.slice(t,A));break;default:k()}else{if(34==o)break;for(o=i.charCodeAt(A),t=A;o>=32&&92!=o&&34!=o;)o=i.charCodeAt(++A);e+=i.slice(t,A)}if(34==i.charCodeAt(A))return A++,e;k();default:if(t=A,45==o&&(r=!0,o=i.charCodeAt(++A)),o>=48&&o<=57){for(48==o&&(o=i.charCodeAt(A+1))>=48&&o<=57&&k(),r=!1;A=48&&o<=57;A++);if(46==i.charCodeAt(A)){for(n=++A;n=48&&o<=57;n++);n==A&&k(),A=n}if(101==(o=i.charCodeAt(A))||69==o){for(43!=(o=i.charCodeAt(++A))&&45!=o||A++,n=A;n=48&&o<=57;n++);n==A&&k(),A=n}return+i.slice(t,A)}if(r&&k(),"true"==i.slice(A,A+4))return A+=4,!0;if("false"==i.slice(A,A+5))return A+=5,!1;if("null"==i.slice(A,A+4))return A+=4,null;k()}return"$"},R=function(e){var t,n;if("$"==e&&k(),"string"==typeof e){if("@"==(b?e.charAt(0):e[0]))return e.slice(1);if("["==e){for(t=[];"]"!=(e=P());n||(n=!0))n&&(","==e?"]"==(e=P())&&k():k()),","==e&&k(),t.push(R(e));return t}if("{"==e){for(t={};"}"!=(e=P());n||(n=!0))n&&(","==e?"}"==(e=P())&&k():k()),","!=e&&"string"==typeof e&&"@"==(b?e.charAt(0):e[0])&&":"==P()||k(),t[e.slice(1)]=R(P());return t}k()}return e},F=function(e,t,n){var r=U(e,t,n);r===v?delete e[t]:e[t]=r},U=function(e,t,n){var r,o=e[t];if("object"==typeof o&&o)if("[object Array]"==m.call(o))for(r=o.length;r--;)F(o,r,n);else g(o,function(e){F(o,e,n)});return n.call(e,t,o)};t.parse=function(e,t){var n,r;return A=0,T=""+e,n=R(P()),"$"!=P()&&k(),A=T=null,t&&"[object Function]"==m.call(t)?U((r={},r[""]=n,r),"",t):n}}}return t.runInContext=n,t}var r={function:!0,object:!0},o=r.object&&t&&!t.nodeType&&t,i=r[typeof window]&&window||this,s=o&&r.object&&e&&!e.nodeType&&"object"==typeof l&&l;if(!s||s.global!==s&&s.window!==s&&s.self!==s||(i=s),o)n(i,o);else{var a=i.JSON,u=i.JSON3,c=!1,p=n(i,i.JSON3={noConflict:function(){return c||(c=!0,i.JSON=a,i.JSON3=u,a=u=null),p}});i.JSON={parse:p.parse,stringify:p.stringify}}}).call(l)}),{DEFAULT_INSTANCE:"$default_instance",API_VERSION:2,MAX_STRING_LENGTH:4096,MAX_PROPERTY_KEYS:1e3,IDENTIFY_EVENT:"$identify",LAST_EVENT_ID:"amplitude_lastEventId",LAST_EVENT_TIME:"amplitude_lastEventTime",LAST_IDENTIFY_ID:"amplitude_lastIdentifyId",LAST_SEQUENCE_NUMBER:"amplitude_lastSequenceNumber",SESSION_ID:"amplitude_sessionId",DEVICE_ID:"amplitude_deviceId",OPT_OUT:"amplitude_optOut",USER_ID:"amplitude_userId",COOKIE_TEST:"amplitude_cookie_test",REVENUE_EVENT:"revenue_amount",REVENUE_PRODUCT_ID:"$productId",REVENUE_QUANTITY:"$quantity",REVENUE_PRICE:"$price",REVENUE_REVENUE_TYPE:"$revenueType",AMP_DEVICE_ID_PARAM:"amp_device_id"}),d={encode:function(e){for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},decode:function(e){for(var t="",n=0,r=0,o=0,i=0;n191&&r<224?(o=e.charCodeAt(n+1),t+=String.fromCharCode((31&r)<<6|63&o),n+=2):(o=e.charCodeAt(n+1),i=e.charCodeAt(n+2),t+=String.fromCharCode((15&r)<<12|(63&o)<<6|63&i),n+=3);return t}},h={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(e)))}catch(e){}return h._encode(e)},_encode:function(e){var t,n,r,o,i,s,a,u="",c=0;for(e=d.encode(e);c>2,i=(3&t)<<4|(n=e.charCodeAt(c++))>>4,s=(15&n)<<2|(r=e.charCodeAt(c++))>>6,a=63&r,isNaN(n)?s=a=64:isNaN(r)&&(a=64),u=u+h._keyStr.charAt(o)+h._keyStr.charAt(i)+h._keyStr.charAt(s)+h._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return h._decode(e)},_decode:function(e){var t,n,r,o,i,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,n=(15&o)<<4|(i=h._keyStr.indexOf(e.charAt(u++)))>>2,r=(3&i)<<6|(s=h._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==i&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(r));return a=d.decode(a)}},g=e(function(e,t){t.parse=function(e){var t=document.createElement("a");return t.href=e,{href:t.href,host:t.host||location.host,port:"0"===t.port||""===t.port?function(e){switch(e){case"http:":return 80;case"https:":return 443;default:return location.port}}(t.protocol):t.port,hash:t.hash,hostname:t.hostname||location.hostname,pathname:"/"!=t.pathname.charAt(0)?"/"+t.pathname:t.pathname,protocol:t.protocol&&":"!=t.protocol?t.protocol:location.protocol,search:t.search,query:t.search.slice(1)}},t.isAbsolute=function(e){return 0==e.indexOf("//")||!!~e.indexOf("://")},t.isRelative=function(e){return!t.isAbsolute(e)},t.isCrossDomain=function(e){e=t.parse(e);var n=t.parse(window.location.href);return e.hostname!==n.hostname||e.port!==n.port||e.protocol!==n.protocol}}),v=1e3,y=60*v,m=60*y,_=24*m,b=365.25*_,w=function(e,n){n=n||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*b;case"days":case"day":case"d":return n*_;case"hours":case"hour":case"hrs":case"hr":case"h":return n*m;case"minutes":case"minute":case"mins":case"min":case"m":return n*y;case"seconds":case"second":case"secs":case"sec":case"s":return n*v;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===r&&!1===isNaN(e))return n.long?function(e){return t(e,_,"day")||t(e,m,"hour")||t(e,y,"minute")||t(e,v,"second")||e+" ms"}(e):function(e){return e>=_?Math.round(e/_)+"d":e>=m?Math.round(e/m)+"h":e>=y?Math.round(e/y)+"m":e>=v?Math.round(e/v)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},I=e(function(e,t){function n(e){function n(){if(n.enabled){var e=n,r=+new Date,i=r-(o||r);e.diff=i,e.prev=o,e.curr=r,o=r;for(var s=new Array(arguments.length),a=0;a=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())})("cookie"),S=function(e,t,o){switch(arguments.length){case 3:case 2:return function(e,t,n){n=n||{};var o=r(e)+"="+r(t);null==t&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(o+="; path="+n.path),n.domain&&(o+="; domain="+n.domain),n.expires&&(o+="; expires="+n.expires.toUTCString()),n.secure&&(o+="; secure"),document.cookie=o}(e,t,o);case 1:return function(e){return n()[e]}(e);default:return n()}},C=e(function(e,t){function n(e){for(var n=t.cookie,r=t.levels(e),o=0;o=0;--i)o.push(t.slice(i).join("."));return o},n.cookie=S,t=e.exports=n}),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},O=Object.prototype.toString,A=function(e){switch(O.call(e)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===e?"null":void 0===e?"undefined":e!=e?"nan":e&&1===e.nodeType?"element":"undefined"!=typeof Buffer&&Buffer.isBuffer(e)?"buffer":void 0===(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e))?"undefined":N(e)},T="WARN",x={DISABLE:0,ERROR:1,WARN:2,INFO:3},j={error:function(e){T>=x.ERROR&&k(e)},warn:function(e){T>=x.WARN&&k(e)},info:function(e){T>=x.INFO&&k(e)}},k=function(e){try{console.log("[Amplitude] "+e)}catch(e){}},P=function(e){return"string"===A(e)&&e.length>f.MAX_STRING_LENGTH?e.substring(0,f.MAX_STRING_LENGTH):e},R=function(e){var t=A(e);if("object"!==t)return j.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>f.MAX_PROPERTY_KEYS)return j.error("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=r,i=A(o);"string"!==i&&(o=String(o),j.warn("WARNING: Non-string property key, received type "+i+', coercing to string "'+o+'"'));var s=U(o,e[r]);null!==s&&(n[o]=s)}return n},F=["null","nan","undefined","function","arguments","regexp","element"],U=function e(t,n){var r=A(n);if(-1!==F.indexOf(r))j.warn('WARNING: Property key "'+t+'" with invalid value type '+r+", ignoring"),n=null;else if("error"===r)n=String(n),j.warn('WARNING: Property key "'+t+'" with value type error, coercing to '+n);else if("array"===r){for(var o=[],i=0;i0?(this.userPropertiesOperations.hasOwnProperty("$clearAll")||q.log.error("Need to send $clearAll on its own Identify object without any other operations, skipping $clearAll"),this):(this.userPropertiesOperations.$clearAll="-",this)},Q.prototype.prepend=function(e,t){return this._addOperation("$prepend",e,t),this},Q.prototype.set=function(e,t){return this._addOperation("$set",e,t),this},Q.prototype.setOnce=function(e,t){return this._addOperation("$setOnce",e,t),this},Q.prototype.unset=function(e){return this._addOperation("$unset",e,"-"),this},Q.prototype._addOperation=function(e,t,n){this.userPropertiesOperations.hasOwnProperty("$clearAll")?q.log.error("This identify already contains a $clearAll operation, skipping operation "+e):-1===this.properties.indexOf(t)?(this.userPropertiesOperations.hasOwnProperty(e)||(this.userPropertiesOperations[e]={}),this.userPropertiesOperations[e][t]=n,this.properties.push(t)):q.log.error('User property "'+t+'" already used in this identify, skipping operation '+e)};var X=e(function(e){!function(t){function n(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,o,i,s){return n(function(e,t){return e<>>32-t}(n(n(t,e),n(o,s)),i),r)}function o(e,t,n,o,i,s,a){return r(t&n|~t&o,e,t,i,s,a)}function i(e,t,n,o,i,s,a){return r(t&o|n&~o,e,t,i,s,a)}function s(e,t,n,o,i,s,a){return r(t^n^o,e,t,i,s,a)}function a(e,t,n,o,i,s,a){return r(n^(t|~o),e,t,i,s,a)}function u(e,t){e[t>>5]|=128<>>9<<4)]=t;var r,u,c,p,l,f=1732584193,d=-271733879,h=-1732584194,g=271733878;for(r=0;r>5]>>>t%32&255);return n}function p(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+"0123456789abcdef".charAt(15&t);return r}function f(e){return unescape(encodeURIComponent(e))}function d(e){return function(e){return c(u(p(e),8*e.length))}(f(e))}function h(e,t){return function(e,t){var n,r,o=p(e),i=[],s=[];for(i[15]=s[15]=void 0,o.length>16&&(o=u(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],s[n]=1549556828^o[n];return r=u(i.concat(p(t)),512+8*t.length),c(u(s.concat(r),640))}(f(e),f(t))}function g(e,t,n){return t?n?h(t,e):function(e,t){return l(h(e,t))}(t,e):n?d(e):function(e){return l(d(e))}(e)}e.exports?e.exports=g:t.md5=g}(l)}),H="object"==typeof l&&l&&l.Object===Object&&l,Z="object"==typeof self&&self&&self.Object===Object&&self,ee=H||Z||Function("return this")(),te=ee.Symbol,ne=Object.prototype,re=ne.hasOwnProperty,oe=ne.toString,ie=te?te.toStringTag:void 0,se=function(e){var t=re.call(e,ie),n=e[ie];try{e[ie]=void 0;var r=!0}catch(e){}var o=oe.call(e);return r&&(t?e[ie]=n:delete e[ie]),o},ae=Object.prototype.toString,ue=function(e){return ae.call(e)},ce="[object Null]",pe="[object Undefined]",le=te?te.toStringTag:void 0,fe=function(e){return null==e?void 0===e?pe:ce:le&&le in Object(e)?se(e):ue(e)},de=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},he="[object AsyncFunction]",ge="[object Function]",ve="[object GeneratorFunction]",ye="[object Proxy]",me=function(e){if(!de(e))return!1;var t=fe(e);return t==ge||t==ve||t==he||t==ye},_e=ee["__core-js_shared__"],be=function(){var e=/[^.]+$/.exec(_e&&_e.keys&&_e.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),we=function(e){return!!be&&be in e},Ie=Function.prototype.toString,Ee=function(e){if(null!=e){try{return Ie.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Se=/^\[object .+?Constructor\]$/,Ce=Function.prototype,Ne=Object.prototype,Oe=Ce.toString,Ae=Ne.hasOwnProperty,Te=RegExp("^"+Oe.call(Ae).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xe=function(e){return!(!de(e)||we(e))&&(me(e)?Te:Se).test(Ee(e))},je=function(e,t){return null==e?void 0:e[t]},ke=function(e,t){var n=je(e,t);return xe(n)?n:void 0},Pe=function(){try{var e=ke(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),Re=function(e,t,n){"__proto__"==t&&Pe?Pe(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},Fe=function(e,t){return e===t||e!=e&&t!=t},Ue=Object.prototype.hasOwnProperty,De=function(e,t,n){var r=e[t];Ue.call(e,t)&&Fe(r,n)&&(void 0!==n||t in e)||Re(e,t,n)},qe=function(e,t,n,r){var o=!n;n||(n={});for(var i=-1,s=t.length;++i0){if(++t>=ze)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Ke),Ye=function(e,t){return We(Ge(e,t,Me),e+"")},Qe=9007199254740991,Xe=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=Qe},He=function(e){return null!=e&&Xe(e.length)&&!me(e)},Ze=9007199254740991,et=/^(?:0|[1-9]\d*)$/,tt=function(e,t){return!!(t=null==t?Ze:t)&&("number"==typeof e||et.test(e))&&e>-1&&e%1==0&&e1?n[o-1]:void 0,s=o>2?n[2]:void 0;for(i=e.length>3&&"function"==typeof i?(o--,i):void 0,s&&nt(n[0],n[1],s)&&(i=o<3?void 0:i,o=1),t=Object(t);++r0?2==o.length?"function"==typeof o[1]?e[o[0]]=o[1].call(this,s):e[o[0]]=o[1]:3==o.length?"function"!=typeof o[1]||o[1].exec&&o[1].test?e[o[0]]=s?s.replace(o[1],o[2]):void 0:e[o[0]]=s?o[1].call(this,s,o[2]):void 0:4==o.length&&(e[o[0]]=s?o[3].call(this,s.replace(o[1],o[2])):void 0):e[o]=s||void 0;a+=2}return e},str:function(e,t){for(var n in t)if("object"==typeof t[n]&&t[n].length>0){for(var r=0;r>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)},qt={apiEndpoint:"api.amplitude.com",cookieExpiration:3650,cookieName:"amplitude_id",domain:"",includeReferrer:!1,includeUtm:!1,language:{language:navigator&&(navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage)||void 0}.language,logLevel:"WARN",optOut:!1,platform:"Web",savedMaxCount:1e3,saveEvents:!0,sessionTimeout:18e5,unsentKey:"amplitude_unsent",unsentIdentifyKey:"amplitude_unsent_identify",uploadBatchSize:100,batchEvents:!1,eventUploadThreshold:30,eventUploadPeriodMillis:3e4,forceHttps:!0,includeGclid:!1,saveParamsReferrerOncePerSession:!0,deviceIdFromUrlParam:!1},Mt=function(e){this._instanceName=q.isEmptyString(e)?f.DEFAULT_INSTANCE:e.toLowerCase(),this._legacyStorageSuffix=this._instanceName===f.DEFAULT_INSTANCE?"":"_"+this._instanceName,this._unsentEvents=[],this._unsentIdentifys=[],this._ua=new Ut(navigator.userAgent).getResult(),this.options=xt({},qt),this.cookieStorage=(new Y).getStorage(),this._q=[],this._sending=!1,this._updateScheduled=!1,this._eventId=0,this._identifyId=0,this._lastEventTime=null,this._newSession=!1,this._sequenceNumber=0,this._sessionId=null,this._userAgent=navigator&&navigator.userAgent||null};Mt.prototype.Identify=Q,Mt.prototype.Revenue=Ft,Mt.prototype.init=function(e,t,n,r){if("string"!==A(e)||q.isEmptyString(e))q.log.error("Invalid apiKey. Please re-initialize with a valid apiKey");else try{if(this.options.apiKey=e,this._storageSuffix="_"+e+this._legacyStorageSuffix,Lt(this.options,n),this.cookieStorage.options({expirationDays:this.options.cookieExpiration,domain:this.options.domain}),this.options.domain=this.cookieStorage.options().domain,this._instanceName===f.DEFAULT_INSTANCE&&Vt(this),Gt(this),this.options.deviceId="object"===A(n)&&"string"===A(n.deviceId)&&!q.isEmptyString(n.deviceId)&&n.deviceId||this.options.deviceIdFromUrlParam&&this._getDeviceIdFromUrlParam(this._getUrlParams())||this.options.deviceId||Dt()+"R",this.options.userId="string"===A(t)&&!q.isEmptyString(t)&&t||"number"===A(t)&&t.toString()||this.options.userId||null,this.options.saveEvents){this._unsentEvents=this._loadSavedUnsentEvents(this.options.unsentKey),this._unsentIdentifys=this._loadSavedUnsentEvents(this.options.unsentIdentifyKey);for(var o=0;othis.options.sessionTimeout)&&(this._newSession=!0,this._sessionId=p,this.options.saveParamsReferrerOncePerSession&&this._trackParamsAndReferrer()),this.options.saveParamsReferrerOncePerSession||this._trackParamsAndReferrer(),this._lastEventTime=p,Kt(this),this._sendEventsIfReady()}catch(e){q.log.error(e)}finally{"function"===A(r)&&r(this)}},Mt.prototype._trackParamsAndReferrer=function(){this.options.includeUtm&&this._initUtmData(),this.options.includeReferrer&&this._saveReferrer(this._getReferrer()),this.options.includeGclid&&this._saveGclid(this._getUrlParams())};var Lt=function(e,t){if("object"===A(t)){var n=function(n){if(qt.hasOwnProperty(n)){var r=t[n],o=A(qt[n]);q.validateInput(r,n+" option",o)&&("boolean"===o?e[n]=!!r:("string"===o&&!q.isEmptyString(r)||"number"===o&&r>0)&&(e[n]=r))}};for(var r in t)t.hasOwnProperty(r)&&n(r)}};Mt.prototype.runQueuedFunctions=function(){for(var e=0;e=this.options.eventUploadThreshold?(this.sendEvents(e),!0):(this._updateScheduled||(this._updateScheduled=!0,setTimeout(function(){this._updateScheduled=!1,this.sendEvents()}.bind(this),this.options.eventUploadPeriodMillis)),!1):(this.sendEvents(e),!0))},Mt.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},Mt.prototype._getFromStorageLegacy=function(e,t){return e.getItem(t+this._legacyStorageSuffix)},Mt.prototype._setInStorage=function(e,t,n){e.setItem(t+this._storageSuffix,n)};var Vt=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);if("object"!==A(t)&&(t=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix),!("object"===A(t)&&t.deviceId&&t.sessionId&&t.lastEventTime))){var n=function(e){var t=W.getItem(e);return W.removeItem(e),t},r="string"===A(e.options.apiKey)&&"_"+e.options.apiKey.slice(0,6)||"",o=n(f.DEVICE_ID+r),i=n(f.USER_ID+r),s=n(f.OPT_OUT+r);null!==s&&void 0!==s&&(s="true"===String(s));var a=parseInt(n(f.SESSION_ID)),u=parseInt(n(f.LAST_EVENT_TIME)),c=parseInt(n(f.LAST_EVENT_ID)),p=parseInt(n(f.LAST_IDENTIFY_ID)),l=parseInt(n(f.LAST_SEQUENCE_NUMBER)),d=function(e){return"object"===A(t)&&t[e]};e.options.deviceId=d("deviceId")||o,e.options.userId=d("userId")||i,e._sessionId=d("sessionId")||a||e._sessionId,e._lastEventTime=d("lastEventTime")||u||e._lastEventTime,e._eventId=d("eventId")||c||e._eventId,e._identifyId=d("identifyId")||p||e._identifyId,e._sequenceNumber=d("sequenceNumber")||l||e._sequenceNumber,e.options.optOut=s||!1,t&&void 0!==t.optOut&&null!==t.optOut&&(e.options.optOut="true"===String(t.optOut)),Kt(e)}},Gt=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);if("object"===A(t))Bt(e,t);else{var n=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix);"object"===A(n)&&(e.cookieStorage.remove(e.options.cookieName+e._legacyStorageSuffix),Bt(e,n))}},Bt=function(e,t){t.deviceId&&(e.options.deviceId=t.deviceId),t.userId&&(e.options.userId=t.userId),null!==t.optOut&&void 0!==t.optOut&&(e.options.optOut=t.optOut),t.sessionId&&(e._sessionId=parseInt(t.sessionId)),t.lastEventTime&&(e._lastEventTime=parseInt(t.lastEventTime)),t.eventId&&(e._eventId=parseInt(t.eventId)),t.identifyId&&(e._identifyId=parseInt(t.identifyId)),t.sequenceNumber&&(e._sequenceNumber=parseInt(t.sequenceNumber))},Kt=function(e){e.cookieStorage.set(e.options.cookieName+e._storageSuffix,{deviceId:e.options.deviceId,userId:e.options.userId,optOut:e.options.optOut,sessionId:e._sessionId,lastEventTime:e._lastEventTime,eventId:e._eventId,identifyId:e._identifyId,sequenceNumber:e._sequenceNumber})};Mt.prototype._initUtmData=function(e,t){e=e||this._getUrlParams();var n=function(e,t){var n=e?"?"+e.split(".").slice(-1)[0].replace(/\|/g,"&"):"",r=function(e,t,n,r){return q.getQueryParam(e,t)||q.getQueryParam(n,r)},o=r("utm_source",t,"utmcsr",n),i=r("utm_medium",t,"utmcmd",n),s=r("utm_campaign",t,"utmccn",n),a=r("utm_term",t,"utmctr",n),u=r("utm_content",t,"utmcct",n),c={},p=function(e,t){q.isEmptyString(t)||(c[e]=t)};return p("utm_source",o),p("utm_medium",i),p("utm_campaign",s),p("utm_term",a),p("utm_content",u),c}(t=t||this.cookieStorage.get("__utmz"),e);zt(this,n)};var zt=function(e,t){if("object"===A(t)&&0!==Object.keys(t).length){var n=new Q;for(var r in t)t.hasOwnProperty(r)&&(n.setOnce("initial_"+r,t[r]),n.set(r,t[r]));e.identify(n)}};Mt.prototype._getReferrer=function(){return document.referrer},Mt.prototype._getUrlParams=function(){return location.search},Mt.prototype._saveGclid=function(e){var t=q.getQueryParam("gclid",e);if(!q.isEmptyString(t)){zt(this,{gclid:t})}},Mt.prototype._getDeviceIdFromUrlParam=function(e){return q.getQueryParam(f.AMP_DEVICE_ID_PARAM,e)},Mt.prototype._getReferringDomain=function(e){if(q.isEmptyString(e))return null;var t=e.split("/");return t.length>=3?t[2]:null},Mt.prototype._saveReferrer=function(e){if(!q.isEmptyString(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};zt(this,t)}},Mt.prototype.saveEvents=function(){try{this._setInStorage(W,this.options.unsentKey,JSON.stringify(this._unsentEvents))}catch(e){}try{this._setInStorage(W,this.options.unsentIdentifyKey,JSON.stringify(this._unsentIdentifys))}catch(e){}},Mt.prototype.setDomain=function(e){if(q.validateInput(e,"domain","string"))try{this.cookieStorage.options({domain:e}),this.options.domain=this.cookieStorage.options().domain,Gt(this),Kt(this)}catch(e){q.log.error(e)}},Mt.prototype.setUserId=function(e){try{this.options.userId=void 0!==e&&null!==e&&""+e||null,Kt(this)}catch(e){q.log.error(e)}},Mt.prototype.setGroup=function(e,t){if(this._apiKeySet("setGroup()")&&q.validateInput(e,"groupType","string")&&!q.isEmptyString(e)){var n={};n[e]=t;var r=(new Q).set(e,t);this._logEvent(f.IDENTIFY_EVENT,null,null,r.userPropertiesOperations,n,null,null)}},Mt.prototype.setOptOut=function(e){if(q.validateInput(e,"enable","boolean"))try{this.options.optOut=e,Kt(this)}catch(e){q.log.error(e)}},Mt.prototype.setSessionId=function(e){if(q.validateInput(e,"sessionId","number"))try{this._sessionId=e,Kt(this)}catch(e){q.log.error(e)}},Mt.prototype.resetSessionId=function(){this.setSessionId((new Date).getTime())},Mt.prototype.regenerateDeviceId=function(){this.setDeviceId(Dt()+"R")},Mt.prototype.setDeviceId=function(e){if(q.validateInput(e,"deviceId","string"))try{q.isEmptyString(e)||(this.options.deviceId=""+e,Kt(this))}catch(e){q.log.error(e)}},Mt.prototype.setUserProperties=function(e){if(this._apiKeySet("setUserProperties()")&&q.validateInput(e,"userProperties","object")){var t=q.truncate(q.validateProperties(e));if(0!==Object.keys(t).length){var n=new Q;for(var r in t)t.hasOwnProperty(r)&&n.set(r,t[r]);this.identify(n)}}},Mt.prototype.clearUserProperties=function(){if(this._apiKeySet("clearUserProperties()")){var e=new Q;e.clearAll(),this.identify(e)}};var Jt=function(e,t){for(var n=0;n0)return this._logEvent(f.IDENTIFY_EVENT,null,null,e.userPropertiesOperations,null,null,t);"function"===A(t)&&t(0,"No request sent",{reason:"No user property operations"})}else q.log.error("Invalid identify input type. Expected Identify object but saw "+A(e)),"function"===A(t)&&t(0,"No request sent",{reason:"Invalid identify input type"});else"function"===A(t)&&t(0,"No request sent",{reason:"API key is not set"})},Mt.prototype.setVersionName=function(e){q.validateInput(e,"versionName","string")&&(this.options.versionName=e)},Mt.prototype._logEvent=function(e,t,n,r,o,i,s){if(Gt(this),e)if(this.options.optOut)"function"===A(s)&&s(0,"No request sent",{reason:"optOut is set to true"});else try{var a;a=e===f.IDENTIFY_EVENT?this.nextIdentifyId():this.nextEventId();var u=this.nextSequenceNumber(),c="number"===A(i)?i:(new Date).getTime();(!this._sessionId||!this._lastEventTime||c-this._lastEventTime>this.options.sessionTimeout)&&(this._sessionId=c),this._lastEventTime=c,Kt(this),r=r||{},n=n||{},t=t||{},o=o||{};var p={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:c,event_id:a,session_id:this._sessionId||-1,event_type:e,version_name:this.options.versionName||null,platform:this.options.platform,os_name:this._ua.browser.name||null,os_version:this._ua.browser.major||null,device_model:this._ua.os.name||null,language:this.options.language,api_properties:n,event_properties:q.truncate(q.validateProperties(t)),user_properties:q.truncate(q.validateProperties(r)),uuid:Dt(),library:{name:"amplitude-js",version:"4.3.0"},sequence_number:u,groups:q.truncate(q.validateGroups(o)),user_agent:this._userAgent};return e===f.IDENTIFY_EVENT?(this._unsentIdentifys.push(p),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push(p),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(s)||"function"!==A(s)||s(0,"No request sent",{reason:"No events to send or upload queued"}),a}catch(e){q.log.error(e)}else"function"===A(s)&&s(0,"No request sent",{reason:"Missing eventType"})},Mt.prototype._limitEventsQueued=function(e){e.length>this.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount)},Mt.prototype.logEvent=function(e,t,n){return this.logEventWithTimestamp(e,t,null,n)},Mt.prototype.logEventWithTimestamp=function(e,t,n,r){return this._apiKeySet("logEvent()")?q.validateInput(e,"eventType","string")?q.isEmptyString(e)?("function"===A(r)&&r(0,"No request sent",{reason:"Missing eventType"}),-1):this._logEvent(e,t,null,null,null,n,r):("function"===A(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===A(r)&&r(0,"No request sent",{reason:"API key not set"}),-1)},Mt.prototype.logEventWithGroups=function(e,t,n,r){return this._apiKeySet("logEventWithGroups()")?q.validateInput(e,"eventType","string")?this._logEvent(e,t,null,null,n,null,r):("function"===A(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===A(r)&&r(0,"No request sent",{reason:"API key not set"}),-1)};var $t=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};Mt.prototype.logRevenueV2=function(e){if(this._apiKeySet("logRevenueV2()"))if("object"===A(e)&&e.hasOwnProperty("_q")&&(e=Jt(new Ft,e)),e instanceof Ft){if(e&&e._isValidRevenue())return this.logEvent(f.REVENUE_EVENT,e._toJSONObject())}else q.log.error("Invalid revenue input type. Expected Revenue object but saw "+A(e))},Mt.prototype.logRevenue=function(e,t,n){return this._apiKeySet("logRevenue()")&&$t(e)&&(void 0===t||$t(t))?this._logEvent(f.REVENUE_EVENT,{},{productId:n,special:"revenue_amount",quantity:t||1,price:e},null,null,null,null):-1},Mt.prototype.removeEvents=function(e,t){Wt(this,"_unsentEvents",e),Wt(this,"_unsentIdentifys",t)};var Wt=function(e,t,n){if(!(n<0)){for(var r=[],o=0;on&&r.push(e[t][o]);e[t]=r}};Mt.prototype.sendEvents=function(e){if(this._apiKeySet("sendEvents()"))if(this.options.optOut)"function"===A(e)&&e(0,"No request sent",{reason:"optOut is set to true"});else if(0!==this._unsentCount())if(this._sending)"function"===A(e)&&e(0,"No request sent",{reason:"Request already in progress"});else{this._sending=!0;var t=(this.options.forceHttps?"https":"https:"===window.location.protocol?"https":"http")+"://"+this.options.apiEndpoint+"/",n=Math.min(this._unsentCount(),this.options.uploadBatchSize),r=this._mergeEventsAndIdentifys(n),o=r.maxEventId,i=r.maxIdentifyId,s=JSON.stringify(r.eventsToSend),a=(new Date).getTime(),u={client:this.options.apiKey,e:s,v:f.API_VERSION,upload_time:a,checksum:X(f.API_VERSION+this.options.apiKey+s+a)},c=this;new Rt(t,u).send(function(t,r){c._sending=!1;try{200===t&&"success"===r?(c.removeEvents(o,i),c.options.saveEvents&&c.saveEvents(),c._sendEventsIfReady(e)||"function"!==A(e)||e(t,r)):413===t?(1===c.options.uploadBatchSize&&c.removeEvents(o,i),c.options.uploadBatchSize=Math.ceil(n/2),c.sendEvents(e)):"function"===A(e)&&e(t,r)}catch(e){}})}else"function"===A(e)&&e(0,"No request sent",{reason:"No events to send"});else"function"===A(e)&&e(0,"No request sent",{reason:"API key not set"})},Mt.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],n=0,r=-1,o=0,i=-1;t.length=this._unsentIdentifys.length,u=n>=this._unsentEvents.length;if(u&&a){q.log.error("Merging Events and Identifys, less events and identifys than expected");break}a?r=(s=this._unsentEvents[n++]).event_id:u?i=(s=this._unsentIdentifys[o++]).event_id:!("sequence_number"in this._unsentEvents[n])||this._unsentEvents[n].sequence_number0&&a>s&&(a=s);for(var u=0;u=0?(c=h.substr(0,g),l=h.substr(g+1)):(c=h,l=""),f=decodeURIComponent(c),d=decodeURIComponent(l),p(o,f)?Ln(o[f])?o[f].push(d):o[f]=[o[f],d]:o[f]=d}return o}var g,v="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y=(e(function(e,t){(function(){function n(e,t){function o(e){if(o[e]!==v)return o[e];var n;if("bug-string-char-index"==e)n="a"!="a"[0];else if("json"==e)n=o("json-stringify")&&o("json-parse");else{var r,i='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if("json-stringify"==e){var u=t.stringify,p="function"==typeof u&&_;if(p){(r=function(){return 1}).toJSON=r;try{p="0"===u(0)&&"0"===u(new s)&&'""'==u(new a)&&u(m)===v&&u(v)===v&&u()===v&&"1"===u(r)&&"[1]"==u([r])&&"[null]"==u([v])&&"null"==u(null)&&"[null,null,null]"==u([v,m,null])&&u({a:[r,!0,!1,null,"\0\b\n\f\r\t"]})==i&&"1"===u(null,r)&&"[\n 1,\n 2\n]"==u([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==u(new c(-864e13))&&'"+275760-09-13T00:00:00.000Z"'==u(new c(864e13))&&'"-000001-01-01T00:00:00.000Z"'==u(new c(-621987552e5))&&'"1969-12-31T23:59:59.999Z"'==u(new c(-1))}catch(e){p=!1}}n=p}if("json-parse"==e){var l=t.parse;if("function"==typeof l)try{if(0===l("0")&&!l(!1)){var f=5==(r=l(i)).a.length&&1===r.a[0];if(f){try{f=!l('"\t"')}catch(e){}if(f)try{f=1!==l("01")}catch(e){}if(f)try{f=1!==l("1.")}catch(e){}}}}catch(e){f=!1}n=f}}return o[e]=!!n}e||(e=i.Object()),t||(t=i.Object());var s=e.Number||i.Number,a=e.String||i.String,u=e.Object||i.Object,c=e.Date||i.Date,p=e.SyntaxError||i.SyntaxError,l=e.TypeError||i.TypeError,f=e.Math||i.Math,d=e.JSON||i.JSON;"object"==typeof d&&d&&(t.stringify=d.stringify,t.parse=d.parse);var h,g,v,y=u.prototype,m=y.toString,_=new c(-0xc782b5b800cec);try{_=-109252==_.getUTCFullYear()&&0===_.getUTCMonth()&&1===_.getUTCDate()&&10==_.getUTCHours()&&37==_.getUTCMinutes()&&6==_.getUTCSeconds()&&708==_.getUTCMilliseconds()}catch(e){}if(!o("json")){var b=o("bug-string-char-index");if(!_)var w=f.floor,I=[0,31,59,90,120,151,181,212,243,273,304,334],E=function(e,t){return I[t]+365*(e-1970)+w((e-1969+(t=+(t>1)))/4)-w((e-1901+t)/100)+w((e-1601+t)/400)};if((h=y.hasOwnProperty)||(h=function(e){var t,n={};return(n.__proto__=null,n.__proto__={toString:1},n).toString!=m?h=function(e){var t=this.__proto__,n=e in(this.__proto__=null,this);return this.__proto__=t,n}:(t=n.constructor,h=function(e){var n=(this.constructor||t).prototype;return e in this&&!(e in n&&this[e]===n[e])}),n=null,h.call(this,e)}),g=function(e,t){var n,o,i,s=0;(n=function(){this.valueOf=0}).prototype.valueOf=0,o=new n;for(i in o)h.call(o,i)&&s++;return n=o=null,s?g=2==s?function(e,t){var n,r={},o="[object Function]"==m.call(e);for(n in e)o&&"prototype"==n||h.call(r,n)||!(r[n]=1)||!h.call(e,n)||t(n)}:function(e,t){var n,r,o="[object Function]"==m.call(e);for(n in e)o&&"prototype"==n||!h.call(e,n)||(r="constructor"===n)||t(n);(r||h.call(e,n="constructor"))&&t(n)}:(o=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],g=function(e,t){var n,i,s="[object Function]"==m.call(e),a=!s&&"function"!=typeof e.constructor&&r[typeof e.hasOwnProperty]&&e.hasOwnProperty||h;for(n in e)s&&"prototype"==n||!a.call(e,n)||t(n);for(i=o.length;n=o[--i];a.call(e,n)&&t(n));}),g(e,t)},!o("json-stringify")){var S={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},C=function(e,t){return("000000"+(t||0)).slice(-e)},O=function(e){for(var t='"',n=0,r=e.length,o=!b||r>10,i=o&&(b?e.split(""):e);n-1/0&&a<1/0){if(E){for(f=w(a/864e5),c=w(f/365.2425)+1970-1;E(c+1,0)<=f;c++);for(p=w((f-E(c,0))/30.42);E(c,p+1)<=f;p++);f=1+f-E(c,p),y=w((d=(a%864e5+864e5)%864e5)/36e5)%24,_=w(d/6e4)%60,b=w(d/1e3)%60,I=d%1e3}else c=a.getUTCFullYear(),p=a.getUTCMonth(),f=a.getUTCDate(),y=a.getUTCHours(),_=a.getUTCMinutes(),b=a.getUTCSeconds(),I=a.getUTCMilliseconds();a=(c<=0||c>=1e4?(c<0?"-":"+")+C(6,c<0?-c:c):C(4,c))+"-"+C(2,p+1)+"-"+C(2,f)+"T"+C(2,y)+":"+C(2,_)+":"+C(2,b)+"."+C(3,I)+"Z"}else a=null;if(n&&(a=n.call(t,e,a)),null===a)return"null";if("[object Boolean]"==(u=m.call(a)))return""+a;if("[object Number]"==u)return a>-1/0&&a<1/0?""+a:"null";if("[object String]"==u)return O(""+a);if("object"==typeof a){for(j=s.length;j--;)if(s[j]===a)throw l();if(s.push(a),S=[],x=i,i+=o,"[object Array]"==u){for(T=0,j=a.length;T0)for(o="",n>10&&(n=10);o.length=48&&o<=57||o>=97&&o<=102||o>=65&&o<=70||k();e+=j("0x"+i.slice(t,A));break;default:k()}else{if(34==o)break;for(o=i.charCodeAt(A),t=A;o>=32&&92!=o&&34!=o;)o=i.charCodeAt(++A);e+=i.slice(t,A)}if(34==i.charCodeAt(A))return A++,e;k();default:if(t=A,45==o&&(r=!0,o=i.charCodeAt(++A)),o>=48&&o<=57){for(48==o&&(o=i.charCodeAt(A+1))>=48&&o<=57&&k(),r=!1;A=48&&o<=57;A++);if(46==i.charCodeAt(A)){for(n=++A;n=48&&o<=57;n++);n==A&&k(),A=n}if(101==(o=i.charCodeAt(A))||69==o){for(43!=(o=i.charCodeAt(++A))&&45!=o||A++,n=A;n=48&&o<=57;n++);n==A&&k(),A=n}return+i.slice(t,A)}if(r&&k(),"true"==i.slice(A,A+4))return A+=4,!0;if("false"==i.slice(A,A+5))return A+=5,!1;if("null"==i.slice(A,A+4))return A+=4,null;k()}return"$"},R=function(e){var t,n;if("$"==e&&k(),"string"==typeof e){if("@"==(b?e.charAt(0):e[0]))return e.slice(1);if("["==e){for(t=[];"]"!=(e=P());n||(n=!0))n&&(","==e?"]"==(e=P())&&k():k()),","==e&&k(),t.push(R(e));return t}if("{"==e){for(t={};"}"!=(e=P());n||(n=!0))n&&(","==e?"}"==(e=P())&&k():k()),","!=e&&"string"==typeof e&&"@"==(b?e.charAt(0):e[0])&&":"==P()||k(),t[e.slice(1)]=R(P());return t}k()}return e},F=function(e,t,n){var r=U(e,t,n);r===v?delete e[t]:e[t]=r},U=function(e,t,n){var r,o=e[t];if("object"==typeof o&&o)if("[object Array]"==m.call(o))for(r=o.length;r--;)F(o,r,n);else g(o,function(e){F(o,e,n)});return n.call(e,t,o)};t.parse=function(e,t){var n,r;return A=0,T=""+e,n=R(P()),"$"!=P()&&k(),A=T=null,t&&"[object Function]"==m.call(t)?U((r={},r[""]=n,r),"",t):n}}}return t.runInContext=n,t}var r={function:!0,object:!0},o=r.object&&t&&!t.nodeType&&t,i=r[typeof window]&&window||this,s=o&&r.object&&e&&!e.nodeType&&"object"==typeof v&&v;if(!s||s.global!==s&&s.window!==s&&s.self!==s||(i=s),o)n(i,o);else{var a=i.JSON,u=i.JSON3,c=!1,p=n(i,i.JSON3={noConflict:function(){return c||(c=!0,i.JSON=a,i.JSON3=u,a=u=null),p}});i.JSON={parse:p.parse,stringify:p.stringify}}}).call(v)}),{DEFAULT_INSTANCE:"$default_instance",API_VERSION:2,MAX_STRING_LENGTH:4096,MAX_PROPERTY_KEYS:1e3,IDENTIFY_EVENT:"$identify",LAST_EVENT_ID:"amplitude_lastEventId",LAST_EVENT_TIME:"amplitude_lastEventTime",LAST_IDENTIFY_ID:"amplitude_lastIdentifyId",LAST_SEQUENCE_NUMBER:"amplitude_lastSequenceNumber",SESSION_ID:"amplitude_sessionId",DEVICE_ID:"amplitude_deviceId",OPT_OUT:"amplitude_optOut",USER_ID:"amplitude_userId",COOKIE_TEST:"amplitude_cookie_test",REVENUE_EVENT:"revenue_amount",REVENUE_PRODUCT_ID:"$productId",REVENUE_QUANTITY:"$quantity",REVENUE_PRICE:"$price",REVENUE_REVENUE_TYPE:"$revenueType",AMP_DEVICE_ID_PARAM:"amp_device_id"}),m={encode:function(e){for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},decode:function(e){for(var t="",n=0,r=0,o=0,i=0;n191&&r<224?(o=e.charCodeAt(n+1),t+=String.fromCharCode((31&r)<<6|63&o),n+=2):(o=e.charCodeAt(n+1),i=e.charCodeAt(n+2),t+=String.fromCharCode((15&r)<<12|(63&o)<<6|63&i),n+=3);return t}},_={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(e)))}catch(e){}return _._encode(e)},_encode:function(e){var t,n,r,o,i,s,a,u="",c=0;for(e=m.encode(e);c>2,i=(3&t)<<4|(n=e.charCodeAt(c++))>>4,s=(15&n)<<2|(r=e.charCodeAt(c++))>>6,a=63&r,isNaN(n)?s=a=64:isNaN(r)&&(a=64),u=u+_._keyStr.charAt(o)+_._keyStr.charAt(i)+_._keyStr.charAt(s)+_._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return _._decode(e)},_decode:function(e){var t,n,r,o,i,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,n=(15&o)<<4|(i=_._keyStr.indexOf(e.charAt(u++)))>>2,r=(3&i)<<6|(s=_._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==i&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(r));return a=m.decode(a)}},b=e(function(e,t){t.parse=function(e){var t=document.createElement("a");return t.href=e,{href:t.href,host:t.host||location.host,port:"0"===t.port||""===t.port?function(e){switch(e){case"http:":return 80;case"https:":return 443;default:return location.port}}(t.protocol):t.port,hash:t.hash,hostname:t.hostname||location.hostname,pathname:"/"!=t.pathname.charAt(0)?"/"+t.pathname:t.pathname,protocol:t.protocol&&":"!=t.protocol?t.protocol:location.protocol,search:t.search,query:t.search.slice(1)}},t.isAbsolute=function(e){return 0==e.indexOf("//")||!!~e.indexOf("://")},t.isRelative=function(e){return!t.isAbsolute(e)},t.isCrossDomain=function(e){e=t.parse(e);var n=t.parse(window.location.href);return e.hostname!==n.hostname||e.port!==n.port||e.protocol!==n.protocol}}),w=1e3,I=60*w,E=60*I,S=24*E,C=365.25*S,O=function(e,n){n=n||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*C;case"days":case"day":case"d":return n*S;case"hours":case"hour":case"hrs":case"hr":case"h":return n*E;case"minutes":case"minute":case"mins":case"min":case"m":return n*I;case"seconds":case"second":case"secs":case"sec":case"s":return n*w;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===r&&!1===isNaN(e))return n.long?function(e){return t(e,S,"day")||t(e,E,"hour")||t(e,I,"minute")||t(e,w,"second")||e+" ms"}(e):function(e){return e>=S?Math.round(e/S)+"d":e>=E?Math.round(e/E)+"h":e>=I?Math.round(e/I)+"m":e>=w?Math.round(e/w)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},N=e(function(e,t){function n(e){function n(){if(n.enabled){var e=n,r=+new Date,i=r-(o||r);e.diff=i,e.prev=o,e.curr=r,o=r;for(var s=new Array(arguments.length),a=0;a=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())})("cookie"),T=function(e,t,o){switch(arguments.length){case 3:case 2:return function(e,t,n){n=n||{};var o=r(e)+"="+r(t);null==t&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(o+="; path="+n.path),n.domain&&(o+="; domain="+n.domain),n.expires&&(o+="; expires="+n.expires.toUTCString()),n.secure&&(o+="; secure"),document.cookie=o}(e,t,o);case 1:return function(e){return n()[e]}(e);default:return n()}},j=e(function(e,t){function n(e){for(var n=t.cookie,r=t.levels(e),o=0;o=0;--i)o.push(t.slice(i).join("."));return o},n.cookie=T,t=e.exports=n}),x="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},k=Object.prototype.toString,P=function(e){switch(k.call(e)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===e?"null":void 0===e?"undefined":e!=e?"nan":e&&1===e.nodeType?"element":"undefined"!=typeof Buffer&&Buffer.isBuffer(e)?"buffer":void 0===(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e))?"undefined":x(e)},R="WARN",F={DISABLE:0,ERROR:1,WARN:2,INFO:3},U={error:function(e){R>=F.ERROR&&D(e)},warn:function(e){R>=F.WARN&&D(e)},info:function(e){R>=F.INFO&&D(e)}},D=function(e){try{console.log("[Amplitude] "+e)}catch(e){}},q=function(e){return"string"===P(e)&&e.length>y.MAX_STRING_LENGTH?e.substring(0,y.MAX_STRING_LENGTH):e},M=function(e){var t=P(e);if("object"!==t)return U.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>y.MAX_PROPERTY_KEYS)return U.error("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=r,i=P(o);"string"!==i&&(o=String(o),U.warn("WARNING: Non-string property key, received type "+i+', coercing to string "'+o+'"'));var s=V(o,e[r]);null!==s&&(n[o]=s)}return n},L=["null","nan","undefined","function","arguments","regexp","element"],V=function e(t,n){var r=P(n);if(-1!==L.indexOf(r))U.warn('WARNING: Property key "'+t+'" with invalid value type '+r+", ignoring"),n=null;else if("error"===r)n=String(n),U.warn('WARNING: Property key "'+t+'" with value type error, coercing to '+n);else if("array"===r){for(var o=[],i=0;i0?(this.userPropertiesOperations.hasOwnProperty("$clearAll")||G.log.error("Need to send $clearAll on its own Identify object without any other operations, skipping $clearAll"),this):(this.userPropertiesOperations.$clearAll="-",this)},te.prototype.prepend=function(e,t){return this._addOperation("$prepend",e,t),this},te.prototype.set=function(e,t){return this._addOperation("$set",e,t),this},te.prototype.setOnce=function(e,t){return this._addOperation("$setOnce",e,t),this},te.prototype.unset=function(e){return this._addOperation("$unset",e,"-"),this},te.prototype._addOperation=function(e,t,n){this.userPropertiesOperations.hasOwnProperty("$clearAll")?G.log.error("This identify already contains a $clearAll operation, skipping operation "+e):-1===this.properties.indexOf(t)?(this.userPropertiesOperations.hasOwnProperty(e)||(this.userPropertiesOperations[e]={}),this.userPropertiesOperations[e][t]=n,this.properties.push(t)):G.log.error('User property "'+t+'" already used in this identify, skipping operation '+e)};var ne=e(function(e){!function(t){function n(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,o,i,s){return n(function(e,t){return e<>>32-t}(n(n(t,e),n(o,s)),i),r)}function o(e,t,n,o,i,s,a){return r(t&n|~t&o,e,t,i,s,a)}function i(e,t,n,o,i,s,a){return r(t&o|n&~o,e,t,i,s,a)}function s(e,t,n,o,i,s,a){return r(t^n^o,e,t,i,s,a)}function a(e,t,n,o,i,s,a){return r(n^(t|~o),e,t,i,s,a)}function u(e,t){e[t>>5]|=128<>>9<<4)]=t;var r,u,c,p,l,f=1732584193,d=-271733879,h=-1732584194,g=271733878;for(r=0;r>5]>>>t%32&255);return n}function p(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+"0123456789abcdef".charAt(15&t);return r}function f(e){return unescape(encodeURIComponent(e))}function d(e){return function(e){return c(u(p(e),8*e.length))}(f(e))}function h(e,t){return function(e,t){var n,r,o=p(e),i=[],s=[];for(i[15]=s[15]=void 0,o.length>16&&(o=u(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],s[n]=1549556828^o[n];return r=u(i.concat(p(t)),512+8*t.length),c(u(s.concat(r),640))}(f(e),f(t))}function g(e,t,n){return t?n?h(t,e):function(e,t){return l(h(e,t))}(t,e):n?d(e):function(e){return l(d(e))}(e)}e.exports?e.exports=g:t.md5=g}(v)}),re=function(){this.__data__=[],this.size=0},oe=function(e,t){return e===t||e!=e&&t!=t},ie=function(e,t){for(var n=e.length;n--;)if(oe(e[n][0],t))return n;return-1},se=Array.prototype.splice,ae=function(e){var t=this.__data__,n=ie(t,e);return!(n<0||(n==t.length-1?t.pop():se.call(t,n,1),--this.size,0))},ue=function(e){var t=this.__data__,n=ie(t,e);return n<0?void 0:t[n][1]},ce=function(e){return ie(this.__data__,e)>-1},pe=function(e,t){var n=this.__data__,r=ie(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};i.prototype.clear=re,i.prototype.delete=ae,i.prototype.get=ue,i.prototype.has=ce,i.prototype.set=pe;var le=i,fe=function(){this.__data__=new le,this.size=0},de=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},he=function(e){return this.__data__.get(e)},ge=function(e){return this.__data__.has(e)},ve="object"==typeof v&&v&&v.Object===Object&&v,ye="object"==typeof self&&self&&self.Object===Object&&self,me=ve||ye||Function("return this")(),_e=me.Symbol,be=Object.prototype,we=be.hasOwnProperty,Ie=be.toString,Ee=_e?_e.toStringTag:void 0,Se=function(e){var t=we.call(e,Ee),n=e[Ee];try{e[Ee]=void 0;var r=!0}catch(e){}var o=Ie.call(e);return r&&(t?e[Ee]=n:delete e[Ee]),o},Ce=Object.prototype.toString,Oe=function(e){return Ce.call(e)},Ne="[object Null]",Ae="[object Undefined]",Te=_e?_e.toStringTag:void 0,je=function(e){return null==e?void 0===e?Ae:Ne:Te&&Te in Object(e)?Se(e):Oe(e)},xe=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},ke="[object AsyncFunction]",Pe="[object Function]",Re="[object GeneratorFunction]",Fe="[object Proxy]",Ue=function(e){if(!xe(e))return!1;var t=je(e);return t==Pe||t==Re||t==ke||t==Fe},De=me["__core-js_shared__"],qe=function(){var e=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Me=function(e){return!!qe&&qe in e},Le=Function.prototype.toString,Ve=function(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""},ze=/^\[object .+?Constructor\]$/,Ge=Function.prototype,Be=Object.prototype,Ke=Ge.toString,Je=Be.hasOwnProperty,$e=RegExp("^"+Ke.call(Je).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),We=function(e){return!(!xe(e)||Me(e))&&(Ue(e)?$e:ze).test(Ve(e))},Ye=function(e,t){return null==e?void 0:e[t]},Qe=function(e,t){var n=Ye(e,t);return We(n)?n:void 0},Xe=Qe(me,"Map"),He=Qe(Object,"create"),Ze=function(){this.__data__=He?He(null):{},this.size=0},et=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},tt="__lodash_hash_undefined__",nt=Object.prototype.hasOwnProperty,rt=function(e){var t=this.__data__;if(He){var n=t[e];return n===tt?void 0:n}return nt.call(t,e)?t[e]:void 0},ot=Object.prototype.hasOwnProperty,it=function(e){var t=this.__data__;return He?void 0!==t[e]:ot.call(t,e)},st="__lodash_hash_undefined__",at=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=He&&void 0===t?st:t,this};s.prototype.clear=Ze,s.prototype.delete=et,s.prototype.get=rt,s.prototype.has=it,s.prototype.set=at;var ut=s,ct=function(){this.size=0,this.__data__={hash:new ut,map:new(Xe||le),string:new ut}},pt=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},lt=function(e,t){var n=e.__data__;return pt(t)?n["string"==typeof t?"string":"hash"]:n.map},ft=function(e){var t=lt(this,e).delete(e);return this.size-=t?1:0,t},dt=function(e){return lt(this,e).get(e)},ht=function(e){return lt(this,e).has(e)},gt=function(e,t){var n=lt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};a.prototype.clear=ct,a.prototype.delete=ft,a.prototype.get=dt,a.prototype.has=ht,a.prototype.set=gt;var vt=a,yt=200,mt=function(e,t){var n=this.__data__;if(n instanceof le){var r=n.__data__;if(!Xe||r.length-1&&e%1==0&&e<=Bt},Jt=function(e){return null!=e&&Kt(e.length)&&!Ue(e)},$t=function(e){return Ut(e)&&Jt(e)},Wt=function(){return!1},Yt=e(function(e,t){var n=t&&!t.nodeType&&t,r=n&&!0&&e&&!e.nodeType&&e,o=r&&r.exports===n?me.Buffer:void 0,i=(o?o.isBuffer:void 0)||Wt;e.exports=i}),Qt="[object Object]",Xt=Function.prototype,Ht=Object.prototype,Zt=Xt.toString,en=Ht.hasOwnProperty,tn=Zt.call(Object),nn=function(e){if(!Ut(e)||je(e)!=Qt)return!1;var t=kt(e);if(null===t)return!0;var n=en.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Zt.call(n)==tn},rn={};rn["[object Float32Array]"]=rn["[object Float64Array]"]=rn["[object Int8Array]"]=rn["[object Int16Array]"]=rn["[object Int32Array]"]=rn["[object Uint8Array]"]=rn["[object Uint8ClampedArray]"]=rn["[object Uint16Array]"]=rn["[object Uint32Array]"]=!0,rn["[object Arguments]"]=rn["[object Array]"]=rn["[object ArrayBuffer]"]=rn["[object Boolean]"]=rn["[object DataView]"]=rn["[object Date]"]=rn["[object Error]"]=rn["[object Function]"]=rn["[object Map]"]=rn["[object Number]"]=rn["[object Object]"]=rn["[object RegExp]"]=rn["[object Set]"]=rn["[object String]"]=rn["[object WeakMap]"]=!1;var on=function(e){return Ut(e)&&Kt(e.length)&&!!rn[je(e)]},sn=function(e){return function(t){return e(t)}},an=e(function(e,t){var n=t&&!t.nodeType&&t,r=n&&!0&&e&&!e.nodeType&&e,o=r&&r.exports===n&&ve.process,i=function(){try{return o&&o.binding&&o.binding("util")}catch(e){}}();e.exports=i}),un=an&&an.isTypedArray,cn=un?sn(un):on,pn=Object.prototype.hasOwnProperty,ln=function(e,t,n){var r=e[t];pn.call(e,t)&&oe(r,n)&&(void 0!==n||t in e)||wt(e,t,n)},fn=function(e,t,n,r){var o=!n;n||(n={});for(var i=-1,s=t.length;++i-1&&e%1==0&&e0){if(++t>=kn)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(xn),Un=function(e,t){return Fn(Tn(e,t,On),e+"")},Dn=function(e,t,n){if(!xe(n))return!1;var r=typeof t;return!!("number"==r?Jt(n)&&vn(t,n.length):"string"==r&&t in n)&&oe(n[t],e)},qn=function(e){return Un(function(t,n){var r=-1,o=n.length,i=o>1?n[o-1]:void 0,s=o>2?n[2]:void 0;for(i=e.length>3&&"function"==typeof i?(o--,i):void 0,s&&Dn(n[0],n[1],s)&&(i=o<3?void 0:i,o=1),t=Object(t);++r0?2==o.length?"function"==typeof o[1]?e[o[0]]=o[1].call(this,s):e[o[0]]=o[1]:3==o.length?"function"!=typeof o[1]||o[1].exec&&o[1].test?e[o[0]]=s?s.replace(o[1],o[2]):void 0:e[o[0]]=s?o[1].call(this,s,o[2]):void 0:4==o.length&&(e[o[0]]=s?o[3].call(this,s.replace(o[1],o[2])):void 0):e[o]=s||void 0;a+=2}return e},str:function(e,t){for(var n in t)if("object"==typeof t[n]&&t[n].length>0){for(var r=0;r>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)},$n={apiEndpoint:"api.amplitude.com",batchEvents:!1,cookieExpiration:3650,cookieName:"amplitude_id",deviceIdFromUrlParam:!1,domain:"",eventUploadPeriodMillis:3e4,eventUploadThreshold:30,forceHttps:!0,includeGclid:!1,includeReferrer:!1,includeUtm:!1,language:{language:navigator&&(navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage)||void 0}.language,logLevel:"WARN",optOut:!1,platform:"Web",savedMaxCount:1e3,saveEvents:!0,saveParamsReferrerOncePerSession:!0,sessionTimeout:18e5,trackingOptions:{city:!0,country:!0,device_model:!0,dma:!0,ip_address:!0,language:!0,os_name:!0,os_version:!0,platform:!0,region:!0,version_name:!0},unsentKey:"amplitude_unsent",unsentIdentifyKey:"amplitude_unsent_identify",uploadBatchSize:100},Wn=function(e){this._instanceName=G.isEmptyString(e)?y.DEFAULT_INSTANCE:e.toLowerCase(),this._legacyStorageSuffix=this._instanceName===y.DEFAULT_INSTANCE?"":"_"+this._instanceName,this._unsentEvents=[],this._unsentIdentifys=[],this._ua=new Kn(navigator.userAgent).getResult(),this.options=Mn({},$n),this.cookieStorage=(new ee).getStorage(),this._q=[],this._sending=!1,this._updateScheduled=!1,this._eventId=0,this._identifyId=0,this._lastEventTime=null,this._newSession=!1,this._sequenceNumber=0,this._sessionId=null,this._userAgent=navigator&&navigator.userAgent||null};Wn.prototype.Identify=te,Wn.prototype.Revenue=Bn,Wn.prototype.init=function(e,t,n,r){if("string"!==P(e)||G.isEmptyString(e))G.log.error("Invalid apiKey. Please re-initialize with a valid apiKey");else try{this.options.apiKey=e,this._storageSuffix="_"+e+this._legacyStorageSuffix,Yn(this.options,n);var o=rr(this);if(this._apiPropertiesTrackingOptions=Object.keys(o).length>0?{tracking_options:o}:{},this.cookieStorage.options({expirationDays:this.options.cookieExpiration,domain:this.options.domain}),this.options.domain=this.cookieStorage.options().domain,this._instanceName===y.DEFAULT_INSTANCE&&Qn(this),Xn(this),this.options.deviceId="object"===P(n)&&"string"===P(n.deviceId)&&!G.isEmptyString(n.deviceId)&&n.deviceId||this.options.deviceIdFromUrlParam&&this._getDeviceIdFromUrlParam(this._getUrlParams())||this.options.deviceId||Jn()+"R",this.options.userId="string"===P(t)&&!G.isEmptyString(t)&&t||"number"===P(t)&&t.toString()||this.options.userId||null,this.options.saveEvents){this._unsentEvents=this._loadSavedUnsentEvents(this.options.unsentKey),this._unsentIdentifys=this._loadSavedUnsentEvents(this.options.unsentIdentifyKey);for(var i=0;ithis.options.sessionTimeout)&&(this._newSession=!0,this._sessionId=l,this.options.saveParamsReferrerOncePerSession&&this._trackParamsAndReferrer()),this.options.saveParamsReferrerOncePerSession||this._trackParamsAndReferrer(),this._lastEventTime=l,Zn(this),this._sendEventsIfReady()}catch(e){G.log.error(e)}finally{"function"===P(r)&&r(this)}},Wn.prototype._trackParamsAndReferrer=function(){this.options.includeUtm&&this._initUtmData(),this.options.includeReferrer&&this._saveReferrer(this._getReferrer()),this.options.includeGclid&&this._saveGclid(this._getUrlParams())};var Yn=function e(t,n){if("object"===P(n)){var r=function(r){if(t.hasOwnProperty(r)){var o=n[r],i=P(t[r]);G.validateInput(o,r+" option",i)&&("boolean"===i?t[r]=!!o:"string"===i&&!G.isEmptyString(o)||"number"===i&&o>0?t[r]=o:"object"===i&&e(t[r],o))}};for(var o in n)n.hasOwnProperty(o)&&r(o)}};Wn.prototype.runQueuedFunctions=function(){for(var e=0;e=this.options.eventUploadThreshold?(this.sendEvents(e),!0):(this._updateScheduled||(this._updateScheduled=!0,setTimeout(function(){this._updateScheduled=!1,this.sendEvents()}.bind(this),this.options.eventUploadPeriodMillis)),!1):(this.sendEvents(e),!0))},Wn.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},Wn.prototype._getFromStorageLegacy=function(e,t){return e.getItem(t+this._legacyStorageSuffix)},Wn.prototype._setInStorage=function(e,t,n){e.setItem(t+this._storageSuffix,n)};var Qn=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);if("object"!==P(t)&&(t=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix),!("object"===P(t)&&t.deviceId&&t.sessionId&&t.lastEventTime))){var n=function(e){var t=Z.getItem(e);return Z.removeItem(e),t},r="string"===P(e.options.apiKey)&&"_"+e.options.apiKey.slice(0,6)||"",o=n(y.DEVICE_ID+r),i=n(y.USER_ID+r),s=n(y.OPT_OUT+r);null!==s&&void 0!==s&&(s="true"===String(s));var a=parseInt(n(y.SESSION_ID)),u=parseInt(n(y.LAST_EVENT_TIME)),c=parseInt(n(y.LAST_EVENT_ID)),p=parseInt(n(y.LAST_IDENTIFY_ID)),l=parseInt(n(y.LAST_SEQUENCE_NUMBER)),f=function(e){return"object"===P(t)&&t[e]};e.options.deviceId=f("deviceId")||o,e.options.userId=f("userId")||i,e._sessionId=f("sessionId")||a||e._sessionId,e._lastEventTime=f("lastEventTime")||u||e._lastEventTime,e._eventId=f("eventId")||c||e._eventId,e._identifyId=f("identifyId")||p||e._identifyId,e._sequenceNumber=f("sequenceNumber")||l||e._sequenceNumber,e.options.optOut=s||!1,t&&void 0!==t.optOut&&null!==t.optOut&&(e.options.optOut="true"===String(t.optOut)),Zn(e)}},Xn=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);if("object"===P(t))Hn(e,t);else{var n=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix);"object"===P(n)&&(e.cookieStorage.remove(e.options.cookieName+e._legacyStorageSuffix),Hn(e,n))}},Hn=function(e,t){t.deviceId&&(e.options.deviceId=t.deviceId),t.userId&&(e.options.userId=t.userId),null!==t.optOut&&void 0!==t.optOut&&(e.options.optOut=t.optOut),t.sessionId&&(e._sessionId=parseInt(t.sessionId)),t.lastEventTime&&(e._lastEventTime=parseInt(t.lastEventTime)),t.eventId&&(e._eventId=parseInt(t.eventId)),t.identifyId&&(e._identifyId=parseInt(t.identifyId)),t.sequenceNumber&&(e._sequenceNumber=parseInt(t.sequenceNumber))},Zn=function(e){e.cookieStorage.set(e.options.cookieName+e._storageSuffix,{deviceId:e.options.deviceId,userId:e.options.userId,optOut:e.options.optOut,sessionId:e._sessionId,lastEventTime:e._lastEventTime,eventId:e._eventId,identifyId:e._identifyId,sequenceNumber:e._sequenceNumber})};Wn.prototype._initUtmData=function(e,t){e=e||this._getUrlParams();var n=function(e,t){var n=e?"?"+e.split(".").slice(-1)[0].replace(/\|/g,"&"):"",r=function(e,t,n,r){return G.getQueryParam(e,t)||G.getQueryParam(n,r)},o=r("utm_source",t,"utmcsr",n),i=r("utm_medium",t,"utmcmd",n),s=r("utm_campaign",t,"utmccn",n),a=r("utm_term",t,"utmctr",n),u=r("utm_content",t,"utmcct",n),c={},p=function(e,t){G.isEmptyString(t)||(c[e]=t)};return p("utm_source",o),p("utm_medium",i),p("utm_campaign",s),p("utm_term",a),p("utm_content",u),c}(t=t||this.cookieStorage.get("__utmz"),e);er(this,n)};var er=function(e,t){if("object"===P(t)&&0!==Object.keys(t).length){var n=new te;for(var r in t)t.hasOwnProperty(r)&&(n.setOnce("initial_"+r,t[r]),n.set(r,t[r]));e.identify(n)}};Wn.prototype._getReferrer=function(){return document.referrer},Wn.prototype._getUrlParams=function(){return location.search},Wn.prototype._saveGclid=function(e){var t=G.getQueryParam("gclid",e);if(!G.isEmptyString(t)){er(this,{gclid:t})}},Wn.prototype._getDeviceIdFromUrlParam=function(e){return G.getQueryParam(y.AMP_DEVICE_ID_PARAM,e)},Wn.prototype._getReferringDomain=function(e){if(G.isEmptyString(e))return null;var t=e.split("/");return t.length>=3?t[2]:null},Wn.prototype._saveReferrer=function(e){if(!G.isEmptyString(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};er(this,t)}},Wn.prototype.saveEvents=function(){try{this._setInStorage(Z,this.options.unsentKey,JSON.stringify(this._unsentEvents))}catch(e){}try{this._setInStorage(Z,this.options.unsentIdentifyKey,JSON.stringify(this._unsentIdentifys))}catch(e){}},Wn.prototype.setDomain=function(e){if(G.validateInput(e,"domain","string"))try{this.cookieStorage.options({domain:e}),this.options.domain=this.cookieStorage.options().domain,Xn(this),Zn(this)}catch(e){G.log.error(e)}},Wn.prototype.setUserId=function(e){try{this.options.userId=void 0!==e&&null!==e&&""+e||null,Zn(this)}catch(e){G.log.error(e)}},Wn.prototype.setGroup=function(e,t){if(this._apiKeySet("setGroup()")&&G.validateInput(e,"groupType","string")&&!G.isEmptyString(e)){var n={};n[e]=t;var r=(new te).set(e,t);this._logEvent(y.IDENTIFY_EVENT,null,null,r.userPropertiesOperations,n,null,null)}},Wn.prototype.setOptOut=function(e){if(G.validateInput(e,"enable","boolean"))try{this.options.optOut=e,Zn(this)}catch(e){G.log.error(e)}},Wn.prototype.setSessionId=function(e){if(G.validateInput(e,"sessionId","number"))try{this._sessionId=e,Zn(this)}catch(e){G.log.error(e)}},Wn.prototype.resetSessionId=function(){this.setSessionId((new Date).getTime())},Wn.prototype.regenerateDeviceId=function(){this.setDeviceId(Jn()+"R")},Wn.prototype.setDeviceId=function(e){if(G.validateInput(e,"deviceId","string"))try{G.isEmptyString(e)||(this.options.deviceId=""+e,Zn(this))}catch(e){G.log.error(e)}},Wn.prototype.setUserProperties=function(e){if(this._apiKeySet("setUserProperties()")&&G.validateInput(e,"userProperties","object")){var t=G.truncate(G.validateProperties(e));if(0!==Object.keys(t).length){var n=new te;for(var r in t)t.hasOwnProperty(r)&&n.set(r,t[r]);this.identify(n)}}},Wn.prototype.clearUserProperties=function(){if(this._apiKeySet("clearUserProperties()")){var e=new te;e.clearAll(),this.identify(e)}};var tr=function(e,t){for(var n=0;n0)return this._logEvent(y.IDENTIFY_EVENT,null,null,e.userPropertiesOperations,null,null,t);"function"===P(t)&&t(0,"No request sent",{reason:"No user property operations"})}else G.log.error("Invalid identify input type. Expected Identify object but saw "+P(e)),"function"===P(t)&&t(0,"No request sent",{reason:"Invalid identify input type"});else"function"===P(t)&&t(0,"No request sent",{reason:"API key is not set"})},Wn.prototype.setVersionName=function(e){G.validateInput(e,"versionName","string")&&(this.options.versionName=e)},Wn.prototype._logEvent=function(e,t,n,r,o,i,s){if(Xn(this),e)if(this.options.optOut)"function"===P(s)&&s(0,"No request sent",{reason:"optOut is set to true"});else try{var a;a=e===y.IDENTIFY_EVENT?this.nextIdentifyId():this.nextEventId();var u=this.nextSequenceNumber(),c="number"===P(i)?i:(new Date).getTime();(!this._sessionId||!this._lastEventTime||c-this._lastEventTime>this.options.sessionTimeout)&&(this._sessionId=c),this._lastEventTime=c,Zn(this),r=r||{};var p=Mn({},this._apiPropertiesTrackingOptions);n=Mn(p,n||{}),t=t||{},o=o||{};var l={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:c,event_id:a,session_id:this._sessionId||-1,event_type:e,version_name:nr(this,"version_name")?this.options.versionName||null:null,platform:nr(this,"platform")?this.options.platform:null,os_name:nr(this,"os_name")?this._ua.browser.name||null:null,os_version:nr(this,"os_version")?this._ua.browser.major||null:null,device_model:nr(this,"device_model")?this._ua.os.name||null:null,language:nr(this,"language")?this.options.language:null,api_properties:n,event_properties:G.truncate(G.validateProperties(t)),user_properties:G.truncate(G.validateProperties(r)),uuid:Jn(),library:{name:"amplitude-js",version:"4.4.0"},sequence_number:u,groups:G.truncate(G.validateGroups(o)),user_agent:this._userAgent};return e===y.IDENTIFY_EVENT?(this._unsentIdentifys.push(l),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push(l),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(s)||"function"!==P(s)||s(0,"No request sent",{reason:"No events to send or upload queued"}),a}catch(e){G.log.error(e)}else"function"===P(s)&&s(0,"No request sent",{reason:"Missing eventType"})};var nr=function(e,t){return!!e.options.trackingOptions[t]},rr=function(e){for(var t=["city","country","dma","ip_address","region"],n={},r=0;rthis.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount)},Wn.prototype.logEvent=function(e,t,n){return this.logEventWithTimestamp(e,t,null,n)},Wn.prototype.logEventWithTimestamp=function(e,t,n,r){return this._apiKeySet("logEvent()")?G.validateInput(e,"eventType","string")?G.isEmptyString(e)?("function"===P(r)&&r(0,"No request sent",{reason:"Missing eventType"}),-1):this._logEvent(e,t,null,null,null,n,r):("function"===P(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===P(r)&&r(0,"No request sent",{reason:"API key not set"}),-1)},Wn.prototype.logEventWithGroups=function(e,t,n,r){return this._apiKeySet("logEventWithGroups()")?G.validateInput(e,"eventType","string")?this._logEvent(e,t,null,null,n,null,r):("function"===P(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===P(r)&&r(0,"No request sent",{reason:"API key not set"}),-1)};var or=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};Wn.prototype.logRevenueV2=function(e){if(this._apiKeySet("logRevenueV2()"))if("object"===P(e)&&e.hasOwnProperty("_q")&&(e=tr(new Bn,e)),e instanceof Bn){if(e&&e._isValidRevenue())return this.logEvent(y.REVENUE_EVENT,e._toJSONObject())}else G.log.error("Invalid revenue input type. Expected Revenue object but saw "+P(e))},Wn.prototype.logRevenue=function(e,t,n){return this._apiKeySet("logRevenue()")&&or(e)&&(void 0===t||or(t))?this._logEvent(y.REVENUE_EVENT,{},{productId:n,special:"revenue_amount",quantity:t||1,price:e},null,null,null,null):-1},Wn.prototype.removeEvents=function(e,t){ir(this,"_unsentEvents",e),ir(this,"_unsentIdentifys",t)};var ir=function(e,t,n){if(!(n<0)){for(var r=[],o=0;on&&r.push(e[t][o]);e[t]=r}};Wn.prototype.sendEvents=function(e){if(this._apiKeySet("sendEvents()"))if(this.options.optOut)"function"===P(e)&&e(0,"No request sent",{reason:"optOut is set to true"});else if(0!==this._unsentCount())if(this._sending)"function"===P(e)&&e(0,"No request sent",{reason:"Request already in progress"});else{this._sending=!0;var t=(this.options.forceHttps?"https":"https:"===window.location.protocol?"https":"http")+"://"+this.options.apiEndpoint+"/",n=Math.min(this._unsentCount(),this.options.uploadBatchSize),r=this._mergeEventsAndIdentifys(n),o=r.maxEventId,i=r.maxIdentifyId,s=JSON.stringify(r.eventsToSend),a=(new Date).getTime(),u={client:this.options.apiKey,e:s,v:y.API_VERSION,upload_time:a,checksum:ne(y.API_VERSION+this.options.apiKey+s+a)},c=this;new Gn(t,u).send(function(t,r){c._sending=!1;try{200===t&&"success"===r?(c.removeEvents(o,i),c.options.saveEvents&&c.saveEvents(),c._sendEventsIfReady(e)||"function"!==P(e)||e(t,r)):413===t?(1===c.options.uploadBatchSize&&c.removeEvents(o,i),c.options.uploadBatchSize=Math.ceil(n/2),c.sendEvents(e)):"function"===P(e)&&e(t,r)}catch(e){}})}else"function"===P(e)&&e(0,"No request sent",{reason:"No events to send"});else"function"===P(e)&&e(0,"No request sent",{reason:"API key not set"})},Wn.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],n=0,r=-1,o=0,i=-1;t.length=this._unsentIdentifys.length,u=n>=this._unsentEvents.length;if(u&&a){G.log.error("Merging Events and Identifys, less events and identifys than expected");break}a?r=(s=this._unsentEvents[n++]).event_id:u?i=(s=this._unsentIdentifys[o++]).event_id:!("sequence_number"in this._unsentEvents[n])||this._unsentEvents[n].sequence_number", - "version": "4.3.0", + "version": "4.4.0", "license": "MIT", "description": "Javascript library for Amplitude Analytics", "keywords": [ diff --git a/src/amplitude-snippet.js b/src/amplitude-snippet.js index 6288906c..e67dd8e3 100644 --- a/src/amplitude-snippet.js +++ b/src/amplitude-snippet.js @@ -3,7 +3,7 @@ var as = document.createElement('script'); as.type = 'text/javascript'; as.async = true; - as.src = 'https://cdn.amplitude.com/libs/amplitude-4.3.0-min.gz.js'; + as.src = 'https://cdn.amplitude.com/libs/amplitude-4.4.0-min.gz.js'; as.onload = function() {if(window.amplitude.runQueuedFunctions) {window.amplitude.runQueuedFunctions();} else {console.log('[Amplitude] Error: could not load SDK');}}; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(as, s); diff --git a/src/version.js b/src/version.js index 0601e528..577799bc 100644 --- a/src/version.js +++ b/src/version.js @@ -1 +1 @@ -export default '4.3.0'; +export default '4.4.0';