@honeybadger-io/js 4.0.4 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Honeybadger=e()}(this,(function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};var e=function(){return e=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},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var o="<unknown>";function i(t){return t.split("\n").reduce((function(t,e){var n=function(t){var e=a.exec(t);if(!e)return null;var n=e[2]&&0===e[2].indexOf("native"),r=e[2]&&0===e[2].indexOf("eval"),i=c.exec(e[2]);r&&null!=i&&(e[2]=i[1],e[3]=i[2],e[4]=i[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){var e=u.exec(t);if(!e)return null;return{file:e[2],methodName:e[1]||o,arguments:[],lineNumber:+e[3],column:e[4]?+e[4]:null}}(e)||function(t){var e=s.exec(t);if(!e)return null;var n=e[3]&&e[3].indexOf(" > eval")>-1,r=f.exec(e[3]);n&&null!=r&&(e[3]=r[1],e[4]=r[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){var e=d.exec(t);if(!e)return null;return{file:e[2],methodName:e[1]||o,arguments:[],lineNumber:+e[3],column:e[4]?+e[4]:null}}(e)||function(t){var e=l.exec(t);if(!e)return null;return{file:e[3],methodName:e[1]||o,arguments:[],lineNumber:+e[4],column:e[5]?+e[5]:null}}(e);return n&&t.push(n),t}),[])}var a=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,c=/\((\S*)(?::(\d+))(?::(\d+))\)/;var u=/^\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,f=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;var l=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;var d=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;function p(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n}function h(t,e){var n=p(t,e);return t.context&&e.context&&(n.context=p(t.context,e.context)),n}function g(t,e,n){t&&t.afterNotify&&t.afterNotify(n,t);for(var r=0,o=e.length;r<o;r++)e[r](n,t);return!0}function m(t){if("object"!=typeof t||null===t)return{};var e={};for(var n in t)e[n]=t[n];return e}function y(t,e){void 0===e&&(e=8);var n=[];function r(t,r){if(void 0===r&&(r=0),r>=e)return"[DEPTH]";if(!function(t){var e=typeof t;return/function/.test(e)?"toJSON"===t.name:!/symbol/.test(e)&&null!==t&&("object"!=typeof t||void 0!==t.hasOwnProperty)}(t))return Object.prototype.toString.call(t);if(function(t){if(!t||"object"!=typeof t)return!1;for(var e=0;e<n.length;e++)if(n[e]===t)return!0;return n.push(t),!1}(t))return"[RECURSION]";if(Array.isArray(t))return t.map((function(t){return o(t,r+1)}));if("object"==typeof t){var i={};for(var a in t){var c=t[a];Object.prototype.hasOwnProperty.call(t,a)&&null!=a&&null!=c&&(i[a]=o(c,r+1))}return i}return t}function o(t,e){void 0===e&&(e=0);try{return r(t,e)}catch(t){return"[ERROR] ".concat(t)}}return o(t)}function v(t){var e;if(t)if(t instanceof Error||"[object Error]"===Object.prototype.toString.call(t)){var n=t;e=p(t,{name:n.name,message:n.message,stack:n.stack})}else if("object"==typeof t)e=m(t);else{e={message:String(t)}}else e={};return e}function b(t,e,n){if(t&&e&&n&&e in t){for(var r=t[e];r&&r.__hb_original;)r=r.__hb_original;try{t[e]=n(r),t[e].__hb_original=r}catch(t){}}}function _(t,e){var n=t.trim().replace(/\/$/,"");return e=e.trim().replace(/(^\/|\/$)/g,""),"".concat(n,"/").concat(e)}function w(t,e){if(x("Object",t)){x("Array",e)||(e=[]);var n=[];return function t(r){var o,i;if(x("Object",r)||x("Array",r)){if(-1!==n.indexOf(r))return"[CIRCULAR DATA STRUCTURE]";n.push(r)}if(x("Object",r)){for(o in i={},r)E(o,e)?i[o]="[FILTERED]":i[o]=t(r[o]);return i}return x("Array",r)?r.map((function(e){return t(e)})):x("Function",r)?"[FUNC]":r}(t)}}function E(t,e){for(var n=0;n<e.length;n++)if(-1!==t.toLowerCase().indexOf(e[n].toLowerCase()))return!0;return!1}function x(t,e){var n=Object.prototype.toString.call(e).slice(8,-1);return null!=e&&n===t}function k(t,e){if(!e)return t;if("string"!=typeof t)return t;var n=t.split(/\?/,2)[1];if(!n)return t;var r=t;return n.split(/[&]\s?/).forEach((function(t){var n=t.split("=",2),o=n[0],i=n[1];E(o,e)&&(r=r.replace("".concat(o,"=").concat(i),"".concat(o,"=[FILTERED]")))})),r}var j=function(){function t(t){this.store=t}return t.prototype.getStore=function(){return this.store},t.prototype.run=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return this.store=t,e.apply(void 0,n)},t}(),N={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:"4.0.4"},S=/,|\s+/,O=/\S/,T=function(){function t(t,n){var r,o;void 0===t&&(t={}),this.__pluginsExecuted=!1,this.__store=null,this.__beforeNotifyHandlers=[],this.__afterNotifyHandlers=[],this.config=e({apiKey:null,endpoint:"https://api.honeybadger.io",environment:null,hostname:null,projectRoot:null,component:null,action:null,revision:null,reportData:null,breadcrumbsEnabled:!0,maxBreadcrumbs:40,maxObjectDepth:8,logger:console,developmentEnvironments:["dev","development","test"],debug:!1,tags:null,enableUncaught:!0,enableUnhandledRejection:!0,afterUncaught:function(){return!0},filters:["creditcard","password"],__plugins:[]},t),this.__store=new j({context:{},breadcrumbs:[]}),this.__transport=n,this.logger=(r=this,o=function(t){return function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if("debug"===t){if(!r.config.debug)return;t="log"}n.unshift("[Honeybadger]"),(e=r.config.logger)[t].apply(e,n)}},{log:o("log"),info:o("info"),debug:o("debug"),warn:o("warn"),error:o("error")})}return t.prototype.getVersion=function(){return N.version},t.prototype.configure=function(t){var e=this;for(var n in void 0===t&&(t={}),t)this.config[n]=t[n];return this.__pluginsExecuted||(this.__pluginsExecuted=!0,this.config.__plugins.forEach((function(t){return t.load(e)}))),this},t.prototype.__setStore=function(t){this.__store=t},t.prototype.beforeNotify=function(t){return this.__beforeNotifyHandlers.push(t),this},t.prototype.afterNotify=function(t){return this.__afterNotifyHandlers.push(t),this},t.prototype.setContext=function(t){if("object"==typeof t){var e=this.__store.getStore();e.context=p(e.context,t)}return this},t.prototype.resetContext=function(t){this.logger.warn("Deprecation warning: `Honeybadger.resetContext()` has been deprecated; please use `Honeybadger.clear()` instead.");var e=this.__store.getStore();return e.context="object"==typeof t&&null!==t?t:{},this},t.prototype.clear=function(){var t=this.__store.getStore();return t.context={},t.breadcrumbs=[],this},t.prototype.notify=function(t,e,o){var i=this;void 0===e&&(e=void 0),void 0===o&&(o=void 0);var a=null,c=this.makeNotice(t,e,o);c||(this.logger.debug("failed to build error report"),a=new Error("failed to build error report")),a||!1!==this.config.reportData||(this.logger.debug("skipping error report: honeybadger.js is disabled",c),a=new Error("honeybadger.js is disabled")),!a&&this.__developmentMode()&&(this.logger.log("honeybadger.js is in development mode; the following error report will be sent in production.",c),a=new Error("honeybadger.js is in development mode")),a||this.config.apiKey||(this.logger.warn("could not send error report: no API key has been configured",c),a=new Error("missing API key"));var u=c&&c.backtrace?c.backtrace.map((function(t){return m(t)})):null,s=function(t,e){for(var n=!0,r=0,o=e.length;r<o;r++)!1===(0,e[r])(t)&&(n=!1);return n}(c,this.__beforeNotifyHandlers);if(a||s||(this.logger.debug("skipping error report: beforeNotify handlers returned false",c),a=new Error("beforeNotify handlers returned false")),a)return g(c,this.__afterNotifyHandlers,a),!1;this.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:c.message,name:c.name,stack:c.stack}});var f=this.__getStoreContentsOrDefault().breadcrumbs;return c.__breadcrumbs=this.config.breadcrumbsEnabled?f.slice():[],function(t,e){return n(this,void 0,void 0,(function(){var n,o,i,a;return r(this,(function(r){switch(r.label){case 0:if(n=[],!e||!t||!t.length)return[2,n];o=0,r.label=1;case 1:return t.length?(i=t.splice(0)[o],[4,e(i.file)]):[3,3];case 2:return a=r.sent(),n[o]=function(t,e,n){if(void 0===n&&(n=2),!t)return null;var r=t.split("\n");r.unshift("");for(var o=e+n,i={},a=e-n;a<=o;a++){var c=r[a];"string"==typeof c&&(i[a]=c)}return i}(a,i.number),o++,[3,1];case 3:return[2,n]}}))}))}(u,this.__getSourceFileHandler).then((function(t){t.forEach((function(t,e){c.backtrace[e].source=t}));var e,n=i.__buildPayload(c);i.__transport.send({headers:{"X-API-Key":i.config.apiKey,"Content-Type":"application/json",Accept:"text/json, application/json"},method:"POST",endpoint:_(i.config.endpoint,"/v1/notices/js"),maxObjectDepth:i.config.maxObjectDepth,logger:i.logger,async:(e=i.config,void 0!==e.async?i.config.async:void 0)},n).then((function(t){if(201!==t.statusCode)return g(c,i.__afterNotifyHandlers,new Error("Bad HTTP response: ".concat(t.statusCode))),void i.logger.warn("Error report failed: unknown response from server. code=".concat(t.statusCode));var e=JSON.parse(t.body).id;g(p(c,{id:e}),i.__afterNotifyHandlers),i.logger.info("Error report sent ⚡ https://app.honeybadger.io/notice/".concat(e))})).catch((function(t){i.logger.error("Error report failed: an unknown error occurred.","message=".concat(t.message)),g(c,i.__afterNotifyHandlers,t)}))})),!0},t.prototype.notifyAsync=function(t,e,n){var r=this;return void 0===e&&(e=void 0),void 0===n&&(n=void 0),new Promise((function(o,i){var a,c,u;a=t.afterNotify?t:e&&e.afterNotify?e:n&&n.afterNotify?n:e&&"object"==typeof e?e:n||(e={}),u=(c=a).afterNotify,c.afterNotify=function(t){if(null==u||u.call(r,t),t)return i(t);o()},r.notify(t,e,n)}))},t.prototype.makeNotice=function(t,e,n){void 0===e&&(e=void 0),void 0===n&&(n=void 0);var r=v(t);e&&"object"!=typeof e&&(e={name:String(e)});if(e&&(r=h(r,e)),"object"==typeof n&&null!==n&&(r=h(r,n)),function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(r))return null;var o=this.__getStoreContentsOrDefault().context,a=this.__constructTags(r.tags),c=this.__constructTags(o.tags),u=this.__constructTags(this.config.tags),s=a.concat(c).concat(u),f=s.filter((function(t,e){return s.indexOf(t)===e})),l=0;return"string"==typeof(r=p(r,{name:r.name||"Error",context:p(o,r.context),projectRoot:r.projectRoot||this.config.projectRoot,environment:r.environment||this.config.environment,component:r.component||this.config.component,action:r.action||this.config.action,revision:r.revision||this.config.revision,tags:f})).stack&&r.stack.trim()||(r.stack=function(){try{throw new Error("")}catch(t){if(t.stack)return t.stack}for(var t=10,e=[],n=arguments.callee;n&&e.length<t;){/function(?:\s+([\w$]+))+\s*\(/.test(n.toString())?e.push(RegExp.$1||"<anonymous>"):e.push("<anonymous>");try{n=n.caller}catch(t){break}}return e.join("\n")}(),l=2),r.backtrace=function(t,e){void 0===e&&(e=0);try{var n=i(t).map((function(t){return{file:t.file,method:t.methodName,number:t.lineNumber,column:t.column}}));return n.splice(0,e),n}catch(t){return[]}}(r.stack,l),r},t.prototype.addBreadcrumb=function(t,e){if(this.config.breadcrumbsEnabled){var n=m((e=e||{}).metadata),r=e.category||"custom",o=(new Date).toISOString(),i=this.__store.getStore(),a=i.breadcrumbs;a.push({category:r,message:t,metadata:n,timestamp:o});var c=this.config.maxBreadcrumbs;return a.length>c&&(a=a.slice(a.length-c)),i.breadcrumbs=a,this}},t.prototype.__developmentMode=function(){return!0!==this.config.reportData&&(this.config.environment&&this.config.developmentEnvironments.includes(this.config.environment))},t.prototype.__buildPayload=function(t){var n=w(t.headers,this.config.filters)||{},r=w(e(e({},t.cgiData),function(t,e){void 0===e&&(e="");var n={};return Object.keys(t).forEach((function(r){var o=e+r.replace(/\W/g,"_").toUpperCase();n[o]=t[r]})),n}(n,"HTTP_")),this.config.filters);return{notifier:N,breadcrumbs:{enabled:!!this.config.breadcrumbsEnabled,trail:t.__breadcrumbs||[]},error:{class:t.name,message:t.message,backtrace:t.backtrace,fingerprint:t.fingerprint,tags:t.tags},request:{url:k(t.url,this.config.filters),component:t.component,action:t.action,context:t.context,cgi_data:r,params:w(t.params,this.config.filters)||{},session:w(t.session,this.config.filters)||{}},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision,hostname:this.config.hostname,time:(new Date).toUTCString()},details:t.details||{}}},t.prototype.__constructTags=function(t){return t?t.toString().split(S).filter((function(t){return O.test(t)})):[]},t.prototype.__getStoreContentsOrDefault=function(){var t=this.__store.getStore();return e({context:{},breadcrumbs:[]},t||{})},t}();function R(t){if(!t||!t.tagName)return"";var e=t.tagName.toLowerCase();if("html"===e)return"";t.id&&(e+="#".concat(t.id));var n=t.getAttribute("class");n&&n.split(/\s+/).forEach((function(t){e+=".".concat(t)})),["alt","name","title","type"].forEach((function(n){var r=t.getAttribute(n);r&&(e+="[".concat(n,'="').concat(r,'"]'))}));var r=function(t){try{var e=t.parentNode.childNodes,n=[];return Array.prototype.forEach.call(e,(function(e){e.tagName&&e.tagName===t.tagName&&n.push(e)})),n}catch(t){return[]}}(t);return r.length>1&&(e+=":nth-child(".concat(Array.prototype.indexOf.call(r,t)+1,")")),e}function C(t){var e=R(t);if(t.parentNode&&t.parentNode.tagName){var n=C(t.parentNode);if(n.length>0)return"".concat(n," > ").concat(e)}return e}function H(t){return-1!==t.toString().indexOf("native")}function P(t){var e=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:e[2],host:e[4],pathname:e[5]}}function A(t){var e=P(t),n=P(document.URL);return e.host&&e.protocol?e.protocol===n.protocol&&e.host===n.host?e.pathname:"".concat(e.protocol,"://").concat(e.host).concat(e.pathname):e.pathname}var U,D=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 I(){L+=1,clearTimeout(U),U=setTimeout((function(){L=0}))}var B,M=function(){function t(){}return t.prototype.send=function(t,e){return new Promise((function(n,r){try{var o=new XMLHttpRequest;if(o.open(t.method,t.endpoint,t.async),Object.keys(t.headers||[]).length)for(var i in t.headers)void 0!==t.headers[i]&&o.setRequestHeader(i,String(t.headers[i]));o.send(e?JSON.stringify(y(e,t.maxObjectDepth)):void 0),o.onload=function(){return n({statusCode:o.status,body:o.response})}}catch(t){r(t)}}))},t}(),q=function(n){function r(t){void 0===t&&(t={});var r=n.call(this,e({async:!0,maxErrors:null,projectRoot:window.location.protocol+"//"+window.location.host},t),new M)||this;return r.__errorsSent=0,r.__lastWrapErr=void 0,r.__beforeNotifyHandlers=[function(t){return r.__exceedsMaxErrors()?(r.logger.debug("Dropping notice: max errors exceeded",t),!1):(t&&!t.url&&(t.url=document.URL),r.__incrementErrorsCount(),!0)}],r}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,n),r.prototype.configure=function(t){return void 0===t&&(t={}),n.prototype.configure.call(this,t)},r.prototype.resetMaxErrors=function(){return this.__errorsSent=0},r.prototype.factory=function(t){return new r(t)},r.prototype.checkIn=function(t){throw new Error("Honeybadger.checkIn() is not supported on the browser")},r.prototype.__buildPayload=function(t){var e,r,o,i={HTTP_USER_AGENT:void 0,HTTP_REFERER:void 0,HTTP_COOKIE:void 0};i.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(i.HTTP_REFERER=document.referrer),"string"==typeof t.cookies?(r=t.cookies,o={},r.split(/[;,]\s?/).forEach((function(t){var e=t.split("=",2),n=e[0],r=e[1];o[n]=r})),e=o):e=t.cookies,e&&(i.HTTP_COOKIE=function(t){if("object"==typeof t){var e=[];for(var n in t)e.push(n+"="+t[n]);return e.join(";")}}(w(e,this.config.filters)));var a=n.prototype.__buildPayload.call(this,t);return a.request.cgi_data=p(i,a.request.cgi_data),a},r.prototype.__wrap=function(t,e){void 0===e&&(e={});var n,r=t;e||(e={});try{if("function"!=typeof r)return r;if(n=r,"function"==typeof Object.isExtensible&&!Object.isExtensible(n))return r;if(!r.___hb){var o=this;r.___hb=function(){if(!D)return r.apply(this,arguments);try{return r.apply(this,arguments)}catch(t){if(o.__lastWrapErr===t)throw t;throw o.__lastWrapErr=t,I(),o.addBreadcrumb(e.component?"".concat(e.component,": ").concat(t.name):t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:t.stack}}),o.config.enableUncaught&&o.notify(t),t}}}return r.___hb.___hb=r.___hb,r.___hb}catch(t){return r}},r.prototype.__incrementErrorsCount=function(){return this.__errorsSent++},r.prototype.__exceedsMaxErrors=function(){return this.config.maxErrors&&this.__errorsSent>=this.config.maxErrors},r}(T),W=new q({__plugins:[(void 0===B&&(B=window),{load:function(t){b(B,"onerror",(function(e){var n=function(e,n,r,o,i){if(t.logger.debug("window.onerror callback invoked",arguments),L>0)return t.logger.debug("Ignoring window.onerror (error likely reported earlier)",arguments),void(L-=1);if(0===r&&/Script error\.?/.test(e))t.config.enableUncaught&&t.logger.warn("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments);else{var a=v(i);a.name||(a.name="window.onerror"),a.message||(a.message=e),a.stack||(a.stack=[a.message,"\n at ? (",n||"unknown",":",r||0,":",o||0,")"].join("")),t.addBreadcrumb("window.onerror"!==a.name&&a.name?"window.onerror: ".concat(a.name):"window.onerror",{category:"error",metadata:{name:a.name,message:a.message,stack:a.stack}}),t.config.enableUncaught&&t.notify(a)}};return function(t,r,o,i,a){return n(t,r,o,i,a),"function"==typeof e&&e.apply(window,arguments)}}))}}),function(t){return void 0===t&&(t=window),{load:function(e){e.config.enableUnhandledRejection&&b(t,"onunhandledrejection",(function(t){function n(t){var n;if(e.logger.debug("window.onunhandledrejection callback invoked",arguments),e.config.enableUnhandledRejection){var r=t.reason;if(r instanceof Error){var o="unknown",i=0,a="".concat(r.message,"\n at ? (").concat(o,":").concat(i,")"),c=r.stack||a,u={name:r.name,message:"UnhandledPromiseRejectionWarning: ".concat(r),stack:c};return e.addBreadcrumb("window.onunhandledrejection: ".concat(u.name),{category:"error",metadata:u}),void e.notify(u)}var s="string"==typeof r?r:null!==(n=JSON.stringify(r))&&void 0!==n?n:"Unspecified reason";e.notify({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: ".concat(s)})}}return function(e){n(e),"function"==typeof t&&t.apply(this,arguments)}}))}}}(),function(t){return void 0===t&&(t=window),{load:function(e){!function(){function n(t){return function(n){return function(r,o){if("function"==typeof r){var i=Array.prototype.slice.call(arguments,2);return r=e.__wrap(r,t),n((function(){r.apply(void 0,i)}),o)}return n(r,o)}}}b(t,"setTimeout",n({component:"setTimeout"})),b(t,"setInterval",n({component:"setInterval"}))}()}}}(),function(t){return void 0===t&&(t=window),{load:function(e){["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(n){var r=t[n]&&t[n].prototype;r&&Object.prototype.hasOwnProperty.call(r,"addEventListener")&&(b(r,"addEventListener",(function(t){var r={component:"".concat(n,".prototype.addEventListener")};return function(n,o,i,a){try{o&&null!=o.handleEvent&&(o.handleEvent=e.__wrap(o.handleEvent,r))}catch(t){e.logger.error(t)}return t.call(this,n,e.__wrap(o,r),i,a)}})),b(r,"removeEventListener",(function(t){return function(n,r,o,i){return t.call(this,n,r,o,i),t.call(this,n,e.__wrap(r),o,i)}})))}))}}}(),function(t){return void 0===t&&(t=window),{load:function(e){function n(t){return!0===e.config.breadcrumbsEnabled||(t?!0===e.config.breadcrumbsEnabled[t]:!1!==e.config.breadcrumbsEnabled)}!function(){function r(t){return Array.isArray(t)?t.map((function(t){try{return String(t)}catch(t){return"[unknown]"}})).join(" "):""}n("console")&&["debug","info","warn","error","log"].forEach((function(n){b(t.console,n,(function(o){return function(){var i=Array.prototype.slice.call(arguments),a=r(i),c={category:"log",metadata:{level:n,arguments:y(i,3)}};e.addBreadcrumb(a,c),"function"==typeof o&&Function.prototype.apply.call(o,t.console,arguments)}}))}))}(),n("dom")&&t.addEventListener("click",(function(t){var n,r,o;try{n=R(t.target),r=C(t.target),o=function(t){var e,n,r=t.textContent||t.innerText||"";return r||"submit"!==t.type&&"button"!==t.type||(r=t.value),e=r.trim(),n=300,e.length>n&&(e=e.substr(0,n)+"..."),e}(t.target)}catch(t){n="UI Click",r="[unknown]",o="[unknown]"}0!==n.length&&e.addBreadcrumb(n,{category:"ui.click",metadata:{selector:r,text:o,event:t}})}),!0),n("network")&&(b(XMLHttpRequest.prototype,"open",(function(t){return function(){var e=this,n=arguments[1],r="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],o="".concat(r," ").concat(A(n));this.__hb_xhr={type:"xhr",method:r,url:n,message:o},"function"==typeof t&&t.apply(e,arguments)}})),b(XMLHttpRequest.prototype,"send",(function(t){return function(){var n=this;function r(){if(4===n.readyState){var t=void 0;n.__hb_xhr&&(n.__hb_xhr.status_code=n.status,t=n.__hb_xhr.message,delete n.__hb_xhr.message),e.addBreadcrumb(t||"XMLHttpRequest",{category:"request",metadata:n.__hb_xhr})}}"onreadystatechange"in n&&"function"==typeof n.onreadystatechange?b(n,"onreadystatechange",(function(t){return function(){r(),"function"==typeof t&&t.apply(this,arguments)}})):n.onreadystatechange=r,"function"==typeof t&&t.apply(n,arguments)}}))),n("network")&&function(){if(!window.fetch)return!1;if(H(window.fetch))return!0;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&H(t.contentWindow.fetch);return document.head.removeChild(t),e}catch(t){console&&console.warn&&console.warn("failed to detect native fetch via iframe: "+t)}return!1}()&&b(t,"fetch",(function(n){return function(){var r,o=arguments[0],i="GET";"string"==typeof o?r=o:"Request"in t&&o instanceof Request?(r=o.url,o.method&&(i=o.method)):r=String(o),arguments[1]&&arguments[1].method&&(i=arguments[1].method),"string"==typeof i&&(i=i.toUpperCase());var a="".concat(i," ").concat(A(r)),c={type:"fetch",method:i,url:r};return n.apply(this,arguments).then((function(t){return c.status_code=t.status,e.addBreadcrumb(a,{category:"request",metadata:c}),t})).catch((function(t){throw e.addBreadcrumb("fetch error",{category:"error",metadata:c}),t}))}})),function(){if(n("navigation")){var r=t.location.href;b(t,"onpopstate",(function(e){return function(){if(o(r,t.location.href),e)return e.apply(this,arguments)}})),b(t.history,"pushState",i),b(t.history,"replaceState",i)}function o(t,n){r=n,e.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:t,to:n}})}function i(t){return function(){var e=arguments.length>2?arguments[2]:void 0;return e&&o(r,String(e)),t.apply(this,arguments)}}}()}}}()]});return W}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Honeybadger=e()}(this,(function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};var e=function(){return e=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},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var o="<unknown>";function i(t){return t.split("\n").reduce((function(t,e){var n=function(t){var e=a.exec(t);if(!e)return null;var n=e[2]&&0===e[2].indexOf("native"),r=e[2]&&0===e[2].indexOf("eval"),i=c.exec(e[2]);r&&null!=i&&(e[2]=i[1],e[3]=i[2],e[4]=i[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){var e=u.exec(t);if(!e)return null;return{file:e[2],methodName:e[1]||o,arguments:[],lineNumber:+e[3],column:e[4]?+e[4]:null}}(e)||function(t){var e=s.exec(t);if(!e)return null;var n=e[3]&&e[3].indexOf(" > eval")>-1,r=f.exec(e[3]);n&&null!=r&&(e[3]=r[1],e[4]=r[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){var e=d.exec(t);if(!e)return null;return{file:e[2],methodName:e[1]||o,arguments:[],lineNumber:+e[3],column:e[4]?+e[4]:null}}(e)||function(t){var e=l.exec(t);if(!e)return null;return{file:e[3],methodName:e[1]||o,arguments:[],lineNumber:+e[4],column:e[5]?+e[5]:null}}(e);return n&&t.push(n),t}),[])}var a=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,c=/\((\S*)(?::(\d+))(?::(\d+))\)/;var u=/^\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,f=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;var l=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;var d=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;function p(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n}function h(t,e){var n=p(t,e);return t.context&&e.context&&(n.context=p(t.context,e.context)),n}function g(t,e,n){t&&t.afterNotify&&t.afterNotify(n,t);for(var r=0,o=e.length;r<o;r++)e[r](n,t);return!0}function m(t){if("object"!=typeof t||null===t)return{};var e={};for(var n in t)e[n]=t[n];return e}function y(t,e){void 0===e&&(e=8);var n=[];function r(t,r){if(void 0===r&&(r=0),r>=e)return"[DEPTH]";if(!function(t){var e=typeof t;return/function/.test(e)?"toJSON"===t.name:!/symbol/.test(e)&&null!==t&&("object"!=typeof t||void 0!==t.hasOwnProperty)}(t))return Object.prototype.toString.call(t);if(function(t){if(!t||"object"!=typeof t)return!1;for(var e=0;e<n.length;e++)if(n[e]===t)return!0;return n.push(t),!1}(t))return"[RECURSION]";if(Array.isArray(t))return t.map((function(t){return o(t,r+1)}));if("object"==typeof t){var i={};for(var a in t){var c=t[a];Object.prototype.hasOwnProperty.call(t,a)&&null!=a&&null!=c&&(i[a]=o(c,r+1))}return i}return t}function o(t,e){void 0===e&&(e=0);try{return r(t,e)}catch(t){return"[ERROR] ".concat(t)}}return o(t)}function v(t){var e;if(t)if(t instanceof Error||"[object Error]"===Object.prototype.toString.call(t)){var n=t;e=p(t,{name:n.name,message:n.message,stack:n.stack})}else if("object"==typeof t)e=m(t);else{e={message:String(t)}}else e={};return e}function b(t,e,n){if(t&&e&&n&&e in t){for(var r=t[e];r&&r.__hb_original;)r=r.__hb_original;try{t[e]=n(r),t[e].__hb_original=r}catch(t){}}}function _(t,e){var n=t.trim().replace(/\/$/,"");return e=e.trim().replace(/(^\/|\/$)/g,""),"".concat(n,"/").concat(e)}function w(t,e){if(x("Object",t)){x("Array",e)||(e=[]);var n=[];return function t(r){var o,i;if(x("Object",r)||x("Array",r)){if(-1!==n.indexOf(r))return"[CIRCULAR DATA STRUCTURE]";n.push(r)}if(x("Object",r)){for(o in i={},r)E(o,e)?i[o]="[FILTERED]":i[o]=t(r[o]);return i}return x("Array",r)?r.map((function(e){return t(e)})):x("Function",r)?"[FUNC]":r}(t)}}function E(t,e){for(var n=0;n<e.length;n++)if(-1!==t.toLowerCase().indexOf(e[n].toLowerCase()))return!0;return!1}function x(t,e){var n=Object.prototype.toString.call(e).slice(8,-1);return null!=e&&n===t}function k(t,e){if(!e)return t;if("string"!=typeof t)return t;var n=t.split(/\?/,2)[1];if(!n)return t;var r=t;return n.split(/[&]\s?/).forEach((function(t){var n=t.split("=",2),o=n[0],i=n[1];E(o,e)&&(r=r.replace("".concat(o,"=").concat(i),"".concat(o,"=[FILTERED]")))})),r}var j=function(){function t(t){this.store=t}return t.prototype.getStore=function(){return this.store},t.prototype.run=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return this.store=t,e.apply(void 0,n)},t}(),N={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:"4.0.5"},S=/,|\s+/,O=/\S/,T=function(){function t(t,n){var r,o;void 0===t&&(t={}),this.__pluginsExecuted=!1,this.__store=null,this.__beforeNotifyHandlers=[],this.__afterNotifyHandlers=[],this.config=e({apiKey:null,endpoint:"https://api.honeybadger.io",environment:null,hostname:null,projectRoot:null,component:null,action:null,revision:null,reportData:null,breadcrumbsEnabled:!0,maxBreadcrumbs:40,maxObjectDepth:8,logger:console,developmentEnvironments:["dev","development","test"],debug:!1,tags:null,enableUncaught:!0,enableUnhandledRejection:!0,afterUncaught:function(){return!0},filters:["creditcard","password"],__plugins:[]},t),this.__store=new j({context:{},breadcrumbs:[]}),this.__transport=n,this.logger=(r=this,o=function(t){return function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if("debug"===t){if(!r.config.debug)return;t="log"}n.unshift("[Honeybadger]"),(e=r.config.logger)[t].apply(e,n)}},{log:o("log"),info:o("info"),debug:o("debug"),warn:o("warn"),error:o("error")})}return t.prototype.getVersion=function(){return N.version},t.prototype.configure=function(t){var e=this;for(var n in void 0===t&&(t={}),t)this.config[n]=t[n];return this.__pluginsExecuted||(this.__pluginsExecuted=!0,this.config.__plugins.forEach((function(t){return t.load(e)}))),this},t.prototype.__setStore=function(t){this.__store=t},t.prototype.beforeNotify=function(t){return this.__beforeNotifyHandlers.push(t),this},t.prototype.afterNotify=function(t){return this.__afterNotifyHandlers.push(t),this},t.prototype.setContext=function(t){if("object"==typeof t){var e=this.__store.getStore();e.context=p(e.context,t)}return this},t.prototype.resetContext=function(t){this.logger.warn("Deprecation warning: `Honeybadger.resetContext()` has been deprecated; please use `Honeybadger.clear()` instead.");var e=this.__store.getStore();return e.context="object"==typeof t&&null!==t?t:{},this},t.prototype.clear=function(){var t=this.__store.getStore();return t.context={},t.breadcrumbs=[],this},t.prototype.notify=function(t,e,o){var i=this;void 0===e&&(e=void 0),void 0===o&&(o=void 0);var a=null,c=this.makeNotice(t,e,o);c||(this.logger.debug("failed to build error report"),a=new Error("failed to build error report")),a||!1!==this.config.reportData||(this.logger.debug("skipping error report: honeybadger.js is disabled",c),a=new Error("honeybadger.js is disabled")),!a&&this.__developmentMode()&&(this.logger.log("honeybadger.js is in development mode; the following error report will be sent in production.",c),a=new Error("honeybadger.js is in development mode")),a||this.config.apiKey||(this.logger.warn("could not send error report: no API key has been configured",c),a=new Error("missing API key"));var u=c&&c.backtrace?c.backtrace.map((function(t){return m(t)})):null,s=function(t,e){for(var n=!0,r=0,o=e.length;r<o;r++)!1===(0,e[r])(t)&&(n=!1);return n}(c,this.__beforeNotifyHandlers);if(a||s||(this.logger.debug("skipping error report: beforeNotify handlers returned false",c),a=new Error("beforeNotify handlers returned false")),a)return g(c,this.__afterNotifyHandlers,a),!1;this.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:c.message,name:c.name,stack:c.stack}});var f=this.__getStoreContentsOrDefault().breadcrumbs;return c.__breadcrumbs=this.config.breadcrumbsEnabled?f.slice():[],function(t,e){return n(this,void 0,void 0,(function(){var n,o,i,a;return r(this,(function(r){switch(r.label){case 0:if(n=[],!e||!t||!t.length)return[2,n];o=0,r.label=1;case 1:return t.length?(i=t.splice(0)[o],[4,e(i.file)]):[3,3];case 2:return a=r.sent(),n[o]=function(t,e,n){if(void 0===n&&(n=2),!t)return null;var r=t.split("\n");r.unshift("");for(var o=e+n,i={},a=e-n;a<=o;a++){var c=r[a];"string"==typeof c&&(i[a]=c)}return i}(a,i.number),o++,[3,1];case 3:return[2,n]}}))}))}(u,this.__getSourceFileHandler).then((function(t){t.forEach((function(t,e){c.backtrace[e].source=t}));var e,n=i.__buildPayload(c);i.__transport.send({headers:{"X-API-Key":i.config.apiKey,"Content-Type":"application/json",Accept:"text/json, application/json"},method:"POST",endpoint:_(i.config.endpoint,"/v1/notices/js"),maxObjectDepth:i.config.maxObjectDepth,logger:i.logger,async:(e=i.config,void 0!==e.async?i.config.async:void 0)},n).then((function(t){if(201!==t.statusCode)return g(c,i.__afterNotifyHandlers,new Error("Bad HTTP response: ".concat(t.statusCode))),void i.logger.warn("Error report failed: unknown response from server. code=".concat(t.statusCode));var e=JSON.parse(t.body).id;g(p(c,{id:e}),i.__afterNotifyHandlers),i.logger.info("Error report sent ⚡ https://app.honeybadger.io/notice/".concat(e))})).catch((function(t){i.logger.error("Error report failed: an unknown error occurred.","message=".concat(t.message)),g(c,i.__afterNotifyHandlers,t)}))})),!0},t.prototype.notifyAsync=function(t,e,n){var r=this;return void 0===e&&(e=void 0),void 0===n&&(n=void 0),new Promise((function(o,i){var a,c,u;a=t.afterNotify?t:e&&e.afterNotify?e:n&&n.afterNotify?n:e&&"object"==typeof e?e:n||(e={}),u=(c=a).afterNotify,c.afterNotify=function(t){if(null==u||u.call(r,t),t)return i(t);o()},r.notify(t,e,n)}))},t.prototype.makeNotice=function(t,e,n){void 0===e&&(e=void 0),void 0===n&&(n=void 0);var r=v(t);e&&"object"!=typeof e&&(e={name:String(e)});if(e&&(r=h(r,e)),"object"==typeof n&&null!==n&&(r=h(r,n)),function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(r))return null;var o=this.__getStoreContentsOrDefault().context,a=this.__constructTags(r.tags),c=this.__constructTags(o.tags),u=this.__constructTags(this.config.tags),s=a.concat(c).concat(u),f=s.filter((function(t,e){return s.indexOf(t)===e})),l=0;return"string"==typeof(r=p(r,{name:r.name||"Error",context:p(o,r.context),projectRoot:r.projectRoot||this.config.projectRoot,environment:r.environment||this.config.environment,component:r.component||this.config.component,action:r.action||this.config.action,revision:r.revision||this.config.revision,tags:f})).stack&&r.stack.trim()||(r.stack=function(){try{throw new Error("")}catch(t){if(t.stack)return t.stack}for(var t=10,e=[],n=arguments.callee;n&&e.length<t;){/function(?:\s+([\w$]+))+\s*\(/.test(n.toString())?e.push(RegExp.$1||"<anonymous>"):e.push("<anonymous>");try{n=n.caller}catch(t){break}}return e.join("\n")}(),l=2),r.backtrace=function(t,e){void 0===e&&(e=0);try{var n=i(t).map((function(t){return{file:t.file,method:t.methodName,number:t.lineNumber,column:t.column}}));return n.splice(0,e),n}catch(t){return[]}}(r.stack,l),r},t.prototype.addBreadcrumb=function(t,e){if(this.config.breadcrumbsEnabled){var n=m((e=e||{}).metadata),r=e.category||"custom",o=(new Date).toISOString(),i=this.__store.getStore(),a=i.breadcrumbs;a.push({category:r,message:t,metadata:n,timestamp:o});var c=this.config.maxBreadcrumbs;return a.length>c&&(a=a.slice(a.length-c)),i.breadcrumbs=a,this}},t.prototype.__developmentMode=function(){return!0!==this.config.reportData&&(this.config.environment&&this.config.developmentEnvironments.includes(this.config.environment))},t.prototype.__buildPayload=function(t){var n=w(t.headers,this.config.filters)||{},r=w(e(e({},t.cgiData),function(t,e){void 0===e&&(e="");var n={};return Object.keys(t).forEach((function(r){var o=e+r.replace(/\W/g,"_").toUpperCase();n[o]=t[r]})),n}(n,"HTTP_")),this.config.filters);return{notifier:N,breadcrumbs:{enabled:!!this.config.breadcrumbsEnabled,trail:t.__breadcrumbs||[]},error:{class:t.name,message:t.message,backtrace:t.backtrace,fingerprint:t.fingerprint,tags:t.tags},request:{url:k(t.url,this.config.filters),component:t.component,action:t.action,context:t.context,cgi_data:r,params:w(t.params,this.config.filters)||{},session:w(t.session,this.config.filters)||{}},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision,hostname:this.config.hostname,time:(new Date).toUTCString()},details:t.details||{}}},t.prototype.__constructTags=function(t){return t?t.toString().split(S).filter((function(t){return O.test(t)})):[]},t.prototype.__getStoreContentsOrDefault=function(){var t=this.__store.getStore();return e({context:{},breadcrumbs:[]},t||{})},t}();function R(t){if(!t||!t.tagName)return"";var e=t.tagName.toLowerCase();if("html"===e)return"";t.id&&(e+="#".concat(t.id));var n=t.getAttribute("class");n&&n.split(/\s+/).forEach((function(t){e+=".".concat(t)})),["alt","name","title","type"].forEach((function(n){var r=t.getAttribute(n);r&&(e+="[".concat(n,'="').concat(r,'"]'))}));var r=function(t){try{var e=t.parentNode.childNodes,n=[];return Array.prototype.forEach.call(e,(function(e){e.tagName&&e.tagName===t.tagName&&n.push(e)})),n}catch(t){return[]}}(t);return r.length>1&&(e+=":nth-child(".concat(Array.prototype.indexOf.call(r,t)+1,")")),e}function C(t){var e=R(t);if(t.parentNode&&t.parentNode.tagName){var n=C(t.parentNode);if(n.length>0)return"".concat(n," > ").concat(e)}return e}function H(t){return-1!==t.toString().indexOf("native")}function P(t){var e=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:e[2],host:e[4],pathname:e[5]}}function A(t){var e=P(t),n=P(document.URL);return e.host&&e.protocol?e.protocol===n.protocol&&e.host===n.host?e.pathname:"".concat(e.protocol,"://").concat(e.host).concat(e.pathname):e.pathname}var U,D=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 I(){L+=1,clearTimeout(U),U=setTimeout((function(){L=0}))}var B,M=function(){function t(){}return t.prototype.send=function(t,e){return new Promise((function(n,r){try{var o=new XMLHttpRequest;if(o.open(t.method,t.endpoint,t.async),Object.keys(t.headers||[]).length)for(var i in t.headers)void 0!==t.headers[i]&&o.setRequestHeader(i,String(t.headers[i]));o.send(e?JSON.stringify(y(e,t.maxObjectDepth)):void 0),o.onload=function(){return n({statusCode:o.status,body:o.response})}}catch(t){r(t)}}))},t}(),q=function(n){function r(t){void 0===t&&(t={});var r=n.call(this,e({async:!0,maxErrors:null,projectRoot:window.location.protocol+"//"+window.location.host},t),new M)||this;return r.__errorsSent=0,r.__lastWrapErr=void 0,r.__beforeNotifyHandlers=[function(t){return r.__exceedsMaxErrors()?(r.logger.debug("Dropping notice: max errors exceeded",t),!1):(t&&!t.url&&(t.url=document.URL),r.__incrementErrorsCount(),!0)}],r}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,n),r.prototype.configure=function(t){return void 0===t&&(t={}),n.prototype.configure.call(this,t)},r.prototype.resetMaxErrors=function(){return this.__errorsSent=0},r.prototype.factory=function(t){return new r(t)},r.prototype.checkIn=function(t){throw new Error("Honeybadger.checkIn() is not supported on the browser")},r.prototype.__buildPayload=function(t){var e,r,o,i={HTTP_USER_AGENT:void 0,HTTP_REFERER:void 0,HTTP_COOKIE:void 0};i.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(i.HTTP_REFERER=document.referrer),"string"==typeof t.cookies?(r=t.cookies,o={},r.split(/[;,]\s?/).forEach((function(t){var e=t.split("=",2),n=e[0],r=e[1];o[n]=r})),e=o):e=t.cookies,e&&(i.HTTP_COOKIE=function(t){if("object"==typeof t){var e=[];for(var n in t)e.push(n+"="+t[n]);return e.join(";")}}(w(e,this.config.filters)));var a=n.prototype.__buildPayload.call(this,t);return a.request.cgi_data=p(i,a.request.cgi_data),a},r.prototype.__wrap=function(t,e){void 0===e&&(e={});var n,r=t;e||(e={});try{if("function"!=typeof r)return r;if(n=r,"function"==typeof Object.isExtensible&&!Object.isExtensible(n))return r;if(!r.___hb){var o=this;r.___hb=function(){if(!D)return r.apply(this,arguments);try{return r.apply(this,arguments)}catch(t){if(o.__lastWrapErr===t)throw t;throw o.__lastWrapErr=t,I(),o.addBreadcrumb(e.component?"".concat(e.component,": ").concat(t.name):t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:t.stack}}),o.config.enableUncaught&&o.notify(t),t}}}return r.___hb.___hb=r.___hb,r.___hb}catch(t){return r}},r.prototype.__incrementErrorsCount=function(){return this.__errorsSent++},r.prototype.__exceedsMaxErrors=function(){return this.config.maxErrors&&this.__errorsSent>=this.config.maxErrors},r}(T),W=new q({__plugins:[(void 0===B&&(B=window),{load:function(t){b(B,"onerror",(function(e){var n=function(e,n,r,o,i){if(t.logger.debug("window.onerror callback invoked",arguments),L>0)return t.logger.debug("Ignoring window.onerror (error likely reported earlier)",arguments),void(L-=1);if(0===r&&/Script error\.?/.test(e))t.config.enableUncaught&&t.logger.warn("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments);else{var a=v(i);a.name||(a.name="window.onerror"),a.message||(a.message=e),a.stack||(a.stack=[a.message,"\n at ? (",n||"unknown",":",r||0,":",o||0,")"].join("")),t.addBreadcrumb("window.onerror"!==a.name&&a.name?"window.onerror: ".concat(a.name):"window.onerror",{category:"error",metadata:{name:a.name,message:a.message,stack:a.stack}}),t.config.enableUncaught&&t.notify(a)}};return function(t,r,o,i,a){return n(t,r,o,i,a),"function"==typeof e&&e.apply(window,arguments)}}))}}),function(t){return void 0===t&&(t=window),{load:function(e){e.config.enableUnhandledRejection&&b(t,"onunhandledrejection",(function(t){function n(t){var n;if(e.logger.debug("window.onunhandledrejection callback invoked",arguments),e.config.enableUnhandledRejection){var r=t.reason;if(r instanceof Error){var o="unknown",i=0,a="".concat(r.message,"\n at ? (").concat(o,":").concat(i,")"),c=r.stack||a,u={name:r.name,message:"UnhandledPromiseRejectionWarning: ".concat(r),stack:c};return e.addBreadcrumb("window.onunhandledrejection: ".concat(u.name),{category:"error",metadata:u}),void e.notify(u)}var s="string"==typeof r?r:null!==(n=JSON.stringify(r))&&void 0!==n?n:"Unspecified reason";e.notify({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: ".concat(s)})}}return function(e){n(e),"function"==typeof t&&t.apply(this,arguments)}}))}}}(),function(t){return void 0===t&&(t=window),{load:function(e){!function(){function n(t){return function(n){return function(r,o){if("function"==typeof r){var i=Array.prototype.slice.call(arguments,2);return r=e.__wrap(r,t),n((function(){r.apply(void 0,i)}),o)}return n(r,o)}}}b(t,"setTimeout",n({component:"setTimeout"})),b(t,"setInterval",n({component:"setInterval"}))}()}}}(),function(t){return void 0===t&&(t=window),{load:function(e){["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(n){var r=t[n]&&t[n].prototype;r&&Object.prototype.hasOwnProperty.call(r,"addEventListener")&&(b(r,"addEventListener",(function(t){var r={component:"".concat(n,".prototype.addEventListener")};return function(n,o,i,a){try{o&&null!=o.handleEvent&&(o.handleEvent=e.__wrap(o.handleEvent,r))}catch(t){e.logger.error(t)}return t.call(this,n,e.__wrap(o,r),i,a)}})),b(r,"removeEventListener",(function(t){return function(n,r,o,i){return t.call(this,n,r,o,i),t.call(this,n,e.__wrap(r),o,i)}})))}))}}}(),function(t){return void 0===t&&(t=window),{load:function(e){function n(t){return!0===e.config.breadcrumbsEnabled||(t?!0===e.config.breadcrumbsEnabled[t]:!1!==e.config.breadcrumbsEnabled)}!function(){function r(t){return Array.isArray(t)?t.map((function(t){try{return String(t)}catch(t){return"[unknown]"}})).join(" "):""}n("console")&&["debug","info","warn","error","log"].forEach((function(n){b(t.console,n,(function(o){return function(){var i=Array.prototype.slice.call(arguments),a=r(i),c={category:"log",metadata:{level:n,arguments:y(i,3)}};e.addBreadcrumb(a,c),"function"==typeof o&&Function.prototype.apply.call(o,t.console,arguments)}}))}))}(),n("dom")&&t.addEventListener("click",(function(t){var n,r,o;try{n=R(t.target),r=C(t.target),o=function(t){var e,n,r=t.textContent||t.innerText||"";return r||"submit"!==t.type&&"button"!==t.type||(r=t.value),e=r.trim(),n=300,e.length>n&&(e=e.substr(0,n)+"..."),e}(t.target)}catch(t){n="UI Click",r="[unknown]",o="[unknown]"}0!==n.length&&e.addBreadcrumb(n,{category:"ui.click",metadata:{selector:r,text:o,event:t}})}),!0),n("network")&&(b(XMLHttpRequest.prototype,"open",(function(t){return function(){var e=this,n=arguments[1],r="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],o="".concat(r," ").concat(A(n));this.__hb_xhr={type:"xhr",method:r,url:n,message:o},"function"==typeof t&&t.apply(e,arguments)}})),b(XMLHttpRequest.prototype,"send",(function(t){return function(){var n=this;function r(){if(4===n.readyState){var t=void 0;n.__hb_xhr&&(n.__hb_xhr.status_code=n.status,t=n.__hb_xhr.message,delete n.__hb_xhr.message),e.addBreadcrumb(t||"XMLHttpRequest",{category:"request",metadata:n.__hb_xhr})}}"onreadystatechange"in n&&"function"==typeof n.onreadystatechange?b(n,"onreadystatechange",(function(t){return function(){r(),"function"==typeof t&&t.apply(this,arguments)}})):n.onreadystatechange=r,"function"==typeof t&&t.apply(n,arguments)}}))),n("network")&&function(){if(!window.fetch)return!1;if(H(window.fetch))return!0;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&H(t.contentWindow.fetch);return document.head.removeChild(t),e}catch(t){console&&console.warn&&console.warn("failed to detect native fetch via iframe: "+t)}return!1}()&&b(t,"fetch",(function(n){return function(){var r,o=arguments[0],i="GET";"string"==typeof o?r=o:"Request"in t&&o instanceof Request?(r=o.url,o.method&&(i=o.method)):r=String(o),arguments[1]&&arguments[1].method&&(i=arguments[1].method),"string"==typeof i&&(i=i.toUpperCase());var a="".concat(i," ").concat(A(r)),c={type:"fetch",method:i,url:r};return n.apply(this,arguments).then((function(t){return c.status_code=t.status,e.addBreadcrumb(a,{category:"request",metadata:c}),t})).catch((function(t){throw e.addBreadcrumb("fetch error",{category:"error",metadata:c}),t}))}})),function(){if(n("navigation")){var r=t.location.href;b(t,"onpopstate",(function(e){return function(){if(o(r,t.location.href),e)return e.apply(this,arguments)}})),b(t.history,"pushState",i),b(t.history,"replaceState",i)}function o(t,n){r=n,e.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:t,to:n}})}function i(t){return function(){var e=arguments.length>2?arguments[2]:void 0;return e&&o(r,String(e)),t.apply(this,arguments)}}}()}}}()]});return W}));
|
|
2
2
|
//# sourceMappingURL=honeybadger.min.js.map
|
|
@@ -619,7 +619,7 @@ var GlobalStore = /** @class */ (function () {
|
|
|
619
619
|
var notifier = {
|
|
620
620
|
name: 'honeybadger-js',
|
|
621
621
|
url: 'https://github.com/honeybadger-io/honeybadger-js',
|
|
622
|
-
version: '4.0.
|
|
622
|
+
version: '4.0.5'
|
|
623
623
|
};
|
|
624
624
|
// Split at commas and spaces
|
|
625
625
|
var TAG_SEPARATOR = /,|\s+/;
|
|
@@ -1218,7 +1218,7 @@ var ServerTransport = /** @class */ (function () {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
ServerTransport.prototype.send = function (options, payload) {
|
|
1220
1220
|
var _this = this;
|
|
1221
|
-
var
|
|
1221
|
+
var _a = new url.URL(options.endpoint), protocol = _a.protocol, hostname = _a.hostname, pathname = _a.pathname;
|
|
1222
1222
|
var transport = (protocol === 'http:' ? http__default["default"] : https__default["default"]);
|
|
1223
1223
|
return new Promise(function (resolve, reject) {
|
|
1224
1224
|
var promise;
|
|
@@ -1231,16 +1231,22 @@ var ServerTransport = /** @class */ (function () {
|
|
|
1231
1231
|
promise = Promise.resolve();
|
|
1232
1232
|
}
|
|
1233
1233
|
promise.then(function () {
|
|
1234
|
+
//
|
|
1235
|
+
// We use a httpOptions object to limit issues with libraries that may patch Node.js
|
|
1236
|
+
// See https://github.com/honeybadger-io/honeybadger-js/issues/825#issuecomment-1193113433
|
|
1234
1237
|
var httpOptions = {
|
|
1235
1238
|
method: options.method,
|
|
1236
1239
|
headers: options.headers,
|
|
1240
|
+
path: pathname,
|
|
1241
|
+
protocol: protocol,
|
|
1242
|
+
hostname: hostname,
|
|
1237
1243
|
};
|
|
1238
1244
|
var data = undefined;
|
|
1239
1245
|
if (payload) {
|
|
1240
1246
|
data = Buffer.from(JSON.stringify(sanitize(payload, options.maxObjectDepth)), 'utf8');
|
|
1241
1247
|
httpOptions.headers['Content-Length'] = data.length;
|
|
1242
1248
|
}
|
|
1243
|
-
var req = transport.request(
|
|
1249
|
+
var req = transport.request(httpOptions, function (res) {
|
|
1244
1250
|
options.logger.debug("statusCode: ".concat(res.statusCode));
|
|
1245
1251
|
var body = '';
|
|
1246
1252
|
res.on('data', function (chunk) {
|