New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

beaver-logger

Package Overview
Dependencies
Maintainers
6
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beaver-logger - npm Package Compare versions

Comparing version 4.0.35 to 4.0.36

8

dist/beaver-logger.js

@@ -1109,3 +1109,5 @@ !function(root, factory) {

prefix && (event = prefix + "_" + event);
var logPayload = _extends({}, objFilter(payload), {
var logPayload = _extends({}, objFilter(payload, (function(value) {
return null != value;
})), {
timestamp: Date.now().toString()

@@ -1164,3 +1166,5 @@ });

if (!dom_isBrowser()) return logger;
var trackingPayload = objFilter(payload);
var trackingPayload = objFilter(payload, (function(value) {
return null != value;
}));
for (var _i8 = 0; _i8 < trackingBuilders.length; _i8++) extendIfDefined(trackingPayload, (0,

@@ -1167,0 +1171,0 @@ trackingBuilders[_i8])(trackingPayload));

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("beaver",[],t):"object"==typeof exports?exports.beaver=t():e.beaver=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return{}.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(e){try{if(!e)return!1;if("undefined"!=typeof Promise&&e instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&e instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&e instanceof window.constructor)return!1;var t={}.toString;if(t){var n=t.call(e);if("[object Window]"===n||"[object global]"===n||"[object DOMWindow]"===n)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}n.r(t),n.d(t,"Logger",(function(){return te})),n.d(t,"LOG_LEVEL",(function(){return G})),n.d(t,"PROTOCOL",(function(){return J})),n.d(t,"canUseSendBeacon",(function(){return Z})),n.d(t,"extendIfDefined",(function(){return Y})),n.d(t,"isAmplitude",(function(){return $})),n.d(t,"sendBeacon",(function(){return Q})),n.d(t,"getHTTPTransport",(function(){return ee}));var i,a=[],u=[],c=0;function s(){if(!c&&i){var e=i;i=null,e.resolve()}}function f(){c+=1}function d(){c-=1,s()}var l=function(){function e(e){var t=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],e){var n,r,o=!1,i=!1,a=!1;f();try{e((function(e){a?t.resolve(e):(o=!0,n=e)}),(function(e){a?t.reject(e):(i=!0,r=e)}))}catch(e){return d(),void this.reject(e)}d(),a=!0,o?this.resolve(n):i&&this.reject(r)}}var t=e.prototype;return t.resolve=function(e){if(this.resolved||this.rejected)return this;if(o(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},t.reject=function(e){var t=this;if(this.resolved||this.rejected)return this;if(o(e))throw new Error("Can not reject promise with another promise");if(!e){var n=e&&"function"==typeof e.toString?e.toString():{}.toString.call(e);e=new Error("Expected reject to be called with Error, got "+n)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout((function(){t.errorHandled||function(e,t){if(-1===a.indexOf(e)){a.push(e),setTimeout((function(){throw e}),1);for(var n=0;n<u.length;n++)u[n](e,t)}}(e,t)}),1),this.dispatch(),this},t.asyncReject=function(e){return this.errorHandled=!0,this.reject(e),this},t.dispatch=function(){var t=this.resolved,n=this.rejected,r=this.handlers;if(!this.dispatching&&(t||n)){this.dispatching=!0,f();for(var i=function(e,t){return e.then((function(e){t.resolve(e)}),(function(e){t.reject(e)}))},a=0;a<r.length;a++){var u=r[a],c=u.onSuccess,s=u.onError,l=u.promise,h=void 0;if(t)try{h=c?c(this.value):this.value}catch(e){l.reject(e);continue}else if(n){if(!s){l.reject(this.error);continue}try{h=s(this.error)}catch(e){l.reject(e);continue}}if(h instanceof e&&(h.resolved||h.rejected)){var v=h;v.resolved?l.resolve(v.value):l.reject(v.error),v.errorHandled=!0}else o(h)?h instanceof e&&(h.resolved||h.rejected)?h.resolved?l.resolve(h.value):l.reject(h.error):i(h,l):l.resolve(h)}r.length=0,this.dispatching=!1,d()}},t.then=function(t,n){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.then expected a function for success handler");if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for error handler");var r=new e;return this.handlers.push({promise:r,onSuccess:t,onError:n}),this.errorHandled=!0,this.dispatch(),r},t.catch=function(e){return this.then(void 0,e)},t.finally=function(t){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.finally expected a function");return this.then((function(n){return e.try(t).then((function(){return n}))}),(function(n){return e.try(t).then((function(){throw n}))}))},t.timeout=function(e,t){var n=this;if(this.resolved||this.rejected)return this;var r=setTimeout((function(){n.resolved||n.rejected||n.reject(t||new Error("Promise timed out after "+e+"ms"))}),e);return this.then((function(e){return clearTimeout(r),e}))},t.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},t.lazy=function(){return this.errorHandled=!0,this},e.resolve=function(t){return t instanceof e?t:o(t)?new e((function(e,n){return t.then(e,n)})):(new e).resolve(t)},e.reject=function(t){return(new e).reject(t)},e.asyncReject=function(t){return(new e).asyncReject(t)},e.all=function(t){var n=new e,r=t.length,i=[].slice();if(!r)return n.resolve(i),n;for(var a=function(e,t,o){return t.then((function(t){i[e]=t,0==(r-=1)&&n.resolve(i)}),(function(e){o.reject(e)}))},u=0;u<t.length;u++){var c=t[u];if(c instanceof e){if(c.resolved){i[u]=c.value,r-=1;continue}}else if(!o(c)){i[u]=c,r-=1;continue}a(u,e.resolve(c),n)}return 0===r&&n.resolve(i),n},e.hash=function(t){var n={},r=[],i=function(e){if(t.hasOwnProperty(e)){var i=t[e];o(i)?r.push(i.then((function(t){n[e]=t}))):n[e]=i}};for(var a in t)i(a);return e.all(r).then((function(){return n}))},e.map=function(t,n){return e.all(t.map(n))},e.onPossiblyUnhandledException=function(e){return function(e){return u.push(e),{cancel:function(){u.splice(u.indexOf(e),1)}}}(e)},e.try=function(t,n,r){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.try expected a function");var o;f();try{o=t.apply(n,r||[])}catch(t){return d(),e.reject(t)}return d(),e.resolve(o)},e.delay=function(t){return new e((function(e){setTimeout(e,t)}))},e.isPromise=function(t){return!!(t&&t instanceof e)||o(t)},e.flush=function(){return t=i=i||new e,s(),t;var t},e}(),h="Call was rejected by callee.\r\n";function v(e){return void 0===e&&(e=window),e.location.protocol}function p(e){if(void 0===e&&(e=window),e.mockDomain){var t=e.mockDomain.split("//")[0];if(t)return t}return v(e)}function w(e){return void 0===e&&(e=window),"about:"===p(e)}function y(e){try{return!0}catch(e){}return!1}function m(e){void 0===e&&(e=window);var t=e.location;if(!t)throw new Error("Can not read window location");var n=v(e);if(!n)throw new Error("Can not read window protocol");if("file:"===n)return"file://";if("about:"===n){var r=function(e){if(void 0===e&&(e=window),e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}(e);return r&&y()?m(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return n+"//"+o}function g(e){void 0===e&&(e=window);var t=m(e);return t&&e.mockDomain&&0===e.mockDomain.indexOf("mock:")?e.mockDomain:t}function b(e){if(!function(e){try{if(e===window)return!0}catch(e){}try{var t=Object.getOwnPropertyDescriptor(e,"location");if(t&&!1===t.enumerable)return!1}catch(e){}try{if(w(e)&&y())return!0}catch(e){}try{if(function(e){return void 0===e&&(e=window),"mock:"===p(e)}(e)&&y())return!0}catch(e){}try{if(m(e)===m(window))return!0}catch(e){}return!1}(e))return!1;try{if(e===window)return!0;if(w(e)&&y())return!0;if(g(window)===g(e))return!0}catch(e){}return!1}var j=[],E=[];function O(e,t){void 0===t&&(t=!0);try{if(e===window)return!1}catch(e){return!0}try{if(!e)return!0}catch(e){return!0}try{if(e.closed)return!0}catch(e){return!e||e.message!==h}if(t&&b(e))try{if(e.mockclosed)return!0}catch(e){}try{if(!e.parent||!e.top)return!0}catch(e){}var n=function(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}(j,e);if(-1!==n){var r=E[n];if(r&&function(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var t=e.ownerDocument;if(t&&t.documentElement&&!t.documentElement.contains(e)){for(var n=e;n.parentNode&&n.parentNode!==n;)n=n.parentNode;if(!n.host||!t.documentElement.contains(n.host))return!0}return!1}(r))return!0}return!1}function _(e){try{if(e===window)return!0}catch(e){if(e&&e.message===h)return!0}try{if("[object Window]"==={}.toString.call(e))return!0}catch(e){if(e&&e.message===h)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&e.self===e)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&e.parent===e)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&e.top===e)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&"__unlikely_value__"===e.__cross_domain_utils_window_check__)return!1}catch(e){return!0}try{if("postMessage"in e&&"self"in e&&"location"in e)return!0}catch(e){}return!1}function k(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}var x,S=function(){function e(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,t={};return Object.freeze(t),e.set(t,"__testvalue__"),"__testvalue__"===e.get(t)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}var t=e.prototype;return t._cleanupClosedWindows=function(){for(var e=this.weakmap,t=this.keys,n=0;n<t.length;n++){var r=t[n];if(_(r)&&O(r)){if(e)try{e.delete(r)}catch(e){}t.splice(n,1),this.values.splice(n,1),n-=1}}},t.isSafeToReadWrite=function(e){return!_(e)},t.set=function(e,t){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{n.set(e,t)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var r=this.name,o=e[r];return void(o&&o[0]===e?o[1]=t:Object.defineProperty(e,r,{value:[e,t],writable:!0}))}catch(e){}this._cleanupClosedWindows();var i=this.keys,a=this.values,u=k(i,e);-1===u?(i.push(e),a.push(t)):a[u]=t},t.get=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{if(t.has(e))return t.get(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var n=e[this.name];return n&&n[0]===e?n[1]:void 0}catch(e){}this._cleanupClosedWindows();var r=k(this.keys,e);if(-1!==r)return this.values[r]},t.delete=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var n=e[this.name];n&&n[0]===e&&(n[0]=n[1]=void 0)}catch(e){}this._cleanupClosedWindows();var r=this.keys,o=k(r,e);-1!==o&&(r.splice(o,1),this.values.splice(o,1))},t.has=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{if(t.has(e))return!0}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var n=e[this.name];return!(!n||n[0]!==e)}catch(e){}return this._cleanupClosedWindows(),-1!==k(this.keys,e)},t.getOrSet=function(e,t){if(this.has(e))return this.get(e);var n=t();return this.set(e,n),n},e}();function B(e){return e.name||e.__name__||e.displayName||"anonymous"}function R(e,t){try{delete e.name,e.name=t}catch(e){}return e.__name__=e.displayName=t,e}function C(){var e="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,(function(){return e.charAt(Math.floor(Math.random()*e.length))}))+"_"+function(e){if("function"==typeof btoa)return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))}))).replace(/[=]/g,"");if("undefined"!=typeof Buffer)return Buffer.from(e,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function P(e){try{return JSON.stringify([].slice.call(e),(function(e,t){return"function"==typeof t?"memoize["+function(e){if(x=x||new S,null==e||"object"!=typeof e&&"function"!=typeof e)throw new Error("Invalid object");var t=x.get(e);return t||(t=typeof e+":"+C(),x.set(e,t)),t}(t)+"]":function(e){var t=!1;try{(e instanceof window.Element||null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument)&&(t=!0)}catch(e){}return t}(t)?{}:t}))}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}function W(){return{}}var T=0,L=0;function N(e,t){void 0===t&&(t={});var n,r,o=t.thisNamespace,i=void 0!==o&&o,a=t.time,u=T;T+=1;var c=function(){for(var t=arguments.length,o=new Array(t),c=0;c<t;c++)o[c]=arguments[c];var s,f;u<L&&(n=null,r=null,u=T,T+=1),s=i?(r=r||new S).getOrSet(this,W):n=n||{};try{f=P(o)}catch(t){return e.apply(this,arguments)}var d=s[f];if(d&&a&&Date.now()-d.time<a&&(delete s[f],d=null),d)return d.value;var l=Date.now(),h=e.apply(this,arguments);return s[f]={time:l,value:h},h};return c.reset=function(){n=null,r=null},R(c,(t.name||B(e))+"::memoized")}function A(){}function D(e,t){void 0===t&&(t=Boolean);var n={};for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)&&(n[r]=e[r]);return n}function M(){return Boolean(document.body)&&"complete"===document.readyState}function I(){return Boolean(document.body)&&"interactive"===document.readyState}function H(){return"undefined"!=typeof window&&void 0!==window.location}N.clear=function(){L=T},N((function(e){if(Object.values)return Object.values(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t})),Error,N((function(){return new l((function(e){if(M()||I())return e();var t=setInterval((function(){if(M()||I())return clearInterval(t),e()}),10)}))}));var U="undefined"!=typeof document?document.currentScript:null,z=N((function(){if(U)return U;if(U=function(){try{var e=function(){try{throw new Error("_")}catch(e){return e.stack||""}}(),t=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(e),n=t&&t[1];if(!n)return;for(var r=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();r<o.length;r++){var i=o[r];if(i.src&&i.src===n)return i}}catch(e){}}())return U;throw new Error("Can not determine current script")})),F=C();N((function(){var e;try{e=z()}catch(e){return F}var t=e.getAttribute("data-uid");if(t&&"string"==typeof t)return t;if((t=e.getAttribute("data-uid-auto"))&&"string"==typeof t)return t;if(e.src){var n=function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify({src:e.src,dataset:e.dataset}));t="uid_"+n.slice(n.length-30)}else t=C();return e.setAttribute("data-uid-auto",t),t}));var q=[],G={DEBUG:"debug",INFO:"info",WARN:"warn",ERROR:"error"},J={FILE:"file:"},K=[G.WARN,G.ERROR],V=[G.ERROR,G.WARN,G.INFO,G.DEBUG],X=G.WARN,Z=function(e){var t=e.headers,n=e.enableSendBeacon,r=t&&Object.keys(t).length;return!!(window&&window.navigator.sendBeacon&&!r&&n&&window.Blob)},$=function(e){return"https://api2.amplitude.com/2/httpapi"===e},Q=function(e){var t=e.win,n=void 0===t?window:t,r=e.url,o=e.data,i=e.useBlob,a=void 0===i||i;try{var u=JSON.stringify(o);if(!n.navigator.sendBeacon)throw new Error("No sendBeacon available");if(a){var c=new Blob([u],{type:"application/json"});return n.navigator.sendBeacon(r,c)}return n.navigator.sendBeacon(r,u)}catch(e){return!1}},Y=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function ee(e){void 0===e&&(e=window);var t=b(e)?function(e){if(!b(e))throw new Error("Expected window to be same domain");return e}(e):window;return function(e){var n=e.url,r=e.method,o=e.headers,i=e.json,a=e.enableSendBeacon,u=void 0!==a&&a;return l.try((function(){var e=!1;return Z({headers:o,enableSendBeacon:u})&&(e=$(n)?Q({win:t,url:n,data:i,useBlob:!1}):Q({win:t,url:n,data:i,useBlob:!0})),e||function(e){var t=e.url,n=e.method,r=void 0===n?"get":n,o=e.headers,i=void 0===o?{}:o,a=e.json,u=e.data,c=e.body,s=e.win,f=void 0===s?window:s,d=e.timeout,h=void 0===d?0:d;return new l((function(e,n){if(a&&u||a&&c||u&&a)throw new Error("Only options.json or options.data or options.body should be passed");for(var o={},s=0,d=Object.keys(i);s<d.length;s++){var l=d[s];o[l.toLowerCase()]=i[l]}a?o["content-type"]=o["content-type"]||"application/json":(u||c)&&(o["content-type"]=o["content-type"]||"application/x-www-form-urlencoded; charset=utf-8"),o.accept=o.accept||"application/json";for(var v=0;v<q.length;v++)for(var p=(0,q[v])(),w=0,y=Object.keys(p);w<y.length;w++){var m=y[w];o[m.toLowerCase()]=p[m]}var g=new f.XMLHttpRequest;for(var b in g.addEventListener("load",(function(){var o=function(e){void 0===e&&(e="");for(var t={},n=0,r=e.trim().split("\n");n<r.length;n++){var o=r[n].split(":"),i=o[0],a=o.slice(1);t[i.toLowerCase()]=a.join(":").trim()}return t}(this.getAllResponseHeaders());if(!this.status)return n(new Error("Request to "+r.toLowerCase()+" "+t+" failed: no response status code."));var i=o["content-type"],a=i&&(0===i.indexOf("application/json")||0===i.indexOf("text/json")),u=this.responseText;try{u=JSON.parse(u)}catch(e){if(a)return n(new Error("Invalid json: "+this.responseText+"."))}return e({status:this.status,headers:o,body:u})}),!1),g.addEventListener("error",(function(e){n(new Error("Request to "+r.toLowerCase()+" "+t+" failed: "+e.toString()+"."))}),!1),g.open(r,t,!0),o)o.hasOwnProperty(b)&&g.setRequestHeader(b,o[b]);a?c=JSON.stringify(a):u&&(c=Object.keys(u).map((function(e){return encodeURIComponent(e)+"="+(u?encodeURIComponent(u[e]):"")})).join("&")),g.timeout=h,g.ontimeout=function(){n(new Error("Request to "+r.toLowerCase()+" "+t+" has timed out"))},g.send(c)}))}({win:t,url:n,method:r,headers:o,json:i})})).then(A)}}function te(e){var t=e.url,n=e.prefix,o=e.logLevel,i=void 0===o?X:o,a=e.transport,u=void 0===a?ee():a,c=e.amplitudeApiKey,s=e.flushInterval,f=void 0===s?6e4:s,d=e.enableSendBeacon,h=void 0!==d&&d,v=[],p=[],w=[],y=[],m=[],g=[];function b(e,t,n){if(H()&&window.console&&window.console.log&&!(V.indexOf(e)>V.indexOf(i))){var r=[t];r.push(n),(n.error||n.warning)&&r.push("\n\n",n.error||n.warning);try{window.console[e]&&window.console[e].apply?window.console[e].apply(window.console,r):window.console.log&&window.console.log.apply&&window.console.log.apply(window.console,r)}catch(e){}}}function j(){return l.try((function(){if(H()&&window.location.protocol!==J.FILE&&(v.length||p.length)){for(var e={},n=0;n<y.length;n++)Y(e,(0,y[n])(e));for(var o,i={},a=0;a<g.length;a++)Y(i,(0,g[a])(i));return t&&(o=u({method:"POST",url:t,headers:i,json:{events:v,meta:e,tracking:p},enableSendBeacon:h}).catch(A)),c&&u({method:"POST",url:"https://api2.amplitude.com/2/httpapi",headers:{},json:{api_key:c,events:p.map((function(e){return r({event_type:e.transition_name||"event",event_properties:e},e)}))},enableSendBeacon:h}).catch(A),v=[],p=[],l.resolve(o).then(A)}}))}var E,O,_,k,x=(void 0===O&&(O=50),R((function(){k&&clearTimeout(k);var e=_=_||new l;return k=setTimeout((function(){_=null,k=null,l.try(E).then((function(t){e.resolve(t)}),(function(t){e.reject(t)}))}),O),e}),B(E=j)+"::promiseDebounced"));function S(e,t,o){if(void 0===o&&(o={}),!H())return P;n&&(t=n+"_"+t);for(var i=r({},D(o),{timestamp:Date.now().toString()}),a=0;a<w.length;a++)Y(i,(0,w[a])(i));return function(e,t,n){v.push({level:e,event:t,payload:n}),-1!==K.indexOf(e)&&x()}(e,t,i),b(e,t,i),P}function C(e,t){return e.push(t),P}H()&&function(e,t){!function n(){setTimeout((function(){e(),n()}),t)}()}(x,f),"object"==typeof window&&(window.addEventListener("beforeunload",(function(){j()})),window.addEventListener("unload",(function(){j()})),window.addEventListener("pagehide",(function(){j()})));var P={debug:function(e,t){return S(G.DEBUG,e,t)},info:function(e,t){return S(G.INFO,e,t)},warn:function(e,t){return S(G.WARN,e,t)},error:function(e,t){return S(G.ERROR,e,t)},track:function(e){if(void 0===e&&(e={}),!H())return P;for(var t=D(e),n=0;n<m.length;n++)Y(t,(0,m[n])(t));return b(G.DEBUG,"track",t),p.push(t),P},flush:x,immediateFlush:j,addPayloadBuilder:function(e){return C(w,e)},addMetaBuilder:function(e){return C(y,e)},addTrackingBuilder:function(e){return C(m,e)},addHeaderBuilder:function(e){return C(g,e)},setTransport:function(e){return u=e,P},configure:function(e){return e.url&&(t=e.url),e.prefix&&(n=e.prefix),e.logLevel&&(i=e.logLevel),e.transport&&(u=e.transport),e.amplitudeApiKey&&(c=e.amplitudeApiKey),e.flushInterval&&(f=e.flushInterval),e.enableSendBeacon&&(h=e.enableSendBeacon),P}};return P}}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("beaver",[],t):"object"==typeof exports?exports.beaver=t():e.beaver=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return{}.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(e){try{if(!e)return!1;if("undefined"!=typeof Promise&&e instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&e instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&e instanceof window.constructor)return!1;var t={}.toString;if(t){var n=t.call(e);if("[object Window]"===n||"[object global]"===n||"[object DOMWindow]"===n)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}n.r(t),n.d(t,"Logger",(function(){return te})),n.d(t,"LOG_LEVEL",(function(){return G})),n.d(t,"PROTOCOL",(function(){return J})),n.d(t,"canUseSendBeacon",(function(){return Z})),n.d(t,"extendIfDefined",(function(){return Y})),n.d(t,"isAmplitude",(function(){return $})),n.d(t,"sendBeacon",(function(){return Q})),n.d(t,"getHTTPTransport",(function(){return ee}));var i,a=[],u=[],c=0;function s(){if(!c&&i){var e=i;i=null,e.resolve()}}function f(){c+=1}function d(){c-=1,s()}var l=function(){function e(e){var t=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],e){var n,r,o=!1,i=!1,a=!1;f();try{e((function(e){a?t.resolve(e):(o=!0,n=e)}),(function(e){a?t.reject(e):(i=!0,r=e)}))}catch(e){return d(),void this.reject(e)}d(),a=!0,o?this.resolve(n):i&&this.reject(r)}}var t=e.prototype;return t.resolve=function(e){if(this.resolved||this.rejected)return this;if(o(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},t.reject=function(e){var t=this;if(this.resolved||this.rejected)return this;if(o(e))throw new Error("Can not reject promise with another promise");if(!e){var n=e&&"function"==typeof e.toString?e.toString():{}.toString.call(e);e=new Error("Expected reject to be called with Error, got "+n)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout((function(){t.errorHandled||function(e,t){if(-1===a.indexOf(e)){a.push(e),setTimeout((function(){throw e}),1);for(var n=0;n<u.length;n++)u[n](e,t)}}(e,t)}),1),this.dispatch(),this},t.asyncReject=function(e){return this.errorHandled=!0,this.reject(e),this},t.dispatch=function(){var t=this.resolved,n=this.rejected,r=this.handlers;if(!this.dispatching&&(t||n)){this.dispatching=!0,f();for(var i=function(e,t){return e.then((function(e){t.resolve(e)}),(function(e){t.reject(e)}))},a=0;a<r.length;a++){var u=r[a],c=u.onSuccess,s=u.onError,l=u.promise,h=void 0;if(t)try{h=c?c(this.value):this.value}catch(e){l.reject(e);continue}else if(n){if(!s){l.reject(this.error);continue}try{h=s(this.error)}catch(e){l.reject(e);continue}}if(h instanceof e&&(h.resolved||h.rejected)){var v=h;v.resolved?l.resolve(v.value):l.reject(v.error),v.errorHandled=!0}else o(h)?h instanceof e&&(h.resolved||h.rejected)?h.resolved?l.resolve(h.value):l.reject(h.error):i(h,l):l.resolve(h)}r.length=0,this.dispatching=!1,d()}},t.then=function(t,n){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.then expected a function for success handler");if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for error handler");var r=new e;return this.handlers.push({promise:r,onSuccess:t,onError:n}),this.errorHandled=!0,this.dispatch(),r},t.catch=function(e){return this.then(void 0,e)},t.finally=function(t){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.finally expected a function");return this.then((function(n){return e.try(t).then((function(){return n}))}),(function(n){return e.try(t).then((function(){throw n}))}))},t.timeout=function(e,t){var n=this;if(this.resolved||this.rejected)return this;var r=setTimeout((function(){n.resolved||n.rejected||n.reject(t||new Error("Promise timed out after "+e+"ms"))}),e);return this.then((function(e){return clearTimeout(r),e}))},t.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},t.lazy=function(){return this.errorHandled=!0,this},e.resolve=function(t){return t instanceof e?t:o(t)?new e((function(e,n){return t.then(e,n)})):(new e).resolve(t)},e.reject=function(t){return(new e).reject(t)},e.asyncReject=function(t){return(new e).asyncReject(t)},e.all=function(t){var n=new e,r=t.length,i=[].slice();if(!r)return n.resolve(i),n;for(var a=function(e,t,o){return t.then((function(t){i[e]=t,0==(r-=1)&&n.resolve(i)}),(function(e){o.reject(e)}))},u=0;u<t.length;u++){var c=t[u];if(c instanceof e){if(c.resolved){i[u]=c.value,r-=1;continue}}else if(!o(c)){i[u]=c,r-=1;continue}a(u,e.resolve(c),n)}return 0===r&&n.resolve(i),n},e.hash=function(t){var n={},r=[],i=function(e){if(t.hasOwnProperty(e)){var i=t[e];o(i)?r.push(i.then((function(t){n[e]=t}))):n[e]=i}};for(var a in t)i(a);return e.all(r).then((function(){return n}))},e.map=function(t,n){return e.all(t.map(n))},e.onPossiblyUnhandledException=function(e){return function(e){return u.push(e),{cancel:function(){u.splice(u.indexOf(e),1)}}}(e)},e.try=function(t,n,r){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.try expected a function");var o;f();try{o=t.apply(n,r||[])}catch(t){return d(),e.reject(t)}return d(),e.resolve(o)},e.delay=function(t){return new e((function(e){setTimeout(e,t)}))},e.isPromise=function(t){return!!(t&&t instanceof e)||o(t)},e.flush=function(){return t=i=i||new e,s(),t;var t},e}(),h="Call was rejected by callee.\r\n";function v(e){return void 0===e&&(e=window),e.location.protocol}function p(e){if(void 0===e&&(e=window),e.mockDomain){var t=e.mockDomain.split("//")[0];if(t)return t}return v(e)}function w(e){return void 0===e&&(e=window),"about:"===p(e)}function y(e){try{return!0}catch(e){}return!1}function m(e){void 0===e&&(e=window);var t=e.location;if(!t)throw new Error("Can not read window location");var n=v(e);if(!n)throw new Error("Can not read window protocol");if("file:"===n)return"file://";if("about:"===n){var r=function(e){if(void 0===e&&(e=window),e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}(e);return r&&y()?m(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return n+"//"+o}function g(e){void 0===e&&(e=window);var t=m(e);return t&&e.mockDomain&&0===e.mockDomain.indexOf("mock:")?e.mockDomain:t}function b(e){if(!function(e){try{if(e===window)return!0}catch(e){}try{var t=Object.getOwnPropertyDescriptor(e,"location");if(t&&!1===t.enumerable)return!1}catch(e){}try{if(w(e)&&y())return!0}catch(e){}try{if(function(e){return void 0===e&&(e=window),"mock:"===p(e)}(e)&&y())return!0}catch(e){}try{if(m(e)===m(window))return!0}catch(e){}return!1}(e))return!1;try{if(e===window)return!0;if(w(e)&&y())return!0;if(g(window)===g(e))return!0}catch(e){}return!1}var j=[],E=[];function O(e,t){void 0===t&&(t=!0);try{if(e===window)return!1}catch(e){return!0}try{if(!e)return!0}catch(e){return!0}try{if(e.closed)return!0}catch(e){return!e||e.message!==h}if(t&&b(e))try{if(e.mockclosed)return!0}catch(e){}try{if(!e.parent||!e.top)return!0}catch(e){}var n=function(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}(j,e);if(-1!==n){var r=E[n];if(r&&function(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var t=e.ownerDocument;if(t&&t.documentElement&&!t.documentElement.contains(e)){for(var n=e;n.parentNode&&n.parentNode!==n;)n=n.parentNode;if(!n.host||!t.documentElement.contains(n.host))return!0}return!1}(r))return!0}return!1}function _(e){try{if(e===window)return!0}catch(e){if(e&&e.message===h)return!0}try{if("[object Window]"==={}.toString.call(e))return!0}catch(e){if(e&&e.message===h)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&e.self===e)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&e.parent===e)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&e.top===e)return!0}catch(e){if(e&&e.message===h)return!0}try{if(e&&"__unlikely_value__"===e.__cross_domain_utils_window_check__)return!1}catch(e){return!0}try{if("postMessage"in e&&"self"in e&&"location"in e)return!0}catch(e){}return!1}function k(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}var x,S=function(){function e(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,t={};return Object.freeze(t),e.set(t,"__testvalue__"),"__testvalue__"===e.get(t)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}var t=e.prototype;return t._cleanupClosedWindows=function(){for(var e=this.weakmap,t=this.keys,n=0;n<t.length;n++){var r=t[n];if(_(r)&&O(r)){if(e)try{e.delete(r)}catch(e){}t.splice(n,1),this.values.splice(n,1),n-=1}}},t.isSafeToReadWrite=function(e){return!_(e)},t.set=function(e,t){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{n.set(e,t)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var r=this.name,o=e[r];return void(o&&o[0]===e?o[1]=t:Object.defineProperty(e,r,{value:[e,t],writable:!0}))}catch(e){}this._cleanupClosedWindows();var i=this.keys,a=this.values,u=k(i,e);-1===u?(i.push(e),a.push(t)):a[u]=t},t.get=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{if(t.has(e))return t.get(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var n=e[this.name];return n&&n[0]===e?n[1]:void 0}catch(e){}this._cleanupClosedWindows();var r=k(this.keys,e);if(-1!==r)return this.values[r]},t.delete=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var n=e[this.name];n&&n[0]===e&&(n[0]=n[1]=void 0)}catch(e){}this._cleanupClosedWindows();var r=this.keys,o=k(r,e);-1!==o&&(r.splice(o,1),this.values.splice(o,1))},t.has=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{if(t.has(e))return!0}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var n=e[this.name];return!(!n||n[0]!==e)}catch(e){}return this._cleanupClosedWindows(),-1!==k(this.keys,e)},t.getOrSet=function(e,t){if(this.has(e))return this.get(e);var n=t();return this.set(e,n),n},e}();function B(e){return e.name||e.__name__||e.displayName||"anonymous"}function R(e,t){try{delete e.name,e.name=t}catch(e){}return e.__name__=e.displayName=t,e}function C(){var e="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,(function(){return e.charAt(Math.floor(Math.random()*e.length))}))+"_"+function(e){if("function"==typeof btoa)return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))}))).replace(/[=]/g,"");if("undefined"!=typeof Buffer)return Buffer.from(e,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function P(e){try{return JSON.stringify([].slice.call(e),(function(e,t){return"function"==typeof t?"memoize["+function(e){if(x=x||new S,null==e||"object"!=typeof e&&"function"!=typeof e)throw new Error("Invalid object");var t=x.get(e);return t||(t=typeof e+":"+C(),x.set(e,t)),t}(t)+"]":function(e){var t=!1;try{(e instanceof window.Element||null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument)&&(t=!0)}catch(e){}return t}(t)?{}:t}))}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}function W(){return{}}var T=0,L=0;function N(e,t){void 0===t&&(t={});var n,r,o=t.thisNamespace,i=void 0!==o&&o,a=t.time,u=T;T+=1;var c=function(){for(var t=arguments.length,o=new Array(t),c=0;c<t;c++)o[c]=arguments[c];var s,f;u<L&&(n=null,r=null,u=T,T+=1),s=i?(r=r||new S).getOrSet(this,W):n=n||{};try{f=P(o)}catch(t){return e.apply(this,arguments)}var d=s[f];if(d&&a&&Date.now()-d.time<a&&(delete s[f],d=null),d)return d.value;var l=Date.now(),h=e.apply(this,arguments);return s[f]={time:l,value:h},h};return c.reset=function(){n=null,r=null},R(c,(t.name||B(e))+"::memoized")}function A(){}function D(e,t){void 0===t&&(t=Boolean);var n={};for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)&&(n[r]=e[r]);return n}function M(){return Boolean(document.body)&&"complete"===document.readyState}function I(){return Boolean(document.body)&&"interactive"===document.readyState}function H(){return"undefined"!=typeof window&&void 0!==window.location}N.clear=function(){L=T},N((function(e){if(Object.values)return Object.values(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t})),Error,N((function(){return new l((function(e){if(M()||I())return e();var t=setInterval((function(){if(M()||I())return clearInterval(t),e()}),10)}))}));var U="undefined"!=typeof document?document.currentScript:null,z=N((function(){if(U)return U;if(U=function(){try{var e=function(){try{throw new Error("_")}catch(e){return e.stack||""}}(),t=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(e),n=t&&t[1];if(!n)return;for(var r=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();r<o.length;r++){var i=o[r];if(i.src&&i.src===n)return i}}catch(e){}}())return U;throw new Error("Can not determine current script")})),F=C();N((function(){var e;try{e=z()}catch(e){return F}var t=e.getAttribute("data-uid");if(t&&"string"==typeof t)return t;if((t=e.getAttribute("data-uid-auto"))&&"string"==typeof t)return t;if(e.src){var n=function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify({src:e.src,dataset:e.dataset}));t="uid_"+n.slice(n.length-30)}else t=C();return e.setAttribute("data-uid-auto",t),t}));var q=[],G={DEBUG:"debug",INFO:"info",WARN:"warn",ERROR:"error"},J={FILE:"file:"},K=[G.WARN,G.ERROR],V=[G.ERROR,G.WARN,G.INFO,G.DEBUG],X=G.WARN,Z=function(e){var t=e.headers,n=e.enableSendBeacon,r=t&&Object.keys(t).length;return!!(window&&window.navigator.sendBeacon&&!r&&n&&window.Blob)},$=function(e){return"https://api2.amplitude.com/2/httpapi"===e},Q=function(e){var t=e.win,n=void 0===t?window:t,r=e.url,o=e.data,i=e.useBlob,a=void 0===i||i;try{var u=JSON.stringify(o);if(!n.navigator.sendBeacon)throw new Error("No sendBeacon available");if(a){var c=new Blob([u],{type:"application/json"});return n.navigator.sendBeacon(r,c)}return n.navigator.sendBeacon(r,u)}catch(e){return!1}},Y=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function ee(e){void 0===e&&(e=window);var t=b(e)?function(e){if(!b(e))throw new Error("Expected window to be same domain");return e}(e):window;return function(e){var n=e.url,r=e.method,o=e.headers,i=e.json,a=e.enableSendBeacon,u=void 0!==a&&a;return l.try((function(){var e=!1;return Z({headers:o,enableSendBeacon:u})&&(e=$(n)?Q({win:t,url:n,data:i,useBlob:!1}):Q({win:t,url:n,data:i,useBlob:!0})),e||function(e){var t=e.url,n=e.method,r=void 0===n?"get":n,o=e.headers,i=void 0===o?{}:o,a=e.json,u=e.data,c=e.body,s=e.win,f=void 0===s?window:s,d=e.timeout,h=void 0===d?0:d;return new l((function(e,n){if(a&&u||a&&c||u&&a)throw new Error("Only options.json or options.data or options.body should be passed");for(var o={},s=0,d=Object.keys(i);s<d.length;s++){var l=d[s];o[l.toLowerCase()]=i[l]}a?o["content-type"]=o["content-type"]||"application/json":(u||c)&&(o["content-type"]=o["content-type"]||"application/x-www-form-urlencoded; charset=utf-8"),o.accept=o.accept||"application/json";for(var v=0;v<q.length;v++)for(var p=(0,q[v])(),w=0,y=Object.keys(p);w<y.length;w++){var m=y[w];o[m.toLowerCase()]=p[m]}var g=new f.XMLHttpRequest;for(var b in g.addEventListener("load",(function(){var o=function(e){void 0===e&&(e="");for(var t={},n=0,r=e.trim().split("\n");n<r.length;n++){var o=r[n].split(":"),i=o[0],a=o.slice(1);t[i.toLowerCase()]=a.join(":").trim()}return t}(this.getAllResponseHeaders());if(!this.status)return n(new Error("Request to "+r.toLowerCase()+" "+t+" failed: no response status code."));var i=o["content-type"],a=i&&(0===i.indexOf("application/json")||0===i.indexOf("text/json")),u=this.responseText;try{u=JSON.parse(u)}catch(e){if(a)return n(new Error("Invalid json: "+this.responseText+"."))}return e({status:this.status,headers:o,body:u})}),!1),g.addEventListener("error",(function(e){n(new Error("Request to "+r.toLowerCase()+" "+t+" failed: "+e.toString()+"."))}),!1),g.open(r,t,!0),o)o.hasOwnProperty(b)&&g.setRequestHeader(b,o[b]);a?c=JSON.stringify(a):u&&(c=Object.keys(u).map((function(e){return encodeURIComponent(e)+"="+(u?encodeURIComponent(u[e]):"")})).join("&")),g.timeout=h,g.ontimeout=function(){n(new Error("Request to "+r.toLowerCase()+" "+t+" has timed out"))},g.send(c)}))}({win:t,url:n,method:r,headers:o,json:i})})).then(A)}}function te(e){var t=e.url,n=e.prefix,o=e.logLevel,i=void 0===o?X:o,a=e.transport,u=void 0===a?ee():a,c=e.amplitudeApiKey,s=e.flushInterval,f=void 0===s?6e4:s,d=e.enableSendBeacon,h=void 0!==d&&d,v=[],p=[],w=[],y=[],m=[],g=[];function b(e,t,n){if(H()&&window.console&&window.console.log&&!(V.indexOf(e)>V.indexOf(i))){var r=[t];r.push(n),(n.error||n.warning)&&r.push("\n\n",n.error||n.warning);try{window.console[e]&&window.console[e].apply?window.console[e].apply(window.console,r):window.console.log&&window.console.log.apply&&window.console.log.apply(window.console,r)}catch(e){}}}function j(){return l.try((function(){if(H()&&window.location.protocol!==J.FILE&&(v.length||p.length)){for(var e={},n=0;n<y.length;n++)Y(e,(0,y[n])(e));for(var o,i={},a=0;a<g.length;a++)Y(i,(0,g[a])(i));return t&&(o=u({method:"POST",url:t,headers:i,json:{events:v,meta:e,tracking:p},enableSendBeacon:h}).catch(A)),c&&u({method:"POST",url:"https://api2.amplitude.com/2/httpapi",headers:{},json:{api_key:c,events:p.map((function(e){return r({event_type:e.transition_name||"event",event_properties:e},e)}))},enableSendBeacon:h}).catch(A),v=[],p=[],l.resolve(o).then(A)}}))}var E,O,_,k,x=(void 0===O&&(O=50),R((function(){k&&clearTimeout(k);var e=_=_||new l;return k=setTimeout((function(){_=null,k=null,l.try(E).then((function(t){e.resolve(t)}),(function(t){e.reject(t)}))}),O),e}),B(E=j)+"::promiseDebounced"));function S(e,t,o){if(void 0===o&&(o={}),!H())return P;n&&(t=n+"_"+t);for(var i=r({},D(o,(function(e){return null!=e})),{timestamp:Date.now().toString()}),a=0;a<w.length;a++)Y(i,(0,w[a])(i));return function(e,t,n){v.push({level:e,event:t,payload:n}),-1!==K.indexOf(e)&&x()}(e,t,i),b(e,t,i),P}function C(e,t){return e.push(t),P}H()&&function(e,t){!function n(){setTimeout((function(){e(),n()}),t)}()}(x,f),"object"==typeof window&&(window.addEventListener("beforeunload",(function(){j()})),window.addEventListener("unload",(function(){j()})),window.addEventListener("pagehide",(function(){j()})));var P={debug:function(e,t){return S(G.DEBUG,e,t)},info:function(e,t){return S(G.INFO,e,t)},warn:function(e,t){return S(G.WARN,e,t)},error:function(e,t){return S(G.ERROR,e,t)},track:function(e){if(void 0===e&&(e={}),!H())return P;for(var t=D(e,(function(e){return null!=e})),n=0;n<m.length;n++)Y(t,(0,m[n])(t));return b(G.DEBUG,"track",t),p.push(t),P},flush:x,immediateFlush:j,addPayloadBuilder:function(e){return C(w,e)},addMetaBuilder:function(e){return C(y,e)},addTrackingBuilder:function(e){return C(m,e)},addHeaderBuilder:function(e){return C(g,e)},setTransport:function(e){return u=e,P},configure:function(e){return e.url&&(t=e.url),e.prefix&&(n=e.prefix),e.logLevel&&(i=e.logLevel),e.transport&&(u=e.transport),e.amplitudeApiKey&&(c=e.amplitudeApiKey),e.flushInterval&&(f=e.flushInterval),e.enableSendBeacon&&(h=e.enableSendBeacon),P}};return P}}])}));
//# sourceMappingURL=beaver-logger.min.js.map

@@ -9,14 +9,12 @@ import { ZalgoPromise } from 'zalgo-promise/src';

}
var win = isSameDomain(httpWin) ? assertSameDomain(httpWin) : window;
return function (_ref) {
var url = _ref.url,
method = _ref.method,
headers = _ref.headers,
json = _ref.json,
_ref$enableSendBeacon = _ref.enableSendBeacon,
enableSendBeacon = _ref$enableSendBeacon === void 0 ? false : _ref$enableSendBeacon;
method = _ref.method,
headers = _ref.headers,
json = _ref.json,
_ref$enableSendBeacon = _ref.enableSendBeacon,
enableSendBeacon = _ref$enableSendBeacon === void 0 ? false : _ref$enableSendBeacon;
return ZalgoPromise.try(function () {
var beaconResult = false;
if (canUseSendBeacon({

@@ -42,3 +40,2 @@ headers: headers,

}
return beaconResult ? beaconResult : request({

@@ -45,0 +42,0 @@ win: win,

@@ -8,14 +8,20 @@ import _extends from "@babel/runtime/helpers/esm/extends";

import { getHTTPTransport } from './http';
// eslint-disable-line no-use-before-define
// eslint-disable-line no-use-before-define
// eslint-disable-line no-use-before-define
export function Logger(_ref) {
var url = _ref.url,
prefix = _ref.prefix,
_ref$logLevel = _ref.logLevel,
logLevel = _ref$logLevel === void 0 ? DEFAULT_LOG_LEVEL : _ref$logLevel,
_ref$transport = _ref.transport,
transport = _ref$transport === void 0 ? getHTTPTransport() : _ref$transport,
amplitudeApiKey = _ref.amplitudeApiKey,
_ref$flushInterval = _ref.flushInterval,
flushInterval = _ref$flushInterval === void 0 ? FLUSH_INTERVAL : _ref$flushInterval,
_ref$enableSendBeacon = _ref.enableSendBeacon,
enableSendBeacon = _ref$enableSendBeacon === void 0 ? false : _ref$enableSendBeacon;
prefix = _ref.prefix,
_ref$logLevel = _ref.logLevel,
logLevel = _ref$logLevel === void 0 ? DEFAULT_LOG_LEVEL : _ref$logLevel,
_ref$transport = _ref.transport,
transport = _ref$transport === void 0 ? getHTTPTransport() : _ref$transport,
amplitudeApiKey = _ref.amplitudeApiKey,
_ref$flushInterval = _ref.flushInterval,
flushInterval = _ref$flushInterval === void 0 ? FLUSH_INTERVAL : _ref$flushInterval,
_ref$enableSendBeacon = _ref.enableSendBeacon,
enableSendBeacon = _ref$enableSendBeacon === void 0 ? false : _ref$enableSendBeacon;
var events = [];

@@ -27,3 +33,2 @@ var tracking = [];

var headerBuilders = [];
function print(level, event, payload) {

@@ -33,14 +38,10 @@ if (!isBrowser() || !window.console || !window.console.log) {

}
if (LOG_LEVEL_PRIORITY.indexOf(level) > LOG_LEVEL_PRIORITY.indexOf(logLevel)) {
return;
}
var args = [event];
args.push(payload);
if (payload.error || payload.warning) {
args.push('\n\n', payload.error || payload.warning);
}
try {

@@ -52,6 +53,6 @@ if (window.console[level] && window.console[level].apply) {

}
} catch (err) {// pass
} catch (err) {
// pass
}
}
function immediateFlush() {

@@ -62,9 +63,6 @@ return ZalgoPromise.try(function () {

}
if (!events.length && !tracking.length) {
return;
}
var meta = {};
for (var _i2 = 0; _i2 < metaBuilders.length; _i2++) {

@@ -74,5 +72,3 @@ var builder = metaBuilders[_i2];

}
var headers = {};
for (var _i4 = 0; _i4 < headerBuilders.length; _i4++) {

@@ -82,5 +78,3 @@ var _builder = headerBuilders[_i4];

}
var res;
if (url) {

@@ -99,3 +93,2 @@ res = transport({

}
if (amplitudeApiKey) {

@@ -119,3 +112,2 @@ transport({

}
events = [];

@@ -126,5 +118,3 @@ tracking = [];

}
var flush = promiseDebounce(immediateFlush);
function enqueue(level, event, payload) {

@@ -136,3 +126,2 @@ events.push({

});
if (AUTO_FLUSH_LEVEL.indexOf(level) !== -1) {

@@ -142,3 +131,2 @@ flush();

}
function log(level, event, payload) {

@@ -148,15 +136,13 @@ if (payload === void 0) {

}
if (!isBrowser()) {
return logger; // eslint-disable-line no-use-before-define
}
if (prefix) {
event = prefix + "_" + event;
}
var logPayload = _extends({}, objFilter(payload), {
var logPayload = _extends({}, objFilter(payload, function (value) {
return value !== null && value !== undefined;
}), {
timestamp: Date.now().toString()
});
for (var _i6 = 0; _i6 < payloadBuilders.length; _i6++) {

@@ -166,3 +152,2 @@ var builder = payloadBuilders[_i6];

}
enqueue(level, event, logPayload);

@@ -172,3 +157,2 @@ print(level, event, logPayload);

}
function addBuilder(builders, builder) {

@@ -178,35 +162,26 @@ builders.push(builder);

}
function addPayloadBuilder(builder) {
return addBuilder(payloadBuilders, builder);
}
function addMetaBuilder(builder) {
return addBuilder(metaBuilders, builder);
}
function addTrackingBuilder(builder) {
return addBuilder(trackingBuilders, builder);
}
function addHeaderBuilder(builder) {
return addBuilder(headerBuilders, builder);
}
function debug(event, payload) {
return log(LOG_LEVEL.DEBUG, event, payload);
}
function info(event, payload) {
return log(LOG_LEVEL.INFO, event, payload);
}
function warn(event, payload) {
return log(LOG_LEVEL.WARN, event, payload);
}
function error(event, payload) {
return log(LOG_LEVEL.ERROR, event, payload);
}
function track(payload) {

@@ -216,9 +191,8 @@ if (payload === void 0) {

}
if (!isBrowser()) {
return logger; // eslint-disable-line no-use-before-define
}
var trackingPayload = objFilter(payload);
var trackingPayload = objFilter(payload, function (value) {
return value !== null && value !== undefined;
});
for (var _i8 = 0; _i8 < trackingBuilders.length; _i8++) {

@@ -228,3 +202,2 @@ var builder = trackingBuilders[_i8];

}
print(LOG_LEVEL.DEBUG, 'track', trackingPayload);

@@ -234,3 +207,2 @@ tracking.push(trackingPayload);

}
function setTransport(newTransport) {

@@ -240,3 +212,2 @@ transport = newTransport;

}
function configure(opts) {

@@ -246,34 +217,25 @@ if (opts.url) {

}
if (opts.prefix) {
prefix = opts.prefix;
}
if (opts.logLevel) {
logLevel = opts.logLevel;
}
if (opts.transport) {
transport = opts.transport;
}
if (opts.amplitudeApiKey) {
amplitudeApiKey = opts.amplitudeApiKey;
}
if (opts.flushInterval) {
flushInterval = opts.flushInterval;
}
if (opts.enableSendBeacon) {
enableSendBeacon = opts.enableSendBeacon;
}
return logger; // eslint-disable-line no-use-before-define
}
if (isBrowser()) {
safeInterval(flush, flushInterval);
}
if (typeof window === 'object') {

@@ -290,3 +252,2 @@ window.addEventListener('beforeunload', function () {

}
var logger = {

@@ -293,0 +254,0 @@ debug: debug,

import { AMPLITUDE_URL } from './config';
var canUseSendBeacon = function canUseSendBeacon(_ref) {
var headers = _ref.headers,
enableSendBeacon = _ref.enableSendBeacon;
enableSendBeacon = _ref.enableSendBeacon;
var hasHeaders = headers && Object.keys(headers).length;
if (window && window.navigator.sendBeacon && !hasHeaders && enableSendBeacon && window.Blob) {
return true;
}
return false;
};
var isAmplitude = function isAmplitude(url) {

@@ -19,21 +15,16 @@ if (url === AMPLITUDE_URL) {

}
return false;
};
var sendBeacon = function sendBeacon(_ref2) {
var _ref2$win = _ref2.win,
win = _ref2$win === void 0 ? window : _ref2$win,
url = _ref2.url,
data = _ref2.data,
_ref2$useBlob = _ref2.useBlob,
useBlob = _ref2$useBlob === void 0 ? true : _ref2$useBlob;
win = _ref2$win === void 0 ? window : _ref2$win,
url = _ref2.url,
data = _ref2.data,
_ref2$useBlob = _ref2.useBlob,
useBlob = _ref2$useBlob === void 0 ? true : _ref2$useBlob;
try {
var json = JSON.stringify(data);
if (!win.navigator.sendBeacon) {
throw new Error("No sendBeacon available");
}
if (useBlob) {

@@ -45,3 +36,2 @@ var blob = new Blob([json], {

}
return win.navigator.sendBeacon(url, json);

@@ -52,3 +42,2 @@ } catch (e) {

};
var extendIfDefined = function extendIfDefined(target, source) {

@@ -61,3 +50,2 @@ for (var key in source) {

};
export { canUseSendBeacon, extendIfDefined, isAmplitude, sendBeacon };
{
"name": "beaver-logger",
"version": "4.0.35",
"version": "4.0.36",
"description": "Client side logger.",

@@ -5,0 +5,0 @@ "main": "dist/beaver-logger.js",

@@ -5,3 +5,3 @@ "use strict";

exports.WILDCARD = exports.LOG_LEVEL = exports.HTTP_METHOD = exports.HTTP_HEADER = void 0;
const LOG_LEVEL = {
const LOG_LEVEL = exports.LOG_LEVEL = {
DEBUG: 'debug',

@@ -12,4 +12,3 @@ INFO: 'info',

};
exports.LOG_LEVEL = LOG_LEVEL;
const HTTP_HEADER = {
const HTTP_HEADER = exports.HTTP_HEADER = {
ORIGIN: 'origin',

@@ -24,4 +23,3 @@ ACCESS_CONTROL_ALLOW_ORIGIN: 'access-control-allow-origin',

};
exports.HTTP_HEADER = HTTP_HEADER;
const HTTP_METHOD = {
const HTTP_METHOD = exports.HTTP_METHOD = {
GET: 'get',

@@ -31,4 +29,2 @@ POST: 'post',

};
exports.HTTP_METHOD = HTTP_METHOD;
const WILDCARD = '*';
exports.WILDCARD = WILDCARD;
const WILDCARD = exports.WILDCARD = '*';
"use strict";
exports.__esModule = true;
var _server = require("./server");
Object.keys(_server).forEach(function (key) {

@@ -8,0 +6,0 @@ if (key === "default" || key === "__esModule") return;

@@ -8,11 +8,9 @@ "use strict";

exports.log = log;
var _url = _interopRequireDefault(require("url"));
var _constants = require("./constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint no-console: 0 */
const defaultLogger = {
// eslint-disable-line no-undef
// eslint-disable-line no-undef
const defaultLogger = exports.defaultLogger = {
log(req, level, name, payload) {

@@ -25,3 +23,2 @@ const date = payload.timestamp ? new Date(payload.timestamp).toString() : new Date().toString();

},
track(req, tracking) {

@@ -32,3 +29,2 @@ console.log('[track]\n', Object.keys(tracking).map(key => {

},
meta(req, meta) {

@@ -39,6 +35,3 @@ console.log('[meta]\n', Object.keys(meta).map(key => {

}
};
exports.defaultLogger = defaultLogger;
function log(req, logger, logs) {

@@ -48,7 +41,5 @@ const events = logs.events || [];

const meta = logs.meta || {};
if (logger.meta) {
logger.meta(req, meta);
}
if (logger.log) {

@@ -59,3 +50,2 @@ events.forEach(event => {

}
const name = event.event.replace(/_*[^a-zA-Z0-9_]+_*/g, '_');

@@ -67,3 +57,2 @@ const level = event.level || _constants.LOG_LEVEL.INFO;

}
if (logger.track) {

@@ -75,11 +64,11 @@ tracking.forEach(track => {

}
function handleRequest(req, logger) {
// $FlowFixMe
const method = req.method || _constants.HTTP_METHOD.GET; // $FlowFixMe
const method = req.method || _constants.HTTP_METHOD.GET;
const query = req.query; // $FlowFixMe
// $FlowFixMe
const query = req.query;
// $FlowFixMe
const body = req.body || {};
if (method.toLowerCase() === 'post') {

@@ -111,9 +100,6 @@ const {

}
function sendCorsHeaders(req, res) {
const origin = req.get(_constants.HTTP_HEADER.ORIGIN);
if (origin) {
const parsedUrl = _url.default.parse(origin) || {};
if (!parsedUrl.protocol || !parsedUrl.host) {

@@ -127,18 +113,12 @@ res.header(_constants.HTTP_HEADER.ACCESS_CONTROL_ALLOW_ORIGIN, _constants.WILDCARD);

}
const corsRequestHeaders = req.headers[_constants.HTTP_HEADER.ACCESS_CONTROL_REQUEST_HEADERS];
if (corsRequestHeaders) {
res.header(_constants.HTTP_HEADER.ACCESS_CONTROL_ALLOW_HEADERS, corsRequestHeaders);
}
const corsRequestMethod = req.headers[_constants.HTTP_HEADER.ACCESS_CONTROL_REQUEST_METHOD];
if (corsRequestMethod) {
res.header(_constants.HTTP_HEADER.ACCESS_CONTROL_ALLOW_METHODS, corsRequestMethod);
}
res.header(_constants.HTTP_HEADER.ACCESS_CONTROL_ALLOW_CREDENTIALS, 'true');
}
function expressEndpoint({

@@ -151,7 +131,6 @@ uri = '/',

const app = require('express')();
app.on('mount', parent => {
// $FlowFixMe
app.settings = Object.create(parent.settings); // $FlowFixMe
app.settings = Object.create(parent.settings);
// $FlowFixMe
app.kraken = parent.kraken || parent.config;

@@ -163,7 +142,5 @@ });

}
if (req.method.toLowerCase() === _constants.HTTP_METHOD.OPTIONS) {
return res.status(200).header(_constants.HTTP_HEADER.ACCESS_CONTROL_ALLOW_CREDENTIALS, 'true').send();
}
try {

@@ -170,0 +147,0 @@ handleRequest(req, logger);

@@ -177,3 +177,5 @@ /* @flow */

const logPayload : Payload = {
...objFilter(payload),
...objFilter(payload, value => {
return value !== null && value !== undefined;
}),
timestamp: Date.now().toString()

@@ -234,3 +236,5 @@ };

const trackingPayload : Payload = objFilter(payload);
const trackingPayload : Payload = objFilter(payload, value => {
return value !== null && value !== undefined;
});

@@ -237,0 +241,0 @@ for (const builder of trackingBuilders) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc