@multiplayer-app/session-recorder-node 1.3.27 → 1.3.30
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/express.d.ts +8 -0
- package/dist/integrations/express.d.ts.map +1 -0
- package/dist/integrations/express.js +24 -0
- package/dist/integrations/express.js.map +1 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +38 -0
- package/dist/integrations/index.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/integrations/express.ts +52 -0
- package/src/integrations/index.ts +1 -0
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,eAAO,MAAM,eAAe,iBAAwB,CAAA;AAEpD,cAAc,0CAA0C,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,eAAO,MAAM,eAAe,iBAAwB,CAAA;AAEpD,cAAc,0CAA0C,CAAA;AACxD,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,35 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
16
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.sessionRecorder = void 0;
|
|
39
|
+
exports.Integrations = exports.sessionRecorder = void 0;
|
|
18
40
|
const sessionRecorder_1 = require("./sessionRecorder");
|
|
19
41
|
exports.sessionRecorder = new sessionRecorder_1.SessionRecorder();
|
|
20
42
|
__exportStar(require("@multiplayer-app/session-recorder-common"), exports);
|
|
43
|
+
exports.Integrations = __importStar(require("./integrations"));
|
|
21
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAmD;AAEtC,QAAA,eAAe,GAAG,IAAI,iCAAe,EAAE,CAAA;AAEpD,2EAAwD;AACxD,+DAA8C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as http from 'node:http';
|
|
2
|
+
type ExpressErrorMiddleware = (error: Error, req: http.IncomingMessage, res: http.ServerResponse, next: (error: Error) => void) => void;
|
|
3
|
+
interface ExpressHandlerOptions {
|
|
4
|
+
shouldHandleError?(this: void, error: Error): boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErrorMiddleware;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=express.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/integrations/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAA;AAKtC,KAAK,sBAAsB,GAAG,CAC5B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KACzB,IAAI,CAAC;AAWV,UAAU,qBAAqB;IAC3B,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;CACzD;AAaD,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAe3F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expressErrorHandler = expressErrorHandler;
|
|
4
|
+
const session_recorder_common_1 = require("@multiplayer-app/session-recorder-common");
|
|
5
|
+
function getStatusCodeFromResponse(error) {
|
|
6
|
+
var _a;
|
|
7
|
+
const statusCode = error.status || error.statusCode || error.status_code || ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode);
|
|
8
|
+
return statusCode ? parseInt(statusCode, 10) : 500;
|
|
9
|
+
}
|
|
10
|
+
/** Returns true if response code is internal server error */
|
|
11
|
+
function defaultShouldHandleError(error) {
|
|
12
|
+
const status = getStatusCodeFromResponse(error);
|
|
13
|
+
return status >= 500;
|
|
14
|
+
}
|
|
15
|
+
function expressErrorHandler(options) {
|
|
16
|
+
return function multiplayerErrorMiddleware(error, request, res, next) {
|
|
17
|
+
const shouldHandleError = (options === null || options === void 0 ? void 0 : options.shouldHandleError) || defaultShouldHandleError;
|
|
18
|
+
if (shouldHandleError(error)) {
|
|
19
|
+
session_recorder_common_1.SessionRecorderSdk.captureException(error);
|
|
20
|
+
}
|
|
21
|
+
next(error);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=express.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/integrations/express.ts"],"names":[],"mappings":";;AAoCA,kDAeC;AAlDD,sFAA6E;AAwB7E,SAAS,yBAAyB,CAAC,KAAsB;;IACvD,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,WAAW,KAAI,MAAA,KAAK,CAAC,MAAM,0CAAE,UAAU,CAAA,CAAA;IACpG,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;AAC9D,CAAC;AAED,6DAA6D;AAC7D,SAAS,wBAAwB,CAAC,KAAY;IAC5C,MAAM,MAAM,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAA;IAC/C,OAAO,MAAM,IAAI,GAAG,CAAA;AACtB,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAA+B;IACjE,OAAO,SAAS,0BAA0B,CACxC,KAAY,EACZ,OAA6B,EAC7B,GAAwB,EACxB,IAA4B;QAE5B,MAAM,iBAAiB,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,KAAI,wBAAwB,CAAA;QAEhF,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,4CAAkB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,CAAA;IACb,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.express = void 0;
|
|
37
|
+
exports.express = __importStar(require("./express"));
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAoC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplayer-app/session-recorder-node",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.30",
|
|
4
4
|
"description": "Multiplayer Fullstack Session Recorder for Node.js",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Multiplayer Software, Inc.",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepublishOnly": "npm run build"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@multiplayer-app/session-recorder-common": "1.3.
|
|
39
|
+
"@multiplayer-app/session-recorder-common": "1.3.30",
|
|
40
40
|
"@opentelemetry/api": "^1.9.0",
|
|
41
41
|
"@opentelemetry/core": "^2.0.1",
|
|
42
42
|
"@opentelemetry/otlp-exporter-base": "^0.203.0",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type * as http from 'node:http'
|
|
2
|
+
import { SessionRecorderSdk } from '@multiplayer-app/session-recorder-common'
|
|
3
|
+
|
|
4
|
+
type ExpressMiddleware = (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void;
|
|
5
|
+
|
|
6
|
+
type ExpressErrorMiddleware = (
|
|
7
|
+
error: Error,
|
|
8
|
+
req: http.IncomingMessage,
|
|
9
|
+
res: http.ServerResponse,
|
|
10
|
+
next: (error: Error) => void,
|
|
11
|
+
) => void;
|
|
12
|
+
|
|
13
|
+
interface MiddlewareError extends Error {
|
|
14
|
+
status?: number | string;
|
|
15
|
+
statusCode?: number | string;
|
|
16
|
+
status_code?: number | string;
|
|
17
|
+
output?: {
|
|
18
|
+
statusCode?: number | string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ExpressHandlerOptions {
|
|
23
|
+
shouldHandleError?(this: void, error: Error): boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getStatusCodeFromResponse(error: MiddlewareError): number {
|
|
27
|
+
const statusCode = error.status || error.statusCode || error.status_code || error.output?.statusCode
|
|
28
|
+
return statusCode ? parseInt(statusCode as string, 10) : 500
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Returns true if response code is internal server error */
|
|
32
|
+
function defaultShouldHandleError(error: Error): boolean {
|
|
33
|
+
const status = getStatusCodeFromResponse(error)
|
|
34
|
+
return status >= 500
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErrorMiddleware {
|
|
38
|
+
return function multiplayerErrorMiddleware(
|
|
39
|
+
error: Error,
|
|
40
|
+
request: http.IncomingMessage,
|
|
41
|
+
res: http.ServerResponse,
|
|
42
|
+
next: (error: Error) => void,
|
|
43
|
+
): void {
|
|
44
|
+
const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError
|
|
45
|
+
|
|
46
|
+
if (shouldHandleError(error)) {
|
|
47
|
+
SessionRecorderSdk.captureException(error)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
next(error)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as express from './express'
|