@honeybadger-io/js 4.2.0 → 4.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.
@@ -6,6 +6,10 @@
6
6
 
7
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
8
 
9
+ function getDefaultExportFromCjs (x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
+ }
12
+
9
13
  function getAugmentedNamespace(n) {
10
14
  var f = n.default;
11
15
  if (typeof f == "function") {
@@ -27,7 +31,7 @@
27
31
  return a;
28
32
  }
29
33
 
30
- var browser = {};
34
+ var browser$1 = {};
31
35
 
32
36
  var src = {};
33
37
 
@@ -239,7 +243,7 @@
239
243
  Object.defineProperty(util$1, "__esModule", { value: true });
240
244
  util$1.isBrowserConfig = util$1.clone = util$1.formatCGIData = util$1.filterUrl = util$1.filter = util$1.generateStackTrace = util$1.endpoint = util$1.instrument = util$1.isErrorObject = util$1.makeNotice = util$1.logger = util$1.sanitize = util$1.shallowClone = util$1.runAfterNotifyHandlers = util$1.runBeforeNotifyHandlers = util$1.getSourceForBacktrace = util$1.getCauses = util$1.makeBacktrace = util$1.objectIsExtensible = util$1.objectIsEmpty = util$1.mergeNotice = util$1.merge = void 0;
241
245
  var stackTraceParser = __importStar(require$$0);
242
- function merge$1(obj1, obj2) {
246
+ function merge(obj1, obj2) {
243
247
  var result = {};
244
248
  for (var k in obj1) {
245
249
  result[k] = obj1[k];
@@ -249,11 +253,11 @@
249
253
  }
250
254
  return result;
251
255
  }
252
- util$1.merge = merge$1;
256
+ util$1.merge = merge;
253
257
  function mergeNotice(notice1, notice2) {
254
- var result = merge$1(notice1, notice2);
258
+ var result = merge(notice1, notice2);
255
259
  if (notice1.context && notice2.context) {
256
- result.context = merge$1(notice1.context, notice2.context);
260
+ result.context = merge(notice1.context, notice2.context);
257
261
  }
258
262
  return result;
259
263
  }
@@ -267,13 +271,13 @@
267
271
  return true;
268
272
  }
269
273
  util$1.objectIsEmpty = objectIsEmpty;
270
- function objectIsExtensible$1(obj) {
274
+ function objectIsExtensible(obj) {
271
275
  if (typeof Object.isExtensible !== 'function') {
272
276
  return true;
273
277
  }
274
278
  return Object.isExtensible(obj);
275
279
  }
276
- util$1.objectIsExtensible = objectIsExtensible$1;
280
+ util$1.objectIsExtensible = objectIsExtensible;
277
281
  function makeBacktrace(stack, shift) {
278
282
  if (shift === void 0) { shift = 0; }
279
283
  try {
@@ -491,7 +495,7 @@
491
495
  }
492
496
  else if (isErrorObject(thing)) {
493
497
  var e = thing;
494
- notice = merge$1(thing, { name: e.name, message: e.message, stack: e.stack, cause: e.cause });
498
+ notice = merge(thing, { name: e.name, message: e.message, stack: e.stack, cause: e.cause });
495
499
  }
496
500
  else if (typeof thing === 'object') {
497
501
  notice = shallowClone(thing);
@@ -569,7 +573,7 @@
569
573
  return stack.join('\n');
570
574
  }
571
575
  util$1.generateStackTrace = generateStackTrace;
572
- function filter$1(obj, filters) {
576
+ function filter(obj, filters) {
573
577
  if (!is('Object', obj)) {
574
578
  return;
575
579
  }
@@ -609,7 +613,7 @@
609
613
  }
610
614
  return filter(obj);
611
615
  }
612
- util$1.filter = filter$1;
616
+ util$1.filter = filter;
613
617
  function filterMatch(key, filters) {
614
618
  for (var i = 0; i < filters.length; i++) {
615
619
  if (key.toLowerCase().indexOf(filters[i].toLowerCase()) !== -1) {
@@ -704,8 +708,8 @@
704
708
  }());
705
709
  store.GlobalStore = GlobalStore;
706
710
 
707
- var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
708
- __assign$1 = Object.assign || function(t) {
711
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
712
+ __assign = Object.assign || function(t) {
709
713
  for (var s, i = 1, n = arguments.length; i < n; i++) {
710
714
  s = arguments[i];
711
715
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
@@ -713,16 +717,16 @@
713
717
  }
714
718
  return t;
715
719
  };
716
- return __assign$1.apply(this, arguments);
720
+ return __assign.apply(this, arguments);
717
721
  };
718
722
  Object.defineProperty(client, "__esModule", { value: true });
719
723
  client.Client = void 0;
720
- var util_1$2 = util$1;
724
+ var util_1$1 = util$1;
721
725
  var store_1 = store;
722
726
  var notifier = {
723
727
  name: 'honeybadger-js',
724
728
  url: 'https://github.com/honeybadger-io/honeybadger-js',
725
- version: '4.2.0'
729
+ version: '4.3.0'
726
730
  };
727
731
  // Split at commas and spaces
728
732
  var TAG_SEPARATOR = /,|\s+/;
@@ -735,12 +739,12 @@
735
739
  this.__store = null;
736
740
  this.__beforeNotifyHandlers = [];
737
741
  this.__afterNotifyHandlers = [];
738
- this.config = __assign$1({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: function () { return true; }, filters: ['creditcard', 'password'], __plugins: [] }, opts);
742
+ this.config = __assign({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: function () { return true; }, filters: ['creditcard', 'password'], __plugins: [] }, opts);
739
743
  // First, we go with the global (shared) store.
740
744
  // Webserver middleware can then switch to the AsyncStore for async context tracking.
741
745
  this.__store = new store_1.GlobalStore({ context: {}, breadcrumbs: [] });
742
746
  this.__transport = transport;
743
- this.logger = (0, util_1$2.logger)(this);
747
+ this.logger = (0, util_1$1.logger)(this);
744
748
  }
745
749
  Client.prototype.getVersion = function () {
746
750
  return notifier.version;
@@ -771,7 +775,7 @@
771
775
  Client.prototype.setContext = function (context) {
772
776
  if (typeof context === 'object') {
773
777
  var store = this.__store.getStore();
774
- store.context = (0, util_1$2.merge)(store.context, context);
778
+ store.context = (0, util_1$1.merge)(store.context, context);
775
779
  }
776
780
  return this;
777
781
  };
@@ -816,14 +820,14 @@
816
820
  }
817
821
  // we need to have the source file data before the beforeNotifyHandlers,
818
822
  // in case they modify them
819
- var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$2.shallowClone)(trace); }) : null;
820
- var beforeNotifyResult = (0, util_1$2.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
823
+ var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$1.shallowClone)(trace); }) : null;
824
+ var beforeNotifyResult = (0, util_1$1.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
821
825
  if (!preConditionError && !beforeNotifyResult) {
822
826
  this.logger.debug('skipping error report: beforeNotify handlers returned false', notice);
823
827
  preConditionError = new Error('beforeNotify handlers returned false');
824
828
  }
825
829
  if (preConditionError) {
826
- (0, util_1$2.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionError);
830
+ (0, util_1$1.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionError);
827
831
  return false;
828
832
  }
829
833
  this.addBreadcrumb('Honeybadger Notice', {
@@ -836,7 +840,7 @@
836
840
  });
837
841
  var breadcrumbs = this.__getStoreContentsOrDefault().breadcrumbs;
838
842
  notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs.slice() : [];
839
- (0, util_1$2.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
843
+ (0, util_1$1.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
840
844
  .then(function (sourcePerTrace) {
841
845
  sourcePerTrace.forEach(function (source, index) {
842
846
  notice.backtrace[index].source = source;
@@ -850,26 +854,26 @@
850
854
  'Accept': 'text/json, application/json'
851
855
  },
852
856
  method: 'POST',
853
- endpoint: (0, util_1$2.endpoint)(_this.config.endpoint, '/v1/notices/js'),
857
+ endpoint: (0, util_1$1.endpoint)(_this.config.endpoint, '/v1/notices/js'),
854
858
  maxObjectDepth: _this.config.maxObjectDepth,
855
859
  logger: _this.logger,
856
- async: (0, util_1$2.isBrowserConfig)(_this.config) ? _this.config.async : undefined,
860
+ async: (0, util_1$1.isBrowserConfig)(_this.config) ? _this.config.async : undefined,
857
861
  }, payload)
858
862
  .then(function (res) {
859
863
  if (res.statusCode !== 201) {
860
- (0, util_1$2.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode)));
864
+ (0, util_1$1.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode)));
861
865
  _this.logger.warn("Error report failed: unknown response from server. code=".concat(res.statusCode));
862
866
  return;
863
867
  }
864
868
  var uuid = JSON.parse(res.body).id;
865
- (0, util_1$2.runAfterNotifyHandlers)((0, util_1$2.merge)(notice, {
869
+ (0, util_1$1.runAfterNotifyHandlers)((0, util_1$1.merge)(notice, {
866
870
  id: uuid
867
871
  }), _this.__afterNotifyHandlers);
868
872
  _this.logger.info("Error report sent \u26A1 https://app.honeybadger.io/notice/".concat(uuid));
869
873
  })
870
874
  .catch(function (err) {
871
875
  _this.logger.error('Error report failed: an unknown error occurred.', "message=".concat(err.message));
872
- (0, util_1$2.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, err);
876
+ (0, util_1$1.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, err);
873
877
  });
874
878
  });
875
879
  return true;
@@ -922,18 +926,18 @@
922
926
  Client.prototype.makeNotice = function (noticeable, name, extra) {
923
927
  if (name === void 0) { name = undefined; }
924
928
  if (extra === void 0) { extra = undefined; }
925
- var notice = (0, util_1$2.makeNotice)(noticeable);
929
+ var notice = (0, util_1$1.makeNotice)(noticeable);
926
930
  if (name && !(typeof name === 'object')) {
927
931
  var n = String(name);
928
932
  name = { name: n };
929
933
  }
930
934
  if (name) {
931
- notice = (0, util_1$2.mergeNotice)(notice, name);
935
+ notice = (0, util_1$1.mergeNotice)(notice, name);
932
936
  }
933
937
  if (typeof extra === 'object' && extra !== null) {
934
- notice = (0, util_1$2.mergeNotice)(notice, extra);
938
+ notice = (0, util_1$1.mergeNotice)(notice, extra);
935
939
  }
936
- if ((0, util_1$2.objectIsEmpty)(notice)) {
940
+ if ((0, util_1$1.objectIsEmpty)(notice)) {
937
941
  return null;
938
942
  }
939
943
  var context = this.__getStoreContentsOrDefault().context;
@@ -943,9 +947,9 @@
943
947
  // Turning into a Set will remove duplicates
944
948
  var tags = noticeTags.concat(contextTags).concat(configTags);
945
949
  var uniqueTags = tags.filter(function (item, index) { return tags.indexOf(item) === index; });
946
- notice = (0, util_1$2.merge)(notice, {
950
+ notice = (0, util_1$1.merge)(notice, {
947
951
  name: notice.name || 'Error',
948
- context: (0, util_1$2.merge)(context, notice.context),
952
+ context: (0, util_1$1.merge)(context, notice.context),
949
953
  projectRoot: notice.projectRoot || this.config.projectRoot,
950
954
  environment: notice.environment || this.config.environment,
951
955
  component: notice.component || this.config.component,
@@ -955,10 +959,10 @@
955
959
  });
956
960
  var backtraceShift = 0;
957
961
  if (typeof notice.stack !== 'string' || !notice.stack.trim()) {
958
- notice.stack = (0, util_1$2.generateStackTrace)();
962
+ notice.stack = (0, util_1$1.generateStackTrace)();
959
963
  backtraceShift = 2;
960
964
  }
961
- notice.backtrace = (0, util_1$2.makeBacktrace)(notice.stack, backtraceShift);
965
+ notice.backtrace = (0, util_1$1.makeBacktrace)(notice.stack, backtraceShift);
962
966
  return notice;
963
967
  };
964
968
  Client.prototype.addBreadcrumb = function (message, opts) {
@@ -966,7 +970,7 @@
966
970
  return;
967
971
  }
968
972
  opts = opts || {};
969
- var metadata = (0, util_1$2.shallowClone)(opts.metadata);
973
+ var metadata = (0, util_1$1.shallowClone)(opts.metadata);
970
974
  var category = opts.category || 'custom';
971
975
  var timestamp = new Date().toISOString();
972
976
  var store = this.__store.getStore();
@@ -991,8 +995,8 @@
991
995
  return (this.config.environment && this.config.developmentEnvironments.includes(this.config.environment));
992
996
  };
993
997
  Client.prototype.__buildPayload = function (notice) {
994
- var headers = (0, util_1$2.filter)(notice.headers, this.config.filters) || {};
995
- var cgiData = (0, util_1$2.filter)(__assign$1(__assign$1({}, notice.cgiData), (0, util_1$2.formatCGIData)(headers, 'HTTP_')), this.config.filters);
998
+ var headers = (0, util_1$1.filter)(notice.headers, this.config.filters) || {};
999
+ var cgiData = (0, util_1$1.filter)(__assign(__assign({}, notice.cgiData), (0, util_1$1.formatCGIData)(headers, 'HTTP_')), this.config.filters);
996
1000
  return {
997
1001
  notifier: notifier,
998
1002
  breadcrumbs: {
@@ -1005,16 +1009,16 @@
1005
1009
  backtrace: notice.backtrace,
1006
1010
  fingerprint: notice.fingerprint,
1007
1011
  tags: notice.tags,
1008
- causes: (0, util_1$2.getCauses)(notice),
1012
+ causes: (0, util_1$1.getCauses)(notice),
1009
1013
  },
1010
1014
  request: {
1011
- url: (0, util_1$2.filterUrl)(notice.url, this.config.filters),
1015
+ url: (0, util_1$1.filterUrl)(notice.url, this.config.filters),
1012
1016
  component: notice.component,
1013
1017
  action: notice.action,
1014
1018
  context: notice.context,
1015
1019
  cgi_data: cgiData,
1016
- params: (0, util_1$2.filter)(notice.params, this.config.filters) || {},
1017
- session: (0, util_1$2.filter)(notice.session, this.config.filters) || {}
1020
+ params: (0, util_1$1.filter)(notice.params, this.config.filters) || {},
1021
+ session: (0, util_1$1.filter)(notice.session, this.config.filters) || {}
1018
1022
  },
1019
1023
  server: {
1020
1024
  project_root: notice.projectRoot,
@@ -1040,7 +1044,7 @@
1040
1044
  Client.prototype.__getStoreContentsOrDefault = function () {
1041
1045
  var existingStoreContents = this.__store.getStore();
1042
1046
  var storeContents = existingStoreContents || {};
1043
- return __assign$1({ context: {}, breadcrumbs: [] }, storeContents);
1047
+ return __assign({ context: {}, breadcrumbs: [] }, storeContents);
1044
1048
  };
1045
1049
  return Client;
1046
1050
  }());
@@ -1265,8 +1269,8 @@
1265
1269
  Object.defineProperty(onerror, "__esModule", { value: true });
1266
1270
  onerror.onError = onerror.ignoreNextOnError = void 0;
1267
1271
  /* eslint-disable prefer-rest-params */
1268
- var core_1$6 = src;
1269
- var instrument$4 = core_1$6.Util.instrument, makeNotice = core_1$6.Util.makeNotice;
1272
+ var core_1$5 = src;
1273
+ var instrument$4 = core_1$5.Util.instrument, makeNotice = core_1$5.Util.makeNotice;
1270
1274
  var ignoreOnError = 0;
1271
1275
  var currentTimeout;
1272
1276
  function ignoreNextOnError() {
@@ -1338,8 +1342,8 @@
1338
1342
 
1339
1343
  Object.defineProperty(onunhandledrejection, "__esModule", { value: true });
1340
1344
  /* eslint-disable prefer-rest-params */
1341
- var core_1$5 = src;
1342
- var instrument$3 = core_1$5.Util.instrument;
1345
+ var core_1$4 = src;
1346
+ var instrument$3 = core_1$4.Util.instrument;
1343
1347
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1344
1348
  function default_1$3(_window) {
1345
1349
  if (_window === void 0) { _window = window; }
@@ -1399,9 +1403,9 @@
1399
1403
 
1400
1404
  Object.defineProperty(breadcrumbs, "__esModule", { value: true });
1401
1405
  /* eslint-disable prefer-rest-params */
1402
- var core_1$4 = src;
1403
- var util_1$1 = util;
1404
- var sanitize$1 = core_1$4.Util.sanitize, instrument$2 = core_1$4.Util.instrument;
1406
+ var core_1$3 = src;
1407
+ var util_1 = util;
1408
+ var sanitize$1 = core_1$3.Util.sanitize, instrument$2 = core_1$3.Util.instrument;
1405
1409
  function default_1$2(_window) {
1406
1410
  if (_window === void 0) { _window = window; }
1407
1411
  return {
@@ -1461,9 +1465,9 @@
1461
1465
  _window.addEventListener('click', function (event) {
1462
1466
  var message, selector, text;
1463
1467
  try {
1464
- message = (0, util_1$1.stringNameOfElement)(event.target);
1465
- selector = (0, util_1$1.stringSelectorOfElement)(event.target);
1466
- text = (0, util_1$1.stringTextOfElement)(event.target);
1468
+ message = (0, util_1.stringNameOfElement)(event.target);
1469
+ selector = (0, util_1.stringSelectorOfElement)(event.target);
1470
+ text = (0, util_1.stringTextOfElement)(event.target);
1467
1471
  }
1468
1472
  catch (e) {
1469
1473
  message = 'UI Click';
@@ -1496,7 +1500,7 @@
1496
1500
  var xhr = this;
1497
1501
  var url = arguments[1];
1498
1502
  var method = typeof arguments[0] === 'string' ? arguments[0].toUpperCase() : arguments[0];
1499
- var message = "".concat(method, " ").concat((0, util_1$1.localURLPathname)(url));
1503
+ var message = "".concat(method, " ").concat((0, util_1.localURLPathname)(url));
1500
1504
  this.__hb_xhr = {
1501
1505
  type: 'xhr',
1502
1506
  method: method,
@@ -1553,7 +1557,7 @@
1553
1557
  if (!breadcrumbsEnabled('network')) {
1554
1558
  return;
1555
1559
  }
1556
- if (!(0, util_1$1.nativeFetch)()) {
1560
+ if (!(0, util_1.nativeFetch)()) {
1557
1561
  // Polyfills use XHR.
1558
1562
  return;
1559
1563
  }
@@ -1581,7 +1585,7 @@
1581
1585
  if (typeof method === 'string') {
1582
1586
  method = method.toUpperCase();
1583
1587
  }
1584
- var message = "".concat(method, " ").concat((0, util_1$1.localURLPathname)(url));
1588
+ var message = "".concat(method, " ").concat((0, util_1.localURLPathname)(url));
1585
1589
  var metadata = {
1586
1590
  type: 'fetch',
1587
1591
  method: method,
@@ -1656,8 +1660,8 @@
1656
1660
 
1657
1661
  Object.defineProperty(timers, "__esModule", { value: true });
1658
1662
  /* eslint-disable prefer-rest-params */
1659
- var core_1$3 = src;
1660
- var instrument$1 = core_1$3.Util.instrument;
1663
+ var core_1$2 = src;
1664
+ var instrument$1 = core_1$2.Util.instrument;
1661
1665
  function default_1$1(_window) {
1662
1666
  if (_window === void 0) { _window = window; }
1663
1667
  return {
@@ -1692,8 +1696,8 @@
1692
1696
  var event_listeners = {};
1693
1697
 
1694
1698
  Object.defineProperty(event_listeners, "__esModule", { value: true });
1695
- var core_1$2 = src;
1696
- var instrument = core_1$2.Util.instrument;
1699
+ var core_1$1 = src;
1700
+ var instrument = core_1$1.Util.instrument;
1697
1701
  function default_1(_window) {
1698
1702
  if (_window === void 0) { _window = window; }
1699
1703
  return {
@@ -1738,8 +1742,8 @@
1738
1742
 
1739
1743
  Object.defineProperty(transport, "__esModule", { value: true });
1740
1744
  transport.BrowserTransport = void 0;
1741
- var core_1$1 = src;
1742
- var sanitize = core_1$1.Util.sanitize;
1745
+ var core_1 = src;
1746
+ var sanitize = core_1.Util.sanitize;
1743
1747
  var BrowserTransport = /** @class */ (function () {
1744
1748
  function BrowserTransport() {
1745
1749
  }
@@ -1767,190 +1771,197 @@
1767
1771
  }());
1768
1772
  transport.BrowserTransport = BrowserTransport;
1769
1773
 
1770
- var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
1771
- var extendStatics = function (d, b) {
1772
- extendStatics = Object.setPrototypeOf ||
1773
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1774
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1775
- return extendStatics(d, b);
1776
- };
1777
- return function (d, b) {
1778
- if (typeof b !== "function" && b !== null)
1779
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1780
- extendStatics(d, b);
1781
- function __() { this.constructor = d; }
1782
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1783
- };
1784
- })();
1785
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1786
- __assign = Object.assign || function(t) {
1787
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1788
- s = arguments[i];
1789
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1790
- t[p] = s[p];
1791
- }
1792
- return t;
1793
- };
1794
- return __assign.apply(this, arguments);
1795
- };
1796
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1797
- return (mod && mod.__esModule) ? mod : { "default": mod };
1798
- };
1799
- Object.defineProperty(browser, "__esModule", { value: true });
1800
- var core_1 = src;
1801
- var util_1 = util;
1802
- var onerror_1 = onerror;
1803
- var onunhandledrejection_1 = __importDefault(onunhandledrejection);
1804
- var breadcrumbs_1 = __importDefault(breadcrumbs);
1805
- var timers_1 = __importDefault(timers);
1806
- var event_listeners_1 = __importDefault(event_listeners);
1807
- var transport_1 = transport;
1808
- var merge = core_1.Util.merge, filter = core_1.Util.filter, objectIsExtensible = core_1.Util.objectIsExtensible;
1809
- var Honeybadger = /** @class */ (function (_super) {
1810
- __extends(Honeybadger, _super);
1811
- function Honeybadger(opts) {
1812
- if (opts === void 0) { opts = {}; }
1813
- var _this = _super.call(this, __assign({ async: true, maxErrors: null, projectRoot: window.location.protocol + '//' + window.location.host }, opts), new transport_1.BrowserTransport()) || this;
1814
- /** @internal */
1815
- _this.__errorsSent = 0;
1816
- /** @internal */
1817
- _this.__lastWrapErr = undefined;
1818
- /** @internal */
1819
- _this.__beforeNotifyHandlers = [
1820
- function (notice) {
1821
- if (_this.__exceedsMaxErrors()) {
1822
- _this.logger.debug('Dropping notice: max errors exceeded', notice);
1823
- return false;
1824
- }
1825
- if (notice && !notice.url) {
1826
- notice.url = document.URL;
1827
- }
1828
- _this.__incrementErrorsCount();
1829
- return true;
1830
- }
1831
- ];
1832
- return _this;
1833
- }
1834
- Honeybadger.prototype.configure = function (opts) {
1835
- if (opts === void 0) { opts = {}; }
1836
- return _super.prototype.configure.call(this, opts);
1837
- };
1838
- Honeybadger.prototype.resetMaxErrors = function () {
1839
- return (this.__errorsSent = 0);
1840
- };
1841
- Honeybadger.prototype.factory = function (opts) {
1842
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1843
- return new Honeybadger(opts);
1844
- };
1845
- Honeybadger.prototype.checkIn = function (_id) {
1846
- throw new Error('Honeybadger.checkIn() is not supported on the browser');
1847
- };
1848
- /** @internal */
1849
- Honeybadger.prototype.__buildPayload = function (notice) {
1850
- var cgiData = {
1851
- HTTP_USER_AGENT: undefined,
1852
- HTTP_REFERER: undefined,
1853
- HTTP_COOKIE: undefined
1854
- };
1855
- cgiData.HTTP_USER_AGENT = navigator.userAgent;
1856
- if (document.referrer.match(/\S/)) {
1857
- cgiData.HTTP_REFERER = document.referrer;
1858
- }
1859
- var cookiesObject;
1860
- if (typeof notice.cookies === 'string') {
1861
- cookiesObject = (0, util_1.decodeCookie)(notice.cookies);
1862
- }
1863
- else {
1864
- cookiesObject = notice.cookies;
1865
- }
1866
- if (cookiesObject) {
1867
- cgiData.HTTP_COOKIE = (0, util_1.encodeCookie)(filter(cookiesObject, this.config.filters));
1868
- }
1869
- var payload = _super.prototype.__buildPayload.call(this, notice);
1870
- payload.request.cgi_data = merge(cgiData, payload.request.cgi_data);
1871
- return payload;
1872
- };
1873
- /**
1874
- * wrap always returns the same function so that callbacks can be removed via
1875
- * removeEventListener.
1876
- * @internal
1877
- */
1878
- Honeybadger.prototype.__wrap = function (f, opts) {
1879
- if (opts === void 0) { opts = {}; }
1880
- var func = f;
1881
- if (!opts) {
1882
- opts = {};
1883
- }
1884
- try {
1885
- if (typeof func !== 'function') {
1886
- return func;
1887
- }
1888
- if (!objectIsExtensible(func)) {
1889
- return func;
1890
- }
1891
- if (!func.___hb) {
1892
- // eslint-disable-next-line @typescript-eslint/no-this-alias
1893
- var client_1 = this;
1894
- func.___hb = function () {
1895
- if (util_1.preferCatch) {
1896
- try {
1897
- // eslint-disable-next-line prefer-rest-params
1898
- return func.apply(this, arguments);
1899
- }
1900
- catch (err) {
1901
- if (client_1.__lastWrapErr === err) {
1902
- throw (err);
1903
- }
1904
- client_1.__lastWrapErr = err;
1905
- (0, onerror_1.ignoreNextOnError)();
1906
- client_1.addBreadcrumb(opts.component ? "".concat(opts.component, ": ").concat(err.name) : err.name, {
1907
- category: 'error',
1908
- metadata: {
1909
- message: err.message,
1910
- name: err.name,
1911
- stack: err.stack
1912
- }
1913
- });
1914
- if (client_1.config.enableUncaught) {
1915
- client_1.notify(err);
1916
- }
1917
- throw (err);
1918
- }
1919
- }
1920
- else {
1921
- // eslint-disable-next-line prefer-rest-params
1922
- return func.apply(this, arguments);
1923
- }
1924
- };
1925
- }
1926
- func.___hb.___hb = func.___hb;
1927
- return func.___hb;
1928
- }
1929
- catch (_e) {
1930
- return func;
1931
- }
1932
- };
1933
- /** @internal */
1934
- Honeybadger.prototype.__incrementErrorsCount = function () {
1935
- return this.__errorsSent++;
1936
- };
1937
- /** @internal */
1938
- Honeybadger.prototype.__exceedsMaxErrors = function () {
1939
- return this.config.maxErrors && this.__errorsSent >= this.config.maxErrors;
1940
- };
1941
- return Honeybadger;
1942
- }(core_1.Client));
1943
- var _default = browser.default = new Honeybadger({
1944
- __plugins: [
1945
- (0, onerror_1.onError)(),
1946
- (0, onunhandledrejection_1.default)(),
1947
- (0, timers_1.default)(),
1948
- (0, event_listeners_1.default)(),
1949
- (0, breadcrumbs_1.default)()
1950
- ]
1951
- });
1774
+ (function (exports) {
1775
+ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
1776
+ var extendStatics = function (d, b) {
1777
+ extendStatics = Object.setPrototypeOf ||
1778
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1779
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1780
+ return extendStatics(d, b);
1781
+ };
1782
+ return function (d, b) {
1783
+ if (typeof b !== "function" && b !== null)
1784
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1785
+ extendStatics(d, b);
1786
+ function __() { this.constructor = d; }
1787
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1788
+ };
1789
+ })();
1790
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1791
+ __assign = Object.assign || function(t) {
1792
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1793
+ s = arguments[i];
1794
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1795
+ t[p] = s[p];
1796
+ }
1797
+ return t;
1798
+ };
1799
+ return __assign.apply(this, arguments);
1800
+ };
1801
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1802
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1803
+ };
1804
+ Object.defineProperty(exports, "__esModule", { value: true });
1805
+ exports.Types = void 0;
1806
+ var core_1 = src;
1807
+ var util_1 = util;
1808
+ var onerror_1 = onerror;
1809
+ var onunhandledrejection_1 = __importDefault(onunhandledrejection);
1810
+ var breadcrumbs_1 = __importDefault(breadcrumbs);
1811
+ var timers_1 = __importDefault(timers);
1812
+ var event_listeners_1 = __importDefault(event_listeners);
1813
+ var transport_1 = transport;
1814
+ var merge = core_1.Util.merge, filter = core_1.Util.filter, objectIsExtensible = core_1.Util.objectIsExtensible;
1815
+ var Honeybadger = /** @class */ (function (_super) {
1816
+ __extends(Honeybadger, _super);
1817
+ function Honeybadger(opts) {
1818
+ if (opts === void 0) { opts = {}; }
1819
+ var _this = _super.call(this, __assign({ async: true, maxErrors: null, projectRoot: window.location.protocol + '//' + window.location.host }, opts), new transport_1.BrowserTransport()) || this;
1820
+ /** @internal */
1821
+ _this.__errorsSent = 0;
1822
+ /** @internal */
1823
+ _this.__lastWrapErr = undefined;
1824
+ /** @internal */
1825
+ _this.__beforeNotifyHandlers = [
1826
+ function (notice) {
1827
+ if (_this.__exceedsMaxErrors()) {
1828
+ _this.logger.debug('Dropping notice: max errors exceeded', notice);
1829
+ return false;
1830
+ }
1831
+ if (notice && !notice.url) {
1832
+ notice.url = document.URL;
1833
+ }
1834
+ _this.__incrementErrorsCount();
1835
+ return true;
1836
+ }
1837
+ ];
1838
+ return _this;
1839
+ }
1840
+ Honeybadger.prototype.configure = function (opts) {
1841
+ if (opts === void 0) { opts = {}; }
1842
+ return _super.prototype.configure.call(this, opts);
1843
+ };
1844
+ Honeybadger.prototype.resetMaxErrors = function () {
1845
+ return (this.__errorsSent = 0);
1846
+ };
1847
+ Honeybadger.prototype.factory = function (opts) {
1848
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1849
+ return new Honeybadger(opts);
1850
+ };
1851
+ Honeybadger.prototype.checkIn = function (_id) {
1852
+ throw new Error('Honeybadger.checkIn() is not supported on the browser');
1853
+ };
1854
+ /** @internal */
1855
+ Honeybadger.prototype.__buildPayload = function (notice) {
1856
+ var cgiData = {
1857
+ HTTP_USER_AGENT: undefined,
1858
+ HTTP_REFERER: undefined,
1859
+ HTTP_COOKIE: undefined
1860
+ };
1861
+ cgiData.HTTP_USER_AGENT = navigator.userAgent;
1862
+ if (document.referrer.match(/\S/)) {
1863
+ cgiData.HTTP_REFERER = document.referrer;
1864
+ }
1865
+ var cookiesObject;
1866
+ if (typeof notice.cookies === 'string') {
1867
+ cookiesObject = (0, util_1.decodeCookie)(notice.cookies);
1868
+ }
1869
+ else {
1870
+ cookiesObject = notice.cookies;
1871
+ }
1872
+ if (cookiesObject) {
1873
+ cgiData.HTTP_COOKIE = (0, util_1.encodeCookie)(filter(cookiesObject, this.config.filters));
1874
+ }
1875
+ var payload = _super.prototype.__buildPayload.call(this, notice);
1876
+ payload.request.cgi_data = merge(cgiData, payload.request.cgi_data);
1877
+ return payload;
1878
+ };
1879
+ /**
1880
+ * wrap always returns the same function so that callbacks can be removed via
1881
+ * removeEventListener.
1882
+ * @internal
1883
+ */
1884
+ Honeybadger.prototype.__wrap = function (f, opts) {
1885
+ if (opts === void 0) { opts = {}; }
1886
+ var func = f;
1887
+ if (!opts) {
1888
+ opts = {};
1889
+ }
1890
+ try {
1891
+ if (typeof func !== 'function') {
1892
+ return func;
1893
+ }
1894
+ if (!objectIsExtensible(func)) {
1895
+ return func;
1896
+ }
1897
+ if (!func.___hb) {
1898
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1899
+ var client_1 = this;
1900
+ func.___hb = function () {
1901
+ if (util_1.preferCatch) {
1902
+ try {
1903
+ // eslint-disable-next-line prefer-rest-params
1904
+ return func.apply(this, arguments);
1905
+ }
1906
+ catch (err) {
1907
+ if (client_1.__lastWrapErr === err) {
1908
+ throw (err);
1909
+ }
1910
+ client_1.__lastWrapErr = err;
1911
+ (0, onerror_1.ignoreNextOnError)();
1912
+ client_1.addBreadcrumb(opts.component ? "".concat(opts.component, ": ").concat(err.name) : err.name, {
1913
+ category: 'error',
1914
+ metadata: {
1915
+ message: err.message,
1916
+ name: err.name,
1917
+ stack: err.stack
1918
+ }
1919
+ });
1920
+ if (client_1.config.enableUncaught) {
1921
+ client_1.notify(err);
1922
+ }
1923
+ throw (err);
1924
+ }
1925
+ }
1926
+ else {
1927
+ // eslint-disable-next-line prefer-rest-params
1928
+ return func.apply(this, arguments);
1929
+ }
1930
+ };
1931
+ }
1932
+ func.___hb.___hb = func.___hb;
1933
+ return func.___hb;
1934
+ }
1935
+ catch (_e) {
1936
+ return func;
1937
+ }
1938
+ };
1939
+ /** @internal */
1940
+ Honeybadger.prototype.__incrementErrorsCount = function () {
1941
+ return this.__errorsSent++;
1942
+ };
1943
+ /** @internal */
1944
+ Honeybadger.prototype.__exceedsMaxErrors = function () {
1945
+ return this.config.maxErrors && this.__errorsSent >= this.config.maxErrors;
1946
+ };
1947
+ return Honeybadger;
1948
+ }(core_1.Client));
1949
+ var core_2 = src;
1950
+ Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return core_2.Types; } });
1951
+ exports.default = new Honeybadger({
1952
+ __plugins: [
1953
+ (0, onerror_1.onError)(),
1954
+ (0, onunhandledrejection_1.default)(),
1955
+ (0, timers_1.default)(),
1956
+ (0, event_listeners_1.default)(),
1957
+ (0, breadcrumbs_1.default)()
1958
+ ]
1959
+ });
1960
+ } (browser$1));
1961
+
1962
+ var browser = /*@__PURE__*/getDefaultExportFromCjs(browser$1);
1952
1963
 
1953
- return _default;
1964
+ return browser;
1954
1965
 
1955
1966
  }));
1956
1967
  //# sourceMappingURL=honeybadger.js.map