@honeybadger-io/js 4.1.2 → 4.1.3

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.
@@ -223,22 +223,49 @@ var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (this
223
223
  step((generator = generator.apply(thisArg, _arguments || [])).next());
224
224
  });
225
225
  };
226
+ var __generator$1 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
227
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
228
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
229
+ function verb(n) { return function (v) { return step([n, v]); }; }
230
+ function step(op) {
231
+ if (f) throw new TypeError("Generator is already executing.");
232
+ while (_) try {
233
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
234
+ if (y = 0, t) op = [op[0] & 2, t.value];
235
+ switch (op[0]) {
236
+ case 0: case 1: t = op; break;
237
+ case 4: _.label++; return { value: op[1], done: false };
238
+ case 5: _.label++; y = op[1]; op = [0]; continue;
239
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
240
+ default:
241
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
242
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
243
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
244
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
245
+ if (t[2]) _.ops.pop();
246
+ _.trys.pop(); continue;
247
+ }
248
+ op = body.call(thisArg, _);
249
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
250
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
251
+ }
252
+ };
226
253
  Object.defineProperty(util$1, "__esModule", { value: true });
227
254
  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;
228
- const stackTraceParser = __importStar(require$$0);
255
+ var stackTraceParser = __importStar(require$$0);
229
256
  function merge(obj1, obj2) {
230
- const result = {};
231
- for (const k in obj1) {
257
+ var result = {};
258
+ for (var k in obj1) {
232
259
  result[k] = obj1[k];
233
260
  }
234
- for (const k in obj2) {
261
+ for (var k in obj2) {
235
262
  result[k] = obj2[k];
236
263
  }
237
264
  return result;
238
265
  }
239
266
  util$1.merge = merge;
240
267
  function mergeNotice(notice1, notice2) {
241
- const result = merge(notice1, notice2);
268
+ var result = merge(notice1, notice2);
242
269
  if (notice1.context && notice2.context) {
243
270
  result.context = merge(notice1.context, notice2.context);
244
271
  }
@@ -246,7 +273,7 @@ function mergeNotice(notice1, notice2) {
246
273
  }
247
274
  util$1.mergeNotice = mergeNotice;
248
275
  function objectIsEmpty(obj) {
249
- for (const k in obj) {
276
+ for (var k in obj) {
250
277
  if (Object.prototype.hasOwnProperty.call(obj, k)) {
251
278
  return false;
252
279
  }
@@ -261,11 +288,12 @@ function objectIsExtensible(obj) {
261
288
  return Object.isExtensible(obj);
262
289
  }
263
290
  util$1.objectIsExtensible = objectIsExtensible;
264
- function makeBacktrace(stack, shift = 0) {
291
+ function makeBacktrace(stack, shift) {
292
+ if (shift === void 0) { shift = 0; }
265
293
  try {
266
- const backtrace = stackTraceParser
294
+ var backtrace = stackTraceParser
267
295
  .parse(stack)
268
- .map(line => {
296
+ .map(function (line) {
269
297
  return {
270
298
  file: line.file,
271
299
  method: line.methodName,
@@ -284,8 +312,8 @@ function makeBacktrace(stack, shift = 0) {
284
312
  util$1.makeBacktrace = makeBacktrace;
285
313
  function getCauses(notice) {
286
314
  if (notice.cause) {
287
- const causes = [];
288
- let cause = notice;
315
+ var causes = [];
316
+ var cause = notice;
289
317
  while (causes.length < 3 && (cause = cause.cause)) {
290
318
  causes.push({
291
319
  class: cause.name,
@@ -299,26 +327,36 @@ function getCauses(notice) {
299
327
  }
300
328
  util$1.getCauses = getCauses;
301
329
  function getSourceForBacktrace(backtrace, getSourceFileHandler) {
302
- return __awaiter$1(this, void 0, void 0, function* () {
303
- const result = [];
304
- if (!getSourceFileHandler || !backtrace || !backtrace.length) {
305
- return result;
306
- }
307
- let index = 0;
308
- while (backtrace.length) {
309
- const trace = backtrace.splice(0)[index];
310
- const fileContent = yield getSourceFileHandler(trace.file);
311
- result[index] = getSourceCodeSnippet(fileContent, trace.number);
312
- index++;
313
- }
314
- return result;
330
+ return __awaiter$1(this, void 0, void 0, function () {
331
+ var result, index, trace, fileContent;
332
+ return __generator$1(this, function (_a) {
333
+ switch (_a.label) {
334
+ case 0:
335
+ result = [];
336
+ if (!getSourceFileHandler || !backtrace || !backtrace.length) {
337
+ return [2 /*return*/, result];
338
+ }
339
+ index = 0;
340
+ _a.label = 1;
341
+ case 1:
342
+ if (!backtrace.length) return [3 /*break*/, 3];
343
+ trace = backtrace.splice(0)[index];
344
+ return [4 /*yield*/, getSourceFileHandler(trace.file)];
345
+ case 2:
346
+ fileContent = _a.sent();
347
+ result[index] = getSourceCodeSnippet(fileContent, trace.number);
348
+ index++;
349
+ return [3 /*break*/, 1];
350
+ case 3: return [2 /*return*/, result];
351
+ }
352
+ });
315
353
  });
316
354
  }
317
355
  util$1.getSourceForBacktrace = getSourceForBacktrace;
318
356
  function runBeforeNotifyHandlers(notice, handlers) {
319
- let result = true;
320
- for (let i = 0, len = handlers.length; i < len; i++) {
321
- const handler = handlers[i];
357
+ var result = true;
358
+ for (var i = 0, len = handlers.length; i < len; i++) {
359
+ var handler = handlers[i];
322
360
  if (handler(notice) === false) {
323
361
  result = false;
324
362
  }
@@ -330,7 +368,7 @@ function runAfterNotifyHandlers(notice, handlers, error) {
330
368
  if (notice && notice.afterNotify) {
331
369
  notice.afterNotify(error, notice);
332
370
  }
333
- for (let i = 0, len = handlers.length; i < len; i++) {
371
+ for (var i = 0, len = handlers.length; i < len; i++) {
334
372
  handlers[i](error, notice);
335
373
  }
336
374
  return true;
@@ -341,21 +379,22 @@ function shallowClone(obj) {
341
379
  if (typeof (obj) !== 'object' || obj === null) {
342
380
  return {};
343
381
  }
344
- const result = {};
345
- for (const k in obj) {
382
+ var result = {};
383
+ for (var k in obj) {
346
384
  result[k] = obj[k];
347
385
  }
348
386
  return result;
349
387
  }
350
388
  util$1.shallowClone = shallowClone;
351
- function sanitize$1(obj, maxDepth = 8) {
352
- const seenObjects = [];
389
+ function sanitize$1(obj, maxDepth) {
390
+ if (maxDepth === void 0) { maxDepth = 8; }
391
+ var seenObjects = [];
353
392
  function seen(obj) {
354
393
  if (!obj || typeof (obj) !== 'object') {
355
394
  return false;
356
395
  }
357
- for (let i = 0; i < seenObjects.length; i++) {
358
- const value = seenObjects[i];
396
+ for (var i = 0; i < seenObjects.length; i++) {
397
+ var value = seenObjects[i];
359
398
  if (value === obj) {
360
399
  return true;
361
400
  }
@@ -364,7 +403,7 @@ function sanitize$1(obj, maxDepth = 8) {
364
403
  return false;
365
404
  }
366
405
  function canSerialize(obj) {
367
- const typeOfObj = typeof obj;
406
+ var typeOfObj = typeof obj;
368
407
  // Functions are TMI
369
408
  if (/function/.test(typeOfObj)) {
370
409
  // Let special toJSON method pass as it's used by JSON.stringify (#722)
@@ -383,7 +422,8 @@ function sanitize$1(obj, maxDepth = 8) {
383
422
  }
384
423
  return true;
385
424
  }
386
- function serialize(obj, depth = 0) {
425
+ function serialize(obj, depth) {
426
+ if (depth === void 0) { depth = 0; }
387
427
  if (depth >= maxDepth) {
388
428
  return '[DEPTH]';
389
429
  }
@@ -397,13 +437,13 @@ function sanitize$1(obj, maxDepth = 8) {
397
437
  }
398
438
  // Serialize inside arrays
399
439
  if (Array.isArray(obj)) {
400
- return obj.map(o => safeSerialize(o, depth + 1));
440
+ return obj.map(function (o) { return safeSerialize(o, depth + 1); });
401
441
  }
402
442
  // Serialize inside objects
403
443
  if (typeof (obj) === 'object') {
404
- const ret = {};
405
- for (const k in obj) {
406
- const v = obj[k];
444
+ var ret = {};
445
+ for (var k in obj) {
446
+ var v = obj[k];
407
447
  if (Object.prototype.hasOwnProperty.call(obj, k) && (k != null) && (v != null)) {
408
448
  ret[k] = safeSerialize(v, depth + 1);
409
449
  }
@@ -413,20 +453,26 @@ function sanitize$1(obj, maxDepth = 8) {
413
453
  // Return everything else untouched
414
454
  return obj;
415
455
  }
416
- function safeSerialize(obj, depth = 0) {
456
+ function safeSerialize(obj, depth) {
457
+ if (depth === void 0) { depth = 0; }
417
458
  try {
418
459
  return serialize(obj, depth);
419
460
  }
420
461
  catch (e) {
421
- return `[ERROR] ${e}`;
462
+ return "[ERROR] ".concat(e);
422
463
  }
423
464
  }
424
465
  return safeSerialize(obj);
425
466
  }
426
467
  util$1.sanitize = sanitize$1;
427
468
  function logger(client) {
428
- const log = (method) => {
429
- return function (...args) {
469
+ var log = function (method) {
470
+ return function () {
471
+ var _a;
472
+ var args = [];
473
+ for (var _i = 0; _i < arguments.length; _i++) {
474
+ args[_i] = arguments[_i];
475
+ }
430
476
  if (method === 'debug') {
431
477
  if (!client.config.debug) {
432
478
  return;
@@ -436,7 +482,7 @@ function logger(client) {
436
482
  method = 'log';
437
483
  }
438
484
  args.unshift('[Honeybadger]');
439
- client.config.logger[method](...args);
485
+ (_a = client.config.logger)[method].apply(_a, args);
440
486
  };
441
487
  };
442
488
  return {
@@ -453,19 +499,19 @@ util$1.logger = logger;
453
499
  * properties as Error, but supports additional Honeybadger properties.)
454
500
  */
455
501
  function makeNotice(thing) {
456
- let notice;
502
+ var notice;
457
503
  if (!thing) {
458
504
  notice = {};
459
505
  }
460
506
  else if (isErrorObject(thing)) {
461
- const e = thing;
507
+ var e = thing;
462
508
  notice = merge(thing, { name: e.name, message: e.message, stack: e.stack, cause: e.cause });
463
509
  }
464
510
  else if (typeof thing === 'object') {
465
511
  notice = shallowClone(thing);
466
512
  }
467
513
  else {
468
- const m = String(thing);
514
+ var m = String(thing);
469
515
  notice = { message: m };
470
516
  }
471
517
  return notice;
@@ -487,7 +533,7 @@ function instrument(object, name, replacement) {
487
533
  if (!object || !name || !replacement || !(name in object)) {
488
534
  return;
489
535
  }
490
- let original = object[name];
536
+ var original = object[name];
491
537
  while (original && original.__hb_original) {
492
538
  original = original.__hb_original;
493
539
  }
@@ -503,9 +549,9 @@ function instrument(object, name, replacement) {
503
549
  }
504
550
  util$1.instrument = instrument;
505
551
  function endpoint$1(base, path) {
506
- const endpoint = base.trim().replace(/\/$/, '');
552
+ var endpoint = base.trim().replace(/\/$/, '');
507
553
  path = path.trim().replace(/(^\/|\/$)/g, '');
508
- return `${endpoint}/${path}`;
554
+ return "".concat(endpoint, "/").concat(path);
509
555
  }
510
556
  util$1.endpoint = endpoint$1;
511
557
  function generateStackTrace() {
@@ -517,9 +563,9 @@ function generateStackTrace() {
517
563
  return e.stack;
518
564
  }
519
565
  }
520
- const maxStackSize = 10;
521
- const stack = [];
522
- let curr = arguments.callee;
566
+ var maxStackSize = 10;
567
+ var stack = [];
568
+ var curr = arguments.callee;
523
569
  while (curr && stack.length < maxStackSize) {
524
570
  if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
525
571
  stack.push(RegExp.$1 || '<anonymous>');
@@ -544,9 +590,9 @@ function filter(obj, filters) {
544
590
  if (!is('Array', filters)) {
545
591
  filters = [];
546
592
  }
547
- const seen = [];
593
+ var seen = [];
548
594
  function filter(obj) {
549
- let k, newObj;
595
+ var k, newObj;
550
596
  if (is('Object', obj) || is('Array', obj)) {
551
597
  if (seen.indexOf(obj) !== -1) {
552
598
  return '[CIRCULAR DATA STRUCTURE]';
@@ -579,7 +625,7 @@ function filter(obj, filters) {
579
625
  }
580
626
  util$1.filter = filter;
581
627
  function filterMatch(key, filters) {
582
- for (let i = 0; i < filters.length; i++) {
628
+ for (var i = 0; i < filters.length; i++) {
583
629
  if (key.toLowerCase().indexOf(filters[i].toLowerCase()) !== -1) {
584
630
  return true;
585
631
  }
@@ -587,7 +633,7 @@ function filterMatch(key, filters) {
587
633
  return false;
588
634
  }
589
635
  function is(type, obj) {
590
- const klass = Object.prototype.toString.call(obj).slice(8, -1);
636
+ var klass = Object.prototype.toString.call(obj).slice(8, -1);
591
637
  return obj !== undefined && obj !== null && klass === type;
592
638
  }
593
639
  function filterUrl(url, filters) {
@@ -597,24 +643,25 @@ function filterUrl(url, filters) {
597
643
  if (typeof url !== 'string') {
598
644
  return url;
599
645
  }
600
- const query = url.split(/\?/, 2)[1];
646
+ var query = url.split(/\?/, 2)[1];
601
647
  if (!query) {
602
648
  return url;
603
649
  }
604
- let result = url;
605
- query.split(/[&]\s?/).forEach((pair) => {
606
- const [key, value] = pair.split('=', 2);
650
+ var result = url;
651
+ query.split(/[&]\s?/).forEach(function (pair) {
652
+ var _a = pair.split('=', 2), key = _a[0], value = _a[1];
607
653
  if (filterMatch(key, filters)) {
608
- result = result.replace(`${key}=${value}`, `${key}=[FILTERED]`);
654
+ result = result.replace("".concat(key, "=").concat(value), "".concat(key, "=[FILTERED]"));
609
655
  }
610
656
  });
611
657
  return result;
612
658
  }
613
659
  util$1.filterUrl = filterUrl;
614
- function formatCGIData(vars, prefix = '') {
615
- const formattedVars = {};
660
+ function formatCGIData(vars, prefix) {
661
+ if (prefix === void 0) { prefix = ''; }
662
+ var formattedVars = {};
616
663
  Object.keys(vars).forEach(function (key) {
617
- const formattedKey = prefix + key.replace(/\W/g, '_').toUpperCase();
664
+ var formattedKey = prefix + key.replace(/\W/g, '_').toUpperCase();
618
665
  formattedVars[formattedKey] = vars[key];
619
666
  });
620
667
  return formattedVars;
@@ -624,18 +671,19 @@ function clone(obj) {
624
671
  return JSON.parse(JSON.stringify(obj));
625
672
  }
626
673
  util$1.clone = clone;
627
- function getSourceCodeSnippet(fileData, lineNumber, sourceRadius = 2) {
674
+ function getSourceCodeSnippet(fileData, lineNumber, sourceRadius) {
675
+ if (sourceRadius === void 0) { sourceRadius = 2; }
628
676
  if (!fileData) {
629
677
  return null;
630
678
  }
631
- const lines = fileData.split('\n');
679
+ var lines = fileData.split('\n');
632
680
  // add one empty line because array index starts from 0, but error line number is counted from 1
633
681
  lines.unshift('');
634
- const start = lineNumber - sourceRadius;
635
- const end = lineNumber + sourceRadius;
636
- const result = {};
637
- for (let i = start; i <= end; i++) {
638
- const line = lines[i];
682
+ var start = lineNumber - sourceRadius;
683
+ var end = lineNumber + sourceRadius;
684
+ var result = {};
685
+ for (var i = start; i <= end; i++) {
686
+ var line = lines[i];
639
687
  if (typeof line === 'string') {
640
688
  result[i] = line;
641
689
  }
@@ -651,80 +699,99 @@ var store = {};
651
699
 
652
700
  Object.defineProperty(store, "__esModule", { value: true });
653
701
  store.GlobalStore = void 0;
654
- class GlobalStore {
655
- constructor(store) {
702
+ var GlobalStore = /** @class */ (function () {
703
+ function GlobalStore(store) {
656
704
  this.store = store;
657
705
  }
658
- getStore() {
706
+ GlobalStore.prototype.getStore = function () {
659
707
  return this.store;
660
- }
661
- run(store, callback, ...args) {
708
+ };
709
+ GlobalStore.prototype.run = function (store, callback) {
710
+ var args = [];
711
+ for (var _i = 2; _i < arguments.length; _i++) {
712
+ args[_i - 2] = arguments[_i];
713
+ }
662
714
  this.store = store;
663
- return callback(...args);
664
- }
665
- }
715
+ return callback.apply(void 0, args);
716
+ };
717
+ return GlobalStore;
718
+ }());
666
719
  store.GlobalStore = GlobalStore;
667
720
 
721
+ var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
722
+ __assign$1 = Object.assign || function(t) {
723
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
724
+ s = arguments[i];
725
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
726
+ t[p] = s[p];
727
+ }
728
+ return t;
729
+ };
730
+ return __assign$1.apply(this, arguments);
731
+ };
668
732
  Object.defineProperty(client, "__esModule", { value: true });
669
733
  client.Client = void 0;
670
- const util_1$4 = util$1;
671
- const store_1 = store;
672
- const notifier = {
734
+ var util_1$4 = util$1;
735
+ var store_1 = store;
736
+ var notifier = {
673
737
  name: 'honeybadger-js',
674
738
  url: 'https://github.com/honeybadger-io/honeybadger-js',
675
- version: '4.1.2'
739
+ version: '4.1.3'
676
740
  };
677
741
  // Split at commas and spaces
678
- const TAG_SEPARATOR = /,|\s+/;
742
+ var TAG_SEPARATOR = /,|\s+/;
679
743
  // Checks for non-blank characters
680
- const NOT_BLANK = /\S/;
681
- class Client {
682
- constructor(opts = {}, transport) {
744
+ var NOT_BLANK = /\S/;
745
+ var Client = /** @class */ (function () {
746
+ function Client(opts, transport) {
747
+ if (opts === void 0) { opts = {}; }
683
748
  this.__pluginsExecuted = false;
684
749
  this.__store = null;
685
750
  this.__beforeNotifyHandlers = [];
686
751
  this.__afterNotifyHandlers = [];
687
- this.config = Object.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: () => true, filters: ['creditcard', 'password'], __plugins: [] }, opts);
752
+ 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);
688
753
  // First, we go with the global (shared) store.
689
754
  // Webserver middleware can then switch to the AsyncStore for async context tracking.
690
755
  this.__store = new store_1.GlobalStore({ context: {}, breadcrumbs: [] });
691
756
  this.__transport = transport;
692
757
  this.logger = (0, util_1$4.logger)(this);
693
758
  }
694
- getVersion() {
759
+ Client.prototype.getVersion = function () {
695
760
  return notifier.version;
696
- }
697
- configure(opts = {}) {
698
- for (const k in opts) {
761
+ };
762
+ Client.prototype.configure = function (opts) {
763
+ var _this = this;
764
+ if (opts === void 0) { opts = {}; }
765
+ for (var k in opts) {
699
766
  this.config[k] = opts[k];
700
767
  }
701
768
  if (!this.__pluginsExecuted) {
702
769
  this.__pluginsExecuted = true;
703
- this.config.__plugins.forEach((plugin) => plugin.load(this));
770
+ this.config.__plugins.forEach(function (plugin) { return plugin.load(_this); });
704
771
  }
705
772
  return this;
706
- }
707
- __setStore(store) {
773
+ };
774
+ Client.prototype.__setStore = function (store) {
708
775
  this.__store = store;
709
- }
710
- beforeNotify(handler) {
776
+ };
777
+ Client.prototype.beforeNotify = function (handler) {
711
778
  this.__beforeNotifyHandlers.push(handler);
712
779
  return this;
713
- }
714
- afterNotify(handler) {
780
+ };
781
+ Client.prototype.afterNotify = function (handler) {
715
782
  this.__afterNotifyHandlers.push(handler);
716
783
  return this;
717
- }
718
- setContext(context) {
784
+ };
785
+ Client.prototype.setContext = function (context) {
719
786
  if (typeof context === 'object') {
720
- const store = this.__store.getStore();
787
+ var store = this.__store.getStore();
721
788
  store.context = (0, util_1$4.merge)(store.context, context);
722
789
  }
723
790
  return this;
724
- }
725
- resetContext(context) {
791
+ };
792
+ Client.prototype.resetContext = function (context) {
726
793
  this.logger.warn('Deprecation warning: `Honeybadger.resetContext()` has been deprecated; please use `Honeybadger.clear()` instead.');
727
- const store = this.__store.getStore();
794
+ var store = this.__store.getStore();
728
795
  if (typeof context === 'object' && context !== null) {
729
796
  store.context = context;
730
797
  }
@@ -732,16 +799,19 @@ class Client {
732
799
  store.context = {};
733
800
  }
734
801
  return this;
735
- }
736
- clear() {
737
- const store = this.__store.getStore();
802
+ };
803
+ Client.prototype.clear = function () {
804
+ var store = this.__store.getStore();
738
805
  store.context = {};
739
806
  store.breadcrumbs = [];
740
807
  return this;
741
- }
742
- notify(noticeable, name = undefined, extra = undefined) {
743
- let preConditionError = null;
744
- const notice = this.makeNotice(noticeable, name, extra);
808
+ };
809
+ Client.prototype.notify = function (noticeable, name, extra) {
810
+ var _this = this;
811
+ if (name === void 0) { name = undefined; }
812
+ if (extra === void 0) { extra = undefined; }
813
+ var preConditionError = null;
814
+ var notice = this.makeNotice(noticeable, name, extra);
745
815
  if (!notice) {
746
816
  this.logger.debug('failed to build error report');
747
817
  preConditionError = new Error('failed to build error report');
@@ -760,8 +830,8 @@ class Client {
760
830
  }
761
831
  // we need to have the source file data before the beforeNotifyHandlers,
762
832
  // in case they modify them
763
- const sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(trace => (0, util_1$4.shallowClone)(trace)) : null;
764
- const beforeNotifyResult = (0, util_1$4.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
833
+ var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$4.shallowClone)(trace); }) : null;
834
+ var beforeNotifyResult = (0, util_1$4.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
765
835
  if (!preConditionError && !beforeNotifyResult) {
766
836
  this.logger.debug('skipping error report: beforeNotify handlers returned false', notice);
767
837
  preConditionError = new Error('beforeNotify handlers returned false');
@@ -778,58 +848,61 @@ class Client {
778
848
  stack: notice.stack
779
849
  }
780
850
  });
781
- const breadcrumbs = this.__getStoreContentsOrDefault().breadcrumbs;
851
+ var breadcrumbs = this.__getStoreContentsOrDefault().breadcrumbs;
782
852
  notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs.slice() : [];
783
853
  (0, util_1$4.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
784
- .then(sourcePerTrace => {
785
- sourcePerTrace.forEach((source, index) => {
854
+ .then(function (sourcePerTrace) {
855
+ sourcePerTrace.forEach(function (source, index) {
786
856
  notice.backtrace[index].source = source;
787
857
  });
788
- const payload = this.__buildPayload(notice);
789
- this.__transport
858
+ var payload = _this.__buildPayload(notice);
859
+ _this.__transport
790
860
  .send({
791
861
  headers: {
792
- 'X-API-Key': this.config.apiKey,
862
+ 'X-API-Key': _this.config.apiKey,
793
863
  'Content-Type': 'application/json',
794
864
  'Accept': 'text/json, application/json'
795
865
  },
796
866
  method: 'POST',
797
- endpoint: (0, util_1$4.endpoint)(this.config.endpoint, '/v1/notices/js'),
798
- maxObjectDepth: this.config.maxObjectDepth,
799
- logger: this.logger,
800
- async: (0, util_1$4.isBrowserConfig)(this.config) ? this.config.async : undefined,
867
+ endpoint: (0, util_1$4.endpoint)(_this.config.endpoint, '/v1/notices/js'),
868
+ maxObjectDepth: _this.config.maxObjectDepth,
869
+ logger: _this.logger,
870
+ async: (0, util_1$4.isBrowserConfig)(_this.config) ? _this.config.async : undefined,
801
871
  }, payload)
802
- .then(res => {
872
+ .then(function (res) {
803
873
  if (res.statusCode !== 201) {
804
- (0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, new Error(`Bad HTTP response: ${res.statusCode}`));
805
- this.logger.warn(`Error report failed: unknown response from server. code=${res.statusCode}`);
874
+ (0, util_1$4.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode)));
875
+ _this.logger.warn("Error report failed: unknown response from server. code=".concat(res.statusCode));
806
876
  return;
807
877
  }
808
- const uuid = JSON.parse(res.body).id;
878
+ var uuid = JSON.parse(res.body).id;
809
879
  (0, util_1$4.runAfterNotifyHandlers)((0, util_1$4.merge)(notice, {
810
880
  id: uuid
811
- }), this.__afterNotifyHandlers);
812
- this.logger.info(`Error report sent https://app.honeybadger.io/notice/${uuid}`);
881
+ }), _this.__afterNotifyHandlers);
882
+ _this.logger.info("Error report sent \u26A1 https://app.honeybadger.io/notice/".concat(uuid));
813
883
  })
814
- .catch(err => {
815
- this.logger.error('Error report failed: an unknown error occurred.', `message=${err.message}`);
816
- (0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, err);
884
+ .catch(function (err) {
885
+ _this.logger.error('Error report failed: an unknown error occurred.', "message=".concat(err.message));
886
+ (0, util_1$4.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, err);
817
887
  });
818
888
  });
819
889
  return true;
820
- }
890
+ };
821
891
  /**
822
892
  * An async version of {@link notify} that resolves only after the notice has been reported to Honeybadger.
823
893
  * Implemented using the {@link afterNotify} hook.
824
894
  * Rejects if for any reason the report failed to be reported.
825
895
  * Useful in serverless environments (AWS Lambda).
826
896
  */
827
- notifyAsync(noticeable, name = undefined, extra = undefined) {
828
- return new Promise((resolve, reject) => {
829
- const applyAfterNotify = (partialNotice) => {
830
- const originalAfterNotify = partialNotice.afterNotify;
831
- partialNotice.afterNotify = (err) => {
832
- originalAfterNotify === null || originalAfterNotify === void 0 ? void 0 : originalAfterNotify.call(this, err);
897
+ Client.prototype.notifyAsync = function (noticeable, name, extra) {
898
+ var _this = this;
899
+ if (name === void 0) { name = undefined; }
900
+ if (extra === void 0) { extra = undefined; }
901
+ return new Promise(function (resolve, reject) {
902
+ var applyAfterNotify = function (partialNotice) {
903
+ var originalAfterNotify = partialNotice.afterNotify;
904
+ partialNotice.afterNotify = function (err) {
905
+ originalAfterNotify === null || originalAfterNotify === void 0 ? void 0 : originalAfterNotify.call(_this, err);
833
906
  if (err) {
834
907
  return reject(err);
835
908
  }
@@ -837,7 +910,7 @@ class Client {
837
910
  };
838
911
  };
839
912
  // We have to respect any afterNotify hooks that come from the arguments
840
- let objectToOverride;
913
+ var objectToOverride;
841
914
  if (noticeable.afterNotify) {
842
915
  objectToOverride = noticeable;
843
916
  }
@@ -857,13 +930,15 @@ class Client {
857
930
  objectToOverride = name = {};
858
931
  }
859
932
  applyAfterNotify(objectToOverride);
860
- this.notify(noticeable, name, extra);
933
+ _this.notify(noticeable, name, extra);
861
934
  });
862
- }
863
- makeNotice(noticeable, name = undefined, extra = undefined) {
864
- let notice = (0, util_1$4.makeNotice)(noticeable);
935
+ };
936
+ Client.prototype.makeNotice = function (noticeable, name, extra) {
937
+ if (name === void 0) { name = undefined; }
938
+ if (extra === void 0) { extra = undefined; }
939
+ var notice = (0, util_1$4.makeNotice)(noticeable);
865
940
  if (name && !(typeof name === 'object')) {
866
- const n = String(name);
941
+ var n = String(name);
867
942
  name = { name: n };
868
943
  }
869
944
  if (name) {
@@ -875,13 +950,13 @@ class Client {
875
950
  if ((0, util_1$4.objectIsEmpty)(notice)) {
876
951
  return null;
877
952
  }
878
- const context = this.__getStoreContentsOrDefault().context;
879
- const noticeTags = this.__constructTags(notice.tags);
880
- const contextTags = this.__constructTags(context['tags']);
881
- const configTags = this.__constructTags(this.config.tags);
953
+ var context = this.__getStoreContentsOrDefault().context;
954
+ var noticeTags = this.__constructTags(notice.tags);
955
+ var contextTags = this.__constructTags(context['tags']);
956
+ var configTags = this.__constructTags(this.config.tags);
882
957
  // Turning into a Set will remove duplicates
883
- const tags = noticeTags.concat(contextTags).concat(configTags);
884
- const uniqueTags = tags.filter((item, index) => tags.indexOf(item) === index);
958
+ var tags = noticeTags.concat(contextTags).concat(configTags);
959
+ var uniqueTags = tags.filter(function (item, index) { return tags.indexOf(item) === index; });
885
960
  notice = (0, util_1$4.merge)(notice, {
886
961
  name: notice.name || 'Error',
887
962
  context: (0, util_1$4.merge)(context, notice.context),
@@ -892,46 +967,46 @@ class Client {
892
967
  revision: notice.revision || this.config.revision,
893
968
  tags: uniqueTags,
894
969
  });
895
- let backtraceShift = 0;
970
+ var backtraceShift = 0;
896
971
  if (typeof notice.stack !== 'string' || !notice.stack.trim()) {
897
972
  notice.stack = (0, util_1$4.generateStackTrace)();
898
973
  backtraceShift = 2;
899
974
  }
900
975
  notice.backtrace = (0, util_1$4.makeBacktrace)(notice.stack, backtraceShift);
901
976
  return notice;
902
- }
903
- addBreadcrumb(message, opts) {
977
+ };
978
+ Client.prototype.addBreadcrumb = function (message, opts) {
904
979
  if (!this.config.breadcrumbsEnabled) {
905
980
  return;
906
981
  }
907
982
  opts = opts || {};
908
- const metadata = (0, util_1$4.shallowClone)(opts.metadata);
909
- const category = opts.category || 'custom';
910
- const timestamp = new Date().toISOString();
911
- const store = this.__store.getStore();
912
- let breadcrumbs = store.breadcrumbs;
983
+ var metadata = (0, util_1$4.shallowClone)(opts.metadata);
984
+ var category = opts.category || 'custom';
985
+ var timestamp = new Date().toISOString();
986
+ var store = this.__store.getStore();
987
+ var breadcrumbs = store.breadcrumbs;
913
988
  breadcrumbs.push({
914
989
  category: category,
915
990
  message: message,
916
991
  metadata: metadata,
917
992
  timestamp: timestamp
918
993
  });
919
- const limit = this.config.maxBreadcrumbs;
994
+ var limit = this.config.maxBreadcrumbs;
920
995
  if (breadcrumbs.length > limit) {
921
996
  breadcrumbs = breadcrumbs.slice(breadcrumbs.length - limit);
922
997
  }
923
998
  store.breadcrumbs = breadcrumbs;
924
999
  return this;
925
- }
926
- __developmentMode() {
1000
+ };
1001
+ Client.prototype.__developmentMode = function () {
927
1002
  if (this.config.reportData === true) {
928
1003
  return false;
929
1004
  }
930
1005
  return (this.config.environment && this.config.developmentEnvironments.includes(this.config.environment));
931
- }
932
- __buildPayload(notice) {
933
- const headers = (0, util_1$4.filter)(notice.headers, this.config.filters) || {};
934
- const cgiData = (0, util_1$4.filter)(Object.assign(Object.assign({}, notice.cgiData), (0, util_1$4.formatCGIData)(headers, 'HTTP_')), this.config.filters);
1006
+ };
1007
+ Client.prototype.__buildPayload = function (notice) {
1008
+ var headers = (0, util_1$4.filter)(notice.headers, this.config.filters) || {};
1009
+ var cgiData = (0, util_1$4.filter)(__assign$1(__assign$1({}, notice.cgiData), (0, util_1$4.formatCGIData)(headers, 'HTTP_')), this.config.filters);
935
1010
  return {
936
1011
  notifier: notifier,
937
1012
  breadcrumbs: {
@@ -964,24 +1039,25 @@ class Client {
964
1039
  },
965
1040
  details: notice.details || {}
966
1041
  };
967
- }
968
- __constructTags(tags) {
1042
+ };
1043
+ Client.prototype.__constructTags = function (tags) {
969
1044
  if (!tags) {
970
1045
  return [];
971
1046
  }
972
- return tags.toString().split(TAG_SEPARATOR).filter((tag) => NOT_BLANK.test(tag));
973
- }
1047
+ return tags.toString().split(TAG_SEPARATOR).filter(function (tag) { return NOT_BLANK.test(tag); });
1048
+ };
974
1049
  /**
975
1050
  * For ALS, the store may be uninitialized (if .run()` has not been called).
976
1051
  * This provides an easy way to read the existing store object or fall back to a default.
977
1052
  * Returns *a copy* of the s tore contents.
978
1053
  */
979
- __getStoreContentsOrDefault() {
980
- const existingStoreContents = this.__store.getStore();
981
- const storeContents = existingStoreContents || {};
982
- return Object.assign({ context: {}, breadcrumbs: [] }, storeContents);
983
- }
984
- }
1054
+ Client.prototype.__getStoreContentsOrDefault = function () {
1055
+ var existingStoreContents = this.__store.getStore();
1056
+ var storeContents = existingStoreContents || {};
1057
+ return __assign$1({ context: {}, breadcrumbs: [] }, storeContents);
1058
+ };
1059
+ return Client;
1060
+ }());
985
1061
  client.Client = Client;
986
1062
 
987
1063
  var types = {};
@@ -1032,15 +1108,42 @@ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisAr
1032
1108
  step((generator = generator.apply(thisArg, _arguments || [])).next());
1033
1109
  });
1034
1110
  };
1111
+ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
1112
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
1113
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1114
+ function verb(n) { return function (v) { return step([n, v]); }; }
1115
+ function step(op) {
1116
+ if (f) throw new TypeError("Generator is already executing.");
1117
+ while (_) try {
1118
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1119
+ if (y = 0, t) op = [op[0] & 2, t.value];
1120
+ switch (op[0]) {
1121
+ case 0: case 1: t = op; break;
1122
+ case 4: _.label++; return { value: op[1], done: false };
1123
+ case 5: _.label++; y = op[1]; op = [0]; continue;
1124
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
1125
+ default:
1126
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
1127
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
1128
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
1129
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
1130
+ if (t[2]) _.ops.pop();
1131
+ _.trys.pop(); continue;
1132
+ }
1133
+ op = body.call(thisArg, _);
1134
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
1135
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
1136
+ }
1137
+ };
1035
1138
  var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1036
1139
  return (mod && mod.__esModule) ? mod : { "default": mod };
1037
1140
  };
1038
1141
  Object.defineProperty(util, "__esModule", { value: true });
1039
1142
  util.getSourceFile = util.getStats = util.fatallyLogAndExit = void 0;
1040
- const os_1$1 = __importDefault$3(require$$0__default["default"]);
1041
- const fs_1 = __importDefault$3(require$$1__default["default"]);
1042
- const util_1$3 = require$$2__default["default"];
1043
- const readFile = (0, util_1$3.promisify)(fs_1.default.readFile);
1143
+ var os_1$1 = __importDefault$3(require$$0__default["default"]);
1144
+ var fs_1 = __importDefault$3(require$$1__default["default"]);
1145
+ var util_1$3 = require$$2__default["default"];
1146
+ var readFile = (0, util_1$3.promisify)(fs_1.default.readFile);
1044
1147
  function fatallyLogAndExit(err) {
1045
1148
  console.error('[Honeybadger] Exiting process due to uncaught exception');
1046
1149
  console.error(err.stack || err);
@@ -1048,46 +1151,58 @@ function fatallyLogAndExit(err) {
1048
1151
  }
1049
1152
  util.fatallyLogAndExit = fatallyLogAndExit;
1050
1153
  function getStats() {
1051
- return __awaiter(this, void 0, void 0, function* () {
1052
- const load = os_1$1.default.loadavg();
1053
- const stats = {
1054
- load: {
1055
- one: load[0],
1056
- five: load[1],
1057
- fifteen: load[2]
1058
- },
1059
- mem: {}
1060
- };
1061
- const fallback = () => {
1062
- stats.mem = {
1063
- free: os_1$1.default.freemem(),
1064
- total: os_1$1.default.totalmem()
1065
- };
1066
- };
1067
- if (!fs_1.default.existsSync('/proc/meminfo')) {
1068
- fallback();
1069
- return stats;
1070
- }
1071
- try {
1072
- const memData = yield readFile('/proc/meminfo', 'utf8');
1073
- // The first four lines, in order, are Total, Free, Buffers, Cached.
1074
- // @TODO: Figure out if there's a way to only read these lines
1075
- const data = memData.split('\n').slice(0, 4);
1076
- const results = data.map(function (i) {
1077
- return parseInt(/\s+(\d+)\skB/i.exec(i)[1], 10) / 1024.0;
1078
- });
1079
- stats.mem = {
1080
- total: results[0],
1081
- free: results[1],
1082
- buffers: results[2],
1083
- cached: results[3],
1084
- free_total: results[1] + results[2] + results[3]
1085
- };
1086
- }
1087
- catch (error) {
1088
- fallback();
1089
- }
1090
- return stats;
1154
+ return __awaiter(this, void 0, void 0, function () {
1155
+ var load, stats, fallback, memData, data, results;
1156
+ return __generator(this, function (_a) {
1157
+ switch (_a.label) {
1158
+ case 0:
1159
+ load = os_1$1.default.loadavg();
1160
+ stats = {
1161
+ load: {
1162
+ one: load[0],
1163
+ five: load[1],
1164
+ fifteen: load[2]
1165
+ },
1166
+ mem: {}
1167
+ };
1168
+ fallback = function () {
1169
+ stats.mem = {
1170
+ free: os_1$1.default.freemem(),
1171
+ total: os_1$1.default.totalmem()
1172
+ };
1173
+ };
1174
+ if (!fs_1.default.existsSync('/proc/meminfo')) {
1175
+ fallback();
1176
+ return [2 /*return*/, stats];
1177
+ }
1178
+ _a.label = 1;
1179
+ case 1:
1180
+ _a.trys.push([1, 3, , 4]);
1181
+ return [4 /*yield*/, readFile('/proc/meminfo', 'utf8')
1182
+ // The first four lines, in order, are Total, Free, Buffers, Cached.
1183
+ // @TODO: Figure out if there's a way to only read these lines
1184
+ ];
1185
+ case 2:
1186
+ memData = _a.sent();
1187
+ data = memData.split('\n').slice(0, 4);
1188
+ results = data.map(function (i) {
1189
+ return parseInt(/\s+(\d+)\skB/i.exec(i)[1], 10) / 1024.0;
1190
+ });
1191
+ stats.mem = {
1192
+ total: results[0],
1193
+ free: results[1],
1194
+ buffers: results[2],
1195
+ cached: results[3],
1196
+ free_total: results[1] + results[2] + results[3]
1197
+ };
1198
+ return [3 /*break*/, 4];
1199
+ case 3:
1200
+ _a.sent();
1201
+ fallback();
1202
+ return [3 /*break*/, 4];
1203
+ case 4: return [2 /*return*/, stats];
1204
+ }
1205
+ });
1091
1206
  });
1092
1207
  }
1093
1208
  util.getStats = getStats;
@@ -1097,13 +1212,19 @@ util.getStats = getStats;
1097
1212
  * @param path to source code
1098
1213
  */
1099
1214
  function getSourceFile(path) {
1100
- return __awaiter(this, void 0, void 0, function* () {
1101
- try {
1102
- return yield readFile(path, 'utf-8');
1103
- }
1104
- catch (_e) {
1105
- return null;
1106
- }
1215
+ return __awaiter(this, void 0, void 0, function () {
1216
+ return __generator(this, function (_a) {
1217
+ switch (_a.label) {
1218
+ case 0:
1219
+ _a.trys.push([0, 2, , 3]);
1220
+ return [4 /*yield*/, readFile(path, 'utf-8')];
1221
+ case 1: return [2 /*return*/, _a.sent()];
1222
+ case 2:
1223
+ _a.sent();
1224
+ return [2 /*return*/, null];
1225
+ case 3: return [2 /*return*/];
1226
+ }
1227
+ });
1107
1228
  });
1108
1229
  }
1109
1230
  util.getSourceFile = getSourceFile;
@@ -1116,11 +1237,11 @@ var async_store = {};
1116
1237
 
1117
1238
  Object.defineProperty(async_store, "__esModule", { value: true });
1118
1239
  async_store.AsyncStore = void 0;
1119
- const core_1$2 = src;
1120
- let Store;
1240
+ var core_1$2 = src;
1241
+ var Store;
1121
1242
  try {
1122
1243
  // eslint-disable-next-line @typescript-eslint/no-var-requires
1123
- const { AsyncLocalStorage } = require('async_hooks');
1244
+ var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage;
1124
1245
  Store = new AsyncLocalStorage();
1125
1246
  }
1126
1247
  catch (e) {
@@ -1130,7 +1251,7 @@ async_store.AsyncStore = Store;
1130
1251
 
1131
1252
  Object.defineProperty(aws_lambda, "__esModule", { value: true });
1132
1253
  aws_lambda.removeAwsDefaultUncaughtExceptionListener = aws_lambda.lambdaHandler = void 0;
1133
- const async_store_1$1 = async_store;
1254
+ var async_store_1$1 = async_store;
1134
1255
  function isHandlerSync(handler) {
1135
1256
  return handler.length > 2;
1136
1257
  }
@@ -1145,14 +1266,14 @@ function reportToHoneybadger(hb, err, callback) {
1145
1266
  function asyncHandler(handler, hb) {
1146
1267
  return function wrappedLambdaHandler(event, context) {
1147
1268
  hb.__setStore(async_store_1$1.AsyncStore);
1148
- return new Promise((resolve, reject) => {
1149
- async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, () => {
1150
- const timeoutHandler = setupTimeoutWarning(hb, context);
1269
+ return new Promise(function (resolve, reject) {
1270
+ async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, function () {
1271
+ var timeoutHandler = setupTimeoutWarning(hb, context);
1151
1272
  try {
1152
1273
  handler(event, context)
1153
1274
  .then(resolve)
1154
- .catch(err => reportToHoneybadger(hb, err, reject))
1155
- .finally(() => clearTimeout(timeoutHandler));
1275
+ .catch(function (err) { return reportToHoneybadger(hb, err, reject); })
1276
+ .finally(function () { return clearTimeout(timeoutHandler); });
1156
1277
  }
1157
1278
  catch (err) {
1158
1279
  clearTimeout(timeoutHandler);
@@ -1165,10 +1286,10 @@ function asyncHandler(handler, hb) {
1165
1286
  function syncHandler(handler, hb) {
1166
1287
  return function wrappedLambdaHandler(event, context, cb) {
1167
1288
  hb.__setStore(async_store_1$1.AsyncStore);
1168
- async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, () => {
1169
- const timeoutHandler = setupTimeoutWarning(hb, context);
1289
+ async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, function () {
1290
+ var timeoutHandler = setupTimeoutWarning(hb, context);
1170
1291
  try {
1171
- handler(event, context, (error, result) => {
1292
+ handler(event, context, function (error, result) {
1172
1293
  clearTimeout(timeoutHandler);
1173
1294
  if (error) {
1174
1295
  return reportToHoneybadger(hb, error, cb);
@@ -1190,21 +1311,21 @@ function setupTimeoutWarning(hb, context) {
1190
1311
  if (!shouldReportTimeoutWarning(hb, context)) {
1191
1312
  return;
1192
1313
  }
1193
- const delay = context.getRemainingTimeInMillis() - (hb.config.timeoutWarningThresholdMs);
1194
- return setTimeout(() => {
1195
- hb.notify(`${context.functionName}[${context.functionVersion}] may have timed out`);
1314
+ var delay = context.getRemainingTimeInMillis() - (hb.config.timeoutWarningThresholdMs);
1315
+ return setTimeout(function () {
1316
+ hb.notify("".concat(context.functionName, "[").concat(context.functionVersion, "] may have timed out"));
1196
1317
  }, delay > 0 ? delay : 0);
1197
1318
  }
1198
1319
  function lambdaHandler(handler) {
1199
1320
  // eslint-disable-next-line @typescript-eslint/no-this-alias
1200
- const hb = this;
1321
+ var hb = this;
1201
1322
  if (isHandlerSync(handler)) {
1202
1323
  return syncHandler(handler, hb);
1203
1324
  }
1204
1325
  return asyncHandler(handler, hb);
1205
1326
  }
1206
1327
  aws_lambda.lambdaHandler = lambdaHandler;
1207
- let listenerRemoved = false;
1328
+ var listenerRemoved = false;
1208
1329
  /**
1209
1330
  * Removes AWS Lambda default listener that
1210
1331
  * exits the process before letting us report to honeybadger.
@@ -1214,7 +1335,7 @@ function removeAwsDefaultUncaughtExceptionListener() {
1214
1335
  return;
1215
1336
  }
1216
1337
  listenerRemoved = true;
1217
- const listeners = process.listeners('uncaughtException');
1338
+ var listeners = process.listeners('uncaughtException');
1218
1339
  if (listeners.length === 0) {
1219
1340
  return;
1220
1341
  }
@@ -1224,11 +1345,11 @@ function removeAwsDefaultUncaughtExceptionListener() {
1224
1345
  aws_lambda.removeAwsDefaultUncaughtExceptionListener = removeAwsDefaultUncaughtExceptionListener;
1225
1346
 
1226
1347
  Object.defineProperty(uncaught_exception, "__esModule", { value: true });
1227
- const util_1$2 = util;
1228
- const aws_lambda_1$1 = aws_lambda;
1229
- let count = 0;
1348
+ var util_1$2 = util;
1349
+ var aws_lambda_1$1 = aws_lambda;
1350
+ var count = 0;
1230
1351
  function removeAwsLambdaListener() {
1231
- const isLambda = !!process.env.LAMBDA_TASK_ROOT;
1352
+ var isLambda = !!process.env.LAMBDA_TASK_ROOT;
1232
1353
  if (!isLambda) {
1233
1354
  return;
1234
1355
  }
@@ -1236,7 +1357,7 @@ function removeAwsLambdaListener() {
1236
1357
  }
1237
1358
  function default_1$1() {
1238
1359
  return {
1239
- load: (client) => {
1360
+ load: function (client) {
1240
1361
  if (!client.config.enableUncaught) {
1241
1362
  return;
1242
1363
  }
@@ -1248,7 +1369,7 @@ function default_1$1() {
1248
1369
  }
1249
1370
  if (client.config.enableUncaught) {
1250
1371
  client.notify(uncaughtError, {
1251
- afterNotify: (_err, _notice) => {
1372
+ afterNotify: function (_err, _notice) {
1252
1373
  count += 1;
1253
1374
  client.config.afterUncaught(uncaughtError);
1254
1375
  }
@@ -1269,7 +1390,7 @@ var unhandled_rejection = {};
1269
1390
  Object.defineProperty(unhandled_rejection, "__esModule", { value: true });
1270
1391
  function default_1() {
1271
1392
  return {
1272
- load: (client) => {
1393
+ load: function (client) {
1273
1394
  if (!client.config.enableUnhandledRejection) {
1274
1395
  return;
1275
1396
  }
@@ -1291,12 +1412,12 @@ var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || fu
1291
1412
  };
1292
1413
  Object.defineProperty(middleware, "__esModule", { value: true });
1293
1414
  middleware.errorHandler = middleware.requestHandler = void 0;
1294
- const url_1$1 = __importDefault$2(require$$0__default$1["default"]);
1415
+ var url_1$1 = __importDefault$2(require$$0__default$1["default"]);
1295
1416
  function fullUrl(req) {
1296
- const connection = req.connection;
1297
- const address = connection && connection.address();
1417
+ var connection = req.connection;
1418
+ var address = connection && connection.address();
1298
1419
  // @ts-ignore The old @types/node incorrectly defines `address` as string|Address
1299
- const port = address ? address.port : undefined;
1420
+ var port = address ? address.port : undefined;
1300
1421
  // @ts-ignore
1301
1422
  return url_1$1.default.format({
1302
1423
  protocol: req.protocol,
@@ -1334,96 +1455,129 @@ var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || fu
1334
1455
  };
1335
1456
  Object.defineProperty(transport, "__esModule", { value: true });
1336
1457
  transport.ServerTransport = void 0;
1337
- const core_1$1 = src;
1338
- const url_1 = require$$0__default$1["default"];
1339
- const http_1 = __importDefault$1(require$$2__default$1["default"]);
1340
- const https_1 = __importDefault$1(require$$3__default["default"]);
1341
- const util_1$1 = util;
1342
- const { sanitize } = core_1$1.Util;
1343
- class ServerTransport {
1344
- send(options, payload) {
1345
- const { protocol, hostname, pathname } = new url_1.URL(options.endpoint);
1346
- const transport = (protocol === 'http:' ? http_1.default : https_1.default);
1347
- return new Promise((resolve, reject) => {
1348
- let promise;
1458
+ var core_1$1 = src;
1459
+ var url_1 = require$$0__default$1["default"];
1460
+ var http_1 = __importDefault$1(require$$2__default$1["default"]);
1461
+ var https_1 = __importDefault$1(require$$3__default["default"]);
1462
+ var util_1$1 = util;
1463
+ var sanitize = core_1$1.Util.sanitize;
1464
+ var ServerTransport = /** @class */ (function () {
1465
+ function ServerTransport() {
1466
+ }
1467
+ ServerTransport.prototype.send = function (options, payload) {
1468
+ var _this = this;
1469
+ var _a = new url_1.URL(options.endpoint), protocol = _a.protocol, hostname = _a.hostname, pathname = _a.pathname;
1470
+ var transport = (protocol === 'http:' ? http_1.default : https_1.default);
1471
+ return new Promise(function (resolve, reject) {
1472
+ var promise;
1349
1473
  // this should not be here. it should be done before reaching the transport layer
1350
1474
  // it could be inside a beforeNotifyHandler, but is not possible at the moment because those handlers are synchronous
1351
- if (this.isNoticePayload(payload)) {
1352
- promise = this.appendMetadata(payload);
1475
+ if (_this.isNoticePayload(payload)) {
1476
+ promise = _this.appendMetadata(payload);
1353
1477
  }
1354
1478
  else {
1355
1479
  promise = Promise.resolve();
1356
1480
  }
1357
- promise.then(() => {
1481
+ promise.then(function () {
1358
1482
  //
1359
1483
  // We use a httpOptions object to limit issues with libraries that may patch Node.js
1360
1484
  // See https://github.com/honeybadger-io/honeybadger-js/issues/825#issuecomment-1193113433
1361
- const httpOptions = {
1485
+ var httpOptions = {
1362
1486
  method: options.method,
1363
1487
  headers: options.headers,
1364
1488
  path: pathname,
1365
- protocol,
1366
- hostname,
1489
+ protocol: protocol,
1490
+ hostname: hostname,
1367
1491
  };
1368
- let data = undefined;
1492
+ var data = undefined;
1369
1493
  if (payload) {
1370
1494
  data = Buffer.from(JSON.stringify(sanitize(payload, options.maxObjectDepth)), 'utf8');
1371
1495
  httpOptions.headers['Content-Length'] = data.length;
1372
1496
  }
1373
- const req = transport.request(httpOptions, (res) => {
1374
- options.logger.debug(`statusCode: ${res.statusCode}`);
1375
- let body = '';
1376
- res.on('data', (chunk) => {
1497
+ var req = transport.request(httpOptions, function (res) {
1498
+ options.logger.debug("statusCode: ".concat(res.statusCode));
1499
+ var body = '';
1500
+ res.on('data', function (chunk) {
1377
1501
  body += chunk;
1378
1502
  });
1379
- res.on('end', () => resolve({ statusCode: res.statusCode, body }));
1503
+ res.on('end', function () { return resolve({ statusCode: res.statusCode, body: body }); });
1380
1504
  });
1381
- req.on('error', (err) => reject(err));
1505
+ req.on('error', function (err) { return reject(err); });
1382
1506
  if (data) {
1383
1507
  req.write(data);
1384
1508
  }
1385
1509
  req.end();
1386
1510
  });
1387
1511
  });
1388
- }
1389
- isNoticePayload(payload) {
1512
+ };
1513
+ ServerTransport.prototype.isNoticePayload = function (payload) {
1390
1514
  return payload && payload.error !== undefined;
1391
- }
1392
- appendMetadata(payload) {
1515
+ };
1516
+ ServerTransport.prototype.appendMetadata = function (payload) {
1393
1517
  payload.server.pid = process.pid;
1394
1518
  return (0, util_1$1.getStats)()
1395
- .then(stats => {
1519
+ .then(function (stats) {
1396
1520
  payload.server.stats = stats;
1397
1521
  });
1398
- }
1399
- }
1522
+ };
1523
+ return ServerTransport;
1524
+ }());
1400
1525
  transport.ServerTransport = ServerTransport;
1401
1526
 
1527
+ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
1528
+ var extendStatics = function (d, b) {
1529
+ extendStatics = Object.setPrototypeOf ||
1530
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1531
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1532
+ return extendStatics(d, b);
1533
+ };
1534
+ return function (d, b) {
1535
+ if (typeof b !== "function" && b !== null)
1536
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1537
+ extendStatics(d, b);
1538
+ function __() { this.constructor = d; }
1539
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1540
+ };
1541
+ })();
1542
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1543
+ __assign = Object.assign || function(t) {
1544
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1545
+ s = arguments[i];
1546
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1547
+ t[p] = s[p];
1548
+ }
1549
+ return t;
1550
+ };
1551
+ return __assign.apply(this, arguments);
1552
+ };
1402
1553
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1403
1554
  return (mod && mod.__esModule) ? mod : { "default": mod };
1404
1555
  };
1405
1556
  Object.defineProperty(server, "__esModule", { value: true });
1406
- const os_1 = __importDefault(require$$0__default["default"]);
1407
- const domain_1 = __importDefault(require$$1__default$1["default"]);
1408
- const core_1 = src;
1409
- const util_1 = util;
1410
- const uncaught_exception_1 = __importDefault(uncaught_exception);
1411
- const unhandled_rejection_1 = __importDefault(unhandled_rejection);
1412
- const middleware_1 = middleware;
1413
- const aws_lambda_1 = aws_lambda;
1414
- const async_store_1 = async_store;
1415
- const transport_1 = transport;
1416
- const { endpoint } = core_1.Util;
1417
- const kHoneybadgerStore = Symbol.for('kHoneybadgerStore');
1418
- class Honeybadger extends core_1.Client {
1419
- constructor(opts = {}) {
1557
+ var os_1 = __importDefault(require$$0__default["default"]);
1558
+ var domain_1 = __importDefault(require$$1__default$1["default"]);
1559
+ var core_1 = src;
1560
+ var util_1 = util;
1561
+ var uncaught_exception_1 = __importDefault(uncaught_exception);
1562
+ var unhandled_rejection_1 = __importDefault(unhandled_rejection);
1563
+ var middleware_1 = middleware;
1564
+ var aws_lambda_1 = aws_lambda;
1565
+ var async_store_1 = async_store;
1566
+ var transport_1 = transport;
1567
+ var endpoint = core_1.Util.endpoint;
1568
+ var kHoneybadgerStore = Symbol.for('kHoneybadgerStore');
1569
+ var Honeybadger = /** @class */ (function (_super) {
1570
+ __extends(Honeybadger, _super);
1571
+ function Honeybadger(opts) {
1572
+ if (opts === void 0) { opts = {}; }
1573
+ var _this = this;
1420
1574
  var _a;
1421
- super(Object.assign({ afterUncaught: util_1.fatallyLogAndExit, projectRoot: process.cwd(), hostname: os_1.default.hostname() }, opts), new transport_1.ServerTransport());
1575
+ _this = _super.call(this, __assign({ afterUncaught: util_1.fatallyLogAndExit, projectRoot: process.cwd(), hostname: os_1.default.hostname() }, opts), new transport_1.ServerTransport()) || this;
1422
1576
  /** @internal */
1423
- this.__beforeNotifyHandlers = [
1424
- (notice) => {
1577
+ _this.__beforeNotifyHandlers = [
1578
+ function (notice) {
1425
1579
  if (notice && notice.backtrace) {
1426
- notice.backtrace.forEach((line) => {
1580
+ notice.backtrace.forEach(function (line) {
1427
1581
  if (line.file) {
1428
1582
  line.file = line.file.replace(/.*\/node_modules\/(.+)/, '[NODE_MODULES]/$1');
1429
1583
  line.file = line.file.replace(notice.projectRoot, '[PROJECT_ROOT]');
@@ -1434,36 +1588,39 @@ class Honeybadger extends core_1.Client {
1434
1588
  }
1435
1589
  ];
1436
1590
  // serverless defaults
1437
- const config = this.config;
1591
+ var config = _this.config;
1438
1592
  config.reportTimeoutWarning = (_a = config.reportTimeoutWarning) !== null && _a !== void 0 ? _a : true;
1439
1593
  config.timeoutWarningThresholdMs = config.timeoutWarningThresholdMs || 50;
1440
- this.__getSourceFileHandler = util_1.getSourceFile.bind(this);
1441
- this.errorHandler = middleware_1.errorHandler.bind(this);
1442
- this.requestHandler = middleware_1.requestHandler.bind(this);
1443
- this.lambdaHandler = aws_lambda_1.lambdaHandler.bind(this);
1594
+ _this.__getSourceFileHandler = util_1.getSourceFile.bind(_this);
1595
+ _this.errorHandler = middleware_1.errorHandler.bind(_this);
1596
+ _this.requestHandler = middleware_1.requestHandler.bind(_this);
1597
+ _this.lambdaHandler = aws_lambda_1.lambdaHandler.bind(_this);
1598
+ return _this;
1444
1599
  }
1445
- factory(opts) {
1600
+ Honeybadger.prototype.factory = function (opts) {
1446
1601
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1447
1602
  return new Honeybadger(opts);
1448
- }
1449
- configure(opts = {}) {
1450
- return super.configure(opts);
1451
- }
1452
- checkIn(id) {
1603
+ };
1604
+ Honeybadger.prototype.configure = function (opts) {
1605
+ if (opts === void 0) { opts = {}; }
1606
+ return _super.prototype.configure.call(this, opts);
1607
+ };
1608
+ Honeybadger.prototype.checkIn = function (id) {
1609
+ var _this = this;
1453
1610
  return this.__transport
1454
1611
  .send({
1455
1612
  method: 'GET',
1456
- endpoint: endpoint(this.config.endpoint, `v1/check_in/${id}`),
1613
+ endpoint: endpoint(this.config.endpoint, "v1/check_in/".concat(id)),
1457
1614
  logger: this.logger,
1458
1615
  })
1459
- .then(() => {
1460
- this.logger.info('CheckIn sent');
1616
+ .then(function () {
1617
+ _this.logger.info('CheckIn sent');
1461
1618
  return Promise.resolve();
1462
1619
  })
1463
- .catch(err => {
1464
- this.logger.error('CheckIn failed: an unknown error occurred.', `message=${err.message}`);
1620
+ .catch(function (err) {
1621
+ _this.logger.error('CheckIn failed: an unknown error occurred.', "message=".concat(err.message));
1465
1622
  });
1466
- }
1623
+ };
1467
1624
  // This method is intended for web frameworks.
1468
1625
  // It allows us to track context for individual requests without leaking to other requests
1469
1626
  // by doing two things:
@@ -1471,8 +1628,9 @@ class Honeybadger extends core_1.Client {
1471
1628
  // 2. Attaching the store contents to the request object,
1472
1629
  // so, even if the store is destroyed, we can still recover the context for a given request
1473
1630
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1474
- withRequest(request, handler, onError) {
1475
- const storeObject = (request[kHoneybadgerStore] || this.__getStoreContentsOrDefault());
1631
+ Honeybadger.prototype.withRequest = function (request, handler, onError) {
1632
+ var _this = this;
1633
+ var storeObject = (request[kHoneybadgerStore] || this.__getStoreContentsOrDefault());
1476
1634
  this.__setStore(async_store_1.AsyncStore);
1477
1635
  if (!request[kHoneybadgerStore]) {
1478
1636
  request[kHoneybadgerStore] = storeObject;
@@ -1484,14 +1642,15 @@ class Honeybadger extends core_1.Client {
1484
1642
  // But the `onError` handler might be request-specific.
1485
1643
  // Note that this doesn't still handle all cases. `domain` has its own problems:
1486
1644
  // See https://github.com/honeybadger-io/honeybadger-js/pull/711
1487
- const dom = domain_1.default.create();
1488
- const onErrorWithContext = (err) => this.__store.run(storeObject, () => onError(err));
1645
+ var dom = domain_1.default.create();
1646
+ var onErrorWithContext = function (err) { return _this.__store.run(storeObject, function () { return onError(err); }); };
1489
1647
  dom.on('error', onErrorWithContext);
1490
1648
  handler = dom.bind(handler);
1491
1649
  }
1492
1650
  return this.__store.run(storeObject, handler);
1493
- }
1494
- }
1651
+ };
1652
+ return Honeybadger;
1653
+ }(core_1.Client));
1495
1654
  var _default = server.default = new Honeybadger({
1496
1655
  __plugins: [
1497
1656
  (0, uncaught_exception_1.default)(),