honeybadger-js
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -8,2 +8,7 @@ # Change Log | ||
## [2.2.2] - 2020-05-22 | ||
### Fixed | ||
- Replace use of `for...in` over `Array` w/ `Array.prototype.some()` (#340) | ||
- Add TypeScript definition for `Honeybadger.addBreadcrumb` | ||
## [2.2.1] - 2020-04-12 | ||
@@ -10,0 +15,0 @@ ### Fixed |
@@ -205,3 +205,3 @@ 'use strict'; | ||
function builder() { | ||
var VERSION = '2.2.1', | ||
var VERSION = '2.2.2', | ||
NOTIFIER = { | ||
@@ -256,9 +256,4 @@ name: 'honeybadger-js', | ||
function isIgnored(err, patterns) { | ||
var msg = err.message; | ||
for (var p in patterns) { | ||
if (patterns[p].test(msg)) { return true; } | ||
} | ||
return false; | ||
if (!Array.isArray(patterns)) { return false; } | ||
return patterns.some((p) => p.test(err.message)); | ||
} | ||
@@ -265,0 +260,0 @@ |
@@ -203,3 +203,3 @@ function sanitize(obj, maxDepth) { | ||
function builder() { | ||
var VERSION = '2.2.1', | ||
var VERSION = '2.2.2', | ||
NOTIFIER = { | ||
@@ -254,9 +254,4 @@ name: 'honeybadger-js', | ||
function isIgnored(err, patterns) { | ||
var msg = err.message; | ||
for (var p in patterns) { | ||
if (patterns[p].test(msg)) { return true; } | ||
} | ||
return false; | ||
if (!Array.isArray(patterns)) { return false; } | ||
return patterns.some((p) => p.test(err.message)); | ||
} | ||
@@ -263,0 +258,0 @@ |
@@ -254,3 +254,3 @@ (function (global, factory) { | ||
function builder() { | ||
var VERSION = '2.2.1', | ||
var VERSION = '2.2.2', | ||
NOTIFIER = { | ||
@@ -328,11 +328,9 @@ name: 'honeybadger-js', | ||
function isIgnored(err, patterns) { | ||
var msg = err.message; | ||
for (var p in patterns) { | ||
if (patterns[p].test(msg)) { | ||
return true; | ||
} | ||
if (!Array.isArray(patterns)) { | ||
return false; | ||
} | ||
return false; | ||
return patterns.some(function (p) { | ||
return p.test(err.message); | ||
}); | ||
} | ||
@@ -339,0 +337,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Honeybadger=e()}(this,function(){"use strict";function j(t){return(j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,i){var s=[];return function e(t,n){if(i<=(n=n||0))return"[DEPTH]";if(/function|symbol/.test(j(r=t))||null===r||"object"===j(r)&&void 0===r.hasOwnProperty)return Object.prototype.toString.call(t);var r;if(function(t){if(!t||"object"!==j(t))return 0;for(var e=0;e<s.length;e++)if(s[e]===t)return 1;return s.push(t),0}(t))return"[RECURSION]";if(Array.isArray(t))return t.map(function(t){return e(t,n+1)});if("object"!==j(t))return t;var o={};for(var a in t){var c=t[a];Object.prototype.hasOwnProperty.call(t,a)&&null!=a&&null!=c&&(o[a]=e(c,n+1))}return o}(t)}function x(n){if(!n||!n.tagName)return"";var r=n.tagName.toLowerCase();if("html"===r)return"";n.id&&(r+="#".concat(n.id));var t=n.getAttribute("class");t&&t.split(/\s+/).forEach(function(t){r+=".".concat(t)}),["alt","name","title","type"].forEach(function(t){var e=n.getAttribute(t);e&&(r+="[".concat(t,'="').concat(e,'"]'))});var e=function(e){try{var t=e.parentNode.childNodes,n=[];return Array.prototype.forEach.call(t,function(t){t.tagName&&t.tagName===e.tagName&&n.push(t)}),n}catch(t){return[]}}(n);return 1<e.length&&(r+=":nth-child(".concat(Array.prototype.indexOf.call(e,n)+1,")")),r}function S(t){var e=t.textContent||t.innerText||"";return e||"submit"!==t.type&&"button"!==t.type||(e=t.value),function(t,e){t.length>e&&(t=t.substr(0,e)+"...");return t}(e.trim(),300)}function N(t){return-1!==t.toString().indexOf("native")}function r(t){var e=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:e[2],host:e[4],pathname:e[5]}}function T(t){var e=r(t),n=r(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 R,O,H,L,C,t=(C=L=!(H={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:O="2.2.1",language:"javascript"}),function(t){var s=C,e=[],a=[],u={context:{},beforeNotifyHandlers:[],afterNotifyHandlers:[],breadcrumbs:[],errorsSent:0};if("object"===j(t))for(var n in t)u[n]=t[n];function i(){var t=window.console;if(t){var e=Array.prototype.slice.call(arguments);e.unshift("[Honeybadger]"),t.log.apply(t,e)}}function f(){if(d("debug"))return i.apply(this,arguments)}function d(t,e){var n=u[t];return void 0===n&&(n=u[t.toLowerCase()]),"false"===n&&(n=!1),void 0!==n?n:e}function l(){return!s&&d("onerror",!0)}function c(){return d("breadcrumbsEnabled",!0)}function r(t,e){try{var n=function(t){var e=function(){var t={};return t.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(t.HTTP_REFERER=document.referrer),t}();return"string"==typeof t.cookies?e.HTTP_COOKIE=t.cookies:"object"===j(t.cookies)&&(e.HTTP_COOKIE=function(t){if("object"===j(t)){var e=[];for(var n in t)e.push(n+"="+t[n]);return e.join(";")}}(t.cookies)),{notifier:H,breadcrumbs:{enabled:c(),trail:t.breadcrumbs},error:{class:t.name,message:t.message,backtrace:t.stack,generator:t.generator,fingerprint:t.fingerprint},request:{url:t.url,component:t.component,action:t.action,context:t.context,cgi_data:e,params:t.params},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision}}}(e),r=new XMLHttpRequest;r.open("POST","http"+(d("ssl",!0)?"s":"")+"://"+d("host","api.honeybadger.io")+"/v1/notices/js",d("async",!0)),r.setRequestHeader("X-API-Key",t),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Accept","text/json, application/json"),r.send(JSON.stringify(E(n,d("max_depth",8)))),r.onload=function(){var t=Array.prototype.slice.call(u.afterNotifyHandlers);if(e.afterNotify&&t.unshift(e.afterNotify),201!==r.status)return I(t,new Error("Bad HTTP response: ".concat(r.status)),e),void f("Unable to send error report: ".concat(r.status,": ").concat(r.statusText),r,e);I(t,void 0,A(e,{id:JSON.parse(r.response).id})),f("Error report sent",n)}}catch(t){I(u.afterNotifyHandlers,t,e),i("Unable to send error report: error while initializing request",t,e)}}function p(t){if(R=null,d("disabled",!1))return f("Dropping notice: honeybadger.js is disabled",t),!1;var e,n=d("apiKey",d("api_key"));return n?(e=d("maxErrors"))&&u.errorsSent>=e?(f("Dropping notice: max errors exceeded",t),!1):(u.errorsSent++,r(n,t),!0):(i("Unable to send error report: no API key has been configured"),!1)}function m(t,e){if(t=t||{},"[object Error]"===Object.prototype.toString.call(t)&&(t=A(t,{name:t.name,message:t.message,stack:B(t)})),"object"!==j(t)){var n=String(t);t={message:n}}if(q(t))return!1;if(R&&L&&p(R),function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return 0;return 1}(t))return!1;var r;e&&(t.stack=e.stack,r=e.generator),t=A(t,{name:t.name||"Error",context:A(u.context,t.context),url:t.url||document.URL,projectRoot:t.projectRoot||t.project_root||d("projectRoot",d("project_root",window.location.protocol+"//"+window.location.host)),environment:t.environment||d("environment"),component:t.component||d("component"),action:t.action||d("action"),revision:t.revision||d("revision")}),u.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:t.message,name:t.name,stack:t.stack}}),t.breadcrumbs=u.breadcrumbs.slice();var o=t.stack;return!I(u.beforeNotifyHandlers,t)&&(t.stack!=o&&(r=void 0),!function(t,e){var n=t.message;for(var r in e)if(e[r].test(n))return 1;return 0}(t,d("ignorePatterns"))&&(t.generator=r,R=t,L?(f("Deferring notice",t),window.setTimeout(function(){q(t)&&p(t)})):(f("Queuing notice",t),a.push(t)),t))}var o=!0;if(window.atob||(o=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(o=!1)}catch(t){}function h(n,r){r=r||{};try{return"function"!=typeof n?n:(t=n,"function"!=typeof Object.isExtensible||Object.isExtensible(t)?(n.___hb||(n.___hb=function(){var t=l();if(!(o&&(t||r.force)||r.force&&!t))return n.apply(this,arguments);try{return n.apply(this,arguments)}catch(t){var e={stack:B(t)};throw u.addBreadcrumb(r.component?"".concat(r.component,": ").concat(t.name):t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:e.stack}}),m(t,e),t}}),n.___hb.___hb=n.___hb,n.___hb):n)}catch(t){return n}var t}u.notify=function(t,e,n){return t=t||{},"[object Error]"===Object.prototype.toString.call(t)&&(t=A(t,{name:t.name,message:t.message,stack:B(t)})),"object"!==j(t)&&(t={message:String(t)}),e&&"object"!==j(e)&&(e={name:String(e)}),e&&(t=P(t,e)),"object"===j(n)&&(t=P(t,n)),m(t,function(t){var e;if(t&&(e=B(t)))return{stack:e,generator:void 0};try{throw new Error("")}catch(t){if(e=B(t))return{stack:e,generator:"throw"}}e=["<call-stack>"];for(var n=arguments.callee;n&&e.length<10;){/function(?:\s+([\w$]+))+\s*\(/.test(n.toString())?e.push(RegExp.$1||"<anonymous>"):e.push("<anonymous>");try{n=n.caller}catch(t){break}}return{stack:e.join("\n"),generator:"walk"}}(t))},u.wrap=function(t){return h(t,{force:!0})},u.setContext=function(t){return"object"===j(t)&&(u.context=A(u.context,t)),u},u.resetContext=function(t){return"object"===j(t)?u.context=A({},t):u.context={},u},u.configure=function(t){for(var e in t)u[e]=t[e];return u},u.beforeNotify=function(t){return u.beforeNotifyHandlers.push(t),u},u.afterNotify=function(t){return u.afterNotifyHandlers.push(t),u};var y,g=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1};function v(t,e,n){if(!s&&t&&e&&n&&e in t){for(var r=t[e];r&&r.__hb_original;)r=r.__hb_original;t[e]=n(r),t[e].__hb_original=r}}function b(t,e){y=e,u.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:t,to:e}})}function w(e){return function(){var t=2<arguments.length?arguments[2]:void 0;return t&&b(y,String(t)),e.apply(this,arguments)}}function _(o){return function(r){return function(t,e){if("function"!=typeof t)return r(t,e);var n=Array.prototype.slice.call(arguments,2);return t=h(t,o),r(function(){t.apply(null,n)},e)}}}for(var n in u.reset=function(){for(var t in u.context={},u.beforeNotifyHandlers=[],u.breadcrumbs=[],u)-1==g.call(e,t)&&(u[t]=void 0);return u.resetMaxErrors(),u},u.resetMaxErrors=function(){return u.errorsSent=0},u.getVersion=function(){return O},u.addBreadcrumb=function(t,e){if(c()){var n=function(t){if("object"!==j(t))return{};var e={};for(var n in t)e[n]=t[n];return e}((e=e||{}).metadata),r=e.category||"custom",o=(new Date).toISOString();u.breadcrumbs.push({category:r,message:t,metadata:n,timestamp:o});var a=d("maxBreadcrumbs",40);return u.breadcrumbs.length>a&&(u.breadcrumbs=u.breadcrumbs.slice(u.breadcrumbs.length-a)),u}},window.addEventListener("click",function(t){var e,n,r;try{e=x(t.target),n=function t(e){var n=x(e);if(e.parentNode&&e.parentNode.tagName){var r=t(e.parentNode);if(0<r.length)return"".concat(r," > ").concat(n)}return n}(t.target),r=S(t.target)}catch(t){e="UI Click",r=n="[unknown]"}0!==e.length&&u.addBreadcrumb(e,{category:"ui.click",metadata:{selector:n,text:r,event:t}})},!0),v(XMLHttpRequest.prototype,"open",function(r){return function(){var t=arguments[1],e="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],n="".concat(e," ").concat(T(t));this.__hb_xhr={type:"xhr",method:e,url:t,message:n},"function"==typeof r&&r.apply(this,arguments)}}),v(XMLHttpRequest.prototype,"send",function(t){return function(){var e=this;function n(){var t;4===e.readyState&&(e.__hb_xhr&&(e.__hb_xhr.status_code=e.status,t=e.__hb_xhr.message,delete e.__hb_xhr.message),u.addBreadcrumb(t||"XMLHttpRequest",{category:"request",metadata:e.__hb_xhr}))}"onreadystatechange"in e&&"function"==typeof e.onreadystatechange?v(e,"onreadystatechange",function(t){return function(){n(),"function"==typeof t&&t.apply(this,arguments)}}):e.onreadystatechange=n,"function"==typeof t&&t.apply(e,arguments)}}),function(){if(!window.fetch)return!1;if(N(window.fetch))return!0;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&N(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}()&&v(window,"fetch",function(a){return function(){var t,e=arguments[0],n="GET";"string"==typeof e?t=e:"Request"in window&&e instanceof Request?(t=e.url,e.method&&(n=e.method)):t=String(e),arguments[1]&&arguments[1].method&&(n=arguments[1].method),"string"==typeof n&&(n=n.toUpperCase());var r="".concat(n," ").concat(T(t)),o={type:"fetch",method:n,url:t};return a.apply(this,arguments).then(function(t){return o.status_code=t.status,u.addBreadcrumb(r,{category:"request",metadata:o}),t}).catch(function(t){throw u.addBreadcrumb("fetch error",{category:"error",metadata:o}),t})}}),y=window.location.href,v(window,"onpopstate",function(t){return function(){if(b(y,window.location.href),t)return t.apply(this,arguments)}}),v(window.history,"pushState",w),v(window.history,"replaceState",w),["debug","info","warn","error","log"].forEach(function(a){v(window.console,a,function(o){return function(){var t,e=Array.prototype.slice.call(arguments),n=(t=e,Array.isArray(t)?t.map(function(t){try{return String(t)}catch(t){return"[unknown]"}}).join(" "):""),r={category:"log",metadata:{level:a,arguments:E(e,3)}};u.addBreadcrumb(n,r),"function"==typeof o&&Function.prototype.apply.call(o,window.console,arguments)}})}),v(window,"setTimeout",_({component:"setTimeout"})),v(window,"setInterval",_({component:"setInterval"})),"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".replace(/\w+/g,function(t){var e=window[t]&&window[t].prototype;e&&e.hasOwnProperty&&e.hasOwnProperty("addEventListener")&&(v(e,"addEventListener",function(o){var a={component:"".concat(t,".prototype.addEventListener")};return function(t,e,n,r){try{e&&null!=e.handleEvent&&(e.handleEvent=h(e.handleEvent,a))}catch(t){i(t)}return o.call(this,t,h(e,a),n,r)}}),v(e,"removeEventListener",function(o){return function(t,e,n,r){return o.call(this,t,e,n,r),o.call(this,t,h(e),n,r)}}))}),v(window,"onerror",function(a){return function(t,e,n,r,o){return function(t,e,n,r,o){if(f("window.onerror callback invoked",arguments),!R&&l())if(0===n&&/Script error\.?/.test(t))i("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments);else{var a,c=[t,"\n at ? (",e||"unknown",":",n||0,":",r||0,")"].join("");o?(a={stack:B(o)}).stack||(a={stack:c}):o={name:"window.onerror",message:t,stack:c},u.addBreadcrumb("window.onerror"!==o.name&&o.name?"window.onerror: ".concat(o.name):"window.onerror",{category:"error",metadata:{message:o.message,name:o.name,stack:a?a.stack:o.stack}}),m(o,a)}}(t,e,n,r,o),!("function"!=typeof a||!d("_onerror_call_orig",!0))&&a.apply(this,arguments)}}),v(window,"onunhandledrejection",function(e){function n(t){if(f("window.onunhandledrejection callback invoked",arguments),!R&&!s&&d("onunhandledrejection",!0)){var e=t.reason;if(e instanceof Error){var n=e.fileName||"unknown",r=e.lineNumber||0,o="".concat(e.message,"\n at ? (").concat(n,":").concat(r,")"),a=B(e)||o,c={name:e.name,message:"UnhandledPromiseRejectionWarning: ".concat(e),stack:a};return u.addBreadcrumb("window.onunhandledrejection: ".concat(c.name),{category:"error",metadata:c}),void m(c)}var i="string"==typeof e?e:JSON.stringify(e);m({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: ".concat(i)})}}return function(t){n(t),"function"==typeof e&&e.apply(this,arguments)}}),C=!0,u)e.push(n);if(f("Initializing honeybadger.js "+O),/complete|interactive|loaded/.test(document.readyState))L=!0,f("honeybadger.js 2.2.1 ready");else{f("Installing ready handler");var k=function(){var t;for(L=!0,f("honeybadger.js 2.2.1 ready");t=a.pop();)p(t)};document.addEventListener?document.addEventListener("DOMContentLoaded",k,!0):window.attachEvent("onload",k)}return u});function A(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 P(t,e){var n=A(t,e);return t.context&&e.context&&(n.context=A(t.context,e.context)),n}function q(t){return!!R&&(R.name===t.name&&(R.message===t.message&&R.stack===t.stack))}function B(t){return t.stacktrace||t.stack||void 0}function I(t,e,n){var r,o;for(r=0,o=t.length;r<o;r++)if(!1===(0,t[r])(e,n))return!0;return!1}var e=t();return e.factory=t,e}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Honeybadger=e()}(this,function(){"use strict";function j(t){return(j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,i){var s=[];return function e(t,n){if(i<=(n=n||0))return"[DEPTH]";if(/function|symbol/.test(j(r=t))||null===r||"object"===j(r)&&void 0===r.hasOwnProperty)return Object.prototype.toString.call(t);var r;if(function(t){if(!t||"object"!==j(t))return 0;for(var e=0;e<s.length;e++)if(s[e]===t)return 1;return s.push(t),0}(t))return"[RECURSION]";if(Array.isArray(t))return t.map(function(t){return e(t,n+1)});if("object"!==j(t))return t;var o={};for(var a in t){var c=t[a];Object.prototype.hasOwnProperty.call(t,a)&&null!=a&&null!=c&&(o[a]=e(c,n+1))}return o}(t)}function x(n){if(!n||!n.tagName)return"";var r=n.tagName.toLowerCase();if("html"===r)return"";n.id&&(r+="#".concat(n.id));var t=n.getAttribute("class");t&&t.split(/\s+/).forEach(function(t){r+=".".concat(t)}),["alt","name","title","type"].forEach(function(t){var e=n.getAttribute(t);e&&(r+="[".concat(t,'="').concat(e,'"]'))});var e=function(e){try{var t=e.parentNode.childNodes,n=[];return Array.prototype.forEach.call(t,function(t){t.tagName&&t.tagName===e.tagName&&n.push(t)}),n}catch(t){return[]}}(n);return 1<e.length&&(r+=":nth-child(".concat(Array.prototype.indexOf.call(e,n)+1,")")),r}function S(t){var e=t.textContent||t.innerText||"";return e||"submit"!==t.type&&"button"!==t.type||(e=t.value),function(t,e){t.length>e&&(t=t.substr(0,e)+"...");return t}(e.trim(),300)}function N(t){return-1!==t.toString().indexOf("native")}function r(t){var e=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:e[2],host:e[4],pathname:e[5]}}function T(t){var e=r(t),n=r(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 R,O,H,L,A,t=(A=L=!(H={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:O="2.2.2",language:"javascript"}),function(t){var s=A,e=[],i=[],u={context:{},beforeNotifyHandlers:[],afterNotifyHandlers:[],breadcrumbs:[],errorsSent:0};if("object"===j(t))for(var n in t)u[n]=t[n];function f(){var t=window.console;if(t){var e=Array.prototype.slice.call(arguments);e.unshift("[Honeybadger]"),t.log.apply(t,e)}}function d(){if(l("debug"))return f.apply(this,arguments)}function l(t,e){var n=u[t];return void 0===n&&(n=u[t.toLowerCase()]),"false"===n&&(n=!1),void 0!==n?n:e}function p(){return!s&&l("onerror",!0)}function c(){return l("breadcrumbsEnabled",!0)}function r(t,e){try{var n=function(t){var e=function(){var t={};return t.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(t.HTTP_REFERER=document.referrer),t}();return"string"==typeof t.cookies?e.HTTP_COOKIE=t.cookies:"object"===j(t.cookies)&&(e.HTTP_COOKIE=function(t){if("object"===j(t)){var e=[];for(var n in t)e.push(n+"="+t[n]);return e.join(";")}}(t.cookies)),{notifier:H,breadcrumbs:{enabled:c(),trail:t.breadcrumbs},error:{class:t.name,message:t.message,backtrace:t.stack,generator:t.generator,fingerprint:t.fingerprint},request:{url:t.url,component:t.component,action:t.action,context:t.context,cgi_data:e,params:t.params},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision}}}(e),r=new XMLHttpRequest;r.open("POST","http"+(l("ssl",!0)?"s":"")+"://"+l("host","api.honeybadger.io")+"/v1/notices/js",l("async",!0)),r.setRequestHeader("X-API-Key",t),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Accept","text/json, application/json"),r.send(JSON.stringify(E(n,l("max_depth",8)))),r.onload=function(){var t=Array.prototype.slice.call(u.afterNotifyHandlers);if(e.afterNotify&&t.unshift(e.afterNotify),201!==r.status)return I(t,new Error("Bad HTTP response: ".concat(r.status)),e),void d("Unable to send error report: ".concat(r.status,": ").concat(r.statusText),r,e);I(t,void 0,C(e,{id:JSON.parse(r.response).id})),d("Error report sent",n)}}catch(t){I(u.afterNotifyHandlers,t,e),f("Unable to send error report: error while initializing request",t,e)}}function m(t){if(R=null,l("disabled",!1))return d("Dropping notice: honeybadger.js is disabled",t),!1;var e,n=l("apiKey",l("api_key"));return n?(e=l("maxErrors"))&&u.errorsSent>=e?(d("Dropping notice: max errors exceeded",t),!1):(u.errorsSent++,r(n,t),!0):(f("Unable to send error report: no API key has been configured"),!1)}function h(t,e){if(t=t||{},"[object Error]"===Object.prototype.toString.call(t)&&(t=C(t,{name:t.name,message:t.message,stack:B(t)})),"object"!==j(t)){var n=String(t);t={message:n}}if(q(t))return!1;if(R&&L&&m(R),function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return 0;return 1}(t))return!1;var r;e&&(t.stack=e.stack,r=e.generator),t=C(t,{name:t.name||"Error",context:C(u.context,t.context),url:t.url||document.URL,projectRoot:t.projectRoot||t.project_root||l("projectRoot",l("project_root",window.location.protocol+"//"+window.location.host)),environment:t.environment||l("environment"),component:t.component||l("component"),action:t.action||l("action"),revision:t.revision||l("revision")}),u.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:t.message,name:t.name,stack:t.stack}}),t.breadcrumbs=u.breadcrumbs.slice();var o,a,c=t.stack;return!I(u.beforeNotifyHandlers,t)&&(t.stack!=c&&(r=void 0),o=t,a=l("ignorePatterns"),(!Array.isArray(a)||!a.some(function(t){return t.test(o.message)}))&&(t.generator=r,R=t,L?(d("Deferring notice",t),window.setTimeout(function(){q(t)&&m(t)})):(d("Queuing notice",t),i.push(t)),t))}var o=!0;if(window.atob||(o=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(o=!1)}catch(t){}function y(n,r){r=r||{};try{return"function"!=typeof n?n:(t=n,"function"!=typeof Object.isExtensible||Object.isExtensible(t)?(n.___hb||(n.___hb=function(){var t=p();if(!(o&&(t||r.force)||r.force&&!t))return n.apply(this,arguments);try{return n.apply(this,arguments)}catch(t){var e={stack:B(t)};throw u.addBreadcrumb(r.component?"".concat(r.component,": ").concat(t.name):t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:e.stack}}),h(t,e),t}}),n.___hb.___hb=n.___hb,n.___hb):n)}catch(t){return n}var t}u.notify=function(t,e,n){return t=t||{},"[object Error]"===Object.prototype.toString.call(t)&&(t=C(t,{name:t.name,message:t.message,stack:B(t)})),"object"!==j(t)&&(t={message:String(t)}),e&&"object"!==j(e)&&(e={name:String(e)}),e&&(t=P(t,e)),"object"===j(n)&&(t=P(t,n)),h(t,function(t){var e;if(t&&(e=B(t)))return{stack:e,generator:void 0};try{throw new Error("")}catch(t){if(e=B(t))return{stack:e,generator:"throw"}}e=["<call-stack>"];for(var n=arguments.callee;n&&e.length<10;){/function(?:\s+([\w$]+))+\s*\(/.test(n.toString())?e.push(RegExp.$1||"<anonymous>"):e.push("<anonymous>");try{n=n.caller}catch(t){break}}return{stack:e.join("\n"),generator:"walk"}}(t))},u.wrap=function(t){return y(t,{force:!0})},u.setContext=function(t){return"object"===j(t)&&(u.context=C(u.context,t)),u},u.resetContext=function(t){return"object"===j(t)?u.context=C({},t):u.context={},u},u.configure=function(t){for(var e in t)u[e]=t[e];return u},u.beforeNotify=function(t){return u.beforeNotifyHandlers.push(t),u},u.afterNotify=function(t){return u.afterNotifyHandlers.push(t),u};var a,g=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1};function v(t,e,n){if(!s&&t&&e&&n&&e in t){for(var r=t[e];r&&r.__hb_original;)r=r.__hb_original;t[e]=n(r),t[e].__hb_original=r}}function b(t,e){a=e,u.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:t,to:e}})}function w(e){return function(){var t=2<arguments.length?arguments[2]:void 0;return t&&b(a,String(t)),e.apply(this,arguments)}}function _(o){return function(r){return function(t,e){if("function"!=typeof t)return r(t,e);var n=Array.prototype.slice.call(arguments,2);return t=y(t,o),r(function(){t.apply(null,n)},e)}}}for(var n in u.reset=function(){for(var t in u.context={},u.beforeNotifyHandlers=[],u.breadcrumbs=[],u)-1==g.call(e,t)&&(u[t]=void 0);return u.resetMaxErrors(),u},u.resetMaxErrors=function(){return u.errorsSent=0},u.getVersion=function(){return O},u.addBreadcrumb=function(t,e){if(c()){var n=function(t){if("object"!==j(t))return{};var e={};for(var n in t)e[n]=t[n];return e}((e=e||{}).metadata),r=e.category||"custom",o=(new Date).toISOString();u.breadcrumbs.push({category:r,message:t,metadata:n,timestamp:o});var a=l("maxBreadcrumbs",40);return u.breadcrumbs.length>a&&(u.breadcrumbs=u.breadcrumbs.slice(u.breadcrumbs.length-a)),u}},window.addEventListener("click",function(t){var e,n,r;try{e=x(t.target),n=function t(e){var n=x(e);if(e.parentNode&&e.parentNode.tagName){var r=t(e.parentNode);if(0<r.length)return"".concat(r," > ").concat(n)}return n}(t.target),r=S(t.target)}catch(t){e="UI Click",r=n="[unknown]"}0!==e.length&&u.addBreadcrumb(e,{category:"ui.click",metadata:{selector:n,text:r,event:t}})},!0),v(XMLHttpRequest.prototype,"open",function(r){return function(){var t=arguments[1],e="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],n="".concat(e," ").concat(T(t));this.__hb_xhr={type:"xhr",method:e,url:t,message:n},"function"==typeof r&&r.apply(this,arguments)}}),v(XMLHttpRequest.prototype,"send",function(t){return function(){var e=this;function n(){var t;4===e.readyState&&(e.__hb_xhr&&(e.__hb_xhr.status_code=e.status,t=e.__hb_xhr.message,delete e.__hb_xhr.message),u.addBreadcrumb(t||"XMLHttpRequest",{category:"request",metadata:e.__hb_xhr}))}"onreadystatechange"in e&&"function"==typeof e.onreadystatechange?v(e,"onreadystatechange",function(t){return function(){n(),"function"==typeof t&&t.apply(this,arguments)}}):e.onreadystatechange=n,"function"==typeof t&&t.apply(e,arguments)}}),function(){if(!window.fetch)return!1;if(N(window.fetch))return!0;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&N(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}()&&v(window,"fetch",function(a){return function(){var t,e=arguments[0],n="GET";"string"==typeof e?t=e:"Request"in window&&e instanceof Request?(t=e.url,e.method&&(n=e.method)):t=String(e),arguments[1]&&arguments[1].method&&(n=arguments[1].method),"string"==typeof n&&(n=n.toUpperCase());var r="".concat(n," ").concat(T(t)),o={type:"fetch",method:n,url:t};return a.apply(this,arguments).then(function(t){return o.status_code=t.status,u.addBreadcrumb(r,{category:"request",metadata:o}),t}).catch(function(t){throw u.addBreadcrumb("fetch error",{category:"error",metadata:o}),t})}}),a=window.location.href,v(window,"onpopstate",function(t){return function(){if(b(a,window.location.href),t)return t.apply(this,arguments)}}),v(window.history,"pushState",w),v(window.history,"replaceState",w),["debug","info","warn","error","log"].forEach(function(a){v(window.console,a,function(o){return function(){var t,e=Array.prototype.slice.call(arguments),n=(t=e,Array.isArray(t)?t.map(function(t){try{return String(t)}catch(t){return"[unknown]"}}).join(" "):""),r={category:"log",metadata:{level:a,arguments:E(e,3)}};u.addBreadcrumb(n,r),"function"==typeof o&&Function.prototype.apply.call(o,window.console,arguments)}})}),v(window,"setTimeout",_({component:"setTimeout"})),v(window,"setInterval",_({component:"setInterval"})),"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".replace(/\w+/g,function(t){var e=window[t]&&window[t].prototype;e&&e.hasOwnProperty&&e.hasOwnProperty("addEventListener")&&(v(e,"addEventListener",function(o){var a={component:"".concat(t,".prototype.addEventListener")};return function(t,e,n,r){try{e&&null!=e.handleEvent&&(e.handleEvent=y(e.handleEvent,a))}catch(t){f(t)}return o.call(this,t,y(e,a),n,r)}}),v(e,"removeEventListener",function(o){return function(t,e,n,r){return o.call(this,t,e,n,r),o.call(this,t,y(e),n,r)}}))}),v(window,"onerror",function(a){return function(t,e,n,r,o){return function(t,e,n,r,o){if(d("window.onerror callback invoked",arguments),!R&&p())if(0===n&&/Script error\.?/.test(t))f("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments);else{var a,c=[t,"\n at ? (",e||"unknown",":",n||0,":",r||0,")"].join("");o?(a={stack:B(o)}).stack||(a={stack:c}):o={name:"window.onerror",message:t,stack:c},u.addBreadcrumb("window.onerror"!==o.name&&o.name?"window.onerror: ".concat(o.name):"window.onerror",{category:"error",metadata:{message:o.message,name:o.name,stack:a?a.stack:o.stack}}),h(o,a)}}(t,e,n,r,o),!("function"!=typeof a||!l("_onerror_call_orig",!0))&&a.apply(this,arguments)}}),v(window,"onunhandledrejection",function(e){function n(t){if(d("window.onunhandledrejection callback invoked",arguments),!R&&!s&&l("onunhandledrejection",!0)){var e=t.reason;if(e instanceof Error){var n=e.fileName||"unknown",r=e.lineNumber||0,o="".concat(e.message,"\n at ? (").concat(n,":").concat(r,")"),a=B(e)||o,c={name:e.name,message:"UnhandledPromiseRejectionWarning: ".concat(e),stack:a};return u.addBreadcrumb("window.onunhandledrejection: ".concat(c.name),{category:"error",metadata:c}),void h(c)}var i="string"==typeof e?e:JSON.stringify(e);h({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: ".concat(i)})}}return function(t){n(t),"function"==typeof e&&e.apply(this,arguments)}}),A=!0,u)e.push(n);if(d("Initializing honeybadger.js "+O),/complete|interactive|loaded/.test(document.readyState))L=!0,d("honeybadger.js 2.2.2 ready");else{d("Installing ready handler");var k=function(){var t;for(L=!0,d("honeybadger.js 2.2.2 ready");t=i.pop();)m(t)};document.addEventListener?document.addEventListener("DOMContentLoaded",k,!0):window.attachEvent("onload",k)}return u});function C(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 P(t,e){var n=C(t,e);return t.context&&e.context&&(n.context=C(t.context,e.context)),n}function q(t){return!!R&&(R.name===t.name&&(R.message===t.message&&R.stack===t.stack))}function B(t){return t.stacktrace||t.stack||void 0}function I(t,e,n){var r,o;for(r=0,o=t.length;r<o;r++)if(!1===(0,t[r])(e,n))return!0;return!1}var e=t();return e.factory=t,e}); | ||
//# sourceMappingURL=honeybadger.min.js.map |
@@ -34,2 +34,7 @@ declare module "honeybadger-js" { | ||
} | ||
interface BreadcrumbOptions { | ||
category?: string; | ||
metadata?: { [s: string]: boolean | number | string }; | ||
} | ||
@@ -48,2 +53,3 @@ class Honeybadger { | ||
static beforeNotifyHandlers: ((notice?: Notice) => void)[]; | ||
static addBreadcrumb(message: string, opts?: BreadcrumbOptions): Honeybadger; | ||
static factory(config: Config): Honeybadger; | ||
@@ -50,0 +56,0 @@ } |
{ | ||
"name": "honeybadger-js", | ||
"description": "A JavaScript library for integrating apps with the Honeybadger Rails Error Notifier.", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"license": "MIT", | ||
@@ -35,21 +35,21 @@ "homepage": "https://github.com/honeybadger-io/honeybadger-js", | ||
"devDependencies": { | ||
"@babel/core": "^7.3.4", | ||
"@babel/preset-env": "^7.3.4", | ||
"@babel/core": "^7.9.0", | ||
"@babel/preset-env": "^7.9.5", | ||
"babel-eslint": "^10.0.3", | ||
"eslint": "^6.1.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-config-prettier": "^6.4.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jasmine": "^3.5.0", | ||
"jasmine-core": "^3.5.0", | ||
"karma": "^4.3.0", | ||
"karma": "^5.0.1", | ||
"karma-browserstack-launcher": "^1.5.1", | ||
"karma-chrome-launcher": "^3.0.0", | ||
"karma-jasmine": "^3.1.0", | ||
"karma-rollup-preprocessor": "^7.0.0", | ||
"karma-rollup-preprocessor": "^7.0.5", | ||
"karma-sinon": "^1.0.5", | ||
"prettier": "^1.18.2", | ||
"prettier": "^2.0.4", | ||
"promise-polyfill": "8.1.3", | ||
"puppeteer": "^2.0.0", | ||
"puppeteer": "^3.0.0", | ||
"rollup": "^1.0.0", | ||
@@ -61,3 +61,3 @@ "rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-uglify": "^6.0.2", | ||
"sinon": "^9.0.1", | ||
"sinon": "^9.0.2", | ||
"whatwg-fetch": "^3.0.0" | ||
@@ -64,0 +64,0 @@ }, |
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
265261
3277