Comparing version 2.17.0 to 2.18.0
@@ -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(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdn.rollbar.com/rollbarjs/refs/tags/v2.17.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);function t(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var a=0;function l(r,e){this.options=r,this._rollbarOldOnError=null;var o=a++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var i=o(3),s=function(r,e){return new l(r,e)},d=function(r){return new i(s,r)};function c(r){return t((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)}))}l.prototype.loadFull=function(r,e,o,n,a){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=t((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,t,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(t=n.args||[],i=0;i<t.length;++i)if("function"==typeof(l=t[i])){l(e);break}}"function"==typeof a&&a(e)}()}})),d.insertBefore(i,s)},l.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 u="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),p=0;p<u.length;++p)l.prototype[u[p]]=c(u[p]);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 a=new d(e);return t((function(){e.captureUncaught&&(a._rollbarOldOnError=r.onerror,n.captureUncaughtExceptions(r,a,!0),e.wrapGlobalEventHandlers&&n.wrapGlobals(r,a,!0)),e.captureUnhandledRejections&&n.captureUnhandledRejections(r,a,!0);var t=e.autoInstrument;return!1!==e.enabled&&(void 0===t||!0===t||"object"==typeof t&&t.network)&&r.addEventListener&&(r.addEventListener("load",a.captureLoad.bind(a)),r.addEventListener("DOMContentLoaded",a.captureDomContentLoaded.bind(a))),r[o]=a,a}))()}},Rollbar:d}},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)}function t(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={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)}},wrapGlobals:function(r,e,o){if(r){var n,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(n=0;n<l.length;++n)r[a=l[n]]&&r[a].prototype&&t(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(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdn.rollbar.com/rollbarjs/refs/tags/v2.18.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);function t(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var a=0;function l(r,e){this.options=r,this._rollbarOldOnError=null;var o=a++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var i=o(3),s=function(r,e){return new l(r,e)},d=function(r){return new i(s,r)};function c(r){return t((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)}))}l.prototype.loadFull=function(r,e,o,n,a){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=t((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,t,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(t=n.args||[],i=0;i<t.length;++i)if("function"==typeof(l=t[i])){l(e);break}}"function"==typeof a&&a(e)}()}})),d.insertBefore(i,s)},l.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 u="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),p=0;p<u.length;++p)l.prototype[u[p]]=c(u[p]);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 a=new d(e);return t((function(){e.captureUncaught&&(a._rollbarOldOnError=r.onerror,n.captureUncaughtExceptions(r,a,!0),e.wrapGlobalEventHandlers&&n.wrapGlobals(r,a,!0)),e.captureUnhandledRejections&&n.captureUnhandledRejections(r,a,!0);var t=e.autoInstrument;return!1!==e.enabled&&(void 0===t||!0===t||"object"==typeof t&&t.network)&&r.addEventListener&&(r.addEventListener("load",a.captureLoad.bind(a)),r.addEventListener("DOMContentLoaded",a.captureDomContentLoaded.bind(a))),r[o]=a,a}))()}},Rollbar:d}},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)}function t(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={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)}},wrapGlobals:function(r,e,o){if(r){var n,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(n=0;n<l.length;++n)r[a=l[n]]&&r[a].prototype&&t(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}}}}]); |
{ | ||
"name": "rollbar", | ||
"version": "2.17.0", | ||
"version": "2.18.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
# Rollbar.js | ||
[![Build Status](https://travis-ci.org/rollbar/rollbar.js.svg?branch=v2.17.0)](https://travis-ci.org/rollbar/rollbar.js) | ||
[![Build Status](https://travis-ci.org/rollbar/rollbar.js.svg?branch=v2.18.0)](https://travis-ci.org/rollbar/rollbar.js) | ||
[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/context:javascript) | ||
@@ -6,0 +6,0 @@ [![Total Alerts](https://img.shields.io/lgtm/alerts/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/alerts) |
@@ -370,4 +370,5 @@ var _ = require('../utility'); | ||
if (self.autoInstrument.networkResponseBody) { | ||
if (typeof resp.text === 'function') { // Response.text() is not implemented on multiple platforms | ||
body = resp.text(); //returns a Promise | ||
if (typeof resp.text === 'function') { // Response.text() is not implemented on some platforms | ||
// The response must be cloned to prevent reading (and locking) the original stream. | ||
body = resp.clone().text(); //returns a Promise | ||
} | ||
@@ -374,0 +375,0 @@ } |
@@ -22,2 +22,6 @@ var _ = require('../utility'); | ||
item.stackInfo = item.err._savedStackTrace || errorParser.parse(item.err, item.skipFrames); | ||
if (options.addErrorContext) { | ||
addErrorContext(item); | ||
} | ||
} catch (e) { | ||
@@ -36,2 +40,16 @@ logger.error('Error while parsing the error object.', e); | ||
function addErrorContext(item) { | ||
var chain = []; | ||
var err = item.err; | ||
chain.push(err); | ||
while (err.nested) { | ||
err = err.nested; | ||
chain.push(err); | ||
} | ||
_.addErrorContext(item, chain); | ||
} | ||
function ensureItemHasSomethingToSay(item, options, callback) { | ||
@@ -297,4 +315,5 @@ if (!item.message && !item.stackInfo && !item.custom) { | ||
function scrubPayload(item, options, callback) { | ||
var scrubFields = options.scrubFields; | ||
item.data = _.scrub(item.data, scrubFields); | ||
var scrubFields = options.scrubFields || []; | ||
var scrubPaths = options.scrubPaths || []; | ||
item.data = _.scrub(item.data, scrubFields, scrubPaths); | ||
callback(null, item); | ||
@@ -301,0 +320,0 @@ } |
@@ -67,2 +67,6 @@ var _ = require('../utility'); | ||
if (options.addErrorContext) { | ||
_.addErrorContext(item, [item.err]); | ||
} | ||
var err = item.err; | ||
@@ -89,4 +93,5 @@ var parsedError = errorParser.parse(err); | ||
var scrubFields = options.scrubFields || []; | ||
var scrubPaths = options.scrubPaths || []; | ||
scrubFields = scrubHeaders.concat(scrubFields); | ||
item.data = _.scrub(item.data, scrubFields); | ||
item.data = _.scrub(item.data, scrubFields, scrubPaths); | ||
callback(null, item); | ||
@@ -93,0 +98,0 @@ } |
@@ -91,2 +91,6 @@ var async = require('async'); | ||
if (options.addErrorContext) { | ||
_.addErrorContext(item, errors); | ||
} | ||
var cb = function(e) { | ||
@@ -188,6 +192,7 @@ if (e) { | ||
var scrubFields = options.scrubFields || []; | ||
var scrubPaths = options.scrubPaths || []; | ||
scrubFields = scrubHeaders.concat(scrubFields); | ||
parseRequestBody(item.data.request, options); | ||
item.data = _.scrub(item.data, scrubFields); | ||
item.data = _.scrub(item.data, scrubFields, scrubPaths); | ||
serializeRequestBody(item.data.request, options); | ||
@@ -194,0 +199,0 @@ |
@@ -509,2 +509,23 @@ var merge = require('./merge'); | ||
function addErrorContext(item, errors) { | ||
var custom = item.data.custom || {}; | ||
var contextAdded = false; | ||
try { | ||
for (var i = 0; i < errors.length; ++i) { | ||
if (errors[i].hasOwnProperty('rollbarContext')) { | ||
custom = merge(custom, errors[i].rollbarContext); | ||
contextAdded = true; | ||
} | ||
} | ||
// Avoid adding an empty object to the data. | ||
if (contextAdded) { | ||
item.data.custom = custom; | ||
} | ||
} catch (e) { | ||
item.diagnostic.error_context = 'Failed: ' + e.message; | ||
} | ||
} | ||
var TELEMETRY_TYPES = ['log', 'network', 'dom', 'navigation', 'error', 'manual']; | ||
@@ -606,4 +627,11 @@ var TELEMETRY_LEVELS = ['critical', 'error', 'warning', 'info', 'debug']; | ||
function scrub(data, scrubFields) { | ||
function scrub(data, scrubFields, scrubPaths) { | ||
scrubFields = scrubFields || []; | ||
if (scrubPaths) { | ||
for (var i = 0; i < scrubPaths.length; ++i) { | ||
scrubPath(data, scrubPaths[i]); | ||
} | ||
} | ||
var paramRes = _getScrubFieldRegexs(scrubFields); | ||
@@ -652,2 +680,18 @@ var queryRes = _getScrubQueryParamRegexs(scrubFields); | ||
function scrubPath(obj, path) { | ||
var keys = path.split('.'); | ||
var last = keys.length - 1; | ||
try { | ||
for (var i = 0; i <= last; ++i) { | ||
if (i < last) { | ||
obj = obj[keys[i]]; | ||
} else { | ||
obj[keys[i]] = redact(); | ||
} | ||
} | ||
} catch (e) { | ||
// Missing key is OK; | ||
} | ||
} | ||
function _getScrubFieldRegexs(scrubFields) { | ||
@@ -759,2 +803,3 @@ var ret = []; | ||
createItem: createItem, | ||
addErrorContext: addErrorContext, | ||
createTelemetryEvent: createTelemetryEvent, | ||
@@ -761,0 +806,0 @@ filterIp: filterIp, |
@@ -747,2 +747,29 @@ /* globals expect */ | ||
it('should add custom data when called with error context', function(done) { | ||
var server = window.server; | ||
stubResponse(server); | ||
server.requests.length = 0; | ||
var options = { | ||
accessToken: 'POST_CLIENT_ITEM_TOKEN', | ||
addErrorContext: true | ||
}; | ||
var rollbar = window.rollbar = new Rollbar(options); | ||
var err = new Error('test error'); | ||
err.rollbarContext = { err: 'test' }; | ||
rollbar.error(err, { 'foo': 'bar' }); | ||
server.respond(); | ||
var body = JSON.parse(server.requests[0].requestBody); | ||
expect(body.data.body.trace.exception.message).to.eql('test error'); | ||
expect(body.data.custom.foo).to.eql('bar'); | ||
expect(body.data.custom.err).to.eql('test'); | ||
done(); | ||
}) | ||
it('should send message when called with only null arguments', function(done) { | ||
@@ -1149,4 +1176,12 @@ var server = window.server; | ||
window.fetchStub = sinon.stub(window, 'fetch'); | ||
var readableStream = new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(JSON.stringify({name: 'foo', password: '123456'})); | ||
controller.close(); | ||
} | ||
}); | ||
window.fetch.returns(Promise.resolve(new Response( | ||
JSON.stringify({name: 'foo', password: '123456'}), | ||
readableStream, | ||
{ status: 200, statusText: 'OK', headers: { 'content-type': 'application/json', 'password': '123456' }} | ||
@@ -1178,4 +1213,4 @@ ))); | ||
var fetchRequest = new Request('https://example.com/xhr-test'); | ||
window,fetch(fetchRequest, fetchInit) | ||
.then(function(_response) { | ||
window.fetch(fetchRequest, fetchInit) | ||
.then(function(response) { | ||
try { | ||
@@ -1204,2 +1239,5 @@ rollbar.log('test'); // generate a payload to inspect | ||
// Assert that the original stream reader hasn't been read. | ||
expect(response.bodyUsed).to.eql(false); | ||
rollbar.configure({ autoInstrument: false }); | ||
@@ -1206,0 +1244,0 @@ window.fetch.restore(); |
@@ -429,3 +429,2 @@ /* globals expect */ | ||
t.addBody(item, options, function(e, i) { | ||
console.log('body:', i.data.body) | ||
expect(i.data.body.trace_chain.length).to.eql(2); | ||
@@ -437,2 +436,21 @@ expect(i.data.body.trace_chain[0].exception.message).to.eql('test error'); | ||
}); | ||
it('should create add error context as custom data', function(done) { | ||
var nestedErr = new Error('nested error'); | ||
nestedErr.rollbarContext = { err1: 'nested context' }; | ||
var err = new Error('test error'); | ||
err.rollbarContext = { err2: 'error context' }; | ||
err.nested = nestedErr; | ||
var args = ['a message', err]; | ||
var item = itemFromArgs(args); | ||
var options = { addErrorContext: true }; | ||
t.handleItemWithError(item, options, function(e, i) { | ||
expect(i.stackInfo).to.be.ok(); | ||
}); | ||
t.addBody(item, options, function(e, i) { | ||
expect(i.data.body.trace_chain.length).to.eql(2); | ||
expect(i.data.custom.err1).to.eql('nested context'); | ||
expect(i.data.custom.err2).to.eql('error context'); | ||
done(e); | ||
}); | ||
}); | ||
}); | ||
@@ -439,0 +457,0 @@ }); |
@@ -385,2 +385,32 @@ "use strict"; | ||
} | ||
}, | ||
'with error context': { | ||
topic: function (options) { | ||
var test = function() { | ||
var x = thisVariableIsNotDefined; | ||
}; | ||
var err; | ||
try { | ||
test(); | ||
} catch (e) { | ||
err = new CustomError('nested-message', e); | ||
e.rollbarContext = { err1: 'nested context' }; | ||
err.rollbarContext = { err2: 'error context' }; | ||
} | ||
var item = { | ||
data: {body: {}}, | ||
err: err | ||
}; | ||
options.addErrorContext = true; | ||
t.handleItemWithError(item, options, this.callback); | ||
}, | ||
'should not error': function(err, item) { | ||
assert.ifError(err); | ||
}, | ||
'should add the error context': function(err, item) { | ||
var trace_chain = item.stackInfo; | ||
assert.lengthOf(trace_chain, 2); | ||
assert.equal(item.data.custom.err1, 'nested context'); | ||
assert.equal(item.data.custom.err2, 'error context'); | ||
} | ||
} | ||
@@ -387,0 +417,0 @@ } |
@@ -659,3 +659,3 @@ /* globals expect */ | ||
expect(result.password).to.not.eql('abc123'); | ||
expect(result.password).to.eql(_.redact()); | ||
}); | ||
@@ -679,6 +679,6 @@ it('should handle nested objects', function() { | ||
expect(result.a.b.other).to.eql('stuff'); | ||
expect(result.a.badthing).to.not.eql('secret'); | ||
expect(result.a.b.badthing).to.eql(_.redact()); | ||
expect(result.a.c).to.eql('bork'); | ||
expect(result.a.password).to.not.eql('abc123'); | ||
expect(result.secret).to.not.eql('blahblah'); | ||
expect(result.a.password).to.eql(_.redact()); | ||
expect(result.secret).to.eql(_.redact()); | ||
expect(data.secret).to.eql('blahblah'); | ||
@@ -702,7 +702,34 @@ }); | ||
expect(result.thing).to.eql('stuff'); | ||
expect(result.password).to.not.eql('abc123'); | ||
expect(result.inner.a).to.not.eql('what'); | ||
expect(result.password).to.eql(_.redact()); | ||
expect(result.inner.a).to.eql(_.redact()); | ||
expect(result.inner.a).to.be.ok(); | ||
expect(result.inner.b).to.eql('yes'); | ||
}); | ||
it('should handle scrubPaths', function() { | ||
var data = { | ||
a: { | ||
b: { | ||
foo: 'secret', | ||
bar: 'stuff' | ||
}, | ||
c: 'bork', | ||
password: 'abc123' | ||
}, | ||
secret: 'blahblah' | ||
}; | ||
var scrubPaths = [ | ||
'nowhere', // path not found | ||
'a.b.foo', // nested path | ||
'a.password', // nested path | ||
'secret' // root path | ||
]; | ||
var result = _.scrub(data, [], scrubPaths); | ||
expect(result.a.b.bar).to.eql('stuff'); | ||
expect(result.a.b.foo).to.eql(_.redact()); | ||
expect(result.a.c).to.eql('bork'); | ||
expect(result.a.password).to.eql(_.redact()); | ||
expect(result.secret).to.eql(_.redact()); | ||
}); | ||
}); | ||
@@ -709,0 +736,0 @@ |
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
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
3775044
44021
4