diff --git a/CHANGELOG.md b/CHANGELOG.md index f40dc51b..87ec86cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Unreleased +### 3.7.0 (September 14, 2017) + * Add `setSessionId(sesionId)` method. Note this is not recommended unless you know what are you doing. * Added support for Bower. Install using `bower install amplitude-js`. * Switched from webpack to Rollup for building the SDK. diff --git a/README.md b/README.md index 57373a48..5f4f9a6f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A JavaScript SDK for tracking events and revenue to [Amplitude](https://www.ampl Please see our [installation guide](https://amplitude.zendesk.com/hc/en-us/articles/115001361248-JavaScript-SDK-Installation) for instructions on installing and using our JavaScript SDK. # Latest Version # -[3.6.0 - Released on September 13, 2017](https://github.com/amplitude/Amplitude-JavaScript/releases/latest) +[3.7.0 - Released on September 14, 2017](https://github.com/amplitude/Amplitude-JavaScript/releases/latest) [![Circle CI](https://circleci.com/gh/amplitude/Amplitude-JavaScript.svg?style=badge&circle-token=80de0dbb7632b2db13f76ccb20a79bbdfc50c215)](https://circleci.com/gh/amplitude/Amplitude-JavaScript) # JavaScript SDK Reference # diff --git a/amplitude-snippet.min.js b/amplitude-snippet.min.js index 138b1e10..b42c0bd3 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://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.6.0-min.gz.js" +;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.7.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 4d9bfa5a..5b889bea 100644 --- a/amplitude.js +++ b/amplitude.js @@ -5588,7 +5588,7 @@ var uuid$1 = function uuid(a) { ); }; -var version = '3.6.0'; +var version = '3.7.0'; var getLanguage = function getLanguage() { return navigator && (navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage) || undefined; diff --git a/amplitude.min.js b/amplitude.min.js index d0846f68..07b621db 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){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*O;case"days":case"day":case"d":return n*C;case"hours":case"hour":case"hrs":case"hr":case"h":return n*S;case"minutes":case"minute":case"mins":case"min":case"m":return n*E;case"seconds":case"second":case"secs":case"sec":case"s":return n*I;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function n(e){return e>=C?Math.round(e/C)+"d":e>=S?Math.round(e/S)+"h":e>=E?Math.round(e/E)+"m":e>=I?Math.round(e/I)+"s":e+"ms"}function r(e){return i(e,C,"day")||i(e,S,"hour")||i(e,E,"minute")||i(e,I,"second")||e+" ms"}function i(e,t,n){if(!(e0&&a>s&&(a=s);for(var u=0;u=0?(c=h.substr(0,g),p=h.substr(g+1)):(c=h,p=""),d=decodeURIComponent(c),f=decodeURIComponent(p),l(i,d)?Ut(i[d])?i[d].push(f):i[d]=[i[d],f]:i[d]=f}return i}var v,y="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},m=(e(function(e,t){(function(){function n(e,t){function i(e){if(i[e]!==v)return i[e];var n;if("bug-string-char-index"==e)n="a"!="a"[0];else if("json"==e)n=i("json-stringify")&&i("json-parse");else{var r,o='{"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"]})==o&&"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 d=5==(r=l(o)).a.length&&1===r.a[0];if(d){try{d=!l('"\t"')}catch(e){}if(d)try{d=1!==l("01")}catch(e){}if(d)try{d=1!==l("1.")}catch(e){}}}}catch(e){d=!1}n=d}}return i[e]=!!n}e||(e=o.Object()),t||(t=o.Object());var s=e.Number||o.Number,a=e.String||o.String,u=e.Object||o.Object,c=e.Date||o.Date,p=e.SyntaxError||o.SyntaxError,l=e.TypeError||o.TypeError,d=e.Math||o.Math,f=e.JSON||o.JSON;"object"==typeof f&&f&&(t.stringify=f.stringify,t.parse=f.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(!i("json")){var b=i("bug-string-char-index");if(!_)var w=d.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,i,o,s=0;(n=function(){this.valueOf=0}).prototype.valueOf=0,i=new n;for(o in i)h.call(i,o)&&s++;return n=i=null,s?g=2==s?function(e,t){var n,r={},i="[object Function]"==m.call(e);for(n in e)i&&"prototype"==n||h.call(r,n)||!(r[n]=1)||!h.call(e,n)||t(n)}:function(e,t){var n,r,i="[object Function]"==m.call(e);for(n in e)i&&"prototype"==n||!h.call(e,n)||(r="constructor"===n)||t(n);(r||h.call(e,n="constructor"))&&t(n)}:(i=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],g=function(e,t){var n,o,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(o=i.length;n=i[--o];a.call(e,n)&&t(n));}),g(e,t)},!i("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,i=!b||r>10,o=i&&(b?e.split(""):e);n-1/0&&a<1/0){if(E){for(d=w(a/864e5),c=w(d/365.2425)+1970-1;E(c+1,0)<=d;c++);for(p=w((d-E(c,0))/30.42);E(c,p+1)<=d;p++);d=1+d-E(c,p),y=w((f=(a%864e5+864e5)%864e5)/36e5)%24,_=w(f/6e4)%60,b=w(f/1e3)%60,I=f%1e3}else c=a.getUTCFullYear(),p=a.getUTCMonth(),d=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,d)+"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(x=s.length;x--;)if(s[x]===a)throw l();if(s.push(a),S=[],j=o,o+=i,"[object Array]"==u){for(T=0,x=a.length;T0)for(i="",n>10&&(n=10);i.length=48&&i<=57||i>=97&&i<=102||i>=65&&i<=70||P();e+=x("0x"+o.slice(t,A));break;default:P()}else{if(34==i)break;for(i=o.charCodeAt(A),t=A;i>=32&&92!=i&&34!=i;)i=o.charCodeAt(++A);e+=o.slice(t,A)}if(34==o.charCodeAt(A))return A++,e;P();default:if(t=A,45==i&&(r=!0,i=o.charCodeAt(++A)),i>=48&&i<=57){for(48==i&&(i=o.charCodeAt(A+1))>=48&&i<=57&&P(),r=!1;A=48&&i<=57;A++);if(46==o.charCodeAt(A)){for(n=++A;n=48&&i<=57;n++);n==A&&P(),A=n}if(101==(i=o.charCodeAt(A))||69==i){for(43!=(i=o.charCodeAt(++A))&&45!=i||A++,n=A;n=48&&i<=57;n++);n==A&&P(),A=n}return+o.slice(t,A)}if(r&&P(),"true"==o.slice(A,A+4))return A+=4,!0;if("false"==o.slice(A,A+5))return A+=5,!1;if("null"==o.slice(A,A+4))return A+=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=k());n||(n=!0))n&&(","==e?"]"==(e=k())&&P():P()),","==e&&P(),t.push(R(e));return t}if("{"==e){for(t={};"}"!=(e=k());n||(n=!0))n&&(","==e?"}"==(e=k())&&P():P()),","!=e&&"string"==typeof e&&"@"==(b?e.charAt(0):e[0])&&":"==k()||P(),t[e.slice(1)]=R(k());return t}P()}return e},U=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,i=e[t];if("object"==typeof i&&i)if("[object Array]"==m.call(i))for(r=i.length;r--;)U(i,r,n);else g(i,function(e){U(i,e,n)});return n.call(e,t,i)};t.parse=function(e,t){var n,r;return A=0,T=""+e,n=R(k()),"$"!=k()&&P(),A=T=null,t&&"[object Function]"==m.call(t)?F((r={},r[""]=n,r),"",t):n}}}return t.runInContext=n,t}var r={function:!0,object:!0},i=r.object&&t&&!t.nodeType&&t,o=r[typeof window]&&window||this,s=i&&r.object&&e&&!e.nodeType&&"object"==typeof y&&y;if(!s||s.global!==s&&s.window!==s&&s.self!==s||(o=s),i)n(o,i);else{var a=o.JSON,u=o.JSON3,c=!1,p=n(o,o.JSON3={noConflict:function(){return c||(c=!0,o.JSON=a,o.JSON3=u,a=u=null),p}});o.JSON={parse:p.parse,stringify:p.stringify}}}).call(y)}),{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"}),_={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,i=0,o=0;n191&&r<224?(i=e.charCodeAt(n+1),t+=String.fromCharCode((31&r)<<6|63&i),n+=2):(i=e.charCodeAt(n+1),o=e.charCodeAt(n+2),t+=String.fromCharCode((15&r)<<12|(63&i)<<6|63&o),n+=3);return t}},b={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(e)))}catch(e){}return b._encode(e)},_encode:function(e){var t,n,r,i,o,s,a,u="",c=0;for(e=_.encode(e);c>2,o=(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+b._keyStr.charAt(i)+b._keyStr.charAt(o)+b._keyStr.charAt(s)+b._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return b._decode(e)},_decode:function(e){var t,n,r,i,o,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,n=(15&i)<<4|(o=b._keyStr.indexOf(e.charAt(u++)))>>2,r=(3&o)<<6|(s=b._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==o&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(r));return a=_.decode(a)}},w=e(function(e,t){function n(e){switch(e){case"http:":return 80;case"https:":return 443;default:return location.port}}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?n(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}}),I=1e3,E=60*I,S=60*E,C=24*S,O=365.25*C,N=function(e,i){i=i||{};var o=typeof e;if("string"===o&&e.length>0)return t(e);if("number"===o&&!1===isNaN(e))return i.long?r(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},A=e(function(e,t){function n(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}function r(e){function r(){if(r.enabled){var e=r,n=+new Date,i=n-(o||n);e.diff=i,e.prev=o,e.curr=n,o=n;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"),x=function(e,t,n){switch(arguments.length){case 3:case 2:return o(e,t,n);case 1:return a(e);default:return s()}},j=e(function(e,t){function n(e){for(var n=t.cookie,r=t.levels(e),i=0;i=0;--o)i.push(t.slice(o).join("."));return i},n.cookie=x,t=e.exports=n}),P="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,R=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":P(e)},U=function(e){try{console.log("[Amplitude] "+e)}catch(e){}},F=function(e){return"string"===R(e)&&e.length>m.MAX_STRING_LENGTH?e.substring(0,m.MAX_STRING_LENGTH):e},D=function(e){var t=R(e);if("object"!==t)return U("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>m.MAX_PROPERTY_KEYS)return U("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var r in e)if(e.hasOwnProperty(r)){var i=r,o=R(i);"string"!==o&&(i=String(i),U("WARNING: Non-string property key, received type "+o+', coercing to string "'+i+'"'));var s=q(i,e[r]);null!==s&&(n[i]=s)}return n},M=["null","nan","undefined","function","arguments","regexp","element"],q=function e(t,n){var r=R(n);if(-1!==M.indexOf(r))U('WARNING: Property key "'+t+'" with invalid value type '+r+", ignoring"),n=null;else if("error"===r)n=String(n),U('WARNING: Property key "'+t+'" with value type error, coercing to '+n);else if("array"===r){for(var i=[],o=0;o0?(this.userPropertiesOperations.hasOwnProperty("$clearAll")||L.log("Need to send $clearAll on its own Identify object without any other operations, skipping $clearAll"),this):(this.userPropertiesOperations.$clearAll="-",this)},ee.prototype.prepend=function(e,t){return this._addOperation("$prepend",e,t),this},ee.prototype.set=function(e,t){return this._addOperation("$set",e,t),this},ee.prototype.setOnce=function(e,t){return this._addOperation("$setOnce",e,t),this},ee.prototype.unset=function(e){return this._addOperation("$unset",e,"-"),this},ee.prototype._addOperation=function(e,t,n){this.userPropertiesOperations.hasOwnProperty("$clearAll")?L.log("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)):L.log('User property "'+t+'" already used in this identify, skipping operation '+e)};var te=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){return e<>>32-t}function i(e,t,i,o,s,a){return n(r(n(n(t,e),n(o,a)),s),i)}function o(e,t,n,r,o,s,a){return i(t&n|~t&r,e,t,o,s,a)}function s(e,t,n,r,o,s,a){return i(t&r|n&~r,e,t,o,s,a)}function a(e,t,n,r,o,s,a){return i(t^n^r,e,t,o,s,a)}function u(e,t,n,r,o,s,a){return i(n^(t|~r),e,t,o,s,a)}function c(e,t){e[t>>5]|=128<>>9<<4)]=t;var r,i,c,p,l,d=1732584193,f=-271733879,h=-1732584194,g=271733878;for(r=0;r>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<16&&(i=c(i,8*e.length)),n=0;n<16;n+=1)o[n]=909522486^i[n],s[n]=1549556828^i[n];return r=c(o.concat(l(t)),512+8*t.length),p(c(s.concat(r),640))}function h(e){var t,n,r="";for(n=0;n>>4&15)+"0123456789abcdef".charAt(15&t);return r}function g(e){return unescape(encodeURIComponent(e))}function v(e){return d(g(e))}function y(e){return h(v(e))}function m(e,t){return f(g(e),g(t))}function _(e,t){return h(m(e,t))}function b(e,t,n){return t?n?m(t,e):_(t,e):n?v(e):y(e)}e.exports?e.exports=b:t.md5=b}(y)}),ne="object"==typeof y&&y&&y.Object===Object&&y,re="object"==typeof self&&self&&self.Object===Object&&self,ie=ne||re||Function("return this")(),oe=ie.Symbol,se=Object.prototype,ae=se.hasOwnProperty,ue=se.toString,ce=oe?oe.toStringTag:void 0,pe=function(e){var t=ae.call(e,ce),n=e[ce];try{e[ce]=void 0;var r=!0}catch(e){}var i=ue.call(e);return r&&(t?e[ce]=n:delete e[ce]),i},le=Object.prototype.toString,de=function(e){return le.call(e)},fe="[object Null]",he="[object Undefined]",ge=oe?oe.toStringTag:void 0,ve=function(e){return null==e?void 0===e?he:fe:ge&&ge in Object(e)?pe(e):de(e)},ye=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},me="[object AsyncFunction]",_e="[object Function]",be="[object GeneratorFunction]",we="[object Proxy]",Ie=function(e){if(!ye(e))return!1;var t=ve(e);return t==_e||t==be||t==me||t==we},Ee=ie["__core-js_shared__"],Se=function(){var e=/[^.]+$/.exec(Ee&&Ee.keys&&Ee.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ce=function(e){return!!Se&&Se in e},Oe=Function.prototype.toString,Ne=function(e){if(null!=e){try{return Oe.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Ae=/[\\^$.*+?()[\]{}|]/g,Te=/^\[object .+?Constructor\]$/,xe=Function.prototype,je=Object.prototype,Pe=xe.toString,ke=je.hasOwnProperty,Re=RegExp("^"+Pe.call(ke).replace(Ae,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ue=function(e){return!(!ye(e)||Ce(e))&&(Ie(e)?Re:Te).test(Ne(e))},Fe=function(e,t){return null==e?void 0:e[t]},De=function(e,t){var n=Fe(e,t);return Ue(n)?n:void 0},Me=function(){try{var e=De(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),qe=function(e,t,n){"__proto__"==t&&Me?Me(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},Ve=function(e,t){return e===t||e!==e&&t!==t},Le=Object.prototype.hasOwnProperty,Ge=function(e,t,n){var r=e[t];Le.call(e,t)&&Ve(r,n)&&(void 0!==n||t in e)||qe(e,t,n)},Be=function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o0){if(++t>=Qe)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Ye),et=function(e,t){return Ze(Je(e,t,Ke),e+"")},tt=9007199254740991,nt=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=tt},rt=function(e){return null!=e&&nt(e.length)&&!Ie(e)},it=9007199254740991,ot=/^(?:0|[1-9]\d*)$/,st=function(e,t){return!!(t=null==t?it:t)&&("number"==typeof e||ot.test(e))&&e>-1&&e%1==0&&e1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&at(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r0?2==i.length?"function"==typeof i[1]?e[i[0]]=i[1].call(this,s):e[i[0]]=i[1]:3==i.length?"function"!=typeof i[1]||i[1].exec&&i[1].test?e[i[0]]=s?s.replace(i[1],i[2]):void 0:e[i[0]]=s?i[1].call(this,s,i[2]):void 0:4==i.length&&(e[i[0]]=s?i[3].call(this,s.replace(i[1],i[2])):void 0):e[i]=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)},Gt={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,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:!1,includeGclid:!1,saveParamsReferrerOncePerSession:!0,deviceIdFromUrlParam:!1},Bt=function(e){this._instanceName=L.isEmptyString(e)?m.DEFAULT_INSTANCE:e.toLowerCase(),this._storageSuffix=this._instanceName===m.DEFAULT_INSTANCE?"":"_"+this._instanceName,this._unsentEvents=[],this._unsentIdentifys=[],this._ua=new Vt(navigator.userAgent).getResult(),this.options=Rt({},Gt),this.cookieStorage=(new H).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};Bt.prototype.Identify=ee,Bt.prototype.Revenue=qt,Bt.prototype.init=function(e,t,n,r){if("string"!==R(e)||L.isEmptyString(e))L.log("Invalid apiKey. Please re-initialize with a valid apiKey");else try{if(this.options.apiKey=e,Kt(this.options,n),this.cookieStorage.options({expirationDays:this.options.cookieExpiration,domain:this.options.domain}),this.options.domain=this.cookieStorage.options().domain,this._instanceName===m.DEFAULT_INSTANCE&&zt(this),$t(this),this.options.deviceId="object"===R(n)&&"string"===R(n.deviceId)&&!L.isEmptyString(n.deviceId)&&n.deviceId||this.options.deviceIdFromUrlParam&&this._getDeviceIdFromUrlParam(this._getUrlParams())||this.options.deviceId||Lt()+"R",this.options.userId="string"===R(t)&&!L.isEmptyString(t)&&t||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=p,this.options.saveParamsReferrerOncePerSession&&this._trackParamsAndReferrer()),this.options.saveParamsReferrerOncePerSession||this._trackParamsAndReferrer(),this._lastEventTime=p,Jt(this),this._sendEventsIfReady()}catch(e){L.log(e)}finally{"function"===R(r)&&r(this)}},Bt.prototype._trackParamsAndReferrer=function(){this.options.includeUtm&&this._initUtmData(),this.options.includeReferrer&&this._saveReferrer(this._getReferrer()),this.options.includeGclid&&this._saveGclid(this._getUrlParams())};var Kt=function(e,t){if("object"===R(t)){for(var n in t)t.hasOwnProperty(n)&&function(n){if(Gt.hasOwnProperty(n)){var r=t[n],i=R(Gt[n]);L.validateInput(r,n+" option",i)&&("boolean"===i?e[n]=!!r:("string"===i&&!L.isEmptyString(r)||"number"===i&&r>0)&&(e[n]=r))}}(n)}};Bt.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))},Bt.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},Bt.prototype._setInStorage=function(e,t,n){e.setItem(t+this._storageSuffix,n)};var zt=function(e){var t=e.cookieStorage.get(e.options.cookieName);if(!("object"===R(t)&&t.deviceId&&t.sessionId&&t.lastEventTime)){var n=function(e){var t=X.getItem(e);return X.removeItem(e),t},r="string"===R(e.options.apiKey)&&"_"+e.options.apiKey.slice(0,6)||"",i=n(m.DEVICE_ID+r),o=n(m.USER_ID+r),s=n(m.OPT_OUT+r);null!==s&&void 0!==s&&(s="true"===String(s));var a=parseInt(n(m.SESSION_ID)),u=parseInt(n(m.LAST_EVENT_TIME)),c=parseInt(n(m.LAST_EVENT_ID)),p=parseInt(n(m.LAST_IDENTIFY_ID)),l=parseInt(n(m.LAST_SEQUENCE_NUMBER)),d=function(e){return"object"===R(t)&&t[e]};e.options.deviceId=d("deviceId")||i,e.options.userId=d("userId")||o,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)),Jt(e)}},$t=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);"object"===R(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)))},Jt=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})};Bt.prototype._initUtmData=function(e,t){e=e||this._getUrlParams(),t=t||this.cookieStorage.get("__utmz");var n=Z(t,e);Wt(this,n)};var Wt=function(e,t){if("object"===R(t)&&0!==Object.keys(t).length){var n=new ee;for(var r in t)t.hasOwnProperty(r)&&(n.setOnce("initial_"+r,t[r]),n.set(r,t[r]));e.identify(n)}};Bt.prototype._getReferrer=function(){return document.referrer},Bt.prototype._getUrlParams=function(){return location.search},Bt.prototype._saveGclid=function(e){var t=L.getQueryParam("gclid",e);L.isEmptyString(t)||Wt(this,{gclid:t})},Bt.prototype._getDeviceIdFromUrlParam=function(e){return L.getQueryParam(m.AMP_DEVICE_ID_PARAM,e)},Bt.prototype._getReferringDomain=function(e){if(L.isEmptyString(e))return null;var t=e.split("/");return t.length>=3?t[2]:null},Bt.prototype._saveReferrer=function(e){if(!L.isEmptyString(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};Wt(this,t)}},Bt.prototype.saveEvents=function(){try{this._setInStorage(X,this.options.unsentKey,JSON.stringify(this._unsentEvents))}catch(e){}try{this._setInStorage(X,this.options.unsentIdentifyKey,JSON.stringify(this._unsentIdentifys))}catch(e){}},Bt.prototype.setDomain=function(e){if(L.validateInput(e,"domain","string"))try{this.cookieStorage.options({domain:e}),this.options.domain=this.cookieStorage.options().domain,$t(this),Jt(this)}catch(e){L.log(e)}},Bt.prototype.setUserId=function(e){try{this.options.userId=void 0!==e&&null!==e&&""+e||null,Jt(this)}catch(e){L.log(e)}},Bt.prototype.setGroup=function(e,t){if(this._apiKeySet("setGroup()")&&L.validateInput(e,"groupType","string")&&!L.isEmptyString(e)){var n={};n[e]=t;var r=(new ee).set(e,t);this._logEvent(m.IDENTIFY_EVENT,null,null,r.userPropertiesOperations,n,null,null)}},Bt.prototype.setOptOut=function(e){if(L.validateInput(e,"enable","boolean"))try{this.options.optOut=e,Jt(this)}catch(e){L.log(e)}},Bt.prototype.setSessionId=function(e){if(L.validateInput(e,"sessionId","number"))try{this._sessionId=e,Jt(this)}catch(e){L.log(e)}},Bt.prototype.regenerateDeviceId=function(){this.setDeviceId(Lt()+"R")},Bt.prototype.setDeviceId=function(e){if(L.validateInput(e,"deviceId","string"))try{L.isEmptyString(e)||(this.options.deviceId=""+e,Jt(this))}catch(e){L.log(e)}},Bt.prototype.setUserProperties=function(e){if(this._apiKeySet("setUserProperties()")&&L.validateInput(e,"userProperties","object")){var t=L.truncate(L.validateProperties(e));if(0!==Object.keys(t).length){var n=new ee;for(var r in t)t.hasOwnProperty(r)&&n.set(r,t[r]);this.identify(n)}}},Bt.prototype.clearUserProperties=function(){if(this._apiKeySet("clearUserProperties()")){var e=new ee;e.clearAll(),this.identify(e)}};var Yt=function(e,t){for(var n=0;n0)return this._logEvent(m.IDENTIFY_EVENT,null,null,e.userPropertiesOperations,null,null,t)}else L.log("Invalid identify input type. Expected Identify object but saw "+R(e));"function"===R(t)&&t(0,"No request sent")}else"function"===R(t)&&t(0,"No request sent")},Bt.prototype.setVersionName=function(e){L.validateInput(e,"versionName","string")&&(this.options.versionName=e)},Bt.prototype._logEvent=function(e,t,n,r,i,o,s){if($t(this),e&&!this.options.optOut)try{var a;a=e===m.IDENTIFY_EVENT?this.nextIdentifyId():this.nextEventId();var u=this.nextSequenceNumber(),c="number"===R(o)?o:(new Date).getTime();(!this._sessionId||!this._lastEventTime||c-this._lastEventTime>this.options.sessionTimeout)&&(this._sessionId=c),this._lastEventTime=c,Jt(this),r=r||{},n=n||{},t=t||{},i=i||{};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:L.truncate(L.validateProperties(t)),user_properties:L.truncate(L.validateProperties(r)),uuid:Lt(),library:{name:"amplitude-js",version:"3.6.0"},sequence_number:u,groups:L.truncate(L.validateGroups(i)),user_agent:this._userAgent};return e===m.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"!==R(s)||s(0,"No request sent"),a}catch(e){L.log(e)}else"function"===R(s)&&s(0,"No request sent")},Bt.prototype._limitEventsQueued=function(e){e.length>this.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount)},Bt.prototype.logEvent=function(e,t,n){return this.logEventWithTimestamp(e,t,null,n)},Bt.prototype.logEventWithTimestamp=function(e,t,n,r){return this._apiKeySet("logEvent()")&&L.validateInput(e,"eventType","string")&&!L.isEmptyString(e)?this._logEvent(e,t,null,null,null,n,r):("function"===R(r)&&r(0,"No request sent"),-1)},Bt.prototype.logEventWithGroups=function(e,t,n,r){return this._apiKeySet("logEventWithGroup()")&&L.validateInput(e,"eventType","string")?this._logEvent(e,t,null,null,n,null,r):("function"===R(r)&&r(0,"No request sent"),-1)};var Qt=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};Bt.prototype.logRevenueV2=function(e){if(this._apiKeySet("logRevenueV2()"))if("object"===R(e)&&e.hasOwnProperty("_q")&&(e=Yt(new qt,e)),e instanceof qt){if(e&&e._isValidRevenue())return this.logEvent(m.REVENUE_EVENT,e._toJSONObject())}else L.log("Invalid revenue input type. Expected Revenue object but saw "+R(e))},Bt.prototype.logRevenue=function(e,t,n){return this._apiKeySet("logRevenue()")&&Qt(e)&&(void 0===t||Qt(t))?this._logEvent(m.REVENUE_EVENT,{},{productId:n,special:"revenue_amount",quantity:t||1,price:e},null,null,null,null):-1},Bt.prototype.removeEvents=function(e,t){Xt(this,"_unsentEvents",e),Xt(this,"_unsentIdentifys",t)};var Xt=function(e,t,n){if(!(n<0)){for(var r=[],i=0;in&&r.push(e[t][i]);e[t]=r}};Bt.prototype.sendEvents=function(e){if(!this._apiKeySet("sendEvents()")||this._sending||this.options.optOut||0===this._unsentCount())"function"===R(e)&&e(0,"No request sent");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),i=r.maxEventId,o=r.maxIdentifyId,s=JSON.stringify(r.eventsToSend),a=(new Date).getTime(),u={client:this.options.apiKey,e:s,v:m.API_VERSION,upload_time:a,checksum:te(m.API_VERSION+this.options.apiKey+s+a)},c=this;new Mt(t,u).send(function(t,r){c._sending=!1;try{200===t&&"success"===r?(c.removeEvents(i,o),c.options.saveEvents&&c.saveEvents(),c._sendEventsIfReady(e)||"function"!==R(e)||e(t,r)):413===t?(1===c.options.uploadBatchSize&&c.removeEvents(i,o),c.options.uploadBatchSize=Math.ceil(n/2),c.sendEvents(e)):"function"===R(e)&&e(t,r)}catch(e){}})}},Bt.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],n=0,r=-1,i=0,o=-1;t.length=this._unsentIdentifys.length,u=n>=this._unsentEvents.length;if(u&&a){L.log("Merging Events and Identifys, less events and identifys than expected");break}a?r=(s=this._unsentEvents[n++]).event_id:u?o=(s=this._unsentIdentifys[i++]).event_id:!("sequence_number"in this._unsentEvents[n])||this._unsentEvents[n].sequence_number100)){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*O;case"days":case"day":case"d":return n*C;case"hours":case"hour":case"hrs":case"hr":case"h":return n*S;case"minutes":case"minute":case"mins":case"min":case"m":return n*E;case"seconds":case"second":case"secs":case"sec":case"s":return n*I;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function n(e){return e>=C?Math.round(e/C)+"d":e>=S?Math.round(e/S)+"h":e>=E?Math.round(e/E)+"m":e>=I?Math.round(e/I)+"s":e+"ms"}function r(e){return i(e,C,"day")||i(e,S,"hour")||i(e,E,"minute")||i(e,I,"second")||e+" ms"}function i(e,t,n){if(!(e0&&a>s&&(a=s);for(var u=0;u=0?(c=h.substr(0,g),p=h.substr(g+1)):(c=h,p=""),d=decodeURIComponent(c),f=decodeURIComponent(p),l(i,d)?Ut(i[d])?i[d].push(f):i[d]=[i[d],f]:i[d]=f}return i}var v,y="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},m=(e(function(e,t){(function(){function n(e,t){function i(e){if(i[e]!==v)return i[e];var n;if("bug-string-char-index"==e)n="a"!="a"[0];else if("json"==e)n=i("json-stringify")&&i("json-parse");else{var r,o='{"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"]})==o&&"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 d=5==(r=l(o)).a.length&&1===r.a[0];if(d){try{d=!l('"\t"')}catch(e){}if(d)try{d=1!==l("01")}catch(e){}if(d)try{d=1!==l("1.")}catch(e){}}}}catch(e){d=!1}n=d}}return i[e]=!!n}e||(e=o.Object()),t||(t=o.Object());var s=e.Number||o.Number,a=e.String||o.String,u=e.Object||o.Object,c=e.Date||o.Date,p=e.SyntaxError||o.SyntaxError,l=e.TypeError||o.TypeError,d=e.Math||o.Math,f=e.JSON||o.JSON;"object"==typeof f&&f&&(t.stringify=f.stringify,t.parse=f.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(!i("json")){var b=i("bug-string-char-index");if(!_)var w=d.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,i,o,s=0;(n=function(){this.valueOf=0}).prototype.valueOf=0,i=new n;for(o in i)h.call(i,o)&&s++;return n=i=null,s?g=2==s?function(e,t){var n,r={},i="[object Function]"==m.call(e);for(n in e)i&&"prototype"==n||h.call(r,n)||!(r[n]=1)||!h.call(e,n)||t(n)}:function(e,t){var n,r,i="[object Function]"==m.call(e);for(n in e)i&&"prototype"==n||!h.call(e,n)||(r="constructor"===n)||t(n);(r||h.call(e,n="constructor"))&&t(n)}:(i=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],g=function(e,t){var n,o,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(o=i.length;n=i[--o];a.call(e,n)&&t(n));}),g(e,t)},!i("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,i=!b||r>10,o=i&&(b?e.split(""):e);n-1/0&&a<1/0){if(E){for(d=w(a/864e5),c=w(d/365.2425)+1970-1;E(c+1,0)<=d;c++);for(p=w((d-E(c,0))/30.42);E(c,p+1)<=d;p++);d=1+d-E(c,p),y=w((f=(a%864e5+864e5)%864e5)/36e5)%24,_=w(f/6e4)%60,b=w(f/1e3)%60,I=f%1e3}else c=a.getUTCFullYear(),p=a.getUTCMonth(),d=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,d)+"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(x=s.length;x--;)if(s[x]===a)throw l();if(s.push(a),S=[],j=o,o+=i,"[object Array]"==u){for(T=0,x=a.length;T0)for(i="",n>10&&(n=10);i.length=48&&i<=57||i>=97&&i<=102||i>=65&&i<=70||P();e+=x("0x"+o.slice(t,A));break;default:P()}else{if(34==i)break;for(i=o.charCodeAt(A),t=A;i>=32&&92!=i&&34!=i;)i=o.charCodeAt(++A);e+=o.slice(t,A)}if(34==o.charCodeAt(A))return A++,e;P();default:if(t=A,45==i&&(r=!0,i=o.charCodeAt(++A)),i>=48&&i<=57){for(48==i&&(i=o.charCodeAt(A+1))>=48&&i<=57&&P(),r=!1;A=48&&i<=57;A++);if(46==o.charCodeAt(A)){for(n=++A;n=48&&i<=57;n++);n==A&&P(),A=n}if(101==(i=o.charCodeAt(A))||69==i){for(43!=(i=o.charCodeAt(++A))&&45!=i||A++,n=A;n=48&&i<=57;n++);n==A&&P(),A=n}return+o.slice(t,A)}if(r&&P(),"true"==o.slice(A,A+4))return A+=4,!0;if("false"==o.slice(A,A+5))return A+=5,!1;if("null"==o.slice(A,A+4))return A+=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=k());n||(n=!0))n&&(","==e?"]"==(e=k())&&P():P()),","==e&&P(),t.push(R(e));return t}if("{"==e){for(t={};"}"!=(e=k());n||(n=!0))n&&(","==e?"}"==(e=k())&&P():P()),","!=e&&"string"==typeof e&&"@"==(b?e.charAt(0):e[0])&&":"==k()||P(),t[e.slice(1)]=R(k());return t}P()}return e},U=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,i=e[t];if("object"==typeof i&&i)if("[object Array]"==m.call(i))for(r=i.length;r--;)U(i,r,n);else g(i,function(e){U(i,e,n)});return n.call(e,t,i)};t.parse=function(e,t){var n,r;return A=0,T=""+e,n=R(k()),"$"!=k()&&P(),A=T=null,t&&"[object Function]"==m.call(t)?F((r={},r[""]=n,r),"",t):n}}}return t.runInContext=n,t}var r={function:!0,object:!0},i=r.object&&t&&!t.nodeType&&t,o=r[typeof window]&&window||this,s=i&&r.object&&e&&!e.nodeType&&"object"==typeof y&&y;if(!s||s.global!==s&&s.window!==s&&s.self!==s||(o=s),i)n(o,i);else{var a=o.JSON,u=o.JSON3,c=!1,p=n(o,o.JSON3={noConflict:function(){return c||(c=!0,o.JSON=a,o.JSON3=u,a=u=null),p}});o.JSON={parse:p.parse,stringify:p.stringify}}}).call(y)}),{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"}),_={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,i=0,o=0;n191&&r<224?(i=e.charCodeAt(n+1),t+=String.fromCharCode((31&r)<<6|63&i),n+=2):(i=e.charCodeAt(n+1),o=e.charCodeAt(n+2),t+=String.fromCharCode((15&r)<<12|(63&i)<<6|63&o),n+=3);return t}},b={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(e)))}catch(e){}return b._encode(e)},_encode:function(e){var t,n,r,i,o,s,a,u="",c=0;for(e=_.encode(e);c>2,o=(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+b._keyStr.charAt(i)+b._keyStr.charAt(o)+b._keyStr.charAt(s)+b._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return b._decode(e)},_decode:function(e){var t,n,r,i,o,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,n=(15&i)<<4|(o=b._keyStr.indexOf(e.charAt(u++)))>>2,r=(3&o)<<6|(s=b._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==o&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(r));return a=_.decode(a)}},w=e(function(e,t){function n(e){switch(e){case"http:":return 80;case"https:":return 443;default:return location.port}}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?n(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}}),I=1e3,E=60*I,S=60*E,C=24*S,O=365.25*C,N=function(e,i){i=i||{};var o=typeof e;if("string"===o&&e.length>0)return t(e);if("number"===o&&!1===isNaN(e))return i.long?r(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},A=e(function(e,t){function n(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}function r(e){function r(){if(r.enabled){var e=r,n=+new Date,i=n-(o||n);e.diff=i,e.prev=o,e.curr=n,o=n;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"),x=function(e,t,n){switch(arguments.length){case 3:case 2:return o(e,t,n);case 1:return a(e);default:return s()}},j=e(function(e,t){function n(e){for(var n=t.cookie,r=t.levels(e),i=0;i=0;--o)i.push(t.slice(o).join("."));return i},n.cookie=x,t=e.exports=n}),P="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,R=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":P(e)},U=function(e){try{console.log("[Amplitude] "+e)}catch(e){}},F=function(e){return"string"===R(e)&&e.length>m.MAX_STRING_LENGTH?e.substring(0,m.MAX_STRING_LENGTH):e},D=function(e){var t=R(e);if("object"!==t)return U("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>m.MAX_PROPERTY_KEYS)return U("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var r in e)if(e.hasOwnProperty(r)){var i=r,o=R(i);"string"!==o&&(i=String(i),U("WARNING: Non-string property key, received type "+o+', coercing to string "'+i+'"'));var s=q(i,e[r]);null!==s&&(n[i]=s)}return n},M=["null","nan","undefined","function","arguments","regexp","element"],q=function e(t,n){var r=R(n);if(-1!==M.indexOf(r))U('WARNING: Property key "'+t+'" with invalid value type '+r+", ignoring"),n=null;else if("error"===r)n=String(n),U('WARNING: Property key "'+t+'" with value type error, coercing to '+n);else if("array"===r){for(var i=[],o=0;o0?(this.userPropertiesOperations.hasOwnProperty("$clearAll")||L.log("Need to send $clearAll on its own Identify object without any other operations, skipping $clearAll"),this):(this.userPropertiesOperations.$clearAll="-",this)},ee.prototype.prepend=function(e,t){return this._addOperation("$prepend",e,t),this},ee.prototype.set=function(e,t){return this._addOperation("$set",e,t),this},ee.prototype.setOnce=function(e,t){return this._addOperation("$setOnce",e,t),this},ee.prototype.unset=function(e){return this._addOperation("$unset",e,"-"),this},ee.prototype._addOperation=function(e,t,n){this.userPropertiesOperations.hasOwnProperty("$clearAll")?L.log("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)):L.log('User property "'+t+'" already used in this identify, skipping operation '+e)};var te=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){return e<>>32-t}function i(e,t,i,o,s,a){return n(r(n(n(t,e),n(o,a)),s),i)}function o(e,t,n,r,o,s,a){return i(t&n|~t&r,e,t,o,s,a)}function s(e,t,n,r,o,s,a){return i(t&r|n&~r,e,t,o,s,a)}function a(e,t,n,r,o,s,a){return i(t^n^r,e,t,o,s,a)}function u(e,t,n,r,o,s,a){return i(n^(t|~r),e,t,o,s,a)}function c(e,t){e[t>>5]|=128<>>9<<4)]=t;var r,i,c,p,l,d=1732584193,f=-271733879,h=-1732584194,g=271733878;for(r=0;r>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<16&&(i=c(i,8*e.length)),n=0;n<16;n+=1)o[n]=909522486^i[n],s[n]=1549556828^i[n];return r=c(o.concat(l(t)),512+8*t.length),p(c(s.concat(r),640))}function h(e){var t,n,r="";for(n=0;n>>4&15)+"0123456789abcdef".charAt(15&t);return r}function g(e){return unescape(encodeURIComponent(e))}function v(e){return d(g(e))}function y(e){return h(v(e))}function m(e,t){return f(g(e),g(t))}function _(e,t){return h(m(e,t))}function b(e,t,n){return t?n?m(t,e):_(t,e):n?v(e):y(e)}e.exports?e.exports=b:t.md5=b}(y)}),ne="object"==typeof y&&y&&y.Object===Object&&y,re="object"==typeof self&&self&&self.Object===Object&&self,ie=ne||re||Function("return this")(),oe=ie.Symbol,se=Object.prototype,ae=se.hasOwnProperty,ue=se.toString,ce=oe?oe.toStringTag:void 0,pe=function(e){var t=ae.call(e,ce),n=e[ce];try{e[ce]=void 0;var r=!0}catch(e){}var i=ue.call(e);return r&&(t?e[ce]=n:delete e[ce]),i},le=Object.prototype.toString,de=function(e){return le.call(e)},fe="[object Null]",he="[object Undefined]",ge=oe?oe.toStringTag:void 0,ve=function(e){return null==e?void 0===e?he:fe:ge&&ge in Object(e)?pe(e):de(e)},ye=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},me="[object AsyncFunction]",_e="[object Function]",be="[object GeneratorFunction]",we="[object Proxy]",Ie=function(e){if(!ye(e))return!1;var t=ve(e);return t==_e||t==be||t==me||t==we},Ee=ie["__core-js_shared__"],Se=function(){var e=/[^.]+$/.exec(Ee&&Ee.keys&&Ee.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ce=function(e){return!!Se&&Se in e},Oe=Function.prototype.toString,Ne=function(e){if(null!=e){try{return Oe.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Ae=/[\\^$.*+?()[\]{}|]/g,Te=/^\[object .+?Constructor\]$/,xe=Function.prototype,je=Object.prototype,Pe=xe.toString,ke=je.hasOwnProperty,Re=RegExp("^"+Pe.call(ke).replace(Ae,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ue=function(e){return!(!ye(e)||Ce(e))&&(Ie(e)?Re:Te).test(Ne(e))},Fe=function(e,t){return null==e?void 0:e[t]},De=function(e,t){var n=Fe(e,t);return Ue(n)?n:void 0},Me=function(){try{var e=De(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),qe=function(e,t,n){"__proto__"==t&&Me?Me(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},Ve=function(e,t){return e===t||e!==e&&t!==t},Le=Object.prototype.hasOwnProperty,Ge=function(e,t,n){var r=e[t];Le.call(e,t)&&Ve(r,n)&&(void 0!==n||t in e)||qe(e,t,n)},Be=function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o0){if(++t>=Qe)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Ye),et=function(e,t){return Ze(Je(e,t,Ke),e+"")},tt=9007199254740991,nt=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=tt},rt=function(e){return null!=e&&nt(e.length)&&!Ie(e)},it=9007199254740991,ot=/^(?:0|[1-9]\d*)$/,st=function(e,t){return!!(t=null==t?it:t)&&("number"==typeof e||ot.test(e))&&e>-1&&e%1==0&&e1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&at(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r0?2==i.length?"function"==typeof i[1]?e[i[0]]=i[1].call(this,s):e[i[0]]=i[1]:3==i.length?"function"!=typeof i[1]||i[1].exec&&i[1].test?e[i[0]]=s?s.replace(i[1],i[2]):void 0:e[i[0]]=s?i[1].call(this,s,i[2]):void 0:4==i.length&&(e[i[0]]=s?i[3].call(this,s.replace(i[1],i[2])):void 0):e[i]=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)},Gt={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,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:!1,includeGclid:!1,saveParamsReferrerOncePerSession:!0,deviceIdFromUrlParam:!1},Bt=function(e){this._instanceName=L.isEmptyString(e)?m.DEFAULT_INSTANCE:e.toLowerCase(),this._storageSuffix=this._instanceName===m.DEFAULT_INSTANCE?"":"_"+this._instanceName,this._unsentEvents=[],this._unsentIdentifys=[],this._ua=new Vt(navigator.userAgent).getResult(),this.options=Rt({},Gt),this.cookieStorage=(new H).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};Bt.prototype.Identify=ee,Bt.prototype.Revenue=qt,Bt.prototype.init=function(e,t,n,r){if("string"!==R(e)||L.isEmptyString(e))L.log("Invalid apiKey. Please re-initialize with a valid apiKey");else try{if(this.options.apiKey=e,Kt(this.options,n),this.cookieStorage.options({expirationDays:this.options.cookieExpiration,domain:this.options.domain}),this.options.domain=this.cookieStorage.options().domain,this._instanceName===m.DEFAULT_INSTANCE&&zt(this),$t(this),this.options.deviceId="object"===R(n)&&"string"===R(n.deviceId)&&!L.isEmptyString(n.deviceId)&&n.deviceId||this.options.deviceIdFromUrlParam&&this._getDeviceIdFromUrlParam(this._getUrlParams())||this.options.deviceId||Lt()+"R",this.options.userId="string"===R(t)&&!L.isEmptyString(t)&&t||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=p,this.options.saveParamsReferrerOncePerSession&&this._trackParamsAndReferrer()),this.options.saveParamsReferrerOncePerSession||this._trackParamsAndReferrer(),this._lastEventTime=p,Jt(this),this._sendEventsIfReady()}catch(e){L.log(e)}finally{"function"===R(r)&&r(this)}},Bt.prototype._trackParamsAndReferrer=function(){this.options.includeUtm&&this._initUtmData(),this.options.includeReferrer&&this._saveReferrer(this._getReferrer()),this.options.includeGclid&&this._saveGclid(this._getUrlParams())};var Kt=function(e,t){if("object"===R(t)){for(var n in t)t.hasOwnProperty(n)&&function(n){if(Gt.hasOwnProperty(n)){var r=t[n],i=R(Gt[n]);L.validateInput(r,n+" option",i)&&("boolean"===i?e[n]=!!r:("string"===i&&!L.isEmptyString(r)||"number"===i&&r>0)&&(e[n]=r))}}(n)}};Bt.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))},Bt.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},Bt.prototype._setInStorage=function(e,t,n){e.setItem(t+this._storageSuffix,n)};var zt=function(e){var t=e.cookieStorage.get(e.options.cookieName);if(!("object"===R(t)&&t.deviceId&&t.sessionId&&t.lastEventTime)){var n=function(e){var t=X.getItem(e);return X.removeItem(e),t},r="string"===R(e.options.apiKey)&&"_"+e.options.apiKey.slice(0,6)||"",i=n(m.DEVICE_ID+r),o=n(m.USER_ID+r),s=n(m.OPT_OUT+r);null!==s&&void 0!==s&&(s="true"===String(s));var a=parseInt(n(m.SESSION_ID)),u=parseInt(n(m.LAST_EVENT_TIME)),c=parseInt(n(m.LAST_EVENT_ID)),p=parseInt(n(m.LAST_IDENTIFY_ID)),l=parseInt(n(m.LAST_SEQUENCE_NUMBER)),d=function(e){return"object"===R(t)&&t[e]};e.options.deviceId=d("deviceId")||i,e.options.userId=d("userId")||o,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)),Jt(e)}},$t=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);"object"===R(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)))},Jt=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})};Bt.prototype._initUtmData=function(e,t){e=e||this._getUrlParams(),t=t||this.cookieStorage.get("__utmz");var n=Z(t,e);Wt(this,n)};var Wt=function(e,t){if("object"===R(t)&&0!==Object.keys(t).length){var n=new ee;for(var r in t)t.hasOwnProperty(r)&&(n.setOnce("initial_"+r,t[r]),n.set(r,t[r]));e.identify(n)}};Bt.prototype._getReferrer=function(){return document.referrer},Bt.prototype._getUrlParams=function(){return location.search},Bt.prototype._saveGclid=function(e){var t=L.getQueryParam("gclid",e);L.isEmptyString(t)||Wt(this,{gclid:t})},Bt.prototype._getDeviceIdFromUrlParam=function(e){return L.getQueryParam(m.AMP_DEVICE_ID_PARAM,e)},Bt.prototype._getReferringDomain=function(e){if(L.isEmptyString(e))return null;var t=e.split("/");return t.length>=3?t[2]:null},Bt.prototype._saveReferrer=function(e){if(!L.isEmptyString(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};Wt(this,t)}},Bt.prototype.saveEvents=function(){try{this._setInStorage(X,this.options.unsentKey,JSON.stringify(this._unsentEvents))}catch(e){}try{this._setInStorage(X,this.options.unsentIdentifyKey,JSON.stringify(this._unsentIdentifys))}catch(e){}},Bt.prototype.setDomain=function(e){if(L.validateInput(e,"domain","string"))try{this.cookieStorage.options({domain:e}),this.options.domain=this.cookieStorage.options().domain,$t(this),Jt(this)}catch(e){L.log(e)}},Bt.prototype.setUserId=function(e){try{this.options.userId=void 0!==e&&null!==e&&""+e||null,Jt(this)}catch(e){L.log(e)}},Bt.prototype.setGroup=function(e,t){if(this._apiKeySet("setGroup()")&&L.validateInput(e,"groupType","string")&&!L.isEmptyString(e)){var n={};n[e]=t;var r=(new ee).set(e,t);this._logEvent(m.IDENTIFY_EVENT,null,null,r.userPropertiesOperations,n,null,null)}},Bt.prototype.setOptOut=function(e){if(L.validateInput(e,"enable","boolean"))try{this.options.optOut=e,Jt(this)}catch(e){L.log(e)}},Bt.prototype.setSessionId=function(e){if(L.validateInput(e,"sessionId","number"))try{this._sessionId=e,Jt(this)}catch(e){L.log(e)}},Bt.prototype.regenerateDeviceId=function(){this.setDeviceId(Lt()+"R")},Bt.prototype.setDeviceId=function(e){if(L.validateInput(e,"deviceId","string"))try{L.isEmptyString(e)||(this.options.deviceId=""+e,Jt(this))}catch(e){L.log(e)}},Bt.prototype.setUserProperties=function(e){if(this._apiKeySet("setUserProperties()")&&L.validateInput(e,"userProperties","object")){var t=L.truncate(L.validateProperties(e));if(0!==Object.keys(t).length){var n=new ee;for(var r in t)t.hasOwnProperty(r)&&n.set(r,t[r]);this.identify(n)}}},Bt.prototype.clearUserProperties=function(){if(this._apiKeySet("clearUserProperties()")){var e=new ee;e.clearAll(),this.identify(e)}};var Yt=function(e,t){for(var n=0;n0)return this._logEvent(m.IDENTIFY_EVENT,null,null,e.userPropertiesOperations,null,null,t)}else L.log("Invalid identify input type. Expected Identify object but saw "+R(e));"function"===R(t)&&t(0,"No request sent")}else"function"===R(t)&&t(0,"No request sent")},Bt.prototype.setVersionName=function(e){L.validateInput(e,"versionName","string")&&(this.options.versionName=e)},Bt.prototype._logEvent=function(e,t,n,r,i,o,s){if($t(this),e&&!this.options.optOut)try{var a;a=e===m.IDENTIFY_EVENT?this.nextIdentifyId():this.nextEventId();var u=this.nextSequenceNumber(),c="number"===R(o)?o:(new Date).getTime();(!this._sessionId||!this._lastEventTime||c-this._lastEventTime>this.options.sessionTimeout)&&(this._sessionId=c),this._lastEventTime=c,Jt(this),r=r||{},n=n||{},t=t||{},i=i||{};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:L.truncate(L.validateProperties(t)),user_properties:L.truncate(L.validateProperties(r)),uuid:Lt(),library:{name:"amplitude-js",version:"3.7.0"},sequence_number:u,groups:L.truncate(L.validateGroups(i)),user_agent:this._userAgent};return e===m.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"!==R(s)||s(0,"No request sent"),a}catch(e){L.log(e)}else"function"===R(s)&&s(0,"No request sent")},Bt.prototype._limitEventsQueued=function(e){e.length>this.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount)},Bt.prototype.logEvent=function(e,t,n){return this.logEventWithTimestamp(e,t,null,n)},Bt.prototype.logEventWithTimestamp=function(e,t,n,r){return this._apiKeySet("logEvent()")&&L.validateInput(e,"eventType","string")&&!L.isEmptyString(e)?this._logEvent(e,t,null,null,null,n,r):("function"===R(r)&&r(0,"No request sent"),-1)},Bt.prototype.logEventWithGroups=function(e,t,n,r){return this._apiKeySet("logEventWithGroup()")&&L.validateInput(e,"eventType","string")?this._logEvent(e,t,null,null,n,null,r):("function"===R(r)&&r(0,"No request sent"),-1)};var Qt=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};Bt.prototype.logRevenueV2=function(e){if(this._apiKeySet("logRevenueV2()"))if("object"===R(e)&&e.hasOwnProperty("_q")&&(e=Yt(new qt,e)),e instanceof qt){if(e&&e._isValidRevenue())return this.logEvent(m.REVENUE_EVENT,e._toJSONObject())}else L.log("Invalid revenue input type. Expected Revenue object but saw "+R(e))},Bt.prototype.logRevenue=function(e,t,n){return this._apiKeySet("logRevenue()")&&Qt(e)&&(void 0===t||Qt(t))?this._logEvent(m.REVENUE_EVENT,{},{productId:n,special:"revenue_amount",quantity:t||1,price:e},null,null,null,null):-1},Bt.prototype.removeEvents=function(e,t){Xt(this,"_unsentEvents",e),Xt(this,"_unsentIdentifys",t)};var Xt=function(e,t,n){if(!(n<0)){for(var r=[],i=0;in&&r.push(e[t][i]);e[t]=r}};Bt.prototype.sendEvents=function(e){if(!this._apiKeySet("sendEvents()")||this._sending||this.options.optOut||0===this._unsentCount())"function"===R(e)&&e(0,"No request sent");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),i=r.maxEventId,o=r.maxIdentifyId,s=JSON.stringify(r.eventsToSend),a=(new Date).getTime(),u={client:this.options.apiKey,e:s,v:m.API_VERSION,upload_time:a,checksum:te(m.API_VERSION+this.options.apiKey+s+a)},c=this;new Mt(t,u).send(function(t,r){c._sending=!1;try{200===t&&"success"===r?(c.removeEvents(i,o),c.options.saveEvents&&c.saveEvents(),c._sendEventsIfReady(e)||"function"!==R(e)||e(t,r)):413===t?(1===c.options.uploadBatchSize&&c.removeEvents(i,o),c.options.uploadBatchSize=Math.ceil(n/2),c.sendEvents(e)):"function"===R(e)&&e(t,r)}catch(e){}})}},Bt.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],n=0,r=-1,i=0,o=-1;t.length=this._unsentIdentifys.length,u=n>=this._unsentEvents.length;if(u&&a){L.log("Merging Events and Identifys, less events and identifys than expected");break}a?r=(s=this._unsentEvents[n++]).event_id:u?o=(s=this._unsentIdentifys[i++]).event_id:!("sequence_number"in this._unsentEvents[n])||this._unsentEvents[n].sequence_number", - "version": "3.6.0", + "version": "3.7.0", "license": "MIT", "description": "Javascript library for Amplitude Analytics", "keywords": [ diff --git a/src/amplitude-snippet.js b/src/amplitude-snippet.js index 5a545ce4..2cc5e146 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://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.6.0-min.gz.js'; + as.src = 'https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.7.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 5047ed2c..e1d36212 100644 --- a/src/version.js +++ b/src/version.js @@ -1 +1 @@ -export default '3.6.0'; +export default '3.7.0';