Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

honeybadger-js

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

honeybadger-js - npm Package Compare versions

Comparing version 2.3.0-beta.0 to 2.3.0-beta.1

4

CHANGELOG.md

@@ -8,2 +8,6 @@ # Change Log

## [2.3.0-beta.1] - 2020-08-20
### Fixed
- Add `referrer` and `userAgent` to notice object to support filtering
## [2.3.0-beta.0] - 2020-07-28

@@ -10,0 +14,0 @@ ### Added

19

dist/honeybadger.cjs.js

@@ -205,3 +205,3 @@ 'use strict';

function builder() {
var VERSION = '2.3.0-beta.0',
var VERSION = '2.3.0-beta.1',
NOTIFIER = {

@@ -261,11 +261,2 @@ name: 'honeybadger-js',

function cgiData() {
var data = {};
data['HTTP_USER_AGENT'] = navigator.userAgent;
if (document.referrer.match(/\S/)) {
data['HTTP_REFERER'] = document.referrer;
}
return data;
}
function encodeCookie(object) {

@@ -474,3 +465,5 @@ if (typeof object !== 'object') {

function buildPayload(err) {
let data = cgiData();
const data = {};
if (err.userAgent) { data['HTTP_USER_AGENT'] = err.userAgent; }
if (err.referrer) { data['HTTP_REFERER'] = err.referrer; }
if (typeof err.cookies === 'string') {

@@ -548,3 +541,5 @@ data['HTTP_COOKIE'] = err.cookies;

action: err.action || config('action'),
revision: err.revision || config('revision')
revision: err.revision || config('revision'),
userAgent: err.userAgent || navigator.userAgent,
referrer: err.referrer || document.referrer
});

@@ -551,0 +546,0 @@

@@ -203,3 +203,3 @@ function sanitize(obj, maxDepth) {

function builder() {
var VERSION = '2.3.0-beta.0',
var VERSION = '2.3.0-beta.1',
NOTIFIER = {

@@ -259,11 +259,2 @@ name: 'honeybadger-js',

function cgiData() {
var data = {};
data['HTTP_USER_AGENT'] = navigator.userAgent;
if (document.referrer.match(/\S/)) {
data['HTTP_REFERER'] = document.referrer;
}
return data;
}
function encodeCookie(object) {

@@ -472,3 +463,5 @@ if (typeof object !== 'object') {

function buildPayload(err) {
let data = cgiData();
const data = {};
if (err.userAgent) { data['HTTP_USER_AGENT'] = err.userAgent; }
if (err.referrer) { data['HTTP_REFERER'] = err.referrer; }
if (typeof err.cookies === 'string') {

@@ -546,3 +539,5 @@ data['HTTP_COOKIE'] = err.cookies;

action: err.action || config('action'),
revision: err.revision || config('revision')
revision: err.revision || config('revision'),
userAgent: err.userAgent || navigator.userAgent,
referrer: err.referrer || document.referrer
});

@@ -549,0 +544,0 @@

@@ -254,3 +254,3 @@ (function (global, factory) {

function builder() {
var VERSION = '2.3.0-beta.0',
var VERSION = '2.3.0-beta.1',
NOTIFIER = {

@@ -338,13 +338,2 @@ name: 'honeybadger-js',

function cgiData() {
var data = {};
data['HTTP_USER_AGENT'] = navigator.userAgent;
if (document.referrer.match(/\S/)) {
data['HTTP_REFERER'] = document.referrer;
}
return data;
}
function encodeCookie(object) {

@@ -600,4 +589,12 @@ if (_typeof(object) !== 'object') {

function buildPayload(err) {
var data = cgiData();
var data = {};
if (err.userAgent) {
data['HTTP_USER_AGENT'] = err.userAgent;
}
if (err.referrer) {
data['HTTP_REFERER'] = err.referrer;
}
if (typeof err.cookies === 'string') {

@@ -686,3 +683,5 @@ data['HTTP_COOKIE'] = err.cookies;

action: err.action || config('action'),
revision: err.revision || config('revision')
revision: err.revision || config('revision'),
userAgent: err.userAgent || navigator.userAgent,
referrer: err.referrer || document.referrer
});

@@ -689,0 +688,0 @@ self.addBreadcrumb('Honeybadger Notice', {

@@ -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 k(t){return(k="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(k(r=t))||null===r||"object"===k(r)&&void 0===r.hasOwnProperty)return Object.prototype.toString.call(t);var r;if(function(t){if(!t||"object"!==k(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"!==k(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 j(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 x(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 S(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 N(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,R,O,H,L,A,t=(L=H=!(O={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:R="2.3.0-beta.0",language:"javascript"}),A=0,function(t){var n=1===(A+=1),s=!n,e=[],i=[],u={context:{},beforeNotifyHandlers:[],afterNotifyHandlers:[],breadcrumbs:[],errorsSent:0,breadcrumbsEnabled:{dom:!0,network:!0,navigation:!0,console:!0}};if("object"===k(t))for(var r in t)u[r]=t[r];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(t){return!0===u.breadcrumbsEnabled||(t?!0===u.breadcrumbsEnabled[t]:!1!==u.breadcrumbsEnabled)}function o(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"===k(t.cookies)&&(e.HTTP_COOKIE=function(t){if("object"===k(t)){var e=[];for(var n in t)e.push(n+"="+t[n]);return e.join(";")}}(t.cookies)),{notifier:O,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(T=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++,o(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"!==k(t)){var n=String(t);t={message:n}}if(q(t))return!1;if(T&&H&&m(T),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,T=t,H?(d("Deferring notice",t),window.setTimeout(function(){q(t)&&m(t)})):(d("Queuing notice",t),i.push(t)),t))}var a=!0;if(window.atob||(a=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(a=!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(!(a&&(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"!==k(t)&&(t={message:String(t)}),e&&"object"!==k(e)&&(e={name:String(e)}),e&&(t=P(t,e)),"object"===k(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"===k(t)&&(u.context=C(u.context,t)),u},u.resetContext=function(t){return"object"===k(t)?u.context=C({},t):u.context={},u},u.configure=function(t){for(var e in t)u[e]=t[e];return n&&!L&&(L=!0,b.forEach(function(t){return t()})),u},u.beforeNotify=function(t){return u.beforeNotifyHandlers.push(t),u},u.afterNotify=function(t){return u.afterNotifyHandlers.push(t),u};var 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};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 R},u.addBreadcrumb=function(t,e){if(c()){var n=function(t){if("object"!==k(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}};var b=[];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 w(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 r in b.push(function(){c("dom")&&window.addEventListener("click",function(t){var e,n,r;try{e=j(t.target),n=function t(e){var n=j(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=x(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)}),b.push(function(){c("network")&&(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(N(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)}}))}),b.push(function(){c("network")&&(!function(){if(!window.fetch)return 0;if(S(window.fetch))return 1;try{var t=document.createElement("iframe");t.style.display="none",document.head.appendChild(t);var e=t.contentWindow.fetch&&S(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 0}()||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(N(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})}}))}),b.push(function(){if(c("navigation")){var n=window.location.href;v(window,"onpopstate",function(t){return function(){if(r(n,window.location.href),t)return t.apply(this,arguments)}}),v(window.history,"pushState",t),v(window.history,"replaceState",t)}function r(t,e){n=e,u.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)}}}),b.push(function(){c("console")&&["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",w({component:"setTimeout"})),v(window,"setInterval",w({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),!T&&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),!T&&!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)}}),u)e.push(r);if(d("Initializing honeybadger.js "+R),/complete|interactive|loaded/.test(document.readyState))H=!0,d("honeybadger.js "+R+" ready");else{d("Installing ready handler");var _=function(){var t;for(H=!0,d("honeybadger.js "+R+" ready");t=i.pop();)m(t)};document.addEventListener?document.addEventListener("DOMContentLoaded",_,!0):window.attachEvent("onload",_)}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!!T&&(T.name===t.name&&(T.message===t.message&&T.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(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Honeybadger=t()}(this,function(){"use strict";function k(e){return(k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function E(e,i){var s=[];return function t(e,n){if(i<=(n=n||0))return"[DEPTH]";if(/function|symbol/.test(k(r=e))||null===r||"object"===k(r)&&void 0===r.hasOwnProperty)return Object.prototype.toString.call(e);var r;if(function(e){if(!e||"object"!==k(e))return 0;for(var t=0;t<s.length;t++)if(s[t]===e)return 1;return s.push(e),0}(e))return"[RECURSION]";if(Array.isArray(e))return e.map(function(e){return t(e,n+1)});if("object"!==k(e))return e;var o={};for(var a in e){var c=e[a];Object.prototype.hasOwnProperty.call(e,a)&&null!=a&&null!=c&&(o[a]=t(c,n+1))}return o}(e)}function j(n){if(!n||!n.tagName)return"";var r=n.tagName.toLowerCase();if("html"===r)return"";n.id&&(r+="#".concat(n.id));var e=n.getAttribute("class");e&&e.split(/\s+/).forEach(function(e){r+=".".concat(e)}),["alt","name","title","type"].forEach(function(e){var t=n.getAttribute(e);t&&(r+="[".concat(e,'="').concat(t,'"]'))});var t=function(t){try{var e=t.parentNode.childNodes,n=[];return Array.prototype.forEach.call(e,function(e){e.tagName&&e.tagName===t.tagName&&n.push(e)}),n}catch(e){return[]}}(n);return 1<t.length&&(r+=":nth-child(".concat(Array.prototype.indexOf.call(t,n)+1,")")),r}function x(e){var t=e.textContent||e.innerText||"";return t||"submit"!==e.type&&"button"!==e.type||(t=e.value),function(e,t){e.length>t&&(e=e.substr(0,t)+"...");return e}(t.trim(),300)}function S(e){return-1!==e.toString().indexOf("native")}function r(e){var t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/)||{};return{protocol:t[2],host:t[4],pathname:t[5]}}function N(e){var t=r(e),n=r(document.URL);return t.host&&t.protocol?t.protocol===n.protocol&&t.host===n.host?t.pathname:"".concat(t.protocol,"://").concat(t.host).concat(t.pathname):t.pathname}var T,R,O,H,A,L,e=(A=H=!(O={name:"honeybadger-js",url:"https://github.com/honeybadger-io/honeybadger-js",version:R="2.3.0-beta.1",language:"javascript"}),L=0,function(e){var n=1===(L+=1),s=!n,t=[],i=[],u={context:{},beforeNotifyHandlers:[],afterNotifyHandlers:[],breadcrumbs:[],errorsSent:0,breadcrumbsEnabled:{dom:!0,network:!0,navigation:!0,console:!0}};if("object"===k(e))for(var r in e)u[r]=e[r];function f(){var e=window.console;if(e){var t=Array.prototype.slice.call(arguments);t.unshift("[Honeybadger]"),e.log.apply(e,t)}}function d(){if(l("debug"))return f.apply(this,arguments)}function l(e,t){var n=u[e];return void 0===n&&(n=u[e.toLowerCase()]),"false"===n&&(n=!1),void 0!==n?n:t}function p(){return!s&&l("onerror",!0)}function c(e){return!0===u.breadcrumbsEnabled||(e?!0===u.breadcrumbsEnabled[e]:!1!==u.breadcrumbsEnabled)}function o(e,t){try{var n=function(e){var t={};return e.userAgent&&(t.HTTP_USER_AGENT=e.userAgent),e.referrer&&(t.HTTP_REFERER=e.referrer),"string"==typeof e.cookies?t.HTTP_COOKIE=e.cookies:"object"===k(e.cookies)&&(t.HTTP_COOKIE=function(e){if("object"===k(e)){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join(";")}}(e.cookies)),{notifier:O,breadcrumbs:{enabled:c(),trail:e.breadcrumbs},error:{class:e.name,message:e.message,backtrace:e.stack,generator:e.generator,fingerprint:e.fingerprint},request:{url:e.url,component:e.component,action:e.action,context:e.context,cgi_data:t,params:e.params},server:{project_root:e.projectRoot,environment_name:e.environment,revision:e.revision}}}(t),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",e),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 e=Array.prototype.slice.call(u.afterNotifyHandlers);if(t.afterNotify&&e.unshift(t.afterNotify),201!==r.status)return I(e,new Error("Bad HTTP response: ".concat(r.status)),t),void d("Unable to send error report: ".concat(r.status,": ").concat(r.statusText),r,t);I(e,void 0,C(t,{id:JSON.parse(r.response).id})),d("Error report sent",n)}}catch(e){I(u.afterNotifyHandlers,e,t),f("Unable to send error report: error while initializing request",e,t)}}function m(e){if(T=null,l("disabled",!1))return d("Dropping notice: honeybadger.js is disabled",e),!1;var t,n=l("apiKey",l("api_key"));return n?(t=l("maxErrors"))&&u.errorsSent>=t?(d("Dropping notice: max errors exceeded",e),!1):(u.errorsSent++,o(n,e),!0):(f("Unable to send error report: no API key has been configured"),!1)}function h(e,t){if(e=e||{},"[object Error]"===Object.prototype.toString.call(e)&&(e=C(e,{name:e.name,message:e.message,stack:B(e)})),"object"!==k(e)){var n=String(e);e={message:n}}if(q(e))return!1;if(T&&H&&m(T),function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return 0;return 1}(e))return!1;var r;t&&(e.stack=t.stack,r=t.generator),e=C(e,{name:e.name||"Error",context:C(u.context,e.context),url:e.url||document.URL,projectRoot:e.projectRoot||e.project_root||l("projectRoot",l("project_root",window.location.protocol+"//"+window.location.host)),environment:e.environment||l("environment"),component:e.component||l("component"),action:e.action||l("action"),revision:e.revision||l("revision"),userAgent:e.userAgent||navigator.userAgent,referrer:e.referrer||document.referrer}),u.addBreadcrumb("Honeybadger Notice",{category:"notice",metadata:{message:e.message,name:e.name,stack:e.stack}}),e.breadcrumbs=u.breadcrumbs.slice();var o,a,c=e.stack;return!I(u.beforeNotifyHandlers,e)&&(e.stack!=c&&(r=void 0),o=e,a=l("ignorePatterns"),(!Array.isArray(a)||!a.some(function(e){return e.test(o.message)}))&&(e.generator=r,T=e,H?(d("Deferring notice",e),window.setTimeout(function(){q(e)&&m(e)})):(d("Queuing notice",e),i.push(e)),e))}var a=!0;if(window.atob||(a=!1),window.ErrorEvent)try{0===new window.ErrorEvent("").colno&&(a=!1)}catch(e){}function y(n,r){r=r||{};try{return"function"!=typeof n?n:(e=n,"function"!=typeof Object.isExtensible||Object.isExtensible(e)?(n.___hb||(n.___hb=function(){var e=p();if(!(a&&(e||r.force)||r.force&&!e))return n.apply(this,arguments);try{return n.apply(this,arguments)}catch(e){var t={stack:B(e)};throw u.addBreadcrumb(r.component?"".concat(r.component,": ").concat(e.name):e.name,{category:"error",metadata:{message:e.message,name:e.name,stack:t.stack}}),h(e,t),e}}),n.___hb.___hb=n.___hb,n.___hb):n)}catch(e){return n}var e}u.notify=function(e,t,n){return e=e||{},"[object Error]"===Object.prototype.toString.call(e)&&(e=C(e,{name:e.name,message:e.message,stack:B(e)})),"object"!==k(e)&&(e={message:String(e)}),t&&"object"!==k(t)&&(t={name:String(t)}),t&&(e=P(e,t)),"object"===k(n)&&(e=P(e,n)),h(e,function(e){var t;if(e&&(t=B(e)))return{stack:t,generator:void 0};try{throw new Error("")}catch(e){if(t=B(e))return{stack:t,generator:"throw"}}t=["<call-stack>"];for(var n=arguments.callee;n&&t.length<10;){/function(?:\s+([\w$]+))+\s*\(/.test(n.toString())?t.push(RegExp.$1||"<anonymous>"):t.push("<anonymous>");try{n=n.caller}catch(e){break}}return{stack:t.join("\n"),generator:"walk"}}(e))},u.wrap=function(e){return y(e,{force:!0})},u.setContext=function(e){return"object"===k(e)&&(u.context=C(u.context,e)),u},u.resetContext=function(e){return"object"===k(e)?u.context=C({},e):u.context={},u},u.configure=function(e){for(var t in e)u[t]=e[t];return n&&!A&&(A=!0,b.forEach(function(e){return e()})),u},u.beforeNotify=function(e){return u.beforeNotifyHandlers.push(e),u},u.afterNotify=function(e){return u.afterNotifyHandlers.push(e),u};var g=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1};u.reset=function(){for(var e in u.context={},u.beforeNotifyHandlers=[],u.breadcrumbs=[],u)-1==g.call(t,e)&&(u[e]=void 0);return u.resetMaxErrors(),u},u.resetMaxErrors=function(){return u.errorsSent=0},u.getVersion=function(){return R},u.addBreadcrumb=function(e,t){if(c()){var n=function(e){if("object"!==k(e))return{};var t={};for(var n in e)t[n]=e[n];return t}((t=t||{}).metadata),r=t.category||"custom",o=(new Date).toISOString();u.breadcrumbs.push({category:r,message:e,metadata:n,timestamp:o});var a=l("maxBreadcrumbs",40);return u.breadcrumbs.length>a&&(u.breadcrumbs=u.breadcrumbs.slice(u.breadcrumbs.length-a)),u}};var b=[];function v(e,t,n){if(!s&&e&&t&&n&&t in e){for(var r=e[t];r&&r.__hb_original;)r=r.__hb_original;e[t]=n(r),e[t].__hb_original=r}}function w(o){return function(r){return function(e,t){if("function"!=typeof e)return r(e,t);var n=Array.prototype.slice.call(arguments,2);return e=y(e,o),r(function(){e.apply(null,n)},t)}}}for(var r in b.push(function(){c("dom")&&window.addEventListener("click",function(e){var t,n,r;try{t=j(e.target),n=function e(t){var n=j(t);if(t.parentNode&&t.parentNode.tagName){var r=e(t.parentNode);if(0<r.length)return"".concat(r," > ").concat(n)}return n}(e.target),r=x(e.target)}catch(e){t="UI Click",r=n="[unknown]"}0!==t.length&&u.addBreadcrumb(t,{category:"ui.click",metadata:{selector:n,text:r,event:e}})},!0)}),b.push(function(){c("network")&&(v(XMLHttpRequest.prototype,"open",function(r){return function(){var e=arguments[1],t="string"==typeof arguments[0]?arguments[0].toUpperCase():arguments[0],n="".concat(t," ").concat(N(e));this.__hb_xhr={type:"xhr",method:t,url:e,message:n},"function"==typeof r&&r.apply(this,arguments)}}),v(XMLHttpRequest.prototype,"send",function(e){return function(){var t=this;function n(){var e;4===t.readyState&&(t.__hb_xhr&&(t.__hb_xhr.status_code=t.status,e=t.__hb_xhr.message,delete t.__hb_xhr.message),u.addBreadcrumb(e||"XMLHttpRequest",{category:"request",metadata:t.__hb_xhr}))}"onreadystatechange"in t&&"function"==typeof t.onreadystatechange?v(t,"onreadystatechange",function(e){return function(){n(),"function"==typeof e&&e.apply(this,arguments)}}):t.onreadystatechange=n,"function"==typeof e&&e.apply(t,arguments)}}))}),b.push(function(){c("network")&&(!function(){if(!window.fetch)return 0;if(S(window.fetch))return 1;try{var e=document.createElement("iframe");e.style.display="none",document.head.appendChild(e);var t=e.contentWindow.fetch&&S(e.contentWindow.fetch);return document.head.removeChild(e),t}catch(e){console&&console.warn&&console.warn("failed to detect native fetch via iframe: "+e)}return 0}()||v(window,"fetch",function(a){return function(){var e,t=arguments[0],n="GET";"string"==typeof t?e=t:"Request"in window&&t instanceof Request?(e=t.url,t.method&&(n=t.method)):e=String(t),arguments[1]&&arguments[1].method&&(n=arguments[1].method),"string"==typeof n&&(n=n.toUpperCase());var r="".concat(n," ").concat(N(e)),o={type:"fetch",method:n,url:e};return a.apply(this,arguments).then(function(e){return o.status_code=e.status,u.addBreadcrumb(r,{category:"request",metadata:o}),e}).catch(function(e){throw u.addBreadcrumb("fetch error",{category:"error",metadata:o}),e})}}))}),b.push(function(){if(c("navigation")){var n=window.location.href;v(window,"onpopstate",function(e){return function(){if(r(n,window.location.href),e)return e.apply(this,arguments)}}),v(window.history,"pushState",e),v(window.history,"replaceState",e)}function r(e,t){n=t,u.addBreadcrumb("Page changed",{category:"navigation",metadata:{from:e,to:t}})}function e(t){return function(){var e=2<arguments.length?arguments[2]:void 0;return e&&r(n,String(e)),t.apply(this,arguments)}}}),b.push(function(){c("console")&&["debug","info","warn","error","log"].forEach(function(a){v(window.console,a,function(o){return function(){var e,t=Array.prototype.slice.call(arguments),n=(e=t,Array.isArray(e)?e.map(function(e){try{return String(e)}catch(e){return"[unknown]"}}).join(" "):""),r={category:"log",metadata:{level:a,arguments:E(t,3)}};u.addBreadcrumb(n,r),"function"==typeof o&&Function.prototype.apply.call(o,window.console,arguments)}})})}),v(window,"setTimeout",w({component:"setTimeout"})),v(window,"setInterval",w({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(e){var t=window[e]&&window[e].prototype;t&&t.hasOwnProperty&&t.hasOwnProperty("addEventListener")&&(v(t,"addEventListener",function(o){var a={component:"".concat(e,".prototype.addEventListener")};return function(e,t,n,r){try{t&&null!=t.handleEvent&&(t.handleEvent=y(t.handleEvent,a))}catch(e){f(e)}return o.call(this,e,y(t,a),n,r)}}),v(t,"removeEventListener",function(o){return function(e,t,n,r){return o.call(this,e,t,n,r),o.call(this,e,y(t),n,r)}}))}),v(window,"onerror",function(a){return function(e,t,n,r,o){return function(e,t,n,r,o){if(d("window.onerror callback invoked",arguments),!T&&p())if(0===n&&/Script error\.?/.test(e))f("Ignoring cross-domain script error: enable CORS to track these types of errors",arguments);else{var a,c=[e,"\n at ? (",t||"unknown",":",n||0,":",r||0,")"].join("");o?(a={stack:B(o)}).stack||(a={stack:c}):o={name:"window.onerror",message:e,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)}}(e,t,n,r,o),!("function"!=typeof a||!l("_onerror_call_orig",!0))&&a.apply(this,arguments)}}),v(window,"onunhandledrejection",function(t){function n(e){if(d("window.onunhandledrejection callback invoked",arguments),!T&&!s&&l("onunhandledrejection",!0)){var t=e.reason;if(t instanceof Error){var n=t.fileName||"unknown",r=t.lineNumber||0,o="".concat(t.message,"\n at ? (").concat(n,":").concat(r,")"),a=B(t)||o,c={name:t.name,message:"UnhandledPromiseRejectionWarning: ".concat(t),stack:a};return u.addBreadcrumb("window.onunhandledrejection: ".concat(c.name),{category:"error",metadata:c}),void h(c)}var i="string"==typeof t?t:JSON.stringify(t);h({name:"window.onunhandledrejection",message:"UnhandledPromiseRejectionWarning: ".concat(i)})}}return function(e){n(e),"function"==typeof t&&t.apply(this,arguments)}}),u)t.push(r);if(d("Initializing honeybadger.js "+R),/complete|interactive|loaded/.test(document.readyState))H=!0,d("honeybadger.js "+R+" ready");else{d("Installing ready handler");var _=function(){var e;for(H=!0,d("honeybadger.js "+R+" ready");e=i.pop();)m(e)};document.addEventListener?document.addEventListener("DOMContentLoaded",_,!0):window.attachEvent("onload",_)}return u});function C(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function P(e,t){var n=C(e,t);return e.context&&t.context&&(n.context=C(e.context,t.context)),n}function q(e){return!!T&&(T.name===e.name&&(T.message===e.message&&T.stack===e.stack))}function B(e){return e.stacktrace||e.stack||void 0}function I(e,t,n){var r,o;for(r=0,o=e.length;r<o;r++)if(!1===(0,e[r])(t,n))return!0;return!1}var t=e();return t.factory=e,t});
//# sourceMappingURL=honeybadger.min.js.map
{
"name": "honeybadger-js",
"description": "A JavaScript library for integrating apps with the Honeybadger Rails Error Notifier.",
"version": "2.3.0-beta.0",
"version": "2.3.0-beta.1",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc