rollbar 2.23.0 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -501,6 +501,37 @@ function wrapCallback(logger, f) {
501
501
  };
502
502
  }
503
503
 
504
+ function nonCircularClone(obj) {
505
+ var seen = [obj];
506
+
507
+ function clone(obj, seen) {
508
+ var value, name, newSeen, result = {};
509
+
510
+ try {
511
+ for (name in obj) {
512
+ value = obj[name];
513
+
514
+ if (value && (isType(value, 'object') || isType(value, 'array'))) {
515
+ if (seen.includes(value)) {
516
+ result[name] = 'Removed circular reference: ' + typeName(value);
517
+ } else {
518
+ newSeen = seen.slice();
519
+ newSeen.push(value);
520
+ result[name] = clone(value, newSeen);
521
+ }
522
+ continue;
523
+ }
524
+
525
+ result[name] = value;
526
+ }
527
+ } catch (e) {
528
+ result = 'Failed cloning custom data: ' + e.message;
529
+ }
530
+ return result;
531
+ }
532
+ return clone(obj, seen);
533
+ }
534
+
504
535
  function createItem(args, logger, notifier, requestKeys, lambdaContext) {
505
536
  var message, err, custom, callback, request;
506
537
  var arg;
@@ -558,10 +589,12 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
558
589
  }
559
590
  }
560
591
 
592
+ // if custom is an array this turns it into an object with integer keys
593
+ if (custom) custom = nonCircularClone(custom);
594
+
561
595
  if (extraArgs.length > 0) {
562
- // if custom is an array this turns it into an object with integer keys
563
- custom = merge(custom);
564
- custom.extraArgs = extraArgs;
596
+ if (!custom) custom = nonCircularClone({});
597
+ custom.extraArgs = nonCircularClone(extraArgs);
565
598
  }
566
599
 
567
600
  var item = {
@@ -606,7 +639,7 @@ function addErrorContext(item, errors) {
606
639
  try {
607
640
  for (var i = 0; i < errors.length; ++i) {
608
641
  if (errors[i].hasOwnProperty('rollbarContext')) {
609
- custom = merge(custom, errors[i].rollbarContext);
642
+ custom = merge(custom, nonCircularClone(errors[i].rollbarContext));
610
643
  contextAdded = true;
611
644
  }
612
645
  }
@@ -1061,11 +1094,11 @@ function Stack(exception, skip) {
1061
1094
  function parse(e, skip) {
1062
1095
  var err = e;
1063
1096
 
1064
- if (err.nested) {
1097
+ if (err.nested || err.cause) {
1065
1098
  var traceChain = [];
1066
1099
  while (err) {
1067
1100
  traceChain.push(new Stack(err, skip));
1068
- err = err.nested;
1101
+ err = err.nested || err.cause;
1069
1102
 
1070
1103
  skip = 0; // Only apply skip value to primary error
1071
1104
  }
@@ -3514,8 +3547,8 @@ function addErrorContext(item) {
3514
3547
 
3515
3548
  chain.push(err);
3516
3549
 
3517
- while (err.nested) {
3518
- err = err.nested;
3550
+ while (err.nested || err.cause) {
3551
+ err = err.nested || err.cause;
3519
3552
  chain.push(err);
3520
3553
  }
3521
3554
 
@@ -4548,7 +4581,7 @@ module.exports = {
4548
4581
 
4549
4582
 
4550
4583
  module.exports = {
4551
- version: '2.23.0',
4584
+ version: '2.25.0',
4552
4585
  endpoint: 'api.rollbar.com/api/1/item/',
4553
4586
  logLevel: 'debug',
4554
4587
  reportLevel: 'debug',
@@ -5224,8 +5257,10 @@ Instrumenter.prototype.instrumentNetwork = function() {
5224
5257
  // Test to ensure body is a Promise, which it should always be.
5225
5258
  if (typeof body.then === 'function') {
5226
5259
  body.then(function (text) {
5227
- if (self.isJsonContentType(metadata.response_content_type)) {
5260
+ if (text && self.isJsonContentType(metadata.response_content_type)) {
5228
5261
  metadata.response.body = self.scrubJson(text);
5262
+ } else {
5263
+ metadata.response.body = text;
5229
5264
  }
5230
5265
  });
5231
5266
  } else {
@@ -5550,16 +5585,16 @@ Instrumenter.prototype.handleCspError = function(message) {
5550
5585
  }
5551
5586
 
5552
5587
  Instrumenter.prototype.deinstrumentContentSecurityPolicy = function() {
5553
- if (!('addEventListener' in this._window)) { return; }
5588
+ if (!('addEventListener' in this._document)) { return; }
5554
5589
 
5555
5590
  this.removeListeners('contentsecuritypolicy');
5556
5591
  };
5557
5592
 
5558
5593
  Instrumenter.prototype.instrumentContentSecurityPolicy = function() {
5559
- if (!('addEventListener' in this._window)) { return; }
5594
+ if (!('addEventListener' in this._document)) { return; }
5560
5595
 
5561
5596
  var cspHandler = this.handleCspEvent.bind(this);
5562
- this.addListener('contentsecuritypolicy', this._window, 'securitypolicyviolation', null, cspHandler, false);
5597
+ this.addListener('contentsecuritypolicy', this._document, 'securitypolicyviolation', null, cspHandler, false);
5563
5598
  };
5564
5599
 
5565
5600
  Instrumenter.prototype.addListener = function(section, obj, type, altType, handler, capture) {