@honeybadger-io/js 6.10.1 → 6.11.1

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.
@@ -392,7 +392,7 @@
392
392
  return [4 /*yield*/, getSourceFileHandler(trace.file)];
393
393
  case 2:
394
394
  fileContent = _a.sent();
395
- result[index] = getSourceCodeSnippet(fileContent, trace.number);
395
+ result[index] = getSourceCodeSnippet(fileContent, trace.number, trace.column, 2);
396
396
  index++;
397
397
  return [3 /*break*/, 1];
398
398
  case 3: return [2 /*return*/, result];
@@ -760,14 +760,34 @@
760
760
  return JSON.parse(JSON.stringify(obj));
761
761
  }
762
762
  exports.clone = clone;
763
- function getSourceCodeSnippet(fileData, lineNumber, sourceRadius) {
763
+ var THRESHOLD_COLUMN_NUMBER = 10000;
764
+ var THRESHOLD_LINE_LENGTH = 10000;
765
+ var THRESHOLD_FILE_SIZE = 200000; // 200KB threshold
766
+ function getThresholdExceededSnippet(lineNumber) {
767
+ var _a;
768
+ return _a = {}, _a[lineNumber] = 'SOURCE_SIZE_TOO_LARGE', _a;
769
+ }
770
+ function getSourceCodeSnippet(fileData, lineNumber, columnNumber, sourceRadius) {
764
771
  if (sourceRadius === void 0) { sourceRadius = 2; }
765
772
  if (!fileData) {
766
773
  return null;
767
774
  }
775
+ // If column number is provided and very high, it's likely a bundled/minified file
776
+ if (columnNumber && columnNumber > THRESHOLD_COLUMN_NUMBER) {
777
+ return getThresholdExceededSnippet(lineNumber);
778
+ }
779
+ // If file is very large, it's likely bundled
780
+ if (fileData.length > THRESHOLD_FILE_SIZE) {
781
+ return getThresholdExceededSnippet(lineNumber);
782
+ }
768
783
  var lines = fileData.split('\n');
769
784
  // add one empty line because array index starts from 0, but error line number is counted from 1
770
785
  lines.unshift('');
786
+ // Check if the target line is extremely long
787
+ var targetLine = lines[lineNumber];
788
+ if (targetLine && targetLine.length > THRESHOLD_LINE_LENGTH) {
789
+ return getThresholdExceededSnippet(lineNumber);
790
+ }
771
791
  var start = lineNumber - sourceRadius;
772
792
  var end = lineNumber + sourceRadius;
773
793
  var result = {};
@@ -1018,16 +1038,17 @@
1018
1038
  this.processQueue();
1019
1039
  }
1020
1040
  };
1041
+ ThrottledEventsLogger.prototype.flushAsync = function () {
1042
+ this.logger.debug('[Honeybadger] Flushing events');
1043
+ return this.send();
1044
+ };
1021
1045
  ThrottledEventsLogger.prototype.processQueue = function () {
1022
1046
  var _this = this;
1023
1047
  if (this.queue.length === 0 || this.isProcessing) {
1024
1048
  return;
1025
1049
  }
1026
1050
  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)
1051
+ this.send()
1031
1052
  .then(function () {
1032
1053
  setTimeout(function () {
1033
1054
  _this.isProcessing = false;
@@ -1043,6 +1064,20 @@
1043
1064
  }, 50);
1044
1065
  });
1045
1066
  };
1067
+ ThrottledEventsLogger.prototype.send = function () {
1068
+ return __awaiter$2(this, void 0, void 0, function () {
1069
+ var eventsData, data;
1070
+ return __generator$2(this, function (_a) {
1071
+ if (this.queue.length === 0) {
1072
+ return [2 /*return*/];
1073
+ }
1074
+ eventsData = this.queue.slice();
1075
+ this.queue = [];
1076
+ data = json_nd_1.NdJson.stringify(eventsData);
1077
+ return [2 /*return*/, this.makeHttpRequest(data)];
1078
+ });
1079
+ });
1080
+ };
1046
1081
  ThrottledEventsLogger.prototype.makeHttpRequest = function (data) {
1047
1082
  return __awaiter$2(this, void 0, void 0, function () {
1048
1083
  var _this = this;
@@ -1162,7 +1197,7 @@
1162
1197
  this.__notifier = {
1163
1198
  name: '@honeybadger-io/core',
1164
1199
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
1165
- version: '6.10.1'
1200
+ version: '6.11.1'
1166
1201
  };
1167
1202
  this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
1168
1203
  this.__initStore();
@@ -1381,6 +1416,13 @@
1381
1416
  }
1382
1417
  this.__eventsLogger.log(__assign$1({ event_type: type, ts: new Date().toISOString() }, data));
1383
1418
  };
1419
+ /**
1420
+ * This method currently flushes the event (Insights) queue.
1421
+ * In the future, it should also flush the error queue (assuming an error throttler is implemented).
1422
+ */
1423
+ Client.prototype.flushAsync = function () {
1424
+ return this.__eventsLogger.flushAsync();
1425
+ };
1384
1426
  Client.prototype.__getBreadcrumbs = function () {
1385
1427
  return this.__store.getContents('breadcrumbs').slice();
1386
1428
  };
@@ -2676,7 +2718,7 @@
2676
2718
  var NOTIFIER = {
2677
2719
  name: '@honeybadger-io/js',
2678
2720
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
2679
- version: '6.10.1'
2721
+ version: '6.11.1'
2680
2722
  };
2681
2723
  var userAgent = function () {
2682
2724
  if (typeof navigator !== 'undefined') {