@honeybadger-io/js 4.0.0-beta.1 → 4.0.0-beta.2

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.
@@ -271,7 +271,7 @@
271
271
  return true;
272
272
  }
273
273
  // Returns a new object with properties from other object.
274
- function newObject(obj) {
274
+ function shallowClone(obj) {
275
275
  if (typeof (obj) !== 'object' || obj === null) {
276
276
  return {};
277
277
  }
@@ -298,8 +298,14 @@
298
298
  return false;
299
299
  }
300
300
  function canSerialize(obj) {
301
- // Functions are TMI and Symbols can't convert to strings.
302
- if (/function|symbol/.test(typeof (obj))) {
301
+ var typeOfObj = typeof obj;
302
+ // Functions are TMI
303
+ if (/function/.test(typeOfObj)) {
304
+ // Let special toJSON method pass as it's used by JSON.stringify (#722)
305
+ return obj.name === 'toJSON';
306
+ }
307
+ // Symbols can't convert to strings.
308
+ if (/symbol/.test(typeOfObj)) {
303
309
  return false;
304
310
  }
305
311
  if (obj === null) {
@@ -395,7 +401,7 @@
395
401
  notice = merge(thing, { name: e.name, message: e.message, stack: e.stack });
396
402
  }
397
403
  else if (typeof thing === 'object') {
398
- notice = newObject(thing);
404
+ notice = shallowClone(thing);
399
405
  }
400
406
  else {
401
407
  var m = String(thing);
@@ -583,7 +589,7 @@
583
589
  var notifier = {
584
590
  name: 'honeybadger-js',
585
591
  url: 'https://github.com/honeybadger-io/honeybadger-js',
586
- version: '4.0.0-beta.1'
592
+ version: '4.0.0-beta.2'
587
593
  };
588
594
  // Split at commas and spaces
589
595
  var TAG_SEPARATOR = /,|\s+/;
@@ -699,7 +705,7 @@
699
705
  notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs.slice() : [];
700
706
  // we need to have the source file data before the beforeNotifyHandlers,
701
707
  // in case they modify them
702
- var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return newObject(trace); }) : null;
708
+ var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return shallowClone(trace); }) : null;
703
709
  getSourceForBacktrace(sourceCodeData, this.__getSourceFileHandler, function (sourcePerTrace) {
704
710
  sourcePerTrace.forEach(function (source, index) {
705
711
  notice.backtrace[index].source = source;
@@ -800,7 +806,7 @@
800
806
  return;
801
807
  }
802
808
  opts = opts || {};
803
- var metadata = newObject(opts.metadata);
809
+ var metadata = shallowClone(opts.metadata);
804
810
  var category = opts.category || 'custom';
805
811
  var timestamp = new Date().toISOString();
806
812
  var store = this.__store.getStore();