beaver-logger
Advanced tools
Comparing version 2.0.2 to 2.0.3
{ | ||
"name": "beaver-logger", | ||
"main": "index.js", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Daniel Brain <dbrain@paypal.com>" |
@@ -24,2 +24,4 @@ | ||
logLevel: 'debug', | ||
autoLog: ['warn', 'error'], | ||
@@ -31,1 +33,3 @@ | ||
}; | ||
export let logLevels = [ 'error', 'warn', 'info', 'debug' ]; |
@@ -6,3 +6,4 @@ | ||
export * from './builders'; | ||
export * from './config'; | ||
export default module.exports; |
import { extend, promiseDebounce, ajax } from './util'; | ||
import { payloadBuilders, metaBuilders, trackingBuilders, headerBuilders } from './builders'; | ||
import { config } from './config'; | ||
import { config, logLevels } from './config'; | ||
@@ -15,4 +15,14 @@ export let buffer = []; | ||
let loaded = false; | ||
setTimeout(() => { | ||
loaded = true; | ||
}, 1); | ||
export function print(level, event, payload) { | ||
if (!loaded) { | ||
return setTimeout(() => print(level, event, payload), 1); | ||
} | ||
if (!window.console || !window.console.log) { | ||
@@ -22,2 +32,6 @@ return; | ||
if (logLevels.indexOf(level) > logLevels.indexOf(config.logLevel)) { | ||
return; | ||
} | ||
payload = payload || {}; | ||
@@ -24,0 +38,0 @@ |
@@ -110,2 +110,14 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
}); | ||
var _config = __webpack_require__(6); | ||
Object.keys(_config).forEach(function (key) { | ||
if (key === "default") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _config[key]; | ||
} | ||
}); | ||
}); | ||
exports['default'] = module.exports; | ||
@@ -151,4 +163,16 @@ | ||
var loaded = false; | ||
setTimeout(function () { | ||
loaded = true; | ||
}, 1); | ||
function print(level, event, payload) { | ||
if (!loaded) { | ||
return setTimeout(function () { | ||
return print(level, event, payload); | ||
}, 1); | ||
} | ||
if (!window.console || !window.console.log) { | ||
@@ -158,2 +182,6 @@ return; | ||
if (_config.logLevels.indexOf(level) > _config.logLevels.indexOf(_config.config.logLevel)) { | ||
return; | ||
} | ||
payload = payload || {}; | ||
@@ -765,2 +793,4 @@ | ||
logLevel: 'debug', | ||
autoLog: ['warn', 'error'], | ||
@@ -773,2 +803,4 @@ | ||
var logLevels = exports.logLevels = ['error', 'warn', 'info', 'debug']; | ||
/***/ }, | ||
@@ -775,0 +807,0 @@ /* 7 */ |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("$logger",[],n):"object"==typeof exports?exports.$logger=n():e.$logger=n()}(this,function(){return function(e){function n(o){if(t[o])return t[o].exports;var r=t[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=t(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var r=t(7);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var i=t(9);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(5);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})}),n["default"]=e.exports},function(e,n,t){"use strict";function o(e,n,t){if(window.console&&window.console.log){t=t||{};var o=[n];o.push(t),(t.error||t.warning)&&o.push("\n\n",t.error||t.warning),window.console&&(window.console[e]&&window.console[e].apply?window.console[e].apply(window.console,o):window.console.log&&window.console.log.apply&&window.console.log.apply(window.console,o))}}function r(){var e=arguments.length<=0||void 0===arguments[0]||arguments[0];if(g.config.uri){var t=m.length,r=Object.keys(w).length;if(t||r){r&&o("info","tracking",w);for(var i={},a=v.metaBuilders,c=Array.isArray(a),u=0,a=c?a:a[Symbol.iterator]();;){var f;if(c){if(u>=a.length)break;f=a[u++]}else{if(u=a.next(),u.done)break;f=u.value}var s=f;try{(0,p.extend)(i,s(),!1)}catch(l){console.error("Error in custom meta builder:",l.stack||l.toString())}}for(var d=v.trackingBuilders,h=Array.isArray(d),y=0,d=h?d:d[Symbol.iterator]();;){var b;if(h){if(y>=d.length)break;b=d[y++]}else{if(y=d.next(),y.done)break;b=y.value}var E=b;try{(0,p.extend)(w,E(),!1)}catch(l){console.error("Error in custom tracking builder:",l.stack||l.toString())}}for(var x={},_=v.headerBuilders,S=Array.isArray(_),j=0,_=S?_:_[Symbol.iterator]();;){var k;if(S){if(j>=_.length)break;k=_[j++]}else{if(j=_.next(),j.done)break;k=j.value}var P=k;try{(0,p.extend)(x,P(),!1)}catch(l){console.error("Error in custom header builder:",l.stack||l.toString())}}var T=m,O=(0,p.ajax)("post",g.config.uri,x,{events:T,meta:i,tracking:w},e);return n.buffer=m=[],n.tracking=w={},O}}}function i(e,n,t){m.push({level:e,event:n,payload:t}),g.config.autoLog.indexOf(e)>-1&&y()}function a(e,n,t){g.config.prefix&&(n=g.config.prefix+"_"+n),t=t||{},"string"==typeof t?t={message:t}:t instanceof Error&&(t={error:t.stack||t.toString()}),t.timestamp=Date.now();for(var r=v.payloadBuilders,a=Array.isArray(r),c=0,r=a?r:r[Symbol.iterator]();;){var u;if(a){if(c>=r.length)break;u=r[c++]}else{if(c=r.next(),c.done)break;u=c.value}var f=u;try{(0,p.extend)(t,f(),!1)}catch(s){console.error("Error in custom payload builder:",s.stack||s.toString())}}g.config.silent||o(e,n,t),m.length===g.config.sizeLimit?i("info","logger_max_buffer_length"):m.length<g.config.sizeLimit&&i(e,n,t)}function c(e){return{debug:function(n,t){return a("debug",e+"_"+n,t)},info:function(n,t){return a("info",e+"_"+n,t)},warn:function(n,t){return a("warn",e+"_"+n,t)},error:function(n,t){return a("error",e+"_"+n,t)},flush:function(){return y()}}}function u(e,n){return a("debug",e,n)}function f(e,n){return a("info",e,n)}function s(e,n){return a("warn",e,n)}function l(e,n){return a("error",e,n)}function d(e){(0,p.extend)(w,e||{},!1)}Object.defineProperty(n,"__esModule",{value:!0}),n.flush=n.tracking=n.buffer=void 0;var h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};n.print=o,n.immediateFlush=r,n.log=a,n.prefix=c,n.debug=u,n.info=f,n.warn=s,n.error=l,n.track=d;var p=t(2),v=t(5),g=t(6),m=n.buffer=[],w=n.tracking={};Function.prototype.bind&&window.console&&"object"===h(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var y=(0,p.promiseDebounce)(r,g.config.debounceInterval);n.flush=y},function(e,n,t){"use strict";function o(e,n){var t=arguments.length<=2||void 0===arguments[2]||arguments[2];e=e||{},n=n||{};for(var o in n)n.hasOwnProperty(o)&&(!t&&e.hasOwnProperty(o)||(e[o]=n[o]));return e}function r(e){return window.location.protocol===e.split("/")[0]}function i(e){var n=e.match(/https?:\/\/[^\/]+/);return!n||n[0]===window.location.protocol+"//"+window.location.host}function a(e,n){var t=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],a=arguments.length<=4||void 0===arguments[4]||arguments[4];return new s.Promise(function(c){var u=window.XMLHttpRequest||window.ActiveXObject;if(window.XDomainRequest&&!i(n)){if(!r(n))return c();u=window.XDomainRequest}var f=new u("MSXML2.XMLHTTP.3.0");f.open(e.toUpperCase(),n,a),f.setRequestHeader("X-Requested-With","XMLHttpRequest"),f.setRequestHeader("Content-type","application/json");for(var s in t)t.hasOwnProperty(s)&&f.setRequestHeader(s,t[s]);f.onreadystatechange=function(){f.readyState>3&&c()},f.send(JSON.stringify(o).replace(/&/g,"%26"))})}function c(e,n){var t={};return function(){var o=arguments;return t.timeout&&(clearTimeout(t.timeout),delete t.timeout),t.timeout=setTimeout(function(){var n=t.resolver,r=t.rejector;return delete t.promise,delete t.resolver,delete t.rejector,delete t.timeout,s.Promise.resolve().then(function(){return e.apply(null,o)}).then(n,r)},n),t.promise=t.promise||new s.Promise(function(e,n){t.resolver=e,t.rejector=n}),t.promise}}function u(e,n){function t(){o=setTimeout(function(){e(),t()},n)}var o=void 0;return t(),{cancel:function(){clearTimeout(o)}}}function f(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})}Object.defineProperty(n,"__esModule",{value:!0}),n.windowReady=void 0,n.extend=o,n.isSameProtocol=r,n.isSameDomain=i,n.ajax=a,n.promiseDebounce=c,n.safeInterval=u,n.uniqueID=f;var s=t(3);n.windowReady=new s.Promise(function(e){"complete"===document.readyState&&e(),window.addEventListener("load",e)})},function(e,n,t){var o;(function(r,i){/*! | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("$logger",[],n):"object"==typeof exports?exports.$logger=n():e.$logger=n()}(this,function(){return function(e){function n(o){if(t[o])return t[o].exports;var r=t[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=t(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var r=t(7);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var i=t(9);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(5);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var c=t(6);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return c[e]}})}),n["default"]=e.exports},function(e,n,t){"use strict";function o(e,n,t){if(!y)return setTimeout(function(){return o(e,n,t)},1);if(window.console&&window.console.log&&!(g.logLevels.indexOf(e)>g.logLevels.indexOf(g.config.logLevel))){t=t||{};var r=[n];r.push(t),(t.error||t.warning)&&r.push("\n\n",t.error||t.warning),window.console&&(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))}}function r(){var e=arguments.length<=0||void 0===arguments[0]||arguments[0];if(g.config.uri){var t=m.length,r=Object.keys(w).length;if(t||r){r&&o("info","tracking",w);for(var i={},a=v.metaBuilders,c=Array.isArray(a),u=0,a=c?a:a[Symbol.iterator]();;){var f;if(c){if(u>=a.length)break;f=a[u++]}else{if(u=a.next(),u.done)break;f=u.value}var s=f;try{(0,p.extend)(i,s(),!1)}catch(l){console.error("Error in custom meta builder:",l.stack||l.toString())}}for(var d=v.trackingBuilders,h=Array.isArray(d),y=0,d=h?d:d[Symbol.iterator]();;){var b;if(h){if(y>=d.length)break;b=d[y++]}else{if(y=d.next(),y.done)break;b=y.value}var E=b;try{(0,p.extend)(w,E(),!1)}catch(l){console.error("Error in custom tracking builder:",l.stack||l.toString())}}for(var x={},j=v.headerBuilders,_=Array.isArray(j),S=0,j=_?j:j[Symbol.iterator]();;){var k;if(_){if(S>=j.length)break;k=j[S++]}else{if(S=j.next(),S.done)break;k=S.value}var T=k;try{(0,p.extend)(x,T(),!1)}catch(l){console.error("Error in custom header builder:",l.stack||l.toString())}}var P=m,O=(0,p.ajax)("post",g.config.uri,x,{events:P,meta:i,tracking:w},e);return n.buffer=m=[],n.tracking=w={},O}}}function i(e,n,t){m.push({level:e,event:n,payload:t}),g.config.autoLog.indexOf(e)>-1&&b()}function a(e,n,t){g.config.prefix&&(n=g.config.prefix+"_"+n),t=t||{},"string"==typeof t?t={message:t}:t instanceof Error&&(t={error:t.stack||t.toString()}),t.timestamp=Date.now();for(var r=v.payloadBuilders,a=Array.isArray(r),c=0,r=a?r:r[Symbol.iterator]();;){var u;if(a){if(c>=r.length)break;u=r[c++]}else{if(c=r.next(),c.done)break;u=c.value}var f=u;try{(0,p.extend)(t,f(),!1)}catch(s){console.error("Error in custom payload builder:",s.stack||s.toString())}}g.config.silent||o(e,n,t),m.length===g.config.sizeLimit?i("info","logger_max_buffer_length"):m.length<g.config.sizeLimit&&i(e,n,t)}function c(e){return{debug:function(n,t){return a("debug",e+"_"+n,t)},info:function(n,t){return a("info",e+"_"+n,t)},warn:function(n,t){return a("warn",e+"_"+n,t)},error:function(n,t){return a("error",e+"_"+n,t)},flush:function(){return b()}}}function u(e,n){return a("debug",e,n)}function f(e,n){return a("info",e,n)}function s(e,n){return a("warn",e,n)}function l(e,n){return a("error",e,n)}function d(e){(0,p.extend)(w,e||{},!1)}Object.defineProperty(n,"__esModule",{value:!0}),n.flush=n.tracking=n.buffer=void 0;var h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};n.print=o,n.immediateFlush=r,n.log=a,n.prefix=c,n.debug=u,n.info=f,n.warn=s,n.error=l,n.track=d;var p=t(2),v=t(5),g=t(6),m=n.buffer=[],w=n.tracking={};Function.prototype.bind&&window.console&&"object"===h(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var y=!1;setTimeout(function(){y=!0},1);var b=(0,p.promiseDebounce)(r,g.config.debounceInterval);n.flush=b},function(e,n,t){"use strict";function o(e,n){var t=arguments.length<=2||void 0===arguments[2]||arguments[2];e=e||{},n=n||{};for(var o in n)n.hasOwnProperty(o)&&(!t&&e.hasOwnProperty(o)||(e[o]=n[o]));return e}function r(e){return window.location.protocol===e.split("/")[0]}function i(e){var n=e.match(/https?:\/\/[^\/]+/);return!n||n[0]===window.location.protocol+"//"+window.location.host}function a(e,n){var t=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],a=arguments.length<=4||void 0===arguments[4]||arguments[4];return new s.Promise(function(c){var u=window.XMLHttpRequest||window.ActiveXObject;if(window.XDomainRequest&&!i(n)){if(!r(n))return c();u=window.XDomainRequest}var f=new u("MSXML2.XMLHTTP.3.0");f.open(e.toUpperCase(),n,a),f.setRequestHeader("X-Requested-With","XMLHttpRequest"),f.setRequestHeader("Content-type","application/json");for(var s in t)t.hasOwnProperty(s)&&f.setRequestHeader(s,t[s]);f.onreadystatechange=function(){f.readyState>3&&c()},f.send(JSON.stringify(o).replace(/&/g,"%26"))})}function c(e,n){var t={};return function(){var o=arguments;return t.timeout&&(clearTimeout(t.timeout),delete t.timeout),t.timeout=setTimeout(function(){var n=t.resolver,r=t.rejector;return delete t.promise,delete t.resolver,delete t.rejector,delete t.timeout,s.Promise.resolve().then(function(){return e.apply(null,o)}).then(n,r)},n),t.promise=t.promise||new s.Promise(function(e,n){t.resolver=e,t.rejector=n}),t.promise}}function u(e,n){function t(){o=setTimeout(function(){e(),t()},n)}var o=void 0;return t(),{cancel:function(){clearTimeout(o)}}}function f(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})}Object.defineProperty(n,"__esModule",{value:!0}),n.windowReady=void 0,n.extend=o,n.isSameProtocol=r,n.isSameDomain=i,n.ajax=a,n.promiseDebounce=c,n.safeInterval=u,n.uniqueID=f;var s=t(3);n.windowReady=new s.Promise(function(e){"complete"===document.readyState&&e(),window.addEventListener("load",e)})},function(e,n,t){var o;(function(r,i){/*! | ||
* @overview es6-promise - a tiny implementation of Promises/A+. | ||
@@ -8,2 +8,2 @@ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) | ||
*/ | ||
(function(){function a(e,n){A[L]=e,A[L+1]=n,L+=2,2===L&&T()}function c(e){return"function"==typeof e}function u(){return function(){r.nextTick(d)}}function f(){var e=0,n=new I(d),t=document.createTextNode("");return n.observe(t,{characterData:!0}),function(){t.data=e=++e%2}}function s(){var e=new MessageChannel;return e.port1.onmessage=d,function(){e.port2.postMessage(0)}}function l(){return function(){setTimeout(d,1)}}function d(){for(var e=0;e<L;e+=2)(0,A[e])(A[e+1]),A[e]=void 0,A[e+1]=void 0;L=0}function h(){}function p(e,n,t,o){try{e.call(n,t,o)}catch(r){return r}}function v(e,n,t){a(function(e){var o=!1,r=p(t,n,function(t){o||(o=!0,n!==t?m(e,t):y(e,t))},function(n){o||(o=!0,b(e,n))});!o&&r&&(o=!0,b(e,r))},e)}function g(e,n){1===n.a?y(e,n.b):2===e.a?b(e,n.b):E(n,void 0,function(n){m(e,n)},function(n){b(e,n)})}function m(e,n){if(e===n)b(e,new TypeError("You cannot resolve a promise with itself"));else if("function"==typeof n||"object"==typeof n&&null!==n)if(n.constructor===e.constructor)g(e,n);else{var t;try{t=n.then}catch(o){q.error=o,t=q}t===q?b(e,q.error):void 0===t?y(e,n):c(t)?v(e,n,t):y(e,n)}else y(e,n)}function w(e){e.f&&e.f(e.b),x(e)}function y(e,n){void 0===e.a&&(e.b=n,e.a=1,0!==e.e.length&&a(x,e))}function b(e,n){void 0===e.a&&(e.a=2,e.b=n,a(w,e))}function E(e,n,t,o){var r=e.e,i=r.length;e.f=null,r[i]=n,r[i+1]=t,r[i+2]=o,0===i&&e.a&&a(x,e)}function x(e){var n=e.e,t=e.a;if(0!==n.length){for(var o,r,i=e.b,a=0;a<n.length;a+=3)o=n[a],r=n[a+t],o?S(t,o,r,i):r(i);e.e.length=0}}function _(){this.error=null}function S(e,n,t,o){var r,i,a,u,f=c(t);if(f){try{r=t(o)}catch(s){B.error=s,r=B}if(r===B?(u=!0,i=r.error,r=null):a=!0,n===r)return void b(n,new TypeError("A promises callback cannot return that same promise."))}else r=o,a=!0;void 0===n.a&&(f&&a?m(n,r):u?b(n,i):1===e?y(n,r):2===e&&b(n,r))}function j(e,n){try{n(function(n){m(e,n)},function(n){b(e,n)})}catch(t){b(e,t)}}function k(e,n,t,o){this.n=e,this.c=new e(h,o),this.i=t,this.o(n)?(this.m=n,this.d=this.length=n.length,this.l(),0===this.length?y(this.c,this.b):(this.length=this.length||0,this.k(),0===this.d&&y(this.c,this.b))):b(this.c,this.p())}function P(e){if(D++,this.b=this.a=void 0,this.e=[],h!==e){if(!c(e))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof P))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");j(this,e)}}var T,O=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},L=0,M="undefined"!=typeof window?window:{},I=M.MutationObserver||M.WebKitMutationObserver,M="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,A=Array(1e3);T="undefined"!=typeof r&&"[object process]"==={}.toString.call(r)?u():I?f():M?s():l();var q=new _,B=new _;k.prototype.o=function(e){return O(e)},k.prototype.p=function(){return Error("Array Methods must be provided an Array")},k.prototype.l=function(){this.b=Array(this.length)},k.prototype.k=function(){for(var e=this.length,n=this.c,t=this.m,o=0;void 0===n.a&&o<e;o++)this.j(t[o],o)},k.prototype.j=function(e,n){var t=this.n;"object"==typeof e&&null!==e?e.constructor===t&&void 0!==e.a?(e.f=null,this.g(e.a,n,e.b)):this.q(t.resolve(e),n):(this.d--,this.b[n]=this.h(e))},k.prototype.g=function(e,n,t){var o=this.c;void 0===o.a&&(this.d--,this.i&&2===e?b(o,t):this.b[n]=this.h(t)),0===this.d&&y(o,this.b)},k.prototype.h=function(e){return e},k.prototype.q=function(e,n){var t=this;E(e,void 0,function(e){t.g(1,n,e)},function(e){t.g(2,n,e)})};var D=0;P.all=function(e,n){return new k(this,e,(!0),n).c},P.race=function(e,n){function t(e){m(r,e)}function o(e){b(r,e)}var r=new this(h,n);if(!O(e))return b(r,new TypeError("You must pass an array to race.")),r;for(var i=e.length,a=0;void 0===r.a&&a<i;a++)E(this.resolve(e[a]),void 0,t,o);return r},P.resolve=function(e,n){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(h,n);return m(t,e),t},P.reject=function(e,n){var t=new this(h,n);return b(t,e),t},P.prototype={constructor:P,then:function(e,n){var t=this.a;if(1===t&&!e||2===t&&!n)return this;var o=new this.constructor(h),r=this.b;if(t){var i=arguments[t-1];a(function(){S(t,o,i,r)})}else E(this,o,e,n);return o},"catch":function(e){return this.then(null,e)}};var C={Promise:P,polyfill:function(){var e;e="undefined"!=typeof i?i:"undefined"!=typeof window&&window.document?window:self,"Promise"in e&&"resolve"in e.Promise&&"reject"in e.Promise&&"all"in e.Promise&&"race"in e.Promise&&function(){var n;return new e.Promise(function(e){n=e}),c(n)}()||(e.Promise=P)}};o=function(){return C}.call(n,t,n,e),!(void 0!==o&&(e.exports=o))}).call(this)}).call(n,t(4),function(){return this}())},function(e,n){function t(){l&&f&&(l=!1,f.length?s=f.concat(s):d=-1,s.length&&o())}function o(){if(!l){var e=a(t);l=!0;for(var n=s.length;n;){for(f=s,s=[];++d<n;)f&&f[d].run();d=-1,n=s.length}f=null,l=!1,c(e)}}function r(e,n){this.fun=e,this.array=n}function i(){}var a,c,u=e.exports={};!function(){try{a=setTimeout}catch(e){a=function(){throw new Error("setTimeout is not defined")}}try{c=clearTimeout}catch(e){c=function(){throw new Error("clearTimeout is not defined")}}}();var f,s=[],l=!1,d=-1;u.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];s.push(new r(e,n)),1!==s.length||l||a(o,0)},r.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=i,u.addListener=i,u.once=i,u.off=i,u.removeListener=i,u.removeAllListeners=i,u.emit=i,u.binding=function(e){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(e){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(e,n){"use strict";function t(e){a.push(e)}function o(e){c.push(e)}function r(e){u.push(e)}function i(e){f.push(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.addPayloadBuilder=t,n.addMetaBuilder=o,n.addTrackingBuilder=r,n.addHeaderBuilder=i;var a=n.payloadBuilders=[],c=n.metaBuilders=[],u=n.trackingBuilders=[],f=n.headerBuilders=[]},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.config={uri:"",prefix:"",initial_state_name:"init",flushInterval:6e5,debounceInterval:10,sizeLimit:300,silent:!1,heartbeat:!0,heartbeatConsoleLog:!0,heartbeatInterval:5e3,heartbeatTooBusy:!1,heartbeatTooBusyThreshold:1e4,autoLog:["warn","error"],logUnload:!0,logUnloadSync:!1,logPerformance:!0}},function(e,n,t){"use strict";function o(e){(0,i.extend)(r.config,e||{}),u||(u=!0,r.config.logPerformance&&(0,a.initPerformance)(),r.config.heartbeat&&(0,a.initHeartBeat)(),r.config.logUnload&&!function(){var e=!r.config.logUnloadSync;window.addEventListener("beforeunload",function(){(0,c.info)("window_beforeunload"),(0,c.immediateFlush)(e)}),window.addEventListener("unload",function(){(0,c.info)("window_unload"),(0,c.immediateFlush)(e)})}(),r.config.flushInterval&&setInterval(c.flush,r.config.flushInterval),window.beaverLogQueue&&(window.beaverLogQueue.forEach(function(e){(0,c.log)(e.level,e.event,e)}),delete window.beaverLogQueue))}Object.defineProperty(n,"__esModule",{value:!0}),n.init=o;var r=t(6),i=t(2),a=t(8),c=t(1),u=!1},function(e,n,t){"use strict";function o(){return d?performance.now():Date.now()}function r(e){return e=void 0!==e?e:o(),{startTime:e,elapsed:function(){return parseInt(o()-e,10)},reset:function(){e=o()}}}function i(){if(d){var e=window.performance.timing;return parseInt(e.connectEnd-e.navigationStart,10)}}function a(){var e=r(),n=0;(0,l.safeInterval)(function(){if(!(u.config.heartbeatMaxThreshold&&n>u.config.heartbeatMaxThreshold)){n+=1;var t=e.elapsed(),o=t-u.config.heartbeatInterval,r={count:n,elapsed:t};u.config.heartbeatTooBusy&&(r.lag=o,o>=u.config.heartbeatTooBusyThreshold&&(0,f.info)("toobusy",r,{noConsole:!u.config.heartbeatConsoleLog})),(0,f.info)("heartbeat",r,{noConsole:!u.config.heartbeatConsoleLog})}},u.config.heartbeatInterval)}function c(){return d?((0,s.addPayloadBuilder)(function(){var e={};return e.client_elapsed=h.elapsed(),d&&(e.req_elapsed=p.elapsed()),e}),void l.windowReady.then(function(){var e=["connectEnd","connectStart","domComplete","domContentLoadedEventEnd","domContentLoadedEventStart","domInteractive","domLoading","domainLookupEnd","domainLookupStart","fetchStart","loadEventEnd","loadEventStart","navigationStart","redirectEnd","redirectStart","requestStart","responseEnd","responseStart","secureConnectionStart","unloadEventEnd","unloadEventStart"],n={};e.forEach(function(e){n[e]=parseInt(window.performance.timing[e],10)||0});var t=n.connectEnd-n.navigationStart;n.connectEnd&&Object.keys(n).forEach(function(e){var o=n[e];o&&(0,f.info)("timing_"+e,{client_elapsed:parseInt(o-n.connectEnd-(h.startTime-t),10),req_elapsed:parseInt(o-n.connectEnd,10)})}),(0,f.info)("timing",n),(0,f.info)("memory",window.performance.memory),(0,f.info)("navigation",window.performance.navigation),window.performance.getEntries&&window.performance.getEntries().forEach(function(e){["link","script","img","css"].indexOf(e.initiatorType)>-1&&(0,f.info)(e.initiatorType,e)})})):(0,f.info)("no_performance_data")}Object.defineProperty(n,"__esModule",{value:!0}),n.reqTimer=n.clientTimer=void 0,n.now=o,n.reqStartElapsed=i,n.initHeartBeat=a,n.initPerformance=c;var u=t(6),f=t(1),s=t(5),l=t(2),d=window&&window.performance&&performance.now&&performance.timing&&performance.timing.connectEnd&&performance.timing.navigationStart&&Math.abs(performance.now()-Date.now())>1e3&&performance.now()-(performance.timing.connectEnd-performance.timing.navigationStart)>0,h=n.clientTimer=r(),p=n.reqTimer=r(i())},function(e,n,t){"use strict";function o(){p=(0,a.now)()}function r(e){p=p||(0,a.reqStartElapsed)();var n=(0,a.now)(),t=void 0;void 0!==p&&(t=parseInt(n-p,0));var o="transition_"+h+"_to_"+e;(0,c.info)(o,{duration:t}),(0,c.track)({transition:o,transition_time:t}),(0,c.immediateFlush)(),p=n,h=e,d=(0,f.uniqueID)()}function i(e){o(),r(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.startTransition=o,n.endTransition=r,n.transition=i;var a=t(8),c=t(1),u=t(5),f=t(2),s=t(6),l=(0,f.uniqueID)(),d=(0,f.uniqueID)(),h=s.config.initial_state_name,p=void 0;(0,u.addPayloadBuilder)(function(){return{windowID:l,pageID:d}}),(0,u.addMetaBuilder)(function(){return{state:"ui_"+h}})}])}); | ||
(function(){function a(e,n){A[L]=e,A[L+1]=n,L+=2,2===L&&P()}function c(e){return"function"==typeof e}function u(){return function(){r.nextTick(d)}}function f(){var e=0,n=new I(d),t=document.createTextNode("");return n.observe(t,{characterData:!0}),function(){t.data=e=++e%2}}function s(){var e=new MessageChannel;return e.port1.onmessage=d,function(){e.port2.postMessage(0)}}function l(){return function(){setTimeout(d,1)}}function d(){for(var e=0;e<L;e+=2)(0,A[e])(A[e+1]),A[e]=void 0,A[e+1]=void 0;L=0}function h(){}function p(e,n,t,o){try{e.call(n,t,o)}catch(r){return r}}function v(e,n,t){a(function(e){var o=!1,r=p(t,n,function(t){o||(o=!0,n!==t?m(e,t):y(e,t))},function(n){o||(o=!0,b(e,n))});!o&&r&&(o=!0,b(e,r))},e)}function g(e,n){1===n.a?y(e,n.b):2===e.a?b(e,n.b):E(n,void 0,function(n){m(e,n)},function(n){b(e,n)})}function m(e,n){if(e===n)b(e,new TypeError("You cannot resolve a promise with itself"));else if("function"==typeof n||"object"==typeof n&&null!==n)if(n.constructor===e.constructor)g(e,n);else{var t;try{t=n.then}catch(o){q.error=o,t=q}t===q?b(e,q.error):void 0===t?y(e,n):c(t)?v(e,n,t):y(e,n)}else y(e,n)}function w(e){e.f&&e.f(e.b),x(e)}function y(e,n){void 0===e.a&&(e.b=n,e.a=1,0!==e.e.length&&a(x,e))}function b(e,n){void 0===e.a&&(e.a=2,e.b=n,a(w,e))}function E(e,n,t,o){var r=e.e,i=r.length;e.f=null,r[i]=n,r[i+1]=t,r[i+2]=o,0===i&&e.a&&a(x,e)}function x(e){var n=e.e,t=e.a;if(0!==n.length){for(var o,r,i=e.b,a=0;a<n.length;a+=3)o=n[a],r=n[a+t],o?_(t,o,r,i):r(i);e.e.length=0}}function j(){this.error=null}function _(e,n,t,o){var r,i,a,u,f=c(t);if(f){try{r=t(o)}catch(s){B.error=s,r=B}if(r===B?(u=!0,i=r.error,r=null):a=!0,n===r)return void b(n,new TypeError("A promises callback cannot return that same promise."))}else r=o,a=!0;void 0===n.a&&(f&&a?m(n,r):u?b(n,i):1===e?y(n,r):2===e&&b(n,r))}function S(e,n){try{n(function(n){m(e,n)},function(n){b(e,n)})}catch(t){b(e,t)}}function k(e,n,t,o){this.n=e,this.c=new e(h,o),this.i=t,this.o(n)?(this.m=n,this.d=this.length=n.length,this.l(),0===this.length?y(this.c,this.b):(this.length=this.length||0,this.k(),0===this.d&&y(this.c,this.b))):b(this.c,this.p())}function T(e){if(D++,this.b=this.a=void 0,this.e=[],h!==e){if(!c(e))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof T))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");S(this,e)}}var P,O=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},L=0,M="undefined"!=typeof window?window:{},I=M.MutationObserver||M.WebKitMutationObserver,M="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,A=Array(1e3);P="undefined"!=typeof r&&"[object process]"==={}.toString.call(r)?u():I?f():M?s():l();var q=new j,B=new j;k.prototype.o=function(e){return O(e)},k.prototype.p=function(){return Error("Array Methods must be provided an Array")},k.prototype.l=function(){this.b=Array(this.length)},k.prototype.k=function(){for(var e=this.length,n=this.c,t=this.m,o=0;void 0===n.a&&o<e;o++)this.j(t[o],o)},k.prototype.j=function(e,n){var t=this.n;"object"==typeof e&&null!==e?e.constructor===t&&void 0!==e.a?(e.f=null,this.g(e.a,n,e.b)):this.q(t.resolve(e),n):(this.d--,this.b[n]=this.h(e))},k.prototype.g=function(e,n,t){var o=this.c;void 0===o.a&&(this.d--,this.i&&2===e?b(o,t):this.b[n]=this.h(t)),0===this.d&&y(o,this.b)},k.prototype.h=function(e){return e},k.prototype.q=function(e,n){var t=this;E(e,void 0,function(e){t.g(1,n,e)},function(e){t.g(2,n,e)})};var D=0;T.all=function(e,n){return new k(this,e,(!0),n).c},T.race=function(e,n){function t(e){m(r,e)}function o(e){b(r,e)}var r=new this(h,n);if(!O(e))return b(r,new TypeError("You must pass an array to race.")),r;for(var i=e.length,a=0;void 0===r.a&&a<i;a++)E(this.resolve(e[a]),void 0,t,o);return r},T.resolve=function(e,n){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(h,n);return m(t,e),t},T.reject=function(e,n){var t=new this(h,n);return b(t,e),t},T.prototype={constructor:T,then:function(e,n){var t=this.a;if(1===t&&!e||2===t&&!n)return this;var o=new this.constructor(h),r=this.b;if(t){var i=arguments[t-1];a(function(){_(t,o,i,r)})}else E(this,o,e,n);return o},"catch":function(e){return this.then(null,e)}};var C={Promise:T,polyfill:function(){var e;e="undefined"!=typeof i?i:"undefined"!=typeof window&&window.document?window:self,"Promise"in e&&"resolve"in e.Promise&&"reject"in e.Promise&&"all"in e.Promise&&"race"in e.Promise&&function(){var n;return new e.Promise(function(e){n=e}),c(n)}()||(e.Promise=T)}};o=function(){return C}.call(n,t,n,e),!(void 0!==o&&(e.exports=o))}).call(this)}).call(n,t(4),function(){return this}())},function(e,n){function t(){l&&f&&(l=!1,f.length?s=f.concat(s):d=-1,s.length&&o())}function o(){if(!l){var e=a(t);l=!0;for(var n=s.length;n;){for(f=s,s=[];++d<n;)f&&f[d].run();d=-1,n=s.length}f=null,l=!1,c(e)}}function r(e,n){this.fun=e,this.array=n}function i(){}var a,c,u=e.exports={};!function(){try{a=setTimeout}catch(e){a=function(){throw new Error("setTimeout is not defined")}}try{c=clearTimeout}catch(e){c=function(){throw new Error("clearTimeout is not defined")}}}();var f,s=[],l=!1,d=-1;u.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];s.push(new r(e,n)),1!==s.length||l||a(o,0)},r.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=i,u.addListener=i,u.once=i,u.off=i,u.removeListener=i,u.removeAllListeners=i,u.emit=i,u.binding=function(e){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(e){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(e,n){"use strict";function t(e){a.push(e)}function o(e){c.push(e)}function r(e){u.push(e)}function i(e){f.push(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.addPayloadBuilder=t,n.addMetaBuilder=o,n.addTrackingBuilder=r,n.addHeaderBuilder=i;var a=n.payloadBuilders=[],c=n.metaBuilders=[],u=n.trackingBuilders=[],f=n.headerBuilders=[]},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.config={uri:"",prefix:"",initial_state_name:"init",flushInterval:6e5,debounceInterval:10,sizeLimit:300,silent:!1,heartbeat:!0,heartbeatConsoleLog:!0,heartbeatInterval:5e3,heartbeatTooBusy:!1,heartbeatTooBusyThreshold:1e4,logLevel:"debug",autoLog:["warn","error"],logUnload:!0,logUnloadSync:!1,logPerformance:!0},n.logLevels=["error","warn","info","debug"]},function(e,n,t){"use strict";function o(e){(0,i.extend)(r.config,e||{}),u||(u=!0,r.config.logPerformance&&(0,a.initPerformance)(),r.config.heartbeat&&(0,a.initHeartBeat)(),r.config.logUnload&&!function(){var e=!r.config.logUnloadSync;window.addEventListener("beforeunload",function(){(0,c.info)("window_beforeunload"),(0,c.immediateFlush)(e)}),window.addEventListener("unload",function(){(0,c.info)("window_unload"),(0,c.immediateFlush)(e)})}(),r.config.flushInterval&&setInterval(c.flush,r.config.flushInterval),window.beaverLogQueue&&(window.beaverLogQueue.forEach(function(e){(0,c.log)(e.level,e.event,e)}),delete window.beaverLogQueue))}Object.defineProperty(n,"__esModule",{value:!0}),n.init=o;var r=t(6),i=t(2),a=t(8),c=t(1),u=!1},function(e,n,t){"use strict";function o(){return d?performance.now():Date.now()}function r(e){return e=void 0!==e?e:o(),{startTime:e,elapsed:function(){return parseInt(o()-e,10)},reset:function(){e=o()}}}function i(){if(d){var e=window.performance.timing;return parseInt(e.connectEnd-e.navigationStart,10)}}function a(){var e=r(),n=0;(0,l.safeInterval)(function(){if(!(u.config.heartbeatMaxThreshold&&n>u.config.heartbeatMaxThreshold)){n+=1;var t=e.elapsed(),o=t-u.config.heartbeatInterval,r={count:n,elapsed:t};u.config.heartbeatTooBusy&&(r.lag=o,o>=u.config.heartbeatTooBusyThreshold&&(0,f.info)("toobusy",r,{noConsole:!u.config.heartbeatConsoleLog})),(0,f.info)("heartbeat",r,{noConsole:!u.config.heartbeatConsoleLog})}},u.config.heartbeatInterval)}function c(){return d?((0,s.addPayloadBuilder)(function(){var e={};return e.client_elapsed=h.elapsed(),d&&(e.req_elapsed=p.elapsed()),e}),void l.windowReady.then(function(){var e=["connectEnd","connectStart","domComplete","domContentLoadedEventEnd","domContentLoadedEventStart","domInteractive","domLoading","domainLookupEnd","domainLookupStart","fetchStart","loadEventEnd","loadEventStart","navigationStart","redirectEnd","redirectStart","requestStart","responseEnd","responseStart","secureConnectionStart","unloadEventEnd","unloadEventStart"],n={};e.forEach(function(e){n[e]=parseInt(window.performance.timing[e],10)||0});var t=n.connectEnd-n.navigationStart;n.connectEnd&&Object.keys(n).forEach(function(e){var o=n[e];o&&(0,f.info)("timing_"+e,{client_elapsed:parseInt(o-n.connectEnd-(h.startTime-t),10),req_elapsed:parseInt(o-n.connectEnd,10)})}),(0,f.info)("timing",n),(0,f.info)("memory",window.performance.memory),(0,f.info)("navigation",window.performance.navigation),window.performance.getEntries&&window.performance.getEntries().forEach(function(e){["link","script","img","css"].indexOf(e.initiatorType)>-1&&(0,f.info)(e.initiatorType,e)})})):(0,f.info)("no_performance_data")}Object.defineProperty(n,"__esModule",{value:!0}),n.reqTimer=n.clientTimer=void 0,n.now=o,n.reqStartElapsed=i,n.initHeartBeat=a,n.initPerformance=c;var u=t(6),f=t(1),s=t(5),l=t(2),d=window&&window.performance&&performance.now&&performance.timing&&performance.timing.connectEnd&&performance.timing.navigationStart&&Math.abs(performance.now()-Date.now())>1e3&&performance.now()-(performance.timing.connectEnd-performance.timing.navigationStart)>0,h=n.clientTimer=r(),p=n.reqTimer=r(i())},function(e,n,t){"use strict";function o(){p=(0,a.now)()}function r(e){p=p||(0,a.reqStartElapsed)();var n=(0,a.now)(),t=void 0;void 0!==p&&(t=parseInt(n-p,0));var o="transition_"+h+"_to_"+e;(0,c.info)(o,{duration:t}),(0,c.track)({transition:o,transition_time:t}),(0,c.immediateFlush)(),p=n,h=e,d=(0,f.uniqueID)()}function i(e){o(),r(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.startTransition=o,n.endTransition=r,n.transition=i;var a=t(8),c=t(1),u=t(5),f=t(2),s=t(6),l=(0,f.uniqueID)(),d=(0,f.uniqueID)(),h=s.config.initial_state_name,p=void 0;(0,u.addPayloadBuilder)(function(){return{windowID:l,pageID:d}}),(0,u.addMetaBuilder)(function(){return{state:"ui_"+h}})}])}); |
{ | ||
"name": "beaver-logger", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Client side logger.", | ||
@@ -5,0 +5,0 @@ "main": "dist/beaver-logger.js", |
269670
3036