@honeybadger-io/js 6.10.0 → 6.11.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.
@@ -1018,16 +1018,17 @@
1018
1018
  this.processQueue();
1019
1019
  }
1020
1020
  };
1021
+ ThrottledEventsLogger.prototype.flushAsync = function () {
1022
+ this.logger.debug('[Honeybadger] Flushing events');
1023
+ return this.send();
1024
+ };
1021
1025
  ThrottledEventsLogger.prototype.processQueue = function () {
1022
1026
  var _this = this;
1023
1027
  if (this.queue.length === 0 || this.isProcessing) {
1024
1028
  return;
1025
1029
  }
1026
1030
  this.isProcessing = true;
1027
- var eventsData = this.queue.slice();
1028
- this.queue = [];
1029
- var data = json_nd_1.NdJson.stringify(eventsData);
1030
- this.makeHttpRequest(data)
1031
+ this.send()
1031
1032
  .then(function () {
1032
1033
  setTimeout(function () {
1033
1034
  _this.isProcessing = false;
@@ -1043,6 +1044,20 @@
1043
1044
  }, 50);
1044
1045
  });
1045
1046
  };
1047
+ ThrottledEventsLogger.prototype.send = function () {
1048
+ return __awaiter$2(this, void 0, void 0, function () {
1049
+ var eventsData, data;
1050
+ return __generator$2(this, function (_a) {
1051
+ if (this.queue.length === 0) {
1052
+ return [2 /*return*/];
1053
+ }
1054
+ eventsData = this.queue.slice();
1055
+ this.queue = [];
1056
+ data = json_nd_1.NdJson.stringify(eventsData);
1057
+ return [2 /*return*/, this.makeHttpRequest(data)];
1058
+ });
1059
+ });
1060
+ };
1046
1061
  ThrottledEventsLogger.prototype.makeHttpRequest = function (data) {
1047
1062
  return __awaiter$2(this, void 0, void 0, function () {
1048
1063
  var _this = this;
@@ -1162,7 +1177,7 @@
1162
1177
  this.__notifier = {
1163
1178
  name: '@honeybadger-io/core',
1164
1179
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
1165
- version: '6.10.0'
1180
+ version: '6.11.0'
1166
1181
  };
1167
1182
  this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
1168
1183
  this.__initStore();
@@ -1381,6 +1396,13 @@
1381
1396
  }
1382
1397
  this.__eventsLogger.log(__assign$1({ event_type: type, ts: new Date().toISOString() }, data));
1383
1398
  };
1399
+ /**
1400
+ * This method currently flushes the event (Insights) queue.
1401
+ * In the future, it should also flush the error queue (assuming an error throttler is implemented).
1402
+ */
1403
+ Client.prototype.flushAsync = function () {
1404
+ return this.__eventsLogger.flushAsync();
1405
+ };
1384
1406
  Client.prototype.__getBreadcrumbs = function () {
1385
1407
  return this.__store.getContents('breadcrumbs').slice();
1386
1408
  };
@@ -2366,8 +2388,34 @@
2366
2388
  this.scriptUrl = scriptUrl;
2367
2389
  }
2368
2390
  /* ROLLUP_STRIP_CODE_CHROME_EXTENSION_START */
2391
+ BrowserFeedbackForm.prototype.appendUserFeedbackTag = 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.isUserFeedbackUrlAlreadyVisible = 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
+ /* ROLLUP_STRIP_CODE_CHROME_EXTENSION_END */
2369
2413
  BrowserFeedbackForm.prototype.show = function (lastNoticeId, options) {
2370
2414
  if (options === void 0) { options = {}; }
2415
+ if (typeof (this.appendUserFeedbackTag) !== 'function') {
2416
+ this.logger.debug('Feedback form is not available in this environment');
2417
+ return;
2418
+ }
2371
2419
  if (!this.config || !this.config.apiKey) {
2372
2420
  this.logger.debug('Client not initialized');
2373
2421
  return;
@@ -2381,33 +2429,12 @@
2381
2429
  this.logger.debug('global.document is undefined. Cannot attach script');
2382
2430
  return;
2383
2431
  }
2384
- if (this.isUserFeedbackScriptUrlAlreadyVisible()) {
2432
+ if (this.isUserFeedbackUrlAlreadyVisible()) {
2385
2433
  this.logger.debug('User feedback form is already visible');
2386
2434
  return;
2387
2435
  }
2388
2436
  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;
2437
+ this.appendUserFeedbackTag(global, options);
2411
2438
  };
2412
2439
  return BrowserFeedbackForm;
2413
2440
  }());
@@ -2671,7 +2698,7 @@
2671
2698
  var NOTIFIER = {
2672
2699
  name: '@honeybadger-io/js',
2673
2700
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
2674
- version: '6.10.0'
2701
+ version: '6.11.0'
2675
2702
  };
2676
2703
  var userAgent = function () {
2677
2704
  if (typeof navigator !== 'undefined') {