Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 50bc646

Browse files
committedJul 31, 2019
Release v2.10.0
1 parent ad54665 commit 50bc646

26 files changed

+378
-130
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Rollbar.js
22

3-
[![Build Status](https://api.travis-ci.org/rollbar/rollbar.js.png?branch=v2.9.0)](https://travis-ci.org/rollbar/rollbar.js)
3+
[![Build Status](https://api.travis-ci.org/rollbar/rollbar.js.png?branch=v2.10.0)](https://travis-ci.org/rollbar/rollbar.js)
44
[![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)
55
[![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)
66

‎dist/rollbar.js

+89-27
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,21 @@ function Stack(exception) {
11561156

11571157

11581158
function parse(e) {
1159-
return new Stack(e);
1159+
var err = e;
1160+
1161+
if (err.nested) {
1162+
var traceChain = [];
1163+
while (err) {
1164+
traceChain.push(new Stack(err));
1165+
err = err.nested;
1166+
}
1167+
1168+
// Return primary error with full trace chain attached.
1169+
traceChain[0].traceChain = traceChain;
1170+
return traceChain[0];
1171+
} else {
1172+
return new Stack(err);
1173+
}
11601174
}
11611175

11621176

@@ -1461,7 +1475,10 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno
14611475
if (!this.options.captureUncaught && !this.options.handleUncaughtExceptions) {
14621476
return;
14631477
}
1464-
if (this.options.inspectAnonymousErrors && this.isChrome && !error) {
1478+
1479+
// Chrome will always send 5+ arrguments and error will be valid or null, not undefined.
1480+
// If error is undefined, we have a different caller.
1481+
if (this.options.inspectAnonymousErrors && this.isChrome && (error === null)) {
14651482
this.anonymousErrorsPending += 1; // See Rollbar.prototype.handleAnonymousErrors()
14661483
return;
14671484
}
@@ -1685,6 +1702,7 @@ Rollbar.prototype.captureLoad = function(e, ts) {
16851702

16861703
function addTransformsToNotifier(notifier, gWindow) {
16871704
notifier
1705+
.addTransform(transforms.handleDomException)
16881706
.addTransform(transforms.handleItemWithError)
16891707
.addTransform(transforms.ensureItemHasSomethingToSay)
16901708
.addTransform(transforms.addBaseInfo)
@@ -1737,7 +1755,7 @@ function _gWindow() {
17371755
/* global __DEFAULT_ENDPOINT__:false */
17381756

17391757
var defaultOptions = {
1740-
version: "2.9.0",
1758+
version: "2.10.0",
17411759
scrubFields: ["pw","pass","passwd","password","secret","confirm_password","confirmPassword","password_confirmation","passwordConfirmation","access_token","accessToken","secret_key","secretKey","secretToken","cc-number","card number","cardnumber","cardnum","ccnum","ccnumber","cc num","creditcardnumber","credit card number","newcreditcardnumber","new credit card","creditcardno","credit card no","card#","card #","cc-csc","cvc2","cvv2","ccv2","security code","card verification","name on credit card","name on card","nameoncard","cardholder","card holder","name des karteninhabers","card type","cardtype","cc type","cctype","payment type","expiration date","expirationdate","expdate","cc-exp"],
17421760
logLevel: "debug",
17431761
reportLevel: "debug",
@@ -1749,7 +1767,8 @@ var defaultOptions = {
17491767
sendConfig: false,
17501768
includeItemsInTelemetry: true,
17511769
captureIp: true,
1752-
inspectAnonymousErrors: true
1770+
inspectAnonymousErrors: true,
1771+
ignoreDuplicateErrors: true
17531772
};
17541773

17551774
module.exports = Rollbar;
@@ -1871,7 +1890,7 @@ Rollbar.prototype._log = function(defaultLevel, item) {
18711890
callback = item.callback;
18721891
delete item.callback;
18731892
}
1874-
if (this._sameAsLastError(item)) {
1893+
if (this.options.ignoreDuplicateErrors && this._sameAsLastError(item)) {
18751894
if (callback) {
18761895
var error = new Error('ignored identical item');
18771896
error.item = item;
@@ -3703,7 +3722,7 @@ module.exports = {
37033722
// Will return undefined otherwise
37043723
function getIEVersion() {
37053724
var undef;
3706-
if (!document) {
3725+
if (typeof document === 'undefined') {
37073726
return undef;
37083727
}
37093728

@@ -4127,6 +4146,18 @@ var _ = __webpack_require__(0);
41274146
var errorParser = __webpack_require__(4);
41284147
var logger = __webpack_require__(1);
41294148

4149+
function handleDomException(item, options, callback) {
4150+
if(item.err && errorParser.Stack(item.err).name === 'DOMException') {
4151+
var originalError = new Error();
4152+
originalError.name = item.err.name;
4153+
originalError.message = item.err.message;
4154+
originalError.stack = item.err.stack;
4155+
originalError.nested = item.err;
4156+
item.err = originalError;
4157+
}
4158+
callback(null, item);
4159+
}
4160+
41304161
function handleItemWithError(item, options, callback) {
41314162
item.data = item.data || {};
41324163
if (item.err) {
@@ -4234,7 +4265,11 @@ function addPluginInfo(window) {
42344265

42354266
function addBody(item, options, callback) {
42364267
if (item.stackInfo) {
4237-
addBodyTrace(item, options, callback);
4268+
if (item.stackInfo.traceChain) {
4269+
addBodyTraceChain(item, options, callback);
4270+
} else {
4271+
addBodyTrace(item, options, callback);
4272+
}
42384273
} else {
42394274
addBodyMessage(item, options, callback);
42404275
}
@@ -4245,13 +4280,7 @@ function addBodyMessage(item, options, callback) {
42454280
var custom = item.custom;
42464281

42474282
if (!message) {
4248-
if (custom) {
4249-
var scrubFields = options.scrubFields;
4250-
var messageResult = _.stringify(_.scrub(custom, scrubFields));
4251-
message = messageResult.error || messageResult.value || '';
4252-
} else {
4253-
message = '';
4254-
}
4283+
message = 'Item sent with null or missing arguments.';
42554284
}
42564285
var result = {
42574286
body: message
@@ -4265,11 +4294,51 @@ function addBodyMessage(item, options, callback) {
42654294
callback(null, item);
42664295
}
42674296

4297+
function stackFromItem(item) {
4298+
// Transform a TraceKit stackInfo object into a Rollbar trace
4299+
var stack = item.stackInfo.stack;
4300+
if (stack && stack.length === 0 && item._unhandledStackInfo && item._unhandledStackInfo.stack) {
4301+
stack = item._unhandledStackInfo.stack;
4302+
}
4303+
return stack;
4304+
}
4305+
4306+
function addBodyTraceChain(item, options, callback) {
4307+
var traceChain = item.stackInfo.traceChain;
4308+
var traces = [];
4309+
4310+
var traceChainLength = traceChain.length;
4311+
for (var i = 0; i < traceChainLength; i++) {
4312+
var trace = buildTrace(item, traceChain[i], options);
4313+
traces.push(trace);
4314+
}
4315+
4316+
_.set(item, 'data.body', {trace_chain: traces});
4317+
callback(null, item);
4318+
}
42684319

42694320
function addBodyTrace(item, options, callback) {
4270-
var description = item.data.description;
4271-
var stackInfo = item.stackInfo;
4272-
var custom = item.custom;
4321+
var stack = stackFromItem(item);
4322+
4323+
if (stack) {
4324+
var trace = buildTrace(item, item.stackInfo, options);
4325+
_.set(item, 'data.body', {trace: trace});
4326+
callback(null, item);
4327+
} else {
4328+
var stackInfo = item.stackInfo;
4329+
var guess = errorParser.guessErrorClass(stackInfo.message);
4330+
var className = stackInfo.name || guess[0];
4331+
var message = guess[1];
4332+
4333+
item.message = className + ': ' + message;
4334+
addBodyMessage(item, options, callback);
4335+
}
4336+
}
4337+
4338+
function buildTrace(item, stackInfo, options) {
4339+
var description = item && item.data.description;
4340+
var custom = item && item.custom;
4341+
var stack = stackFromItem(item);
42734342

42744343
var guess = errorParser.guessErrorClass(stackInfo.message);
42754344
var className = stackInfo.name || guess[0];
@@ -4285,11 +4354,6 @@ function addBodyTrace(item, options, callback) {
42854354
trace.exception.description = description;
42864355
}
42874356

4288-
// Transform a TraceKit stackInfo object into a Rollbar trace
4289-
var stack = stackInfo.stack;
4290-
if (stack && stack.length === 0 && item._unhandledStackInfo && item._unhandledStackInfo.stack) {
4291-
stack = item._unhandledStackInfo.stack;
4292-
}
42934357
if (stack) {
42944358
if (stack.length === 0) {
42954359
trace.exception.stack = stackInfo.rawStack;
@@ -4355,12 +4419,9 @@ function addBodyTrace(item, options, callback) {
43554419
if (custom) {
43564420
trace.extra = _.merge(custom);
43574421
}
4358-
_.set(item, 'data.body', {trace: trace});
4359-
callback(null, item);
4360-
} else {
4361-
item.message = className + ': ' + message;
4362-
addBodyMessage(item, options, callback);
43634422
}
4423+
4424+
return trace;
43644425
}
43654426

43664427
function scrubPayload(item, options, callback) {
@@ -4370,6 +4431,7 @@ function scrubPayload(item, options, callback) {
43704431
}
43714432

43724433
module.exports = {
4434+
handleDomException: handleDomException,
43734435
handleItemWithError: handleItemWithError,
43744436
ensureItemHasSomethingToSay: ensureItemHasSomethingToSay,
43754437
addBaseInfo: addBaseInfo,

‎dist/rollbar.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/rollbar.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/rollbar.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)