diff --git a/amplitude.js b/amplitude.js index 67780625..61185930 100644 --- a/amplitude.js +++ b/amplitude.js @@ -2062,7 +2062,9 @@ var logLevels = { var logLevel = logLevels.WARN; var setLogLevel = function setLogLevel(logLevelName) { - logLevel = logLevels[logLevelName] || logLevel; + if (logLevels.hasOwnProperty(logLevelName)) { + logLevel = logLevels[logLevelName]; + } }; var getLogLevel = function getLogLevel() { @@ -2284,6 +2286,7 @@ var getQueryParam = function getQueryParam(name, query) { var utils = { setLogLevel: setLogLevel, getLogLevel: getLogLevel, + logLevels: logLevels, log: log, isEmptyString: isEmptyString, getQueryParam: getQueryParam, diff --git a/amplitude.min.js b/amplitude.min.js index 84526567..0c276b88 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&&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&&m;if(p){(r=function(){return 1}).toJSON=r;try{p="0"===u(0)&&"0"===u(new s)&&'""'==u(new a)&&u(_)===v&&u(v)===v&&u()===v&&"1"===u(r)&&"[1]"==u([r])&&"[null]"==u([v])&&"null"==u(null)&&"[null,null,null]"==u([v,_,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,_=y.toString,m=new c(-0xc782b5b800cec);try{m=-109252==m.getUTCFullYear()&&0===m.getUTCMonth()&&1===m.getUTCDate()&&10==m.getUTCHours()&&37==m.getUTCMinutes()&&6==m.getUTCSeconds()&&708==m.getUTCMilliseconds()}catch(e){}if(!o("json")){var b=o("bug-string-char-index");if(!m)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!=_?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]"==_.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]"==_.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]"==_.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,m=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(),m=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,m)+":"+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=_.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(A=0,j=a.length;A0)for(o="",n>10&&(n=10);o.length=48&&o<=57||o>=97&&o<=102||o>=65&&o<=70||P();e+=j("0x"+i.slice(t,T));break;default:P()}else{if(34==o)break;for(o=i.charCodeAt(T),t=T;o>=32&&92!=o&&34!=o;)o=i.charCodeAt(++T);e+=i.slice(t,T)}if(34==i.charCodeAt(T))return T++,e;P();default:if(t=T,45==o&&(r=!0,o=i.charCodeAt(++T)),o>=48&&o<=57){for(48==o&&(o=i.charCodeAt(T+1))>=48&&o<=57&&P(),r=!1;T=48&&o<=57;T++);if(46==i.charCodeAt(T)){for(n=++T;n=48&&o<=57;n++);n==T&&P(),T=n}if(101==(o=i.charCodeAt(T))||69==o){for(43!=(o=i.charCodeAt(++T))&&45!=o||T++,n=T;n=48&&o<=57;n++);n==T&&P(),T=n}return+i.slice(t,T)}if(r&&P(),"true"==i.slice(T,T+4))return T+=4,!0;if("false"==i.slice(T,T+5))return T+=5,!1;if("null"==i.slice(T,T+4))return T+=4,null;P()}return"$"},R=function(e){var t,n;if("$"==e&&P(),"string"==typeof e){if("@"==(b?e.charAt(0):e[0]))return e.slice(1);if("["==e){for(t=[];"]"!=(e=U());n||(n=!0))n&&(","==e?"]"==(e=U())&&P():P()),","==e&&P(),t.push(R(e));return t}if("{"==e){for(t={};"}"!=(e=U());n||(n=!0))n&&(","==e?"}"==(e=U())&&P():P()),","!=e&&"string"==typeof e&&"@"==(b?e.charAt(0):e[0])&&":"==U()||P(),t[e.slice(1)]=R(U());return t}P()}return e},k=function(e,t,n){var r=F(e,t,n);r===v?delete e[t]:e[t]=r},F=function(e,t,n){var r,o=e[t];if("object"==typeof o&&o)if("[object Array]"==_.call(o))for(r=o.length;r--;)k(o,r,n);else g(o,function(e){k(o,e,n)});return n.call(e,t,o)};t.parse=function(e,t){var n,r;return T=0,A=""+e,n=R(U()),"$"!=U()&&P(),T=A=null,t&&"[object Function]"==_.call(t)?F((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",GROUP_IDENTIFY_EVENT:"$groupidentify",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",REFERRER:"referrer",UTM_SOURCE:"utm_source",UTM_MEDIUM:"utm_medium",UTM_CAMPAIGN:"utm_campaign",UTM_TERM:"utm_term",UTM_CONTENT:"utm_content"}),_={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}},m={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(e)))}catch(e){}return m._encode(e)},_encode:function(e){var t,n,r,o,i,s,a,u="",c=0;for(e=_.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+m._keyStr.charAt(o)+m._keyStr.charAt(i)+m._keyStr.charAt(s)+m._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return m._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=m._keyStr.indexOf(e.charAt(u++)))>>2,r=(3&i)<<6|(s=m._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==i&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(r));return a=_.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"),A=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=A,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},P=Object.prototype.toString,U=function(e){switch(P.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&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)?"buffer":void 0===(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e))?"undefined":x(e)},R={DISABLE:0,ERROR:1,WARN:2,INFO:3},k=R.WARN,F={error:function(e){k>=R.ERROR&&M(e)},warn:function(e){k>=R.WARN&&M(e)},info:function(e){k>=R.INFO&&M(e)}},M=function(e){try{console.log("[Amplitude] "+e)}catch(e){}},D=function(e){return"string"===U(e)&&e.length>y.MAX_STRING_LENGTH?e.substring(0,y.MAX_STRING_LENGTH):e},q=function(e){var t=U(e);if("object"!==t)return F.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>y.MAX_PROPERTY_KEYS)return F.error("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=r,i=U(o);"string"!==i&&(o=String(o),F.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=U(n);if(-1!==L.indexOf(r))F.warn('WARNING: Property key "'+t+'" with invalid value type '+r+", ignoring"),n=null;else if("error"===r)n=String(n),F.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,_e=ve||ye||Function("return this")(),me=_e.Symbol,be=Object.prototype,we=be.hasOwnProperty,Ie=be.toString,Ee=me?me.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]",Te="[object Undefined]",Ae=me?me.toStringTag:void 0,je=function(e){return null==e?void 0===e?Te:Ne:Ae&&Ae in Object(e)?Se(e):Oe(e)},xe=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},Pe="[object AsyncFunction]",Ue="[object Function]",Re="[object GeneratorFunction]",ke="[object Proxy]",Fe=function(e){if(!xe(e))return!1;var t=je(e);return t==Ue||t==Re||t==Pe||t==ke},Me=_e["__core-js_shared__"],De=function(){var e=/[^.]+$/.exec(Me&&Me.keys&&Me.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),qe=function(e){return!!De&&De 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,$e=Be.hasOwnProperty,Je=RegExp("^"+Ke.call($e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),We=function(e){return!(!xe(e)||qe(e))&&(Fe(e)?Je: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(_e,"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,_t=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},$t=function(e){return null!=e&&Kt(e.length)&&!Fe(e)},Jt=function(e){return Ft(e)&&$t(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?_e.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(!Ft(e)||je(e)!=Qt)return!1;var t=Pt(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 Ft(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>=Pn)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(xn),Fn=function(e,t){return kn(An(e,t,On),e+"")},Mn=function(e,t,n){if(!xe(n))return!1;var r=typeof t;return!!("number"==r?$t(n)&&vn(t,n.length):"string"==r&&t in n)&&oe(n[t],e)},Dn=function(e){return Fn(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&&Mn(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)},Jn={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},unsetParamsReferrerOnNewSession:!1,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=qn({},Jn),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"!==U(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),"string"===U(this.options.logLevel)&&G.setLogLevel(this.options.logLevel);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"===U(n)&&"string"===U(n.deviceId)&&!G.isEmptyString(n.deviceId)&&n.deviceId||this.options.deviceIdFromUrlParam&&this._getDeviceIdFromUrlParam(this._getUrlParams())||this.options.deviceId||$n()+"R",this.options.userId="string"===U(t)&&!G.isEmptyString(t)&&t||"number"===U(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.options.unsetParamsReferrerOnNewSession&&this._unsetUTMParams(),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"===U(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"===U(n)){var r=function(r){if(t.hasOwnProperty(r)){var o=n[r],i=U(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"!==U(t)&&(t=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix),!("object"===U(t)&&t.deviceId&&t.sessionId&&t.lastEventTime))){var n=function(e){var t=Z.getItem(e);return Z.removeItem(e),t},r="string"===U(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"===U(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"===U(t))Hn(e,t);else{var n=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix);"object"===U(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(y.UTM_SOURCE,t,"utmcsr",n),i=r(y.UTM_MEDIUM,t,"utmcmd",n),s=r(y.UTM_CAMPAIGN,t,"utmccn",n),a=r(y.UTM_TERM,t,"utmctr",n),u=r(y.UTM_CONTENT,t,"utmcct",n),c={},p=function(e,t){G.isEmptyString(t)||(c[e]=t)};return p(y.UTM_SOURCE,o),p(y.UTM_MEDIUM,i),p(y.UTM_CAMPAIGN,s),p(y.UTM_TERM,a),p(y.UTM_CONTENT,u),c}(t=t||this.cookieStorage.get("__utmz"),e);er(this,n)},Wn.prototype._unsetUTMParams=function(){var e=new te;e.unset(y.REFERRER),e.unset(y.UTM_SOURCE),e.unset(y.UTM_MEDIUM),e.unset(y.UTM_CAMPAIGN),e.unset(y.UTM_TERM),e.unset(y.UTM_CONTENT),this.identify(e)};var er=function(e,t){if("object"===U(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,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($n()+"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,null,t);"function"===U(t)&&t(0,"No request sent",{reason:"No user property operations"})}else G.log.error("Invalid identify input type. Expected Identify object but saw "+U(e)),"function"===U(t)&&t(0,"No request sent",{reason:"Invalid identify input type"});else"function"===U(t)&&t(0,"No request sent",{reason:"API key is not set"})},Wn.prototype.groupIdentify=function(e,t,n,r){if(this._apiKeySet("groupIdentify()"))if(G.validateInput(e,"group_type","string")&&!G.isEmptyString(e))if(null!==t&&void 0!==t)if("object"===U(n)&&n.hasOwnProperty("_q")&&(n=tr(new te,n)),n instanceof te){if(Object.keys(n.userPropertiesOperations).length>0)return this._logEvent(y.GROUP_IDENTIFY_EVENT,null,null,null,function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e,t),n.userPropertiesOperations,null,r);"function"===U(r)&&r(0,"No request sent",{reason:"No group property operations"})}else G.log.error("Invalid identify input type. Expected Identify object but saw "+U(n)),"function"===U(r)&&r(0,"No request sent",{reason:"Invalid identify input type"});else"function"===U(r)&&r(0,"No request sent",{reason:"Invalid group name"});else"function"===U(r)&&r(0,"No request sent",{reason:"Invalid group type"});else"function"===U(r)&&r(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,a){if(Xn(this),e)if(this.options.optOut)"function"===U(a)&&a(0,"No request sent",{reason:"optOut is set to true"});else try{var u;u=e===y.IDENTIFY_EVENT||e===y.GROUP_IDENTIFY_EVENT?this.nextIdentifyId():this.nextEventId();var c=this.nextSequenceNumber(),p="number"===U(s)?s:(new Date).getTime();(!this._sessionId||!this._lastEventTime||p-this._lastEventTime>this.options.sessionTimeout)&&(this._sessionId=p),this._lastEventTime=p,Zn(this),r=r||{};var l=qn({},this._apiPropertiesTrackingOptions);n=qn(l,n||{}),t=t||{},o=o||{},i=i||{};var f={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:p,event_id:u,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:$n(),library:{name:"amplitude-js",version:"4.5.2"},sequence_number:c,groups:G.truncate(G.validateGroups(o)),group_properties:G.truncate(G.validateProperties(i)),user_agent:this._userAgent};return e===y.IDENTIFY_EVENT||e===y.GROUP_IDENTIFY_EVENT?(this._unsentIdentifys.push(f),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push(f),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(a)||"function"!==U(a)||a(0,"No request sent",{reason:"No events to send or upload queued"}),u}catch(e){G.log.error(e)}else"function"===U(a)&&a(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"===U(r)&&r(0,"No request sent",{reason:"Missing eventType"}),-1):this._logEvent(e,t,null,null,null,null,n,r):("function"===U(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===U(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,null,r):("function"===U(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===U(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"===U(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 "+U(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,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"===U(e)&&e(0,"No request sent",{reason:"optOut is set to true"});else if(0!==this._unsentCount())if(this._sending)"function"===U(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"!==U(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"===U(e)&&e(t,r)}catch(e){}})}else"function"===U(e)&&e(0,"No request sent",{reason:"No events to send"});else"function"===U(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_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&&m;if(p){(r=function(){return 1}).toJSON=r;try{p="0"===u(0)&&"0"===u(new s)&&'""'==u(new a)&&u(_)===v&&u(v)===v&&u()===v&&"1"===u(r)&&"[1]"==u([r])&&"[null]"==u([v])&&"null"==u(null)&&"[null,null,null]"==u([v,_,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,_=y.toString,m=new c(-0xc782b5b800cec);try{m=-109252==m.getUTCFullYear()&&0===m.getUTCMonth()&&1===m.getUTCDate()&&10==m.getUTCHours()&&37==m.getUTCMinutes()&&6==m.getUTCSeconds()&&708==m.getUTCMilliseconds()}catch(e){}if(!o("json")){var b=o("bug-string-char-index");if(!m)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!=_?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]"==_.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]"==_.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]"==_.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,m=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(),m=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,m)+":"+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=_.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(A=0,j=a.length;A0)for(o="",n>10&&(n=10);o.length=48&&o<=57||o>=97&&o<=102||o>=65&&o<=70||P();e+=j("0x"+i.slice(t,T));break;default:P()}else{if(34==o)break;for(o=i.charCodeAt(T),t=T;o>=32&&92!=o&&34!=o;)o=i.charCodeAt(++T);e+=i.slice(t,T)}if(34==i.charCodeAt(T))return T++,e;P();default:if(t=T,45==o&&(r=!0,o=i.charCodeAt(++T)),o>=48&&o<=57){for(48==o&&(o=i.charCodeAt(T+1))>=48&&o<=57&&P(),r=!1;T=48&&o<=57;T++);if(46==i.charCodeAt(T)){for(n=++T;n=48&&o<=57;n++);n==T&&P(),T=n}if(101==(o=i.charCodeAt(T))||69==o){for(43!=(o=i.charCodeAt(++T))&&45!=o||T++,n=T;n=48&&o<=57;n++);n==T&&P(),T=n}return+i.slice(t,T)}if(r&&P(),"true"==i.slice(T,T+4))return T+=4,!0;if("false"==i.slice(T,T+5))return T+=5,!1;if("null"==i.slice(T,T+4))return T+=4,null;P()}return"$"},R=function(e){var t,n;if("$"==e&&P(),"string"==typeof e){if("@"==(b?e.charAt(0):e[0]))return e.slice(1);if("["==e){for(t=[];"]"!=(e=U());n||(n=!0))n&&(","==e?"]"==(e=U())&&P():P()),","==e&&P(),t.push(R(e));return t}if("{"==e){for(t={};"}"!=(e=U());n||(n=!0))n&&(","==e?"}"==(e=U())&&P():P()),","!=e&&"string"==typeof e&&"@"==(b?e.charAt(0):e[0])&&":"==U()||P(),t[e.slice(1)]=R(U());return t}P()}return e},k=function(e,t,n){var r=F(e,t,n);r===v?delete e[t]:e[t]=r},F=function(e,t,n){var r,o=e[t];if("object"==typeof o&&o)if("[object Array]"==_.call(o))for(r=o.length;r--;)k(o,r,n);else g(o,function(e){k(o,e,n)});return n.call(e,t,o)};t.parse=function(e,t){var n,r;return T=0,A=""+e,n=R(U()),"$"!=U()&&P(),T=A=null,t&&"[object Function]"==_.call(t)?F((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",GROUP_IDENTIFY_EVENT:"$groupidentify",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",REFERRER:"referrer",UTM_SOURCE:"utm_source",UTM_MEDIUM:"utm_medium",UTM_CAMPAIGN:"utm_campaign",UTM_TERM:"utm_term",UTM_CONTENT:"utm_content"}),_={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}},m={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(e)))}catch(e){}return m._encode(e)},_encode:function(e){var t,n,r,o,i,s,a,u="",c=0;for(e=_.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+m._keyStr.charAt(o)+m._keyStr.charAt(i)+m._keyStr.charAt(s)+m._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return m._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=m._keyStr.indexOf(e.charAt(u++)))>>2,r=(3&i)<<6|(s=m._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==i&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(r));return a=_.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"),A=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=A,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},P=Object.prototype.toString,U=function(e){switch(P.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&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)?"buffer":void 0===(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e))?"undefined":x(e)},R={DISABLE:0,ERROR:1,WARN:2,INFO:3},k=R.WARN,F={error:function(e){k>=R.ERROR&&M(e)},warn:function(e){k>=R.WARN&&M(e)},info:function(e){k>=R.INFO&&M(e)}},M=function(e){try{console.log("[Amplitude] "+e)}catch(e){}},D=function(e){return"string"===U(e)&&e.length>y.MAX_STRING_LENGTH?e.substring(0,y.MAX_STRING_LENGTH):e},q=function(e){var t=U(e);if("object"!==t)return F.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>y.MAX_PROPERTY_KEYS)return F.error("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=r,i=U(o);"string"!==i&&(o=String(o),F.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=U(n);if(-1!==L.indexOf(r))F.warn('WARNING: Property key "'+t+'" with invalid value type '+r+", ignoring"),n=null;else if("error"===r)n=String(n),F.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,_e=ve||ye||Function("return this")(),me=_e.Symbol,be=Object.prototype,we=be.hasOwnProperty,Ie=be.toString,Ee=me?me.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]",Te="[object Undefined]",Ae=me?me.toStringTag:void 0,je=function(e){return null==e?void 0===e?Te:Ne:Ae&&Ae in Object(e)?Se(e):Oe(e)},xe=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},Pe="[object AsyncFunction]",Ue="[object Function]",Re="[object GeneratorFunction]",ke="[object Proxy]",Fe=function(e){if(!xe(e))return!1;var t=je(e);return t==Ue||t==Re||t==Pe||t==ke},Me=_e["__core-js_shared__"],De=function(){var e=/[^.]+$/.exec(Me&&Me.keys&&Me.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),qe=function(e){return!!De&&De 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,$e=Be.hasOwnProperty,Je=RegExp("^"+Ke.call($e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),We=function(e){return!(!xe(e)||qe(e))&&(Fe(e)?Je: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(_e,"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,_t=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},$t=function(e){return null!=e&&Kt(e.length)&&!Fe(e)},Jt=function(e){return Ft(e)&&$t(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?_e.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(!Ft(e)||je(e)!=Qt)return!1;var t=Pt(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 Ft(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>=Pn)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(xn),Fn=function(e,t){return kn(An(e,t,On),e+"")},Mn=function(e,t,n){if(!xe(n))return!1;var r=typeof t;return!!("number"==r?$t(n)&&vn(t,n.length):"string"==r&&t in n)&&oe(n[t],e)},Dn=function(e){return Fn(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&&Mn(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)},Jn={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},unsetParamsReferrerOnNewSession:!1,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=qn({},Jn),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"!==U(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),"string"===U(this.options.logLevel)&&G.setLogLevel(this.options.logLevel);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"===U(n)&&"string"===U(n.deviceId)&&!G.isEmptyString(n.deviceId)&&n.deviceId||this.options.deviceIdFromUrlParam&&this._getDeviceIdFromUrlParam(this._getUrlParams())||this.options.deviceId||$n()+"R",this.options.userId="string"===U(t)&&!G.isEmptyString(t)&&t||"number"===U(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.options.unsetParamsReferrerOnNewSession&&this._unsetUTMParams(),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"===U(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"===U(n)){var r=function(r){if(t.hasOwnProperty(r)){var o=n[r],i=U(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"!==U(t)&&(t=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix),!("object"===U(t)&&t.deviceId&&t.sessionId&&t.lastEventTime))){var n=function(e){var t=Z.getItem(e);return Z.removeItem(e),t},r="string"===U(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"===U(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"===U(t))Hn(e,t);else{var n=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix);"object"===U(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(y.UTM_SOURCE,t,"utmcsr",n),i=r(y.UTM_MEDIUM,t,"utmcmd",n),s=r(y.UTM_CAMPAIGN,t,"utmccn",n),a=r(y.UTM_TERM,t,"utmctr",n),u=r(y.UTM_CONTENT,t,"utmcct",n),c={},p=function(e,t){G.isEmptyString(t)||(c[e]=t)};return p(y.UTM_SOURCE,o),p(y.UTM_MEDIUM,i),p(y.UTM_CAMPAIGN,s),p(y.UTM_TERM,a),p(y.UTM_CONTENT,u),c}(t=t||this.cookieStorage.get("__utmz"),e);er(this,n)},Wn.prototype._unsetUTMParams=function(){var e=new te;e.unset(y.REFERRER),e.unset(y.UTM_SOURCE),e.unset(y.UTM_MEDIUM),e.unset(y.UTM_CAMPAIGN),e.unset(y.UTM_TERM),e.unset(y.UTM_CONTENT),this.identify(e)};var er=function(e,t){if("object"===U(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,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($n()+"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,null,t);"function"===U(t)&&t(0,"No request sent",{reason:"No user property operations"})}else G.log.error("Invalid identify input type. Expected Identify object but saw "+U(e)),"function"===U(t)&&t(0,"No request sent",{reason:"Invalid identify input type"});else"function"===U(t)&&t(0,"No request sent",{reason:"API key is not set"})},Wn.prototype.groupIdentify=function(e,t,n,r){if(this._apiKeySet("groupIdentify()"))if(G.validateInput(e,"group_type","string")&&!G.isEmptyString(e))if(null!==t&&void 0!==t)if("object"===U(n)&&n.hasOwnProperty("_q")&&(n=tr(new te,n)),n instanceof te){if(Object.keys(n.userPropertiesOperations).length>0)return this._logEvent(y.GROUP_IDENTIFY_EVENT,null,null,null,function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e,t),n.userPropertiesOperations,null,r);"function"===U(r)&&r(0,"No request sent",{reason:"No group property operations"})}else G.log.error("Invalid identify input type. Expected Identify object but saw "+U(n)),"function"===U(r)&&r(0,"No request sent",{reason:"Invalid identify input type"});else"function"===U(r)&&r(0,"No request sent",{reason:"Invalid group name"});else"function"===U(r)&&r(0,"No request sent",{reason:"Invalid group type"});else"function"===U(r)&&r(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,a){if(Xn(this),e)if(this.options.optOut)"function"===U(a)&&a(0,"No request sent",{reason:"optOut is set to true"});else try{var u;u=e===y.IDENTIFY_EVENT||e===y.GROUP_IDENTIFY_EVENT?this.nextIdentifyId():this.nextEventId();var c=this.nextSequenceNumber(),p="number"===U(s)?s:(new Date).getTime();(!this._sessionId||!this._lastEventTime||p-this._lastEventTime>this.options.sessionTimeout)&&(this._sessionId=p),this._lastEventTime=p,Zn(this),r=r||{};var l=qn({},this._apiPropertiesTrackingOptions);n=qn(l,n||{}),t=t||{},o=o||{},i=i||{};var f={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:p,event_id:u,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:$n(),library:{name:"amplitude-js",version:"4.5.2"},sequence_number:c,groups:G.truncate(G.validateGroups(o)),group_properties:G.truncate(G.validateProperties(i)),user_agent:this._userAgent};return e===y.IDENTIFY_EVENT||e===y.GROUP_IDENTIFY_EVENT?(this._unsentIdentifys.push(f),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push(f),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(a)||"function"!==U(a)||a(0,"No request sent",{reason:"No events to send or upload queued"}),u}catch(e){G.log.error(e)}else"function"===U(a)&&a(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"===U(r)&&r(0,"No request sent",{reason:"Missing eventType"}),-1):this._logEvent(e,t,null,null,null,null,n,r):("function"===U(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===U(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,null,r):("function"===U(r)&&r(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===U(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"===U(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 "+U(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,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"===U(e)&&e(0,"No request sent",{reason:"optOut is set to true"});else if(0!==this._unsentCount())if(this._sending)"function"===U(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"!==U(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"===U(e)&&e(t,r)}catch(e){}})}else"function"===U(e)&&e(0,"No request sent",{reason:"No events to send"});else"function"===U(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 { + utils.setLogLevel('WARN'); + }); + + it('can set log level to DISABLE', function() { + utils.setLogLevel('DISABLE'); + assert.strictEqual(utils.getLogLevel(), utils.logLevels.DISABLE); + }); + + it('can set log level to ERROR', () => { + utils.setLogLevel('ERROR'); + assert.strictEqual(utils.getLogLevel(), utils.logLevels.ERROR); + }); + + it('can set log level to WARN', () => { + utils.setLogLevel('DISABLE'); + utils.setLogLevel('WARN'); + assert.strictEqual(utils.getLogLevel(), utils.logLevels.WARN); + }); + + it('can set log level to INFO', () => { + utils.setLogLevel('INFO'); + assert.strictEqual(utils.getLogLevel(), utils.logLevels.INFO); + }); + }); + describe('log', function() { beforeEach(function() { utils.setLogLevel('INFO');