@honeybadger-io/js 4.0.5 → 4.1.2
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/README.md +13 -64
- package/dist/browser/honeybadger.d.ts +6 -6
- package/dist/browser/honeybadger.js +1791 -1694
- 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 +3 -0
- package/dist/browser/integrations/event_listeners.d.ts +3 -0
- package/dist/browser/integrations/onerror.d.ts +4 -0
- package/dist/browser/integrations/onunhandledrejection.d.ts +3 -0
- package/dist/browser/integrations/timers.d.ts +3 -0
- package/dist/browser/transport.d.ts +8 -0
- package/dist/browser/{types/browser/util.d.ts → util.d.ts} +1 -0
- package/dist/server/async_store.d.ts +6 -0
- package/dist/server/{types/server/aws_lambda.d.ts → aws_lambda.d.ts} +1 -1
- package/dist/server/honeybadger.d.ts +8 -8
- package/dist/server/honeybadger.js +632 -501
- package/dist/server/integrations/uncaught_exception.d.ts +3 -0
- package/dist/server/integrations/unhandled_rejection.d.ts +3 -0
- package/dist/server/middleware.d.ts +5 -0
- package/dist/server/transport.d.ts +10 -0
- package/dist/server/{types/server/util.d.ts → util.d.ts} +3 -2
- package/honeybadger.d.ts +2 -2
- package/package.json +27 -39
- package/dist/browser/types/browser/integrations/breadcrumbs.d.ts +0 -2
- package/dist/browser/types/browser/integrations/event_listeners.d.ts +0 -2
- package/dist/browser/types/browser/integrations/onerror.d.ts +0 -3
- package/dist/browser/types/browser/integrations/onunhandledrejection.d.ts +0 -2
- package/dist/browser/types/browser/integrations/timers.d.ts +0 -2
- package/dist/browser/types/browser/transport.d.ts +0 -7
- package/dist/browser/types/browser.d.ts +0 -12
- package/dist/browser/types/core/client.d.ts +0 -37
- package/dist/browser/types/core/store.d.ts +0 -7
- package/dist/browser/types/core/types.d.ts +0 -160
- package/dist/browser/types/core/util.d.ts +0 -32
- package/dist/browser/types/server/async_store.d.ts +0 -5
- package/dist/browser/types/server/aws_lambda.d.ts +0 -10
- package/dist/browser/types/server/integrations/uncaught_exception.d.ts +0 -2
- package/dist/browser/types/server/integrations/unhandled_rejection.d.ts +0 -2
- package/dist/browser/types/server/middleware.d.ts +0 -4
- package/dist/browser/types/server/transport.d.ts +0 -9
- package/dist/browser/types/server/util.d.ts +0 -9
- package/dist/browser/types/server.d.ts +0 -17
- package/dist/server/types/browser/integrations/breadcrumbs.d.ts +0 -2
- package/dist/server/types/browser/integrations/event_listeners.d.ts +0 -2
- package/dist/server/types/browser/integrations/onerror.d.ts +0 -3
- package/dist/server/types/browser/integrations/onunhandledrejection.d.ts +0 -2
- package/dist/server/types/browser/integrations/timers.d.ts +0 -2
- package/dist/server/types/browser/transport.d.ts +0 -7
- package/dist/server/types/browser/util.d.ts +0 -18
- package/dist/server/types/browser.d.ts +0 -12
- package/dist/server/types/core/client.d.ts +0 -37
- package/dist/server/types/core/store.d.ts +0 -7
- package/dist/server/types/core/types.d.ts +0 -160
- package/dist/server/types/core/util.d.ts +0 -32
- package/dist/server/types/server/async_store.d.ts +0 -5
- package/dist/server/types/server/integrations/uncaught_exception.d.ts +0 -2
- package/dist/server/types/server/integrations/unhandled_rejection.d.ts +0 -2
- package/dist/server/types/server/middleware.d.ts +0 -4
- package/dist/server/types/server/transport.d.ts +0 -9
- package/dist/server/types/server.d.ts +0 -17
|
@@ -1,102 +1,54 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
3
|
+
var require$$0$1 = require('os');
|
|
4
|
+
var require$$1$1 = require('domain');
|
|
5
|
+
var require$$1 = require('fs');
|
|
6
|
+
var require$$2 = require('util');
|
|
7
|
+
var require$$0$2 = require('url');
|
|
8
|
+
var require$$2$1 = require('http');
|
|
9
|
+
var require$$3 = require('https');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function __extends(d, b) {
|
|
44
|
-
if (typeof b !== "function" && b !== null)
|
|
45
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
46
|
-
extendStatics(d, b);
|
|
47
|
-
function __() { this.constructor = d; }
|
|
48
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var __assign = function() {
|
|
52
|
-
__assign = Object.assign || function __assign(t) {
|
|
53
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
54
|
-
s = arguments[i];
|
|
55
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
|
-
return __assign.apply(this, arguments);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
63
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
64
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
65
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
66
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
67
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
68
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function __generator(thisArg, body) {
|
|
73
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
74
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
75
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
76
|
-
function step(op) {
|
|
77
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
78
|
-
while (_) try {
|
|
79
|
-
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;
|
|
80
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
81
|
-
switch (op[0]) {
|
|
82
|
-
case 0: case 1: t = op; break;
|
|
83
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
84
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
85
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
86
|
-
default:
|
|
87
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
88
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
89
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
90
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
91
|
-
if (t[2]) _.ops.pop();
|
|
92
|
-
_.trys.pop(); continue;
|
|
93
|
-
}
|
|
94
|
-
op = body.call(thisArg, _);
|
|
95
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
96
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
97
|
-
}
|
|
13
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
14
|
+
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
15
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
16
|
+
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
17
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
18
|
+
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
|
19
|
+
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
20
|
+
|
|
21
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
22
|
+
|
|
23
|
+
function getAugmentedNamespace(n) {
|
|
24
|
+
var f = n.default;
|
|
25
|
+
if (typeof f == "function") {
|
|
26
|
+
var a = function () {
|
|
27
|
+
return f.apply(this, arguments);
|
|
28
|
+
};
|
|
29
|
+
a.prototype = f.prototype;
|
|
30
|
+
} else a = {};
|
|
31
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
32
|
+
Object.keys(n).forEach(function (k) {
|
|
33
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
34
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return n[k];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
return a;
|
|
98
42
|
}
|
|
99
43
|
|
|
44
|
+
var server = {};
|
|
45
|
+
|
|
46
|
+
var src = {};
|
|
47
|
+
|
|
48
|
+
var client = {};
|
|
49
|
+
|
|
50
|
+
var util$1 = {};
|
|
51
|
+
|
|
100
52
|
var UNKNOWN_FUNCTION = '<unknown>';
|
|
101
53
|
/**
|
|
102
54
|
* This parses the different stack traces and puts them into one format
|
|
@@ -232,36 +184,88 @@ function parseNode(line) {
|
|
|
232
184
|
};
|
|
233
185
|
}
|
|
234
186
|
|
|
235
|
-
|
|
187
|
+
var stackTraceParser_esm = /*#__PURE__*/Object.freeze({
|
|
188
|
+
__proto__: null,
|
|
189
|
+
parse: parse
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
193
|
+
|
|
194
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
195
|
+
if (k2 === undefined) k2 = k;
|
|
196
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
197
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
198
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
199
|
+
}
|
|
200
|
+
Object.defineProperty(o, k2, desc);
|
|
201
|
+
}) : (function(o, m, k, k2) {
|
|
202
|
+
if (k2 === undefined) k2 = k;
|
|
203
|
+
o[k2] = m[k];
|
|
204
|
+
}));
|
|
205
|
+
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
206
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
207
|
+
}) : function(o, v) {
|
|
208
|
+
o["default"] = v;
|
|
209
|
+
});
|
|
210
|
+
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
211
|
+
if (mod && mod.__esModule) return mod;
|
|
236
212
|
var result = {};
|
|
237
|
-
for (var k in
|
|
213
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
214
|
+
__setModuleDefault(result, mod);
|
|
215
|
+
return result;
|
|
216
|
+
};
|
|
217
|
+
var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
218
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
219
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
220
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
221
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
222
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
223
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
Object.defineProperty(util$1, "__esModule", { value: true });
|
|
227
|
+
util$1.isBrowserConfig = util$1.clone = util$1.formatCGIData = util$1.filterUrl = util$1.filter = util$1.generateStackTrace = util$1.endpoint = util$1.instrument = util$1.isErrorObject = util$1.makeNotice = util$1.logger = util$1.sanitize = util$1.shallowClone = util$1.runAfterNotifyHandlers = util$1.runBeforeNotifyHandlers = util$1.getSourceForBacktrace = util$1.getCauses = util$1.makeBacktrace = util$1.objectIsExtensible = util$1.objectIsEmpty = util$1.mergeNotice = util$1.merge = void 0;
|
|
228
|
+
const stackTraceParser = __importStar(require$$0);
|
|
229
|
+
function merge(obj1, obj2) {
|
|
230
|
+
const result = {};
|
|
231
|
+
for (const k in obj1) {
|
|
238
232
|
result[k] = obj1[k];
|
|
239
233
|
}
|
|
240
|
-
for (
|
|
234
|
+
for (const k in obj2) {
|
|
241
235
|
result[k] = obj2[k];
|
|
242
236
|
}
|
|
243
237
|
return result;
|
|
244
238
|
}
|
|
239
|
+
util$1.merge = merge;
|
|
245
240
|
function mergeNotice(notice1, notice2) {
|
|
246
|
-
|
|
241
|
+
const result = merge(notice1, notice2);
|
|
247
242
|
if (notice1.context && notice2.context) {
|
|
248
243
|
result.context = merge(notice1.context, notice2.context);
|
|
249
244
|
}
|
|
250
245
|
return result;
|
|
251
246
|
}
|
|
247
|
+
util$1.mergeNotice = mergeNotice;
|
|
252
248
|
function objectIsEmpty(obj) {
|
|
253
|
-
for (
|
|
249
|
+
for (const k in obj) {
|
|
254
250
|
if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
|
255
251
|
return false;
|
|
256
252
|
}
|
|
257
253
|
}
|
|
258
254
|
return true;
|
|
259
255
|
}
|
|
260
|
-
|
|
261
|
-
|
|
256
|
+
util$1.objectIsEmpty = objectIsEmpty;
|
|
257
|
+
function objectIsExtensible(obj) {
|
|
258
|
+
if (typeof Object.isExtensible !== 'function') {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
return Object.isExtensible(obj);
|
|
262
|
+
}
|
|
263
|
+
util$1.objectIsExtensible = objectIsExtensible;
|
|
264
|
+
function makeBacktrace(stack, shift = 0) {
|
|
262
265
|
try {
|
|
263
|
-
|
|
264
|
-
.
|
|
266
|
+
const backtrace = stackTraceParser
|
|
267
|
+
.parse(stack)
|
|
268
|
+
.map(line => {
|
|
265
269
|
return {
|
|
266
270
|
file: line.file,
|
|
267
271
|
method: line.methodName,
|
|
@@ -277,71 +281,81 @@ function makeBacktrace(stack, shift) {
|
|
|
277
281
|
return [];
|
|
278
282
|
}
|
|
279
283
|
}
|
|
284
|
+
util$1.makeBacktrace = makeBacktrace;
|
|
285
|
+
function getCauses(notice) {
|
|
286
|
+
if (notice.cause) {
|
|
287
|
+
const causes = [];
|
|
288
|
+
let cause = notice;
|
|
289
|
+
while (causes.length < 3 && (cause = cause.cause)) {
|
|
290
|
+
causes.push({
|
|
291
|
+
class: cause.name,
|
|
292
|
+
message: cause.message,
|
|
293
|
+
backtrace: typeof cause.stack == 'string' ? makeBacktrace(cause.stack) : null
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
return causes;
|
|
297
|
+
}
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
util$1.getCauses = getCauses;
|
|
280
301
|
function getSourceForBacktrace(backtrace, getSourceFileHandler) {
|
|
281
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
trace = backtrace.splice(0)[index];
|
|
295
|
-
return [4 /*yield*/, getSourceFileHandler(trace.file)];
|
|
296
|
-
case 2:
|
|
297
|
-
fileContent = _a.sent();
|
|
298
|
-
result[index] = getSourceCodeSnippet(fileContent, trace.number);
|
|
299
|
-
index++;
|
|
300
|
-
return [3 /*break*/, 1];
|
|
301
|
-
case 3: return [2 /*return*/, result];
|
|
302
|
-
}
|
|
303
|
-
});
|
|
302
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
303
|
+
const result = [];
|
|
304
|
+
if (!getSourceFileHandler || !backtrace || !backtrace.length) {
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
let index = 0;
|
|
308
|
+
while (backtrace.length) {
|
|
309
|
+
const trace = backtrace.splice(0)[index];
|
|
310
|
+
const fileContent = yield getSourceFileHandler(trace.file);
|
|
311
|
+
result[index] = getSourceCodeSnippet(fileContent, trace.number);
|
|
312
|
+
index++;
|
|
313
|
+
}
|
|
314
|
+
return result;
|
|
304
315
|
});
|
|
305
316
|
}
|
|
317
|
+
util$1.getSourceForBacktrace = getSourceForBacktrace;
|
|
306
318
|
function runBeforeNotifyHandlers(notice, handlers) {
|
|
307
|
-
|
|
308
|
-
for (
|
|
309
|
-
|
|
319
|
+
let result = true;
|
|
320
|
+
for (let i = 0, len = handlers.length; i < len; i++) {
|
|
321
|
+
const handler = handlers[i];
|
|
310
322
|
if (handler(notice) === false) {
|
|
311
323
|
result = false;
|
|
312
324
|
}
|
|
313
325
|
}
|
|
314
326
|
return result;
|
|
315
327
|
}
|
|
328
|
+
util$1.runBeforeNotifyHandlers = runBeforeNotifyHandlers;
|
|
316
329
|
function runAfterNotifyHandlers(notice, handlers, error) {
|
|
317
330
|
if (notice && notice.afterNotify) {
|
|
318
331
|
notice.afterNotify(error, notice);
|
|
319
332
|
}
|
|
320
|
-
for (
|
|
333
|
+
for (let i = 0, len = handlers.length; i < len; i++) {
|
|
321
334
|
handlers[i](error, notice);
|
|
322
335
|
}
|
|
323
336
|
return true;
|
|
324
337
|
}
|
|
338
|
+
util$1.runAfterNotifyHandlers = runAfterNotifyHandlers;
|
|
325
339
|
// Returns a new object with properties from other object.
|
|
326
340
|
function shallowClone(obj) {
|
|
327
341
|
if (typeof (obj) !== 'object' || obj === null) {
|
|
328
342
|
return {};
|
|
329
343
|
}
|
|
330
|
-
|
|
331
|
-
for (
|
|
344
|
+
const result = {};
|
|
345
|
+
for (const k in obj) {
|
|
332
346
|
result[k] = obj[k];
|
|
333
347
|
}
|
|
334
348
|
return result;
|
|
335
349
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
350
|
+
util$1.shallowClone = shallowClone;
|
|
351
|
+
function sanitize$1(obj, maxDepth = 8) {
|
|
352
|
+
const seenObjects = [];
|
|
339
353
|
function seen(obj) {
|
|
340
354
|
if (!obj || typeof (obj) !== 'object') {
|
|
341
355
|
return false;
|
|
342
356
|
}
|
|
343
|
-
for (
|
|
344
|
-
|
|
357
|
+
for (let i = 0; i < seenObjects.length; i++) {
|
|
358
|
+
const value = seenObjects[i];
|
|
345
359
|
if (value === obj) {
|
|
346
360
|
return true;
|
|
347
361
|
}
|
|
@@ -350,7 +364,7 @@ function sanitize(obj, maxDepth) {
|
|
|
350
364
|
return false;
|
|
351
365
|
}
|
|
352
366
|
function canSerialize(obj) {
|
|
353
|
-
|
|
367
|
+
const typeOfObj = typeof obj;
|
|
354
368
|
// Functions are TMI
|
|
355
369
|
if (/function/.test(typeOfObj)) {
|
|
356
370
|
// Let special toJSON method pass as it's used by JSON.stringify (#722)
|
|
@@ -369,8 +383,7 @@ function sanitize(obj, maxDepth) {
|
|
|
369
383
|
}
|
|
370
384
|
return true;
|
|
371
385
|
}
|
|
372
|
-
function serialize(obj, depth) {
|
|
373
|
-
if (depth === void 0) { depth = 0; }
|
|
386
|
+
function serialize(obj, depth = 0) {
|
|
374
387
|
if (depth >= maxDepth) {
|
|
375
388
|
return '[DEPTH]';
|
|
376
389
|
}
|
|
@@ -384,13 +397,13 @@ function sanitize(obj, maxDepth) {
|
|
|
384
397
|
}
|
|
385
398
|
// Serialize inside arrays
|
|
386
399
|
if (Array.isArray(obj)) {
|
|
387
|
-
return obj.map(
|
|
400
|
+
return obj.map(o => safeSerialize(o, depth + 1));
|
|
388
401
|
}
|
|
389
402
|
// Serialize inside objects
|
|
390
403
|
if (typeof (obj) === 'object') {
|
|
391
|
-
|
|
392
|
-
for (
|
|
393
|
-
|
|
404
|
+
const ret = {};
|
|
405
|
+
for (const k in obj) {
|
|
406
|
+
const v = obj[k];
|
|
394
407
|
if (Object.prototype.hasOwnProperty.call(obj, k) && (k != null) && (v != null)) {
|
|
395
408
|
ret[k] = safeSerialize(v, depth + 1);
|
|
396
409
|
}
|
|
@@ -400,25 +413,20 @@ function sanitize(obj, maxDepth) {
|
|
|
400
413
|
// Return everything else untouched
|
|
401
414
|
return obj;
|
|
402
415
|
}
|
|
403
|
-
function safeSerialize(obj, depth) {
|
|
404
|
-
if (depth === void 0) { depth = 0; }
|
|
416
|
+
function safeSerialize(obj, depth = 0) {
|
|
405
417
|
try {
|
|
406
418
|
return serialize(obj, depth);
|
|
407
419
|
}
|
|
408
420
|
catch (e) {
|
|
409
|
-
return
|
|
421
|
+
return `[ERROR] ${e}`;
|
|
410
422
|
}
|
|
411
423
|
}
|
|
412
424
|
return safeSerialize(obj);
|
|
413
425
|
}
|
|
426
|
+
util$1.sanitize = sanitize$1;
|
|
414
427
|
function logger(client) {
|
|
415
|
-
|
|
416
|
-
return function () {
|
|
417
|
-
var _a;
|
|
418
|
-
var args = [];
|
|
419
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
420
|
-
args[_i] = arguments[_i];
|
|
421
|
-
}
|
|
428
|
+
const log = (method) => {
|
|
429
|
+
return function (...args) {
|
|
422
430
|
if (method === 'debug') {
|
|
423
431
|
if (!client.config.debug) {
|
|
424
432
|
return;
|
|
@@ -428,7 +436,7 @@ function logger(client) {
|
|
|
428
436
|
method = 'log';
|
|
429
437
|
}
|
|
430
438
|
args.unshift('[Honeybadger]');
|
|
431
|
-
|
|
439
|
+
client.config.logger[method](...args);
|
|
432
440
|
};
|
|
433
441
|
};
|
|
434
442
|
return {
|
|
@@ -439,33 +447,67 @@ function logger(client) {
|
|
|
439
447
|
error: log('error')
|
|
440
448
|
};
|
|
441
449
|
}
|
|
450
|
+
util$1.logger = logger;
|
|
442
451
|
/**
|
|
443
452
|
* Converts any object into a notice object (which at minimum has the same
|
|
444
453
|
* properties as Error, but supports additional Honeybadger properties.)
|
|
445
454
|
*/
|
|
446
455
|
function makeNotice(thing) {
|
|
447
|
-
|
|
456
|
+
let notice;
|
|
448
457
|
if (!thing) {
|
|
449
458
|
notice = {};
|
|
450
459
|
}
|
|
451
|
-
else if (
|
|
452
|
-
|
|
453
|
-
notice = merge(thing, { name: e.name, message: e.message, stack: e.stack });
|
|
460
|
+
else if (isErrorObject(thing)) {
|
|
461
|
+
const e = thing;
|
|
462
|
+
notice = merge(thing, { name: e.name, message: e.message, stack: e.stack, cause: e.cause });
|
|
454
463
|
}
|
|
455
464
|
else if (typeof thing === 'object') {
|
|
456
465
|
notice = shallowClone(thing);
|
|
457
466
|
}
|
|
458
467
|
else {
|
|
459
|
-
|
|
468
|
+
const m = String(thing);
|
|
460
469
|
notice = { message: m };
|
|
461
470
|
}
|
|
462
471
|
return notice;
|
|
463
472
|
}
|
|
464
|
-
|
|
465
|
-
|
|
473
|
+
util$1.makeNotice = makeNotice;
|
|
474
|
+
function isErrorObject(thing) {
|
|
475
|
+
return thing instanceof Error
|
|
476
|
+
|| Object.prototype.toString.call(thing) === '[object Error]'; // Important for cross-realm objects
|
|
477
|
+
}
|
|
478
|
+
util$1.isErrorObject = isErrorObject;
|
|
479
|
+
/**
|
|
480
|
+
* Instrument an existing function inside an object (usually global).
|
|
481
|
+
* @param {!Object} object
|
|
482
|
+
* @param {!String} name
|
|
483
|
+
* @param {!Function} replacement
|
|
484
|
+
*/
|
|
485
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
486
|
+
function instrument(object, name, replacement) {
|
|
487
|
+
if (!object || !name || !replacement || !(name in object)) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
let original = object[name];
|
|
491
|
+
while (original && original.__hb_original) {
|
|
492
|
+
original = original.__hb_original;
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
object[name] = replacement(original);
|
|
496
|
+
object[name].__hb_original = original;
|
|
497
|
+
}
|
|
498
|
+
catch (_e) {
|
|
499
|
+
// Ignores errors like this one:
|
|
500
|
+
// Error: TypeError: Cannot set property onunhandledrejection of [object Object] which has only a getter
|
|
501
|
+
// 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
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
util$1.instrument = instrument;
|
|
505
|
+
function endpoint$1(base, path) {
|
|
506
|
+
const endpoint = base.trim().replace(/\/$/, '');
|
|
466
507
|
path = path.trim().replace(/(^\/|\/$)/g, '');
|
|
467
|
-
return
|
|
508
|
+
return `${endpoint}/${path}`;
|
|
468
509
|
}
|
|
510
|
+
util$1.endpoint = endpoint$1;
|
|
469
511
|
function generateStackTrace() {
|
|
470
512
|
try {
|
|
471
513
|
throw new Error('');
|
|
@@ -475,9 +517,9 @@ function generateStackTrace() {
|
|
|
475
517
|
return e.stack;
|
|
476
518
|
}
|
|
477
519
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
520
|
+
const maxStackSize = 10;
|
|
521
|
+
const stack = [];
|
|
522
|
+
let curr = arguments.callee;
|
|
481
523
|
while (curr && stack.length < maxStackSize) {
|
|
482
524
|
if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
|
|
483
525
|
stack.push(RegExp.$1 || '<anonymous>');
|
|
@@ -494,6 +536,7 @@ function generateStackTrace() {
|
|
|
494
536
|
}
|
|
495
537
|
return stack.join('\n');
|
|
496
538
|
}
|
|
539
|
+
util$1.generateStackTrace = generateStackTrace;
|
|
497
540
|
function filter(obj, filters) {
|
|
498
541
|
if (!is('Object', obj)) {
|
|
499
542
|
return;
|
|
@@ -501,9 +544,9 @@ function filter(obj, filters) {
|
|
|
501
544
|
if (!is('Array', filters)) {
|
|
502
545
|
filters = [];
|
|
503
546
|
}
|
|
504
|
-
|
|
547
|
+
const seen = [];
|
|
505
548
|
function filter(obj) {
|
|
506
|
-
|
|
549
|
+
let k, newObj;
|
|
507
550
|
if (is('Object', obj) || is('Array', obj)) {
|
|
508
551
|
if (seen.indexOf(obj) !== -1) {
|
|
509
552
|
return '[CIRCULAR DATA STRUCTURE]';
|
|
@@ -534,8 +577,9 @@ function filter(obj, filters) {
|
|
|
534
577
|
}
|
|
535
578
|
return filter(obj);
|
|
536
579
|
}
|
|
580
|
+
util$1.filter = filter;
|
|
537
581
|
function filterMatch(key, filters) {
|
|
538
|
-
for (
|
|
582
|
+
for (let i = 0; i < filters.length; i++) {
|
|
539
583
|
if (key.toLowerCase().indexOf(filters[i].toLowerCase()) !== -1) {
|
|
540
584
|
return true;
|
|
541
585
|
}
|
|
@@ -543,7 +587,7 @@ function filterMatch(key, filters) {
|
|
|
543
587
|
return false;
|
|
544
588
|
}
|
|
545
589
|
function is(type, obj) {
|
|
546
|
-
|
|
590
|
+
const klass = Object.prototype.toString.call(obj).slice(8, -1);
|
|
547
591
|
return obj !== undefined && obj !== null && klass === type;
|
|
548
592
|
}
|
|
549
593
|
function filterUrl(url, filters) {
|
|
@@ -553,41 +597,45 @@ function filterUrl(url, filters) {
|
|
|
553
597
|
if (typeof url !== 'string') {
|
|
554
598
|
return url;
|
|
555
599
|
}
|
|
556
|
-
|
|
600
|
+
const query = url.split(/\?/, 2)[1];
|
|
557
601
|
if (!query) {
|
|
558
602
|
return url;
|
|
559
603
|
}
|
|
560
|
-
|
|
561
|
-
query.split(/[&]\s?/).forEach(
|
|
562
|
-
|
|
604
|
+
let result = url;
|
|
605
|
+
query.split(/[&]\s?/).forEach((pair) => {
|
|
606
|
+
const [key, value] = pair.split('=', 2);
|
|
563
607
|
if (filterMatch(key, filters)) {
|
|
564
|
-
result = result.replace(
|
|
608
|
+
result = result.replace(`${key}=${value}`, `${key}=[FILTERED]`);
|
|
565
609
|
}
|
|
566
610
|
});
|
|
567
611
|
return result;
|
|
568
612
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
613
|
+
util$1.filterUrl = filterUrl;
|
|
614
|
+
function formatCGIData(vars, prefix = '') {
|
|
615
|
+
const formattedVars = {};
|
|
572
616
|
Object.keys(vars).forEach(function (key) {
|
|
573
|
-
|
|
617
|
+
const formattedKey = prefix + key.replace(/\W/g, '_').toUpperCase();
|
|
574
618
|
formattedVars[formattedKey] = vars[key];
|
|
575
619
|
});
|
|
576
620
|
return formattedVars;
|
|
577
621
|
}
|
|
578
|
-
|
|
579
|
-
|
|
622
|
+
util$1.formatCGIData = formatCGIData;
|
|
623
|
+
function clone(obj) {
|
|
624
|
+
return JSON.parse(JSON.stringify(obj));
|
|
625
|
+
}
|
|
626
|
+
util$1.clone = clone;
|
|
627
|
+
function getSourceCodeSnippet(fileData, lineNumber, sourceRadius = 2) {
|
|
580
628
|
if (!fileData) {
|
|
581
629
|
return null;
|
|
582
630
|
}
|
|
583
|
-
|
|
631
|
+
const lines = fileData.split('\n');
|
|
584
632
|
// add one empty line because array index starts from 0, but error line number is counted from 1
|
|
585
633
|
lines.unshift('');
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
for (
|
|
590
|
-
|
|
634
|
+
const start = lineNumber - sourceRadius;
|
|
635
|
+
const end = lineNumber + sourceRadius;
|
|
636
|
+
const result = {};
|
|
637
|
+
for (let i = start; i <= end; i++) {
|
|
638
|
+
const line = lines[i];
|
|
591
639
|
if (typeof line === 'string') {
|
|
592
640
|
result[i] = line;
|
|
593
641
|
}
|
|
@@ -597,85 +645,86 @@ function getSourceCodeSnippet(fileData, lineNumber, sourceRadius) {
|
|
|
597
645
|
function isBrowserConfig(config) {
|
|
598
646
|
return config.async !== undefined;
|
|
599
647
|
}
|
|
648
|
+
util$1.isBrowserConfig = isBrowserConfig;
|
|
649
|
+
|
|
650
|
+
var store = {};
|
|
600
651
|
|
|
601
|
-
|
|
602
|
-
|
|
652
|
+
Object.defineProperty(store, "__esModule", { value: true });
|
|
653
|
+
store.GlobalStore = void 0;
|
|
654
|
+
class GlobalStore {
|
|
655
|
+
constructor(store) {
|
|
603
656
|
this.store = store;
|
|
604
657
|
}
|
|
605
|
-
|
|
658
|
+
getStore() {
|
|
606
659
|
return this.store;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
var args = [];
|
|
610
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
611
|
-
args[_i - 2] = arguments[_i];
|
|
612
|
-
}
|
|
660
|
+
}
|
|
661
|
+
run(store, callback, ...args) {
|
|
613
662
|
this.store = store;
|
|
614
|
-
return callback
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
|
|
663
|
+
return callback(...args);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
store.GlobalStore = GlobalStore;
|
|
618
667
|
|
|
619
|
-
|
|
668
|
+
Object.defineProperty(client, "__esModule", { value: true });
|
|
669
|
+
client.Client = void 0;
|
|
670
|
+
const util_1$4 = util$1;
|
|
671
|
+
const store_1 = store;
|
|
672
|
+
const notifier = {
|
|
620
673
|
name: 'honeybadger-js',
|
|
621
674
|
url: 'https://github.com/honeybadger-io/honeybadger-js',
|
|
622
|
-
version: '4.
|
|
675
|
+
version: '4.1.2'
|
|
623
676
|
};
|
|
624
677
|
// Split at commas and spaces
|
|
625
|
-
|
|
678
|
+
const TAG_SEPARATOR = /,|\s+/;
|
|
626
679
|
// Checks for non-blank characters
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
if (opts === void 0) { opts = {}; }
|
|
680
|
+
const NOT_BLANK = /\S/;
|
|
681
|
+
class Client {
|
|
682
|
+
constructor(opts = {}, transport) {
|
|
631
683
|
this.__pluginsExecuted = false;
|
|
632
684
|
this.__store = null;
|
|
633
685
|
this.__beforeNotifyHandlers = [];
|
|
634
686
|
this.__afterNotifyHandlers = [];
|
|
635
|
-
this.config =
|
|
687
|
+
this.config = Object.assign({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: () => true, filters: ['creditcard', 'password'], __plugins: [] }, opts);
|
|
636
688
|
// First, we go with the global (shared) store.
|
|
637
689
|
// Webserver middleware can then switch to the AsyncStore for async context tracking.
|
|
638
|
-
this.__store = new GlobalStore({ context: {}, breadcrumbs: [] });
|
|
690
|
+
this.__store = new store_1.GlobalStore({ context: {}, breadcrumbs: [] });
|
|
639
691
|
this.__transport = transport;
|
|
640
|
-
this.logger = logger(this);
|
|
692
|
+
this.logger = (0, util_1$4.logger)(this);
|
|
641
693
|
}
|
|
642
|
-
|
|
694
|
+
getVersion() {
|
|
643
695
|
return notifier.version;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
if (opts === void 0) { opts = {}; }
|
|
648
|
-
for (var k in opts) {
|
|
696
|
+
}
|
|
697
|
+
configure(opts = {}) {
|
|
698
|
+
for (const k in opts) {
|
|
649
699
|
this.config[k] = opts[k];
|
|
650
700
|
}
|
|
651
701
|
if (!this.__pluginsExecuted) {
|
|
652
702
|
this.__pluginsExecuted = true;
|
|
653
|
-
this.config.__plugins.forEach(
|
|
703
|
+
this.config.__plugins.forEach((plugin) => plugin.load(this));
|
|
654
704
|
}
|
|
655
705
|
return this;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
Client.prototype.__setStore = function (store) {
|
|
706
|
+
}
|
|
707
|
+
__setStore(store) {
|
|
659
708
|
this.__store = store;
|
|
660
|
-
}
|
|
661
|
-
|
|
709
|
+
}
|
|
710
|
+
beforeNotify(handler) {
|
|
662
711
|
this.__beforeNotifyHandlers.push(handler);
|
|
663
712
|
return this;
|
|
664
|
-
}
|
|
665
|
-
|
|
713
|
+
}
|
|
714
|
+
afterNotify(handler) {
|
|
666
715
|
this.__afterNotifyHandlers.push(handler);
|
|
667
716
|
return this;
|
|
668
|
-
}
|
|
669
|
-
|
|
717
|
+
}
|
|
718
|
+
setContext(context) {
|
|
670
719
|
if (typeof context === 'object') {
|
|
671
|
-
|
|
672
|
-
store.context = merge(store.context, context);
|
|
720
|
+
const store = this.__store.getStore();
|
|
721
|
+
store.context = (0, util_1$4.merge)(store.context, context);
|
|
673
722
|
}
|
|
674
723
|
return this;
|
|
675
|
-
}
|
|
676
|
-
|
|
724
|
+
}
|
|
725
|
+
resetContext(context) {
|
|
677
726
|
this.logger.warn('Deprecation warning: `Honeybadger.resetContext()` has been deprecated; please use `Honeybadger.clear()` instead.');
|
|
678
|
-
|
|
727
|
+
const store = this.__store.getStore();
|
|
679
728
|
if (typeof context === 'object' && context !== null) {
|
|
680
729
|
store.context = context;
|
|
681
730
|
}
|
|
@@ -683,19 +732,16 @@ var Client = /** @class */ (function () {
|
|
|
683
732
|
store.context = {};
|
|
684
733
|
}
|
|
685
734
|
return this;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
|
|
735
|
+
}
|
|
736
|
+
clear() {
|
|
737
|
+
const store = this.__store.getStore();
|
|
689
738
|
store.context = {};
|
|
690
739
|
store.breadcrumbs = [];
|
|
691
740
|
return this;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
if (extra === void 0) { extra = undefined; }
|
|
697
|
-
var preConditionError = null;
|
|
698
|
-
var notice = this.makeNotice(noticeable, name, extra);
|
|
741
|
+
}
|
|
742
|
+
notify(noticeable, name = undefined, extra = undefined) {
|
|
743
|
+
let preConditionError = null;
|
|
744
|
+
const notice = this.makeNotice(noticeable, name, extra);
|
|
699
745
|
if (!notice) {
|
|
700
746
|
this.logger.debug('failed to build error report');
|
|
701
747
|
preConditionError = new Error('failed to build error report');
|
|
@@ -714,14 +760,14 @@ var Client = /** @class */ (function () {
|
|
|
714
760
|
}
|
|
715
761
|
// we need to have the source file data before the beforeNotifyHandlers,
|
|
716
762
|
// in case they modify them
|
|
717
|
-
|
|
718
|
-
|
|
763
|
+
const sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(trace => (0, util_1$4.shallowClone)(trace)) : null;
|
|
764
|
+
const beforeNotifyResult = (0, util_1$4.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
|
|
719
765
|
if (!preConditionError && !beforeNotifyResult) {
|
|
720
766
|
this.logger.debug('skipping error report: beforeNotify handlers returned false', notice);
|
|
721
767
|
preConditionError = new Error('beforeNotify handlers returned false');
|
|
722
768
|
}
|
|
723
769
|
if (preConditionError) {
|
|
724
|
-
runAfterNotifyHandlers(notice, this.__afterNotifyHandlers, preConditionError);
|
|
770
|
+
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionError);
|
|
725
771
|
return false;
|
|
726
772
|
}
|
|
727
773
|
this.addBreadcrumb('Honeybadger Notice', {
|
|
@@ -732,61 +778,58 @@ var Client = /** @class */ (function () {
|
|
|
732
778
|
stack: notice.stack
|
|
733
779
|
}
|
|
734
780
|
});
|
|
735
|
-
|
|
781
|
+
const breadcrumbs = this.__getStoreContentsOrDefault().breadcrumbs;
|
|
736
782
|
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs.slice() : [];
|
|
737
|
-
getSourceForBacktrace(sourceCodeData, this.__getSourceFileHandler)
|
|
738
|
-
.then(
|
|
739
|
-
sourcePerTrace.forEach(
|
|
783
|
+
(0, util_1$4.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
|
|
784
|
+
.then(sourcePerTrace => {
|
|
785
|
+
sourcePerTrace.forEach((source, index) => {
|
|
740
786
|
notice.backtrace[index].source = source;
|
|
741
787
|
});
|
|
742
|
-
|
|
743
|
-
|
|
788
|
+
const payload = this.__buildPayload(notice);
|
|
789
|
+
this.__transport
|
|
744
790
|
.send({
|
|
745
791
|
headers: {
|
|
746
|
-
'X-API-Key':
|
|
792
|
+
'X-API-Key': this.config.apiKey,
|
|
747
793
|
'Content-Type': 'application/json',
|
|
748
794
|
'Accept': 'text/json, application/json'
|
|
749
795
|
},
|
|
750
796
|
method: 'POST',
|
|
751
|
-
endpoint: endpoint(
|
|
752
|
-
maxObjectDepth:
|
|
753
|
-
logger:
|
|
754
|
-
async: isBrowserConfig(
|
|
797
|
+
endpoint: (0, util_1$4.endpoint)(this.config.endpoint, '/v1/notices/js'),
|
|
798
|
+
maxObjectDepth: this.config.maxObjectDepth,
|
|
799
|
+
logger: this.logger,
|
|
800
|
+
async: (0, util_1$4.isBrowserConfig)(this.config) ? this.config.async : undefined,
|
|
755
801
|
}, payload)
|
|
756
|
-
.then(
|
|
802
|
+
.then(res => {
|
|
757
803
|
if (res.statusCode !== 201) {
|
|
758
|
-
runAfterNotifyHandlers(notice,
|
|
759
|
-
|
|
804
|
+
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, new Error(`Bad HTTP response: ${res.statusCode}`));
|
|
805
|
+
this.logger.warn(`Error report failed: unknown response from server. code=${res.statusCode}`);
|
|
760
806
|
return;
|
|
761
807
|
}
|
|
762
|
-
|
|
763
|
-
runAfterNotifyHandlers(merge(notice, {
|
|
808
|
+
const uuid = JSON.parse(res.body).id;
|
|
809
|
+
(0, util_1$4.runAfterNotifyHandlers)((0, util_1$4.merge)(notice, {
|
|
764
810
|
id: uuid
|
|
765
|
-
}),
|
|
766
|
-
|
|
811
|
+
}), this.__afterNotifyHandlers);
|
|
812
|
+
this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${uuid}`);
|
|
767
813
|
})
|
|
768
|
-
.catch(
|
|
769
|
-
|
|
770
|
-
runAfterNotifyHandlers(notice,
|
|
814
|
+
.catch(err => {
|
|
815
|
+
this.logger.error('Error report failed: an unknown error occurred.', `message=${err.message}`);
|
|
816
|
+
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, err);
|
|
771
817
|
});
|
|
772
818
|
});
|
|
773
819
|
return true;
|
|
774
|
-
}
|
|
820
|
+
}
|
|
775
821
|
/**
|
|
776
822
|
* An async version of {@link notify} that resolves only after the notice has been reported to Honeybadger.
|
|
777
823
|
* Implemented using the {@link afterNotify} hook.
|
|
778
824
|
* Rejects if for any reason the report failed to be reported.
|
|
779
825
|
* Useful in serverless environments (AWS Lambda).
|
|
780
826
|
*/
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
var originalAfterNotify = partialNotice.afterNotify;
|
|
788
|
-
partialNotice.afterNotify = function (err) {
|
|
789
|
-
originalAfterNotify === null || originalAfterNotify === void 0 ? void 0 : originalAfterNotify.call(_this, err);
|
|
827
|
+
notifyAsync(noticeable, name = undefined, extra = undefined) {
|
|
828
|
+
return new Promise((resolve, reject) => {
|
|
829
|
+
const applyAfterNotify = (partialNotice) => {
|
|
830
|
+
const originalAfterNotify = partialNotice.afterNotify;
|
|
831
|
+
partialNotice.afterNotify = (err) => {
|
|
832
|
+
originalAfterNotify === null || originalAfterNotify === void 0 ? void 0 : originalAfterNotify.call(this, err);
|
|
790
833
|
if (err) {
|
|
791
834
|
return reject(err);
|
|
792
835
|
}
|
|
@@ -794,7 +837,7 @@ var Client = /** @class */ (function () {
|
|
|
794
837
|
};
|
|
795
838
|
};
|
|
796
839
|
// We have to respect any afterNotify hooks that come from the arguments
|
|
797
|
-
|
|
840
|
+
let objectToOverride;
|
|
798
841
|
if (noticeable.afterNotify) {
|
|
799
842
|
objectToOverride = noticeable;
|
|
800
843
|
}
|
|
@@ -814,83 +857,81 @@ var Client = /** @class */ (function () {
|
|
|
814
857
|
objectToOverride = name = {};
|
|
815
858
|
}
|
|
816
859
|
applyAfterNotify(objectToOverride);
|
|
817
|
-
|
|
860
|
+
this.notify(noticeable, name, extra);
|
|
818
861
|
});
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (extra === void 0) { extra = undefined; }
|
|
823
|
-
var notice = makeNotice(noticeable);
|
|
862
|
+
}
|
|
863
|
+
makeNotice(noticeable, name = undefined, extra = undefined) {
|
|
864
|
+
let notice = (0, util_1$4.makeNotice)(noticeable);
|
|
824
865
|
if (name && !(typeof name === 'object')) {
|
|
825
|
-
|
|
866
|
+
const n = String(name);
|
|
826
867
|
name = { name: n };
|
|
827
868
|
}
|
|
828
869
|
if (name) {
|
|
829
|
-
notice = mergeNotice(notice, name);
|
|
870
|
+
notice = (0, util_1$4.mergeNotice)(notice, name);
|
|
830
871
|
}
|
|
831
872
|
if (typeof extra === 'object' && extra !== null) {
|
|
832
|
-
notice = mergeNotice(notice, extra);
|
|
873
|
+
notice = (0, util_1$4.mergeNotice)(notice, extra);
|
|
833
874
|
}
|
|
834
|
-
if (objectIsEmpty(notice)) {
|
|
875
|
+
if ((0, util_1$4.objectIsEmpty)(notice)) {
|
|
835
876
|
return null;
|
|
836
877
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
878
|
+
const context = this.__getStoreContentsOrDefault().context;
|
|
879
|
+
const noticeTags = this.__constructTags(notice.tags);
|
|
880
|
+
const contextTags = this.__constructTags(context['tags']);
|
|
881
|
+
const configTags = this.__constructTags(this.config.tags);
|
|
841
882
|
// Turning into a Set will remove duplicates
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
notice = merge(notice, {
|
|
883
|
+
const tags = noticeTags.concat(contextTags).concat(configTags);
|
|
884
|
+
const uniqueTags = tags.filter((item, index) => tags.indexOf(item) === index);
|
|
885
|
+
notice = (0, util_1$4.merge)(notice, {
|
|
845
886
|
name: notice.name || 'Error',
|
|
846
|
-
context: merge(context, notice.context),
|
|
887
|
+
context: (0, util_1$4.merge)(context, notice.context),
|
|
847
888
|
projectRoot: notice.projectRoot || this.config.projectRoot,
|
|
848
889
|
environment: notice.environment || this.config.environment,
|
|
849
890
|
component: notice.component || this.config.component,
|
|
850
891
|
action: notice.action || this.config.action,
|
|
851
892
|
revision: notice.revision || this.config.revision,
|
|
852
|
-
tags: uniqueTags
|
|
893
|
+
tags: uniqueTags,
|
|
853
894
|
});
|
|
854
|
-
|
|
895
|
+
let backtraceShift = 0;
|
|
855
896
|
if (typeof notice.stack !== 'string' || !notice.stack.trim()) {
|
|
856
|
-
notice.stack = generateStackTrace();
|
|
897
|
+
notice.stack = (0, util_1$4.generateStackTrace)();
|
|
857
898
|
backtraceShift = 2;
|
|
858
899
|
}
|
|
859
|
-
notice.backtrace = makeBacktrace(notice.stack, backtraceShift);
|
|
900
|
+
notice.backtrace = (0, util_1$4.makeBacktrace)(notice.stack, backtraceShift);
|
|
860
901
|
return notice;
|
|
861
|
-
}
|
|
862
|
-
|
|
902
|
+
}
|
|
903
|
+
addBreadcrumb(message, opts) {
|
|
863
904
|
if (!this.config.breadcrumbsEnabled) {
|
|
864
905
|
return;
|
|
865
906
|
}
|
|
866
907
|
opts = opts || {};
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
908
|
+
const metadata = (0, util_1$4.shallowClone)(opts.metadata);
|
|
909
|
+
const category = opts.category || 'custom';
|
|
910
|
+
const timestamp = new Date().toISOString();
|
|
911
|
+
const store = this.__store.getStore();
|
|
912
|
+
let breadcrumbs = store.breadcrumbs;
|
|
872
913
|
breadcrumbs.push({
|
|
873
914
|
category: category,
|
|
874
915
|
message: message,
|
|
875
916
|
metadata: metadata,
|
|
876
917
|
timestamp: timestamp
|
|
877
918
|
});
|
|
878
|
-
|
|
919
|
+
const limit = this.config.maxBreadcrumbs;
|
|
879
920
|
if (breadcrumbs.length > limit) {
|
|
880
921
|
breadcrumbs = breadcrumbs.slice(breadcrumbs.length - limit);
|
|
881
922
|
}
|
|
882
923
|
store.breadcrumbs = breadcrumbs;
|
|
883
924
|
return this;
|
|
884
|
-
}
|
|
885
|
-
|
|
925
|
+
}
|
|
926
|
+
__developmentMode() {
|
|
886
927
|
if (this.config.reportData === true) {
|
|
887
928
|
return false;
|
|
888
929
|
}
|
|
889
930
|
return (this.config.environment && this.config.developmentEnvironments.includes(this.config.environment));
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
931
|
+
}
|
|
932
|
+
__buildPayload(notice) {
|
|
933
|
+
const headers = (0, util_1$4.filter)(notice.headers, this.config.filters) || {};
|
|
934
|
+
const cgiData = (0, util_1$4.filter)(Object.assign(Object.assign({}, notice.cgiData), (0, util_1$4.formatCGIData)(headers, 'HTTP_')), this.config.filters);
|
|
894
935
|
return {
|
|
895
936
|
notifier: notifier,
|
|
896
937
|
breadcrumbs: {
|
|
@@ -902,16 +943,17 @@ var Client = /** @class */ (function () {
|
|
|
902
943
|
message: notice.message,
|
|
903
944
|
backtrace: notice.backtrace,
|
|
904
945
|
fingerprint: notice.fingerprint,
|
|
905
|
-
tags: notice.tags
|
|
946
|
+
tags: notice.tags,
|
|
947
|
+
causes: (0, util_1$4.getCauses)(notice),
|
|
906
948
|
},
|
|
907
949
|
request: {
|
|
908
|
-
url: filterUrl(notice.url, this.config.filters),
|
|
950
|
+
url: (0, util_1$4.filterUrl)(notice.url, this.config.filters),
|
|
909
951
|
component: notice.component,
|
|
910
952
|
action: notice.action,
|
|
911
953
|
context: notice.context,
|
|
912
954
|
cgi_data: cgiData,
|
|
913
|
-
params: filter(notice.params, this.config.filters) || {},
|
|
914
|
-
session: filter(notice.session, this.config.filters) || {}
|
|
955
|
+
params: (0, util_1$4.filter)(notice.params, this.config.filters) || {},
|
|
956
|
+
session: (0, util_1$4.filter)(notice.session, this.config.filters) || {}
|
|
915
957
|
},
|
|
916
958
|
server: {
|
|
917
959
|
project_root: notice.projectRoot,
|
|
@@ -922,121 +964,173 @@ var Client = /** @class */ (function () {
|
|
|
922
964
|
},
|
|
923
965
|
details: notice.details || {}
|
|
924
966
|
};
|
|
925
|
-
}
|
|
926
|
-
|
|
967
|
+
}
|
|
968
|
+
__constructTags(tags) {
|
|
927
969
|
if (!tags) {
|
|
928
970
|
return [];
|
|
929
971
|
}
|
|
930
|
-
return tags.toString().split(TAG_SEPARATOR).filter(
|
|
931
|
-
}
|
|
972
|
+
return tags.toString().split(TAG_SEPARATOR).filter((tag) => NOT_BLANK.test(tag));
|
|
973
|
+
}
|
|
932
974
|
/**
|
|
933
975
|
* For ALS, the store may be uninitialized (if .run()` has not been called).
|
|
934
976
|
* This provides an easy way to read the existing store object or fall back to a default.
|
|
935
|
-
* Returns *a copy* of the
|
|
936
|
-
* @internal
|
|
977
|
+
* Returns *a copy* of the s tore contents.
|
|
937
978
|
*/
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
return
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
979
|
+
__getStoreContentsOrDefault() {
|
|
980
|
+
const existingStoreContents = this.__store.getStore();
|
|
981
|
+
const storeContents = existingStoreContents || {};
|
|
982
|
+
return Object.assign({ context: {}, breadcrumbs: [] }, storeContents);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
client.Client = Client;
|
|
986
|
+
|
|
987
|
+
var types = {};
|
|
988
|
+
|
|
989
|
+
Object.defineProperty(types, "__esModule", { value: true });
|
|
990
|
+
|
|
991
|
+
(function (exports) {
|
|
992
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
993
|
+
if (k2 === undefined) k2 = k;
|
|
994
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
995
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
996
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
997
|
+
}
|
|
998
|
+
Object.defineProperty(o, k2, desc);
|
|
999
|
+
}) : (function(o, m, k, k2) {
|
|
1000
|
+
if (k2 === undefined) k2 = k;
|
|
1001
|
+
o[k2] = m[k];
|
|
1002
|
+
}));
|
|
1003
|
+
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1004
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1005
|
+
}) : function(o, v) {
|
|
1006
|
+
o["default"] = v;
|
|
1007
|
+
});
|
|
1008
|
+
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
1009
|
+
if (mod && mod.__esModule) return mod;
|
|
1010
|
+
var result = {};
|
|
1011
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1012
|
+
__setModuleDefault(result, mod);
|
|
1013
|
+
return result;
|
|
1014
|
+
};
|
|
1015
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1016
|
+
exports.Util = exports.Types = exports.Store = exports.Client = void 0;
|
|
1017
|
+
var client_1 = client;
|
|
1018
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
1019
|
+
exports.Store = __importStar(store);
|
|
1020
|
+
exports.Types = __importStar(types);
|
|
1021
|
+
exports.Util = __importStar(util$1);
|
|
1022
|
+
} (src));
|
|
945
1023
|
|
|
946
|
-
var
|
|
1024
|
+
var util = {};
|
|
1025
|
+
|
|
1026
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1027
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1028
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1029
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1030
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1031
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1032
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1033
|
+
});
|
|
1034
|
+
};
|
|
1035
|
+
var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1036
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1037
|
+
};
|
|
1038
|
+
Object.defineProperty(util, "__esModule", { value: true });
|
|
1039
|
+
util.getSourceFile = util.getStats = util.fatallyLogAndExit = void 0;
|
|
1040
|
+
const os_1$1 = __importDefault$3(require$$0__default["default"]);
|
|
1041
|
+
const fs_1 = __importDefault$3(require$$1__default["default"]);
|
|
1042
|
+
const util_1$3 = require$$2__default["default"];
|
|
1043
|
+
const readFile = (0, util_1$3.promisify)(fs_1.default.readFile);
|
|
947
1044
|
function fatallyLogAndExit(err) {
|
|
948
1045
|
console.error('[Honeybadger] Exiting process due to uncaught exception');
|
|
949
1046
|
console.error(err.stack || err);
|
|
950
1047
|
process.exit(1);
|
|
951
1048
|
}
|
|
1049
|
+
util.fatallyLogAndExit = fatallyLogAndExit;
|
|
952
1050
|
function getStats() {
|
|
953
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
buffers: results[2],
|
|
994
|
-
cached: results[3],
|
|
995
|
-
free_total: results[1] + results[2] + results[3]
|
|
996
|
-
};
|
|
997
|
-
return [3 /*break*/, 4];
|
|
998
|
-
case 3:
|
|
999
|
-
_a.sent();
|
|
1000
|
-
fallback();
|
|
1001
|
-
return [3 /*break*/, 4];
|
|
1002
|
-
case 4: return [2 /*return*/, stats];
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1051
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1052
|
+
const load = os_1$1.default.loadavg();
|
|
1053
|
+
const stats = {
|
|
1054
|
+
load: {
|
|
1055
|
+
one: load[0],
|
|
1056
|
+
five: load[1],
|
|
1057
|
+
fifteen: load[2]
|
|
1058
|
+
},
|
|
1059
|
+
mem: {}
|
|
1060
|
+
};
|
|
1061
|
+
const fallback = () => {
|
|
1062
|
+
stats.mem = {
|
|
1063
|
+
free: os_1$1.default.freemem(),
|
|
1064
|
+
total: os_1$1.default.totalmem()
|
|
1065
|
+
};
|
|
1066
|
+
};
|
|
1067
|
+
if (!fs_1.default.existsSync('/proc/meminfo')) {
|
|
1068
|
+
fallback();
|
|
1069
|
+
return stats;
|
|
1070
|
+
}
|
|
1071
|
+
try {
|
|
1072
|
+
const memData = yield readFile('/proc/meminfo', 'utf8');
|
|
1073
|
+
// The first four lines, in order, are Total, Free, Buffers, Cached.
|
|
1074
|
+
// @TODO: Figure out if there's a way to only read these lines
|
|
1075
|
+
const data = memData.split('\n').slice(0, 4);
|
|
1076
|
+
const results = data.map(function (i) {
|
|
1077
|
+
return parseInt(/\s+(\d+)\skB/i.exec(i)[1], 10) / 1024.0;
|
|
1078
|
+
});
|
|
1079
|
+
stats.mem = {
|
|
1080
|
+
total: results[0],
|
|
1081
|
+
free: results[1],
|
|
1082
|
+
buffers: results[2],
|
|
1083
|
+
cached: results[3],
|
|
1084
|
+
free_total: results[1] + results[2] + results[3]
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
catch (error) {
|
|
1088
|
+
fallback();
|
|
1089
|
+
}
|
|
1090
|
+
return stats;
|
|
1005
1091
|
});
|
|
1006
1092
|
}
|
|
1093
|
+
util.getStats = getStats;
|
|
1007
1094
|
/**
|
|
1008
1095
|
* Get source file if possible, used to build `notice.backtrace.source`
|
|
1009
1096
|
*
|
|
1010
1097
|
* @param path to source code
|
|
1011
1098
|
*/
|
|
1012
1099
|
function getSourceFile(path) {
|
|
1013
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
case 2:
|
|
1021
|
-
_a.sent();
|
|
1022
|
-
return [2 /*return*/, null];
|
|
1023
|
-
case 3: return [2 /*return*/];
|
|
1024
|
-
}
|
|
1025
|
-
});
|
|
1100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1101
|
+
try {
|
|
1102
|
+
return yield readFile(path, 'utf-8');
|
|
1103
|
+
}
|
|
1104
|
+
catch (_e) {
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1026
1107
|
});
|
|
1027
1108
|
}
|
|
1109
|
+
util.getSourceFile = getSourceFile;
|
|
1110
|
+
|
|
1111
|
+
var uncaught_exception = {};
|
|
1112
|
+
|
|
1113
|
+
var aws_lambda = {};
|
|
1028
1114
|
|
|
1029
|
-
var
|
|
1115
|
+
var async_store = {};
|
|
1116
|
+
|
|
1117
|
+
Object.defineProperty(async_store, "__esModule", { value: true });
|
|
1118
|
+
async_store.AsyncStore = void 0;
|
|
1119
|
+
const core_1$2 = src;
|
|
1120
|
+
let Store;
|
|
1030
1121
|
try {
|
|
1031
1122
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1032
|
-
|
|
1123
|
+
const { AsyncLocalStorage } = require('async_hooks');
|
|
1033
1124
|
Store = new AsyncLocalStorage();
|
|
1034
1125
|
}
|
|
1035
1126
|
catch (e) {
|
|
1036
|
-
Store = new GlobalStore({ context: {}, breadcrumbs: [] });
|
|
1127
|
+
Store = new core_1$2.Store.GlobalStore({ context: {}, breadcrumbs: [] });
|
|
1037
1128
|
}
|
|
1038
|
-
|
|
1129
|
+
async_store.AsyncStore = Store;
|
|
1039
1130
|
|
|
1131
|
+
Object.defineProperty(aws_lambda, "__esModule", { value: true });
|
|
1132
|
+
aws_lambda.removeAwsDefaultUncaughtExceptionListener = aws_lambda.lambdaHandler = void 0;
|
|
1133
|
+
const async_store_1$1 = async_store;
|
|
1040
1134
|
function isHandlerSync(handler) {
|
|
1041
1135
|
return handler.length > 2;
|
|
1042
1136
|
}
|
|
@@ -1050,15 +1144,15 @@ function reportToHoneybadger(hb, err, callback) {
|
|
|
1050
1144
|
}
|
|
1051
1145
|
function asyncHandler(handler, hb) {
|
|
1052
1146
|
return function wrappedLambdaHandler(event, context) {
|
|
1053
|
-
hb.__setStore(AsyncStore);
|
|
1054
|
-
return new Promise(
|
|
1055
|
-
AsyncStore.run({ context: {}, breadcrumbs: [] },
|
|
1056
|
-
|
|
1147
|
+
hb.__setStore(async_store_1$1.AsyncStore);
|
|
1148
|
+
return new Promise((resolve, reject) => {
|
|
1149
|
+
async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, () => {
|
|
1150
|
+
const timeoutHandler = setupTimeoutWarning(hb, context);
|
|
1057
1151
|
try {
|
|
1058
1152
|
handler(event, context)
|
|
1059
1153
|
.then(resolve)
|
|
1060
|
-
.catch(
|
|
1061
|
-
.finally(
|
|
1154
|
+
.catch(err => reportToHoneybadger(hb, err, reject))
|
|
1155
|
+
.finally(() => clearTimeout(timeoutHandler));
|
|
1062
1156
|
}
|
|
1063
1157
|
catch (err) {
|
|
1064
1158
|
clearTimeout(timeoutHandler);
|
|
@@ -1070,11 +1164,11 @@ function asyncHandler(handler, hb) {
|
|
|
1070
1164
|
}
|
|
1071
1165
|
function syncHandler(handler, hb) {
|
|
1072
1166
|
return function wrappedLambdaHandler(event, context, cb) {
|
|
1073
|
-
hb.__setStore(AsyncStore);
|
|
1074
|
-
AsyncStore.run({ context: {}, breadcrumbs: [] },
|
|
1075
|
-
|
|
1167
|
+
hb.__setStore(async_store_1$1.AsyncStore);
|
|
1168
|
+
async_store_1$1.AsyncStore.run({ context: {}, breadcrumbs: [] }, () => {
|
|
1169
|
+
const timeoutHandler = setupTimeoutWarning(hb, context);
|
|
1076
1170
|
try {
|
|
1077
|
-
handler(event, context,
|
|
1171
|
+
handler(event, context, (error, result) => {
|
|
1078
1172
|
clearTimeout(timeoutHandler);
|
|
1079
1173
|
if (error) {
|
|
1080
1174
|
return reportToHoneybadger(hb, error, cb);
|
|
@@ -1096,20 +1190,21 @@ function setupTimeoutWarning(hb, context) {
|
|
|
1096
1190
|
if (!shouldReportTimeoutWarning(hb, context)) {
|
|
1097
1191
|
return;
|
|
1098
1192
|
}
|
|
1099
|
-
|
|
1100
|
-
return setTimeout(
|
|
1101
|
-
hb.notify(
|
|
1193
|
+
const delay = context.getRemainingTimeInMillis() - (hb.config.timeoutWarningThresholdMs);
|
|
1194
|
+
return setTimeout(() => {
|
|
1195
|
+
hb.notify(`${context.functionName}[${context.functionVersion}] may have timed out`);
|
|
1102
1196
|
}, delay > 0 ? delay : 0);
|
|
1103
1197
|
}
|
|
1104
1198
|
function lambdaHandler(handler) {
|
|
1105
1199
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1106
|
-
|
|
1200
|
+
const hb = this;
|
|
1107
1201
|
if (isHandlerSync(handler)) {
|
|
1108
1202
|
return syncHandler(handler, hb);
|
|
1109
1203
|
}
|
|
1110
1204
|
return asyncHandler(handler, hb);
|
|
1111
1205
|
}
|
|
1112
|
-
|
|
1206
|
+
aws_lambda.lambdaHandler = lambdaHandler;
|
|
1207
|
+
let listenerRemoved = false;
|
|
1113
1208
|
/**
|
|
1114
1209
|
* Removes AWS Lambda default listener that
|
|
1115
1210
|
* exits the process before letting us report to honeybadger.
|
|
@@ -1119,25 +1214,29 @@ function removeAwsDefaultUncaughtExceptionListener() {
|
|
|
1119
1214
|
return;
|
|
1120
1215
|
}
|
|
1121
1216
|
listenerRemoved = true;
|
|
1122
|
-
|
|
1217
|
+
const listeners = process.listeners('uncaughtException');
|
|
1123
1218
|
if (listeners.length === 0) {
|
|
1124
1219
|
return;
|
|
1125
1220
|
}
|
|
1126
1221
|
// We assume it's the first listener
|
|
1127
1222
|
process.removeListener('uncaughtException', listeners[0]);
|
|
1128
1223
|
}
|
|
1224
|
+
aws_lambda.removeAwsDefaultUncaughtExceptionListener = removeAwsDefaultUncaughtExceptionListener;
|
|
1129
1225
|
|
|
1130
|
-
|
|
1226
|
+
Object.defineProperty(uncaught_exception, "__esModule", { value: true });
|
|
1227
|
+
const util_1$2 = util;
|
|
1228
|
+
const aws_lambda_1$1 = aws_lambda;
|
|
1229
|
+
let count = 0;
|
|
1131
1230
|
function removeAwsLambdaListener() {
|
|
1132
|
-
|
|
1231
|
+
const isLambda = !!process.env.LAMBDA_TASK_ROOT;
|
|
1133
1232
|
if (!isLambda) {
|
|
1134
1233
|
return;
|
|
1135
1234
|
}
|
|
1136
|
-
removeAwsDefaultUncaughtExceptionListener();
|
|
1235
|
+
(0, aws_lambda_1$1.removeAwsDefaultUncaughtExceptionListener)();
|
|
1137
1236
|
}
|
|
1138
|
-
function
|
|
1237
|
+
function default_1$1() {
|
|
1139
1238
|
return {
|
|
1140
|
-
load:
|
|
1239
|
+
load: (client) => {
|
|
1141
1240
|
if (!client.config.enableUncaught) {
|
|
1142
1241
|
return;
|
|
1143
1242
|
}
|
|
@@ -1145,11 +1244,11 @@ function uncaughtException () {
|
|
|
1145
1244
|
process.on('uncaughtException', function honeybadgerUncaughtExceptionListener(uncaughtError) {
|
|
1146
1245
|
// Prevent recursive errors
|
|
1147
1246
|
if (count > 1) {
|
|
1148
|
-
fatallyLogAndExit(uncaughtError);
|
|
1247
|
+
(0, util_1$2.fatallyLogAndExit)(uncaughtError);
|
|
1149
1248
|
}
|
|
1150
1249
|
if (client.config.enableUncaught) {
|
|
1151
1250
|
client.notify(uncaughtError, {
|
|
1152
|
-
afterNotify:
|
|
1251
|
+
afterNotify: (_err, _notice) => {
|
|
1153
1252
|
count += 1;
|
|
1154
1253
|
client.config.afterUncaught(uncaughtError);
|
|
1155
1254
|
}
|
|
@@ -1163,10 +1262,14 @@ function uncaughtException () {
|
|
|
1163
1262
|
}
|
|
1164
1263
|
};
|
|
1165
1264
|
}
|
|
1265
|
+
uncaught_exception.default = default_1$1;
|
|
1266
|
+
|
|
1267
|
+
var unhandled_rejection = {};
|
|
1166
1268
|
|
|
1167
|
-
|
|
1269
|
+
Object.defineProperty(unhandled_rejection, "__esModule", { value: true });
|
|
1270
|
+
function default_1() {
|
|
1168
1271
|
return {
|
|
1169
|
-
load:
|
|
1272
|
+
load: (client) => {
|
|
1170
1273
|
if (!client.config.enableUnhandledRejection) {
|
|
1171
1274
|
return;
|
|
1172
1275
|
}
|
|
@@ -1179,14 +1282,23 @@ function unhandledRejection () {
|
|
|
1179
1282
|
}
|
|
1180
1283
|
};
|
|
1181
1284
|
}
|
|
1285
|
+
unhandled_rejection.default = default_1;
|
|
1182
1286
|
|
|
1287
|
+
var middleware = {};
|
|
1288
|
+
|
|
1289
|
+
var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1290
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1291
|
+
};
|
|
1292
|
+
Object.defineProperty(middleware, "__esModule", { value: true });
|
|
1293
|
+
middleware.errorHandler = middleware.requestHandler = void 0;
|
|
1294
|
+
const url_1$1 = __importDefault$2(require$$0__default$1["default"]);
|
|
1183
1295
|
function fullUrl(req) {
|
|
1184
|
-
|
|
1185
|
-
|
|
1296
|
+
const connection = req.connection;
|
|
1297
|
+
const address = connection && connection.address();
|
|
1186
1298
|
// @ts-ignore The old @types/node incorrectly defines `address` as string|Address
|
|
1187
|
-
|
|
1299
|
+
const port = address ? address.port : undefined;
|
|
1188
1300
|
// @ts-ignore
|
|
1189
|
-
return
|
|
1301
|
+
return url_1$1.default.format({
|
|
1190
1302
|
protocol: req.protocol,
|
|
1191
1303
|
hostname: req.hostname,
|
|
1192
1304
|
port: port,
|
|
@@ -1197,6 +1309,7 @@ function fullUrl(req) {
|
|
|
1197
1309
|
function requestHandler(req, res, next) {
|
|
1198
1310
|
this.withRequest(req, next, next);
|
|
1199
1311
|
}
|
|
1312
|
+
middleware.requestHandler = requestHandler;
|
|
1200
1313
|
function errorHandler(err, req, _res, next) {
|
|
1201
1314
|
this.notify(err, {
|
|
1202
1315
|
url: fullUrl(req),
|
|
@@ -1212,82 +1325,105 @@ function errorHandler(err, req, _res, next) {
|
|
|
1212
1325
|
return next(err);
|
|
1213
1326
|
}
|
|
1214
1327
|
}
|
|
1328
|
+
middleware.errorHandler = errorHandler;
|
|
1215
1329
|
|
|
1216
|
-
var
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1330
|
+
var transport = {};
|
|
1331
|
+
|
|
1332
|
+
var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1333
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1334
|
+
};
|
|
1335
|
+
Object.defineProperty(transport, "__esModule", { value: true });
|
|
1336
|
+
transport.ServerTransport = void 0;
|
|
1337
|
+
const core_1$1 = src;
|
|
1338
|
+
const url_1 = require$$0__default$1["default"];
|
|
1339
|
+
const http_1 = __importDefault$1(require$$2__default$1["default"]);
|
|
1340
|
+
const https_1 = __importDefault$1(require$$3__default["default"]);
|
|
1341
|
+
const util_1$1 = util;
|
|
1342
|
+
const { sanitize } = core_1$1.Util;
|
|
1343
|
+
class ServerTransport {
|
|
1344
|
+
send(options, payload) {
|
|
1345
|
+
const { protocol, hostname, pathname } = new url_1.URL(options.endpoint);
|
|
1346
|
+
const transport = (protocol === 'http:' ? http_1.default : https_1.default);
|
|
1347
|
+
return new Promise((resolve, reject) => {
|
|
1348
|
+
let promise;
|
|
1225
1349
|
// this should not be here. it should be done before reaching the transport layer
|
|
1226
1350
|
// it could be inside a beforeNotifyHandler, but is not possible at the moment because those handlers are synchronous
|
|
1227
|
-
if (
|
|
1228
|
-
promise =
|
|
1351
|
+
if (this.isNoticePayload(payload)) {
|
|
1352
|
+
promise = this.appendMetadata(payload);
|
|
1229
1353
|
}
|
|
1230
1354
|
else {
|
|
1231
1355
|
promise = Promise.resolve();
|
|
1232
1356
|
}
|
|
1233
|
-
promise.then(
|
|
1357
|
+
promise.then(() => {
|
|
1234
1358
|
//
|
|
1235
1359
|
// We use a httpOptions object to limit issues with libraries that may patch Node.js
|
|
1236
1360
|
// See https://github.com/honeybadger-io/honeybadger-js/issues/825#issuecomment-1193113433
|
|
1237
|
-
|
|
1361
|
+
const httpOptions = {
|
|
1238
1362
|
method: options.method,
|
|
1239
1363
|
headers: options.headers,
|
|
1240
1364
|
path: pathname,
|
|
1241
|
-
protocol
|
|
1242
|
-
hostname
|
|
1365
|
+
protocol,
|
|
1366
|
+
hostname,
|
|
1243
1367
|
};
|
|
1244
|
-
|
|
1368
|
+
let data = undefined;
|
|
1245
1369
|
if (payload) {
|
|
1246
1370
|
data = Buffer.from(JSON.stringify(sanitize(payload, options.maxObjectDepth)), 'utf8');
|
|
1247
1371
|
httpOptions.headers['Content-Length'] = data.length;
|
|
1248
1372
|
}
|
|
1249
|
-
|
|
1250
|
-
options.logger.debug(
|
|
1251
|
-
|
|
1252
|
-
res.on('data',
|
|
1373
|
+
const req = transport.request(httpOptions, (res) => {
|
|
1374
|
+
options.logger.debug(`statusCode: ${res.statusCode}`);
|
|
1375
|
+
let body = '';
|
|
1376
|
+
res.on('data', (chunk) => {
|
|
1253
1377
|
body += chunk;
|
|
1254
1378
|
});
|
|
1255
|
-
res.on('end',
|
|
1379
|
+
res.on('end', () => resolve({ statusCode: res.statusCode, body }));
|
|
1256
1380
|
});
|
|
1257
|
-
req.on('error',
|
|
1381
|
+
req.on('error', (err) => reject(err));
|
|
1258
1382
|
if (data) {
|
|
1259
1383
|
req.write(data);
|
|
1260
1384
|
}
|
|
1261
1385
|
req.end();
|
|
1262
1386
|
});
|
|
1263
1387
|
});
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1388
|
+
}
|
|
1389
|
+
isNoticePayload(payload) {
|
|
1266
1390
|
return payload && payload.error !== undefined;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1391
|
+
}
|
|
1392
|
+
appendMetadata(payload) {
|
|
1269
1393
|
payload.server.pid = process.pid;
|
|
1270
|
-
return getStats()
|
|
1271
|
-
.then(
|
|
1394
|
+
return (0, util_1$1.getStats)()
|
|
1395
|
+
.then(stats => {
|
|
1272
1396
|
payload.server.stats = stats;
|
|
1273
1397
|
});
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
var
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
transport.ServerTransport = ServerTransport;
|
|
1401
|
+
|
|
1402
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1403
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1404
|
+
};
|
|
1405
|
+
Object.defineProperty(server, "__esModule", { value: true });
|
|
1406
|
+
const os_1 = __importDefault(require$$0__default["default"]);
|
|
1407
|
+
const domain_1 = __importDefault(require$$1__default$1["default"]);
|
|
1408
|
+
const core_1 = src;
|
|
1409
|
+
const util_1 = util;
|
|
1410
|
+
const uncaught_exception_1 = __importDefault(uncaught_exception);
|
|
1411
|
+
const unhandled_rejection_1 = __importDefault(unhandled_rejection);
|
|
1412
|
+
const middleware_1 = middleware;
|
|
1413
|
+
const aws_lambda_1 = aws_lambda;
|
|
1414
|
+
const async_store_1 = async_store;
|
|
1415
|
+
const transport_1 = transport;
|
|
1416
|
+
const { endpoint } = core_1.Util;
|
|
1417
|
+
const kHoneybadgerStore = Symbol.for('kHoneybadgerStore');
|
|
1418
|
+
class Honeybadger extends core_1.Client {
|
|
1419
|
+
constructor(opts = {}) {
|
|
1284
1420
|
var _a;
|
|
1285
|
-
|
|
1421
|
+
super(Object.assign({ afterUncaught: util_1.fatallyLogAndExit, projectRoot: process.cwd(), hostname: os_1.default.hostname() }, opts), new transport_1.ServerTransport());
|
|
1286
1422
|
/** @internal */
|
|
1287
|
-
|
|
1288
|
-
|
|
1423
|
+
this.__beforeNotifyHandlers = [
|
|
1424
|
+
(notice) => {
|
|
1289
1425
|
if (notice && notice.backtrace) {
|
|
1290
|
-
notice.backtrace.forEach(
|
|
1426
|
+
notice.backtrace.forEach((line) => {
|
|
1291
1427
|
if (line.file) {
|
|
1292
1428
|
line.file = line.file.replace(/.*\/node_modules\/(.+)/, '[NODE_MODULES]/$1');
|
|
1293
1429
|
line.file = line.file.replace(notice.projectRoot, '[PROJECT_ROOT]');
|
|
@@ -1298,39 +1434,36 @@ var Honeybadger = /** @class */ (function (_super) {
|
|
|
1298
1434
|
}
|
|
1299
1435
|
];
|
|
1300
1436
|
// serverless defaults
|
|
1301
|
-
|
|
1437
|
+
const config = this.config;
|
|
1302
1438
|
config.reportTimeoutWarning = (_a = config.reportTimeoutWarning) !== null && _a !== void 0 ? _a : true;
|
|
1303
1439
|
config.timeoutWarningThresholdMs = config.timeoutWarningThresholdMs || 50;
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
return _this;
|
|
1440
|
+
this.__getSourceFileHandler = util_1.getSourceFile.bind(this);
|
|
1441
|
+
this.errorHandler = middleware_1.errorHandler.bind(this);
|
|
1442
|
+
this.requestHandler = middleware_1.requestHandler.bind(this);
|
|
1443
|
+
this.lambdaHandler = aws_lambda_1.lambdaHandler.bind(this);
|
|
1309
1444
|
}
|
|
1310
|
-
|
|
1445
|
+
factory(opts) {
|
|
1311
1446
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1312
1447
|
return new Honeybadger(opts);
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
Honeybadger.prototype.checkIn = function (id) {
|
|
1319
|
-
var _this = this;
|
|
1448
|
+
}
|
|
1449
|
+
configure(opts = {}) {
|
|
1450
|
+
return super.configure(opts);
|
|
1451
|
+
}
|
|
1452
|
+
checkIn(id) {
|
|
1320
1453
|
return this.__transport
|
|
1321
1454
|
.send({
|
|
1322
1455
|
method: 'GET',
|
|
1323
|
-
endpoint: endpoint(this.config.endpoint,
|
|
1456
|
+
endpoint: endpoint(this.config.endpoint, `v1/check_in/${id}`),
|
|
1324
1457
|
logger: this.logger,
|
|
1325
1458
|
})
|
|
1326
|
-
.then(
|
|
1327
|
-
|
|
1459
|
+
.then(() => {
|
|
1460
|
+
this.logger.info('CheckIn sent');
|
|
1328
1461
|
return Promise.resolve();
|
|
1329
1462
|
})
|
|
1330
|
-
.catch(
|
|
1331
|
-
|
|
1463
|
+
.catch(err => {
|
|
1464
|
+
this.logger.error('CheckIn failed: an unknown error occurred.', `message=${err.message}`);
|
|
1332
1465
|
});
|
|
1333
|
-
}
|
|
1466
|
+
}
|
|
1334
1467
|
// This method is intended for web frameworks.
|
|
1335
1468
|
// It allows us to track context for individual requests without leaking to other requests
|
|
1336
1469
|
// by doing two things:
|
|
@@ -1338,10 +1471,9 @@ var Honeybadger = /** @class */ (function (_super) {
|
|
|
1338
1471
|
// 2. Attaching the store contents to the request object,
|
|
1339
1472
|
// so, even if the store is destroyed, we can still recover the context for a given request
|
|
1340
1473
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
this.__setStore(AsyncStore);
|
|
1474
|
+
withRequest(request, handler, onError) {
|
|
1475
|
+
const storeObject = (request[kHoneybadgerStore] || this.__getStoreContentsOrDefault());
|
|
1476
|
+
this.__setStore(async_store_1.AsyncStore);
|
|
1345
1477
|
if (!request[kHoneybadgerStore]) {
|
|
1346
1478
|
request[kHoneybadgerStore] = storeObject;
|
|
1347
1479
|
}
|
|
@@ -1352,20 +1484,19 @@ var Honeybadger = /** @class */ (function (_super) {
|
|
|
1352
1484
|
// But the `onError` handler might be request-specific.
|
|
1353
1485
|
// Note that this doesn't still handle all cases. `domain` has its own problems:
|
|
1354
1486
|
// See https://github.com/honeybadger-io/honeybadger-js/pull/711
|
|
1355
|
-
|
|
1356
|
-
|
|
1487
|
+
const dom = domain_1.default.create();
|
|
1488
|
+
const onErrorWithContext = (err) => this.__store.run(storeObject, () => onError(err));
|
|
1357
1489
|
dom.on('error', onErrorWithContext);
|
|
1358
1490
|
handler = dom.bind(handler);
|
|
1359
1491
|
}
|
|
1360
1492
|
return this.__store.run(storeObject, handler);
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
var server = new Honeybadger({
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
var _default = server.default = new Honeybadger({
|
|
1365
1496
|
__plugins: [
|
|
1366
|
-
|
|
1367
|
-
|
|
1497
|
+
(0, uncaught_exception_1.default)(),
|
|
1498
|
+
(0, unhandled_rejection_1.default)()
|
|
1368
1499
|
],
|
|
1369
1500
|
});
|
|
1370
1501
|
|
|
1371
|
-
module.exports =
|
|
1502
|
+
module.exports = _default;
|