@honeybadger-io/js
Advanced tools
Comparing version 3.0.0-alpha.1 to 3.0.0-alpha.2
@@ -388,3 +388,3 @@ (function (global, factory) { | ||
url: 'https://github.com/honeybadger-io/honeybadger-js', | ||
version: '3.0.0-alpha.1' | ||
version: '3.0.0-alpha.2' | ||
}; | ||
@@ -391,0 +391,0 @@ var Client = /** @class */ (function () { |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Honeybadger=e()}(this,function(){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},o="<unknown>";function e(t){return t.split("\n").reduce(function(t,e){e=function(t){var e=i.exec(t);if(!e)return null;var n=e[2]&&0===e[2].indexOf("native"),r=e[2]&&0===e[2].indexOf("eval"),t=a.exec(e[2]);r&&null!=t&&(e[2]=t[1],e[3]=t[2],e[4]=t[3]);return{file:n?null:e[2],methodName:e[1]||o,arguments:n?[e[2]]:[],lineNumber:e[3]?+e[3]:null,column:e[4]?+e[4]:null}}(e)||function(t){t=c.exec(t);return t?{file:t[2],methodName:t[1]||o,arguments:[],lineNumber:+t[3],column:t[4]?+t[4]:null}:null}(e)||function(t){var e=s.exec(t);if(!e)return null;var n=e[3]&&-1<e[3].indexOf(" > eval"),t=u.exec(e[3]);n&&null!=t&&(e[3]=t[1],e[4]=t[2],e[5]=null);return{file:e[3],methodName:e[1]||o,arguments:e[2]?e[2].split(","):[],lineNumber:e[4]?+e[4]:null,column:e[5]?+e[5]:null}}(e)||function(t){t=l.exec(t);return t?{file:t[2],methodName:t[1]||o,arguments:[],lineNumber:+t[3],column:t[4]?+t[4]:null}:null}(e)||function(t){t=f.exec(t);return t?{file:t[3],methodName:t[1]||o,arguments:[],lineNumber:+t[4],column:t[5]?+t[5]:null}:null}(e);return e&&t.push(e),t},[])}var i=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,a=/\((\S*)(?::(\d+))(?::(\d+))\)/;var c=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var s=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,u=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;var f=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;var l=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;function d(t,e){var n,r={};for(n in t)r[n]=t[n];for(n in e)r[n]=e[n];return r}function p(t,e){var n=d(t,e);return t.context&&e.context&&(n.context=d(t.context,e.context)),n}function h(t,e,n){void 0===n&&(n=void 0);for(var r=0,o=e.length;r<o;r++)e[r](n,t);return 1}function m(t){if("object"!=typeof t)return{};var e,n={};for(e in t)n[e]=t[e];return n}function g(t,c){void 0===c&&(c=8);var s=[];return function e(t,n){if(void 0===n&&(n=0),c<=n)return"[DEPTH]";if(/function|symbol/.test(typeof(r=t))||null===r||"object"==typeof r&&void 0===r.hasOwnProperty)return Object.prototype.toString.call(t);var r;if(function(t){if(t&&"object"==typeof t){for(var e=0;e<s.length;e++)if(s[e]===t)return 1;s.push(t)}}(t))return"[RECURSION]";if(Array.isArray(t))return t.map(function(t){return e(t,n+1)});if("object"!=typeof t)return t;var o,i={};for(o in t){var a=t[o];Object.prototype.hasOwnProperty.call(t,o)&&null!=o&&null!=a&&(i[o]=e(a,n+1))}return i}(t)}function y(t){return t?"[object Error]"===Object.prototype.toString.call(t)?d(t,{name:t.name,message:t.message,stack:t.stack}):"object"==typeof t?m(t):{message:String(t)}:{}}function _(t,e,n){if(t&&e&&n&&e in t){for(var r=t[e];r&&r.__hb_original;)r=r.__hb_original;t[e]=n(r),t[e].__hb_original=r}}var b={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:"3.0.0-alpha.1"},t=(v.prototype.factory=function(t){throw new Error("Must implement __factory in subclass")},v.prototype.getVersion=function(){return b.version},v.prototype.configure=function(t){var e,n=this;for(e in void 0===t&&(t={}),t)this.config[e]=t[e];return this.__pluginsExecuted||(this.__pluginsExecuted=!0,this.config.__plugins.forEach(function(t){return t.load(n)})),this},v.prototype.beforeNotify=function(t){return this.__beforeNotifyHandlers.push(t),this},v.prototype.afterNotify=function(t){return this.__afterNotifyHandlers.push(t),this},v.prototype.setContext=function(t){return"object"==typeof t&&(this.__context=d(this.__context,t)),this},v.prototype.resetContext=function(t){return this.__context="object"==typeof t?d({},t):{},this},v.prototype.notify=function(t,e,n){return void 0===e&&(e=void 0),void 0===n&&(n=void 0),this.config.apiKey?this.config.disabled?(this.config.logger.debug("Dropping notice: honeybadger.js is disabled",t),!1):(t=y(t),e&&"object"!=typeof e&&(e={name:String(e)}),e&&(t=p(t,e)),"object"==typeof n&&(t=p(t,n)),!function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return;return 1}(t)&&(!!function(t,e){for(var n=0,r=e.length;n<r;n++)if(!1===(0,e[n])(t))return;return 1}(t=d(t,{name:t.name||"Error",context:d(this.__context,t.context),projectRoot:t.projectRoot||this.config.projectRoot,environment:t.environment||this.config.environment,component:t.component||this.config.component,action:t.action||this.config.action,revision:t.revision||this.config.revision}),this.__beforeNotifyHandlers)&&(r=t,n=this.config.ignorePatterns,(!Array.isArray(n)||!n.some(function(t){return t.test(r.message)}))&&(this.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:t.message,name:t.name,stack:t.stack}}),t.__breadcrumbs=this.config.breadcrumbsEnabled?this.__breadcrumbs.slice():[],this.__send(t))))):(this.config.logger.warn("Unable to send error report: no API key has been configured"),!1);var r},v.prototype.addBreadcrumb=function(t,e){if(this.config.breadcrumbsEnabled){var n=m((e=e||{}).metadata),r=e.category||"custom",e=(new Date).toISOString();this.__breadcrumbs.push({category:r,message:t,metadata:n,timestamp:e});e=this.config.maxBreadcrumbs;return this.__breadcrumbs.length>e&&(this.__breadcrumbs=this.__breadcrumbs.slice(this.__breadcrumbs.length-e)),this}},v.prototype.__send=function(t){throw new Error("Must implement send in subclass")},v.prototype.__buildPayload=function(t){return{notifier:b,breadcrumbs:{enabled:!!this.config.breadcrumbsEnabled,trail:t.__breadcrumbs||[]},error:{class:t.name,message:t.message,backtrace:function(t){if("string"!=typeof t)return[];try{return e(t).map(function(t){return{file:t.file,method:t.methodName,number:t.lineNumber,column:t.column}})}catch(t){return[]}}(t.stack),raw_backtrace:t.stack,fingerprint:t.fingerprint},request:{url:t.url,component:t.component,action:t.action,context:t.context,cgi_data:t.cgiData||{},params:t.params},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision}}},v);function v(t){function e(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift("[Honeybadger]"),console[e].apply(console,t)}}void 0===t&&(t={}),this.__pluginsExecuted=!1,this.__context={},this.__breadcrumbs=[],this.__beforeNotifyHandlers=[],this.__afterNotifyHandlers=[],this.config=r({apiKey:null,environment:null,projectRoot:null,component:null,action:null,revision:null,disabled:!1,breadcrumbsEnabled:!0,maxBreadcrumbs:40,maxObjectDepth:8,ignorePatterns:[],logger:{log:e("log"),info:e("info"),debug:e("debug"),warn:e("warn"),error:e("error")},__plugins:[]},t)}function w(n){if(!n||!n.tagName)return"";var r=n.tagName.toLowerCase();if("html"===r)return"";n.id&&(r+="#"+n.id);var t=n.getAttribute("class");t&&t.split(/\s+/).forEach(function(t){r+="."+t}),["alt","name","title","type"].forEach(function(t){var e=n.getAttribute(t);e&&(r+="["+t+'="'+e+'"]')});t=function(e){try{var t=e.parentNode.childNodes,n=[];return Array.prototype.forEach.call(t,function(t){t.tagName&&t.tagName===e.tagName&&n.push(t)}),n}catch(t){return[]}}(n);return 1<t.length&&(r+=":nth-child("+(Array.prototype.indexOf.call(t,n)+1)+")"),r}function E(t){var e=t.textContent||t.innerText||"";return e||"submit"!==t.type&&"button"!==t.type||(e=t.value),function(t,e){t.length>e&&(t=t.substr(0,e)+"...");return t}(e.trim(),300)}function x(t){return-1!==t.toString().indexOf("native")}function j(t){t=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:t[2],host:t[4],pathname:t[5]}}function k(t){var e=j(t),t=j(document.URL);return!e.host||!e.protocol||e.protocol===t.protocol&&e.host===t.host?e.pathname:e.protocol+"://"+e.host+e.pathname}var N,O,T,S,R,H,P,A,C,q=function(){var t=!0;if(window.atob||(t=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(t=!1)}catch(t){}return t}(),L=0;function B(){this.constructor=T}function M(t){void 0===t&&(t={});var e=O.call(this,r({async:!0,maxErrors:null,projectRoot:window.location.protocol+"//"+window.location.host},t))||this;return e.__errorsSent=0,e.__lastWrapErr=void 0,e.__beforeNotifyHandlers=[function(t){return e.__exceedsMaxErrors()?(e.config.logger.debug("Dropping notice: max errors exceeded",t),!1):(t.url||(t.url=document.URL),!0)}],e}return new(n(T=M,S=O=t),T.prototype=null===S?Object.create(S):(B.prototype=S.prototype,new B),M.prototype.resetMaxErrors=function(){return this.__errorsSent=0},M.prototype.wrap=function(t){return this.__wrap(t,{catch:!0})},M.prototype.factory=function(t){return new M(t)},M.prototype.__buildPayload=function(t){var e={HTTP_USER_AGENT:void 0,HTTP_REFERER:void 0,HTTP_COOKIE:void 0};e.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(e.HTTP_REFERER=document.referrer),"string"==typeof t.cookies?e.HTTP_COOKIE=t.cookies:"object"==typeof t.cookies&&(e.HTTP_COOKIE=function(t){if("object"==typeof t){var e,n=[];for(e in t)n.push(e+"="+t[e]);return n.join(";")}}(t.cookies));t=O.prototype.__buildPayload.call(this,t);return t.request.cgi_data=d(e,t.request.cgi_data),t},M.prototype.__send=function(e){var t=this;this.__incrementErrorsCount();var n=this.__buildPayload(e),r=Array.prototype.slice.call(this.__afterNotifyHandlers);e.afterNotify&&r.unshift(e.afterNotify);try{var o=new XMLHttpRequest;o.open("POST","https://api.honeybadger.io/v1/notices/js",this.config.async),o.setRequestHeader("X-API-Key",this.config.apiKey),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Accept","text/json, application/json"),o.send(JSON.stringify(g(n,this.config.maxObjectDepth))),o.onload=function(){if(201!==o.status)return h(e,r,new Error("Bad HTTP response: "+o.status)),void t.config.logger.debug("Unable to send error report: "+o.status+": "+o.statusText,o,e);h(d(e,{id:JSON.parse(o.response).id}),r),t.config.logger.debug("Error report sent",e)}}catch(t){h(e,r,t),this.config.logger.error("Unable to send error report: error while initializing request",t,e)}return!0},M.prototype.__wrap=function(t,e){void 0===e&&(e={});var n,r,o=t;e=e||{};try{return"function"!=typeof o?o:(r=o,"function"!=typeof Object.isExtensible||Object.isExtensible(r)?(o.___hb||(n=this,o.___hb=function(){var t=n.config.onerror;if(!e.catch&&!q&&t)return o.apply(this,arguments);try{return o.apply(this,arguments)}catch(t){if(n.__lastWrapErr===t)throw t;throw n.__lastWrapErr=t,L+=1,clearTimeout(N),N=setTimeout(function(){L=0}),n.addBreadcrumb(e.component?e.component+": "+t.name:t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:t.stack}}),n.notify(t),t}}),o.___hb.___hb=o.___hb,o.___hb):o)}catch(t){return o}},M.prototype.__incrementErrorsCount=function(){return this.__errorsSent++},M.prototype.__exceedsMaxErrors=function(){return this.config.maxErrors&&this.__errorsSent>=this.config.maxErrors},M)({__plugins:[(void 0===C&&(C=window),{load:function(a){void 0===a.config.onerror&&(a.config.onerror=!0),_(C,"onerror",function(i){return function(t,e,n,r,o){return function(t,e,n,r,o){if(a.config.logger.debug("window.onerror callback invoked",arguments),0<L)return a.config.logger.debug("Ignoring window.onerror (error likely reported earlier)",arguments),--L;a.config.onerror&&(0===n&&/Script error\.?/.test(t)?a.config.logger.info("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments):((o=y(o)).name||(o.name="window.onerror"),o.message||(o.message=t),o.stack||(o.stack=[o.message,"\n at ? (",e||"unknown",":",n||0,":",r||0,")"].join("")),a.addBreadcrumb("window.onerror"!==o.name&&o.name?"window.onerror: "+o.name:"window.onerror",{category:"error",metadata:{name:o.name,message:o.message,stack:o.stack}}),a.notify(o)))}(t,e,n,r,o),"function"==typeof i&&i.apply(window,arguments)}})}}),(void 0===A&&(A=window),{load:function(n){void 0===n.config.onunhandledrejection&&(n.config.onunhandledrejection=!0),_(A,"onunhandledrejection",function(e){return function(t){!function(t){if(n.config.logger.debug("window.onunhandledrejection callback invoked",arguments),n.config.onunhandledrejection){var e=t.reason;if(e instanceof Error){t=e.message+"\n at ? (unknown:0)",t=e.stack||t,t={name:e.name,message:"UnhandledPromiseRejectionWarning: "+e,stack:t};return n.addBreadcrumb("window.onunhandledrejection: "+t.name,{category:"error",metadata:t}),n.notify(t)}e="string"==typeof e?e:JSON.stringify(e);n.notify({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: "+e})}}(t),"function"==typeof e&&e.apply(this,arguments)}})}}),(void 0===P&&(P=window),{load:function(i){function t(o){return function(r){return function(t,e){if("function"!=typeof t)return r(t,e);var n=Array.prototype.slice.call(arguments,2);return t=i.__wrap(t,o),r(function(){t.apply(void 0,n)},e)}}}_(P,"setTimeout",t({component:"setTimeout"})),_(P,"setInterval",t({component:"setInterval"}))}}),(void 0===H&&(H=window),{load:function(a){["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"].forEach(function(t){var e=H[t]&&H[t].prototype;e&&Object.prototype.hasOwnProperty.call(e,"addEventListener")&&(_(e,"addEventListener",function(o){var i={component:t+".prototype.addEventListener"};return function(t,e,n,r){try{e&&null!=e.handleEvent&&(e.handleEvent=a.__wrap(e.handleEvent,i))}catch(t){a.config.logger.error(t)}return o.call(this,t,a.__wrap(e,i),n,r)}}),_(e,"removeEventListener",function(o){return function(t,e,n,r){return o.call(this,t,e,n,r),o.call(this,t,a.__wrap(e),n,r)}}))})}}),(void 0===R&&(R=window),{load:function(a){function t(t){return!0===a.config.breadcrumbsEnabled||(t?!0===a.config.breadcrumbsEnabled[t]:!1!==a.config.breadcrumbsEnabled)}function n(t,e){r=e,a.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:t,to:e}})}function e(e){return function(){var t=2<arguments.length?arguments[2]:void 0;return t&&n(r,String(t)),e.apply(this,arguments)}}var r;t("console")&&["debug","info","warn","error","log"].forEach(function(r){_(R.console,r,function(n){return function(){var t,e=Array.prototype.slice.call(arguments),t=(t=e,Array.isArray(t)?t.map(function(t){try{return String(t)}catch(t){return"[unknown]"}}).join(" "):""),e={category:"log",metadata:{level:r,arguments:g(e,3)}};a.addBreadcrumb(t,e),"function"==typeof n&&Function.prototype.apply.call(n,R.console,arguments)}})}),t("dom")&&R.addEventListener("click",function(t){var e,n,r;try{e=w(t.target),n=function t(e){var n=w(e);if(e.parentNode&&e.parentNode.tagName&&0<(e=t(e.parentNode)).length)return e+" > "+n;return n}(t.target),r=E(t.target)}catch(t){e="UI Click",r=n="[unknown]"}0!==e.length&&a.addBreadcrumb(e,{category:"ui.click",metadata:{selector:n,text:r,event:t}})},!0),t("network")&&(_(XMLHttpRequest.prototype,"open",function(r){return function(){var t=arguments[1],e="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],n=e+" "+k(t);this.__hb_xhr={type:"xhr",method:e,url:t,message:n},"function"==typeof r&&r.apply(this,arguments)}}),_(XMLHttpRequest.prototype,"send",function(t){return function(){var e=this;function n(){var t;4===e.readyState&&(t=void 0,e.__hb_xhr&&(e.__hb_xhr.status_code=e.status,t=e.__hb_xhr.message,delete e.__hb_xhr.message),a.addBreadcrumb(t||"XMLHttpRequest",{category:"request",metadata:e.__hb_xhr}))}"onreadystatechange"in e&&"function"==typeof e.onreadystatechange?_(e,"onreadystatechange",function(t){return function(){n(),"function"==typeof t&&t.apply(this,arguments)}}):e.onreadystatechange=n,"function"==typeof t&&t.apply(e,arguments)}})),!t("network")||function(){if(window.fetch){if(x(window.fetch))return 1;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&x(t.contentWindow.fetch);return document.head.removeChild(t),e}catch(t){console&&console.warn&&console.warn("failed to detect native fetch via iframe: "+t)}}}()&&_(R,"fetch",function(i){return function(){var t,e=arguments[0],n="GET";"string"==typeof e?t=e:"Request"in R&&e instanceof Request?(t=e.url,e.method&&(n=e.method)):t=String(e),arguments[1]&&arguments[1].method&&(n=arguments[1].method),"string"==typeof n&&(n=n.toUpperCase());var r=n+" "+k(t),o={type:"fetch",method:n,url:t};return i.apply(this,arguments).then(function(t){return o.status_code=t.status,a.addBreadcrumb(r,{category:"request",metadata:o}),t}).catch(function(t){throw a.addBreadcrumb("fetch error",{category:"error",metadata:o}),t})}}),t("navigation")&&(r=R.location.href,_(R,"onpopstate",function(t){return function(){if(n(r,R.location.href),t)return t.apply(this,arguments)}}),_(R.history,"pushState",e),_(R.history,"replaceState",e))}})]})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Honeybadger=e()}(this,function(){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},o="<unknown>";function e(t){return t.split("\n").reduce(function(t,e){e=function(t){var e=i.exec(t);if(!e)return null;var n=e[2]&&0===e[2].indexOf("native"),r=e[2]&&0===e[2].indexOf("eval"),t=a.exec(e[2]);r&&null!=t&&(e[2]=t[1],e[3]=t[2],e[4]=t[3]);return{file:n?null:e[2],methodName:e[1]||o,arguments:n?[e[2]]:[],lineNumber:e[3]?+e[3]:null,column:e[4]?+e[4]:null}}(e)||function(t){t=c.exec(t);return t?{file:t[2],methodName:t[1]||o,arguments:[],lineNumber:+t[3],column:t[4]?+t[4]:null}:null}(e)||function(t){var e=s.exec(t);if(!e)return null;var n=e[3]&&-1<e[3].indexOf(" > eval"),t=u.exec(e[3]);n&&null!=t&&(e[3]=t[1],e[4]=t[2],e[5]=null);return{file:e[3],methodName:e[1]||o,arguments:e[2]?e[2].split(","):[],lineNumber:e[4]?+e[4]:null,column:e[5]?+e[5]:null}}(e)||function(t){t=l.exec(t);return t?{file:t[2],methodName:t[1]||o,arguments:[],lineNumber:+t[3],column:t[4]?+t[4]:null}:null}(e)||function(t){t=f.exec(t);return t?{file:t[3],methodName:t[1]||o,arguments:[],lineNumber:+t[4],column:t[5]?+t[5]:null}:null}(e);return e&&t.push(e),t},[])}var i=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,a=/\((\S*)(?::(\d+))(?::(\d+))\)/;var c=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var s=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,u=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;var f=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;var l=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;function d(t,e){var n,r={};for(n in t)r[n]=t[n];for(n in e)r[n]=e[n];return r}function p(t,e){var n=d(t,e);return t.context&&e.context&&(n.context=d(t.context,e.context)),n}function h(t,e,n){void 0===n&&(n=void 0);for(var r=0,o=e.length;r<o;r++)e[r](n,t);return 1}function m(t){if("object"!=typeof t)return{};var e,n={};for(e in t)n[e]=t[e];return n}function g(t,c){void 0===c&&(c=8);var s=[];return function e(t,n){if(void 0===n&&(n=0),c<=n)return"[DEPTH]";if(/function|symbol/.test(typeof(r=t))||null===r||"object"==typeof r&&void 0===r.hasOwnProperty)return Object.prototype.toString.call(t);var r;if(function(t){if(t&&"object"==typeof t){for(var e=0;e<s.length;e++)if(s[e]===t)return 1;s.push(t)}}(t))return"[RECURSION]";if(Array.isArray(t))return t.map(function(t){return e(t,n+1)});if("object"!=typeof t)return t;var o,i={};for(o in t){var a=t[o];Object.prototype.hasOwnProperty.call(t,o)&&null!=o&&null!=a&&(i[o]=e(a,n+1))}return i}(t)}function y(t){return t?"[object Error]"===Object.prototype.toString.call(t)?d(t,{name:t.name,message:t.message,stack:t.stack}):"object"==typeof t?m(t):{message:String(t)}:{}}function _(t,e,n){if(t&&e&&n&&e in t){for(var r=t[e];r&&r.__hb_original;)r=r.__hb_original;t[e]=n(r),t[e].__hb_original=r}}var b={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:"3.0.0-alpha.2"},t=(v.prototype.factory=function(t){throw new Error("Must implement __factory in subclass")},v.prototype.getVersion=function(){return b.version},v.prototype.configure=function(t){var e,n=this;for(e in void 0===t&&(t={}),t)this.config[e]=t[e];return this.__pluginsExecuted||(this.__pluginsExecuted=!0,this.config.__plugins.forEach(function(t){return t.load(n)})),this},v.prototype.beforeNotify=function(t){return this.__beforeNotifyHandlers.push(t),this},v.prototype.afterNotify=function(t){return this.__afterNotifyHandlers.push(t),this},v.prototype.setContext=function(t){return"object"==typeof t&&(this.__context=d(this.__context,t)),this},v.prototype.resetContext=function(t){return this.__context="object"==typeof t?d({},t):{},this},v.prototype.notify=function(t,e,n){return void 0===e&&(e=void 0),void 0===n&&(n=void 0),this.config.apiKey?this.config.disabled?(this.config.logger.debug("Dropping notice: honeybadger.js is disabled",t),!1):(t=y(t),e&&"object"!=typeof e&&(e={name:String(e)}),e&&(t=p(t,e)),"object"==typeof n&&(t=p(t,n)),!function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return;return 1}(t)&&(!!function(t,e){for(var n=0,r=e.length;n<r;n++)if(!1===(0,e[n])(t))return;return 1}(t=d(t,{name:t.name||"Error",context:d(this.__context,t.context),projectRoot:t.projectRoot||this.config.projectRoot,environment:t.environment||this.config.environment,component:t.component||this.config.component,action:t.action||this.config.action,revision:t.revision||this.config.revision}),this.__beforeNotifyHandlers)&&(r=t,n=this.config.ignorePatterns,(!Array.isArray(n)||!n.some(function(t){return t.test(r.message)}))&&(this.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:t.message,name:t.name,stack:t.stack}}),t.__breadcrumbs=this.config.breadcrumbsEnabled?this.__breadcrumbs.slice():[],this.__send(t))))):(this.config.logger.warn("Unable to send error report: no API key has been configured"),!1);var r},v.prototype.addBreadcrumb=function(t,e){if(this.config.breadcrumbsEnabled){var n=m((e=e||{}).metadata),r=e.category||"custom",e=(new Date).toISOString();this.__breadcrumbs.push({category:r,message:t,metadata:n,timestamp:e});e=this.config.maxBreadcrumbs;return this.__breadcrumbs.length>e&&(this.__breadcrumbs=this.__breadcrumbs.slice(this.__breadcrumbs.length-e)),this}},v.prototype.__send=function(t){throw new Error("Must implement send in subclass")},v.prototype.__buildPayload=function(t){return{notifier:b,breadcrumbs:{enabled:!!this.config.breadcrumbsEnabled,trail:t.__breadcrumbs||[]},error:{class:t.name,message:t.message,backtrace:function(t){if("string"!=typeof t)return[];try{return e(t).map(function(t){return{file:t.file,method:t.methodName,number:t.lineNumber,column:t.column}})}catch(t){return[]}}(t.stack),raw_backtrace:t.stack,fingerprint:t.fingerprint},request:{url:t.url,component:t.component,action:t.action,context:t.context,cgi_data:t.cgiData||{},params:t.params},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision}}},v);function v(t){function e(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift("[Honeybadger]"),console[e].apply(console,t)}}void 0===t&&(t={}),this.__pluginsExecuted=!1,this.__context={},this.__breadcrumbs=[],this.__beforeNotifyHandlers=[],this.__afterNotifyHandlers=[],this.config=r({apiKey:null,environment:null,projectRoot:null,component:null,action:null,revision:null,disabled:!1,breadcrumbsEnabled:!0,maxBreadcrumbs:40,maxObjectDepth:8,ignorePatterns:[],logger:{log:e("log"),info:e("info"),debug:e("debug"),warn:e("warn"),error:e("error")},__plugins:[]},t)}function w(n){if(!n||!n.tagName)return"";var r=n.tagName.toLowerCase();if("html"===r)return"";n.id&&(r+="#"+n.id);var t=n.getAttribute("class");t&&t.split(/\s+/).forEach(function(t){r+="."+t}),["alt","name","title","type"].forEach(function(t){var e=n.getAttribute(t);e&&(r+="["+t+'="'+e+'"]')});t=function(e){try{var t=e.parentNode.childNodes,n=[];return Array.prototype.forEach.call(t,function(t){t.tagName&&t.tagName===e.tagName&&n.push(t)}),n}catch(t){return[]}}(n);return 1<t.length&&(r+=":nth-child("+(Array.prototype.indexOf.call(t,n)+1)+")"),r}function E(t){var e=t.textContent||t.innerText||"";return e||"submit"!==t.type&&"button"!==t.type||(e=t.value),function(t,e){t.length>e&&(t=t.substr(0,e)+"...");return t}(e.trim(),300)}function x(t){return-1!==t.toString().indexOf("native")}function j(t){t=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:t[2],host:t[4],pathname:t[5]}}function k(t){var e=j(t),t=j(document.URL);return!e.host||!e.protocol||e.protocol===t.protocol&&e.host===t.host?e.pathname:e.protocol+"://"+e.host+e.pathname}var N,O,T,S,R,H,P,A,C,q=function(){var t=!0;if(window.atob||(t=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(t=!1)}catch(t){}return t}(),L=0;function B(){this.constructor=T}function M(t){void 0===t&&(t={});var e=O.call(this,r({async:!0,maxErrors:null,projectRoot:window.location.protocol+"//"+window.location.host},t))||this;return e.__errorsSent=0,e.__lastWrapErr=void 0,e.__beforeNotifyHandlers=[function(t){return e.__exceedsMaxErrors()?(e.config.logger.debug("Dropping notice: max errors exceeded",t),!1):(t.url||(t.url=document.URL),!0)}],e}return new(n(T=M,S=O=t),T.prototype=null===S?Object.create(S):(B.prototype=S.prototype,new B),M.prototype.resetMaxErrors=function(){return this.__errorsSent=0},M.prototype.wrap=function(t){return this.__wrap(t,{catch:!0})},M.prototype.factory=function(t){return new M(t)},M.prototype.__buildPayload=function(t){var e={HTTP_USER_AGENT:void 0,HTTP_REFERER:void 0,HTTP_COOKIE:void 0};e.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(e.HTTP_REFERER=document.referrer),"string"==typeof t.cookies?e.HTTP_COOKIE=t.cookies:"object"==typeof t.cookies&&(e.HTTP_COOKIE=function(t){if("object"==typeof t){var e,n=[];for(e in t)n.push(e+"="+t[e]);return n.join(";")}}(t.cookies));t=O.prototype.__buildPayload.call(this,t);return t.request.cgi_data=d(e,t.request.cgi_data),t},M.prototype.__send=function(e){var t=this;this.__incrementErrorsCount();var n=this.__buildPayload(e),r=Array.prototype.slice.call(this.__afterNotifyHandlers);e.afterNotify&&r.unshift(e.afterNotify);try{var o=new XMLHttpRequest;o.open("POST","https://api.honeybadger.io/v1/notices/js",this.config.async),o.setRequestHeader("X-API-Key",this.config.apiKey),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Accept","text/json, application/json"),o.send(JSON.stringify(g(n,this.config.maxObjectDepth))),o.onload=function(){if(201!==o.status)return h(e,r,new Error("Bad HTTP response: "+o.status)),void t.config.logger.debug("Unable to send error report: "+o.status+": "+o.statusText,o,e);h(d(e,{id:JSON.parse(o.response).id}),r),t.config.logger.debug("Error report sent",e)}}catch(t){h(e,r,t),this.config.logger.error("Unable to send error report: error while initializing request",t,e)}return!0},M.prototype.__wrap=function(t,e){void 0===e&&(e={});var n,r,o=t;e=e||{};try{return"function"!=typeof o?o:(r=o,"function"!=typeof Object.isExtensible||Object.isExtensible(r)?(o.___hb||(n=this,o.___hb=function(){var t=n.config.onerror;if(!e.catch&&!q&&t)return o.apply(this,arguments);try{return o.apply(this,arguments)}catch(t){if(n.__lastWrapErr===t)throw t;throw n.__lastWrapErr=t,L+=1,clearTimeout(N),N=setTimeout(function(){L=0}),n.addBreadcrumb(e.component?e.component+": "+t.name:t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:t.stack}}),n.notify(t),t}}),o.___hb.___hb=o.___hb,o.___hb):o)}catch(t){return o}},M.prototype.__incrementErrorsCount=function(){return this.__errorsSent++},M.prototype.__exceedsMaxErrors=function(){return this.config.maxErrors&&this.__errorsSent>=this.config.maxErrors},M)({__plugins:[(void 0===C&&(C=window),{load:function(a){void 0===a.config.onerror&&(a.config.onerror=!0),_(C,"onerror",function(i){return function(t,e,n,r,o){return function(t,e,n,r,o){if(a.config.logger.debug("window.onerror callback invoked",arguments),0<L)return a.config.logger.debug("Ignoring window.onerror (error likely reported earlier)",arguments),--L;a.config.onerror&&(0===n&&/Script error\.?/.test(t)?a.config.logger.info("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments):((o=y(o)).name||(o.name="window.onerror"),o.message||(o.message=t),o.stack||(o.stack=[o.message,"\n at ? (",e||"unknown",":",n||0,":",r||0,")"].join("")),a.addBreadcrumb("window.onerror"!==o.name&&o.name?"window.onerror: "+o.name:"window.onerror",{category:"error",metadata:{name:o.name,message:o.message,stack:o.stack}}),a.notify(o)))}(t,e,n,r,o),"function"==typeof i&&i.apply(window,arguments)}})}}),(void 0===A&&(A=window),{load:function(n){void 0===n.config.onunhandledrejection&&(n.config.onunhandledrejection=!0),_(A,"onunhandledrejection",function(e){return function(t){!function(t){if(n.config.logger.debug("window.onunhandledrejection callback invoked",arguments),n.config.onunhandledrejection){var e=t.reason;if(e instanceof Error){t=e.message+"\n at ? (unknown:0)",t=e.stack||t,t={name:e.name,message:"UnhandledPromiseRejectionWarning: "+e,stack:t};return n.addBreadcrumb("window.onunhandledrejection: "+t.name,{category:"error",metadata:t}),n.notify(t)}e="string"==typeof e?e:JSON.stringify(e);n.notify({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: "+e})}}(t),"function"==typeof e&&e.apply(this,arguments)}})}}),(void 0===P&&(P=window),{load:function(i){function t(o){return function(r){return function(t,e){if("function"!=typeof t)return r(t,e);var n=Array.prototype.slice.call(arguments,2);return t=i.__wrap(t,o),r(function(){t.apply(void 0,n)},e)}}}_(P,"setTimeout",t({component:"setTimeout"})),_(P,"setInterval",t({component:"setInterval"}))}}),(void 0===H&&(H=window),{load:function(a){["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"].forEach(function(t){var e=H[t]&&H[t].prototype;e&&Object.prototype.hasOwnProperty.call(e,"addEventListener")&&(_(e,"addEventListener",function(o){var i={component:t+".prototype.addEventListener"};return function(t,e,n,r){try{e&&null!=e.handleEvent&&(e.handleEvent=a.__wrap(e.handleEvent,i))}catch(t){a.config.logger.error(t)}return o.call(this,t,a.__wrap(e,i),n,r)}}),_(e,"removeEventListener",function(o){return function(t,e,n,r){return o.call(this,t,e,n,r),o.call(this,t,a.__wrap(e),n,r)}}))})}}),(void 0===R&&(R=window),{load:function(a){function t(t){return!0===a.config.breadcrumbsEnabled||(t?!0===a.config.breadcrumbsEnabled[t]:!1!==a.config.breadcrumbsEnabled)}function n(t,e){r=e,a.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:t,to:e}})}function e(e){return function(){var t=2<arguments.length?arguments[2]:void 0;return t&&n(r,String(t)),e.apply(this,arguments)}}var r;t("console")&&["debug","info","warn","error","log"].forEach(function(r){_(R.console,r,function(n){return function(){var t,e=Array.prototype.slice.call(arguments),t=(t=e,Array.isArray(t)?t.map(function(t){try{return String(t)}catch(t){return"[unknown]"}}).join(" "):""),e={category:"log",metadata:{level:r,arguments:g(e,3)}};a.addBreadcrumb(t,e),"function"==typeof n&&Function.prototype.apply.call(n,R.console,arguments)}})}),t("dom")&&R.addEventListener("click",function(t){var e,n,r;try{e=w(t.target),n=function t(e){var n=w(e);if(e.parentNode&&e.parentNode.tagName&&0<(e=t(e.parentNode)).length)return e+" > "+n;return n}(t.target),r=E(t.target)}catch(t){e="UI Click",r=n="[unknown]"}0!==e.length&&a.addBreadcrumb(e,{category:"ui.click",metadata:{selector:n,text:r,event:t}})},!0),t("network")&&(_(XMLHttpRequest.prototype,"open",function(r){return function(){var t=arguments[1],e="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],n=e+" "+k(t);this.__hb_xhr={type:"xhr",method:e,url:t,message:n},"function"==typeof r&&r.apply(this,arguments)}}),_(XMLHttpRequest.prototype,"send",function(t){return function(){var e=this;function n(){var t;4===e.readyState&&(t=void 0,e.__hb_xhr&&(e.__hb_xhr.status_code=e.status,t=e.__hb_xhr.message,delete e.__hb_xhr.message),a.addBreadcrumb(t||"XMLHttpRequest",{category:"request",metadata:e.__hb_xhr}))}"onreadystatechange"in e&&"function"==typeof e.onreadystatechange?_(e,"onreadystatechange",function(t){return function(){n(),"function"==typeof t&&t.apply(this,arguments)}}):e.onreadystatechange=n,"function"==typeof t&&t.apply(e,arguments)}})),!t("network")||function(){if(window.fetch){if(x(window.fetch))return 1;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&x(t.contentWindow.fetch);return document.head.removeChild(t),e}catch(t){console&&console.warn&&console.warn("failed to detect native fetch via iframe: "+t)}}}()&&_(R,"fetch",function(i){return function(){var t,e=arguments[0],n="GET";"string"==typeof e?t=e:"Request"in R&&e instanceof Request?(t=e.url,e.method&&(n=e.method)):t=String(e),arguments[1]&&arguments[1].method&&(n=arguments[1].method),"string"==typeof n&&(n=n.toUpperCase());var r=n+" "+k(t),o={type:"fetch",method:n,url:t};return i.apply(this,arguments).then(function(t){return o.status_code=t.status,a.addBreadcrumb(r,{category:"request",metadata:o}),t}).catch(function(t){throw a.addBreadcrumb("fetch error",{category:"error",metadata:o}),t})}}),t("navigation")&&(r=R.location.href,_(R,"onpopstate",function(t){return function(){if(n(r,R.location.href),t)return t.apply(this,arguments)}}),_(R.history,"pushState",e),_(R.history,"replaceState",e))}})]})}); | ||
//# sourceMappingURL=honeybadger.min.js.map |
@@ -365,3 +365,3 @@ 'use strict'; | ||
url: 'https://github.com/honeybadger-io/honeybadger-js', | ||
version: '3.0.0-alpha.1' | ||
version: '3.0.0-alpha.2' | ||
}; | ||
@@ -368,0 +368,0 @@ var Client = /** @class */ (function () { |
{ | ||
"name": "@honeybadger-io/js", | ||
"version": "3.0.0-alpha.1", | ||
"version": "3.0.0-alpha.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/honeybadger-io/honeybadger-js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package