@honeybadger-io/js
Advanced tools
Comparing version 4.0.5 to 4.1.0
@@ -1,9 +0,8 @@ | ||
import Client from './types/core/client'; | ||
import { BrowserConfig } from './types/core/types'; | ||
import { Types, Client } from '@honeybadger-io/core'; | ||
declare class Honeybadger extends Client { | ||
config: BrowserConfig; | ||
constructor(opts?: Partial<BrowserConfig>); | ||
configure(opts?: Partial<BrowserConfig>): this; | ||
config: Types.BrowserConfig; | ||
constructor(opts?: Partial<Types.BrowserConfig>); | ||
configure(opts?: Partial<Types.BrowserConfig>): this; | ||
resetMaxErrors(): number; | ||
factory(opts?: Partial<BrowserConfig>): this; | ||
factory(opts?: Partial<Types.BrowserConfig>): this; | ||
checkIn(_id: string): Promise<void>; | ||
@@ -13,1 +12,2 @@ } | ||
export default _default; | ||
//# sourceMappingURL=browser.d.ts.map |
@@ -1,2 +0,2 @@ | ||
!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})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Honeybadger=t()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){var t=e.default;if("function"==typeof t){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n={},r={},o={},i={},a="<unknown>";var s=/^\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 l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,f=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;var d=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;var g=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;var p=Object.freeze({__proto__:null,parse:function(e){return e.split("\n").reduce((function(e,t){var n=function(e){var t=s.exec(e);if(!t)return null;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=c.exec(t[2]);r&&null!=o&&(t[2]=o[1],t[3]=o[2],t[4]=o[3]);return{file:n?null:t[2],methodName:t[1]||a,arguments:n?[t[2]]:[],lineNumber:t[3]?+t[3]:null,column:t[4]?+t[4]:null}}(t)||function(e){var t=u.exec(e);if(!t)return null;return{file:t[2],methodName:t[1]||a,arguments:[],lineNumber:+t[3],column:t[4]?+t[4]:null}}(t)||function(e){var t=l.exec(e);if(!t)return null;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=f.exec(t[3]);n&&null!=r&&(t[3]=r[1],t[4]=r[2],t[5]=null);return{file:t[3],methodName:t[1]||a,arguments:t[2]?t[2].split(","):[],lineNumber:t[4]?+t[4]:null,column:t[5]?+t[5]:null}}(t)||function(e){var t=g.exec(e);if(!t)return null;return{file:t[2],methodName:t[1]||a,arguments:[],lineNumber:+t[3],column:t[4]?+t[4]:null}}(t)||function(e){var t=d.exec(e);if(!t)return null;return{file:t[3],methodName:t[1]||a,arguments:[],lineNumber:+t[4],column:t[5]?+t[5]:null}}(t);return n&&e.push(n),e}),[])}}),h=t(p),m=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),b=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),y=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&m(t,e,n);return b(t,e),t},_=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(i,"__esModule",{value:!0}),i.isBrowserConfig=i.clone=i.formatCGIData=i.filterUrl=i.filter=i.generateStackTrace=i.endpoint=i.instrument=i.isErrorObject=i.makeNotice=i.logger=i.sanitize=i.shallowClone=i.runAfterNotifyHandlers=i.runBeforeNotifyHandlers=i.getSourceForBacktrace=i.getCauses=i.makeBacktrace=i.objectIsExtensible=i.objectIsEmpty=i.mergeNotice=i.merge=void 0;const v=y(h);function w(e,t){const n={};for(const t in e)n[t]=e[t];for(const e in t)n[e]=t[e];return n}function E(e,t=0){try{const n=v.parse(e).map((e=>({file:e.file,method:e.methodName,number:e.lineNumber,column:e.column})));return n.splice(0,t),n}catch(e){return[]}}function j(e){if("object"!=typeof e||null===e)return{};const t={};for(const n in e)t[n]=e[n];return t}function O(e){return e instanceof Error||"[object Error]"===Object.prototype.toString.call(e)}function k(e,t){for(let n=0;n<t.length;n++)if(-1!==e.toLowerCase().indexOf(t[n].toLowerCase()))return!0;return!1}function x(e,t){const n=Object.prototype.toString.call(t).slice(8,-1);return null!=t&&n===e}function N(e,t,n=2){if(!e)return null;const r=e.split("\n");r.unshift("");const o=t+n,i={};for(let e=t-n;e<=o;e++){const t=r[e];"string"==typeof t&&(i[e]=t)}return i}i.merge=w,i.mergeNotice=function(e,t){const n=w(e,t);return e.context&&t.context&&(n.context=w(e.context,t.context)),n},i.objectIsEmpty=function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},i.objectIsExtensible=function(e){return"function"!=typeof Object.isExtensible||Object.isExtensible(e)},i.makeBacktrace=E,i.getCauses=function(e){if(e.cause){const t=[];let n=e;for(;t.length<3&&(n=n.cause);)t.push({class:n.name,message:n.message,backtrace:"string"==typeof n.stack?E(n.stack):null});return t}return[]},i.getSourceForBacktrace=function(e,t){return _(this,void 0,void 0,(function*(){const n=[];if(!t||!e||!e.length)return n;let r=0;for(;e.length;){const o=e.splice(0)[r],i=yield t(o.file);n[r]=N(i,o.number),r++}return n}))},i.runBeforeNotifyHandlers=function(e,t){let n=!0;for(let r=0,o=t.length;r<o;r++){!1===(0,t[r])(e)&&(n=!1)}return n},i.runAfterNotifyHandlers=function(e,t,n){e&&e.afterNotify&&e.afterNotify(n,e);for(let r=0,o=t.length;r<o;r++)t[r](n,e);return!0},i.shallowClone=j,i.sanitize=function(e,t=8){const n=[];function r(e,r=0){if(r>=t)return"[DEPTH]";if(!function(e){const t=typeof e;return/function/.test(t)?"toJSON"===e.name:!/symbol/.test(t)&&null!==e&&("object"!=typeof e||void 0!==e.hasOwnProperty)}(e))return Object.prototype.toString.call(e);if(function(e){if(!e||"object"!=typeof e)return!1;for(let t=0;t<n.length;t++)if(n[t]===e)return!0;return n.push(e),!1}(e))return"[RECURSION]";if(Array.isArray(e))return e.map((e=>o(e,r+1)));if("object"==typeof e){const t={};for(const n in e){const i=e[n];Object.prototype.hasOwnProperty.call(e,n)&&null!=n&&null!=i&&(t[n]=o(i,r+1))}return t}return e}function o(e,t=0){try{return r(e,t)}catch(e){return`[ERROR] ${e}`}}return o(e)},i.logger=function(e){const t=t=>function(...n){if("debug"===t){if(!e.config.debug)return;t="log"}n.unshift("[Honeybadger]"),e.config.logger[t](...n)};return{log:t("log"),info:t("info"),debug:t("debug"),warn:t("warn"),error:t("error")}},i.makeNotice=function(e){let t;if(e)if(O(e)){const n=e;t=w(e,{name:n.name,message:n.message,stack:n.stack,cause:n.cause})}else if("object"==typeof e)t=j(e);else{t={message:String(e)}}else t={};return t},i.isErrorObject=O,i.instrument=function(e,t,n){if(!(e&&t&&n&&t in e))return;let r=e[t];for(;r&&r.__hb_original;)r=r.__hb_original;try{e[t]=n(r),e[t].__hb_original=r}catch(e){}},i.endpoint=function(e,t){return`${e.trim().replace(/\/$/,"")}/${t=t.trim().replace(/(^\/|\/$)/g,"")}`},i.generateStackTrace=function(){try{throw new Error("")}catch(e){if(e.stack)return e.stack}const e=10,t=[];let n=arguments.callee;for(;n&&t.length<e;){/function(?:\s+([\w$]+))+\s*\(/.test(n.toString())?t.push(RegExp.$1||"<anonymous>"):t.push("<anonymous>");try{n=n.caller}catch(e){break}}return t.join("\n")},i.filter=function(e,t){if(!x("Object",e))return;x("Array",t)||(t=[]);const n=[];return function e(r){let 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)k(o,t)?i[o]="[FILTERED]":i[o]=e(r[o]);return i}return x("Array",r)?r.map((function(t){return e(t)})):x("Function",r)?"[FUNC]":r}(e)},i.filterUrl=function(e,t){if(!t)return e;if("string"!=typeof e)return e;const n=e.split(/\?/,2)[1];if(!n)return e;let r=e;return n.split(/[&]\s?/).forEach((e=>{const[n,o]=e.split("=",2);k(n,t)&&(r=r.replace(`${n}=${o}`,`${n}=[FILTERED]`))})),r},i.formatCGIData=function(e,t=""){const n={};return Object.keys(e).forEach((function(r){const o=t+r.replace(/\W/g,"_").toUpperCase();n[o]=e[r]})),n},i.clone=function(e){return JSON.parse(JSON.stringify(e))},i.isBrowserConfig=function(e){return void 0!==e.async};var S={};Object.defineProperty(S,"__esModule",{value:!0}),S.GlobalStore=void 0;S.GlobalStore=class{constructor(e){this.store=e}getStore(){return this.store}run(e,t,...n){return this.store=e,t(...n)}},Object.defineProperty(o,"__esModule",{value:!0}),o.Client=void 0;const C=i,T=S,P={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:"4.1.0"},R=/,|\s+/,U=/\S/;o.Client=class{constructor(e={},t){this.__pluginsExecuted=!1,this.__store=null,this.__beforeNotifyHandlers=[],this.__afterNotifyHandlers=[],this.config=Object.assign({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:()=>!0,filters:["creditcard","password"],__plugins:[]},e),this.__store=new T.GlobalStore({context:{},breadcrumbs:[]}),this.__transport=t,this.logger=(0,C.logger)(this)}getVersion(){return P.version}configure(e={}){for(const t in e)this.config[t]=e[t];return this.__pluginsExecuted||(this.__pluginsExecuted=!0,this.config.__plugins.forEach((e=>e.load(this)))),this}__setStore(e){this.__store=e}beforeNotify(e){return this.__beforeNotifyHandlers.push(e),this}afterNotify(e){return this.__afterNotifyHandlers.push(e),this}setContext(e){if("object"==typeof e){const t=this.__store.getStore();t.context=(0,C.merge)(t.context,e)}return this}resetContext(e){this.logger.warn("Deprecation warning: `Honeybadger.resetContext()` has been deprecated; please use `Honeybadger.clear()` instead.");const t=this.__store.getStore();return t.context="object"==typeof e&&null!==e?e:{},this}clear(){const e=this.__store.getStore();return e.context={},e.breadcrumbs=[],this}notify(e,t,n){let r=null;const o=this.makeNotice(e,t,n);o||(this.logger.debug("failed to build error report"),r=new Error("failed to build error report")),r||!1!==this.config.reportData||(this.logger.debug("skipping error report: honeybadger.js is disabled",o),r=new Error("honeybadger.js is disabled")),!r&&this.__developmentMode()&&(this.logger.log("honeybadger.js is in development mode; the following error report will be sent in production.",o),r=new Error("honeybadger.js is in development mode")),r||this.config.apiKey||(this.logger.warn("could not send error report: no API key has been configured",o),r=new Error("missing API key"));const i=o&&o.backtrace?o.backtrace.map((e=>(0,C.shallowClone)(e))):null,a=(0,C.runBeforeNotifyHandlers)(o,this.__beforeNotifyHandlers);if(r||a||(this.logger.debug("skipping error report: beforeNotify handlers returned false",o),r=new Error("beforeNotify handlers returned false")),r)return(0,C.runAfterNotifyHandlers)(o,this.__afterNotifyHandlers,r),!1;this.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:o.message,name:o.name,stack:o.stack}});const s=this.__getStoreContentsOrDefault().breadcrumbs;return o.__breadcrumbs=this.config.breadcrumbsEnabled?s.slice():[],(0,C.getSourceForBacktrace)(i,this.__getSourceFileHandler).then((e=>{e.forEach(((e,t)=>{o.backtrace[t].source=e}));const t=this.__buildPayload(o);this.__transport.send({headers:{"X-API-Key":this.config.apiKey,"Content-Type":"application/json",Accept:"text/json, application/json"},method:"POST",endpoint:(0,C.endpoint)(this.config.endpoint,"/v1/notices/js"),maxObjectDepth:this.config.maxObjectDepth,logger:this.logger,async:(0,C.isBrowserConfig)(this.config)?this.config.async:void 0},t).then((e=>{if(201!==e.statusCode)return(0,C.runAfterNotifyHandlers)(o,this.__afterNotifyHandlers,new Error(`Bad HTTP response: ${e.statusCode}`)),void this.logger.warn(`Error report failed: unknown response from server. code=${e.statusCode}`);const t=JSON.parse(e.body).id;(0,C.runAfterNotifyHandlers)((0,C.merge)(o,{id:t}),this.__afterNotifyHandlers),this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${t}`)})).catch((e=>{this.logger.error("Error report failed: an unknown error occurred.",`message=${e.message}`),(0,C.runAfterNotifyHandlers)(o,this.__afterNotifyHandlers,e)}))})),!0}notifyAsync(e,t,n){return new Promise(((r,o)=>{let i;i=e.afterNotify?e:t&&t.afterNotify?t:n&&n.afterNotify?n:t&&"object"==typeof t?t:n||(t={}),(e=>{const t=e.afterNotify;e.afterNotify=e=>{if(null==t||t.call(this,e),e)return o(e);r()}})(i),this.notify(e,t,n)}))}makeNotice(e,t,n){let r=(0,C.makeNotice)(e);if(t&&"object"!=typeof t){t={name:String(t)}}if(t&&(r=(0,C.mergeNotice)(r,t)),"object"==typeof n&&null!==n&&(r=(0,C.mergeNotice)(r,n)),(0,C.objectIsEmpty)(r))return null;const o=this.__getStoreContentsOrDefault().context,i=this.__constructTags(r.tags),a=this.__constructTags(o.tags),s=this.__constructTags(this.config.tags),c=i.concat(a).concat(s),u=c.filter(((e,t)=>c.indexOf(e)===t));r=(0,C.merge)(r,{name:r.name||"Error",context:(0,C.merge)(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:u});let l=0;return"string"==typeof r.stack&&r.stack.trim()||(r.stack=(0,C.generateStackTrace)(),l=2),r.backtrace=(0,C.makeBacktrace)(r.stack,l),r}addBreadcrumb(e,t){if(!this.config.breadcrumbsEnabled)return;t=t||{};const n=(0,C.shallowClone)(t.metadata),r=t.category||"custom",o=(new Date).toISOString(),i=this.__store.getStore();let a=i.breadcrumbs;a.push({category:r,message:e,metadata:n,timestamp:o});const s=this.config.maxBreadcrumbs;return a.length>s&&(a=a.slice(a.length-s)),i.breadcrumbs=a,this}__developmentMode(){return!0!==this.config.reportData&&(this.config.environment&&this.config.developmentEnvironments.includes(this.config.environment))}__buildPayload(e){const t=(0,C.filter)(e.headers,this.config.filters)||{},n=(0,C.filter)(Object.assign(Object.assign({},e.cgiData),(0,C.formatCGIData)(t,"HTTP_")),this.config.filters);return{notifier:P,breadcrumbs:{enabled:!!this.config.breadcrumbsEnabled,trail:e.__breadcrumbs||[]},error:{class:e.name,message:e.message,backtrace:e.backtrace,fingerprint:e.fingerprint,tags:e.tags,causes:(0,C.getCauses)(e)},request:{url:(0,C.filterUrl)(e.url,this.config.filters),component:e.component,action:e.action,context:e.context,cgi_data:n,params:(0,C.filter)(e.params,this.config.filters)||{},session:(0,C.filter)(e.session,this.config.filters)||{}},server:{project_root:e.projectRoot,environment_name:e.environment,revision:e.revision,hostname:this.config.hostname,time:(new Date).toUTCString()},details:e.details||{}}}__constructTags(e){return e?e.toString().split(R).filter((e=>U.test(e))):[]}__getStoreContentsOrDefault(){const e=this.__store.getStore()||{};return Object.assign({context:{},breadcrumbs:[]},e)}};var H={};Object.defineProperty(H,"__esModule",{value:!0}),function(t){var n=e&&e.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=e&&e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&n(t,e,o);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Types=t.Store=t.Client=void 0;var s=o;Object.defineProperty(t,"Client",{enumerable:!0,get:function(){return s.Client}}),t.Store=a(S),t.Types=a(H),t.Util=a(i)}(r);var $={};function M(e){if(!e||!e.tagName)return"";let t=e.tagName.toLowerCase();if("html"===t)return"";e.id&&(t+=`#${e.id}`);const n=e.getAttribute("class");n&&n.split(/\s+/).forEach((e=>{t+=`.${e}`})),["alt","name","title","type"].forEach((n=>{const r=e.getAttribute(n);r&&(t+=`[${n}="${r}"]`)}));const r=function(e){try{const t=e.parentNode.childNodes,n=[];return Array.prototype.forEach.call(t,(t=>{t.tagName&&t.tagName===e.tagName&&n.push(t)})),n}catch(e){return[]}}(e);return r.length>1&&(t+=`:nth-child(${Array.prototype.indexOf.call(r,e)+1})`),t}function B(e){return-1!==e.toString().indexOf("native")}function A(e){const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:t[2],host:t[4],pathname:t[5]}}Object.defineProperty($,"__esModule",{value:!0}),$.preferCatch=$.encodeCookie=$.decodeCookie=$.localURLPathname=$.parseURL=$.nativeFetch=$.stringTextOfElement=$.stringSelectorOfElement=$.stringNameOfElement=void 0,$.stringNameOfElement=M,$.stringSelectorOfElement=function e(t){const n=M(t);if(t.parentNode&&t.parentNode.tagName){const r=e(t.parentNode);if(r.length>0)return`${r} > ${n}`}return n},$.stringTextOfElement=function(e){let t=e.textContent||e.innerText||"";return t||"submit"!==e.type&&"button"!==e.type||(t=e.value),function(e,t){e.length>t&&(e=e.substr(0,t)+"...");return e}(t.trim(),300)},$.nativeFetch=function(){if(!window.fetch)return!1;if(B(window.fetch))return!0;try{const e=document.createElement("iframe");e.style.display="none",document.head.appendChild(e);const t=e.contentWindow.fetch&&B(e.contentWindow.fetch);return document.head.removeChild(e),t}catch(e){console&&console.warn&&console.warn("failed to detect native fetch via iframe: "+e)}return!1},$.parseURL=A,$.localURLPathname=function(e){const t=A(e),n=A(document.URL);return t.host&&t.protocol?t.protocol===n.protocol&&t.host===n.host?t.pathname:`${t.protocol}://${t.host}${t.pathname}`:t.pathname},$.decodeCookie=function(e){const t={};return e.split(/[;,]\s?/).forEach((e=>{const[n,r]=e.split("=",2);t[n]=r})),t},$.encodeCookie=function(e){if("object"!=typeof e)return;const t=[];for(const n in e)t.push(n+"="+e[n]);return t.join(";")},$.preferCatch=function(){let e=!0;if(window.atob||(e=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(e=!1)}catch(e){}return e}();var D={};Object.defineProperty(D,"__esModule",{value:!0}),D.onError=D.ignoreNextOnError=void 0;const I=r,{instrument:L,makeNotice:q}=I.Util;let F,W=0;D.ignoreNextOnError=function(){W+=1,clearTimeout(F),F=setTimeout((()=>{W=0}))},D.onError=function(e=window){return{load:t=>{L(e,"onerror",(function(e){const n=function(e,n,r,o,i){if(t.logger.debug("window.onerror callback invoked",arguments),W>0)return t.logger.debug("Ignoring window.onerror (error likely reported earlier)",arguments),void(W-=1);if(0===r&&/Script error\.?/.test(e))return void(t.config.enableUncaught&&t.logger.warn("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments));const a=q(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: ${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)}}))}}};var G={};Object.defineProperty(G,"__esModule",{value:!0});const X=r,{instrument:K}=X.Util;G.default=function(e=window){return{load:t=>{t.config.enableUnhandledRejection&&K(e,"onunhandledrejection",(function(e){function n(e){var n;if(t.logger.debug("window.onunhandledrejection callback invoked",arguments),!t.config.enableUnhandledRejection)return;const{reason:r}=e;if(r instanceof Error){const e="unknown",n=0,o=`${r.message}\n at ? (${e}:${n})`,i=r.stack||o,a={name:r.name,message:`UnhandledPromiseRejectionWarning: ${r}`,stack:i};return t.addBreadcrumb(`window.onunhandledrejection: ${a.name}`,{category:"error",metadata:a}),void t.notify(a)}const o="string"==typeof r?r:null!==(n=JSON.stringify(r))&&void 0!==n?n:"Unspecified reason";t.notify({name:"window.onunhandledrejection",message:`UnhandledPromiseRejectionWarning: ${o}`})}return function(t){n(t),"function"==typeof e&&e.apply(this,arguments)}}))}}};var z={};Object.defineProperty(z,"__esModule",{value:!0});const J=r,V=$,{sanitize:Q,instrument:Y}=J.Util;z.default=function(e=window){return{load:t=>{function n(e){return!0===t.config.breadcrumbsEnabled||(e?!0===t.config.breadcrumbsEnabled[e]:!1!==t.config.breadcrumbsEnabled)}!function(){function r(e){return Array.isArray(e)?e.map((e=>{try{return String(e)}catch(e){return"[unknown]"}})).join(" "):""}n("console")&&["debug","info","warn","error","log"].forEach((n=>{Y(e.console,n,(function(o){return function(){const i=Array.prototype.slice.call(arguments),a=r(i),s={category:"log",metadata:{level:n,arguments:Q(i,3)}};t.addBreadcrumb(a,s),"function"==typeof o&&Function.prototype.apply.call(o,e.console,arguments)}}))}))}(),n("dom")&&e.addEventListener("click",(e=>{let n,r,o;try{n=(0,V.stringNameOfElement)(e.target),r=(0,V.stringSelectorOfElement)(e.target),o=(0,V.stringTextOfElement)(e.target)}catch(e){n="UI Click",r="[unknown]",o="[unknown]"}0!==n.length&&t.addBreadcrumb(n,{category:"ui.click",metadata:{selector:r,text:o,event:e}})}),!0),n("network")&&(Y(XMLHttpRequest.prototype,"open",(function(e){return function(){const t=this,n=arguments[1],r="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],o=`${r} ${(0,V.localURLPathname)(n)}`;this.__hb_xhr={type:"xhr",method:r,url:n,message:o},"function"==typeof e&&e.apply(t,arguments)}})),Y(XMLHttpRequest.prototype,"send",(function(e){return function(){const n=this;function r(){if(4===n.readyState){let e;n.__hb_xhr&&(n.__hb_xhr.status_code=n.status,e=n.__hb_xhr.message,delete n.__hb_xhr.message),t.addBreadcrumb(e||"XMLHttpRequest",{category:"request",metadata:n.__hb_xhr})}}"onreadystatechange"in n&&"function"==typeof n.onreadystatechange?Y(n,"onreadystatechange",(function(e){return function(){r(),"function"==typeof e&&e.apply(this,arguments)}})):n.onreadystatechange=r,"function"==typeof e&&e.apply(n,arguments)}}))),n("network")&&(0,V.nativeFetch)()&&Y(e,"fetch",(function(n){return function(){const r=arguments[0];let o,i="GET";"string"==typeof r?o=r:"Request"in e&&r instanceof Request?(o=r.url,r.method&&(i=r.method)):o=String(r),arguments[1]&&arguments[1].method&&(i=arguments[1].method),"string"==typeof i&&(i=i.toUpperCase());const a=`${i} ${(0,V.localURLPathname)(o)}`,s={type:"fetch",method:i,url:o};return n.apply(this,arguments).then((function(e){return s.status_code=e.status,t.addBreadcrumb(a,{category:"request",metadata:s}),e})).catch((function(e){throw t.addBreadcrumb("fetch error",{category:"error",metadata:s}),e}))}})),function(){if(!n("navigation"))return;let r=e.location.href;function o(e,n){r=n,t.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:e,to:n}})}function i(e){return function(){const t=arguments.length>2?arguments[2]:void 0;return t&&o(r,String(t)),e.apply(this,arguments)}}Y(e,"onpopstate",(function(t){return function(){if(o(r,e.location.href),t)return t.apply(this,arguments)}})),Y(e.history,"pushState",i),Y(e.history,"replaceState",i)}()}}};var Z={};Object.defineProperty(Z,"__esModule",{value:!0});const ee=r,{instrument:te}=ee.Util;Z.default=function(e=window){return{load:t=>{!function(){function n(e){return function(n){return function(r,o){if("function"==typeof r){const i=Array.prototype.slice.call(arguments,2);return r=t.__wrap(r,e),n((function(){r(...i)}),o)}return n(r,o)}}}te(e,"setTimeout",n({component:"setTimeout"})),te(e,"setInterval",n({component:"setInterval"}))}()}}};var ne={};Object.defineProperty(ne,"__esModule",{value:!0});const re=r,{instrument:oe}=re.Util;ne.default=function(e=window){return{load:t=>{["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){const r=e[n]&&e[n].prototype;r&&Object.prototype.hasOwnProperty.call(r,"addEventListener")&&(oe(r,"addEventListener",(function(e){const r={component:`${n}.prototype.addEventListener`};return function(n,o,i,a){try{o&&null!=o.handleEvent&&(o.handleEvent=t.__wrap(o.handleEvent,r))}catch(e){t.logger.error(e)}return e.call(this,n,t.__wrap(o,r),i,a)}})),oe(r,"removeEventListener",(function(e){return function(n,r,o,i){return e.call(this,n,r,o,i),e.call(this,n,t.__wrap(r),o,i)}})))}))}}};var ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.BrowserTransport=void 0;const ae=r,{sanitize:se}=ae.Util;ie.BrowserTransport=class{send(e,t){return new Promise(((n,r)=>{try{const r=new XMLHttpRequest;if(r.open(e.method,e.endpoint,e.async),Object.keys(e.headers||[]).length)for(const t in e.headers)void 0!==e.headers[t]&&r.setRequestHeader(t,String(e.headers[t]));r.send(t?JSON.stringify(se(t,e.maxObjectDepth)):void 0),r.onload=()=>n({statusCode:r.status,body:r.response})}catch(e){r(e)}}))}};var ce=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0});const ue=r,le=$,fe=D,de=ce(G),ge=ce(z),pe=ce(Z),he=ce(ne),me=ie,{merge:be,filter:ye,objectIsExtensible:_e}=ue.Util;class ve extends ue.Client{constructor(e={}){super(Object.assign({async:!0,maxErrors:null,projectRoot:window.location.protocol+"//"+window.location.host},e),new me.BrowserTransport),this.__errorsSent=0,this.__lastWrapErr=void 0,this.__beforeNotifyHandlers=[e=>this.__exceedsMaxErrors()?(this.logger.debug("Dropping notice: max errors exceeded",e),!1):(e&&!e.url&&(e.url=document.URL),this.__incrementErrorsCount(),!0)]}configure(e={}){return super.configure(e)}resetMaxErrors(){return this.__errorsSent=0}factory(e){return new ve(e)}checkIn(e){throw new Error("Honeybadger.checkIn() is not supported on the browser")}__buildPayload(e){const t={HTTP_USER_AGENT:void 0,HTTP_REFERER:void 0,HTTP_COOKIE:void 0};let n;t.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(t.HTTP_REFERER=document.referrer),n="string"==typeof e.cookies?(0,le.decodeCookie)(e.cookies):e.cookies,n&&(t.HTTP_COOKIE=(0,le.encodeCookie)(ye(n,this.config.filters)));const r=super.__buildPayload(e);return r.request.cgi_data=be(t,r.request.cgi_data),r}__wrap(e,t={}){const n=e;t||(t={});try{if("function"!=typeof n)return n;if(!_e(n))return n;if(!n.___hb){const e=this;n.___hb=function(){if(!le.preferCatch)return n.apply(this,arguments);try{return n.apply(this,arguments)}catch(n){if(e.__lastWrapErr===n)throw n;throw e.__lastWrapErr=n,(0,fe.ignoreNextOnError)(),e.addBreadcrumb(t.component?`${t.component}: ${n.name}`:n.name,{category:"error",metadata:{message:n.message,name:n.name,stack:n.stack}}),e.config.enableUncaught&&e.notify(n),n}}}return n.___hb.___hb=n.___hb,n.___hb}catch(e){return n}}__incrementErrorsCount(){return this.__errorsSent++}__exceedsMaxErrors(){return this.config.maxErrors&&this.__errorsSent>=this.config.maxErrors}}return n.default=new ve({__plugins:[(0,fe.onError)(),(0,de.default)(),(0,pe.default)(),(0,he.default)(),(0,ge.default)()]})})); | ||
//# sourceMappingURL=honeybadger.min.js.map |
@@ -1,5 +0,4 @@ | ||
import Client from './types/core/client'; | ||
import { Config, ServerlessConfig } from './types/core/types'; | ||
import { errorHandler, requestHandler } from './types/server/middleware'; | ||
import { lambdaHandler } from './types/server/aws_lambda'; | ||
import { Client, Types } from '@honeybadger-io/core'; | ||
import { errorHandler, requestHandler } from './middleware'; | ||
import { lambdaHandler } from './aws_lambda'; | ||
declare class Honeybadger extends Client { | ||
@@ -9,6 +8,6 @@ errorHandler: typeof errorHandler; | ||
lambdaHandler: typeof lambdaHandler; | ||
config: Config | ServerlessConfig; | ||
constructor(opts?: Partial<Config | ServerlessConfig>); | ||
factory(opts?: Partial<Config | ServerlessConfig>): this; | ||
configure(opts?: Partial<Config | ServerlessConfig>): this; | ||
config: Types.Config | Types.ServerlessConfig; | ||
constructor(opts?: Partial<Types.Config | Types.ServerlessConfig>); | ||
factory(opts?: Partial<Types.Config | Types.ServerlessConfig>): this; | ||
configure(opts?: Partial<Types.Config | Types.ServerlessConfig>): this; | ||
checkIn(id: string): Promise<void>; | ||
@@ -19,1 +18,2 @@ withRequest<R>(request: Record<symbol, unknown>, handler: (...args: never[]) => R, onError?: (...args: unknown[]) => unknown): R | void; | ||
export default _default; | ||
//# sourceMappingURL=server.d.ts.map |
'use strict'; | ||
var os = require('os'); | ||
var domain = require('domain'); | ||
var fs = require('fs'); | ||
var util = require('util'); | ||
var url = require('url'); | ||
var http = require('http'); | ||
var https = require('https'); | ||
var require$$0$1 = require('os'); | ||
var require$$1$1 = require('domain'); | ||
var require$$1 = require('fs'); | ||
var require$$2 = require('util'); | ||
var require$$0$2 = require('url'); | ||
var require$$2$1 = require('http'); | ||
var require$$3 = require('https'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var os__default = /*#__PURE__*/_interopDefaultLegacy(os); | ||
var domain__default = /*#__PURE__*/_interopDefaultLegacy(domain); | ||
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); | ||
var url__default = /*#__PURE__*/_interopDefaultLegacy(url); | ||
var http__default = /*#__PURE__*/_interopDefaultLegacy(http); | ||
var https__default = /*#__PURE__*/_interopDefaultLegacy(https); | ||
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1); | ||
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1); | ||
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); | ||
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); | ||
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2); | ||
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1); | ||
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3); | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
function getAugmentedNamespace(n) { | ||
var f = n.default; | ||
if (typeof f == "function") { | ||
var a = function () { | ||
return f.apply(this, arguments); | ||
}; | ||
a.prototype = f.prototype; | ||
} else a = {}; | ||
Object.defineProperty(a, '__esModule', {value: true}); | ||
Object.keys(n).forEach(function (k) { | ||
var d = Object.getOwnPropertyDescriptor(n, k); | ||
Object.defineProperty(a, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { | ||
return n[k]; | ||
} | ||
}); | ||
}); | ||
return a; | ||
} | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var server = {}; | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
var src = {}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var client = {}; | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var util$1 = {}; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
var UNKNOWN_FUNCTION = '<unknown>'; | ||
@@ -235,8 +187,50 @@ /** | ||
var stackTraceParser_esm = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
parse: parse | ||
}); | ||
var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm); | ||
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(util$1, "__esModule", { value: true }); | ||
util$1.isBrowserConfig = util$1.clone = util$1.formatCGIData = util$1.filterUrl = util$1.filter = util$1.generateStackTrace = util$1.endpoint = util$1.instrument = util$1.isErrorObject = util$1.makeNotice = util$1.logger = util$1.sanitize = util$1.shallowClone = util$1.runAfterNotifyHandlers = util$1.runBeforeNotifyHandlers = util$1.getSourceForBacktrace = util$1.getCauses = util$1.makeBacktrace = util$1.objectIsExtensible = util$1.objectIsEmpty = util$1.mergeNotice = util$1.merge = void 0; | ||
const stackTraceParser = __importStar(require$$0); | ||
function merge(obj1, obj2) { | ||
var result = {}; | ||
for (var k in obj1) { | ||
const result = {}; | ||
for (const k in obj1) { | ||
result[k] = obj1[k]; | ||
} | ||
for (var k in obj2) { | ||
for (const k in obj2) { | ||
result[k] = obj2[k]; | ||
@@ -246,4 +240,5 @@ } | ||
} | ||
util$1.merge = merge; | ||
function mergeNotice(notice1, notice2) { | ||
var result = merge(notice1, notice2); | ||
const result = merge(notice1, notice2); | ||
if (notice1.context && notice2.context) { | ||
@@ -254,4 +249,5 @@ result.context = merge(notice1.context, notice2.context); | ||
} | ||
util$1.mergeNotice = mergeNotice; | ||
function objectIsEmpty(obj) { | ||
for (var k in obj) { | ||
for (const k in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, k)) { | ||
@@ -263,7 +259,15 @@ return false; | ||
} | ||
function makeBacktrace(stack, shift) { | ||
if (shift === void 0) { shift = 0; } | ||
util$1.objectIsEmpty = objectIsEmpty; | ||
function objectIsExtensible(obj) { | ||
if (typeof Object.isExtensible !== 'function') { | ||
return true; | ||
} | ||
return Object.isExtensible(obj); | ||
} | ||
util$1.objectIsExtensible = objectIsExtensible; | ||
function makeBacktrace(stack, shift = 0) { | ||
try { | ||
var backtrace = parse(stack) | ||
.map(function (line) { | ||
const backtrace = stackTraceParser | ||
.parse(stack) | ||
.map(line => { | ||
return { | ||
@@ -284,32 +288,40 @@ file: line.file, | ||
} | ||
util$1.makeBacktrace = makeBacktrace; | ||
function getCauses(notice) { | ||
if (notice.cause) { | ||
const causes = []; | ||
let cause = notice; | ||
while (causes.length < 3 && (cause = cause.cause)) { | ||
causes.push({ | ||
class: cause.name, | ||
message: cause.message, | ||
backtrace: typeof cause.stack == 'string' ? makeBacktrace(cause.stack) : null | ||
}); | ||
} | ||
return causes; | ||
} | ||
return []; | ||
} | ||
util$1.getCauses = getCauses; | ||
function getSourceForBacktrace(backtrace, getSourceFileHandler) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result, index, trace, fileContent; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
result = []; | ||
if (!getSourceFileHandler || !backtrace || !backtrace.length) { | ||
return [2 /*return*/, result]; | ||
} | ||
index = 0; | ||
_a.label = 1; | ||
case 1: | ||
if (!backtrace.length) return [3 /*break*/, 3]; | ||
trace = backtrace.splice(0)[index]; | ||
return [4 /*yield*/, getSourceFileHandler(trace.file)]; | ||
case 2: | ||
fileContent = _a.sent(); | ||
result[index] = getSourceCodeSnippet(fileContent, trace.number); | ||
index++; | ||
return [3 /*break*/, 1]; | ||
case 3: return [2 /*return*/, result]; | ||
} | ||
}); | ||
return __awaiter$1(this, void 0, void 0, function* () { | ||
const result = []; | ||
if (!getSourceFileHandler || !backtrace || !backtrace.length) { | ||
return result; | ||
} | ||
let index = 0; | ||
while (backtrace.length) { | ||
const trace = backtrace.splice(0)[index]; | ||
const fileContent = yield getSourceFileHandler(trace.file); | ||
result[index] = getSourceCodeSnippet(fileContent, trace.number); | ||
index++; | ||
} | ||
return result; | ||
}); | ||
} | ||
util$1.getSourceForBacktrace = getSourceForBacktrace; | ||
function runBeforeNotifyHandlers(notice, handlers) { | ||
var result = true; | ||
for (var i = 0, len = handlers.length; i < len; i++) { | ||
var handler = handlers[i]; | ||
let result = true; | ||
for (let i = 0, len = handlers.length; i < len; i++) { | ||
const handler = handlers[i]; | ||
if (handler(notice) === false) { | ||
@@ -321,2 +333,3 @@ result = false; | ||
} | ||
util$1.runBeforeNotifyHandlers = runBeforeNotifyHandlers; | ||
function runAfterNotifyHandlers(notice, handlers, error) { | ||
@@ -326,3 +339,3 @@ if (notice && notice.afterNotify) { | ||
} | ||
for (var i = 0, len = handlers.length; i < len; i++) { | ||
for (let i = 0, len = handlers.length; i < len; i++) { | ||
handlers[i](error, notice); | ||
@@ -332,2 +345,3 @@ } | ||
} | ||
util$1.runAfterNotifyHandlers = runAfterNotifyHandlers; | ||
// Returns a new object with properties from other object. | ||
@@ -338,4 +352,4 @@ function shallowClone(obj) { | ||
} | ||
var result = {}; | ||
for (var k in obj) { | ||
const result = {}; | ||
for (const k in obj) { | ||
result[k] = obj[k]; | ||
@@ -345,5 +359,5 @@ } | ||
} | ||
function sanitize(obj, maxDepth) { | ||
if (maxDepth === void 0) { maxDepth = 8; } | ||
var seenObjects = []; | ||
util$1.shallowClone = shallowClone; | ||
function sanitize$1(obj, maxDepth = 8) { | ||
const seenObjects = []; | ||
function seen(obj) { | ||
@@ -353,4 +367,4 @@ if (!obj || typeof (obj) !== 'object') { | ||
} | ||
for (var i = 0; i < seenObjects.length; i++) { | ||
var value = seenObjects[i]; | ||
for (let i = 0; i < seenObjects.length; i++) { | ||
const value = seenObjects[i]; | ||
if (value === obj) { | ||
@@ -364,3 +378,3 @@ return true; | ||
function canSerialize(obj) { | ||
var typeOfObj = typeof obj; | ||
const typeOfObj = typeof obj; | ||
// Functions are TMI | ||
@@ -384,4 +398,3 @@ if (/function/.test(typeOfObj)) { | ||
} | ||
function serialize(obj, depth) { | ||
if (depth === void 0) { depth = 0; } | ||
function serialize(obj, depth = 0) { | ||
if (depth >= maxDepth) { | ||
@@ -400,9 +413,9 @@ return '[DEPTH]'; | ||
if (Array.isArray(obj)) { | ||
return obj.map(function (o) { return safeSerialize(o, depth + 1); }); | ||
return obj.map(o => safeSerialize(o, depth + 1)); | ||
} | ||
// Serialize inside objects | ||
if (typeof (obj) === 'object') { | ||
var ret = {}; | ||
for (var k in obj) { | ||
var v = obj[k]; | ||
const ret = {}; | ||
for (const k in obj) { | ||
const v = obj[k]; | ||
if (Object.prototype.hasOwnProperty.call(obj, k) && (k != null) && (v != null)) { | ||
@@ -417,4 +430,3 @@ ret[k] = safeSerialize(v, depth + 1); | ||
} | ||
function safeSerialize(obj, depth) { | ||
if (depth === void 0) { depth = 0; } | ||
function safeSerialize(obj, depth = 0) { | ||
try { | ||
@@ -424,3 +436,3 @@ return serialize(obj, depth); | ||
catch (e) { | ||
return "[ERROR] ".concat(e); | ||
return `[ERROR] ${e}`; | ||
} | ||
@@ -430,10 +442,6 @@ } | ||
} | ||
util$1.sanitize = sanitize$1; | ||
function logger(client) { | ||
var log = function (method) { | ||
return function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
const log = (method) => { | ||
return function (...args) { | ||
if (method === 'debug') { | ||
@@ -448,3 +456,3 @@ if (!client.config.debug) { | ||
args.unshift('[Honeybadger]'); | ||
(_a = client.config.logger)[method].apply(_a, args); | ||
client.config.logger[method](...args); | ||
}; | ||
@@ -460,2 +468,3 @@ }; | ||
} | ||
util$1.logger = logger; | ||
/** | ||
@@ -466,9 +475,9 @@ * Converts any object into a notice object (which at minimum has the same | ||
function makeNotice(thing) { | ||
var notice; | ||
let notice; | ||
if (!thing) { | ||
notice = {}; | ||
} | ||
else if (thing instanceof Error || Object.prototype.toString.call(thing) === '[object Error]') { | ||
var e = thing; | ||
notice = merge(thing, { name: e.name, message: e.message, stack: e.stack }); | ||
else if (isErrorObject(thing)) { | ||
const e = thing; | ||
notice = merge(thing, { name: e.name, message: e.message, stack: e.stack, cause: e.cause }); | ||
} | ||
@@ -479,3 +488,3 @@ else if (typeof thing === 'object') { | ||
else { | ||
var m = String(thing); | ||
const m = String(thing); | ||
notice = { message: m }; | ||
@@ -485,7 +494,40 @@ } | ||
} | ||
function endpoint(base, path) { | ||
var endpoint = base.trim().replace(/\/$/, ''); | ||
util$1.makeNotice = makeNotice; | ||
function isErrorObject(thing) { | ||
return thing instanceof Error | ||
|| Object.prototype.toString.call(thing) === '[object Error]'; // Important for cross-realm objects | ||
} | ||
util$1.isErrorObject = isErrorObject; | ||
/** | ||
* Instrument an existing function inside an object (usually global). | ||
* @param {!Object} object | ||
* @param {!String} name | ||
* @param {!Function} replacement | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function instrument(object, name, replacement) { | ||
if (!object || !name || !replacement || !(name in object)) { | ||
return; | ||
} | ||
let original = object[name]; | ||
while (original && original.__hb_original) { | ||
original = original.__hb_original; | ||
} | ||
try { | ||
object[name] = replacement(original); | ||
object[name].__hb_original = original; | ||
} | ||
catch (_e) { | ||
// Ignores errors like this one: | ||
// Error: TypeError: Cannot set property onunhandledrejection of [object Object] which has only a getter | ||
// User-Agent: Mozilla/5.0 (Linux; Android 10; SAMSUNG SM-G960F) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/12.1 Chrome/79.0.3945.136 Mobile Safari/537.36 | ||
} | ||
} | ||
util$1.instrument = instrument; | ||
function endpoint$1(base, path) { | ||
const endpoint = base.trim().replace(/\/$/, ''); | ||
path = path.trim().replace(/(^\/|\/$)/g, ''); | ||
return "".concat(endpoint, "/").concat(path); | ||
return `${endpoint}/${path}`; | ||
} | ||
util$1.endpoint = endpoint$1; | ||
function generateStackTrace() { | ||
@@ -500,5 +542,5 @@ try { | ||
} | ||
var maxStackSize = 10; | ||
var stack = []; | ||
var curr = arguments.callee; | ||
const maxStackSize = 10; | ||
const stack = []; | ||
let curr = arguments.callee; | ||
while (curr && stack.length < maxStackSize) { | ||
@@ -520,2 +562,3 @@ if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) { | ||
} | ||
util$1.generateStackTrace = generateStackTrace; | ||
function filter(obj, filters) { | ||
@@ -528,5 +571,5 @@ if (!is('Object', obj)) { | ||
} | ||
var seen = []; | ||
const seen = []; | ||
function filter(obj) { | ||
var k, newObj; | ||
let k, newObj; | ||
if (is('Object', obj) || is('Array', obj)) { | ||
@@ -562,4 +605,5 @@ if (seen.indexOf(obj) !== -1) { | ||
} | ||
util$1.filter = filter; | ||
function filterMatch(key, filters) { | ||
for (var i = 0; i < filters.length; i++) { | ||
for (let i = 0; i < filters.length; i++) { | ||
if (key.toLowerCase().indexOf(filters[i].toLowerCase()) !== -1) { | ||
@@ -572,3 +616,3 @@ return true; | ||
function is(type, obj) { | ||
var klass = Object.prototype.toString.call(obj).slice(8, -1); | ||
const klass = Object.prototype.toString.call(obj).slice(8, -1); | ||
return obj !== undefined && obj !== null && klass === type; | ||
@@ -583,11 +627,11 @@ } | ||
} | ||
var query = url.split(/\?/, 2)[1]; | ||
const query = url.split(/\?/, 2)[1]; | ||
if (!query) { | ||
return url; | ||
} | ||
var result = url; | ||
query.split(/[&]\s?/).forEach(function (pair) { | ||
var _a = pair.split('=', 2), key = _a[0], value = _a[1]; | ||
let result = url; | ||
query.split(/[&]\s?/).forEach((pair) => { | ||
const [key, value] = pair.split('=', 2); | ||
if (filterMatch(key, filters)) { | ||
result = result.replace("".concat(key, "=").concat(value), "".concat(key, "=[FILTERED]")); | ||
result = result.replace(`${key}=${value}`, `${key}=[FILTERED]`); | ||
} | ||
@@ -597,7 +641,7 @@ }); | ||
} | ||
function formatCGIData(vars, prefix) { | ||
if (prefix === void 0) { prefix = ''; } | ||
var formattedVars = {}; | ||
util$1.filterUrl = filterUrl; | ||
function formatCGIData(vars, prefix = '') { | ||
const formattedVars = {}; | ||
Object.keys(vars).forEach(function (key) { | ||
var formattedKey = prefix + key.replace(/\W/g, '_').toUpperCase(); | ||
const formattedKey = prefix + key.replace(/\W/g, '_').toUpperCase(); | ||
formattedVars[formattedKey] = vars[key]; | ||
@@ -607,15 +651,19 @@ }); | ||
} | ||
function getSourceCodeSnippet(fileData, lineNumber, sourceRadius) { | ||
if (sourceRadius === void 0) { sourceRadius = 2; } | ||
util$1.formatCGIData = formatCGIData; | ||
function clone(obj) { | ||
return JSON.parse(JSON.stringify(obj)); | ||
} | ||
util$1.clone = clone; | ||
function getSourceCodeSnippet(fileData, lineNumber, sourceRadius = 2) { | ||
if (!fileData) { | ||
return null; | ||
} | ||
var lines = fileData.split('\n'); | ||
const lines = fileData.split('\n'); | ||
// add one empty line because array index starts from 0, but error line number is counted from 1 | ||
lines.unshift(''); | ||
var start = lineNumber - sourceRadius; | ||
var end = lineNumber + sourceRadius; | ||
var result = {}; | ||
for (var i = start; i <= end; i++) { | ||
var line = lines[i]; | ||
const start = lineNumber - sourceRadius; | ||
const end = lineNumber + sourceRadius; | ||
const result = {}; | ||
for (let i = start; i <= end; i++) { | ||
const line = lines[i]; | ||
if (typeof line === 'string') { | ||
@@ -630,33 +678,37 @@ result[i] = line; | ||
} | ||
util$1.isBrowserConfig = isBrowserConfig; | ||
var GlobalStore = /** @class */ (function () { | ||
function GlobalStore(store) { | ||
var store = {}; | ||
Object.defineProperty(store, "__esModule", { value: true }); | ||
store.GlobalStore = void 0; | ||
class GlobalStore { | ||
constructor(store) { | ||
this.store = store; | ||
} | ||
GlobalStore.prototype.getStore = function () { | ||
getStore() { | ||
return this.store; | ||
}; | ||
GlobalStore.prototype.run = function (store, callback) { | ||
var args = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
} | ||
} | ||
run(store, callback, ...args) { | ||
this.store = store; | ||
return callback.apply(void 0, args); | ||
}; | ||
return GlobalStore; | ||
}()); | ||
return callback(...args); | ||
} | ||
} | ||
store.GlobalStore = GlobalStore; | ||
var notifier = { | ||
Object.defineProperty(client, "__esModule", { value: true }); | ||
client.Client = void 0; | ||
const util_1$4 = util$1; | ||
const store_1 = store; | ||
const notifier = { | ||
name: 'honeybadger-js', | ||
url: 'https://github.com/honeybadger-io/honeybadger-js', | ||
version: '4.0.5' | ||
version: '4.1.0' | ||
}; | ||
// Split at commas and spaces | ||
var TAG_SEPARATOR = /,|\s+/; | ||
const TAG_SEPARATOR = /,|\s+/; | ||
// Checks for non-blank characters | ||
var NOT_BLANK = /\S/; | ||
var Client = /** @class */ (function () { | ||
function Client(opts, transport) { | ||
if (opts === void 0) { opts = {}; } | ||
const NOT_BLANK = /\S/; | ||
class Client { | ||
constructor(opts = {}, transport) { | ||
this.__pluginsExecuted = false; | ||
@@ -666,16 +718,14 @@ this.__store = null; | ||
this.__afterNotifyHandlers = []; | ||
this.config = __assign({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: function () { return true; }, filters: ['creditcard', 'password'], __plugins: [] }, opts); | ||
this.config = Object.assign({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: () => true, filters: ['creditcard', 'password'], __plugins: [] }, opts); | ||
// First, we go with the global (shared) store. | ||
// Webserver middleware can then switch to the AsyncStore for async context tracking. | ||
this.__store = new GlobalStore({ context: {}, breadcrumbs: [] }); | ||
this.__store = new store_1.GlobalStore({ context: {}, breadcrumbs: [] }); | ||
this.__transport = transport; | ||
this.logger = logger(this); | ||
this.logger = (0, util_1$4.logger)(this); | ||
} | ||
Client.prototype.getVersion = function () { | ||
getVersion() { | ||
return notifier.version; | ||
}; | ||
Client.prototype.configure = function (opts) { | ||
var _this = this; | ||
if (opts === void 0) { opts = {}; } | ||
for (var k in opts) { | ||
} | ||
configure(opts = {}) { | ||
for (const k in opts) { | ||
this.config[k] = opts[k]; | ||
@@ -685,28 +735,27 @@ } | ||
this.__pluginsExecuted = true; | ||
this.config.__plugins.forEach(function (plugin) { return plugin.load(_this); }); | ||
this.config.__plugins.forEach((plugin) => plugin.load(this)); | ||
} | ||
return this; | ||
}; | ||
/** @internal */ | ||
Client.prototype.__setStore = function (store) { | ||
} | ||
__setStore(store) { | ||
this.__store = store; | ||
}; | ||
Client.prototype.beforeNotify = function (handler) { | ||
} | ||
beforeNotify(handler) { | ||
this.__beforeNotifyHandlers.push(handler); | ||
return this; | ||
}; | ||
Client.prototype.afterNotify = function (handler) { | ||
} | ||
afterNotify(handler) { | ||
this.__afterNotifyHandlers.push(handler); | ||
return this; | ||
}; | ||
Client.prototype.setContext = function (context) { | ||
} | ||
setContext(context) { | ||
if (typeof context === 'object') { | ||
var store = this.__store.getStore(); | ||
store.context = merge(store.context, context); | ||
const store = this.__store.getStore(); | ||
store.context = (0, util_1$4.merge)(store.context, context); | ||
} | ||
return this; | ||
}; | ||
Client.prototype.resetContext = function (context) { | ||
} | ||
resetContext(context) { | ||
this.logger.warn('Deprecation warning: `Honeybadger.resetContext()` has been deprecated; please use `Honeybadger.clear()` instead.'); | ||
var store = this.__store.getStore(); | ||
const store = this.__store.getStore(); | ||
if (typeof context === 'object' && context !== null) { | ||
@@ -719,15 +768,12 @@ store.context = context; | ||
return this; | ||
}; | ||
Client.prototype.clear = function () { | ||
var store = this.__store.getStore(); | ||
} | ||
clear() { | ||
const store = this.__store.getStore(); | ||
store.context = {}; | ||
store.breadcrumbs = []; | ||
return this; | ||
}; | ||
Client.prototype.notify = function (noticeable, name, extra) { | ||
var _this = this; | ||
if (name === void 0) { name = undefined; } | ||
if (extra === void 0) { extra = undefined; } | ||
var preConditionError = null; | ||
var notice = this.makeNotice(noticeable, name, extra); | ||
} | ||
notify(noticeable, name = undefined, extra = undefined) { | ||
let preConditionError = null; | ||
const notice = this.makeNotice(noticeable, name, extra); | ||
if (!notice) { | ||
@@ -751,4 +797,4 @@ this.logger.debug('failed to build error report'); | ||
// in case they modify them | ||
var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return shallowClone(trace); }) : null; | ||
var beforeNotifyResult = runBeforeNotifyHandlers(notice, this.__beforeNotifyHandlers); | ||
const sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(trace => (0, util_1$4.shallowClone)(trace)) : null; | ||
const beforeNotifyResult = (0, util_1$4.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers); | ||
if (!preConditionError && !beforeNotifyResult) { | ||
@@ -759,3 +805,3 @@ this.logger.debug('skipping error report: beforeNotify handlers returned false', notice); | ||
if (preConditionError) { | ||
runAfterNotifyHandlers(notice, this.__afterNotifyHandlers, preConditionError); | ||
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionError); | ||
return false; | ||
@@ -771,14 +817,14 @@ } | ||
}); | ||
var breadcrumbs = this.__getStoreContentsOrDefault().breadcrumbs; | ||
const breadcrumbs = this.__getStoreContentsOrDefault().breadcrumbs; | ||
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs.slice() : []; | ||
getSourceForBacktrace(sourceCodeData, this.__getSourceFileHandler) | ||
.then(function (sourcePerTrace) { | ||
sourcePerTrace.forEach(function (source, index) { | ||
(0, util_1$4.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler) | ||
.then(sourcePerTrace => { | ||
sourcePerTrace.forEach((source, index) => { | ||
notice.backtrace[index].source = source; | ||
}); | ||
var payload = _this.__buildPayload(notice); | ||
_this.__transport | ||
const payload = this.__buildPayload(notice); | ||
this.__transport | ||
.send({ | ||
headers: { | ||
'X-API-Key': _this.config.apiKey, | ||
'X-API-Key': this.config.apiKey, | ||
'Content-Type': 'application/json', | ||
@@ -788,26 +834,26 @@ 'Accept': 'text/json, application/json' | ||
method: 'POST', | ||
endpoint: endpoint(_this.config.endpoint, '/v1/notices/js'), | ||
maxObjectDepth: _this.config.maxObjectDepth, | ||
logger: _this.logger, | ||
async: isBrowserConfig(_this.config) ? _this.config.async : undefined, | ||
endpoint: (0, util_1$4.endpoint)(this.config.endpoint, '/v1/notices/js'), | ||
maxObjectDepth: this.config.maxObjectDepth, | ||
logger: this.logger, | ||
async: (0, util_1$4.isBrowserConfig)(this.config) ? this.config.async : undefined, | ||
}, payload) | ||
.then(function (res) { | ||
.then(res => { | ||
if (res.statusCode !== 201) { | ||
runAfterNotifyHandlers(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode))); | ||
_this.logger.warn("Error report failed: unknown response from server. code=".concat(res.statusCode)); | ||
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, new Error(`Bad HTTP response: ${res.statusCode}`)); | ||
this.logger.warn(`Error report failed: unknown response from server. code=${res.statusCode}`); | ||
return; | ||
} | ||
var uuid = JSON.parse(res.body).id; | ||
runAfterNotifyHandlers(merge(notice, { | ||
const uuid = JSON.parse(res.body).id; | ||
(0, util_1$4.runAfterNotifyHandlers)((0, util_1$4.merge)(notice, { | ||
id: uuid | ||
}), _this.__afterNotifyHandlers); | ||
_this.logger.info("Error report sent \u26A1 https://app.honeybadger.io/notice/".concat(uuid)); | ||
}), this.__afterNotifyHandlers); | ||
this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${uuid}`); | ||
}) | ||
.catch(function (err) { | ||
_this.logger.error('Error report failed: an unknown error occurred.', "message=".concat(err.message)); | ||
runAfterNotifyHandlers(notice, _this.__afterNotifyHandlers, err); | ||
.catch(err => { | ||
this.logger.error('Error report failed: an unknown error occurred.', `message=${err.message}`); | ||
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, err); | ||
}); | ||
}); | ||
return true; | ||
}; | ||
} | ||
/** | ||
@@ -819,11 +865,8 @@ * An async version of {@link notify} that resolves only after the notice has been reported to Honeybadger. | ||
*/ | ||
Client.prototype.notifyAsync = function (noticeable, name, extra) { | ||
var _this = this; | ||
if (name === void 0) { name = undefined; } | ||
if (extra === void 0) { extra = undefined; } | ||
return new Promise(function (resolve, reject) { | ||
var applyAfterNotify = function (partialNotice) { | ||
var originalAfterNotify = partialNotice.afterNotify; | ||
partialNotice.afterNotify = function (err) { | ||
originalAfterNotify === null || originalAfterNotify === void 0 ? void 0 : originalAfterNotify.call(_this, err); | ||
notifyAsync(noticeable, name = undefined, extra = undefined) { | ||
return new Promise((resolve, reject) => { | ||
const applyAfterNotify = (partialNotice) => { | ||
const originalAfterNotify = partialNotice.afterNotify; | ||
partialNotice.afterNotify = (err) => { | ||
originalAfterNotify === null || originalAfterNotify === void 0 ? void 0 : originalAfterNotify.call(this, err); | ||
if (err) { | ||
@@ -836,3 +879,3 @@ return reject(err); | ||
// We have to respect any afterNotify hooks that come from the arguments | ||
var objectToOverride; | ||
let objectToOverride; | ||
if (noticeable.afterNotify) { | ||
@@ -857,32 +900,30 @@ objectToOverride = noticeable; | ||
applyAfterNotify(objectToOverride); | ||
_this.notify(noticeable, name, extra); | ||
this.notify(noticeable, name, extra); | ||
}); | ||
}; | ||
Client.prototype.makeNotice = function (noticeable, name, extra) { | ||
if (name === void 0) { name = undefined; } | ||
if (extra === void 0) { extra = undefined; } | ||
var notice = makeNotice(noticeable); | ||
} | ||
makeNotice(noticeable, name = undefined, extra = undefined) { | ||
let notice = (0, util_1$4.makeNotice)(noticeable); | ||
if (name && !(typeof name === 'object')) { | ||
var n = String(name); | ||
const n = String(name); | ||
name = { name: n }; | ||
} | ||
if (name) { | ||
notice = mergeNotice(notice, name); | ||
notice = (0, util_1$4.mergeNotice)(notice, name); | ||
} | ||
if (typeof extra === 'object' && extra !== null) { | ||
notice = mergeNotice(notice, extra); | ||
notice = (0, util_1$4.mergeNotice)(notice, extra); | ||
} | ||
if (objectIsEmpty(notice)) { | ||
if ((0, util_1$4.objectIsEmpty)(notice)) { | ||
return null; | ||
} | ||
var context = this.__getStoreContentsOrDefault().context; | ||
var noticeTags = this.__constructTags(notice.tags); | ||
var contextTags = this.__constructTags(context['tags']); | ||
var configTags = this.__constructTags(this.config.tags); | ||
const context = this.__getStoreContentsOrDefault().context; | ||
const noticeTags = this.__constructTags(notice.tags); | ||
const contextTags = this.__constructTags(context['tags']); | ||
const configTags = this.__constructTags(this.config.tags); | ||
// Turning into a Set will remove duplicates | ||
var tags = noticeTags.concat(contextTags).concat(configTags); | ||
var uniqueTags = tags.filter(function (item, index) { return tags.indexOf(item) === index; }); | ||
notice = merge(notice, { | ||
const tags = noticeTags.concat(contextTags).concat(configTags); | ||
const uniqueTags = tags.filter((item, index) => tags.indexOf(item) === index); | ||
notice = (0, util_1$4.merge)(notice, { | ||
name: notice.name || 'Error', | ||
context: merge(context, notice.context), | ||
context: (0, util_1$4.merge)(context, notice.context), | ||
projectRoot: notice.projectRoot || this.config.projectRoot, | ||
@@ -893,13 +934,13 @@ environment: notice.environment || this.config.environment, | ||
revision: notice.revision || this.config.revision, | ||
tags: uniqueTags | ||
tags: uniqueTags, | ||
}); | ||
var backtraceShift = 0; | ||
let backtraceShift = 0; | ||
if (typeof notice.stack !== 'string' || !notice.stack.trim()) { | ||
notice.stack = generateStackTrace(); | ||
notice.stack = (0, util_1$4.generateStackTrace)(); | ||
backtraceShift = 2; | ||
} | ||
notice.backtrace = makeBacktrace(notice.stack, backtraceShift); | ||
notice.backtrace = (0, util_1$4.makeBacktrace)(notice.stack, backtraceShift); | ||
return notice; | ||
}; | ||
Client.prototype.addBreadcrumb = function (message, opts) { | ||
} | ||
addBreadcrumb(message, opts) { | ||
if (!this.config.breadcrumbsEnabled) { | ||
@@ -909,7 +950,7 @@ return; | ||
opts = opts || {}; | ||
var metadata = shallowClone(opts.metadata); | ||
var category = opts.category || 'custom'; | ||
var timestamp = new Date().toISOString(); | ||
var store = this.__store.getStore(); | ||
var breadcrumbs = store.breadcrumbs; | ||
const metadata = (0, util_1$4.shallowClone)(opts.metadata); | ||
const category = opts.category || 'custom'; | ||
const timestamp = new Date().toISOString(); | ||
const store = this.__store.getStore(); | ||
let breadcrumbs = store.breadcrumbs; | ||
breadcrumbs.push({ | ||
@@ -921,3 +962,3 @@ category: category, | ||
}); | ||
var limit = this.config.maxBreadcrumbs; | ||
const limit = this.config.maxBreadcrumbs; | ||
if (breadcrumbs.length > limit) { | ||
@@ -928,4 +969,4 @@ breadcrumbs = breadcrumbs.slice(breadcrumbs.length - limit); | ||
return this; | ||
}; | ||
Client.prototype.__developmentMode = function () { | ||
} | ||
__developmentMode() { | ||
if (this.config.reportData === true) { | ||
@@ -935,6 +976,6 @@ return false; | ||
return (this.config.environment && this.config.developmentEnvironments.includes(this.config.environment)); | ||
}; | ||
Client.prototype.__buildPayload = function (notice) { | ||
var headers = filter(notice.headers, this.config.filters) || {}; | ||
var cgiData = filter(__assign(__assign({}, notice.cgiData), formatCGIData(headers, 'HTTP_')), this.config.filters); | ||
} | ||
__buildPayload(notice) { | ||
const headers = (0, util_1$4.filter)(notice.headers, this.config.filters) || {}; | ||
const cgiData = (0, util_1$4.filter)(Object.assign(Object.assign({}, notice.cgiData), (0, util_1$4.formatCGIData)(headers, 'HTTP_')), this.config.filters); | ||
return { | ||
@@ -951,6 +992,7 @@ notifier: notifier, | ||
fingerprint: notice.fingerprint, | ||
tags: notice.tags | ||
tags: notice.tags, | ||
causes: (0, util_1$4.getCauses)(notice), | ||
}, | ||
request: { | ||
url: filterUrl(notice.url, this.config.filters), | ||
url: (0, util_1$4.filterUrl)(notice.url, this.config.filters), | ||
component: notice.component, | ||
@@ -960,4 +1002,4 @@ action: notice.action, | ||
cgi_data: cgiData, | ||
params: filter(notice.params, this.config.filters) || {}, | ||
session: filter(notice.session, this.config.filters) || {} | ||
params: (0, util_1$4.filter)(notice.params, this.config.filters) || {}, | ||
session: (0, util_1$4.filter)(notice.session, this.config.filters) || {} | ||
}, | ||
@@ -973,24 +1015,79 @@ server: { | ||
}; | ||
}; | ||
Client.prototype.__constructTags = function (tags) { | ||
} | ||
__constructTags(tags) { | ||
if (!tags) { | ||
return []; | ||
} | ||
return tags.toString().split(TAG_SEPARATOR).filter(function (tag) { return NOT_BLANK.test(tag); }); | ||
}; | ||
return tags.toString().split(TAG_SEPARATOR).filter((tag) => NOT_BLANK.test(tag)); | ||
} | ||
/** | ||
* For ALS, the store may be uninitialized (if .run()` has not been called). | ||
* This provides an easy way to read the existing store object or fall back to a default. | ||
* Returns *a copy* of the store contents. | ||
* @internal | ||
* Returns *a copy* of the s tore contents. | ||
*/ | ||
Client.prototype.__getStoreContentsOrDefault = function () { | ||
var existingStoreContents = this.__store.getStore(); | ||
var storeContents = existingStoreContents || {}; | ||
return __assign({ context: {}, breadcrumbs: [] }, storeContents); | ||
}; | ||
return Client; | ||
}()); | ||
__getStoreContentsOrDefault() { | ||
const existingStoreContents = this.__store.getStore(); | ||
const storeContents = existingStoreContents || {}; | ||
return Object.assign({ context: {}, breadcrumbs: [] }, storeContents); | ||
} | ||
} | ||
client.Client = Client; | ||
var readFile = util.promisify(fs__default["default"].readFile); | ||
var types = {}; | ||
Object.defineProperty(types, "__esModule", { value: true }); | ||
(function (exports) { | ||
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Util = exports.Types = exports.Store = exports.Client = void 0; | ||
var client_1 = client; | ||
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } }); | ||
exports.Store = __importStar(store); | ||
exports.Types = __importStar(types); | ||
exports.Util = __importStar(util$1); | ||
} (src)); | ||
var util = {}; | ||
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(util, "__esModule", { value: true }); | ||
util.getSourceFile = util.getStats = util.fatallyLogAndExit = void 0; | ||
const os_1$1 = __importDefault$3(require$$0__default["default"]); | ||
const fs_1 = __importDefault$3(require$$1__default["default"]); | ||
const util_1$3 = require$$2__default["default"]; | ||
const readFile = (0, util_1$3.promisify)(fs_1.default.readFile); | ||
function fatallyLogAndExit(err) { | ||
@@ -1001,57 +1098,47 @@ console.error('[Honeybadger] Exiting process due to uncaught exception'); | ||
} | ||
util.fatallyLogAndExit = fatallyLogAndExit; | ||
function getStats() { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var load, stats, fallback, memData, data, results; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
load = os__default["default"].loadavg(); | ||
stats = { | ||
load: { | ||
one: load[0], | ||
five: load[1], | ||
fifteen: load[2] | ||
}, | ||
mem: {} | ||
}; | ||
fallback = function () { | ||
stats.mem = { | ||
free: os__default["default"].freemem(), | ||
total: os__default["default"].totalmem() | ||
}; | ||
}; | ||
if (!fs__default["default"].existsSync('/proc/meminfo')) { | ||
fallback(); | ||
return [2 /*return*/, stats]; | ||
} | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, readFile('/proc/meminfo', 'utf8') | ||
// The first four lines, in order, are Total, Free, Buffers, Cached. | ||
// @TODO: Figure out if there's a way to only read these lines | ||
]; | ||
case 2: | ||
memData = _a.sent(); | ||
data = memData.split('\n').slice(0, 4); | ||
results = data.map(function (i) { | ||
return parseInt(/\s+(\d+)\skB/i.exec(i)[1], 10) / 1024.0; | ||
}); | ||
stats.mem = { | ||
total: results[0], | ||
free: results[1], | ||
buffers: results[2], | ||
cached: results[3], | ||
free_total: results[1] + results[2] + results[3] | ||
}; | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_a.sent(); | ||
fallback(); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/, stats]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const load = os_1$1.default.loadavg(); | ||
const stats = { | ||
load: { | ||
one: load[0], | ||
five: load[1], | ||
fifteen: load[2] | ||
}, | ||
mem: {} | ||
}; | ||
const fallback = () => { | ||
stats.mem = { | ||
free: os_1$1.default.freemem(), | ||
total: os_1$1.default.totalmem() | ||
}; | ||
}; | ||
if (!fs_1.default.existsSync('/proc/meminfo')) { | ||
fallback(); | ||
return stats; | ||
} | ||
try { | ||
const memData = yield readFile('/proc/meminfo', 'utf8'); | ||
// The first four lines, in order, are Total, Free, Buffers, Cached. | ||
// @TODO: Figure out if there's a way to only read these lines | ||
const data = memData.split('\n').slice(0, 4); | ||
const results = data.map(function (i) { | ||
return parseInt(/\s+(\d+)\skB/i.exec(i)[1], 10) / 1024.0; | ||
}); | ||
stats.mem = { | ||
total: results[0], | ||
free: results[1], | ||
buffers: results[2], | ||
cached: results[3], | ||
free_total: results[1] + results[2] + results[3] | ||
}; | ||
} | ||
catch (error) { | ||
fallback(); | ||
} | ||
return stats; | ||
}); | ||
} | ||
util.getStats = getStats; | ||
/** | ||
@@ -1063,29 +1150,36 @@ * Get source file if possible, used to build `notice.backtrace.source` | ||
function getSourceFile(path) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, readFile(path, 'utf-8')]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, null]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
return yield readFile(path, 'utf-8'); | ||
} | ||
catch (_e) { | ||
return null; | ||
} | ||
}); | ||
} | ||
util.getSourceFile = getSourceFile; | ||
var Store; | ||
var uncaught_exception = {}; | ||
var aws_lambda = {}; | ||
var async_store = {}; | ||
Object.defineProperty(async_store, "__esModule", { value: true }); | ||
async_store.AsyncStore = void 0; | ||
const core_1$2 = src; | ||
let Store; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage; | ||
const { AsyncLocalStorage } = require('async_hooks'); | ||
Store = new AsyncLocalStorage(); | ||
} | ||
catch (e) { | ||
Store = new GlobalStore({ context: {}, breadcrumbs: [] }); | ||
Store = new core_1$2.Store.GlobalStore({ context: {}, breadcrumbs: [] }); | ||
} | ||
var AsyncStore = Store; | ||
async_store.AsyncStore = Store; | ||
Object.defineProperty(aws_lambda, "__esModule", { value: true }); | ||
aws_lambda.removeAwsDefaultUncaughtExceptionListener = aws_lambda.lambdaHandler = void 0; | ||
const async_store_1$1 = async_store; | ||
function isHandlerSync(handler) { | ||
@@ -1104,11 +1198,11 @@ return handler.length > 2; | ||
return function wrappedLambdaHandler(event, context) { | ||
hb.__setStore(AsyncStore); | ||
return new Promise(function (resolve, reject) { | ||
AsyncStore.run({ context: {}, breadcrumbs: [] }, function () { | ||
var timeoutHandler = setupTimeoutWarning(hb, context); | ||
hb.__setStore(async_store_1$1.AsyncStore); | ||
return new Promise((resolve, reject) => { | ||
async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, () => { | ||
const timeoutHandler = setupTimeoutWarning(hb, context); | ||
try { | ||
handler(event, context) | ||
.then(resolve) | ||
.catch(function (err) { return reportToHoneybadger(hb, err, reject); }) | ||
.finally(function () { return clearTimeout(timeoutHandler); }); | ||
.catch(err => reportToHoneybadger(hb, err, reject)) | ||
.finally(() => clearTimeout(timeoutHandler)); | ||
} | ||
@@ -1125,7 +1219,7 @@ catch (err) { | ||
return function wrappedLambdaHandler(event, context, cb) { | ||
hb.__setStore(AsyncStore); | ||
AsyncStore.run({ context: {}, breadcrumbs: [] }, function () { | ||
var timeoutHandler = setupTimeoutWarning(hb, context); | ||
hb.__setStore(async_store_1$1.AsyncStore); | ||
async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, () => { | ||
const timeoutHandler = setupTimeoutWarning(hb, context); | ||
try { | ||
handler(event, context, function (error, result) { | ||
handler(event, context, (error, result) => { | ||
clearTimeout(timeoutHandler); | ||
@@ -1152,5 +1246,5 @@ if (error) { | ||
} | ||
var delay = context.getRemainingTimeInMillis() - (hb.config.timeoutWarningThresholdMs); | ||
return setTimeout(function () { | ||
hb.notify("".concat(context.functionName, "[").concat(context.functionVersion, "] may have timed out")); | ||
const delay = context.getRemainingTimeInMillis() - (hb.config.timeoutWarningThresholdMs); | ||
return setTimeout(() => { | ||
hb.notify(`${context.functionName}[${context.functionVersion}] may have timed out`); | ||
}, delay > 0 ? delay : 0); | ||
@@ -1160,3 +1254,3 @@ } | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
var hb = this; | ||
const hb = this; | ||
if (isHandlerSync(handler)) { | ||
@@ -1167,3 +1261,4 @@ return syncHandler(handler, hb); | ||
} | ||
var listenerRemoved = false; | ||
aws_lambda.lambdaHandler = lambdaHandler; | ||
let listenerRemoved = false; | ||
/** | ||
@@ -1178,3 +1273,3 @@ * Removes AWS Lambda default listener that | ||
listenerRemoved = true; | ||
var listeners = process.listeners('uncaughtException'); | ||
const listeners = process.listeners('uncaughtException'); | ||
if (listeners.length === 0) { | ||
@@ -1186,14 +1281,18 @@ return; | ||
} | ||
aws_lambda.removeAwsDefaultUncaughtExceptionListener = removeAwsDefaultUncaughtExceptionListener; | ||
var count = 0; | ||
Object.defineProperty(uncaught_exception, "__esModule", { value: true }); | ||
const util_1$2 = util; | ||
const aws_lambda_1$1 = aws_lambda; | ||
let count = 0; | ||
function removeAwsLambdaListener() { | ||
var isLambda = !!process.env.LAMBDA_TASK_ROOT; | ||
const isLambda = !!process.env.LAMBDA_TASK_ROOT; | ||
if (!isLambda) { | ||
return; | ||
} | ||
removeAwsDefaultUncaughtExceptionListener(); | ||
(0, aws_lambda_1$1.removeAwsDefaultUncaughtExceptionListener)(); | ||
} | ||
function uncaughtException () { | ||
function default_1$1() { | ||
return { | ||
load: function (client) { | ||
load: (client) => { | ||
if (!client.config.enableUncaught) { | ||
@@ -1206,7 +1305,7 @@ return; | ||
if (count > 1) { | ||
fatallyLogAndExit(uncaughtError); | ||
(0, util_1$2.fatallyLogAndExit)(uncaughtError); | ||
} | ||
if (client.config.enableUncaught) { | ||
client.notify(uncaughtError, { | ||
afterNotify: function (_err, _notice) { | ||
afterNotify: (_err, _notice) => { | ||
count += 1; | ||
@@ -1225,6 +1324,10 @@ client.config.afterUncaught(uncaughtError); | ||
} | ||
uncaught_exception.default = default_1$1; | ||
function unhandledRejection () { | ||
var unhandled_rejection = {}; | ||
Object.defineProperty(unhandled_rejection, "__esModule", { value: true }); | ||
function default_1() { | ||
return { | ||
load: function (client) { | ||
load: (client) => { | ||
if (!client.config.enableUnhandledRejection) { | ||
@@ -1242,10 +1345,19 @@ return; | ||
} | ||
unhandled_rejection.default = default_1; | ||
var middleware = {}; | ||
var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(middleware, "__esModule", { value: true }); | ||
middleware.errorHandler = middleware.requestHandler = void 0; | ||
const url_1$1 = __importDefault$2(require$$0__default$1["default"]); | ||
function fullUrl(req) { | ||
var connection = req.connection; | ||
var address = connection && connection.address(); | ||
const connection = req.connection; | ||
const address = connection && connection.address(); | ||
// @ts-ignore The old @types/node incorrectly defines `address` as string|Address | ||
var port = address ? address.port : undefined; | ||
const port = address ? address.port : undefined; | ||
// @ts-ignore | ||
return url__default["default"].format({ | ||
return url_1$1.default.format({ | ||
protocol: req.protocol, | ||
@@ -1261,2 +1373,3 @@ hostname: req.hostname, | ||
} | ||
middleware.requestHandler = requestHandler; | ||
function errorHandler(err, req, _res, next) { | ||
@@ -1277,16 +1390,27 @@ this.notify(err, { | ||
} | ||
middleware.errorHandler = errorHandler; | ||
var ServerTransport = /** @class */ (function () { | ||
function ServerTransport() { | ||
} | ||
ServerTransport.prototype.send = function (options, payload) { | ||
var _this = this; | ||
var _a = new url.URL(options.endpoint), protocol = _a.protocol, hostname = _a.hostname, pathname = _a.pathname; | ||
var transport = (protocol === 'http:' ? http__default["default"] : https__default["default"]); | ||
return new Promise(function (resolve, reject) { | ||
var promise; | ||
var transport = {}; | ||
var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(transport, "__esModule", { value: true }); | ||
transport.ServerTransport = void 0; | ||
const core_1$1 = src; | ||
const url_1 = require$$0__default$1["default"]; | ||
const http_1 = __importDefault$1(require$$2__default$1["default"]); | ||
const https_1 = __importDefault$1(require$$3__default["default"]); | ||
const util_1$1 = util; | ||
const { sanitize } = core_1$1.Util; | ||
class ServerTransport { | ||
send(options, payload) { | ||
const { protocol, hostname, pathname } = new url_1.URL(options.endpoint); | ||
const transport = (protocol === 'http:' ? http_1.default : https_1.default); | ||
return new Promise((resolve, reject) => { | ||
let promise; | ||
// this should not be here. it should be done before reaching the transport layer | ||
// it could be inside a beforeNotifyHandler, but is not possible at the moment because those handlers are synchronous | ||
if (_this.isNoticePayload(payload)) { | ||
promise = _this.appendMetadata(payload); | ||
if (this.isNoticePayload(payload)) { | ||
promise = this.appendMetadata(payload); | ||
} | ||
@@ -1296,14 +1420,14 @@ else { | ||
} | ||
promise.then(function () { | ||
promise.then(() => { | ||
// | ||
// We use a httpOptions object to limit issues with libraries that may patch Node.js | ||
// See https://github.com/honeybadger-io/honeybadger-js/issues/825#issuecomment-1193113433 | ||
var httpOptions = { | ||
const httpOptions = { | ||
method: options.method, | ||
headers: options.headers, | ||
path: pathname, | ||
protocol: protocol, | ||
hostname: hostname, | ||
protocol, | ||
hostname, | ||
}; | ||
var data = undefined; | ||
let data = undefined; | ||
if (payload) { | ||
@@ -1313,11 +1437,11 @@ data = Buffer.from(JSON.stringify(sanitize(payload, options.maxObjectDepth)), 'utf8'); | ||
} | ||
var req = transport.request(httpOptions, function (res) { | ||
options.logger.debug("statusCode: ".concat(res.statusCode)); | ||
var body = ''; | ||
res.on('data', function (chunk) { | ||
const req = transport.request(httpOptions, (res) => { | ||
options.logger.debug(`statusCode: ${res.statusCode}`); | ||
let body = ''; | ||
res.on('data', (chunk) => { | ||
body += chunk; | ||
}); | ||
res.on('end', function () { return resolve({ statusCode: res.statusCode, body: body }); }); | ||
res.on('end', () => resolve({ statusCode: res.statusCode, body })); | ||
}); | ||
req.on('error', function (err) { return reject(err); }); | ||
req.on('error', (err) => reject(err)); | ||
if (data) { | ||
@@ -1329,29 +1453,41 @@ req.write(data); | ||
}); | ||
}; | ||
ServerTransport.prototype.isNoticePayload = function (payload) { | ||
} | ||
isNoticePayload(payload) { | ||
return payload && payload.error !== undefined; | ||
}; | ||
ServerTransport.prototype.appendMetadata = function (payload) { | ||
} | ||
appendMetadata(payload) { | ||
payload.server.pid = process.pid; | ||
return getStats() | ||
.then(function (stats) { | ||
return (0, util_1$1.getStats)() | ||
.then(stats => { | ||
payload.server.stats = stats; | ||
}); | ||
}; | ||
return ServerTransport; | ||
}()); | ||
} | ||
} | ||
transport.ServerTransport = ServerTransport; | ||
var kHoneybadgerStore = Symbol.for('kHoneybadgerStore'); | ||
var Honeybadger = /** @class */ (function (_super) { | ||
__extends(Honeybadger, _super); | ||
function Honeybadger(opts) { | ||
if (opts === void 0) { opts = {}; } | ||
var _this = this; | ||
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(server, "__esModule", { value: true }); | ||
const os_1 = __importDefault(require$$0__default["default"]); | ||
const domain_1 = __importDefault(require$$1__default$1["default"]); | ||
const core_1 = src; | ||
const util_1 = util; | ||
const uncaught_exception_1 = __importDefault(uncaught_exception); | ||
const unhandled_rejection_1 = __importDefault(unhandled_rejection); | ||
const middleware_1 = middleware; | ||
const aws_lambda_1 = aws_lambda; | ||
const async_store_1 = async_store; | ||
const transport_1 = transport; | ||
const { endpoint } = core_1.Util; | ||
const kHoneybadgerStore = Symbol.for('kHoneybadgerStore'); | ||
class Honeybadger extends core_1.Client { | ||
constructor(opts = {}) { | ||
var _a; | ||
_this = _super.call(this, __assign({ afterUncaught: fatallyLogAndExit, projectRoot: process.cwd(), hostname: os__default["default"].hostname() }, opts), new ServerTransport()) || this; | ||
super(Object.assign({ afterUncaught: util_1.fatallyLogAndExit, projectRoot: process.cwd(), hostname: os_1.default.hostname() }, opts), new transport_1.ServerTransport()); | ||
/** @internal */ | ||
_this.__beforeNotifyHandlers = [ | ||
function (notice) { | ||
this.__beforeNotifyHandlers = [ | ||
(notice) => { | ||
if (notice && notice.backtrace) { | ||
notice.backtrace.forEach(function (line) { | ||
notice.backtrace.forEach((line) => { | ||
if (line.file) { | ||
@@ -1367,35 +1503,32 @@ line.file = line.file.replace(/.*\/node_modules\/(.+)/, '[NODE_MODULES]/$1'); | ||
// serverless defaults | ||
var config = _this.config; | ||
const config = this.config; | ||
config.reportTimeoutWarning = (_a = config.reportTimeoutWarning) !== null && _a !== void 0 ? _a : true; | ||
config.timeoutWarningThresholdMs = config.timeoutWarningThresholdMs || 50; | ||
_this.__getSourceFileHandler = getSourceFile.bind(_this); | ||
_this.errorHandler = errorHandler.bind(_this); | ||
_this.requestHandler = requestHandler.bind(_this); | ||
_this.lambdaHandler = lambdaHandler.bind(_this); | ||
return _this; | ||
this.__getSourceFileHandler = util_1.getSourceFile.bind(this); | ||
this.errorHandler = middleware_1.errorHandler.bind(this); | ||
this.requestHandler = middleware_1.requestHandler.bind(this); | ||
this.lambdaHandler = aws_lambda_1.lambdaHandler.bind(this); | ||
} | ||
Honeybadger.prototype.factory = function (opts) { | ||
factory(opts) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return new Honeybadger(opts); | ||
}; | ||
Honeybadger.prototype.configure = function (opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return _super.prototype.configure.call(this, opts); | ||
}; | ||
Honeybadger.prototype.checkIn = function (id) { | ||
var _this = this; | ||
} | ||
configure(opts = {}) { | ||
return super.configure(opts); | ||
} | ||
checkIn(id) { | ||
return this.__transport | ||
.send({ | ||
method: 'GET', | ||
endpoint: endpoint(this.config.endpoint, "v1/check_in/".concat(id)), | ||
endpoint: endpoint(this.config.endpoint, `v1/check_in/${id}`), | ||
logger: this.logger, | ||
}) | ||
.then(function () { | ||
_this.logger.info('CheckIn sent'); | ||
.then(() => { | ||
this.logger.info('CheckIn sent'); | ||
return Promise.resolve(); | ||
}) | ||
.catch(function (err) { | ||
_this.logger.error('CheckIn failed: an unknown error occurred.', "message=".concat(err.message)); | ||
.catch(err => { | ||
this.logger.error('CheckIn failed: an unknown error occurred.', `message=${err.message}`); | ||
}); | ||
}; | ||
} | ||
// This method is intended for web frameworks. | ||
@@ -1408,6 +1541,5 @@ // It allows us to track context for individual requests without leaking to other requests | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Honeybadger.prototype.withRequest = function (request, handler, onError) { | ||
var _this = this; | ||
var storeObject = (request[kHoneybadgerStore] || this.__getStoreContentsOrDefault()); | ||
this.__setStore(AsyncStore); | ||
withRequest(request, handler, onError) { | ||
const storeObject = (request[kHoneybadgerStore] || this.__getStoreContentsOrDefault()); | ||
this.__setStore(async_store_1.AsyncStore); | ||
if (!request[kHoneybadgerStore]) { | ||
@@ -1423,4 +1555,4 @@ request[kHoneybadgerStore] = storeObject; | ||
// See https://github.com/honeybadger-io/honeybadger-js/pull/711 | ||
var dom = domain__default["default"].create(); | ||
var onErrorWithContext = function (err) { return _this.__store.run(storeObject, function () { return onError(err); }); }; | ||
const dom = domain_1.default.create(); | ||
const onErrorWithContext = (err) => this.__store.run(storeObject, () => onError(err)); | ||
dom.on('error', onErrorWithContext); | ||
@@ -1430,12 +1562,11 @@ handler = dom.bind(handler); | ||
return this.__store.run(storeObject, handler); | ||
}; | ||
return Honeybadger; | ||
}(Client)); | ||
var server = new Honeybadger({ | ||
} | ||
} | ||
var _default = server.default = new Honeybadger({ | ||
__plugins: [ | ||
uncaughtException(), | ||
unhandledRejection() | ||
(0, uncaught_exception_1.default)(), | ||
(0, unhandled_rejection_1.default)() | ||
], | ||
}); | ||
module.exports = server; | ||
module.exports = _default; |
/* eslint-disable import/no-unresolved */ | ||
// Type definitions for honeybadger.js | ||
// Project: https://github.com/honeybadger-io/honeybadger-js | ||
import Server from './dist/server/types/server' | ||
import Browser from './dist/browser/types/browser' | ||
import Server from './dist/server/honeybadger' | ||
import Browser from './dist/browser/honeybadger' | ||
@@ -7,0 +7,0 @@ type Honeybadger = typeof Server & typeof Browser; |
{ | ||
"name": "@honeybadger-io/js", | ||
"version": "4.0.5", | ||
"version": "4.1.0", | ||
"license": "MIT", | ||
@@ -22,4 +22,4 @@ "homepage": "https://github.com/honeybadger-io/honeybadger-js", | ||
], | ||
"main": "dist/server/honeybadger.js", | ||
"browser": "dist/browser/honeybadger.js", | ||
"main": "./dist/server/honeybadger.js", | ||
"browser": "./dist/browser/honeybadger.js", | ||
"repository": { | ||
@@ -32,24 +32,30 @@ "type": "git", | ||
}, | ||
"types": "./honeybadger.d.ts", | ||
"files": [ | ||
"./dist", | ||
"./honeybadger.d.ts" | ||
], | ||
"tsd": { | ||
"compilerOptions": { | ||
"strict": false | ||
} | ||
}, | ||
"scripts": { | ||
"prepare": "npm run build && husky install", | ||
"test": "concurrently \"npm:test:browser\" \"npm:test:server\"", | ||
"build": "tsc --build tsconfig.json && rollup -c && node ./scripts/copy-typedefs.js", | ||
"test": "npm run test:browser && npm run test:server && npm run tsd", | ||
"test:browser": "jest --env=jsdom --testPathPattern=\"test/unit/.*(?<![\\./]server)\\.test\\.(js|ts)\"", | ||
"test:server": "jest --env=node --testPathPattern=\"test/unit/.*(?<![\\./]browser)\\.test\\.(js|ts)\"", | ||
"test:integration": "npm run build && test/integration/node_modules/karma/bin/karma start test/integration/karma.conf.js", | ||
"test:integration": "test/integration/node_modules/karma/bin/karma start test/integration/karma.conf.js", | ||
"test:integration:browserstack": "npm run test:integration", | ||
"test:integration:headless": "HEADLESS=1 npm run test:integration", | ||
"tsd": "npm run build && tsd", | ||
"lint": "npx eslint .", | ||
"build": "rollup -c && node ./scripts/copy-typedefs.js", | ||
"release": "shipjs prepare" | ||
"tsd": "tsd", | ||
"postpublish": "./scripts/release-cdn.sh" | ||
}, | ||
"dependencies": { | ||
"stacktrace-parser": "^0.1.10" | ||
"@honeybadger-io/core": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^17.0.0", | ||
"@commitlint/config-conventional": "^17.0.0", | ||
"@rollup/plugin-commonjs": "^22.0.1", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"@rollup/plugin-replace": "^4.0.0", | ||
"@rollup/plugin-typescript": "^8.3.3", | ||
"@types/aws-lambda": "^8.10.89", | ||
@@ -59,35 +65,17 @@ "@types/express": "^4.17.13", | ||
"@types/node": "^12.20.46", | ||
"@typescript-eslint/eslint-plugin": "^5.6.0", | ||
"@typescript-eslint/parser": "^5.6.0", | ||
"axios": ">=0.24.0", | ||
"concurrently": "^7.0.0", | ||
"eslint": "^8.4.1", | ||
"eslint-plugin-import": "^2.25.3", | ||
"eslint-plugin-jest": "^26.0.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"express": "^4.17.1", | ||
"husky": "^8.0.1", | ||
"jest": "^27.4.4", | ||
"nock": "^13.2.1", | ||
"rollup": "^2.75.6", | ||
"rollup": "^2.77.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"shipjs": "0.24.4", | ||
"sinon": "^14.0.0", | ||
"supertest": "^6.1.6", | ||
"ts-jest": "^27.1.5", | ||
"tsd": "^0.21.0", | ||
"tslib": "^2.3.1", | ||
"tsd": "^0.22.0", | ||
"typescript": "^4.5.3" | ||
}, | ||
"readmeFilename": "README.md", | ||
"files": [ | ||
"dist", | ||
"honeybadger.d.ts" | ||
], | ||
"tsd": { | ||
"compilerOptions": { | ||
"strict": false | ||
} | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"types": "./honeybadger.d.ts" | ||
"gitHead": "84edbaf12e205a95e0e6c7c208f501a3eb23da50" | ||
} |
@@ -5,8 +5,7 @@ # Honeybadger for JavaScript | ||
[![npm version](https://badge.fury.io/js/%40honeybadger-io%2Fjs.svg)](https://badge.fury.io/js/%40honeybadger-io%2Fjs) | ||
[![deploy](https://img.shields.io/badge/deploy-🛳%20Ship.js-blue?style=flat)](https://github.com/algolia/shipjs) | ||
[![npm dm](https://img.shields.io/npm/dm/@honeybadger-io/js)](https://www.npmjs.com/package/@honeybadger-io/js) | ||
[![npm dt](https://img.shields.io/npm/dt/@honeybadger-io/js)](https://www.npmjs.com/package/@honeybadger-io/js) | ||
Universal JavaScript library for integrating apps with the :zap: [Honeybadger Error Notifier](http://honeybadger.io). | ||
❗*Note: The NPM package has been moved to [**@honeybadger-io/js**](https://www.npmjs.com/package/@honeybadger-io/js) starting with v3.0.0. See the [v2-stable](https://github.com/honeybadger-io/honeybadger-js/tree/v2-stable) branch for the [**honeybadger-js**](https://www.npmjs.com/package/honeybadger-js) 2.x package. [Upgrade instructions](https://docs.honeybadger.io/lib/javascript/support/upgrading-to-v3.html)* | ||
## Documentation and Support | ||
@@ -16,23 +15,4 @@ | ||
## Changelog | ||
[Conventional Commits](https://www.conventionalcommits.org/) are enforced with a git hook ([husky](https://typicode.github.io/husky) + [commitlint](https://commitlint.js.org/)) in order to automate changelog generation. | ||
[CHANGELOG.md](CHANGELOG.md) is updated when a new version is released (npm run release) with [shipjs](https://community.algolia.com/shipjs/reference/all-config.html#updatechangelog). | ||
## Contributing | ||
1. Fork it. | ||
2. Create a topic branch `git checkout -b my_branch` | ||
3. Commit your changes `git commit -am "Boom"` | ||
4. Push to your branch `git push origin my_branch` | ||
5. Send a [pull request](https://github.com/honeybadger-io/honeybadger-js/pulls) | ||
## Development | ||
1. Run `npm install`. | ||
2. To run unit tests for both browser and server builds: `npm test`. Or separately: `npm run test:browser`, `npm run test:server`. | ||
3. To run integration tests across all supported platforms, set up a [BrowserStack](https://www.browserstack.com/) | ||
account and use `BROWSERSTACK_USERNAME=your_username BROWSERSTACK_ACCESS_KEY=your-access-key npm run test:integration`. | ||
4. To test the TypeScript type definitions: `npm run tsd`. | ||
### Bundling and types | ||
@@ -48,7 +28,13 @@ This project is _isomorphic_, meaning it's a single library which contains both browser and server builds. It's written in TypeScript, and transpiled and bundled with Rollup. Our Rollup config generates three main files: | ||
### Tests | ||
1. To run unit tests for both browser and server builds: `npm test`. Or separately: `npm run test:browser`, `npm run test:server`. | ||
2. To run integration tests across all supported platforms, set up a [BrowserStack](https://www.browserstack.com/) | ||
account and use `BROWSERSTACK_USERNAME=your_username BROWSERSTACK_ACCESS_KEY=your-access-key npm run test:integration`. | ||
3. To test the TypeScript type definitions: `npm run tsd`. | ||
## Releasing | ||
Releasing is done with two commands: `npm version` and `npm publish`. **Both | ||
commands should be used with care.** The `npm publish` command publishes to NPM | ||
**and** to our *js.honeybadger.io* CDN (hosted on AWS via S3/CloudFront). | ||
This package comes with a `postpublish` script (`scripts/release-cdn.sh`) | ||
which is executed every time a new version is released to NPM. | ||
The script publishes to our *js.honeybadger.io* CDN (hosted on AWS via S3/CloudFront). | ||
@@ -65,45 +51,8 @@ For the CDN release, make sure you have the following environment variable | ||
To perform a full release: | ||
1. With a clean working tree, use `npm version [new version]` to bump the version, commit the | ||
changes, tag the release, and push to GitHub. See `npm help version` for | ||
documentation. | ||
2. To publish the release, use `npm publish`. See `npm help publish` for | ||
documentation. | ||
If the CDN release fails for some reason (bad AWS credentials, for instance), | ||
re-run the release manually with `npm run release-cdn`. | ||
re-run the release manually with by executing the script `npm run postpublish`. | ||
### Release Automation | ||
We use [Ship.js](https://github.com/algolia/shipjs) to automate releasing. Our [custom Ship.js config](https://github.com/honeybadger-io/honeybadger-js/blob/master/ship.config.js) determines the next release version based on the unreleased section of our [changelog](https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md) ([Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format). | ||
Ship.js creates a PR once per week when unreleased changes are present. You can also trigger a release PR by saying "@shipjs prepare" in any issue or pull request comment on GitHub. | ||
#### Available Commands | ||
- `npm run release` - Calculates the next version and creates a PR via `shipjs prepare`. This can run locally or in CI | ||
- `npx shipjs trigger` - Publish to NPM (usually happens in CI, but can also run locally) | ||
#### GitHub Workflows | ||
- [shipjs-manual-prepare](https://github.com/honeybadger-io/honeybadger-js/blob/master/.github/workflows/shipjs-manual-prepare.yml) | ||
- [shipjs-schedule-prepare](https://github.com/honeybadger-io/honeybadger-js/blob/master/.github/workflows/shipjs-schedule-prepare.yml) | ||
- [shipjs-trigger](https://github.com/honeybadger-io/honeybadger-js/blob/master/.github/workflows/shipjs-trigger.yml) | ||
#### Related Links | ||
- [Our Ship.js config file](https://github.com/honeybadger-io/honeybadger-js/blob/master/ship.config.js) | ||
- [Our Changelog file](https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md) | ||
- [Ship.js on GitHub](https://github.com/algolia/shipjs) | ||
- [Ship.js docs](https://community.algolia.com/shipjs/guide/) | ||
- [More about our unique setup](https://www.joshuawood.net/notes/release-automation-with-ship-js-and-keep-a-changelog) | ||
## License | ||
The Honeybadger gem is MIT licensed. See the [MIT-LICENSE](https://raw.github.com/honeybadger-io/honeybadger-js/master/MIT-LICENSE) file in this repository for details. | ||
--- | ||
<p><a href="https://www.browserstack.com/"><img src="/browserstack-logo.png" width="150"></a><br> | ||
<p><a href="https://www.browserstack.com/"><img src="./browserstack-logo.png" width="150"></a><br> | ||
<small>We use <a href="https://www.browserstack.com/">BrowserStack</a> to run our automated integration tests on multiple platforms in CI.</small></p> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
17
406522
24
3437
55
+ Added@honeybadger-io/core@^4.1.0
+ Added@honeybadger-io/core@4.10.0(transitive)
- Removedstacktrace-parser@^0.1.10