@honeybadger-io/js 4.2.0 → 4.3.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.d.ts +1 -0
- package/dist/browser/honeybadger.js +256 -245
- 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/server/honeybadger.d.ts +1 -0
- package/dist/server/honeybadger.js +221 -202
- package/package.json +4 -4
|
@@ -20,6 +20,10 @@ var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
|
20
20
|
|
|
21
21
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
22
22
|
|
|
23
|
+
function getDefaultExportFromCjs (x) {
|
|
24
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
function getAugmentedNamespace(n) {
|
|
24
28
|
var f = n.default;
|
|
25
29
|
if (typeof f == "function") {
|
|
@@ -41,7 +45,7 @@ function getAugmentedNamespace(n) {
|
|
|
41
45
|
return a;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
var server = {};
|
|
48
|
+
var server$1 = {};
|
|
45
49
|
|
|
46
50
|
var src = {};
|
|
47
51
|
|
|
@@ -548,12 +552,12 @@ function instrument(object, name, replacement) {
|
|
|
548
552
|
}
|
|
549
553
|
}
|
|
550
554
|
util$1.instrument = instrument;
|
|
551
|
-
function endpoint
|
|
555
|
+
function endpoint(base, path) {
|
|
552
556
|
var endpoint = base.trim().replace(/\/$/, '');
|
|
553
557
|
path = path.trim().replace(/(^\/|\/$)/g, '');
|
|
554
558
|
return "".concat(endpoint, "/").concat(path);
|
|
555
559
|
}
|
|
556
|
-
util$1.endpoint = endpoint
|
|
560
|
+
util$1.endpoint = endpoint;
|
|
557
561
|
function generateStackTrace() {
|
|
558
562
|
try {
|
|
559
563
|
throw new Error('');
|
|
@@ -718,8 +722,8 @@ var GlobalStore = /** @class */ (function () {
|
|
|
718
722
|
}());
|
|
719
723
|
store.GlobalStore = GlobalStore;
|
|
720
724
|
|
|
721
|
-
var __assign
|
|
722
|
-
__assign
|
|
725
|
+
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
726
|
+
__assign = Object.assign || function(t) {
|
|
723
727
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
724
728
|
s = arguments[i];
|
|
725
729
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -727,16 +731,16 @@ var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
|
727
731
|
}
|
|
728
732
|
return t;
|
|
729
733
|
};
|
|
730
|
-
return __assign
|
|
734
|
+
return __assign.apply(this, arguments);
|
|
731
735
|
};
|
|
732
736
|
Object.defineProperty(client, "__esModule", { value: true });
|
|
733
737
|
client.Client = void 0;
|
|
734
|
-
var util_1$
|
|
738
|
+
var util_1$3 = util$1;
|
|
735
739
|
var store_1 = store;
|
|
736
740
|
var notifier = {
|
|
737
741
|
name: 'honeybadger-js',
|
|
738
742
|
url: 'https://github.com/honeybadger-io/honeybadger-js',
|
|
739
|
-
version: '4.
|
|
743
|
+
version: '4.3.0'
|
|
740
744
|
};
|
|
741
745
|
// Split at commas and spaces
|
|
742
746
|
var TAG_SEPARATOR = /,|\s+/;
|
|
@@ -749,12 +753,12 @@ var Client = /** @class */ (function () {
|
|
|
749
753
|
this.__store = null;
|
|
750
754
|
this.__beforeNotifyHandlers = [];
|
|
751
755
|
this.__afterNotifyHandlers = [];
|
|
752
|
-
this.config = __assign
|
|
756
|
+
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);
|
|
753
757
|
// First, we go with the global (shared) store.
|
|
754
758
|
// Webserver middleware can then switch to the AsyncStore for async context tracking.
|
|
755
759
|
this.__store = new store_1.GlobalStore({ context: {}, breadcrumbs: [] });
|
|
756
760
|
this.__transport = transport;
|
|
757
|
-
this.logger = (0, util_1$
|
|
761
|
+
this.logger = (0, util_1$3.logger)(this);
|
|
758
762
|
}
|
|
759
763
|
Client.prototype.getVersion = function () {
|
|
760
764
|
return notifier.version;
|
|
@@ -785,7 +789,7 @@ var Client = /** @class */ (function () {
|
|
|
785
789
|
Client.prototype.setContext = function (context) {
|
|
786
790
|
if (typeof context === 'object') {
|
|
787
791
|
var store = this.__store.getStore();
|
|
788
|
-
store.context = (0, util_1$
|
|
792
|
+
store.context = (0, util_1$3.merge)(store.context, context);
|
|
789
793
|
}
|
|
790
794
|
return this;
|
|
791
795
|
};
|
|
@@ -830,14 +834,14 @@ var Client = /** @class */ (function () {
|
|
|
830
834
|
}
|
|
831
835
|
// we need to have the source file data before the beforeNotifyHandlers,
|
|
832
836
|
// in case they modify them
|
|
833
|
-
var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$
|
|
834
|
-
var beforeNotifyResult = (0, util_1$
|
|
837
|
+
var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$3.shallowClone)(trace); }) : null;
|
|
838
|
+
var beforeNotifyResult = (0, util_1$3.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
|
|
835
839
|
if (!preConditionError && !beforeNotifyResult) {
|
|
836
840
|
this.logger.debug('skipping error report: beforeNotify handlers returned false', notice);
|
|
837
841
|
preConditionError = new Error('beforeNotify handlers returned false');
|
|
838
842
|
}
|
|
839
843
|
if (preConditionError) {
|
|
840
|
-
(0, util_1$
|
|
844
|
+
(0, util_1$3.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionError);
|
|
841
845
|
return false;
|
|
842
846
|
}
|
|
843
847
|
this.addBreadcrumb('Honeybadger Notice', {
|
|
@@ -850,7 +854,7 @@ var Client = /** @class */ (function () {
|
|
|
850
854
|
});
|
|
851
855
|
var breadcrumbs = this.__getStoreContentsOrDefault().breadcrumbs;
|
|
852
856
|
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs.slice() : [];
|
|
853
|
-
(0, util_1$
|
|
857
|
+
(0, util_1$3.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
|
|
854
858
|
.then(function (sourcePerTrace) {
|
|
855
859
|
sourcePerTrace.forEach(function (source, index) {
|
|
856
860
|
notice.backtrace[index].source = source;
|
|
@@ -864,26 +868,26 @@ var Client = /** @class */ (function () {
|
|
|
864
868
|
'Accept': 'text/json, application/json'
|
|
865
869
|
},
|
|
866
870
|
method: 'POST',
|
|
867
|
-
endpoint: (0, util_1$
|
|
871
|
+
endpoint: (0, util_1$3.endpoint)(_this.config.endpoint, '/v1/notices/js'),
|
|
868
872
|
maxObjectDepth: _this.config.maxObjectDepth,
|
|
869
873
|
logger: _this.logger,
|
|
870
|
-
async: (0, util_1$
|
|
874
|
+
async: (0, util_1$3.isBrowserConfig)(_this.config) ? _this.config.async : undefined,
|
|
871
875
|
}, payload)
|
|
872
876
|
.then(function (res) {
|
|
873
877
|
if (res.statusCode !== 201) {
|
|
874
|
-
(0, util_1$
|
|
878
|
+
(0, util_1$3.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode)));
|
|
875
879
|
_this.logger.warn("Error report failed: unknown response from server. code=".concat(res.statusCode));
|
|
876
880
|
return;
|
|
877
881
|
}
|
|
878
882
|
var uuid = JSON.parse(res.body).id;
|
|
879
|
-
(0, util_1$
|
|
883
|
+
(0, util_1$3.runAfterNotifyHandlers)((0, util_1$3.merge)(notice, {
|
|
880
884
|
id: uuid
|
|
881
885
|
}), _this.__afterNotifyHandlers);
|
|
882
886
|
_this.logger.info("Error report sent \u26A1 https://app.honeybadger.io/notice/".concat(uuid));
|
|
883
887
|
})
|
|
884
888
|
.catch(function (err) {
|
|
885
889
|
_this.logger.error('Error report failed: an unknown error occurred.', "message=".concat(err.message));
|
|
886
|
-
(0, util_1$
|
|
890
|
+
(0, util_1$3.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, err);
|
|
887
891
|
});
|
|
888
892
|
});
|
|
889
893
|
return true;
|
|
@@ -936,18 +940,18 @@ var Client = /** @class */ (function () {
|
|
|
936
940
|
Client.prototype.makeNotice = function (noticeable, name, extra) {
|
|
937
941
|
if (name === void 0) { name = undefined; }
|
|
938
942
|
if (extra === void 0) { extra = undefined; }
|
|
939
|
-
var notice = (0, util_1$
|
|
943
|
+
var notice = (0, util_1$3.makeNotice)(noticeable);
|
|
940
944
|
if (name && !(typeof name === 'object')) {
|
|
941
945
|
var n = String(name);
|
|
942
946
|
name = { name: n };
|
|
943
947
|
}
|
|
944
948
|
if (name) {
|
|
945
|
-
notice = (0, util_1$
|
|
949
|
+
notice = (0, util_1$3.mergeNotice)(notice, name);
|
|
946
950
|
}
|
|
947
951
|
if (typeof extra === 'object' && extra !== null) {
|
|
948
|
-
notice = (0, util_1$
|
|
952
|
+
notice = (0, util_1$3.mergeNotice)(notice, extra);
|
|
949
953
|
}
|
|
950
|
-
if ((0, util_1$
|
|
954
|
+
if ((0, util_1$3.objectIsEmpty)(notice)) {
|
|
951
955
|
return null;
|
|
952
956
|
}
|
|
953
957
|
var context = this.__getStoreContentsOrDefault().context;
|
|
@@ -957,9 +961,9 @@ var Client = /** @class */ (function () {
|
|
|
957
961
|
// Turning into a Set will remove duplicates
|
|
958
962
|
var tags = noticeTags.concat(contextTags).concat(configTags);
|
|
959
963
|
var uniqueTags = tags.filter(function (item, index) { return tags.indexOf(item) === index; });
|
|
960
|
-
notice = (0, util_1$
|
|
964
|
+
notice = (0, util_1$3.merge)(notice, {
|
|
961
965
|
name: notice.name || 'Error',
|
|
962
|
-
context: (0, util_1$
|
|
966
|
+
context: (0, util_1$3.merge)(context, notice.context),
|
|
963
967
|
projectRoot: notice.projectRoot || this.config.projectRoot,
|
|
964
968
|
environment: notice.environment || this.config.environment,
|
|
965
969
|
component: notice.component || this.config.component,
|
|
@@ -969,10 +973,10 @@ var Client = /** @class */ (function () {
|
|
|
969
973
|
});
|
|
970
974
|
var backtraceShift = 0;
|
|
971
975
|
if (typeof notice.stack !== 'string' || !notice.stack.trim()) {
|
|
972
|
-
notice.stack = (0, util_1$
|
|
976
|
+
notice.stack = (0, util_1$3.generateStackTrace)();
|
|
973
977
|
backtraceShift = 2;
|
|
974
978
|
}
|
|
975
|
-
notice.backtrace = (0, util_1$
|
|
979
|
+
notice.backtrace = (0, util_1$3.makeBacktrace)(notice.stack, backtraceShift);
|
|
976
980
|
return notice;
|
|
977
981
|
};
|
|
978
982
|
Client.prototype.addBreadcrumb = function (message, opts) {
|
|
@@ -980,7 +984,7 @@ var Client = /** @class */ (function () {
|
|
|
980
984
|
return;
|
|
981
985
|
}
|
|
982
986
|
opts = opts || {};
|
|
983
|
-
var metadata = (0, util_1$
|
|
987
|
+
var metadata = (0, util_1$3.shallowClone)(opts.metadata);
|
|
984
988
|
var category = opts.category || 'custom';
|
|
985
989
|
var timestamp = new Date().toISOString();
|
|
986
990
|
var store = this.__store.getStore();
|
|
@@ -1005,8 +1009,8 @@ var Client = /** @class */ (function () {
|
|
|
1005
1009
|
return (this.config.environment && this.config.developmentEnvironments.includes(this.config.environment));
|
|
1006
1010
|
};
|
|
1007
1011
|
Client.prototype.__buildPayload = function (notice) {
|
|
1008
|
-
var headers = (0, util_1$
|
|
1009
|
-
var cgiData = (0, util_1$
|
|
1012
|
+
var headers = (0, util_1$3.filter)(notice.headers, this.config.filters) || {};
|
|
1013
|
+
var cgiData = (0, util_1$3.filter)(__assign(__assign({}, notice.cgiData), (0, util_1$3.formatCGIData)(headers, 'HTTP_')), this.config.filters);
|
|
1010
1014
|
return {
|
|
1011
1015
|
notifier: notifier,
|
|
1012
1016
|
breadcrumbs: {
|
|
@@ -1019,16 +1023,16 @@ var Client = /** @class */ (function () {
|
|
|
1019
1023
|
backtrace: notice.backtrace,
|
|
1020
1024
|
fingerprint: notice.fingerprint,
|
|
1021
1025
|
tags: notice.tags,
|
|
1022
|
-
causes: (0, util_1$
|
|
1026
|
+
causes: (0, util_1$3.getCauses)(notice),
|
|
1023
1027
|
},
|
|
1024
1028
|
request: {
|
|
1025
|
-
url: (0, util_1$
|
|
1029
|
+
url: (0, util_1$3.filterUrl)(notice.url, this.config.filters),
|
|
1026
1030
|
component: notice.component,
|
|
1027
1031
|
action: notice.action,
|
|
1028
1032
|
context: notice.context,
|
|
1029
1033
|
cgi_data: cgiData,
|
|
1030
|
-
params: (0, util_1$
|
|
1031
|
-
session: (0, util_1$
|
|
1034
|
+
params: (0, util_1$3.filter)(notice.params, this.config.filters) || {},
|
|
1035
|
+
session: (0, util_1$3.filter)(notice.session, this.config.filters) || {}
|
|
1032
1036
|
},
|
|
1033
1037
|
server: {
|
|
1034
1038
|
project_root: notice.projectRoot,
|
|
@@ -1054,7 +1058,7 @@ var Client = /** @class */ (function () {
|
|
|
1054
1058
|
Client.prototype.__getStoreContentsOrDefault = function () {
|
|
1055
1059
|
var existingStoreContents = this.__store.getStore();
|
|
1056
1060
|
var storeContents = existingStoreContents || {};
|
|
1057
|
-
return __assign
|
|
1061
|
+
return __assign({ context: {}, breadcrumbs: [] }, storeContents);
|
|
1058
1062
|
};
|
|
1059
1063
|
return Client;
|
|
1060
1064
|
}());
|
|
@@ -1135,15 +1139,15 @@ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (th
|
|
|
1135
1139
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1136
1140
|
}
|
|
1137
1141
|
};
|
|
1138
|
-
var __importDefault$
|
|
1142
|
+
var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1139
1143
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1140
1144
|
};
|
|
1141
1145
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
1142
1146
|
util.getSourceFile = util.getStats = util.fatallyLogAndExit = void 0;
|
|
1143
|
-
var os_1
|
|
1144
|
-
var fs_1 = __importDefault$
|
|
1145
|
-
var util_1$
|
|
1146
|
-
var readFile = (0, util_1$
|
|
1147
|
+
var os_1 = __importDefault$2(require$$0__default["default"]);
|
|
1148
|
+
var fs_1 = __importDefault$2(require$$1__default["default"]);
|
|
1149
|
+
var util_1$2 = require$$2__default["default"];
|
|
1150
|
+
var readFile = (0, util_1$2.promisify)(fs_1.default.readFile);
|
|
1147
1151
|
function fatallyLogAndExit(err) {
|
|
1148
1152
|
console.error('[Honeybadger] Exiting process due to uncaught exception');
|
|
1149
1153
|
console.error(err.stack || err);
|
|
@@ -1156,7 +1160,7 @@ function getStats() {
|
|
|
1156
1160
|
return __generator(this, function (_a) {
|
|
1157
1161
|
switch (_a.label) {
|
|
1158
1162
|
case 0:
|
|
1159
|
-
load = os_1
|
|
1163
|
+
load = os_1.default.loadavg();
|
|
1160
1164
|
stats = {
|
|
1161
1165
|
load: {
|
|
1162
1166
|
one: load[0],
|
|
@@ -1167,8 +1171,8 @@ function getStats() {
|
|
|
1167
1171
|
};
|
|
1168
1172
|
fallback = function () {
|
|
1169
1173
|
stats.mem = {
|
|
1170
|
-
free: os_1
|
|
1171
|
-
total: os_1
|
|
1174
|
+
free: os_1.default.freemem(),
|
|
1175
|
+
total: os_1.default.totalmem()
|
|
1172
1176
|
};
|
|
1173
1177
|
};
|
|
1174
1178
|
if (!fs_1.default.existsSync('/proc/meminfo')) {
|
|
@@ -1237,7 +1241,7 @@ var async_store = {};
|
|
|
1237
1241
|
|
|
1238
1242
|
Object.defineProperty(async_store, "__esModule", { value: true });
|
|
1239
1243
|
async_store.AsyncStore = void 0;
|
|
1240
|
-
var core_1$
|
|
1244
|
+
var core_1$1 = src;
|
|
1241
1245
|
var Store;
|
|
1242
1246
|
try {
|
|
1243
1247
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -1245,13 +1249,13 @@ try {
|
|
|
1245
1249
|
Store = new AsyncLocalStorage();
|
|
1246
1250
|
}
|
|
1247
1251
|
catch (e) {
|
|
1248
|
-
Store = new core_1$
|
|
1252
|
+
Store = new core_1$1.Store.GlobalStore({ context: {}, breadcrumbs: [] });
|
|
1249
1253
|
}
|
|
1250
1254
|
async_store.AsyncStore = Store;
|
|
1251
1255
|
|
|
1252
1256
|
Object.defineProperty(aws_lambda, "__esModule", { value: true });
|
|
1253
1257
|
aws_lambda.removeAwsDefaultUncaughtExceptionListener = aws_lambda.lambdaHandler = void 0;
|
|
1254
|
-
var async_store_1
|
|
1258
|
+
var async_store_1 = async_store;
|
|
1255
1259
|
function isHandlerSync(handler) {
|
|
1256
1260
|
return handler.length > 2;
|
|
1257
1261
|
}
|
|
@@ -1265,15 +1269,23 @@ function reportToHoneybadger(hb, err, callback) {
|
|
|
1265
1269
|
}
|
|
1266
1270
|
function asyncHandler(handler, hb) {
|
|
1267
1271
|
return function wrappedLambdaHandler(event, context) {
|
|
1268
|
-
hb.__setStore(async_store_1
|
|
1272
|
+
hb.__setStore(async_store_1.AsyncStore);
|
|
1269
1273
|
return new Promise(function (resolve, reject) {
|
|
1270
|
-
async_store_1
|
|
1274
|
+
async_store_1.AsyncStore.run({ context: {}, breadcrumbs: [] }, function () {
|
|
1271
1275
|
var timeoutHandler = setupTimeoutWarning(hb, context);
|
|
1272
1276
|
try {
|
|
1273
|
-
handler(event, context)
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
+
var result = handler(event, context);
|
|
1278
|
+
// check if handler returns a promise
|
|
1279
|
+
if (result && result.then) {
|
|
1280
|
+
result
|
|
1281
|
+
.then(resolve)
|
|
1282
|
+
.catch(function (err) { return reportToHoneybadger(hb, err, reject); })
|
|
1283
|
+
.finally(function () { return clearTimeout(timeoutHandler); });
|
|
1284
|
+
}
|
|
1285
|
+
else {
|
|
1286
|
+
clearTimeout(timeoutHandler);
|
|
1287
|
+
resolve(result);
|
|
1288
|
+
}
|
|
1277
1289
|
}
|
|
1278
1290
|
catch (err) {
|
|
1279
1291
|
clearTimeout(timeoutHandler);
|
|
@@ -1285,8 +1297,8 @@ function asyncHandler(handler, hb) {
|
|
|
1285
1297
|
}
|
|
1286
1298
|
function syncHandler(handler, hb) {
|
|
1287
1299
|
return function wrappedLambdaHandler(event, context, cb) {
|
|
1288
|
-
hb.__setStore(async_store_1
|
|
1289
|
-
async_store_1
|
|
1300
|
+
hb.__setStore(async_store_1.AsyncStore);
|
|
1301
|
+
async_store_1.AsyncStore.run({ context: {}, breadcrumbs: [] }, function () {
|
|
1290
1302
|
var timeoutHandler = setupTimeoutWarning(hb, context);
|
|
1291
1303
|
try {
|
|
1292
1304
|
handler(event, context, function (error, result) {
|
|
@@ -1345,15 +1357,15 @@ function removeAwsDefaultUncaughtExceptionListener() {
|
|
|
1345
1357
|
aws_lambda.removeAwsDefaultUncaughtExceptionListener = removeAwsDefaultUncaughtExceptionListener;
|
|
1346
1358
|
|
|
1347
1359
|
Object.defineProperty(uncaught_exception, "__esModule", { value: true });
|
|
1348
|
-
var util_1$
|
|
1349
|
-
var aws_lambda_1
|
|
1360
|
+
var util_1$1 = util;
|
|
1361
|
+
var aws_lambda_1 = aws_lambda;
|
|
1350
1362
|
var count = 0;
|
|
1351
1363
|
function removeAwsLambdaListener() {
|
|
1352
1364
|
var isLambda = !!process.env.LAMBDA_TASK_ROOT;
|
|
1353
1365
|
if (!isLambda) {
|
|
1354
1366
|
return;
|
|
1355
1367
|
}
|
|
1356
|
-
(0, aws_lambda_1
|
|
1368
|
+
(0, aws_lambda_1.removeAwsDefaultUncaughtExceptionListener)();
|
|
1357
1369
|
}
|
|
1358
1370
|
function default_1$1() {
|
|
1359
1371
|
return {
|
|
@@ -1365,7 +1377,7 @@ function default_1$1() {
|
|
|
1365
1377
|
process.on('uncaughtException', function honeybadgerUncaughtExceptionListener(uncaughtError) {
|
|
1366
1378
|
// Prevent recursive errors
|
|
1367
1379
|
if (count > 1) {
|
|
1368
|
-
(0, util_1$
|
|
1380
|
+
(0, util_1$1.fatallyLogAndExit)(uncaughtError);
|
|
1369
1381
|
}
|
|
1370
1382
|
if (client.config.enableUncaught) {
|
|
1371
1383
|
client.notify(uncaughtError, {
|
|
@@ -1407,12 +1419,12 @@ unhandled_rejection.default = default_1;
|
|
|
1407
1419
|
|
|
1408
1420
|
var middleware = {};
|
|
1409
1421
|
|
|
1410
|
-
var __importDefault$
|
|
1422
|
+
var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1411
1423
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1412
1424
|
};
|
|
1413
1425
|
Object.defineProperty(middleware, "__esModule", { value: true });
|
|
1414
1426
|
middleware.errorHandler = middleware.requestHandler = void 0;
|
|
1415
|
-
var url_1$1 = __importDefault$
|
|
1427
|
+
var url_1$1 = __importDefault$1(require$$0__default$1["default"]);
|
|
1416
1428
|
function fullUrl(req) {
|
|
1417
1429
|
var connection = req.connection;
|
|
1418
1430
|
var address = connection && connection.address();
|
|
@@ -1450,17 +1462,17 @@ middleware.errorHandler = errorHandler;
|
|
|
1450
1462
|
|
|
1451
1463
|
var transport = {};
|
|
1452
1464
|
|
|
1453
|
-
var __importDefault
|
|
1465
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1454
1466
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1455
1467
|
};
|
|
1456
1468
|
Object.defineProperty(transport, "__esModule", { value: true });
|
|
1457
1469
|
transport.ServerTransport = void 0;
|
|
1458
|
-
var core_1
|
|
1470
|
+
var core_1 = src;
|
|
1459
1471
|
var url_1 = require$$0__default$1["default"];
|
|
1460
|
-
var http_1 = __importDefault
|
|
1461
|
-
var https_1 = __importDefault
|
|
1462
|
-
var util_1
|
|
1463
|
-
var sanitize = core_1
|
|
1472
|
+
var http_1 = __importDefault(require$$2__default$1["default"]);
|
|
1473
|
+
var https_1 = __importDefault(require$$3__default["default"]);
|
|
1474
|
+
var util_1 = util;
|
|
1475
|
+
var sanitize = core_1.Util.sanitize;
|
|
1464
1476
|
var ServerTransport = /** @class */ (function () {
|
|
1465
1477
|
function ServerTransport() {
|
|
1466
1478
|
}
|
|
@@ -1515,7 +1527,7 @@ var ServerTransport = /** @class */ (function () {
|
|
|
1515
1527
|
};
|
|
1516
1528
|
ServerTransport.prototype.appendMetadata = function (payload) {
|
|
1517
1529
|
payload.server.pid = process.pid;
|
|
1518
|
-
return (0, util_1
|
|
1530
|
+
return (0, util_1.getStats)()
|
|
1519
1531
|
.then(function (stats) {
|
|
1520
1532
|
payload.server.stats = stats;
|
|
1521
1533
|
});
|
|
@@ -1524,138 +1536,145 @@ var ServerTransport = /** @class */ (function () {
|
|
|
1524
1536
|
}());
|
|
1525
1537
|
transport.ServerTransport = ServerTransport;
|
|
1526
1538
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
};
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
var
|
|
1560
|
-
var
|
|
1561
|
-
var
|
|
1562
|
-
var
|
|
1563
|
-
var
|
|
1564
|
-
var
|
|
1565
|
-
var
|
|
1566
|
-
var
|
|
1567
|
-
var
|
|
1568
|
-
var
|
|
1569
|
-
var
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1539
|
+
(function (exports) {
|
|
1540
|
+
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
1541
|
+
var extendStatics = function (d, b) {
|
|
1542
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1543
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1544
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1545
|
+
return extendStatics(d, b);
|
|
1546
|
+
};
|
|
1547
|
+
return function (d, b) {
|
|
1548
|
+
if (typeof b !== "function" && b !== null)
|
|
1549
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1550
|
+
extendStatics(d, b);
|
|
1551
|
+
function __() { this.constructor = d; }
|
|
1552
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1553
|
+
};
|
|
1554
|
+
})();
|
|
1555
|
+
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
1556
|
+
__assign = Object.assign || function(t) {
|
|
1557
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1558
|
+
s = arguments[i];
|
|
1559
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1560
|
+
t[p] = s[p];
|
|
1561
|
+
}
|
|
1562
|
+
return t;
|
|
1563
|
+
};
|
|
1564
|
+
return __assign.apply(this, arguments);
|
|
1565
|
+
};
|
|
1566
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1567
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1568
|
+
};
|
|
1569
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1570
|
+
exports.Types = void 0;
|
|
1571
|
+
var os_1 = __importDefault(require$$0__default["default"]);
|
|
1572
|
+
var domain_1 = __importDefault(require$$1__default$1["default"]);
|
|
1573
|
+
var core_1 = src;
|
|
1574
|
+
var util_1 = util;
|
|
1575
|
+
var uncaught_exception_1 = __importDefault(uncaught_exception);
|
|
1576
|
+
var unhandled_rejection_1 = __importDefault(unhandled_rejection);
|
|
1577
|
+
var middleware_1 = middleware;
|
|
1578
|
+
var aws_lambda_1 = aws_lambda;
|
|
1579
|
+
var async_store_1 = async_store;
|
|
1580
|
+
var transport_1 = transport;
|
|
1581
|
+
var endpoint = core_1.Util.endpoint;
|
|
1582
|
+
var kHoneybadgerStore = Symbol.for('kHoneybadgerStore');
|
|
1583
|
+
var Honeybadger = /** @class */ (function (_super) {
|
|
1584
|
+
__extends(Honeybadger, _super);
|
|
1585
|
+
function Honeybadger(opts) {
|
|
1586
|
+
if (opts === void 0) { opts = {}; }
|
|
1587
|
+
var _this = this;
|
|
1588
|
+
var _a;
|
|
1589
|
+
_this = _super.call(this, __assign({ afterUncaught: util_1.fatallyLogAndExit, projectRoot: process.cwd(), hostname: os_1.default.hostname() }, opts), new transport_1.ServerTransport()) || this;
|
|
1590
|
+
/** @internal */
|
|
1591
|
+
_this.__beforeNotifyHandlers = [
|
|
1592
|
+
function (notice) {
|
|
1593
|
+
if (notice && notice.backtrace) {
|
|
1594
|
+
notice.backtrace.forEach(function (line) {
|
|
1595
|
+
if (line.file) {
|
|
1596
|
+
line.file = line.file.replace(/.*\/node_modules\/(.+)/, '[NODE_MODULES]/$1');
|
|
1597
|
+
line.file = line.file.replace(notice.projectRoot, '[PROJECT_ROOT]');
|
|
1598
|
+
}
|
|
1599
|
+
return line;
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
];
|
|
1604
|
+
// serverless defaults
|
|
1605
|
+
var config = _this.config;
|
|
1606
|
+
config.reportTimeoutWarning = (_a = config.reportTimeoutWarning) !== null && _a !== void 0 ? _a : true;
|
|
1607
|
+
config.timeoutWarningThresholdMs = config.timeoutWarningThresholdMs || 50;
|
|
1608
|
+
_this.__getSourceFileHandler = util_1.getSourceFile.bind(_this);
|
|
1609
|
+
_this.errorHandler = middleware_1.errorHandler.bind(_this);
|
|
1610
|
+
_this.requestHandler = middleware_1.requestHandler.bind(_this);
|
|
1611
|
+
_this.lambdaHandler = aws_lambda_1.lambdaHandler.bind(_this);
|
|
1612
|
+
return _this;
|
|
1613
|
+
}
|
|
1614
|
+
Honeybadger.prototype.factory = function (opts) {
|
|
1615
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1616
|
+
return new Honeybadger(opts);
|
|
1617
|
+
};
|
|
1618
|
+
Honeybadger.prototype.configure = function (opts) {
|
|
1619
|
+
if (opts === void 0) { opts = {}; }
|
|
1620
|
+
return _super.prototype.configure.call(this, opts);
|
|
1621
|
+
};
|
|
1622
|
+
Honeybadger.prototype.checkIn = function (id) {
|
|
1623
|
+
var _this = this;
|
|
1624
|
+
return this.__transport
|
|
1625
|
+
.send({
|
|
1626
|
+
method: 'GET',
|
|
1627
|
+
endpoint: endpoint(this.config.endpoint, "v1/check_in/".concat(id)),
|
|
1628
|
+
logger: this.logger,
|
|
1629
|
+
})
|
|
1630
|
+
.then(function () {
|
|
1631
|
+
_this.logger.info('CheckIn sent');
|
|
1632
|
+
return Promise.resolve();
|
|
1633
|
+
})
|
|
1634
|
+
.catch(function (err) {
|
|
1635
|
+
_this.logger.error('CheckIn failed: an unknown error occurred.', "message=".concat(err.message));
|
|
1636
|
+
});
|
|
1637
|
+
};
|
|
1638
|
+
// This method is intended for web frameworks.
|
|
1639
|
+
// It allows us to track context for individual requests without leaking to other requests
|
|
1640
|
+
// by doing two things:
|
|
1641
|
+
// 1. Using AsyncLocalStorage so the context is tracked across async operations.
|
|
1642
|
+
// 2. Attaching the store contents to the request object,
|
|
1643
|
+
// so, even if the store is destroyed, we can still recover the context for a given request
|
|
1644
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1645
|
+
Honeybadger.prototype.withRequest = function (request, handler, onError) {
|
|
1646
|
+
var _this = this;
|
|
1647
|
+
var storeObject = (request[kHoneybadgerStore] || this.__getStoreContentsOrDefault());
|
|
1648
|
+
this.__setStore(async_store_1.AsyncStore);
|
|
1649
|
+
if (!request[kHoneybadgerStore]) {
|
|
1650
|
+
request[kHoneybadgerStore] = storeObject;
|
|
1651
|
+
}
|
|
1652
|
+
if (onError) {
|
|
1653
|
+
// ALS is fine for context-tracking, but `domain` allows us to catch errors
|
|
1654
|
+
// thrown asynchronously (timers, event emitters)
|
|
1655
|
+
// We can't use unhandledRejection/uncaughtException listeners; they're global and shared across all requests
|
|
1656
|
+
// But the `onError` handler might be request-specific.
|
|
1657
|
+
// Note that this doesn't still handle all cases. `domain` has its own problems:
|
|
1658
|
+
// See https://github.com/honeybadger-io/honeybadger-js/pull/711
|
|
1659
|
+
var dom = domain_1.default.create();
|
|
1660
|
+
var onErrorWithContext = function (err) { return _this.__store.run(storeObject, function () { return onError(err); }); };
|
|
1661
|
+
dom.on('error', onErrorWithContext);
|
|
1662
|
+
handler = dom.bind(handler);
|
|
1663
|
+
}
|
|
1664
|
+
return this.__store.run(storeObject, handler);
|
|
1665
|
+
};
|
|
1666
|
+
return Honeybadger;
|
|
1667
|
+
}(core_1.Client));
|
|
1668
|
+
var core_2 = src;
|
|
1669
|
+
Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return core_2.Types; } });
|
|
1670
|
+
exports.default = new Honeybadger({
|
|
1671
|
+
__plugins: [
|
|
1672
|
+
(0, uncaught_exception_1.default)(),
|
|
1673
|
+
(0, unhandled_rejection_1.default)()
|
|
1674
|
+
],
|
|
1675
|
+
});
|
|
1676
|
+
} (server$1));
|
|
1677
|
+
|
|
1678
|
+
var server = /*@__PURE__*/getDefaultExportFromCjs(server$1);
|
|
1660
1679
|
|
|
1661
|
-
module.exports =
|
|
1680
|
+
module.exports = server;
|