Socket
Socket
Sign inDemoInstall

beaver-logger

Package Overview
Dependencies
4
Maintainers
3
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.27 to 4.0.28

17

dist/beaver-logger.js

@@ -949,3 +949,4 @@ !function(root, factory) {

headerBuilders[_i4])(headers));
var res = transport({
var res;
url && (res = transport({
method: "POST",

@@ -960,3 +961,3 @@ url: url,

enableSendBeacon: enableSendBeacon
}).catch(src_util_noop);
}).catch(src_util_noop));
amplitudeApiKey && transport({

@@ -980,3 +981,3 @@ method: "POST",

tracking = [];
return res.then(src_util_noop);
return promise_ZalgoPromise.resolve(res).then(src_util_noop);
}

@@ -1083,2 +1084,12 @@ }));

return logger;
},
configure: function(opts) {
opts.url && (url = opts.url);
opts.prefix && (prefix = opts.prefix);
opts.logLevel && (logLevel = opts.logLevel);
opts.transport && (transport = opts.transport);
opts.amplitudeApiKey && (amplitudeApiKey = opts.amplitudeApiKey);
opts.flushInterval && (flushInterval = opts.flushInterval);
opts.enableSendBeacon && (enableSendBeacon = opts.enableSendBeacon);
return logger;
}

@@ -1085,0 +1096,0 @@ };

2

dist/beaver-logger.min.js

@@ -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 X})),n.d(t,"LOG_LEVEL",(function(){return z})),n.d(t,"PROTOCOL",(function(){return F}));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}}h instanceof e&&(h.resolved||h.rejected)?(h.resolved?l.resolve(h.value):l.reject(h.error),h.errorHandled=!0):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)},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=[];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),"about:"===e.location.protocol}function p(e){try{return!0}catch(e){}return!1}function w(e){void 0===e&&(e=window);var t=e.location;if(!t)throw new Error("Can not read window location");var n=t.protocol;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&&p()?w(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return n+"//"+o}function y(e){void 0===e&&(e=window);var t=w(e);return t&&e.mockDomain&&0===e.mockDomain.indexOf("mock:")?e.mockDomain:t}var m=[],g=[];function j(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&&function(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(v(e)&&p())return!0}catch(e){}try{if(w(e)===w(window))return!0}catch(e){}return!1}(e))return!1;try{if(e===window)return!0;if(v(e)&&p())return!0;if(y(window)===y(e))return!0}catch(e){}return!1}(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}(m,e);if(-1!==n){var r=g[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 b(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 O(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}var _,E=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(b(r)&&j(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!b(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=O(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=O(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=O(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!==O(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 k(e){return e.name||e.__name__||e.displayName||"anonymous"}function x(e,t){try{delete e.name,e.name=t}catch(e){}return e.__name__=e.displayName=t,e}function S(){var e="0123456789abcdef";return"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))})));if("undefined"!=typeof Buffer)return Buffer.from(e,"utf8").toString("base64");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 R(e){try{return JSON.stringify([].slice.call(e),(function(e,t){return"function"==typeof t?"memoize["+function(e){if(_=_||new E,null==e||"object"!=typeof e&&"function"!=typeof e)throw new Error("Invalid object");var t=_.get(e);return t||(t=typeof e+":"+S(),_.set(e,t)),t}(t)+"]":t}))}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}function P(){return{}}var W=0,C=0;function T(e,t){void 0===t&&(t={});var n,r,o=t.thisNamespace,i=void 0!==o&&o,a=t.time,u=W;W+=1;var c=function(){for(var t=arguments.length,o=new Array(t),c=0;c<t;c++)o[c]=arguments[c];var s;u<C&&(n=null,r=null,u=W,W+=1),s=i?(r=r||new E).getOrSet(this,P):n=n||{};var f=R(o),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},x(c,(t.name||k(e))+"::memoized")}function B(){}function L(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 N(){return Boolean(document.body)&&"complete"===document.readyState}function M(){return Boolean(document.body)&&"interactive"===document.readyState}function A(){return"undefined"!=typeof window&&void 0!==window.location}T.clear=function(){C=W},T((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,T((function(){return new l((function(e){if(N()||M())return e();var t=setInterval((function(){if(N()||M())return clearInterval(t),e()}),10)}))}));var D="undefined"!=typeof document?document.currentScript:null,I=T((function(){if(D)return D;if(D=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 D;throw new Error("Can not determine current script")})),H=S();T((function(){var e;try{e=I()}catch(e){return H}var t=e.getAttribute("data-uid");return t&&"string"==typeof t||(t=e.getAttribute("data-uid-auto"))&&"string"==typeof t||(t=S(),e.setAttribute("data-uid-auto",t)),t}));var U=[],z={DEBUG:"debug",INFO:"info",WARN:"warn",ERROR:"error"},F={FILE:"file:"},q=[z.WARN,z.ERROR],G=[z.ERROR,z.WARN,z.INFO,z.DEBUG],J=z.WARN;function K(e){var t=e.url,n=e.method,r=e.headers,o=e.json,i=e.enableSendBeacon,a=void 0!==i&&i;return l.try((function(){var e=r&&Object.keys(r).length;if(window&&window.navigator.sendBeacon&&!e&&a&&window.Blob)try{var i=new Blob([JSON.stringify(o)],{type:"application/json"});return window.navigator.sendBeacon(t,i)}catch(e){}return 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<U.length;v++)for(var p=(0,U[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 j 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(j)&&g.setRequestHeader(j,o[j]);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)}))}({url:t,method:n,headers:r,json:o})})).then(B)}function V(e,t){for(var n in t)t.hasOwnProperty(n)&&t[n]&&!e[n]&&(e[n]=t[n])}function X(e){var t=e.url,n=e.prefix,o=e.logLevel,i=void 0===o?J:o,a=e.transport,u=void 0===a?K: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 j(e,t,n){if(A()&&window.console&&window.console.log&&!(G.indexOf(e)>G.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 b(){return l.try((function(){if(A()&&window.location.protocol!==F.FILE&&(v.length||p.length)){for(var e={},n=0;n<y.length;n++)V(e,(0,y[n])(e));for(var o={},i=0;i<g.length;i++)V(o,(0,g[i])(o));var a=u({method:"POST",url:t,headers:o,json:{events:v,meta:e,tracking:p},enableSendBeacon:h}).catch(B);return c&&u({method:"POST",url:"https://api2.amplitude.com/2/httpapi",headers:{"content-type":"application/json"},json:{api_key:c,events:p.map((function(e){return r({event_type:e.transition_name||"event",event_properties:e},e)}))}}).catch(B),v=[],p=[],a.then(B)}}))}var O,_,E,S,R=(void 0===_&&(_=50),x((function(){S&&clearTimeout(S);var e=E=E||new l;return S=setTimeout((function(){E=null,S=null,l.try(O).then((function(t){e.resolve(t)}),(function(t){e.reject(t)}))}),_),e}),k(O=b)+"::promiseDebounced"));function P(e,t,o){if(void 0===o&&(o={}),!A())return C;n&&(t=n+"_"+t);for(var i=r({},L(o),{timestamp:Date.now().toString()}),a=0;a<w.length;a++)V(i,(0,w[a])(i));return function(e,t,n){v.push({level:e,event:t,payload:n}),-1!==q.indexOf(e)&&R()}(e,t,i),j(e,t,i),C}function W(e,t){return e.push(t),C}A()&&function(e,t){!function n(){setTimeout((function(){e(),n()}),t)}()}(R,f),"object"==typeof window&&(window.addEventListener("beforeunload",(function(){b()})),window.addEventListener("unload",(function(){b()})));var C={debug:function(e,t){return P(z.DEBUG,e,t)},info:function(e,t){return P(z.INFO,e,t)},warn:function(e,t){return P(z.WARN,e,t)},error:function(e,t){return P(z.ERROR,e,t)},track:function(e){if(void 0===e&&(e={}),!A())return C;for(var t=L(e),n=0;n<m.length;n++)V(t,(0,m[n])(t));return j(z.DEBUG,"track",t),p.push(t),C},flush:R,immediateFlush:b,addPayloadBuilder:function(e){return W(w,e)},addMetaBuilder:function(e){return W(y,e)},addTrackingBuilder:function(e){return W(m,e)},addHeaderBuilder:function(e){return W(g,e)},setTransport:function(e){return u=e,C}};return C}}])}));
!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 X})),n.d(t,"LOG_LEVEL",(function(){return z})),n.d(t,"PROTOCOL",(function(){return F}));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}}h instanceof e&&(h.resolved||h.rejected)?(h.resolved?l.resolve(h.value):l.reject(h.error),h.errorHandled=!0):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)},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=[];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 p(e){return void 0===e&&(e=window),"about:"===e.location.protocol}function v(e){try{return!0}catch(e){}return!1}function w(e){void 0===e&&(e=window);var t=e.location;if(!t)throw new Error("Can not read window location");var n=t.protocol;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&&v()?w(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return n+"//"+o}function y(e){void 0===e&&(e=window);var t=w(e);return t&&e.mockDomain&&0===e.mockDomain.indexOf("mock:")?e.mockDomain:t}var m=[],g=[];function j(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&&function(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(p(e)&&v())return!0}catch(e){}try{if(w(e)===w(window))return!0}catch(e){}return!1}(e))return!1;try{if(e===window)return!0;if(p(e)&&v())return!0;if(y(window)===y(e))return!0}catch(e){}return!1}(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}(m,e);if(-1!==n){var r=g[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 b(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 O(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}var _,E=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(b(r)&&j(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!b(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=O(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=O(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=O(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!==O(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 k(e){return e.name||e.__name__||e.displayName||"anonymous"}function x(e,t){try{delete e.name,e.name=t}catch(e){}return e.__name__=e.displayName=t,e}function S(){var e="0123456789abcdef";return"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))})));if("undefined"!=typeof Buffer)return Buffer.from(e,"utf8").toString("base64");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 R(e){try{return JSON.stringify([].slice.call(e),(function(e,t){return"function"==typeof t?"memoize["+function(e){if(_=_||new E,null==e||"object"!=typeof e&&"function"!=typeof e)throw new Error("Invalid object");var t=_.get(e);return t||(t=typeof e+":"+S(),_.set(e,t)),t}(t)+"]":t}))}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}function P(){return{}}var W=0,C=0;function T(e,t){void 0===t&&(t={});var n,r,o=t.thisNamespace,i=void 0!==o&&o,a=t.time,u=W;W+=1;var c=function(){for(var t=arguments.length,o=new Array(t),c=0;c<t;c++)o[c]=arguments[c];var s;u<C&&(n=null,r=null,u=W,W+=1),s=i?(r=r||new E).getOrSet(this,P):n=n||{};var f=R(o),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},x(c,(t.name||k(e))+"::memoized")}function B(){}function L(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 N(){return Boolean(document.body)&&"complete"===document.readyState}function M(){return Boolean(document.body)&&"interactive"===document.readyState}function A(){return"undefined"!=typeof window&&void 0!==window.location}T.clear=function(){C=W},T((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,T((function(){return new l((function(e){if(N()||M())return e();var t=setInterval((function(){if(N()||M())return clearInterval(t),e()}),10)}))}));var I="undefined"!=typeof document?document.currentScript:null,D=T((function(){if(I)return I;if(I=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 I;throw new Error("Can not determine current script")})),H=S();T((function(){var e;try{e=D()}catch(e){return H}var t=e.getAttribute("data-uid");return t&&"string"==typeof t||(t=e.getAttribute("data-uid-auto"))&&"string"==typeof t||(t=S(),e.setAttribute("data-uid-auto",t)),t}));var U=[],z={DEBUG:"debug",INFO:"info",WARN:"warn",ERROR:"error"},F={FILE:"file:"},q=[z.WARN,z.ERROR],G=[z.ERROR,z.WARN,z.INFO,z.DEBUG],J=z.WARN;function K(e){var t=e.url,n=e.method,r=e.headers,o=e.json,i=e.enableSendBeacon,a=void 0!==i&&i;return l.try((function(){var e=r&&Object.keys(r).length;if(window&&window.navigator.sendBeacon&&!e&&a&&window.Blob)try{var i=new Blob([JSON.stringify(o)],{type:"application/json"});return window.navigator.sendBeacon(t,i)}catch(e){}return 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 p=0;p<U.length;p++)for(var v=(0,U[p])(),w=0,y=Object.keys(v);w<y.length;w++){var m=y[w];o[m.toLowerCase()]=v[m]}var g=new f.XMLHttpRequest;for(var j 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(j)&&g.setRequestHeader(j,o[j]);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)}))}({url:t,method:n,headers:r,json:o})})).then(B)}function V(e,t){for(var n in t)t.hasOwnProperty(n)&&t[n]&&!e[n]&&(e[n]=t[n])}function X(e){var t=e.url,n=e.prefix,o=e.logLevel,i=void 0===o?J:o,a=e.transport,u=void 0===a?K:a,c=e.amplitudeApiKey,s=e.flushInterval,f=void 0===s?6e4:s,d=e.enableSendBeacon,h=void 0!==d&&d,p=[],v=[],w=[],y=[],m=[],g=[];function j(e,t,n){if(A()&&window.console&&window.console.log&&!(G.indexOf(e)>G.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 b(){return l.try((function(){if(A()&&window.location.protocol!==F.FILE&&(p.length||v.length)){for(var e={},n=0;n<y.length;n++)V(e,(0,y[n])(e));for(var o,i={},a=0;a<g.length;a++)V(i,(0,g[a])(i));return t&&(o=u({method:"POST",url:t,headers:i,json:{events:p,meta:e,tracking:v},enableSendBeacon:h}).catch(B)),c&&u({method:"POST",url:"https://api2.amplitude.com/2/httpapi",headers:{"content-type":"application/json"},json:{api_key:c,events:v.map((function(e){return r({event_type:e.transition_name||"event",event_properties:e},e)}))}}).catch(B),p=[],v=[],l.resolve(o).then(B)}}))}var O,_,E,S,R=(void 0===_&&(_=50),x((function(){S&&clearTimeout(S);var e=E=E||new l;return S=setTimeout((function(){E=null,S=null,l.try(O).then((function(t){e.resolve(t)}),(function(t){e.reject(t)}))}),_),e}),k(O=b)+"::promiseDebounced"));function P(e,t,o){if(void 0===o&&(o={}),!A())return C;n&&(t=n+"_"+t);for(var i=r({},L(o),{timestamp:Date.now().toString()}),a=0;a<w.length;a++)V(i,(0,w[a])(i));return function(e,t,n){p.push({level:e,event:t,payload:n}),-1!==q.indexOf(e)&&R()}(e,t,i),j(e,t,i),C}function W(e,t){return e.push(t),C}A()&&function(e,t){!function n(){setTimeout((function(){e(),n()}),t)}()}(R,f),"object"==typeof window&&(window.addEventListener("beforeunload",(function(){b()})),window.addEventListener("unload",(function(){b()})));var C={debug:function(e,t){return P(z.DEBUG,e,t)},info:function(e,t){return P(z.INFO,e,t)},warn:function(e,t){return P(z.WARN,e,t)},error:function(e,t){return P(z.ERROR,e,t)},track:function(e){if(void 0===e&&(e={}),!A())return C;for(var t=L(e),n=0;n<m.length;n++)V(t,(0,m[n])(t));return j(z.DEBUG,"track",t),v.push(t),C},flush:R,immediateFlush:b,addPayloadBuilder:function(e){return W(w,e)},addMetaBuilder:function(e){return W(y,e)},addTrackingBuilder:function(e){return W(m,e)},addHeaderBuilder:function(e){return W(g,e)},setTransport:function(e){return u=e,C},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),C}};return C}}])}));
//# sourceMappingURL=beaver-logger.min.js.map

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

var res = transport({
method: 'POST',
url: url,
headers: headers,
json: {
events: events,
meta: meta,
tracking: tracking
},
enableSendBeacon: enableSendBeacon
}).catch(noop);
var res;
if (url) {
res = transport({
method: 'POST',
url: url,
headers: headers,
json: {
events: events,
meta: meta,
tracking: tracking
},
enableSendBeacon: enableSendBeacon
}).catch(noop);
}
if (amplitudeApiKey) {

@@ -148,3 +152,3 @@ transport({

tracking = [];
return res.then(noop);
return ZalgoPromise.resolve(res).then(noop);
});

@@ -257,2 +261,34 @@ }

function configure(opts) {
if (opts.url) {
url = 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()) {

@@ -283,5 +319,6 @@ safeInterval(flush, flushInterval);

addHeaderBuilder: addHeaderBuilder,
setTransport: setTransport
setTransport: setTransport,
configure: configure
};
return logger;
}
{
"name": "beaver-logger",
"version": "4.0.27",
"version": "4.0.28",
"description": "Client side logger.",

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

@@ -21,3 +21,3 @@ /* @flow */

type LoggerOptions = {|
url : string,
url? : string,
prefix? : string,

@@ -54,3 +54,4 @@ logLevel? : $Values<typeof LOG_LEVEL>,

setTransport : (Transport) => LoggerType
setTransport : (Transport) => LoggerType,
configure : (LoggerOptions) => LoggerType
|};

@@ -141,14 +142,18 @@

const res = transport({
method: 'POST',
url,
headers,
json: {
events,
meta,
tracking
},
enableSendBeacon
}).catch(noop);
let res;
if (url) {
res = transport({
method: 'POST',
url,
headers,
json: {
events,
meta,
tracking
},
enableSendBeacon
}).catch(noop);
}
if (amplitudeApiKey) {

@@ -178,3 +183,3 @@ transport({

return res.then(noop);
return ZalgoPromise.resolve(res).then(noop);
});

@@ -282,2 +287,34 @@ }

function configure(opts : LoggerOptions) : LoggerType {
if (opts.url) {
url = 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()) {

@@ -309,3 +346,4 @@ safeInterval(flush, flushInterval);

addHeaderBuilder,
setTransport
setTransport,
configure
};

@@ -312,0 +350,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc