@honeybadger-io/js 3.2.4 → 3.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/honeybadger.js +17 -8
- package/dist/browser/honeybadger.js.map +1 -1
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/browser/honeybadger.min.js.map +1 -1
- package/dist/browser/types/core/error.d.ts +3 -0
- package/dist/browser/types/server/aws_lambda.d.ts +9 -0
- package/dist/browser/types/server/integrations/uncaught_exception.d.ts +2 -0
- package/dist/browser/types/server/integrations/unhandled_rejection.d.ts +2 -0
- package/dist/browser/types/server/middleware.d.ts +4 -0
- package/dist/browser/types/server/util.d.ts +9 -0
- package/dist/browser/types/server.d.ts +13 -0
- package/dist/server/honeybadger.js +36 -20
- package/dist/server/types/browser/integrations/breadcrumbs.d.ts +2 -0
- package/dist/server/types/browser/integrations/event_listeners.d.ts +2 -0
- package/dist/server/types/browser/integrations/onerror.d.ts +3 -0
- package/dist/server/types/browser/integrations/onunhandledrejection.d.ts +2 -0
- package/dist/server/types/browser/integrations/timers.d.ts +2 -0
- package/dist/server/types/browser/util.d.ts +18 -0
- package/dist/server/types/browser.d.ts +15 -0
- package/dist/server/types/core/error.d.ts +3 -0
- package/dist/server/types/server/aws_lambda.d.ts +9 -0
- package/package.json +9 -9
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
import { Noticeable } from '../core/types';
|
|
3
|
+
export declare function requestHandler(req: Request, res: Response, next: NextFunction): void;
|
|
4
|
+
export declare function errorHandler(err: Noticeable, req: Request, _res: Response, next: NextFunction): unknown;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function fatallyLogAndExit(err: Error): never;
|
|
2
|
+
export declare function getStats(cb: (stats: Record<string, unknown>) => void): void;
|
|
3
|
+
/**
|
|
4
|
+
* Get source file if possible, used to build `notice.backtrace.source`
|
|
5
|
+
*
|
|
6
|
+
* @param path to source code
|
|
7
|
+
* @param cb callback with fileContent
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSourceFile(path: string, cb: (fileContent: string) => void): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Client from './core/client';
|
|
2
|
+
import { Config } from './core/types';
|
|
3
|
+
import { errorHandler, requestHandler } from './server/middleware';
|
|
4
|
+
import { lambdaHandler } from './server/aws_lambda';
|
|
5
|
+
declare class Honeybadger extends Client {
|
|
6
|
+
errorHandler: typeof errorHandler;
|
|
7
|
+
requestHandler: typeof requestHandler;
|
|
8
|
+
lambdaHandler: typeof lambdaHandler;
|
|
9
|
+
constructor(opts?: Partial<Config>);
|
|
10
|
+
factory(opts?: Partial<Config>): Honeybadger;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: Honeybadger;
|
|
13
|
+
export default _default;
|
|
@@ -309,7 +309,7 @@ function sanitize(obj, maxDepth) {
|
|
|
309
309
|
}
|
|
310
310
|
// Serialize inside arrays
|
|
311
311
|
if (Array.isArray(obj)) {
|
|
312
|
-
return obj.map(function (o) { return
|
|
312
|
+
return obj.map(function (o) { return safeSerialize(o, depth + 1); });
|
|
313
313
|
}
|
|
314
314
|
// Serialize inside objects
|
|
315
315
|
if (typeof (obj) === 'object') {
|
|
@@ -317,7 +317,7 @@ function sanitize(obj, maxDepth) {
|
|
|
317
317
|
for (var k in obj) {
|
|
318
318
|
var v = obj[k];
|
|
319
319
|
if (Object.prototype.hasOwnProperty.call(obj, k) && (k != null) && (v != null)) {
|
|
320
|
-
ret[k] =
|
|
320
|
+
ret[k] = safeSerialize(v, depth + 1);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
return ret;
|
|
@@ -325,7 +325,16 @@ function sanitize(obj, maxDepth) {
|
|
|
325
325
|
// Return everything else untouched
|
|
326
326
|
return obj;
|
|
327
327
|
}
|
|
328
|
-
|
|
328
|
+
function safeSerialize(obj, depth) {
|
|
329
|
+
if (depth === void 0) { depth = 0; }
|
|
330
|
+
try {
|
|
331
|
+
return serialize(obj, depth);
|
|
332
|
+
}
|
|
333
|
+
catch (e) {
|
|
334
|
+
return "[ERROR] " + e;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return safeSerialize(obj);
|
|
329
338
|
}
|
|
330
339
|
function logger(client) {
|
|
331
340
|
var log = function (method) {
|
|
@@ -488,7 +497,7 @@ function formatCGIData(vars, prefix) {
|
|
|
488
497
|
var notifier = {
|
|
489
498
|
name: 'honeybadger-js',
|
|
490
499
|
url: 'https://github.com/honeybadger-io/honeybadger-js',
|
|
491
|
-
version: '3.2.
|
|
500
|
+
version: '3.2.8'
|
|
492
501
|
};
|
|
493
502
|
// Split at commas
|
|
494
503
|
var TAG_SEPARATOR = /,/;
|
|
@@ -564,10 +573,6 @@ var Client = /** @class */ (function () {
|
|
|
564
573
|
Client.prototype.notify = function (notice, name, extra) {
|
|
565
574
|
if (name === void 0) { name = undefined; }
|
|
566
575
|
if (extra === void 0) { extra = undefined; }
|
|
567
|
-
if (!this.config.apiKey) {
|
|
568
|
-
this.logger.warn('Unable to send error report: no API key has been configured');
|
|
569
|
-
return false;
|
|
570
|
-
}
|
|
571
576
|
if (this.config.disabled) {
|
|
572
577
|
this.logger.warn('Deprecation warning: instead of `disabled: true`, use `reportData: false` to explicitly disable Honeybadger reporting. (Dropping notice: honeybadger.js is disabled)');
|
|
573
578
|
return false;
|
|
@@ -576,6 +581,10 @@ var Client = /** @class */ (function () {
|
|
|
576
581
|
this.logger.debug('Dropping notice: honeybadger.js is in development mode');
|
|
577
582
|
return false;
|
|
578
583
|
}
|
|
584
|
+
if (!this.config.apiKey) {
|
|
585
|
+
this.logger.warn('Unable to send error report: no API key has been configured');
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
579
588
|
notice = makeNotice(notice);
|
|
580
589
|
if (name && !(typeof name === 'object')) {
|
|
581
590
|
var n = String(name);
|
|
@@ -830,31 +839,38 @@ function errorHandler(err, req, _res, next) {
|
|
|
830
839
|
}
|
|
831
840
|
function lambdaHandler(handler) {
|
|
832
841
|
return function lambdaHandler(event, context, callback) {
|
|
842
|
+
// in the case of an async handler, the length of the handler will be less than 3 (no callback function).
|
|
843
|
+
// if this is the case, we have to explicitly call the callback function from the function we are returning.
|
|
844
|
+
// we don't have to do that if the handler has third callback function parameter,
|
|
845
|
+
// because it will be called directly from inside the handler.
|
|
846
|
+
var shouldInvokeCallbackExplicitly = handler.length < 3;
|
|
833
847
|
// eslint-disable-next-line prefer-rest-params
|
|
834
848
|
var args = arguments;
|
|
835
849
|
var dom = domain__default['default'].create();
|
|
836
850
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
837
851
|
var hb = this;
|
|
838
|
-
|
|
839
|
-
hb.notify(err, {
|
|
852
|
+
var hbHandler = function (err) {
|
|
853
|
+
var willNotify = hb.notify(err, {
|
|
840
854
|
afterNotify: function () {
|
|
841
855
|
hb.clear();
|
|
842
856
|
callback(err);
|
|
843
857
|
}
|
|
844
858
|
});
|
|
845
|
-
|
|
859
|
+
if (!willNotify) {
|
|
860
|
+
callback(err);
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
dom.on('error', hbHandler);
|
|
846
864
|
dom.run(function () {
|
|
847
865
|
process.nextTick(function () {
|
|
848
866
|
Promise.resolve(handler.apply(this, args))
|
|
849
|
-
.then(function () {
|
|
850
|
-
.
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
});
|
|
857
|
-
});
|
|
867
|
+
.then(function (res) {
|
|
868
|
+
hb.clear();
|
|
869
|
+
if (shouldInvokeCallbackExplicitly) {
|
|
870
|
+
callback(null, res);
|
|
871
|
+
}
|
|
872
|
+
})
|
|
873
|
+
.catch(hbHandler);
|
|
858
874
|
});
|
|
859
875
|
});
|
|
860
876
|
}.bind(this);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an HTMLElement into a human-readable string.
|
|
3
|
+
* @param {!HTMLElement} element
|
|
4
|
+
* @return {string}
|
|
5
|
+
*/
|
|
6
|
+
export declare function stringNameOfElement(element: HTMLElement): string;
|
|
7
|
+
export declare function stringSelectorOfElement(element: any): any;
|
|
8
|
+
export declare function stringTextOfElement(element: any): any;
|
|
9
|
+
export declare function nativeFetch(): boolean;
|
|
10
|
+
export declare function parseURL(url: any): {
|
|
11
|
+
protocol: any;
|
|
12
|
+
host: any;
|
|
13
|
+
pathname: any;
|
|
14
|
+
};
|
|
15
|
+
export declare function localURLPathname(url: any): any;
|
|
16
|
+
export declare function decodeCookie(string: string): Record<string, unknown>;
|
|
17
|
+
export declare function encodeCookie(object: any): string;
|
|
18
|
+
export declare const preferCatch: boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Client from './core/client';
|
|
2
|
+
import { Config } from './core/types';
|
|
3
|
+
interface BrowserConfig extends Config {
|
|
4
|
+
async: boolean;
|
|
5
|
+
maxErrors: number;
|
|
6
|
+
}
|
|
7
|
+
declare class Honeybadger extends Client {
|
|
8
|
+
config: BrowserConfig;
|
|
9
|
+
constructor(opts?: Partial<BrowserConfig>);
|
|
10
|
+
configure(opts?: Partial<BrowserConfig>): Client;
|
|
11
|
+
resetMaxErrors(): number;
|
|
12
|
+
factory(opts?: Partial<BrowserConfig>): Honeybadger;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: Honeybadger;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Handler, Callback, Context } from 'aws-lambda';
|
|
2
|
+
export declare type SyncHandler<TEvent = any, TResult = any> = (event: TEvent, context: Context, callback: Callback<TResult>) => void;
|
|
3
|
+
export declare type AsyncHandler<TEvent = any, TResult = any> = (event: TEvent, context: Context) => Promise<TResult>;
|
|
4
|
+
export declare function lambdaHandler<TEvent = any, TResult = any>(handler: Handler<TEvent, TResult>): Handler<TEvent, TResult>;
|
|
5
|
+
/**
|
|
6
|
+
* Removes AWS Lambda default listener that
|
|
7
|
+
* exits the process before letting us report to honeybadger.
|
|
8
|
+
*/
|
|
9
|
+
export declare function removeAwsDefaultUncaughtExceptionListener(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honeybadger-io/js",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/honeybadger-io/honeybadger-js",
|
|
6
6
|
"author": {
|
|
@@ -48,25 +48,25 @@
|
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
50
50
|
"@rollup/plugin-typescript": "^8.2.5",
|
|
51
|
-
"@types/jest": "^
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
53
|
-
"@typescript-eslint/parser": "^
|
|
54
|
-
"axios": ">=0.21.
|
|
51
|
+
"@types/jest": "^27.0.2",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
53
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
54
|
+
"axios": ">=0.21.4",
|
|
55
55
|
"concurrently": "^6.2.1",
|
|
56
|
-
"eslint": "^
|
|
56
|
+
"eslint": "^8.0.0",
|
|
57
57
|
"eslint-plugin-import": "^2.24.1",
|
|
58
|
-
"eslint-plugin-jest": "^
|
|
58
|
+
"eslint-plugin-jest": "^25.0.1",
|
|
59
59
|
"eslint-plugin-promise": "^5.1.0",
|
|
60
60
|
"express": "^4.17.1",
|
|
61
61
|
"jest": "^27.0.6",
|
|
62
62
|
"nock": "^13.1.2",
|
|
63
63
|
"rollup": "^2.56.2",
|
|
64
64
|
"rollup-plugin-uglify": "^6.0.2",
|
|
65
|
-
"shipjs": "0.
|
|
65
|
+
"shipjs": "0.24.0",
|
|
66
66
|
"sinon": "^11.1.2",
|
|
67
67
|
"supertest": "^6.1.6",
|
|
68
68
|
"ts-jest": "^27.0.5",
|
|
69
|
-
"tsd": "^0.
|
|
69
|
+
"tsd": "^0.18.0",
|
|
70
70
|
"tslib": "^2.3.1",
|
|
71
71
|
"typescript": "^4.3.5"
|
|
72
72
|
},
|