@honeybadger-io/js 6.9.2 → 6.10.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.
@@ -946,8 +946,8 @@
946
946
  __plugins: [],
947
947
  };
948
948
 
949
- var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
950
- __assign$1 = Object.assign || function(t) {
949
+ var __assign$2 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
950
+ __assign$2 = Object.assign || function(t) {
951
951
  for (var s, i = 1, n = arguments.length; i < n; i++) {
952
952
  s = arguments[i];
953
953
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
@@ -955,7 +955,7 @@
955
955
  }
956
956
  return t;
957
957
  };
958
- return __assign$1.apply(this, arguments);
958
+ return __assign$2.apply(this, arguments);
959
959
  };
960
960
  var __awaiter$2 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
961
961
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -1004,7 +1004,7 @@
1004
1004
  this.transport = transport;
1005
1005
  this.queue = [];
1006
1006
  this.isProcessing = false;
1007
- this.config = __assign$1(__assign$1({}, defaults_1$1.CONFIG), config);
1007
+ this.config = __assign$2(__assign$2({}, defaults_1$1.CONFIG), config);
1008
1008
  this.logger = this.originalLogger();
1009
1009
  }
1010
1010
  ThrottledEventsLogger.prototype.configure = function (opts) {
@@ -1095,8 +1095,8 @@
1095
1095
  }());
1096
1096
  throttled_events_logger.ThrottledEventsLogger = ThrottledEventsLogger;
1097
1097
 
1098
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1099
- __assign = Object.assign || function(t) {
1098
+ var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1099
+ __assign$1 = Object.assign || function(t) {
1100
1100
  for (var s, i = 1, n = arguments.length; i < n; i++) {
1101
1101
  s = arguments[i];
1102
1102
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
@@ -1104,7 +1104,7 @@
1104
1104
  }
1105
1105
  return t;
1106
1106
  };
1107
- return __assign.apply(this, arguments);
1107
+ return __assign$1.apply(this, arguments);
1108
1108
  };
1109
1109
  var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
1110
1110
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -1162,9 +1162,9 @@
1162
1162
  this.__notifier = {
1163
1163
  name: '@honeybadger-io/core',
1164
1164
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
1165
- version: '6.9.2'
1165
+ version: '6.10.0'
1166
1166
  };
1167
- this.config = __assign(__assign({}, defaults_1.CONFIG), opts);
1167
+ this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
1168
1168
  this.__initStore();
1169
1169
  this.__transport = transport;
1170
1170
  this.__eventsLogger = new throttled_events_logger_1.ThrottledEventsLogger(this.config, this.__transport);
@@ -1379,7 +1379,7 @@
1379
1379
  data = type;
1380
1380
  type = (_a = type['event_type']) !== null && _a !== void 0 ? _a : undefined;
1381
1381
  }
1382
- this.__eventsLogger.log(__assign({ event_type: type, ts: new Date().toISOString() }, data));
1382
+ this.__eventsLogger.log(__assign$1({ event_type: type, ts: new Date().toISOString() }, data));
1383
1383
  };
1384
1384
  Client.prototype.__getBreadcrumbs = function () {
1385
1385
  return this.__store.getContents('breadcrumbs').slice();
@@ -1395,7 +1395,7 @@
1395
1395
  };
1396
1396
  Client.prototype.__buildPayload = function (notice) {
1397
1397
  var headers = (0, util_1$1.filter)(notice.headers, this.config.filters) || {};
1398
- var cgiData = (0, util_1$1.filter)(__assign(__assign({}, notice.cgiData), (0, util_1$1.formatCGIData)(headers, 'HTTP_')), this.config.filters);
1398
+ var cgiData = (0, util_1$1.filter)(__assign$1(__assign$1({}, notice.cgiData), (0, util_1$1.formatCGIData)(headers, 'HTTP_')), this.config.filters);
1399
1399
  return {
1400
1400
  notifier: this.__notifier,
1401
1401
  breadcrumbs: {
@@ -1586,8 +1586,8 @@
1586
1586
 
1587
1587
  Object.defineProperty(util, "__esModule", { value: true });
1588
1588
  util.preferCatch = util.encodeCookie = util.decodeCookie = util.localURLPathname = util.parseURL = util.nativeFetch = util.stringTextOfElement = util.stringSelectorOfElement = util.stringNameOfElement = void 0;
1589
- var core_1$6 = src;
1590
- var globalThisOrWindow$6 = core_1$6.Util.globalThisOrWindow;
1589
+ var core_1$7 = src;
1590
+ var globalThisOrWindow$7 = core_1$7.Util.globalThisOrWindow;
1591
1591
  /**
1592
1592
  * Converts an HTMLElement into a human-readable string.
1593
1593
  * @param {!HTMLElement} element
@@ -1644,7 +1644,7 @@
1644
1644
  }
1645
1645
  util.stringTextOfElement = stringTextOfElement;
1646
1646
  function nativeFetch() {
1647
- var global = globalThisOrWindow$6();
1647
+ var global = globalThisOrWindow$7();
1648
1648
  if (!global.fetch) {
1649
1649
  return false;
1650
1650
  }
@@ -1773,8 +1773,8 @@
1773
1773
  Object.defineProperty(onerror, "__esModule", { value: true });
1774
1774
  onerror.onError = onerror.ignoreNextOnError = void 0;
1775
1775
  /* eslint-disable prefer-rest-params */
1776
- var core_1$5 = src;
1777
- var instrument$4 = core_1$5.Util.instrument, makeNotice = core_1$5.Util.makeNotice, globalThisOrWindow$5 = core_1$5.Util.globalThisOrWindow;
1776
+ var core_1$6 = src;
1777
+ var instrument$4 = core_1$6.Util.instrument, makeNotice = core_1$6.Util.makeNotice, globalThisOrWindow$6 = core_1$6.Util.globalThisOrWindow;
1778
1778
  var ignoreOnError = 0;
1779
1779
  var currentTimeout;
1780
1780
  function ignoreNextOnError() {
@@ -1787,7 +1787,7 @@
1787
1787
  onerror.ignoreNextOnError = ignoreNextOnError;
1788
1788
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1789
1789
  function onError(_window) {
1790
- if (_window === void 0) { _window = globalThisOrWindow$5(); }
1790
+ if (_window === void 0) { _window = globalThisOrWindow$6(); }
1791
1791
  return {
1792
1792
  load: function (client) {
1793
1793
  instrument$4(_window, 'onerror', function (original) {
@@ -1846,11 +1846,11 @@
1846
1846
 
1847
1847
  Object.defineProperty(onunhandledrejection, "__esModule", { value: true });
1848
1848
  /* eslint-disable prefer-rest-params */
1849
- var core_1$4 = src;
1850
- var instrument$3 = core_1$4.Util.instrument, globalThisOrWindow$4 = core_1$4.Util.globalThisOrWindow;
1849
+ var core_1$5 = src;
1850
+ var instrument$3 = core_1$5.Util.instrument, globalThisOrWindow$5 = core_1$5.Util.globalThisOrWindow;
1851
1851
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1852
1852
  function default_1$3(_window) {
1853
- if (_window === void 0) { _window = globalThisOrWindow$4(); }
1853
+ if (_window === void 0) { _window = globalThisOrWindow$5(); }
1854
1854
  return {
1855
1855
  load: function (client) {
1856
1856
  if (!client.config.enableUnhandledRejection) {
@@ -1907,11 +1907,11 @@
1907
1907
 
1908
1908
  Object.defineProperty(breadcrumbs, "__esModule", { value: true });
1909
1909
  /* eslint-disable prefer-rest-params */
1910
- var core_1$3 = src;
1910
+ var core_1$4 = src;
1911
1911
  var util_1 = util;
1912
- var sanitize$1 = core_1$3.Util.sanitize, instrument$2 = core_1$3.Util.instrument, instrumentConsole = core_1$3.Util.instrumentConsole, globalThisOrWindow$3 = core_1$3.Util.globalThisOrWindow;
1912
+ var sanitize$1 = core_1$4.Util.sanitize, instrument$2 = core_1$4.Util.instrument, instrumentConsole = core_1$4.Util.instrumentConsole, globalThisOrWindow$4 = core_1$4.Util.globalThisOrWindow;
1913
1913
  function default_1$2(_window) {
1914
- if (_window === void 0) { _window = globalThisOrWindow$3(); }
1914
+ if (_window === void 0) { _window = globalThisOrWindow$4(); }
1915
1915
  return {
1916
1916
  load: function (client) {
1917
1917
  function breadcrumbsEnabled(type) {
@@ -2169,10 +2169,10 @@
2169
2169
 
2170
2170
  Object.defineProperty(timers, "__esModule", { value: true });
2171
2171
  /* eslint-disable prefer-rest-params */
2172
- var core_1$2 = src;
2173
- var instrument$1 = core_1$2.Util.instrument, globalThisOrWindow$2 = core_1$2.Util.globalThisOrWindow;
2172
+ var core_1$3 = src;
2173
+ var instrument$1 = core_1$3.Util.instrument, globalThisOrWindow$3 = core_1$3.Util.globalThisOrWindow;
2174
2174
  function default_1$1(_window) {
2175
- if (_window === void 0) { _window = globalThisOrWindow$2(); }
2175
+ if (_window === void 0) { _window = globalThisOrWindow$3(); }
2176
2176
  return {
2177
2177
  load: function (client) {
2178
2178
  // Wrap timers
@@ -2205,10 +2205,10 @@
2205
2205
  var event_listeners = {};
2206
2206
 
2207
2207
  Object.defineProperty(event_listeners, "__esModule", { value: true });
2208
- var core_1$1 = src;
2209
- var instrument = core_1$1.Util.instrument, globalThisOrWindow$1 = core_1$1.Util.globalThisOrWindow;
2208
+ var core_1$2 = src;
2209
+ var instrument = core_1$2.Util.instrument, globalThisOrWindow$2 = core_1$2.Util.globalThisOrWindow;
2210
2210
  function default_1(_window) {
2211
- if (_window === void 0) { _window = globalThisOrWindow$1(); }
2211
+ if (_window === void 0) { _window = globalThisOrWindow$2(); }
2212
2212
  return {
2213
2213
  load: function (client) {
2214
2214
  // Wrap event listeners
@@ -2287,8 +2287,8 @@
2287
2287
  };
2288
2288
  Object.defineProperty(transport, "__esModule", { value: true });
2289
2289
  transport.BrowserTransport = void 0;
2290
- var core_1 = src;
2291
- var sanitize = core_1.Util.sanitize, globalThisOrWindow = core_1.Util.globalThisOrWindow;
2290
+ var core_1$1 = src;
2291
+ var sanitize = core_1$1.Util.sanitize, globalThisOrWindow$1 = core_1$1.Util.globalThisOrWindow;
2292
2292
  /**
2293
2293
  * Helper function to get typesafe Object.entries()
2294
2294
  * https://twitter.com/mattpocockuk/status/1502264005251018754?lang=en
@@ -2327,7 +2327,7 @@
2327
2327
  if (options.method === 'POST' && payload) {
2328
2328
  requestInit.body = typeof payload === 'string' ? payload : JSON.stringify(sanitize(payload, options.maxObjectDepth));
2329
2329
  }
2330
- return [4 /*yield*/, globalThisOrWindow().fetch(options.endpoint, requestInit)];
2330
+ return [4 /*yield*/, globalThisOrWindow$1().fetch(options.endpoint, requestInit)];
2331
2331
  case 1:
2332
2332
  response = _a.sent();
2333
2333
  return [4 /*yield*/, response.text()];
@@ -2342,6 +2342,77 @@
2342
2342
  }());
2343
2343
  transport.BrowserTransport = BrowserTransport;
2344
2344
 
2345
+ var feedbackForm = {};
2346
+
2347
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
2348
+ __assign = Object.assign || function(t) {
2349
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2350
+ s = arguments[i];
2351
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2352
+ t[p] = s[p];
2353
+ }
2354
+ return t;
2355
+ };
2356
+ return __assign.apply(this, arguments);
2357
+ };
2358
+ Object.defineProperty(feedbackForm, "__esModule", { value: true });
2359
+ feedbackForm.BrowserFeedbackForm = void 0;
2360
+ var core_1 = src;
2361
+ var globalThisOrWindow = core_1.Util.globalThisOrWindow;
2362
+ var BrowserFeedbackForm = /** @class */ (function () {
2363
+ function BrowserFeedbackForm(config, logger, scriptUrl) {
2364
+ this.config = config;
2365
+ this.logger = logger;
2366
+ this.scriptUrl = scriptUrl;
2367
+ }
2368
+ /* ROLLUP_STRIP_CODE_CHROME_EXTENSION_START */
2369
+ BrowserFeedbackForm.prototype.show = function (lastNoticeId, options) {
2370
+ if (options === void 0) { options = {}; }
2371
+ if (!this.config || !this.config.apiKey) {
2372
+ this.logger.debug('Client not initialized');
2373
+ return;
2374
+ }
2375
+ if (!lastNoticeId) {
2376
+ this.logger.debug("Can't show user feedback form without a notice already reported");
2377
+ return;
2378
+ }
2379
+ var global = globalThisOrWindow();
2380
+ if (typeof global.document === 'undefined') {
2381
+ this.logger.debug('global.document is undefined. Cannot attach script');
2382
+ return;
2383
+ }
2384
+ if (this.isUserFeedbackScriptUrlAlreadyVisible()) {
2385
+ this.logger.debug('User feedback form is already visible');
2386
+ return;
2387
+ }
2388
+ global['honeybadgerUserFeedbackOptions'] = __assign(__assign({}, options), { apiKey: this.config.apiKey, endpoint: this.config.userFeedbackEndpoint, noticeId: lastNoticeId });
2389
+ this.appendUserFeedbackScriptTag(global, options);
2390
+ };
2391
+ BrowserFeedbackForm.prototype.appendUserFeedbackScriptTag = function (window, options) {
2392
+ if (options === void 0) { options = {}; }
2393
+ var script = window.document.createElement('script');
2394
+ script.setAttribute('src', this.scriptUrl);
2395
+ script.setAttribute('async', 'true');
2396
+ if (options.onLoad) {
2397
+ script.onload = options.onLoad;
2398
+ }
2399
+ (commonjsGlobal.document.head || commonjsGlobal.document.body).appendChild(script);
2400
+ };
2401
+ BrowserFeedbackForm.prototype.isUserFeedbackScriptUrlAlreadyVisible = function () {
2402
+ var global = globalThisOrWindow();
2403
+ var feedbackScriptUrl = this.scriptUrl;
2404
+ for (var i = 0; i < global.document.scripts.length; i++) {
2405
+ var script = global.document.scripts[i];
2406
+ if (script.src === feedbackScriptUrl) {
2407
+ return true;
2408
+ }
2409
+ }
2410
+ return false;
2411
+ };
2412
+ return BrowserFeedbackForm;
2413
+ }());
2414
+ feedbackForm.BrowserFeedbackForm = BrowserFeedbackForm;
2415
+
2345
2416
  (function (exports) {
2346
2417
  var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
2347
2418
  var extendStatics = function (d, b) {
@@ -2418,6 +2489,7 @@
2418
2489
  var timers_1 = __importDefault(timers);
2419
2490
  var event_listeners_1 = __importDefault(event_listeners);
2420
2491
  var transport_1 = transport;
2492
+ var feedback_form_1 = feedbackForm;
2421
2493
  var merge = core_1.Util.merge, filter = core_1.Util.filter, objectIsExtensible = core_1.Util.objectIsExtensible, globalThisOrWindow = core_1.Util.globalThisOrWindow;
2422
2494
  var getProjectRoot = function () {
2423
2495
  var global = globalThisOrWindow();
@@ -2488,52 +2560,14 @@
2488
2560
  Honeybadger.prototype.showUserFeedbackForm = function (options) {
2489
2561
  if (options === void 0) { options = {}; }
2490
2562
  return __awaiter(this, void 0, void 0, function () {
2491
- var global;
2563
+ var form;
2492
2564
  return __generator(this, function (_a) {
2493
- if (!this.config || !this.config.apiKey) {
2494
- this.logger.debug('Client not initialized');
2495
- return [2 /*return*/];
2496
- }
2497
- if (!this.__lastNoticeId) {
2498
- this.logger.debug("Can't show user feedback form without a notice already reported");
2499
- return [2 /*return*/];
2500
- }
2501
- global = globalThisOrWindow();
2502
- if (typeof global.document === 'undefined') {
2503
- this.logger.debug('global.document is undefined. Cannot attach script');
2504
- return [2 /*return*/];
2505
- }
2506
- if (this.isUserFeedbackScriptUrlAlreadyVisible()) {
2507
- this.logger.debug('User feedback form is already visible');
2508
- return [2 /*return*/];
2509
- }
2510
- global['honeybadgerUserFeedbackOptions'] = __assign(__assign({}, options), { apiKey: this.config.apiKey, endpoint: this.config.userFeedbackEndpoint, noticeId: this.__lastNoticeId });
2511
- this.appendUserFeedbackScriptTag(global, options);
2565
+ form = new feedback_form_1.BrowserFeedbackForm(this.config, this.logger, this.getUserFeedbackSubmitUrl());
2566
+ form.show(this.__lastNoticeId, options);
2512
2567
  return [2 /*return*/];
2513
2568
  });
2514
2569
  });
2515
2570
  };
2516
- Honeybadger.prototype.appendUserFeedbackScriptTag = function (window, options) {
2517
- if (options === void 0) { options = {}; }
2518
- var script = window.document.createElement('script');
2519
- script.setAttribute('src', this.getUserFeedbackSubmitUrl());
2520
- script.setAttribute('async', 'true');
2521
- if (options.onLoad) {
2522
- script.onload = options.onLoad;
2523
- }
2524
- (commonjsGlobal.document.head || commonjsGlobal.document.body).appendChild(script);
2525
- };
2526
- Honeybadger.prototype.isUserFeedbackScriptUrlAlreadyVisible = function () {
2527
- var global = globalThisOrWindow();
2528
- var feedbackScriptUrl = this.getUserFeedbackSubmitUrl();
2529
- for (var i = 0; i < global.document.scripts.length; i++) {
2530
- var script = global.document.scripts[i];
2531
- if (script.src === feedbackScriptUrl) {
2532
- return true;
2533
- }
2534
- }
2535
- return false;
2536
- };
2537
2571
  Honeybadger.prototype.getUserFeedbackSubmitUrl = function () {
2538
2572
  return (0, exports.getUserFeedbackScriptUrl)(this.getVersion());
2539
2573
  };
@@ -2637,7 +2671,7 @@
2637
2671
  var NOTIFIER = {
2638
2672
  name: '@honeybadger-io/js',
2639
2673
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
2640
- version: '6.9.2'
2674
+ version: '6.10.0'
2641
2675
  };
2642
2676
  var userAgent = function () {
2643
2677
  if (typeof navigator !== 'undefined') {