@honeybadger-io/js 5.1.7 → 5.3.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.
@@ -800,7 +800,7 @@
800
800
  var notifier = {
801
801
  name: 'honeybadger-js',
802
802
  url: 'https://github.com/honeybadger-io/honeybadger-js',
803
- version: '5.1.7'
803
+ version: '5.3.0'
804
804
  };
805
805
  // Split at commas and spaces
806
806
  var TAG_SEPARATOR = /,|\s+/;
@@ -1022,12 +1022,16 @@
1022
1022
  revision: notice.revision || this.config.revision,
1023
1023
  tags: uniqueTags,
1024
1024
  });
1025
- if (typeof notice.stack !== 'string' || !notice.stack.trim()) {
1026
- notice.stack = (0, util_1$6.generateStackTrace)();
1027
- notice.backtrace = (0, util_1$6.makeBacktrace)(notice.stack, true, this.logger);
1028
- }
1029
- else {
1030
- notice.backtrace = (0, util_1$6.makeBacktrace)(notice.stack, false, this.logger);
1025
+ // If we're passed a custom backtrace array, use it
1026
+ // Otherwise we make one.
1027
+ if (!Array.isArray(notice.backtrace) || !notice.backtrace.length) {
1028
+ if (typeof notice.stack !== 'string' || !notice.stack.trim()) {
1029
+ notice.stack = (0, util_1$6.generateStackTrace)();
1030
+ notice.backtrace = (0, util_1$6.makeBacktrace)(notice.stack, true, this.logger);
1031
+ }
1032
+ else {
1033
+ notice.backtrace = (0, util_1$6.makeBacktrace)(notice.stack, false, this.logger);
1034
+ }
1031
1035
  }
1032
1036
  return notice;
1033
1037
  };
@@ -1213,6 +1217,9 @@
1213
1217
  if (isNative(global.fetch)) {
1214
1218
  return true;
1215
1219
  }
1220
+ if (typeof document === 'undefined') {
1221
+ return false;
1222
+ }
1216
1223
  // If fetch isn't native, it may be wrapped by someone else. Try to get
1217
1224
  // a pristine function from an iframe.
1218
1225
  try {
@@ -1540,6 +1547,9 @@
1540
1547
  if (!breadcrumbsEnabled('dom')) {
1541
1548
  return;
1542
1549
  }
1550
+ if (typeof _window.addEventListener !== 'function') {
1551
+ return;
1552
+ }
1543
1553
  _window.addEventListener('click', function (event) {
1544
1554
  var message, selector, text;
1545
1555
  try {
@@ -1564,7 +1574,7 @@
1564
1574
  event: event
1565
1575
  }
1566
1576
  });
1567
- }, _window.location ? true : false); // In CloudFlare workers useCapture must be false. window.locaiton is a hacky way to detect it.
1577
+ }, _window.location ? true : false); // In CloudFlare workers useCapture must be false. window.location is a hacky way to detect it.
1568
1578
  })();
1569
1579
  // Breadcrumbs: instrument XMLHttpRequest
1570
1580
  (function () {
@@ -1572,8 +1582,9 @@
1572
1582
  return;
1573
1583
  }
1574
1584
  // Some environments may not support XMLHttpRequest.
1575
- if (typeof XMLHttpRequest === 'undefined')
1585
+ if (typeof XMLHttpRequest === 'undefined') {
1576
1586
  return;
1587
+ }
1577
1588
  // -- On xhr.open: capture initial metadata
1578
1589
  instrument$2(XMLHttpRequest.prototype, 'open', function (original) {
1579
1590
  return function () {
@@ -1719,6 +1730,9 @@
1719
1730
  recordUrlChange(lastHref, _window.location.href);
1720
1731
  });
1721
1732
  }
1733
+ if (typeof _window.history === 'undefined') {
1734
+ return;
1735
+ }
1722
1736
  // https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
1723
1737
  // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
1724
1738
  function historyWrapper(original) {
@@ -2107,7 +2121,9 @@
2107
2121
  HTTP_REFERER: undefined,
2108
2122
  HTTP_COOKIE: undefined
2109
2123
  };
2110
- cgiData.HTTP_USER_AGENT = navigator.userAgent;
2124
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
2125
+ cgiData.HTTP_USER_AGENT = navigator.userAgent;
2126
+ }
2111
2127
  if (typeof document !== 'undefined' && document.referrer.match(/\S/)) {
2112
2128
  cgiData.HTTP_REFERER = document.referrer;
2113
2129
  }