@honeybadger-io/js 4.7.4 → 4.8.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.
- package/dist/browser/honeybadger.js +717 -569
- package/dist/browser/honeybadger.js.map +1 -1
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/browser/honeybadger.min.js.map +1 -1
- package/dist/browser/integrations/breadcrumbs.d.ts +1 -1
- package/dist/browser/integrations/event_listeners.d.ts +1 -1
- package/dist/browser/integrations/timers.d.ts +1 -1
- package/dist/browser/util.d.ts +4 -0
- package/dist/server/honeybadger.js +564 -509
- package/dist/server/honeybadger.js.map +1 -1
- package/package.json +5 -4
|
@@ -181,515 +181,570 @@
|
|
|
181
181
|
|
|
182
182
|
var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
184
|
+
(function (exports) {
|
|
185
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
186
|
+
if (k2 === undefined) k2 = k;
|
|
187
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
188
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
189
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
190
|
+
}
|
|
191
|
+
Object.defineProperty(o, k2, desc);
|
|
192
|
+
}) : (function(o, m, k, k2) {
|
|
193
|
+
if (k2 === undefined) k2 = k;
|
|
194
|
+
o[k2] = m[k];
|
|
195
|
+
}));
|
|
196
|
+
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
197
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
198
|
+
}) : function(o, v) {
|
|
199
|
+
o["default"] = v;
|
|
200
|
+
});
|
|
201
|
+
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
202
|
+
if (mod && mod.__esModule) return mod;
|
|
203
|
+
var result = {};
|
|
204
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
205
|
+
__setModuleDefault(result, mod);
|
|
206
|
+
return result;
|
|
207
|
+
};
|
|
208
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
209
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
210
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
211
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
212
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
213
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
214
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
218
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
219
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
220
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
221
|
+
function step(op) {
|
|
222
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
223
|
+
while (_) try {
|
|
224
|
+
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;
|
|
225
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
226
|
+
switch (op[0]) {
|
|
227
|
+
case 0: case 1: t = op; break;
|
|
228
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
229
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
230
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
231
|
+
default:
|
|
232
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
233
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
234
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
235
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
236
|
+
if (t[2]) _.ops.pop();
|
|
237
|
+
_.trys.pop(); continue;
|
|
238
|
+
}
|
|
239
|
+
op = body.call(thisArg, _);
|
|
240
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
241
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
245
|
+
exports.isBrowserConfig = exports.clone = exports.formatCGIData = exports.filterUrl = exports.filter = exports.generateStackTrace = exports.endpoint = exports.instrument = exports.isErrorObject = exports.makeNotice = exports.logger = exports.sanitize = exports.shallowClone = exports.runAfterNotifyHandlers = exports.runBeforeNotifyHandlers = exports.getSourceForBacktrace = exports.getCauses = exports.calculateBacktraceShift = exports.DEFAULT_BACKTRACE_SHIFT = exports.makeBacktrace = exports.objectIsExtensible = exports.objectIsEmpty = exports.mergeNotice = exports.merge = void 0;
|
|
246
|
+
var stackTraceParser = __importStar(require$$0);
|
|
247
|
+
function merge(obj1, obj2) {
|
|
248
|
+
var result = {};
|
|
249
|
+
for (var k in obj1) {
|
|
250
|
+
result[k] = obj1[k];
|
|
251
|
+
}
|
|
252
|
+
for (var k in obj2) {
|
|
253
|
+
result[k] = obj2[k];
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
exports.merge = merge;
|
|
258
|
+
function mergeNotice(notice1, notice2) {
|
|
259
|
+
var result = merge(notice1, notice2);
|
|
260
|
+
if (notice1.context && notice2.context) {
|
|
261
|
+
result.context = merge(notice1.context, notice2.context);
|
|
262
|
+
}
|
|
263
|
+
return result;
|
|
264
|
+
}
|
|
265
|
+
exports.mergeNotice = mergeNotice;
|
|
266
|
+
function objectIsEmpty(obj) {
|
|
267
|
+
for (var k in obj) {
|
|
268
|
+
if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
exports.objectIsEmpty = objectIsEmpty;
|
|
275
|
+
function objectIsExtensible(obj) {
|
|
276
|
+
if (typeof Object.isExtensible !== 'function') {
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
return Object.isExtensible(obj);
|
|
280
|
+
}
|
|
281
|
+
exports.objectIsExtensible = objectIsExtensible;
|
|
282
|
+
function makeBacktrace(stack, filterHbSourceCode, logger) {
|
|
283
|
+
if (filterHbSourceCode === void 0) { filterHbSourceCode = false; }
|
|
284
|
+
if (logger === void 0) { logger = console; }
|
|
285
|
+
try {
|
|
286
|
+
var backtrace = stackTraceParser
|
|
287
|
+
.parse(stack)
|
|
288
|
+
.map(function (line) {
|
|
289
|
+
return {
|
|
290
|
+
file: line.file,
|
|
291
|
+
method: line.methodName,
|
|
292
|
+
number: line.lineNumber,
|
|
293
|
+
column: line.column
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
if (filterHbSourceCode) {
|
|
297
|
+
backtrace.splice(0, calculateBacktraceShift(backtrace));
|
|
298
|
+
}
|
|
299
|
+
return backtrace;
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
logger.debug(err);
|
|
303
|
+
return [];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
exports.makeBacktrace = makeBacktrace;
|
|
307
|
+
function isFrameFromHbSourceCode(frame) {
|
|
308
|
+
var hasHbFile = false;
|
|
309
|
+
var hasHbMethod = false;
|
|
310
|
+
if (frame.file) {
|
|
311
|
+
hasHbFile = frame.file.toLowerCase().indexOf('@honeybadger-io') > -1;
|
|
312
|
+
}
|
|
313
|
+
if (frame.method) {
|
|
314
|
+
hasHbMethod = frame.method.toLowerCase().indexOf('@honeybadger-io') > -1;
|
|
315
|
+
}
|
|
316
|
+
return hasHbFile || hasHbMethod;
|
|
317
|
+
}
|
|
318
|
+
exports.DEFAULT_BACKTRACE_SHIFT = 3;
|
|
319
|
+
/**
|
|
320
|
+
* If {@link generateStackTrace} is used, we want to exclude frames that come from
|
|
321
|
+
* Honeybadger's source code.
|
|
322
|
+
*
|
|
323
|
+
* Logic:
|
|
324
|
+
* - For each frame, increment the shift if source code is from Honeybadger
|
|
325
|
+
* - If a frame from an <anonymous> file is encountered increment the shift ONLY if between Honeybadger source code
|
|
326
|
+
* (i.e. previous and next frames are from Honeybadger)
|
|
327
|
+
* - Exit when frame encountered is not from Honeybadger source code
|
|
328
|
+
*
|
|
329
|
+
* Note: this will not always work, especially in browser versions where code
|
|
330
|
+
* is minified, uglified and bundled.
|
|
331
|
+
* For those cases we default to 3:
|
|
332
|
+
* - generateStackTrace
|
|
333
|
+
* - makeNotice
|
|
334
|
+
* - notify
|
|
335
|
+
*/
|
|
336
|
+
function calculateBacktraceShift(backtrace) {
|
|
337
|
+
var shift = 0;
|
|
338
|
+
for (var i = 0; i < backtrace.length; i++) {
|
|
339
|
+
var frame = backtrace[i];
|
|
340
|
+
if (isFrameFromHbSourceCode(frame)) {
|
|
341
|
+
shift++;
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (!frame.file || frame.file === '<anonymous>') {
|
|
345
|
+
var nextFrame = backtrace[i + 1];
|
|
346
|
+
if (nextFrame && isFrameFromHbSourceCode(nextFrame)) {
|
|
347
|
+
shift++;
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
return shift || exports.DEFAULT_BACKTRACE_SHIFT;
|
|
354
|
+
}
|
|
355
|
+
exports.calculateBacktraceShift = calculateBacktraceShift;
|
|
356
|
+
function getCauses(notice, logger) {
|
|
357
|
+
if (notice.cause) {
|
|
358
|
+
var causes = [];
|
|
359
|
+
var cause = notice;
|
|
360
|
+
while (causes.length < 3 && (cause = cause.cause)) {
|
|
361
|
+
causes.push({
|
|
362
|
+
class: cause.name,
|
|
363
|
+
message: cause.message,
|
|
364
|
+
backtrace: typeof cause.stack == 'string' ? makeBacktrace(cause.stack, false, logger) : null
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
return causes;
|
|
368
|
+
}
|
|
369
|
+
return [];
|
|
370
|
+
}
|
|
371
|
+
exports.getCauses = getCauses;
|
|
372
|
+
function getSourceForBacktrace(backtrace, getSourceFileHandler) {
|
|
373
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
374
|
+
var result, index, trace, fileContent;
|
|
375
|
+
return __generator(this, function (_a) {
|
|
376
|
+
switch (_a.label) {
|
|
377
|
+
case 0:
|
|
378
|
+
result = [];
|
|
379
|
+
if (!getSourceFileHandler || !backtrace || !backtrace.length) {
|
|
380
|
+
return [2 /*return*/, result];
|
|
381
|
+
}
|
|
382
|
+
index = 0;
|
|
383
|
+
_a.label = 1;
|
|
384
|
+
case 1:
|
|
385
|
+
if (!backtrace.length) return [3 /*break*/, 3];
|
|
386
|
+
trace = backtrace.splice(0)[index];
|
|
387
|
+
return [4 /*yield*/, getSourceFileHandler(trace.file)];
|
|
388
|
+
case 2:
|
|
389
|
+
fileContent = _a.sent();
|
|
390
|
+
result[index] = getSourceCodeSnippet(fileContent, trace.number);
|
|
391
|
+
index++;
|
|
392
|
+
return [3 /*break*/, 1];
|
|
393
|
+
case 3: return [2 /*return*/, result];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
exports.getSourceForBacktrace = getSourceForBacktrace;
|
|
399
|
+
function runBeforeNotifyHandlers(notice, handlers) {
|
|
400
|
+
var result = true;
|
|
401
|
+
for (var i = 0, len = handlers.length; i < len; i++) {
|
|
402
|
+
var handler = handlers[i];
|
|
403
|
+
if (handler(notice) === false) {
|
|
404
|
+
result = false;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
exports.runBeforeNotifyHandlers = runBeforeNotifyHandlers;
|
|
410
|
+
function runAfterNotifyHandlers(notice, handlers, error) {
|
|
411
|
+
if (notice && notice.afterNotify) {
|
|
412
|
+
notice.afterNotify(error, notice);
|
|
413
|
+
}
|
|
414
|
+
for (var i = 0, len = handlers.length; i < len; i++) {
|
|
415
|
+
handlers[i](error, notice);
|
|
416
|
+
}
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
exports.runAfterNotifyHandlers = runAfterNotifyHandlers;
|
|
420
|
+
// Returns a new object with properties from other object.
|
|
421
|
+
function shallowClone(obj) {
|
|
422
|
+
if (typeof (obj) !== 'object' || obj === null) {
|
|
423
|
+
return {};
|
|
424
|
+
}
|
|
425
|
+
var result = {};
|
|
426
|
+
for (var k in obj) {
|
|
427
|
+
result[k] = obj[k];
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
exports.shallowClone = shallowClone;
|
|
432
|
+
function sanitize(obj, maxDepth) {
|
|
433
|
+
if (maxDepth === void 0) { maxDepth = 8; }
|
|
434
|
+
var seenObjects = [];
|
|
435
|
+
function seen(obj) {
|
|
436
|
+
if (!obj || typeof (obj) !== 'object') {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
for (var i = 0; i < seenObjects.length; i++) {
|
|
440
|
+
var value = seenObjects[i];
|
|
441
|
+
if (value === obj) {
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
seenObjects.push(obj);
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
function canSerialize(obj) {
|
|
449
|
+
var typeOfObj = typeof obj;
|
|
450
|
+
// Functions are TMI
|
|
451
|
+
if (/function/.test(typeOfObj)) {
|
|
452
|
+
// Let special toJSON method pass as it's used by JSON.stringify (#722)
|
|
453
|
+
return obj.name === 'toJSON';
|
|
454
|
+
}
|
|
455
|
+
// Symbols can't convert to strings.
|
|
456
|
+
if (/symbol/.test(typeOfObj)) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
if (obj === null) {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
// No prototype, likely created with `Object.create(null)`.
|
|
463
|
+
if (typeof obj === 'object' && typeof obj.hasOwnProperty === 'undefined') {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
function serialize(obj, depth) {
|
|
469
|
+
if (depth === void 0) { depth = 0; }
|
|
470
|
+
if (depth >= maxDepth) {
|
|
471
|
+
return '[DEPTH]';
|
|
472
|
+
}
|
|
473
|
+
// Inspect invalid types
|
|
474
|
+
if (!canSerialize(obj)) {
|
|
475
|
+
return Object.prototype.toString.call(obj);
|
|
476
|
+
}
|
|
477
|
+
// Halt circular references
|
|
478
|
+
if (seen(obj)) {
|
|
479
|
+
return '[RECURSION]';
|
|
480
|
+
}
|
|
481
|
+
// Serialize inside arrays
|
|
482
|
+
if (Array.isArray(obj)) {
|
|
483
|
+
return obj.map(function (o) { return safeSerialize(o, depth + 1); });
|
|
484
|
+
}
|
|
485
|
+
// Serialize inside objects
|
|
486
|
+
if (typeof (obj) === 'object') {
|
|
487
|
+
var ret = {};
|
|
488
|
+
for (var k in obj) {
|
|
489
|
+
var v = obj[k];
|
|
490
|
+
if (Object.prototype.hasOwnProperty.call(obj, k) && (k != null) && (v != null)) {
|
|
491
|
+
ret[k] = safeSerialize(v, depth + 1);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return ret;
|
|
495
|
+
}
|
|
496
|
+
// Return everything else untouched
|
|
497
|
+
return obj;
|
|
498
|
+
}
|
|
499
|
+
function safeSerialize(obj, depth) {
|
|
500
|
+
if (depth === void 0) { depth = 0; }
|
|
501
|
+
try {
|
|
502
|
+
return serialize(obj, depth);
|
|
503
|
+
}
|
|
504
|
+
catch (e) {
|
|
505
|
+
return "[ERROR] ".concat(e);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return safeSerialize(obj);
|
|
509
|
+
}
|
|
510
|
+
exports.sanitize = sanitize;
|
|
511
|
+
function logger(client) {
|
|
512
|
+
var log = function (method) {
|
|
513
|
+
return function () {
|
|
514
|
+
var _a;
|
|
515
|
+
var args = [];
|
|
516
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
517
|
+
args[_i] = arguments[_i];
|
|
518
|
+
}
|
|
519
|
+
if (method === 'debug') {
|
|
520
|
+
if (!client.config.debug) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
// Log at default level so that you don't need to also enable verbose
|
|
524
|
+
// logging in Chrome.
|
|
525
|
+
method = 'log';
|
|
526
|
+
}
|
|
527
|
+
args.unshift('[Honeybadger]');
|
|
528
|
+
(_a = client.config.logger)[method].apply(_a, args);
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
return {
|
|
532
|
+
log: log('log'),
|
|
533
|
+
info: log('info'),
|
|
534
|
+
debug: log('debug'),
|
|
535
|
+
warn: log('warn'),
|
|
536
|
+
error: log('error')
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
exports.logger = logger;
|
|
540
|
+
/**
|
|
541
|
+
* Converts any object into a notice object (which at minimum has the same
|
|
542
|
+
* properties as Error, but supports additional Honeybadger properties.)
|
|
543
|
+
*/
|
|
544
|
+
function makeNotice(thing) {
|
|
545
|
+
var notice;
|
|
546
|
+
if (!thing) {
|
|
547
|
+
notice = {};
|
|
548
|
+
}
|
|
549
|
+
else if (isErrorObject(thing)) {
|
|
550
|
+
var e = thing;
|
|
551
|
+
notice = merge(thing, { name: e.name, message: e.message, stack: e.stack, cause: e.cause });
|
|
552
|
+
}
|
|
553
|
+
else if (typeof thing === 'object') {
|
|
554
|
+
notice = shallowClone(thing);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
var m = String(thing);
|
|
558
|
+
notice = { message: m };
|
|
559
|
+
}
|
|
560
|
+
return notice;
|
|
561
|
+
}
|
|
562
|
+
exports.makeNotice = makeNotice;
|
|
563
|
+
function isErrorObject(thing) {
|
|
564
|
+
return thing instanceof Error
|
|
565
|
+
|| Object.prototype.toString.call(thing) === '[object Error]'; // Important for cross-realm objects
|
|
566
|
+
}
|
|
567
|
+
exports.isErrorObject = isErrorObject;
|
|
568
|
+
/**
|
|
569
|
+
* Instrument an existing function inside an object (usually global).
|
|
570
|
+
* @param {!Object} object
|
|
571
|
+
* @param {!String} name
|
|
572
|
+
* @param {!Function} replacement
|
|
573
|
+
*/
|
|
574
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
575
|
+
function instrument(object, name, replacement) {
|
|
576
|
+
if (!object || !name || !replacement || !(name in object)) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
var original = object[name];
|
|
580
|
+
while (original && original.__hb_original) {
|
|
581
|
+
original = original.__hb_original;
|
|
582
|
+
}
|
|
583
|
+
try {
|
|
584
|
+
object[name] = replacement(original);
|
|
585
|
+
object[name].__hb_original = original;
|
|
586
|
+
}
|
|
587
|
+
catch (_e) {
|
|
588
|
+
// Ignores errors like this one:
|
|
589
|
+
// Error: TypeError: Cannot set property onunhandledrejection of [object Object] which has only a getter
|
|
590
|
+
// User-Agent: Mozilla/5.0 (Linux; Android 10; SAMSUNG SM-G960F) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/12.1 Chrome/79.0.3945.136 Mobile Safari/537.36
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
exports.instrument = instrument;
|
|
594
|
+
function endpoint(base, path) {
|
|
595
|
+
var endpoint = base.trim().replace(/\/$/, '');
|
|
596
|
+
path = path.trim().replace(/(^\/|\/$)/g, '');
|
|
597
|
+
return "".concat(endpoint, "/").concat(path);
|
|
598
|
+
}
|
|
599
|
+
exports.endpoint = endpoint;
|
|
600
|
+
function generateStackTrace() {
|
|
601
|
+
try {
|
|
602
|
+
throw new Error('');
|
|
603
|
+
}
|
|
604
|
+
catch (e) {
|
|
605
|
+
if (e.stack) {
|
|
606
|
+
return e.stack;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
var maxStackSize = 10;
|
|
610
|
+
var stack = [];
|
|
611
|
+
var curr = arguments.callee;
|
|
612
|
+
while (curr && stack.length < maxStackSize) {
|
|
613
|
+
if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
|
|
614
|
+
stack.push(RegExp.$1 || '<anonymous>');
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
stack.push('<anonymous>');
|
|
618
|
+
}
|
|
619
|
+
try {
|
|
620
|
+
curr = curr.caller;
|
|
621
|
+
}
|
|
622
|
+
catch (e) {
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return stack.join('\n');
|
|
627
|
+
}
|
|
628
|
+
exports.generateStackTrace = generateStackTrace;
|
|
629
|
+
function filter(obj, filters) {
|
|
630
|
+
if (!is('Object', obj)) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
if (!is('Array', filters)) {
|
|
634
|
+
filters = [];
|
|
635
|
+
}
|
|
636
|
+
var seen = [];
|
|
637
|
+
function filter(obj) {
|
|
638
|
+
var k, newObj;
|
|
639
|
+
if (is('Object', obj) || is('Array', obj)) {
|
|
640
|
+
if (seen.indexOf(obj) !== -1) {
|
|
641
|
+
return '[CIRCULAR DATA STRUCTURE]';
|
|
642
|
+
}
|
|
643
|
+
seen.push(obj);
|
|
644
|
+
}
|
|
645
|
+
if (is('Object', obj)) {
|
|
646
|
+
newObj = {};
|
|
647
|
+
for (k in obj) {
|
|
648
|
+
if (filterMatch(k, filters)) {
|
|
649
|
+
newObj[k] = '[FILTERED]';
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
newObj[k] = filter(obj[k]);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return newObj;
|
|
656
|
+
}
|
|
657
|
+
if (is('Array', obj)) {
|
|
658
|
+
return obj.map(function (v) {
|
|
659
|
+
return filter(v);
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
if (is('Function', obj)) {
|
|
663
|
+
return '[FUNC]';
|
|
664
|
+
}
|
|
665
|
+
return obj;
|
|
666
|
+
}
|
|
667
|
+
return filter(obj);
|
|
668
|
+
}
|
|
669
|
+
exports.filter = filter;
|
|
670
|
+
function filterMatch(key, filters) {
|
|
671
|
+
for (var i = 0; i < filters.length; i++) {
|
|
672
|
+
if (key.toLowerCase().indexOf(filters[i].toLowerCase()) !== -1) {
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
function is(type, obj) {
|
|
679
|
+
var klass = Object.prototype.toString.call(obj).slice(8, -1);
|
|
680
|
+
return obj !== undefined && obj !== null && klass === type;
|
|
681
|
+
}
|
|
682
|
+
function filterUrl(url, filters) {
|
|
683
|
+
if (!filters) {
|
|
684
|
+
return url;
|
|
685
|
+
}
|
|
686
|
+
if (typeof url !== 'string') {
|
|
687
|
+
return url;
|
|
688
|
+
}
|
|
689
|
+
var query = url.split(/\?/, 2)[1];
|
|
690
|
+
if (!query) {
|
|
691
|
+
return url;
|
|
692
|
+
}
|
|
693
|
+
var result = url;
|
|
694
|
+
query.split(/[&]\s?/).forEach(function (pair) {
|
|
695
|
+
var _a = pair.split('=', 2), key = _a[0], value = _a[1];
|
|
696
|
+
if (filterMatch(key, filters)) {
|
|
697
|
+
result = result.replace("".concat(key, "=").concat(value), "".concat(key, "=[FILTERED]"));
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
return result;
|
|
701
|
+
}
|
|
702
|
+
exports.filterUrl = filterUrl;
|
|
703
|
+
function formatCGIData(vars, prefix) {
|
|
704
|
+
if (prefix === void 0) { prefix = ''; }
|
|
705
|
+
var formattedVars = {};
|
|
706
|
+
Object.keys(vars).forEach(function (key) {
|
|
707
|
+
var formattedKey = prefix + key.replace(/\W/g, '_').toUpperCase();
|
|
708
|
+
formattedVars[formattedKey] = vars[key];
|
|
709
|
+
});
|
|
710
|
+
return formattedVars;
|
|
711
|
+
}
|
|
712
|
+
exports.formatCGIData = formatCGIData;
|
|
713
|
+
function clone(obj) {
|
|
714
|
+
return JSON.parse(JSON.stringify(obj));
|
|
715
|
+
}
|
|
716
|
+
exports.clone = clone;
|
|
717
|
+
function getSourceCodeSnippet(fileData, lineNumber, sourceRadius) {
|
|
718
|
+
if (sourceRadius === void 0) { sourceRadius = 2; }
|
|
719
|
+
if (!fileData) {
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
var lines = fileData.split('\n');
|
|
723
|
+
// add one empty line because array index starts from 0, but error line number is counted from 1
|
|
724
|
+
lines.unshift('');
|
|
725
|
+
var start = lineNumber - sourceRadius;
|
|
726
|
+
var end = lineNumber + sourceRadius;
|
|
727
|
+
var result = {};
|
|
728
|
+
for (var i = start; i <= end; i++) {
|
|
729
|
+
var line = lines[i];
|
|
730
|
+
if (typeof line === 'string') {
|
|
731
|
+
result[i] = line;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
return result;
|
|
735
|
+
}
|
|
736
|
+
function isBrowserConfig(config) {
|
|
737
|
+
return config.async !== undefined;
|
|
738
|
+
}
|
|
739
|
+
exports.isBrowserConfig = isBrowserConfig;
|
|
740
|
+
|
|
741
|
+
} (util$1));
|
|
687
742
|
|
|
688
743
|
var store = {};
|
|
689
744
|
|
|
690
745
|
Object.defineProperty(store, "__esModule", { value: true });
|
|
691
746
|
store.GlobalStore = void 0;
|
|
692
|
-
var util_1$
|
|
747
|
+
var util_1$7 = util$1;
|
|
693
748
|
var GlobalStore = /** @class */ (function () {
|
|
694
749
|
function GlobalStore(contents, breadcrumbsLimit) {
|
|
695
750
|
this.contents = contents;
|
|
@@ -706,7 +761,7 @@
|
|
|
706
761
|
return JSON.parse(JSON.stringify(value));
|
|
707
762
|
};
|
|
708
763
|
GlobalStore.prototype.setContext = function (context) {
|
|
709
|
-
this.contents.context = (0, util_1$
|
|
764
|
+
this.contents.context = (0, util_1$7.merge)(this.contents.context, context || {});
|
|
710
765
|
};
|
|
711
766
|
GlobalStore.prototype.addBreadcrumb = function (breadcrumb) {
|
|
712
767
|
if (this.contents.breadcrumbs.length == this.breadcrumbsLimit) {
|
|
@@ -738,12 +793,12 @@
|
|
|
738
793
|
};
|
|
739
794
|
Object.defineProperty(client, "__esModule", { value: true });
|
|
740
795
|
client.Client = void 0;
|
|
741
|
-
var util_1$
|
|
796
|
+
var util_1$6 = util$1;
|
|
742
797
|
var store_1 = store;
|
|
743
798
|
var notifier = {
|
|
744
799
|
name: 'honeybadger-js',
|
|
745
800
|
url: 'https://github.com/honeybadger-io/honeybadger-js',
|
|
746
|
-
version: '4.
|
|
801
|
+
version: '4.8.1'
|
|
747
802
|
};
|
|
748
803
|
// Split at commas and spaces
|
|
749
804
|
var TAG_SEPARATOR = /,|\s+/;
|
|
@@ -759,7 +814,7 @@
|
|
|
759
814
|
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);
|
|
760
815
|
this.__initStore();
|
|
761
816
|
this.__transport = transport;
|
|
762
|
-
this.logger = (0, util_1$
|
|
817
|
+
this.logger = (0, util_1$6.logger)(this);
|
|
763
818
|
}
|
|
764
819
|
Client.prototype.getVersion = function () {
|
|
765
820
|
return notifier.version;
|
|
@@ -829,14 +884,14 @@
|
|
|
829
884
|
}
|
|
830
885
|
// we need to have the source file data before the beforeNotifyHandlers,
|
|
831
886
|
// in case they modify them
|
|
832
|
-
var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$
|
|
833
|
-
var beforeNotifyResult = (0, util_1$
|
|
887
|
+
var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$6.shallowClone)(trace); }) : null;
|
|
888
|
+
var beforeNotifyResult = (0, util_1$6.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
|
|
834
889
|
if (!preConditionError && !beforeNotifyResult) {
|
|
835
890
|
this.logger.debug('skipping error report: beforeNotify handlers returned false', notice);
|
|
836
891
|
preConditionError = new Error('beforeNotify handlers returned false');
|
|
837
892
|
}
|
|
838
893
|
if (preConditionError) {
|
|
839
|
-
(0, util_1$
|
|
894
|
+
(0, util_1$6.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionError);
|
|
840
895
|
return false;
|
|
841
896
|
}
|
|
842
897
|
this.addBreadcrumb('Honeybadger Notice', {
|
|
@@ -849,7 +904,7 @@
|
|
|
849
904
|
});
|
|
850
905
|
var breadcrumbs = this.__store.getContents('breadcrumbs');
|
|
851
906
|
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs : [];
|
|
852
|
-
(0, util_1$
|
|
907
|
+
(0, util_1$6.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
|
|
853
908
|
.then(function (sourcePerTrace) {
|
|
854
909
|
sourcePerTrace.forEach(function (source, index) {
|
|
855
910
|
notice.backtrace[index].source = source;
|
|
@@ -863,26 +918,25 @@
|
|
|
863
918
|
'Accept': 'text/json, application/json'
|
|
864
919
|
},
|
|
865
920
|
method: 'POST',
|
|
866
|
-
endpoint: (0, util_1$
|
|
921
|
+
endpoint: (0, util_1$6.endpoint)(_this.config.endpoint, '/v1/notices/js'),
|
|
867
922
|
maxObjectDepth: _this.config.maxObjectDepth,
|
|
868
923
|
logger: _this.logger,
|
|
869
|
-
async: (0, util_1$1.isBrowserConfig)(_this.config) ? _this.config.async : undefined,
|
|
870
924
|
}, payload)
|
|
871
925
|
.then(function (res) {
|
|
872
926
|
if (res.statusCode !== 201) {
|
|
873
|
-
(0, util_1$
|
|
927
|
+
(0, util_1$6.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode)));
|
|
874
928
|
_this.logger.warn("Error report failed: unknown response from server. code=".concat(res.statusCode));
|
|
875
929
|
return;
|
|
876
930
|
}
|
|
877
931
|
var uuid = JSON.parse(res.body).id;
|
|
878
|
-
(0, util_1$
|
|
932
|
+
(0, util_1$6.runAfterNotifyHandlers)((0, util_1$6.merge)(notice, {
|
|
879
933
|
id: uuid
|
|
880
934
|
}), _this.__afterNotifyHandlers);
|
|
881
935
|
_this.logger.info("Error report sent \u26A1 https://app.honeybadger.io/notice/".concat(uuid));
|
|
882
936
|
})
|
|
883
937
|
.catch(function (err) {
|
|
884
938
|
_this.logger.error('Error report failed: an unknown error occurred.', "message=".concat(err.message));
|
|
885
|
-
(0, util_1$
|
|
939
|
+
(0, util_1$6.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, err);
|
|
886
940
|
});
|
|
887
941
|
});
|
|
888
942
|
return true;
|
|
@@ -935,18 +989,18 @@
|
|
|
935
989
|
Client.prototype.makeNotice = function (noticeable, name, extra) {
|
|
936
990
|
if (name === void 0) { name = undefined; }
|
|
937
991
|
if (extra === void 0) { extra = undefined; }
|
|
938
|
-
var notice = (0, util_1$
|
|
992
|
+
var notice = (0, util_1$6.makeNotice)(noticeable);
|
|
939
993
|
if (name && !(typeof name === 'object')) {
|
|
940
994
|
var n = String(name);
|
|
941
995
|
name = { name: n };
|
|
942
996
|
}
|
|
943
997
|
if (name) {
|
|
944
|
-
notice = (0, util_1$
|
|
998
|
+
notice = (0, util_1$6.mergeNotice)(notice, name);
|
|
945
999
|
}
|
|
946
1000
|
if (typeof extra === 'object' && extra !== null) {
|
|
947
|
-
notice = (0, util_1$
|
|
1001
|
+
notice = (0, util_1$6.mergeNotice)(notice, extra);
|
|
948
1002
|
}
|
|
949
|
-
if ((0, util_1$
|
|
1003
|
+
if ((0, util_1$6.objectIsEmpty)(notice)) {
|
|
950
1004
|
return null;
|
|
951
1005
|
}
|
|
952
1006
|
var context = this.__store.getContents('context');
|
|
@@ -956,9 +1010,9 @@
|
|
|
956
1010
|
// Turning into a Set will remove duplicates
|
|
957
1011
|
var tags = noticeTags.concat(contextTags).concat(configTags);
|
|
958
1012
|
var uniqueTags = tags.filter(function (item, index) { return tags.indexOf(item) === index; });
|
|
959
|
-
notice = (0, util_1$
|
|
1013
|
+
notice = (0, util_1$6.merge)(notice, {
|
|
960
1014
|
name: notice.name || 'Error',
|
|
961
|
-
context: (0, util_1$
|
|
1015
|
+
context: (0, util_1$6.merge)(context, notice.context),
|
|
962
1016
|
projectRoot: notice.projectRoot || this.config.projectRoot,
|
|
963
1017
|
environment: notice.environment || this.config.environment,
|
|
964
1018
|
component: notice.component || this.config.component,
|
|
@@ -966,12 +1020,13 @@
|
|
|
966
1020
|
revision: notice.revision || this.config.revision,
|
|
967
1021
|
tags: uniqueTags,
|
|
968
1022
|
});
|
|
969
|
-
var backtraceShift = 0;
|
|
970
1023
|
if (typeof notice.stack !== 'string' || !notice.stack.trim()) {
|
|
971
|
-
notice.stack = (0, util_1$
|
|
972
|
-
|
|
1024
|
+
notice.stack = (0, util_1$6.generateStackTrace)();
|
|
1025
|
+
notice.backtrace = (0, util_1$6.makeBacktrace)(notice.stack, true, this.logger);
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
notice.backtrace = (0, util_1$6.makeBacktrace)(notice.stack, false, this.logger);
|
|
973
1029
|
}
|
|
974
|
-
notice.backtrace = (0, util_1$1.makeBacktrace)(notice.stack, backtraceShift);
|
|
975
1030
|
return notice;
|
|
976
1031
|
};
|
|
977
1032
|
Client.prototype.addBreadcrumb = function (message, opts) {
|
|
@@ -979,7 +1034,7 @@
|
|
|
979
1034
|
return;
|
|
980
1035
|
}
|
|
981
1036
|
opts = opts || {};
|
|
982
|
-
var metadata = (0, util_1$
|
|
1037
|
+
var metadata = (0, util_1$6.shallowClone)(opts.metadata);
|
|
983
1038
|
var category = opts.category || 'custom';
|
|
984
1039
|
var timestamp = new Date().toISOString();
|
|
985
1040
|
this.__store.addBreadcrumb({
|
|
@@ -1003,8 +1058,8 @@
|
|
|
1003
1058
|
return (this.config.environment && this.config.developmentEnvironments.includes(this.config.environment));
|
|
1004
1059
|
};
|
|
1005
1060
|
Client.prototype.__buildPayload = function (notice) {
|
|
1006
|
-
var headers = (0, util_1$
|
|
1007
|
-
var cgiData = (0, util_1$
|
|
1061
|
+
var headers = (0, util_1$6.filter)(notice.headers, this.config.filters) || {};
|
|
1062
|
+
var cgiData = (0, util_1$6.filter)(__assign(__assign({}, notice.cgiData), (0, util_1$6.formatCGIData)(headers, 'HTTP_')), this.config.filters);
|
|
1008
1063
|
return {
|
|
1009
1064
|
notifier: notifier,
|
|
1010
1065
|
breadcrumbs: {
|
|
@@ -1017,16 +1072,16 @@
|
|
|
1017
1072
|
backtrace: notice.backtrace,
|
|
1018
1073
|
fingerprint: notice.fingerprint,
|
|
1019
1074
|
tags: notice.tags,
|
|
1020
|
-
causes: (0, util_1$
|
|
1075
|
+
causes: (0, util_1$6.getCauses)(notice, this.logger),
|
|
1021
1076
|
},
|
|
1022
1077
|
request: {
|
|
1023
|
-
url: (0, util_1$
|
|
1078
|
+
url: (0, util_1$6.filterUrl)(notice.url, this.config.filters),
|
|
1024
1079
|
component: notice.component,
|
|
1025
1080
|
action: notice.action,
|
|
1026
1081
|
context: notice.context,
|
|
1027
1082
|
cgi_data: cgiData,
|
|
1028
|
-
params: (0, util_1$
|
|
1029
|
-
session: (0, util_1$
|
|
1083
|
+
params: (0, util_1$6.filter)(notice.params, this.config.filters) || {},
|
|
1084
|
+
session: (0, util_1$6.filter)(notice.session, this.config.filters) || {}
|
|
1030
1085
|
},
|
|
1031
1086
|
server: {
|
|
1032
1087
|
project_root: notice.projectRoot,
|
|
@@ -1092,7 +1147,7 @@
|
|
|
1092
1147
|
var util = {};
|
|
1093
1148
|
|
|
1094
1149
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
1095
|
-
util.preferCatch = util.encodeCookie = util.decodeCookie = util.localURLPathname = util.parseURL = util.nativeFetch = util.stringTextOfElement = util.stringSelectorOfElement = util.stringNameOfElement = void 0;
|
|
1150
|
+
util.globalThisOrWindow = util.preferCatch = util.encodeCookie = util.decodeCookie = util.localURLPathname = util.parseURL = util.nativeFetch = util.stringTextOfElement = util.stringSelectorOfElement = util.stringNameOfElement = void 0;
|
|
1096
1151
|
/**
|
|
1097
1152
|
* Converts an HTMLElement into a human-readable string.
|
|
1098
1153
|
* @param {!HTMLElement} element
|
|
@@ -1149,10 +1204,11 @@
|
|
|
1149
1204
|
}
|
|
1150
1205
|
util.stringTextOfElement = stringTextOfElement;
|
|
1151
1206
|
function nativeFetch() {
|
|
1152
|
-
|
|
1207
|
+
var global = globalThisOrWindow();
|
|
1208
|
+
if (!global.fetch) {
|
|
1153
1209
|
return false;
|
|
1154
1210
|
}
|
|
1155
|
-
if (isNative(
|
|
1211
|
+
if (isNative(global.fetch)) {
|
|
1156
1212
|
return true;
|
|
1157
1213
|
}
|
|
1158
1214
|
// If fetch isn't native, it may be wrapped by someone else. Try to get
|
|
@@ -1248,6 +1304,9 @@
|
|
|
1248
1304
|
// will provide more information in modern browsers.
|
|
1249
1305
|
util.preferCatch = (function () {
|
|
1250
1306
|
var preferCatch = true;
|
|
1307
|
+
// In case we're in an environment without access to "window", lets make sure theres a window.
|
|
1308
|
+
if (typeof window === 'undefined')
|
|
1309
|
+
return preferCatch;
|
|
1251
1310
|
// IE < 10
|
|
1252
1311
|
if (!window.atob) {
|
|
1253
1312
|
preferCatch = false;
|
|
@@ -1265,6 +1324,19 @@
|
|
|
1265
1324
|
}
|
|
1266
1325
|
return preferCatch;
|
|
1267
1326
|
})();
|
|
1327
|
+
/** globalThis has fairly good support. But just in case, lets check its defined.
|
|
1328
|
+
* @see {https://caniuse.com/?search=globalThis}
|
|
1329
|
+
*/
|
|
1330
|
+
function globalThisOrWindow() {
|
|
1331
|
+
if (typeof globalThis !== 'undefined') {
|
|
1332
|
+
return globalThis;
|
|
1333
|
+
}
|
|
1334
|
+
if (typeof self !== 'undefined') {
|
|
1335
|
+
return self;
|
|
1336
|
+
}
|
|
1337
|
+
return window;
|
|
1338
|
+
}
|
|
1339
|
+
util.globalThisOrWindow = globalThisOrWindow;
|
|
1268
1340
|
|
|
1269
1341
|
var onerror = {};
|
|
1270
1342
|
|
|
@@ -1272,6 +1344,7 @@
|
|
|
1272
1344
|
onerror.onError = onerror.ignoreNextOnError = void 0;
|
|
1273
1345
|
/* eslint-disable prefer-rest-params */
|
|
1274
1346
|
var core_1$5 = src;
|
|
1347
|
+
var util_1$5 = util;
|
|
1275
1348
|
var instrument$4 = core_1$5.Util.instrument, makeNotice = core_1$5.Util.makeNotice;
|
|
1276
1349
|
var ignoreOnError = 0;
|
|
1277
1350
|
var currentTimeout;
|
|
@@ -1285,7 +1358,7 @@
|
|
|
1285
1358
|
onerror.ignoreNextOnError = ignoreNextOnError;
|
|
1286
1359
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1287
1360
|
function onError(_window) {
|
|
1288
|
-
if (_window === void 0) { _window =
|
|
1361
|
+
if (_window === void 0) { _window = (0, util_1$5.globalThisOrWindow)(); }
|
|
1289
1362
|
return {
|
|
1290
1363
|
load: function (client) {
|
|
1291
1364
|
instrument$4(_window, 'onerror', function (original) {
|
|
@@ -1330,7 +1403,7 @@
|
|
|
1330
1403
|
return function (msg, url, line, col, err) {
|
|
1331
1404
|
onerror(msg, url, line, col, err);
|
|
1332
1405
|
if (typeof original === 'function') {
|
|
1333
|
-
return original.apply(
|
|
1406
|
+
return original.apply(_window, arguments);
|
|
1334
1407
|
}
|
|
1335
1408
|
return false;
|
|
1336
1409
|
};
|
|
@@ -1345,10 +1418,11 @@
|
|
|
1345
1418
|
Object.defineProperty(onunhandledrejection, "__esModule", { value: true });
|
|
1346
1419
|
/* eslint-disable prefer-rest-params */
|
|
1347
1420
|
var core_1$4 = src;
|
|
1421
|
+
var util_1$4 = util;
|
|
1348
1422
|
var instrument$3 = core_1$4.Util.instrument;
|
|
1349
1423
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1350
1424
|
function default_1$3(_window) {
|
|
1351
|
-
if (_window === void 0) { _window =
|
|
1425
|
+
if (_window === void 0) { _window = (0, util_1$4.globalThisOrWindow)(); }
|
|
1352
1426
|
return {
|
|
1353
1427
|
load: function (client) {
|
|
1354
1428
|
if (!client.config.enableUnhandledRejection) {
|
|
@@ -1406,10 +1480,10 @@
|
|
|
1406
1480
|
Object.defineProperty(breadcrumbs, "__esModule", { value: true });
|
|
1407
1481
|
/* eslint-disable prefer-rest-params */
|
|
1408
1482
|
var core_1$3 = src;
|
|
1409
|
-
var util_1 = util;
|
|
1483
|
+
var util_1$3 = util;
|
|
1410
1484
|
var sanitize$1 = core_1$3.Util.sanitize, instrument$2 = core_1$3.Util.instrument;
|
|
1411
1485
|
function default_1$2(_window) {
|
|
1412
|
-
if (_window === void 0) { _window =
|
|
1486
|
+
if (_window === void 0) { _window = (0, util_1$3.globalThisOrWindow)(); }
|
|
1413
1487
|
return {
|
|
1414
1488
|
load: function (client) {
|
|
1415
1489
|
function breadcrumbsEnabled(type) {
|
|
@@ -1467,9 +1541,9 @@
|
|
|
1467
1541
|
_window.addEventListener('click', function (event) {
|
|
1468
1542
|
var message, selector, text;
|
|
1469
1543
|
try {
|
|
1470
|
-
message = (0, util_1.stringNameOfElement)(event.target);
|
|
1471
|
-
selector = (0, util_1.stringSelectorOfElement)(event.target);
|
|
1472
|
-
text = (0, util_1.stringTextOfElement)(event.target);
|
|
1544
|
+
message = (0, util_1$3.stringNameOfElement)(event.target);
|
|
1545
|
+
selector = (0, util_1$3.stringSelectorOfElement)(event.target);
|
|
1546
|
+
text = (0, util_1$3.stringTextOfElement)(event.target);
|
|
1473
1547
|
}
|
|
1474
1548
|
catch (e) {
|
|
1475
1549
|
message = 'UI Click';
|
|
@@ -1488,13 +1562,16 @@
|
|
|
1488
1562
|
event: event
|
|
1489
1563
|
}
|
|
1490
1564
|
});
|
|
1491
|
-
}, true);
|
|
1565
|
+
}, _window.location ? true : false); // In CloudFlare workers useCapture must be false. window.locaiton is a hacky way to detect it.
|
|
1492
1566
|
})();
|
|
1493
1567
|
// Breadcrumbs: instrument XMLHttpRequest
|
|
1494
1568
|
(function () {
|
|
1495
1569
|
if (!breadcrumbsEnabled('network')) {
|
|
1496
1570
|
return;
|
|
1497
1571
|
}
|
|
1572
|
+
// Some environments may not support XMLHttpRequest.
|
|
1573
|
+
if (typeof XMLHttpRequest === 'undefined')
|
|
1574
|
+
return;
|
|
1498
1575
|
// -- On xhr.open: capture initial metadata
|
|
1499
1576
|
instrument$2(XMLHttpRequest.prototype, 'open', function (original) {
|
|
1500
1577
|
return function () {
|
|
@@ -1502,7 +1579,7 @@
|
|
|
1502
1579
|
var xhr = this;
|
|
1503
1580
|
var url = arguments[1];
|
|
1504
1581
|
var method = typeof arguments[0] === 'string' ? arguments[0].toUpperCase() : arguments[0];
|
|
1505
|
-
var message = "".concat(method, " ").concat((0, util_1.localURLPathname)(url));
|
|
1582
|
+
var message = "".concat(method, " ").concat((0, util_1$3.localURLPathname)(url));
|
|
1506
1583
|
this.__hb_xhr = {
|
|
1507
1584
|
type: 'xhr',
|
|
1508
1585
|
method: method,
|
|
@@ -1559,7 +1636,7 @@
|
|
|
1559
1636
|
if (!breadcrumbsEnabled('network')) {
|
|
1560
1637
|
return;
|
|
1561
1638
|
}
|
|
1562
|
-
if (!(0, util_1.nativeFetch)()) {
|
|
1639
|
+
if (!(0, util_1$3.nativeFetch)()) {
|
|
1563
1640
|
// Polyfills use XHR.
|
|
1564
1641
|
return;
|
|
1565
1642
|
}
|
|
@@ -1587,7 +1664,8 @@
|
|
|
1587
1664
|
if (typeof method === 'string') {
|
|
1588
1665
|
method = method.toUpperCase();
|
|
1589
1666
|
}
|
|
1590
|
-
|
|
1667
|
+
// localURLPathname cant be constructed for CF workers due to reliance on "document".
|
|
1668
|
+
var message = "".concat(method, " ").concat(typeof document === 'undefined' ? url : (0, util_1$3.localURLPathname)(url));
|
|
1591
1669
|
var metadata = {
|
|
1592
1670
|
type: 'fetch',
|
|
1593
1671
|
method: method,
|
|
@@ -1618,6 +1696,10 @@
|
|
|
1618
1696
|
if (!breadcrumbsEnabled('navigation')) {
|
|
1619
1697
|
return;
|
|
1620
1698
|
}
|
|
1699
|
+
if (_window.location == null) {
|
|
1700
|
+
// Most likely in a CF worker, we should be listening to fetch requests instead.
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1621
1703
|
// The last known href of the current page
|
|
1622
1704
|
var lastHref = _window.location.href;
|
|
1623
1705
|
function recordUrlChange(from, to) {
|
|
@@ -1663,9 +1745,10 @@
|
|
|
1663
1745
|
Object.defineProperty(timers, "__esModule", { value: true });
|
|
1664
1746
|
/* eslint-disable prefer-rest-params */
|
|
1665
1747
|
var core_1$2 = src;
|
|
1748
|
+
var util_1$2 = util;
|
|
1666
1749
|
var instrument$1 = core_1$2.Util.instrument;
|
|
1667
1750
|
function default_1$1(_window) {
|
|
1668
|
-
if (_window === void 0) { _window =
|
|
1751
|
+
if (_window === void 0) { _window = (0, util_1$2.globalThisOrWindow)(); }
|
|
1669
1752
|
return {
|
|
1670
1753
|
load: function (client) {
|
|
1671
1754
|
// Wrap timers
|
|
@@ -1699,9 +1782,10 @@
|
|
|
1699
1782
|
|
|
1700
1783
|
Object.defineProperty(event_listeners, "__esModule", { value: true });
|
|
1701
1784
|
var core_1$1 = src;
|
|
1785
|
+
var util_1$1 = util;
|
|
1702
1786
|
var instrument = core_1$1.Util.instrument;
|
|
1703
1787
|
function default_1(_window) {
|
|
1704
|
-
if (_window === void 0) { _window =
|
|
1788
|
+
if (_window === void 0) { _window = (0, util_1$1.globalThisOrWindow)(); }
|
|
1705
1789
|
return {
|
|
1706
1790
|
load: function (client) {
|
|
1707
1791
|
// Wrap event listeners
|
|
@@ -1742,31 +1826,88 @@
|
|
|
1742
1826
|
|
|
1743
1827
|
var transport = {};
|
|
1744
1828
|
|
|
1829
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1830
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1831
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1832
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1833
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1834
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1835
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1836
|
+
});
|
|
1837
|
+
};
|
|
1838
|
+
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
1839
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1840
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1841
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1842
|
+
function step(op) {
|
|
1843
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1844
|
+
while (_) try {
|
|
1845
|
+
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;
|
|
1846
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1847
|
+
switch (op[0]) {
|
|
1848
|
+
case 0: case 1: t = op; break;
|
|
1849
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
1850
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1851
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1852
|
+
default:
|
|
1853
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1854
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1855
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1856
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1857
|
+
if (t[2]) _.ops.pop();
|
|
1858
|
+
_.trys.pop(); continue;
|
|
1859
|
+
}
|
|
1860
|
+
op = body.call(thisArg, _);
|
|
1861
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1862
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1745
1865
|
Object.defineProperty(transport, "__esModule", { value: true });
|
|
1746
1866
|
transport.BrowserTransport = void 0;
|
|
1747
1867
|
var core_1 = src;
|
|
1868
|
+
var util_1 = util;
|
|
1748
1869
|
var sanitize = core_1.Util.sanitize;
|
|
1870
|
+
/**
|
|
1871
|
+
* Helper function to get typesafe Object.entries()
|
|
1872
|
+
* https://twitter.com/mattpocockuk/status/1502264005251018754?lang=en
|
|
1873
|
+
*/
|
|
1874
|
+
function objectEntries(obj) {
|
|
1875
|
+
return Object.entries(obj);
|
|
1876
|
+
}
|
|
1749
1877
|
var BrowserTransport = /** @class */ (function () {
|
|
1750
1878
|
function BrowserTransport() {
|
|
1751
1879
|
}
|
|
1752
1880
|
BrowserTransport.prototype.send = function (options, payload) {
|
|
1753
|
-
return
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1881
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1882
|
+
var headerArray, headers, requestInit, response, body;
|
|
1883
|
+
return __generator(this, function (_a) {
|
|
1884
|
+
switch (_a.label) {
|
|
1885
|
+
case 0:
|
|
1886
|
+
headerArray = options.headers ? objectEntries(options.headers) : [];
|
|
1887
|
+
headers = {};
|
|
1888
|
+
headerArray.forEach(function (_a) {
|
|
1889
|
+
var key = _a[0], value = _a[1];
|
|
1890
|
+
if (key != null && value != null) {
|
|
1891
|
+
headers[String(key)] = String(value);
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
requestInit = {
|
|
1895
|
+
method: options.method,
|
|
1896
|
+
headers: headers
|
|
1897
|
+
};
|
|
1898
|
+
// GET methods cannot have a body.
|
|
1899
|
+
if (options.method === 'POST') {
|
|
1900
|
+
requestInit.body = payload ? JSON.stringify(sanitize(payload, options.maxObjectDepth)) : undefined;
|
|
1761
1901
|
}
|
|
1762
|
-
|
|
1902
|
+
return [4 /*yield*/, (0, util_1.globalThisOrWindow)().fetch(options.endpoint, requestInit)];
|
|
1903
|
+
case 1:
|
|
1904
|
+
response = _a.sent();
|
|
1905
|
+
return [4 /*yield*/, response.text()];
|
|
1906
|
+
case 2:
|
|
1907
|
+
body = _a.sent();
|
|
1908
|
+
return [2 /*return*/, Promise.resolve({ statusCode: response.status, body: body })];
|
|
1763
1909
|
}
|
|
1764
|
-
|
|
1765
|
-
x_1.onload = function () { return resolve({ statusCode: x_1.status, body: x_1.response }); };
|
|
1766
|
-
}
|
|
1767
|
-
catch (err) {
|
|
1768
|
-
reject(err);
|
|
1769
|
-
}
|
|
1910
|
+
});
|
|
1770
1911
|
});
|
|
1771
1912
|
};
|
|
1772
1913
|
return BrowserTransport;
|
|
@@ -1818,7 +1959,14 @@
|
|
|
1818
1959
|
__extends(Honeybadger, _super);
|
|
1819
1960
|
function Honeybadger(opts) {
|
|
1820
1961
|
if (opts === void 0) { opts = {}; }
|
|
1821
|
-
var _this =
|
|
1962
|
+
var _this = this;
|
|
1963
|
+
var global = (0, util_1.globalThisOrWindow)();
|
|
1964
|
+
var projectRoot = '';
|
|
1965
|
+
// Cloudflare workers do not have access to location API.
|
|
1966
|
+
if (global.location != null) {
|
|
1967
|
+
projectRoot = global.location.protocol + '//' + global.location.host;
|
|
1968
|
+
}
|
|
1969
|
+
_this = _super.call(this, __assign({ async: true, maxErrors: null, projectRoot: projectRoot }, opts), new transport_1.BrowserTransport()) || this;
|
|
1822
1970
|
/** @internal */
|
|
1823
1971
|
_this.__errorsSent = 0;
|
|
1824
1972
|
/** @internal */
|
|
@@ -1830,7 +1978,7 @@
|
|
|
1830
1978
|
_this.logger.debug('Dropping notice: max errors exceeded', notice);
|
|
1831
1979
|
return false;
|
|
1832
1980
|
}
|
|
1833
|
-
if (notice && !notice.url) {
|
|
1981
|
+
if (notice && !notice.url && typeof document !== 'undefined') {
|
|
1834
1982
|
notice.url = document.URL;
|
|
1835
1983
|
}
|
|
1836
1984
|
_this.__incrementErrorsCount();
|
|
@@ -1861,7 +2009,7 @@
|
|
|
1861
2009
|
HTTP_COOKIE: undefined
|
|
1862
2010
|
};
|
|
1863
2011
|
cgiData.HTTP_USER_AGENT = navigator.userAgent;
|
|
1864
|
-
if (document.referrer.match(/\S/)) {
|
|
2012
|
+
if (typeof document !== 'undefined' && document.referrer.match(/\S/)) {
|
|
1865
2013
|
cgiData.HTTP_REFERER = document.referrer;
|
|
1866
2014
|
}
|
|
1867
2015
|
var cookiesObject;
|