Socket
Socket
Sign inDemoInstall

rollbar

Package Overview
Dependencies
Maintainers
4
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollbar - npm Package Compare versions

Comparing version 2.21.1 to 2.22.0

src/server/telemetry.js

2

dist/rollbar.snippet.js

@@ -1,1 +0,1 @@

!function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){"use strict";var n=o(1),t=o(5);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdn.rollbar.com/rollbarjs/refs/tags/v2.21.1/rollbar.min.js",_rollbarConfig.async=void 0===_rollbarConfig.async||_rollbarConfig.async;var a=n.setupShim(window,_rollbarConfig),l=t(_rollbarConfig);window.rollbar=n.Rollbar,a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,l)},function(r,e,o){"use strict";var n=o(2),t=o(3);function a(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var l=0;function i(r,e){this.options=r,this._rollbarOldOnError=null;var o=l++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var s=o(4),d=function(r,e){return new i(r,e)},c=function(r){return new s(d,r)};function u(r){return a((function(){var e=this,o=Array.prototype.slice.call(arguments,0),n={shim:e,method:r,args:o,ts:new Date};window._rollbarShims[this.shimId()].messages.push(n)}))}i.prototype.loadFull=function(r,e,o,n,t){var l=!1,i=e.createElement("script"),s=e.getElementsByTagName("script")[0],d=s.parentNode;i.crossOrigin="",i.src=n.rollbarJsUrl,o||(i.async=!0),i.onload=i.onreadystatechange=a((function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){i.onload=i.onreadystatechange=null;try{d.removeChild(i)}catch(r){}l=!0,function(){var e;if(void 0===r._rollbarDidLoad){e=new Error("rollbar.js did not load");for(var o,n,a,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(a=n.args||[],i=0;i<a.length;++i)if("function"==typeof(l=a[i])){l(e);break}}"function"==typeof t&&t(e)}()}})),d.insertBefore(i,s)},i.prototype.wrap=function(r,e,o){try{var n;if(n="function"==typeof e?e:function(){return e||{}},"function"!=typeof r)return r;if(r._isWrap)return r;if(!r._rollbar_wrapped&&(r._rollbar_wrapped=function(){o&&"function"==typeof o&&o.apply(this,arguments);try{return r.apply(this,arguments)}catch(o){var e=o;throw e&&("string"==typeof e&&(e=new String(e)),e._rollbarContext=n()||{},e._rollbarContext._wrappedSource=r.toString(),window._rollbarWrappedError=e),e}},r._rollbar_wrapped._isWrap=!0,r.hasOwnProperty))for(var t in r)r.hasOwnProperty(t)&&(r._rollbar_wrapped[t]=r[t]);return r._rollbar_wrapped}catch(e){return r}};for(var p="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),f=0;f<p.length;++f)i.prototype[p[f]]=u(p[f]);r.exports={setupShim:function(r,e){if(r){var o=e.globalAlias||"Rollbar";if("object"==typeof r[o])return r[o];r._rollbarShims={},r._rollbarWrappedError=null;var l=new c(e);return a((function(){e.captureUncaught&&(l._rollbarOldOnError=r.onerror,n.captureUncaughtExceptions(r,l,!0),e.wrapGlobalEventHandlers&&t(r,l,!0)),e.captureUnhandledRejections&&n.captureUnhandledRejections(r,l,!0);var a=e.autoInstrument;return!1!==e.enabled&&(void 0===a||!0===a||"object"==typeof a&&a.network)&&r.addEventListener&&(r.addEventListener("load",l.captureLoad.bind(l)),r.addEventListener("DOMContentLoaded",l.captureDomContentLoaded.bind(l))),r[o]=l,l}))()}},Rollbar:c}},function(r,e,o){"use strict";function n(r,e,o,n){r._rollbarWrappedError&&(n[4]||(n[4]=r._rollbarWrappedError),n[5]||(n[5]=r._rollbarWrappedError._rollbarContext),r._rollbarWrappedError=null);var t=e.handleUncaughtException.apply(e,n);o&&o.apply(r,n),"anonymous"===t&&(e.anonymousErrorsPending+=1)}r.exports={captureUncaughtExceptions:function(r,e,o){if(r){var t;if("function"==typeof e._rollbarOldOnError)t=e._rollbarOldOnError;else if(r.onerror){for(t=r.onerror;t._rollbarOldOnError;)t=t._rollbarOldOnError;e._rollbarOldOnError=t}e.handleAnonymousErrors();var a=function(){var o=Array.prototype.slice.call(arguments,0);n(r,e,t,o)};o&&(a._rollbarOldOnError=t),r.onerror=a}},captureUnhandledRejections:function(r,e,o){if(r){"function"==typeof r._rollbarURH&&r._rollbarURH.belongsToShim&&r.removeEventListener("unhandledrejection",r._rollbarURH);var n=function(r){var o,n,t;try{o=r.reason}catch(r){o=void 0}try{n=r.promise}catch(r){n="[unhandledrejection] error getting `promise` from event"}try{t=r.detail,!o&&t&&(o=t.reason,n=t.promise)}catch(r){}o||(o="[unhandledrejection] error getting `reason` from event"),e&&e.handleUnhandledRejection&&e.handleUnhandledRejection(o,n)};n.belongsToShim=o,r._rollbarURH=n,r.addEventListener("unhandledrejection",n)}}}},function(r,e,o){"use strict";function n(r,e,o){if(e.hasOwnProperty&&e.hasOwnProperty("addEventListener")){for(var n=e.addEventListener;n._rollbarOldAdd&&n.belongsToShim;)n=n._rollbarOldAdd;var t=function(e,o,t){n.call(this,e,r.wrap(o),t)};t._rollbarOldAdd=n,t.belongsToShim=o,e.addEventListener=t;for(var a=e.removeEventListener;a._rollbarOldRemove&&a.belongsToShim;)a=a._rollbarOldRemove;var l=function(r,e,o){a.call(this,r,e&&e._rollbar_wrapped||e,o)};l._rollbarOldRemove=a,l.belongsToShim=o,e.removeEventListener=l}}r.exports=function(r,e,o){if(r){var t,a,l="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".split(",");for(t=0;t<l.length;++t)r[a=l[t]]&&r[a].prototype&&n(e,r[a].prototype,o)}}},function(r,e,o){"use strict";function n(r,e){this.impl=r(e,this),this.options=e,function(r){for(var e=function(r){return function(){var e=Array.prototype.slice.call(arguments,0);if(this.impl[r])return this.impl[r].apply(this.impl,e)}},o="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad".split(","),n=0;n<o.length;n++)r[o[n]]=e(o[n])}(n.prototype)}n.prototype._swapAndProcessMessages=function(r,e){var o,n,t;for(this.impl=r(this.options);o=e.shift();)n=o.method,t=o.args,this[n]&&"function"==typeof this[n]&&("captureDomContentLoaded"===n||"captureLoad"===n?this[n].apply(this,[t[0],o.ts]):this[n].apply(this,t));return this},r.exports=n},function(r,e,o){"use strict";r.exports=function(r){return function(e){if(!e&&!window._rollbarInitialized){for(var o,n,t=(r=r||{}).globalAlias||"Rollbar",a=window.rollbar,l=function(r){return new a(r)},i=0;o=window._rollbarShims[i++];)n||(n=o.handler),o.handler._swapAndProcessMessages(l,o.messages);window[t]=n,window._rollbarInitialized=!0}}}}]);
!function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){"use strict";var n=o(1),t=o(5);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdn.rollbar.com/rollbarjs/refs/tags/v2.22.0/rollbar.min.js",_rollbarConfig.async=void 0===_rollbarConfig.async||_rollbarConfig.async;var a=n.setupShim(window,_rollbarConfig),l=t(_rollbarConfig);window.rollbar=n.Rollbar,a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,l)},function(r,e,o){"use strict";var n=o(2),t=o(3);function a(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var l=0;function i(r,e){this.options=r,this._rollbarOldOnError=null;var o=l++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var s=o(4),d=function(r,e){return new i(r,e)},c=function(r){return new s(d,r)};function u(r){return a((function(){var e=this,o=Array.prototype.slice.call(arguments,0),n={shim:e,method:r,args:o,ts:new Date};window._rollbarShims[this.shimId()].messages.push(n)}))}i.prototype.loadFull=function(r,e,o,n,t){var l=!1,i=e.createElement("script"),s=e.getElementsByTagName("script")[0],d=s.parentNode;i.crossOrigin="",i.src=n.rollbarJsUrl,o||(i.async=!0),i.onload=i.onreadystatechange=a((function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){i.onload=i.onreadystatechange=null;try{d.removeChild(i)}catch(r){}l=!0,function(){var e;if(void 0===r._rollbarDidLoad){e=new Error("rollbar.js did not load");for(var o,n,a,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(a=n.args||[],i=0;i<a.length;++i)if("function"==typeof(l=a[i])){l(e);break}}"function"==typeof t&&t(e)}()}})),d.insertBefore(i,s)},i.prototype.wrap=function(r,e,o){try{var n;if(n="function"==typeof e?e:function(){return e||{}},"function"!=typeof r)return r;if(r._isWrap)return r;if(!r._rollbar_wrapped&&(r._rollbar_wrapped=function(){o&&"function"==typeof o&&o.apply(this,arguments);try{return r.apply(this,arguments)}catch(o){var e=o;throw e&&("string"==typeof e&&(e=new String(e)),e._rollbarContext=n()||{},e._rollbarContext._wrappedSource=r.toString(),window._rollbarWrappedError=e),e}},r._rollbar_wrapped._isWrap=!0,r.hasOwnProperty))for(var t in r)r.hasOwnProperty(t)&&(r._rollbar_wrapped[t]=r[t]);return r._rollbar_wrapped}catch(e){return r}};for(var p="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),f=0;f<p.length;++f)i.prototype[p[f]]=u(p[f]);r.exports={setupShim:function(r,e){if(r){var o=e.globalAlias||"Rollbar";if("object"==typeof r[o])return r[o];r._rollbarShims={},r._rollbarWrappedError=null;var l=new c(e);return a((function(){e.captureUncaught&&(l._rollbarOldOnError=r.onerror,n.captureUncaughtExceptions(r,l,!0),e.wrapGlobalEventHandlers&&t(r,l,!0)),e.captureUnhandledRejections&&n.captureUnhandledRejections(r,l,!0);var a=e.autoInstrument;return!1!==e.enabled&&(void 0===a||!0===a||"object"==typeof a&&a.network)&&r.addEventListener&&(r.addEventListener("load",l.captureLoad.bind(l)),r.addEventListener("DOMContentLoaded",l.captureDomContentLoaded.bind(l))),r[o]=l,l}))()}},Rollbar:c}},function(r,e,o){"use strict";function n(r,e,o,n){r._rollbarWrappedError&&(n[4]||(n[4]=r._rollbarWrappedError),n[5]||(n[5]=r._rollbarWrappedError._rollbarContext),r._rollbarWrappedError=null);var t=e.handleUncaughtException.apply(e,n);o&&o.apply(r,n),"anonymous"===t&&(e.anonymousErrorsPending+=1)}r.exports={captureUncaughtExceptions:function(r,e,o){if(r){var t;if("function"==typeof e._rollbarOldOnError)t=e._rollbarOldOnError;else if(r.onerror){for(t=r.onerror;t._rollbarOldOnError;)t=t._rollbarOldOnError;e._rollbarOldOnError=t}e.handleAnonymousErrors();var a=function(){var o=Array.prototype.slice.call(arguments,0);n(r,e,t,o)};o&&(a._rollbarOldOnError=t),r.onerror=a}},captureUnhandledRejections:function(r,e,o){if(r){"function"==typeof r._rollbarURH&&r._rollbarURH.belongsToShim&&r.removeEventListener("unhandledrejection",r._rollbarURH);var n=function(r){var o,n,t;try{o=r.reason}catch(r){o=void 0}try{n=r.promise}catch(r){n="[unhandledrejection] error getting `promise` from event"}try{t=r.detail,!o&&t&&(o=t.reason,n=t.promise)}catch(r){}o||(o="[unhandledrejection] error getting `reason` from event"),e&&e.handleUnhandledRejection&&e.handleUnhandledRejection(o,n)};n.belongsToShim=o,r._rollbarURH=n,r.addEventListener("unhandledrejection",n)}}}},function(r,e,o){"use strict";function n(r,e,o){if(e.hasOwnProperty&&e.hasOwnProperty("addEventListener")){for(var n=e.addEventListener;n._rollbarOldAdd&&n.belongsToShim;)n=n._rollbarOldAdd;var t=function(e,o,t){n.call(this,e,r.wrap(o),t)};t._rollbarOldAdd=n,t.belongsToShim=o,e.addEventListener=t;for(var a=e.removeEventListener;a._rollbarOldRemove&&a.belongsToShim;)a=a._rollbarOldRemove;var l=function(r,e,o){a.call(this,r,e&&e._rollbar_wrapped||e,o)};l._rollbarOldRemove=a,l.belongsToShim=o,e.removeEventListener=l}}r.exports=function(r,e,o){if(r){var t,a,l="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".split(",");for(t=0;t<l.length;++t)r[a=l[t]]&&r[a].prototype&&n(e,r[a].prototype,o)}}},function(r,e,o){"use strict";function n(r,e){this.impl=r(e,this),this.options=e,function(r){for(var e=function(r){return function(){var e=Array.prototype.slice.call(arguments,0);if(this.impl[r])return this.impl[r].apply(this.impl,e)}},o="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad".split(","),n=0;n<o.length;n++)r[o[n]]=e(o[n])}(n.prototype)}n.prototype._swapAndProcessMessages=function(r,e){var o,n,t;for(this.impl=r(this.options);o=e.shift();)n=o.method,t=o.args,this[n]&&"function"==typeof this[n]&&("captureDomContentLoaded"===n||"captureLoad"===n?this[n].apply(this,[t[0],o.ts]):this[n].apply(this,t));return this},r.exports=n},function(r,e,o){"use strict";r.exports=function(r){return function(e){if(!e&&!window._rollbarInitialized){for(var o,n,t=(r=r||{}).globalAlias||"Rollbar",a=window.rollbar,l=function(r){return new a(r)},i=0;o=window._rollbarShims[i++];)n||(n=o.handler),o.handler._swapAndProcessMessages(l,o.messages);window[t]=n,window._rollbarInitialized=!0}}}}]);

@@ -75,2 +75,3 @@ // Type definitions for rollbar

maxItems?: number;
maxRetries?: number;
maxTelemetryEvents?: number;

@@ -91,2 +92,3 @@ nodeSourceMaps?: boolean;

telemetryScrubber?: TelemetryScrubber;
timeout?: number;
transform?: (data: object) => void;

@@ -122,2 +124,4 @@ transmit?: boolean;

connectivity?: boolean;
contentSecurityPolicy?: boolean;
errorOnContentSecurityPolicy?: boolean;
}

@@ -141,4 +145,9 @@ export type TelemetryScrubber = (description: TelemetryScrubberInput) => boolean;

}
export type LocalsOptions = boolean | LocalsSettings;
class Locals {}
export type LocalsType = typeof Locals;
export type LocalsOptions = LocalsType | LocalsSettings;
export interface LocalsSettings {
locals: LocalsType,
enabled?: boolean;
uncaughtOnly?: boolean;
depth?: number;

@@ -145,0 +154,0 @@ maxProperties?: number;

{
"name": "rollbar",
"version": "2.21.1",
"version": "2.22.0",
"repository": {

@@ -71,2 +71,3 @@ "type": "git",

"natives": "^1.1.6",
"nock": "^11.9.1",
"node-libs-browser": "^0.5.2",

@@ -73,0 +74,0 @@ "request": "^2.88.0",

@@ -27,2 +27,3 @@ var _ = require('./utility');

var search = defaults.search;
var timeout = options.timeout;

@@ -39,2 +40,3 @@ var proxy = options.proxy;

return {
timeout: timeout,
hostname: hostname,

@@ -54,2 +56,3 @@ protocol: protocol,

var path = transport.path;
var timeout = transport.timeout;
if (transport.search) {

@@ -65,2 +68,3 @@ path = path + transport.search;

return {
timeout: timeout,
protocol: protocol,

@@ -67,0 +71,0 @@ hostname: hostname,

@@ -35,3 +35,3 @@ /*global XDomainRequest*/

var url = _.formatUrl(options);
_makeZoneRequest(accessToken, url, method, null, callback, requestFactory);
_makeZoneRequest(accessToken, url, method, null, callback, requestFactory, options.timeout);
}

@@ -61,3 +61,3 @@

var url = _.formatUrl(options);
_makeZoneRequest(accessToken, url, method, writeData, callback, requestFactory);
_makeZoneRequest(accessToken, url, method, writeData, callback, requestFactory, options.timeout);
}

@@ -72,5 +72,6 @@

var url = _.formatUrl(options);
_makeZoneRequest(accessToken, url, method, jsonPayload, callback, requestFactory);
_makeZoneRequest(accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout);
}
// Wraps _makeRequest and if Angular 2+ Zone.js is detected, changes scope

@@ -80,5 +81,6 @@ // so Angular change detection isn't triggered on each API call.

//
function _makeZoneRequest(accessToken, url, method, data, callback, requestFactory) {
function _makeZoneRequest() {
var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
var currentZone = gWindow && gWindow.Zone && gWindow.Zone.current;
var args = Array.prototype.slice.call(arguments);

@@ -88,6 +90,6 @@ if (currentZone && currentZone._name === 'angular') {

rootZone.run(function () {
_makeRequest(accessToken, url, method, data, callback, requestFactory);
_makeRequest.apply(undefined, args);
});
} else {
_makeRequest(accessToken, url, method, data, callback, requestFactory);
_makeRequest.apply(undefined, args);
}

@@ -108,3 +110,3 @@ }

function _makeRequest(accessToken, url, method, data, callback, requestFactory) {
function _makeRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
if (typeof RollbarProxy !== 'undefined') {

@@ -170,2 +172,7 @@ return _proxyRequest(data, callback);

}
if(_.isFiniteNumber(timeout)) {
request.timeout = timeout;
}
request.onreadystatechange = onreadystatechange;

@@ -172,0 +179,0 @@ request.send(data);

module.exports = {
version: '2.21.1',
version: '2.22.0',
endpoint: 'api.rollbar.com/api/1/item/',

@@ -4,0 +4,0 @@ logLevel: 'debug',

@@ -125,5 +125,3 @@ var _ = require('./utility');

return function(item, settings) {
var exceptionMessage, i, ignoredMessages,
len, messageIsIgnored, rIgnoredMessage,
body, traceMessage, bodyMessage;
var i, j, ignoredMessages, len, messageIsIgnored, rIgnoredMessage, messages;

@@ -138,9 +136,5 @@ try {

body = item.body;
traceMessage = _.get(body, 'trace.exception.message');
bodyMessage = _.get(body, 'message.body');
messages = messagesFromItem(item);
exceptionMessage = traceMessage || bodyMessage;
if (!exceptionMessage){
if (messages.length === 0){
return true;

@@ -152,6 +146,9 @@ }

rIgnoredMessage = new RegExp(ignoredMessages[i], 'gi');
messageIsIgnored = rIgnoredMessage.test(exceptionMessage);
if (messageIsIgnored) {
break;
for (j = 0; j < messages.length; j++) {
messageIsIgnored = rIgnoredMessage.test(messages[j]);
if (messageIsIgnored) {
return false;
}
}

@@ -166,6 +163,29 @@ }

return !messageIsIgnored;
return true;
}
}
function messagesFromItem(item) {
var body = item.body;
var messages = [];
// The payload schema only allows one of trace_chain, message, or trace.
// However, existing test cases are based on having both trace and message present.
// So here we preserve the ability to collect strings from any combination of these keys.
if (body.trace_chain) {
var traceChain = body.trace_chain;
for (var i = 0; i < traceChain.length; i++) {
var trace = traceChain[i];
messages.push(_.get(trace, 'exception.message'));
}
}
if (body.trace) {
messages.push(_.get(body, 'trace.exception.message'));
}
if (body.message) {
messages.push(_.get(body, 'message.body'));
}
return messages;
}
module.exports = {

@@ -172,0 +192,0 @@ checkLevel: checkLevel,

@@ -191,2 +191,8 @@ var _ = require('./utility');

}
if (shouldRetry && _.isFiniteNumber(this.options.maxRetries)) {
item.retries = item.retries ? item.retries + 1 : 1;
if (item.retries > this.options.maxRetries) {
shouldRetry = false;
}
}
}

@@ -193,0 +199,0 @@ if (shouldRetry) {

@@ -87,3 +87,2 @@ /* globals Map */

var state = pauseStateFromOptions(options);
console.log('setPauseOnExceptions', state);
Locals.session.post('Debugger.setPauseOnExceptions', { state: state}, (err, _result) => {

@@ -90,0 +89,0 @@ if (err) {

@@ -15,2 +15,3 @@ var util = require('util');

var Telemeter = require('../telemetry');
var Instrumenter = require('./telemetry');
var transforms = require('./transforms');

@@ -44,2 +45,4 @@ var sharedTransforms = require('../transforms');

this.client = client || new Client(this.options, api, logger, telemeter, 'server');
this.instrumenter = new Instrumenter(this.options, this.client.telemeter, this);
this.instrumenter.instrument();
if (this.options.locals) {

@@ -675,5 +678,6 @@ this.locals = initLocals(this.options.locals, logger);

ignoreDuplicateErrors: true,
scrubRequestBody: true
scrubRequestBody: true,
autoInstrument: false
};
module.exports = Rollbar;

@@ -113,2 +113,12 @@ var merge = require('./merge');

/**
* isFiniteNumber - determines whether the passed value is a finite number
*
* @param {*} n - any value
* @returns true if value is a finite number
*/
function isFiniteNumber(n) {
return Number.isFinite(n);
}
/*

@@ -706,8 +716,9 @@ * isDefined - a convenience function for checking if a value is not equal to undefined

isError: isError,
isFiniteNumber: isFiniteNumber,
isFunction: isFunction,
isIterable: isIterable,
isNativeFunction: isNativeFunction,
isType: isType,
isObject: isObject,
isString: isString,
isType: isType,
jsonParse: jsonParse,

@@ -714,0 +725,0 @@ LEVELS: LEVELS,

@@ -55,3 +55,4 @@ /* globals expect */

port: 9090
}
},
timeout: 3000
};

@@ -74,2 +75,3 @@ var defaults = {

expect(t.proxy).to.eql(options.proxy);
expect(t.timeout).to.eql(options.timeout);
});

@@ -106,2 +108,3 @@ it('should parse the endpoint if given', function() {

expect(t.proxy).to.eql(options.proxy);
expect(t.timeout).to.eql(undefined);
});

@@ -125,2 +128,3 @@ });

expect(o.method).to.eql(method);
expect(o.timeout).to.eql(undefined);
});

@@ -135,3 +139,4 @@ it('should use the proxy if given', function() {

port: 8080
}
},
timeout: 3000
};

@@ -146,2 +151,3 @@ var method = 'GET';

expect(o.method).to.eql(method);
expect(o.timeout).to.eql(transport.timeout);
});

@@ -148,0 +154,0 @@ });

@@ -17,3 +17,4 @@ /* globals expect */

protocol: 'https',
path: '/api/1/item/'
path: '/api/1/item/',
timeout: 2000
};

@@ -39,5 +40,6 @@ var payload = {

expect(resp.result).to.be.ok();
expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
done(err);
};
t.post(accessToken, options, payload, callback, requestFactory);
t.post(accessToken, options, payload, callback, requestFactory.getInstance);
});

@@ -50,5 +52,6 @@ it('should callback with the server error if 403', function(done) {

expect(err.message).to.eql('403');
expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
done(resp);
};
t.post(accessToken, options, payload, callback, requestFactory);
t.post(accessToken, options, payload, callback, requestFactory.getInstance);
});

@@ -61,5 +64,6 @@ it('should callback with the server error if 500', function(done) {

expect(err.message).to.eql('500');
expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
done(resp);
};
t.post(accessToken, options, payload, callback, requestFactory);
t.post(accessToken, options, payload, callback, requestFactory.getInstance);
});

@@ -73,5 +77,6 @@ it('should callback with a retriable error with a weird status', function(done) {

expect(err.code).to.eql('ENOTFOUND');
expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
done(resp);
};
t.post(accessToken, options, payload, callback, requestFactory);
t.post(accessToken, options, payload, callback, requestFactory.getInstance);
});

@@ -84,5 +89,6 @@ it('should callback with some error if normal sending throws', function(done) {

expect(err.message).to.match(/Cannot find a method to transport/);
expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
done(resp);
};
t.post(accessToken, options, payload, callback, requestFactory);
t.post(accessToken, options, payload, callback, requestFactory.getInstance);
});

@@ -121,6 +127,13 @@ });

};
var requestGenerator = function(response, status, shouldThrow) {
return function() {
return new TestRequest(response, status, shouldThrow);
};
var request;
return {
getInstance: function() {
if(!request) {
request = new TestRequest(response, status, shouldThrow);
}
return request;
}
}
};

@@ -419,3 +419,3 @@ /* globals expect */

});
it('true if both trace and body message but ignoredMessages only match body', function() {
it('false if both trace and body message but ignoredMessages only match body', function() {
var item = {

@@ -432,3 +432,3 @@ level: 'critical',

};
expect(p.messageIsIgnored(logger)(item, settings)).to.be.ok();
expect(p.messageIsIgnored(logger)(item, settings)).to.not.be.ok();
});

@@ -449,2 +449,50 @@ it('false if ignoredMessages match something in body exception message', function() {

});
it("true if trace_chain doesn't match", function() {
var item = {
level: 'critical',
body: {
trace_chain: [
{exception: {message: 'inner bork'}},
{exception: {message: 'outer bork'}}
]
}
};
var settings = {
reportLevel: 'debug',
ignoredMessages: ['stuff', 'fuzz']
};
expect(p.messageIsIgnored(logger)(item, settings)).to.be.ok();
});
it("false if first trace_chain trace matches", function() {
var item = {
level: 'critical',
body: {
trace_chain: [
{exception: {message: 'inner stuff'}},
{exception: {message: 'outer bork'}}
]
}
};
var settings = {
reportLevel: 'debug',
ignoredMessages: ['stuff', 'fuzz']
};
expect(p.messageIsIgnored(logger)(item, settings)).to.not.be.ok();
});
it("false if last trace_chain trace matches", function() {
var item = {
level: 'critical',
body: {
trace_chain: [
{exception: {message: 'inner bork'}},
{exception: {message: 'outer fuzz'}}
]
}
};
var settings = {
reportLevel: 'debug',
ignoredMessages: ['stuff', 'fuzz']
};
expect(p.messageIsIgnored(logger)(item, settings)).to.not.be.ok();
});
});

@@ -477,31 +477,60 @@ /* globals expect */

});
it('should retry if we get a retriable error', function(done) {
var rateLimiter = new (TestRateLimiterGenerator())();
var api = new (TestApiGenerator())();
var logger = new (TestLoggerGenerator())();
var options = {retryInterval: 1, transmit: true};
var queue = new Queue(rateLimiter, api, logger, options);
describe('if we get a retriable error', function() {
it('should retry', function(done) {
var rateLimiter = new (TestRateLimiterGenerator())();
var api = new (TestApiGenerator())();
var logger = new (TestLoggerGenerator())();
var options = {retryInterval: 1, transmit: true};
var queue = new Queue(rateLimiter, api, logger, options);
var item = {mykey: 'myvalue'};
var serverResponse = {success: true};
var apiError = {code: 'ENOTFOUND', message: 'No internet connection'};
var item = {mykey: 'myvalue'};
var serverResponse = {success: true};
var apiError = {code: 'ENOTFOUND', message: 'No internet connection'};
var apiRequestCount = 0;
rateLimiter.handler = function(i) {
return {error: null, shouldSend: true, payload: null};
};
api.handler = function(i, cb) {
apiRequestCount++;
if (apiRequestCount === 1) {
cb(apiError);
} else {
cb(null, serverResponse);
}
};
queue.addItem({mykey: 'myvalue'}, function(err, resp) {
expect(err).to.not.be.ok();
expect(resp).to.eql(serverResponse);
expect(apiRequestCount).to.eql(2);
done();
var apiRequestCount = 0;
rateLimiter.handler = function(i) {
return {error: null, shouldSend: true, payload: null};
};
api.handler = function(i, cb) {
apiRequestCount++;
if (apiRequestCount === 1) {
cb(apiError);
} else {
cb(null, serverResponse);
}
};
queue.addItem({mykey: 'myvalue'}, function(err, resp) {
expect(err).to.not.be.ok();
expect(resp).to.eql(serverResponse);
expect(apiRequestCount).to.eql(2);
done();
});
});
it('should retry until maxRetries limit is reached', function(done) {
var rateLimiter = new (TestRateLimiterGenerator())();
var api = new (TestApiGenerator())();
var logger = new (TestLoggerGenerator())();
var options = {retryInterval: 1, maxRetries: 2, transmit: true};
var queue = new Queue(rateLimiter, api, logger, options);
var item = {mykey: 'myvalue'};
var serverResponse = {success: true};
var apiError = {code: 'ENOTFOUND', message: 'No internet connection'};
var apiRequestCount = 0;
rateLimiter.handler = function(i) {
return {error: null, shouldSend: true, payload: null};
};
api.handler = function(i, cb) {
apiRequestCount++;
cb({...apiError, retry: apiRequestCount});
};
queue.addItem({mykey: 'myvalue'}, function(err, resp) {
var numRequests = options.maxRetries + 1;
expect(apiRequestCount).to.eql(numRequests);
expect(err).to.eql({...apiError, retry: numRequests});
expect(resp).to.not.be.ok();
done();
});
});
});

@@ -508,0 +537,0 @@ });

@@ -289,3 +289,8 @@ "use strict";

assert.ok(sourceMappingURLs[urls[1]].includes('not found'));
assert.ok(urls[2].includes('timers.js'));
// Node until v12 will have 'timers.js' here.
// Node 12 - 14 will have 'internal/timers.js' here.
// Starting in v16, this is 'node:internal/timers'.
// This assert works for all and is specific enough for this test case.
assert.ok(urls[2].includes('timers'));
assert.ok(sourceMappingURLs[urls[2]].includes('not found'));

@@ -292,0 +297,0 @@ }

@@ -249,2 +249,17 @@ /* globals expect */

describe('isFiniteNumber', function() {
[ NaN, null, undefined, 'x' ].forEach(function(value) {
it(`should return false for ${value}`, function(done) {
expect(_.isFiniteNumber(value)).to.equal(false);
done();
});
});
[ -100, 0, 100 ].forEach(function(value) {
it(`should return true for ${value}`, function(done) {
expect(_.isFiniteNumber(value)).to.equal(true);
done();
});
});
});
describe('merge', function() {

@@ -251,0 +266,0 @@ it('should work for simple objects', function(done) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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