honeybadger-js
Advanced tools
Comparing version 2.1.0-beta.4 to 2.1.0
@@ -8,23 +8,19 @@ # Change Log | ||
## [2.1.0-beta.4] - 2020-01-27 | ||
### Fixed | ||
- Fix TypeScript type definitions | ||
- Fix local pathname bug in XHR breadcrumbs | ||
## [2.1.0] - 2020-01-28 | ||
### Added | ||
- Add Breadcrumbs (#210). See [the | ||
docs](https://docs.honeybadger.io/lib/javascript/guides/breadcrumbs.html) for | ||
more info. | ||
## [2.1.0-beta.3] - 2019-12-18 | ||
### Fixed | ||
- Fix an error that occurs when a null error is passed with arguments and ignore patterns. -@littleredninja (#266, #270) | ||
## [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 | ||
## [2.0.2] - 2020-01-08 | ||
### Fixed | ||
- Fix TypeScript type definitions | ||
## [2.1.0-beta.0] - 2019-11-13 | ||
### Added | ||
- Add Breadcrumbs (#210). See [the | ||
docs](https://docs.honeybadger.io/lib/javascript/guides/breadcrumbs.html) | ||
for more info. | ||
## [2.0.1] - 2020-01-07 | ||
### Fixed | ||
- Fix an error that occurs when a null error is passed with arguments and ignore patterns. -@littleredninja (#266, #270) | ||
@@ -31,0 +27,0 @@ ## [2.0.0] - 2019-07-24 |
@@ -203,3 +203,3 @@ 'use strict'; | ||
function builder() { | ||
var VERSION = '2.1.0-beta.4', | ||
var VERSION = '2.1.0', | ||
NOTIFIER = { | ||
@@ -206,0 +206,0 @@ name: 'honeybadger-js', |
@@ -201,3 +201,3 @@ function sanitize(obj, maxDepth) { | ||
function builder() { | ||
var VERSION = '2.1.0-beta.4', | ||
var VERSION = '2.1.0', | ||
NOTIFIER = { | ||
@@ -204,0 +204,0 @@ name: 'honeybadger-js', |
@@ -246,3 +246,3 @@ (function (global, factory) { | ||
function builder() { | ||
var VERSION = '2.1.0-beta.4', | ||
var VERSION = '2.1.0', | ||
NOTIFIER = { | ||
@@ -249,0 +249,0 @@ name: 'honeybadger-js', |
@@ -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 x(t,i){var u=[];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<u.length;e++)if(u[e]===t)return 1;return u.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 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.protocol===n.protocol&&e.host===n.host?e.pathname:"".concat(e.protocol,"://").concat(e.host).concat(e.pathname):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.4",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,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)&&(t=P(t,{name:t.name,message:t.message,stack:B(t)})),"object"!==j(t)){var n=String(t);t={message:n}}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 r;e&&(t.stack=e.stack,r=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 o=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!=o&&(r=void 0),function(t,e){var n=t.message;if(!n)return 0;for(var r in e)if(n.match(e[r]))return 1;return 0}(t,l("ignorePatterns")))return!1;var a,c=((a={}).HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(a.HTTP_REFERER=document.referrer),a);"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:r,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:(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 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){return t=t||{},"[object Error]"===Object.prototype.toString.call(t)&&(t=P(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=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(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:x(e,3)}};f.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=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}); | ||
!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,i){var u=[];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<u.length;e++)if(u[e]===t)return 1;return u.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 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.protocol===n.protocol&&e.host===n.host?e.pathname:"".concat(e.protocol,"://").concat(e.host).concat(e.pathname):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",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,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)&&(t=P(t,{name:t.name,message:t.message,stack:B(t)})),"object"!==j(t)){var n=String(t);t={message:n}}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 r;e&&(t.stack=e.stack,r=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 o=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!=o&&(r=void 0),function(t,e){var n=t.message;if(!n)return 0;for(var r in e)if(n.match(e[r]))return 1;return 0}(t,l("ignorePatterns")))return!1;var a,c=((a={}).HTTP_USER_AGENT=navigator.userAgent,document.referrer.match(/\S/)&&(a.HTTP_REFERER=document.referrer),a);"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:r,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:(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 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){return t=t||{},"[object Error]"===Object.prototype.toString.call(t)&&(t=P(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=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(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:x(e,3)}};f.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=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 2.1.0 ready");else{d("Installing ready handler");var k=function(){var t;for(C=!0,d("honeybadger.js 2.1.0 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.4", | ||
"version": "2.1.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/honeybadger-io/honeybadger-js", |
# Honeybadger Client-Side Javascript Library | ||
[![CircleCI](https://circleci.com/gh/honeybadger-io/honeybadger-js.svg?style=svg)](https://circleci.com/gh/honeybadger-io/honeybadger-js) | ||
![Node CI](https://github.com/honeybadger-io/honeybadger-js/workflows/Node%20CI/badge.svg) | ||
[![npm version](https://badge.fury.io/js/honeybadger-js.svg)](https://badge.fury.io/js/honeybadger-js) | ||
@@ -5,0 +5,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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
255193