@honeybadger-io/js 3.2.4 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/honeybadger.js +193 -80
- 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/types/browser/util.d.ts +1 -1
- package/dist/browser/types/core/client.d.ts +9 -1
- package/dist/browser/types/core/error.d.ts +3 -0
- package/dist/browser/types/core/types.d.ts +5 -4
- package/dist/browser/types/core/util.d.ts +4 -2
- package/dist/browser/types/server/aws_lambda.d.ts +9 -0
- package/dist/browser/types/server/integrations/uncaught_exception.d.ts +2 -0
- package/dist/browser/types/server/integrations/unhandled_rejection.d.ts +2 -0
- package/dist/browser/types/server/middleware.d.ts +4 -0
- package/dist/browser/types/server/util.d.ts +9 -0
- package/dist/browser/types/server.d.ts +13 -0
- package/dist/server/honeybadger.d.ts +2 -1
- package/dist/server/honeybadger.js +313 -93
- package/dist/server/types/browser/integrations/breadcrumbs.d.ts +2 -0
- package/dist/server/types/browser/integrations/event_listeners.d.ts +2 -0
- package/dist/server/types/browser/integrations/onerror.d.ts +3 -0
- package/dist/server/types/browser/integrations/onunhandledrejection.d.ts +2 -0
- package/dist/server/types/browser/integrations/timers.d.ts +2 -0
- package/dist/server/types/browser/util.d.ts +18 -0
- package/dist/server/types/browser.d.ts +15 -0
- package/dist/server/types/core/client.d.ts +9 -1
- package/dist/server/types/core/error.d.ts +3 -0
- package/dist/server/types/core/types.d.ts +5 -4
- package/dist/server/types/core/util.d.ts +4 -2
- package/dist/server/types/server/aws_lambda.d.ts +9 -0
- package/dist/server/types/server/middleware.d.ts +3 -5
- package/dist/server/types/server/util.d.ts +7 -0
- package/dist/server/types/server.d.ts +2 -1
- package/honeybadger.d.ts +2 -1
- package/package.json +23 -21
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Honeybadger = factory());
|
|
5
|
-
}(this, (function () { 'use strict';
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -215,7 +215,8 @@
|
|
|
215
215
|
function makeBacktrace(stack, shift) {
|
|
216
216
|
if (shift === void 0) { shift = 0; }
|
|
217
217
|
try {
|
|
218
|
-
var backtrace = parse(stack)
|
|
218
|
+
var backtrace = parse(stack)
|
|
219
|
+
.map(function (line) {
|
|
219
220
|
return {
|
|
220
221
|
file: line.file,
|
|
221
222
|
method: line.methodName,
|
|
@@ -231,17 +232,39 @@
|
|
|
231
232
|
return [];
|
|
232
233
|
}
|
|
233
234
|
}
|
|
235
|
+
function getSourceForBacktrace(backtrace, getSourceFileHandler, cb) {
|
|
236
|
+
if (!getSourceFileHandler || !backtrace || !backtrace.length) {
|
|
237
|
+
cb([]);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
var result = [];
|
|
241
|
+
var getSourceFromFile = function (index) {
|
|
242
|
+
if (index === void 0) { index = 0; }
|
|
243
|
+
if (!backtrace.length) {
|
|
244
|
+
return cb(result);
|
|
245
|
+
}
|
|
246
|
+
var trace = backtrace.splice(0)[index];
|
|
247
|
+
getSourceFileHandler(trace.file, (function (fileContent) {
|
|
248
|
+
result[index] = getSourceCodeSnippet(fileContent, trace.number);
|
|
249
|
+
getSourceFromFile(index + 1);
|
|
250
|
+
}));
|
|
251
|
+
};
|
|
252
|
+
getSourceFromFile();
|
|
253
|
+
}
|
|
234
254
|
function runBeforeNotifyHandlers(notice, handlers) {
|
|
255
|
+
var result = true;
|
|
235
256
|
for (var i = 0, len = handlers.length; i < len; i++) {
|
|
236
257
|
var handler = handlers[i];
|
|
237
258
|
if (handler(notice) === false) {
|
|
238
|
-
|
|
259
|
+
result = false;
|
|
239
260
|
}
|
|
240
261
|
}
|
|
241
|
-
return
|
|
262
|
+
return result;
|
|
242
263
|
}
|
|
243
264
|
function runAfterNotifyHandlers(notice, handlers, error) {
|
|
244
|
-
if (
|
|
265
|
+
if (notice && notice.afterNotify) {
|
|
266
|
+
handlers.unshift(notice.afterNotify);
|
|
267
|
+
}
|
|
245
268
|
for (var i = 0, len = handlers.length; i < len; i++) {
|
|
246
269
|
handlers[i](error, notice);
|
|
247
270
|
}
|
|
@@ -329,8 +352,13 @@
|
|
|
329
352
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
330
353
|
args[_i] = arguments[_i];
|
|
331
354
|
}
|
|
332
|
-
if (method === 'debug'
|
|
333
|
-
|
|
355
|
+
if (method === 'debug') {
|
|
356
|
+
if (!client.config.debug) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
// Log at default level so that you don't need to also enable verbose
|
|
360
|
+
// logging in Chrome.
|
|
361
|
+
method = 'log';
|
|
334
362
|
}
|
|
335
363
|
args.unshift('[Honeybadger]');
|
|
336
364
|
(_a = client.config.logger)[method].apply(_a, args);
|
|
@@ -394,7 +422,7 @@
|
|
|
394
422
|
function endpoint(config, path) {
|
|
395
423
|
var endpoint = config.endpoint.trim().replace(/\/$/, '');
|
|
396
424
|
path = path.trim().replace(/(^\/|\/$)/g, '');
|
|
397
|
-
return endpoint
|
|
425
|
+
return "".concat(endpoint, "/").concat(path);
|
|
398
426
|
}
|
|
399
427
|
function generateStackTrace() {
|
|
400
428
|
try {
|
|
@@ -453,7 +481,9 @@
|
|
|
453
481
|
return newObj;
|
|
454
482
|
}
|
|
455
483
|
if (is('Array', obj)) {
|
|
456
|
-
return obj.map(function (v) {
|
|
484
|
+
return obj.map(function (v) {
|
|
485
|
+
return filter(v);
|
|
486
|
+
});
|
|
457
487
|
}
|
|
458
488
|
if (is('Function', obj)) {
|
|
459
489
|
return '[FUNC]';
|
|
@@ -489,7 +519,7 @@
|
|
|
489
519
|
query.split(/[&]\s?/).forEach(function (pair) {
|
|
490
520
|
var _a = pair.split('=', 2), key = _a[0], value = _a[1];
|
|
491
521
|
if (filterMatch(key, filters)) {
|
|
492
|
-
result = result.replace(key
|
|
522
|
+
result = result.replace("".concat(key, "=").concat(value), "".concat(key, "=[FILTERED]"));
|
|
493
523
|
}
|
|
494
524
|
});
|
|
495
525
|
return result;
|
|
@@ -503,11 +533,30 @@
|
|
|
503
533
|
});
|
|
504
534
|
return formattedVars;
|
|
505
535
|
}
|
|
536
|
+
function getSourceCodeSnippet(fileData, lineNumber, sourceRadius) {
|
|
537
|
+
if (sourceRadius === void 0) { sourceRadius = 2; }
|
|
538
|
+
if (!fileData) {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
var lines = fileData.split('\n');
|
|
542
|
+
// add one empty line because array index starts from 0, but error line number is counted from 1
|
|
543
|
+
lines.unshift('');
|
|
544
|
+
var start = lineNumber - sourceRadius;
|
|
545
|
+
var end = lineNumber + sourceRadius;
|
|
546
|
+
var result = {};
|
|
547
|
+
for (var i = start; i <= end; i++) {
|
|
548
|
+
var line = lines[i];
|
|
549
|
+
if (typeof line === 'string') {
|
|
550
|
+
result[i] = line;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return result;
|
|
554
|
+
}
|
|
506
555
|
|
|
507
556
|
var notifier = {
|
|
508
557
|
name: 'honeybadger-js',
|
|
509
558
|
url: 'https://github.com/honeybadger-io/honeybadger-js',
|
|
510
|
-
version: '
|
|
559
|
+
version: '4.0.0-beta.0'
|
|
511
560
|
};
|
|
512
561
|
// Split at commas
|
|
513
562
|
var TAG_SEPARATOR = /,/;
|
|
@@ -530,7 +579,7 @@
|
|
|
530
579
|
this.__beforeNotifyHandlers = [];
|
|
531
580
|
/** @internal */
|
|
532
581
|
this.__afterNotifyHandlers = [];
|
|
533
|
-
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'],
|
|
582
|
+
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);
|
|
534
583
|
this.logger = logger(this);
|
|
535
584
|
}
|
|
536
585
|
Client.prototype.factory = function (_opts) {
|
|
@@ -580,22 +629,106 @@
|
|
|
580
629
|
this.__breadcrumbs = [];
|
|
581
630
|
return this;
|
|
582
631
|
};
|
|
583
|
-
Client.prototype.notify = function (
|
|
632
|
+
Client.prototype.notify = function (noticeable, name, extra) {
|
|
633
|
+
var _this = this;
|
|
584
634
|
if (name === void 0) { name = undefined; }
|
|
585
635
|
if (extra === void 0) { extra = undefined; }
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
636
|
+
var preConditionError = null;
|
|
637
|
+
var notice = this.makeNotice(noticeable, name, extra);
|
|
638
|
+
if (!notice) {
|
|
639
|
+
this.logger.debug('failed to build error report');
|
|
640
|
+
preConditionError = new Error('failed to build error report');
|
|
589
641
|
}
|
|
590
|
-
if (this.config.
|
|
591
|
-
this.logger.
|
|
592
|
-
|
|
642
|
+
if (!preConditionError && this.config.reportData === false) {
|
|
643
|
+
this.logger.debug('skipping error report: honeybadger.js is disabled', notice);
|
|
644
|
+
preConditionError = new Error('honeybadger.js is disabled');
|
|
645
|
+
}
|
|
646
|
+
if (!preConditionError && this.__developmentMode()) {
|
|
647
|
+
this.logger.log('honeybadger.js is in development mode; the following error report will be sent in production.', notice);
|
|
648
|
+
preConditionError = new Error('honeybadger.js is in development mode');
|
|
649
|
+
}
|
|
650
|
+
if (!preConditionError && !this.config.apiKey) {
|
|
651
|
+
this.logger.warn('could not send error report: no API key has been configured', notice);
|
|
652
|
+
preConditionError = new Error('missing API key');
|
|
593
653
|
}
|
|
594
|
-
|
|
595
|
-
|
|
654
|
+
var beforeNotifyResult = runBeforeNotifyHandlers(notice, this.__beforeNotifyHandlers);
|
|
655
|
+
if (!preConditionError && !beforeNotifyResult) {
|
|
656
|
+
this.logger.debug('skipping error report: beforeNotify handlers returned false', notice);
|
|
657
|
+
preConditionError = new Error('beforeNotify handlers returned false');
|
|
658
|
+
}
|
|
659
|
+
if (preConditionError) {
|
|
660
|
+
runAfterNotifyHandlers(notice, this.__afterNotifyHandlers, preConditionError);
|
|
596
661
|
return false;
|
|
597
662
|
}
|
|
598
|
-
|
|
663
|
+
this.addBreadcrumb('Honeybadger Notice', {
|
|
664
|
+
category: 'notice',
|
|
665
|
+
metadata: {
|
|
666
|
+
message: notice.message,
|
|
667
|
+
name: notice.name,
|
|
668
|
+
stack: notice.stack
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? this.__breadcrumbs.slice() : [];
|
|
672
|
+
// we need to have the source file data before the beforeNotifyHandlers,
|
|
673
|
+
// in case they modify them
|
|
674
|
+
var sourceCodeData = notice ? notice.backtrace.slice() : null;
|
|
675
|
+
getSourceForBacktrace(sourceCodeData, this.__getSourceFileHandler, function (sourcePerTrace) {
|
|
676
|
+
sourcePerTrace.forEach(function (source, index) {
|
|
677
|
+
notice.backtrace[index].source = source;
|
|
678
|
+
});
|
|
679
|
+
_this.__send(notice);
|
|
680
|
+
});
|
|
681
|
+
return true;
|
|
682
|
+
};
|
|
683
|
+
/**
|
|
684
|
+
* An async version of {@link notify} that resolves only after the notice has been reported to Honeybadger.
|
|
685
|
+
* Implemented using the {@link afterNotify} hook.
|
|
686
|
+
* Rejects if for any reason the report failed to be reported.
|
|
687
|
+
* Useful in serverless environments (AWS Lambda).
|
|
688
|
+
*/
|
|
689
|
+
Client.prototype.notifyAsync = function (noticeable, name, extra) {
|
|
690
|
+
var _this = this;
|
|
691
|
+
if (name === void 0) { name = undefined; }
|
|
692
|
+
if (extra === void 0) { extra = undefined; }
|
|
693
|
+
return new Promise(function (resolve, reject) {
|
|
694
|
+
var applyAfterNotify = function (partialNotice) {
|
|
695
|
+
var originalAfterNotify = partialNotice.afterNotify;
|
|
696
|
+
partialNotice.afterNotify = function (err) {
|
|
697
|
+
originalAfterNotify === null || originalAfterNotify === void 0 ? void 0 : originalAfterNotify.call(_this, err);
|
|
698
|
+
if (err) {
|
|
699
|
+
return reject(err);
|
|
700
|
+
}
|
|
701
|
+
resolve();
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
// We have to respect any afterNotify hooks that come from the arguments
|
|
705
|
+
var objectToOverride;
|
|
706
|
+
if (noticeable.afterNotify) {
|
|
707
|
+
objectToOverride = noticeable;
|
|
708
|
+
}
|
|
709
|
+
else if (name && name.afterNotify) {
|
|
710
|
+
objectToOverride = name;
|
|
711
|
+
}
|
|
712
|
+
else if (extra && extra.afterNotify) {
|
|
713
|
+
objectToOverride = extra;
|
|
714
|
+
}
|
|
715
|
+
else if (name && typeof name === 'object') {
|
|
716
|
+
objectToOverride = name;
|
|
717
|
+
}
|
|
718
|
+
else if (extra) {
|
|
719
|
+
objectToOverride = extra;
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
objectToOverride = name = {};
|
|
723
|
+
}
|
|
724
|
+
applyAfterNotify(objectToOverride);
|
|
725
|
+
_this.notify(noticeable, name, extra);
|
|
726
|
+
});
|
|
727
|
+
};
|
|
728
|
+
Client.prototype.makeNotice = function (noticeable, name, extra) {
|
|
729
|
+
if (name === void 0) { name = undefined; }
|
|
730
|
+
if (extra === void 0) { extra = undefined; }
|
|
731
|
+
var notice = makeNotice(noticeable);
|
|
599
732
|
if (name && !(typeof name === 'object')) {
|
|
600
733
|
var n = String(name);
|
|
601
734
|
name = { name: n };
|
|
@@ -607,7 +740,7 @@
|
|
|
607
740
|
notice = mergeNotice(notice, extra);
|
|
608
741
|
}
|
|
609
742
|
if (objectIsEmpty(notice)) {
|
|
610
|
-
return
|
|
743
|
+
return null;
|
|
611
744
|
}
|
|
612
745
|
var noticeTags = this.__constructTags(notice.tags);
|
|
613
746
|
var contextTags = this.__constructTags(this.__context["tags"]);
|
|
@@ -631,19 +764,7 @@
|
|
|
631
764
|
backtraceShift = 2;
|
|
632
765
|
}
|
|
633
766
|
notice.backtrace = makeBacktrace(notice.stack, backtraceShift);
|
|
634
|
-
|
|
635
|
-
return false;
|
|
636
|
-
}
|
|
637
|
-
this.addBreadcrumb('Honeybadger Notice', {
|
|
638
|
-
category: 'notice',
|
|
639
|
-
metadata: {
|
|
640
|
-
message: notice.message,
|
|
641
|
-
name: notice.name,
|
|
642
|
-
stack: notice.stack
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? this.__breadcrumbs.slice() : [];
|
|
646
|
-
return this.__send(notice);
|
|
767
|
+
return notice;
|
|
647
768
|
};
|
|
648
769
|
Client.prototype.addBreadcrumb = function (message, opts) {
|
|
649
770
|
if (!this.config.breadcrumbsEnabled) {
|
|
@@ -666,11 +787,11 @@
|
|
|
666
787
|
return this;
|
|
667
788
|
};
|
|
668
789
|
/** @internal */
|
|
669
|
-
Client.prototype.
|
|
670
|
-
if (this.config.reportData
|
|
671
|
-
return
|
|
790
|
+
Client.prototype.__developmentMode = function () {
|
|
791
|
+
if (this.config.reportData === true) {
|
|
792
|
+
return false;
|
|
672
793
|
}
|
|
673
|
-
return
|
|
794
|
+
return (this.config.environment && this.config.developmentEnvironments.includes(this.config.environment));
|
|
674
795
|
};
|
|
675
796
|
/** @internal */
|
|
676
797
|
Client.prototype.__send = function (_notice) {
|
|
@@ -739,23 +860,23 @@
|
|
|
739
860
|
return '';
|
|
740
861
|
}
|
|
741
862
|
if (element.id) {
|
|
742
|
-
name += "#"
|
|
863
|
+
name += "#".concat(element.id);
|
|
743
864
|
}
|
|
744
865
|
var stringClassNames = element.getAttribute('class');
|
|
745
866
|
if (stringClassNames) {
|
|
746
867
|
stringClassNames.split(/\s+/).forEach(function (className) {
|
|
747
|
-
name += "."
|
|
868
|
+
name += ".".concat(className);
|
|
748
869
|
});
|
|
749
870
|
}
|
|
750
871
|
['alt', 'name', 'title', 'type'].forEach(function (attrName) {
|
|
751
872
|
var attr = element.getAttribute(attrName);
|
|
752
873
|
if (attr) {
|
|
753
|
-
name += "["
|
|
874
|
+
name += "[".concat(attrName, "=\"").concat(attr, "\"]");
|
|
754
875
|
}
|
|
755
876
|
});
|
|
756
877
|
var siblings = getSiblings(element);
|
|
757
878
|
if (siblings.length > 1) {
|
|
758
|
-
name += ":nth-child("
|
|
879
|
+
name += ":nth-child(".concat(Array.prototype.indexOf.call(siblings, element) + 1, ")");
|
|
759
880
|
}
|
|
760
881
|
return name;
|
|
761
882
|
}
|
|
@@ -764,7 +885,7 @@
|
|
|
764
885
|
if (element.parentNode && element.parentNode.tagName) {
|
|
765
886
|
var parentName = stringSelectorOfElement(element.parentNode);
|
|
766
887
|
if (parentName.length > 0) {
|
|
767
|
-
return parentName
|
|
888
|
+
return "".concat(parentName, " > ").concat(name);
|
|
768
889
|
}
|
|
769
890
|
}
|
|
770
891
|
return name;
|
|
@@ -824,7 +945,7 @@
|
|
|
824
945
|
return parsed.pathname;
|
|
825
946
|
}
|
|
826
947
|
// x-domain
|
|
827
|
-
return parsed.protocol
|
|
948
|
+
return "".concat(parsed.protocol, "://").concat(parsed.host).concat(parsed.pathname);
|
|
828
949
|
}
|
|
829
950
|
function decodeCookie(string) {
|
|
830
951
|
var result = {};
|
|
@@ -912,12 +1033,12 @@
|
|
|
912
1033
|
ignoreOnError -= 1;
|
|
913
1034
|
return;
|
|
914
1035
|
}
|
|
915
|
-
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
1036
|
+
// See https://developer.mozilla.org/en/docs/Web/API/GlobalEventHandlers/onerror#Notes
|
|
918
1037
|
if (line === 0 && /Script error\.?/.test(msg)) {
|
|
919
|
-
|
|
920
|
-
|
|
1038
|
+
if (client.config.enableUncaught) {
|
|
1039
|
+
// Log only if the user wants to report uncaught errors
|
|
1040
|
+
client.logger.warn('Ignoring cross-domain script error: enable CORS to track these types of errors', arguments);
|
|
1041
|
+
}
|
|
921
1042
|
return;
|
|
922
1043
|
}
|
|
923
1044
|
var notice = makeNotice(err);
|
|
@@ -931,7 +1052,7 @@
|
|
|
931
1052
|
// Simulate v8 stack
|
|
932
1053
|
notice.stack = [notice.message, '\n at ? (', url || 'unknown', ':', line || 0, ':', col || 0, ')'].join('');
|
|
933
1054
|
}
|
|
934
|
-
client.addBreadcrumb((notice.name === 'window.onerror' || !notice.name) ? 'window.onerror' : "window.onerror: "
|
|
1055
|
+
client.addBreadcrumb((notice.name === 'window.onerror' || !notice.name) ? 'window.onerror' : "window.onerror: ".concat(notice.name), {
|
|
935
1056
|
category: 'error',
|
|
936
1057
|
metadata: {
|
|
937
1058
|
name: notice.name,
|
|
@@ -939,7 +1060,9 @@
|
|
|
939
1060
|
stack: notice.stack
|
|
940
1061
|
}
|
|
941
1062
|
});
|
|
942
|
-
client.
|
|
1063
|
+
if (client.config.enableUncaught) {
|
|
1064
|
+
client.notify(notice);
|
|
1065
|
+
}
|
|
943
1066
|
};
|
|
944
1067
|
return function (msg, url, line, col, err) {
|
|
945
1068
|
onerror(msg, url, line, col, err);
|
|
@@ -977,14 +1100,14 @@
|
|
|
977
1100
|
// const lineNumber = reason.lineNumber || 0
|
|
978
1101
|
var fileName = 'unknown';
|
|
979
1102
|
var lineNumber = 0;
|
|
980
|
-
var stackFallback = reason.message
|
|
1103
|
+
var stackFallback = "".concat(reason.message, "\n at ? (").concat(fileName, ":").concat(lineNumber, ")");
|
|
981
1104
|
var stack = reason.stack || stackFallback;
|
|
982
1105
|
var err = {
|
|
983
1106
|
name: reason.name,
|
|
984
|
-
message: "UnhandledPromiseRejectionWarning: "
|
|
1107
|
+
message: "UnhandledPromiseRejectionWarning: ".concat(reason),
|
|
985
1108
|
stack: stack
|
|
986
1109
|
};
|
|
987
|
-
client.addBreadcrumb("window.onunhandledrejection: "
|
|
1110
|
+
client.addBreadcrumb("window.onunhandledrejection: ".concat(err.name), {
|
|
988
1111
|
category: 'error',
|
|
989
1112
|
metadata: err
|
|
990
1113
|
});
|
|
@@ -994,7 +1117,7 @@
|
|
|
994
1117
|
var message = typeof reason === 'string' ? reason : ((_a = JSON.stringify(reason)) !== null && _a !== void 0 ? _a : 'Unspecified reason');
|
|
995
1118
|
client.notify({
|
|
996
1119
|
name: 'window.onunhandledrejection',
|
|
997
|
-
message: "UnhandledPromiseRejectionWarning: "
|
|
1120
|
+
message: "UnhandledPromiseRejectionWarning: ".concat(message)
|
|
998
1121
|
});
|
|
999
1122
|
}
|
|
1000
1123
|
return function (promiseRejectionEvent) {
|
|
@@ -1103,7 +1226,7 @@
|
|
|
1103
1226
|
var xhr = this;
|
|
1104
1227
|
var url = arguments[1];
|
|
1105
1228
|
var method = typeof arguments[0] === 'string' ? arguments[0].toUpperCase() : arguments[0];
|
|
1106
|
-
var message = method
|
|
1229
|
+
var message = "".concat(method, " ").concat(localURLPathname(url));
|
|
1107
1230
|
this.__hb_xhr = {
|
|
1108
1231
|
type: 'xhr',
|
|
1109
1232
|
method: method,
|
|
@@ -1188,7 +1311,7 @@
|
|
|
1188
1311
|
if (typeof method === 'string') {
|
|
1189
1312
|
method = method.toUpperCase();
|
|
1190
1313
|
}
|
|
1191
|
-
var message = method
|
|
1314
|
+
var message = "".concat(method, " ").concat(localURLPathname(url));
|
|
1192
1315
|
var metadata = {
|
|
1193
1316
|
type: 'fetch',
|
|
1194
1317
|
method: method,
|
|
@@ -1301,7 +1424,7 @@
|
|
|
1301
1424
|
var prototype = _window[prop] && _window[prop].prototype;
|
|
1302
1425
|
if (prototype && Object.prototype.hasOwnProperty.call(prototype, 'addEventListener')) {
|
|
1303
1426
|
instrument(prototype, 'addEventListener', function (original) {
|
|
1304
|
-
var wrapOpts = { component: prop
|
|
1427
|
+
var wrapOpts = { component: "".concat(prop, ".prototype.addEventListener") };
|
|
1305
1428
|
// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
|
|
1306
1429
|
return function (type, listener, useCapture, wantsUntrusted) {
|
|
1307
1430
|
try {
|
|
@@ -1392,10 +1515,6 @@
|
|
|
1392
1515
|
var _this = this;
|
|
1393
1516
|
this.__incrementErrorsCount();
|
|
1394
1517
|
var payload = this.__buildPayload(notice);
|
|
1395
|
-
var handlers = Array.prototype.slice.call(this.__afterNotifyHandlers);
|
|
1396
|
-
if (notice.afterNotify) {
|
|
1397
|
-
handlers.unshift(notice.afterNotify);
|
|
1398
|
-
}
|
|
1399
1518
|
try {
|
|
1400
1519
|
var x_1 = new XMLHttpRequest();
|
|
1401
1520
|
x_1.open('POST', endpoint(this.config, '/v1/notices/js'), this.config.async);
|
|
@@ -1405,21 +1524,20 @@
|
|
|
1405
1524
|
x_1.send(JSON.stringify(sanitize(payload, this.config.maxObjectDepth)));
|
|
1406
1525
|
x_1.onload = function () {
|
|
1407
1526
|
if (x_1.status !== 201) {
|
|
1408
|
-
runAfterNotifyHandlers(notice,
|
|
1409
|
-
_this.logger.debug("Unable to send error report: "
|
|
1527
|
+
runAfterNotifyHandlers(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(x_1.status)));
|
|
1528
|
+
_this.logger.debug("Unable to send error report: ".concat(x_1.status, ": ").concat(x_1.statusText), x_1, notice);
|
|
1410
1529
|
return;
|
|
1411
1530
|
}
|
|
1412
1531
|
runAfterNotifyHandlers(merge(notice, {
|
|
1413
1532
|
id: JSON.parse(x_1.response).id
|
|
1414
|
-
}),
|
|
1533
|
+
}), _this.__afterNotifyHandlers);
|
|
1415
1534
|
_this.logger.debug('Error report sent', notice);
|
|
1416
1535
|
};
|
|
1417
1536
|
}
|
|
1418
1537
|
catch (err) {
|
|
1419
|
-
runAfterNotifyHandlers(notice,
|
|
1538
|
+
runAfterNotifyHandlers(notice, this.__afterNotifyHandlers, err);
|
|
1420
1539
|
this.logger.error('Unable to send error report: error while initializing request', err, notice);
|
|
1421
1540
|
}
|
|
1422
|
-
return true;
|
|
1423
1541
|
};
|
|
1424
1542
|
/**
|
|
1425
1543
|
* wrap always returns the same function so that callbacks can be removed via
|
|
@@ -1443,14 +1561,7 @@
|
|
|
1443
1561
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1444
1562
|
var client_1 = this;
|
|
1445
1563
|
func.___hb = function () {
|
|
1446
|
-
|
|
1447
|
-
// Catch if:
|
|
1448
|
-
// 1. We explicitly want to catch (i.e. if the error could be
|
|
1449
|
-
// caught before reaching window.onerror)
|
|
1450
|
-
// 2. The browser provides less information via the window.onerror
|
|
1451
|
-
// handler
|
|
1452
|
-
// 3. The window.onerror handler is unavailable
|
|
1453
|
-
if (opts.catch || preferCatch || !onErrorEnabled) {
|
|
1564
|
+
if (preferCatch) {
|
|
1454
1565
|
try {
|
|
1455
1566
|
// eslint-disable-next-line prefer-rest-params
|
|
1456
1567
|
return func.apply(this, arguments);
|
|
@@ -1461,7 +1572,7 @@
|
|
|
1461
1572
|
}
|
|
1462
1573
|
client_1.__lastWrapErr = err;
|
|
1463
1574
|
ignoreNextOnError();
|
|
1464
|
-
client_1.addBreadcrumb(opts.component ? opts.component
|
|
1575
|
+
client_1.addBreadcrumb(opts.component ? "".concat(opts.component, ": ").concat(err.name) : err.name, {
|
|
1465
1576
|
category: 'error',
|
|
1466
1577
|
metadata: {
|
|
1467
1578
|
message: err.message,
|
|
@@ -1469,7 +1580,9 @@
|
|
|
1469
1580
|
stack: err.stack
|
|
1470
1581
|
}
|
|
1471
1582
|
});
|
|
1472
|
-
client_1.
|
|
1583
|
+
if (client_1.config.enableUncaught) {
|
|
1584
|
+
client_1.notify(err);
|
|
1585
|
+
}
|
|
1473
1586
|
throw (err);
|
|
1474
1587
|
}
|
|
1475
1588
|
}
|
|
@@ -1508,5 +1621,5 @@
|
|
|
1508
1621
|
|
|
1509
1622
|
return browser;
|
|
1510
1623
|
|
|
1511
|
-
}))
|
|
1624
|
+
}));
|
|
1512
1625
|
//# sourceMappingURL=honeybadger.js.map
|