honeybadger-js
Advanced tools
Comparing version 2.1.0-beta.1 to 2.1.0-beta.2
@@ -8,2 +8,7 @@ # Change Log | ||
## [2.1.0-beta.2] - 2019-11-26 | ||
### Fixed | ||
- Global browser instrumentation now unwraps previously wrapped | ||
functions prior to wrapping them. | ||
## [2.1.0-beta.1] - 2019-11-21 | ||
@@ -10,0 +15,0 @@ |
@@ -203,3 +203,3 @@ 'use strict'; | ||
function builder() { | ||
var VERSION = '2.1.0-beta.1', | ||
var VERSION = '2.1.0-beta.2', | ||
NOTIFIER = { | ||
@@ -720,4 +720,8 @@ name: 'honeybadger-js', | ||
if (!object || !name || !replacement || !(name in object)) { return; } | ||
var original = object[name]; | ||
let original = object[name]; | ||
while (original && original.__hb_original) { | ||
original = original.__hb_original; | ||
} | ||
object[name] = replacement(original); | ||
object[name].__hb_original = original; | ||
} | ||
@@ -724,0 +728,0 @@ |
@@ -201,3 +201,3 @@ function sanitize(obj, maxDepth) { | ||
function builder() { | ||
var VERSION = '2.1.0-beta.1', | ||
var VERSION = '2.1.0-beta.2', | ||
NOTIFIER = { | ||
@@ -718,4 +718,8 @@ name: 'honeybadger-js', | ||
if (!object || !name || !replacement || !(name in object)) { return; } | ||
var original = object[name]; | ||
let original = object[name]; | ||
while (original && original.__hb_original) { | ||
original = original.__hb_original; | ||
} | ||
object[name] = replacement(original); | ||
object[name].__hb_original = original; | ||
} | ||
@@ -722,0 +726,0 @@ |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = global || self, global.Honeybadger = factory()); | ||
}(this, function () { 'use strict'; | ||
}(this, (function () { 'use strict'; | ||
@@ -247,3 +247,3 @@ function _typeof(obj) { | ||
function builder() { | ||
var VERSION = '2.1.0-beta.1', | ||
var VERSION = '2.1.0-beta.2', | ||
NOTIFIER = { | ||
@@ -874,3 +874,9 @@ name: 'honeybadger-js', | ||
var original = object[name]; | ||
while (original && original.__hb_original) { | ||
original = original.__hb_original; | ||
} | ||
object[name] = replacement(original); | ||
object[name].__hb_original = original; | ||
} // Breadcrumbs: instrument click events | ||
@@ -1341,3 +1347,3 @@ | ||
})); | ||
}))); | ||
//# sourceMappingURL=honeybadger.js.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=t||self).Honeybadger=e()}(this,function(){"use strict";function T(t){return(T="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 N(t,i){var u=[];return function e(t,n){if(n||(n=0),i<=n)return"[DEPTH]";if(/function|symbol/.test(T(r=t))||null===r||"object"===T(r)&&void 0===r.hasOwnProperty)return Object.prototype.toString.call(t);var r;if(function(t){if(!t||"object"!==T(t))return!1;for(var e=0;e<u.length;e++)if(u[e]===t)return!0;return u.push(t),!1}(t))return"[RECURSION]";if(Array.isArray(t))return t.map(function(t){return e(t,n+1)});if("object"!==T(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 H(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 L(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 C(t){var e=r(t),n=r(document.URL);return!e.host||e.protocol?e.pathname:e.protocol===n.protocol&&e.host===n.host?e.pathname:"".concat(e.protocol,"://").concat(e.host).concat(e.pathname)}var t=function(){var b,w,k="2.1.0-beta.1",_={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:k,language:"javascript"},j=!1,x=!1;function E(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 S(t,e){var n=E(t,e);return t.context&&e.context&&(n.context=E(t.context,e.context)),n}function R(t){return!!b&&b.name===t.name&&b.message===t.message&&b.stack===t.stack}function O(t){return t.stacktrace||t.stack||void 0}return function(t){var u=x,e=[],s=[],f={context:{},beforeNotifyHandlers:[],breadcrumbs:[],errorsSent:0};if("object"===T(t))for(var n in t)f[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 d(){if(l("debug"))return i.apply(this,arguments)}function l(t,e){var n=f[t];return void 0===n&&(n=f[t.toLowerCase()]),"false"===n&&(n=!1),void 0!==n?n:e}function p(){return!u&&l("onerror",!0)}function m(){return l("breadcrumbsEnabled",!1)}function r(t,e){try{var n=new XMLHttpRequest;n.open("POST","http"+(l("ssl",!0)?"s":"")+"://"+l("host","api.honeybadger.io")+"/v1/notices/js",l("async",!0)),n.setRequestHeader("X-API-Key",t),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Accept","text/json, application/json"),n.send(JSON.stringify(N(e,l("max_depth",8))))}catch(t){i("Unable to send error report: error while initializing request",t,e)}}function h(t){if(b=w=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"))&&f.errorsSent>=e?(d("Dropping notice: max errors exceeded",t),!1):(f.errorsSent++,r(n,t),!0):(i("Unable to send error report: no API key has been configured"),!1)}function y(t,e){if(t||(t={}),"[object Error]"===Object.prototype.toString.call(t)){var n=t;t=E(t,{name:n.name,message:n.message,stack:O(n)})}if("object"!==T(t)){var r=String(t);t={message:r}}if(R(t))return!1;if(w&&j&&h(w),function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(t))return!1;var o;e&&(t.stack=e.stack,o=e.generator),t=E(t,{name:t.name||"Error",context:E(f.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")}),f.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:t.message,name:t.name,stack:t.stack}}),t.breadcrumbs=f.breadcrumbs.slice();var a=t.stack;if(function(t,e){var n,r;for(n=0,r=t.length;n<r;n++)if(!1===(0,t[n])(e))return!0;return!1}(f.beforeNotifyHandlers,t))return!1;if(t.stack!=a&&(o=void 0),function(t,e){var n=t.message;for(var r in e)if(n.match(e[r]))return!0;return!1}(t,l("ignorePatterns")))return!1;var c,i=((c={}).HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(c.HTTP_REFERER=document.referrer),c);"string"==typeof t.cookies?i.HTTP_COOKIE=t.cookies:"object"===T(t.cookies)&&(i.HTTP_COOKIE=function(t){if("object"===T(t)){var e=[];for(var n in t)e.push(n+"="+t[n]);return e.join(";")}}(t.cookies));var u={notifier:_,breadcrumbs:{enabled:m(),trail:t.breadcrumbs},error:{class:t.name,message:t.message,backtrace:t.stack,generator:o,fingerprint:t.fingerprint},request:{url:t.url,component:t.component,action:t.action,context:t.context,cgi_data:i,params:t.params},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision}};return w=u,b=t,j?(d("Deferring notice",t,u),window.setTimeout(function(){R(t)&&h(u)})):(d("Queuing notice",t,u),s.push(u)),t}var o=!0;if(window.atob||(o=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(o=!1)}catch(t){}function c(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:O(t)};throw f.addBreadcrumb(r.component?"".concat(r.component,": ").concat(t.name):t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:e.stack}}),y(t,e),t}}),n.___hb.___hb=n.___hb,n.___hb):n)}catch(t){return n}var t}f.notify=function(t,e,n){if(t||(t={}),"[object Error]"===Object.prototype.toString.call(t)){var r=t;t=E(t,{name:r.name,message:r.message,stack:O(r)})}return"object"!==T(t)&&(t={message:String(t)}),e&&"object"!==T(e)&&(e={name:String(e)}),e&&(t=S(t,e)),"object"===T(n)&&(t=S(t,n)),y(t,function(t){var e;if(t&&(e=O(t)))return{stack:e,generator:void 0};try{throw new Error("")}catch(t){if(e=O(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))},f.wrap=function(t){return c(t,{force:!0})},f.setContext=function(t){return"object"===T(t)&&(f.context=E(f.context,t)),f},f.resetContext=function(t){return"object"===T(t)?f.context=E({},t):f.context={},f},f.configure=function(t){for(var e in t)f[e]=t[e];return f},f.beforeNotify=function(t){return f.beforeNotifyHandlers.push(t),f};var a=[].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 g(t,e,n){if(!u&&t&&e&&n&&e in t){var r=t[e];t[e]=n(r)}}for(var n in f.reset=function(){for(var t in f.context={},f.beforeNotifyHandlers=[],f.breadcrumbs=[],f)-1==a.call(e,t)&&(f[t]=void 0);return f.resetMaxErrors(),f},f.resetMaxErrors=function(){return f.errorsSent=0},f.getVersion=function(){return k},f.addBreadcrumb=function(t,e){if(m()){var n=(e=e||{}).metadata||void 0,r=e.category||"custom",o=(new Date).toISOString();f.breadcrumbs.push({category:r,message:t,metadata:n||{},timestamp:o});var a=l("maxBreadcrumbs",40);return f.breadcrumbs.length>a&&(f.breadcrumbs=f.breadcrumbs.slice(f.breadcrumbs.length-a)),f}},window.addEventListener("click",function(t){var e,n,r,o,a,c;try{e=H(t.target),n=function t(e){var n=H(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),o=t.target,a=(o.textContent||o.innerText||o.value||"").trim(),c=300,a.length>c&&(a=a.substr(0,c)+"..."),r=a}catch(t){e="UI Click",r=n="[unknown]"}0!==e.length&&f.addBreadcrumb(e,{category:"ui.click",metadata:{selector:n,text:r,event:t}})},!0),g(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(C(t));this.__hb_xhr={type:"xhr",method:e,url:t,message:n},"function"==typeof r&&r.apply(this,arguments)}}),g(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),f.addBreadcrumb(t||"XMLHttpRequest",{category:"request",metadata:e.__hb_xhr}))}"onreadystatechange"in e&&"function"==typeof e.onreadystatechange?g(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(L(window.fetch))return!0;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&L(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}()&&g(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(C(t)),o={type:"fetch",method:n,url:t};return a.apply(this,arguments).then(function(t){return o.status_code=t.status,f.addBreadcrumb(r,{category:"request",metadata:o}),t}).catch(function(t){throw f.addBreadcrumb("fetch error",{category:"error",metadata:o}),t})}}),function(){var n=window.location.href;function r(t,e){n=e,f.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:t,to:e}})}function t(e){return function(){var t=2<arguments.length?arguments[2]:void 0;return t&&r(n,String(t)),e.apply(this,arguments)}}g(window,"onpopstate",function(t){return function(){if(r(n,window.location.href),t)return t.apply(this,arguments)}}),g(window.history,"pushState",t),g(window.history,"replaceState",t)}(),["debug","info","warn","error","log"].forEach(function(a){g(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:N(e,3)}};f.addBreadcrumb(n,r),"function"==typeof o&&Function.prototype.apply.call(o,window.console,arguments)}})}),function(){function t(o){return function(r){return function(t,e){if("function"!=typeof t)return r(t,e);var n=Array.prototype.slice.call(arguments,2);return t=c(t,o),r(function(){t.apply(null,n)},e)}}}g(window,"setTimeout",t({component:"setTimeout"})),g(window,"setInterval",t({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")&&(g(e,"addEventListener",function(o){var a={component:"".concat(t,".prototype.addEventListener")};return function(t,e,n,r){try{e&&null!=e.handleEvent&&(e.handleEvent=c(e.handleEvent,a))}catch(t){i(t)}return o.call(this,t,c(e,a),n,r)}}),g(e,"removeEventListener",function(o){return function(t,e,n,r){return o.call(this,t,e,n,r),o.call(this,t,c(e),n,r)}}))}),g(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),!b&&p())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:O(o)}).stack||(a={stack:c}):o={name:"window.onerror",message:t,stack:c},f.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}}),y(o,a)}}(t,e,n,r,o),!("function"!=typeof a||!l("_onerror_call_orig",!0))&&a.apply(this,arguments)}}),g(window,"onunhandledrejection",function(e){function n(t){if(d("window.onunhandledrejection callback invoked",arguments),!b&&!u&&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=O(e)||o,c={name:e.name,message:"UnhandledPromiseRejectionWarning: ".concat(e),stack:a};return f.addBreadcrumb("window.onunhandledrejection: ".concat(c.name),{category:"error",metadata:c}),void y(c)}var i="string"==typeof e?e:JSON.stringify(e);y({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: ".concat(i)})}}return function(t){n(t),"function"==typeof e&&e.apply(this,arguments)}}),x=!0,f)e.push(n);if(d("Initializing honeybadger.js "+k),/complete|interactive|loaded/.test(document.readyState))j=!0,d("honeybadger.js "+k+" ready");else{d("Installing ready handler");var v=function(){var t;for(j=!0,d("honeybadger.js "+k+" ready");t=s.pop();)h(t)};document.addEventListener?document.addEventListener("DOMContentLoaded",v,!0):window.attachEvent("onload",v)}return f}}(),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 x(t,c){var i=[];return function e(t,n){if(c<=(n=n||0))return"[DEPTH]";if(!function(t){return!/function|symbol/.test(j(t))&&null!==t&&("object"!==j(t)||void 0!==t.hasOwnProperty)}(t))return Object.prototype.toString.call(t);if(function(t){if(!t||"object"!==j(t))return 0;for(var e=0;e<i.length;e++)if(i[e]===t)return 1;return i.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 r={};for(var o in t){var a=t[o];Object.prototype.hasOwnProperty.call(t,o)&&null!=o&&null!=a&&(r[o]=e(a,n+1))}return r}(t)}function E(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){return function(t,e){t.length>e&&(t=t.substr(0,e)+"...");return t}((t.textContent||t.innerText||t.value||"").trim(),300)}function R(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 O(t){var e=r(t),n=r(document.URL);return!e.host||e.protocol?e.pathname:e.protocol===n.protocol&&e.host===n.host?e.pathname:"".concat(e.protocol,"://").concat(e.host).concat(e.pathname)}var T,N,H,L,C,A,t=(A=C=!(L={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:H="2.1.0-beta.2",language:"javascript"}),function(t){var u=A,e=[],s=[],f={context:{},beforeNotifyHandlers:[],breadcrumbs:[],errorsSent:0};if("object"===j(t))for(var n in t)f[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 d(){if(l("debug"))return i.apply(this,arguments)}function l(t,e){var n=f[t];return void 0===n&&(n=f[t.toLowerCase()]),"false"===n&&(n=!1),void 0!==n?n:e}function p(){return!u&&l("onerror",!0)}function m(){return l("breadcrumbsEnabled",!1)}function r(t,e){try{var n=new XMLHttpRequest;n.open("POST","http"+(l("ssl",!0)?"s":"")+"://"+l("host","api.honeybadger.io")+"/v1/notices/js",l("async",!0)),n.setRequestHeader("X-API-Key",t),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Accept","text/json, application/json"),n.send(JSON.stringify(x(e,l("max_depth",8))))}catch(t){i("Unable to send error report: error while initializing request",t,e)}}function h(t){if(T=N=null,l("disabled",!1))return d("Dropping notice: honeybadger.js is disabled",t),!1;var e=l("apiKey",l("api_key"));return e?function(){var t=l("maxErrors");return t&&f.errorsSent>=t}()?(d("Dropping notice: max errors exceeded",t),!1):(f.errorsSent++,r(e,t),!0):(i("Unable to send error report: no API key has been configured"),!1)}function y(t,e){if(t=t||{},"[object Error]"===Object.prototype.toString.call(t)){var n=t;t=P(t,{name:n.name,message:n.message,stack:B(n)})}if("object"!==j(t)){var r=String(t);t={message:r}}if(I(t))return!1;if(N&&C&&h(N),function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return 0;return 1}(t))return!1;var o;e&&(t.stack=e.stack,o=e.generator),t=P(t,{name:t.name||"Error",context:P(f.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")}),f.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:t.message,name:t.name,stack:t.stack}}),t.breadcrumbs=f.breadcrumbs.slice();var a=t.stack;if(function(t,e){var n,r;for(n=0,r=t.length;n<r;n++)if(!1===(0,t[n])(e))return 1;return 0}(f.beforeNotifyHandlers,t))return!1;if(t.stack!=a&&(o=void 0),function(t,e){var n=t.message;for(var r in e)if(n.match(e[r]))return 1;return 0}(t,l("ignorePatterns")))return!1;var c=function(){var t={};return t.HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(t.HTTP_REFERER=document.referrer),t}();"string"==typeof t.cookies?c.HTTP_COOKIE=t.cookies:"object"===j(t.cookies)&&(c.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));var i={notifier:L,breadcrumbs:{enabled:m(),trail:t.breadcrumbs},error:{class:t.name,message:t.message,backtrace:t.stack,generator:o,fingerprint:t.fingerprint},request:{url:t.url,component:t.component,action:t.action,context:t.context,cgi_data:c,params:t.params},server:{project_root:t.projectRoot,environment_name:t.environment,revision:t.revision}};return N=i,T=t,C?(d("Deferring notice",t,i),window.setTimeout(function(){I(t)&&h(i)})):(d("Queuing notice",t,i),s.push(i)),t}var o=!0;if(window.atob||(o=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(o=!1)}catch(t){}function c(n,r){r=r||{};try{return"function"!=typeof n?n:function(t){return"function"!=typeof Object.isExtensible||Object.isExtensible(t)}(n)?(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 f.addBreadcrumb(r.component?"".concat(r.component,": ").concat(t.name):t.name,{category:"error",metadata:{message:t.message,name:t.name,stack:e.stack}}),y(t,e),t}}),n.___hb.___hb=n.___hb,n.___hb):n}catch(t){return n}}f.notify=function(t,e,n){if(t=t||{},"[object Error]"===Object.prototype.toString.call(t)){var r=t;t=P(t,{name:r.name,message:r.message,stack:B(r)})}return"object"!==j(t)&&(t={message:String(t)}),e&&"object"!==j(e)&&(e={name:String(e)}),e&&(t=q(t,e)),"object"===j(n)&&(t=q(t,n)),y(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))},f.wrap=function(t){return c(t,{force:!0})},f.setContext=function(t){return"object"===j(t)&&(f.context=P(f.context,t)),f},f.resetContext=function(t){return"object"===j(t)?f.context=P({},t):f.context={},f},f.configure=function(t){for(var e in t)f[e]=t[e];return f},f.beforeNotify=function(t){return f.beforeNotifyHandlers.push(t),f};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(!u&&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,f.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=c(t,o),r(function(){t.apply(null,n)},e)}}}for(var n in f.reset=function(){for(var t in f.context={},f.beforeNotifyHandlers=[],f.breadcrumbs=[],f)-1==g.call(e,t)&&(f[t]=void 0);return f.resetMaxErrors(),f},f.resetMaxErrors=function(){return f.errorsSent=0},f.getVersion=function(){return H},f.addBreadcrumb=function(t,e){if(m()){var n=(e=e||{}).metadata||void 0,r=e.category||"custom",o=(new Date).toISOString();f.breadcrumbs.push({category:r,message:t,metadata:n||{},timestamp:o});var a=l("maxBreadcrumbs",40);return f.breadcrumbs.length>a&&(f.breadcrumbs=f.breadcrumbs.slice(f.breadcrumbs.length-a)),f}},window.addEventListener("click",function(t){var e,n,r;try{e=E(t.target),n=function t(e){var n=E(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&&f.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(O(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),f.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(R(window.fetch))return!0;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&R(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(O(t)),o={type:"fetch",method:n,url:t};return a.apply(this,arguments).then(function(t){return o.status_code=t.status,f.addBreadcrumb(r,{category:"request",metadata:o}),t}).catch(function(t){throw f.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(o){v(window.console,o,function(r){return function(){var t=Array.prototype.slice.call(arguments),e=function(t){return Array.isArray(t)?t.map(function(t){try{return String(t)}catch(t){return"[unknown]"}}).join(" "):""}(t),n={category:"log",metadata:{level:o,arguments:x(t,3)}};f.addBreadcrumb(e,n),"function"==typeof r&&Function.prototype.apply.call(r,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=c(e.handleEvent,a))}catch(t){i(t)}return o.call(this,t,c(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,c(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),!T&&p())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},f.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}}),y(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),!T&&!u&&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 f.addBreadcrumb("window.onunhandledrejection: ".concat(c.name),{category:"error",metadata:c}),void y(c)}var i="string"==typeof e?e:JSON.stringify(e);y({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: ".concat(i)})}}return function(t){n(t),"function"==typeof e&&e.apply(this,arguments)}}),A=!0,f)e.push(n);if(d("Initializing honeybadger.js "+H),/complete|interactive|loaded/.test(document.readyState))C=!0,d("honeybadger.js "+H+" ready");else{d("Installing ready handler");var k=function(){var t;for(C=!0,d("honeybadger.js "+H+" ready");t=s.pop();)h(t)};document.addEventListener?document.addEventListener("DOMContentLoaded",k,!0):window.attachEvent("onload",k)}return f});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 q(t,e){var n=P(t,e);return t.context&&e.context&&(n.context=P(t.context,e.context)),n}function I(t){return!!T&&(T.name===t.name&&(T.message===t.message&&T.stack===t.stack))}function B(t){return t.stacktrace||t.stack||void 0}var e=t();return e.factory=t,e}); | ||
//# sourceMappingURL=honeybadger.min.js.map |
{ | ||
"name": "honeybadger-js", | ||
"description": "A JavaScript library for integrating apps with the Honeybadger Rails Error Notifier.", | ||
"version": "2.1.0-beta.1", | ||
"version": "2.1.0-beta.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/honeybadger-io/honeybadger-js", |
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
254784
3171