@multiplayer-app/session-recorder-node 0.0.13 → 1.0.1-alpha.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 +24 -26
- package/dist/config.js.map +1 -1
- package/dist/services/api.service.d.ts +10 -2
- package/dist/services/api.service.d.ts.map +1 -1
- package/dist/services/api.service.js +27 -5
- package/dist/services/api.service.js.map +1 -1
- package/dist/sessionRecorder.d.ts +7 -2
- package/dist/sessionRecorder.d.ts.map +1 -1
- package/dist/sessionRecorder.js +13 -6
- package/dist/sessionRecorder.js.map +1 -1
- package/package.json +8 -8
- package/src/config.ts +1 -1
- package/src/services/api.service.ts +34 -7
- package/src/sessionRecorder.ts +20 -12
package/README.md
CHANGED
|
@@ -15,9 +15,9 @@ The Multiplayer **Session Recorder** is a powerful tool that offers deep session
|
|
|
15
15
|
You can install the Session Recorder using npm or yarn:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install @multiplayer-app/session-recorder-node
|
|
18
|
+
npm install @multiplayer-app/session-recorder-node
|
|
19
19
|
# or
|
|
20
|
-
yarn add @multiplayer-app/session-recorder-node
|
|
20
|
+
yarn add @multiplayer-app/session-recorder-node
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
### Basic Setup
|
|
@@ -37,17 +37,15 @@ import { idGenerator } from './opentelemetry'
|
|
|
37
37
|
Use the following code to initialize the session recorder with your application details:
|
|
38
38
|
|
|
39
39
|
```javascript
|
|
40
|
-
SessionRecorder.init(
|
|
41
|
-
'{YOUR_API_KEY}',
|
|
42
|
-
idGenerator,
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
environment: '{YOUR_APPLICATION_ENVIRONMENT}',
|
|
48
|
-
}
|
|
40
|
+
SessionRecorder.init({
|
|
41
|
+
apiKey: '{YOUR_API_KEY}',
|
|
42
|
+
traceIdGenerator: idGenerator,
|
|
43
|
+
resourceAttributes: {
|
|
44
|
+
serviceName: '{YOUR_APPLICATION_NAME}'
|
|
45
|
+
version: '{YOUR_APPLICATION_VERSION}',
|
|
46
|
+
environment: '{YOUR_APPLICATION_ENVIRONMENT}',
|
|
49
47
|
}
|
|
50
|
-
)
|
|
48
|
+
})
|
|
51
49
|
```
|
|
52
50
|
|
|
53
51
|
Replace the placeholders with your application’s version, name, environment, and API key.
|
|
@@ -61,26 +59,26 @@ This library relies on the following packages:
|
|
|
61
59
|
## Example Usage
|
|
62
60
|
|
|
63
61
|
```javascript
|
|
64
|
-
import
|
|
65
|
-
|
|
62
|
+
import {
|
|
63
|
+
sessionRecorder,
|
|
64
|
+
SessionType
|
|
65
|
+
} from '@multiplayer-app/session-recorder-node'
|
|
66
66
|
// Session recorder trace id generator which is used during opentelemetry initialization
|
|
67
67
|
import { idGenerator } from './opentelemetry'
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
'{YOUR_API_KEY}',
|
|
71
|
-
idGenerator,
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
environment: '{YOUR_APPLICATION_ENVIRONMENT}',
|
|
77
|
-
}
|
|
69
|
+
sessionRecorder.init({
|
|
70
|
+
apiKey: '{YOUR_API_KEY}',
|
|
71
|
+
traceIdGenerator: idGenerator,
|
|
72
|
+
resourceAttributes: {
|
|
73
|
+
serviceName: '{YOUR_APPLICATION_NAME}',
|
|
74
|
+
version: '{YOUR_APPLICATION_VERSION}',
|
|
75
|
+
environment: '{YOUR_APPLICATION_ENVIRONMENT}',
|
|
78
76
|
}
|
|
79
|
-
)
|
|
77
|
+
})
|
|
80
78
|
|
|
81
79
|
// ...
|
|
82
80
|
|
|
83
|
-
await
|
|
81
|
+
await sessionRecorder.start(
|
|
84
82
|
SessionType.PLAIN,
|
|
85
83
|
{
|
|
86
84
|
name: 'This is test session',
|
|
@@ -93,6 +91,6 @@ SessionRecorder.init(
|
|
|
93
91
|
|
|
94
92
|
// do something here
|
|
95
93
|
|
|
96
|
-
await
|
|
94
|
+
await sessionRecorder.stop()
|
|
97
95
|
|
|
98
96
|
```
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAiC;AAEpB,QAAA,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,6BAA6B,CAAA;AAEhG,QAAA,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,sBAAG,CAAC,OAAO,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ISession } from '../types';
|
|
2
2
|
export interface ApiServiceConfig {
|
|
3
3
|
apiKey?: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
apiBaseUrl?: string;
|
|
5
|
+
continuousRecording?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export interface StartSessionRequest {
|
|
8
8
|
name?: string;
|
|
@@ -25,6 +25,9 @@ export declare class ApiService {
|
|
|
25
25
|
/**
|
|
26
26
|
* Initialize the API service
|
|
27
27
|
* @param config - API service configuration
|
|
28
|
+
* @param config.apiKey - API key for authentication
|
|
29
|
+
* @param config.apiBaseUrl - Base URL for API endpoints (preferred)
|
|
30
|
+
* @param config.continuousRecording - Whether continuous recording is enabled
|
|
28
31
|
*/
|
|
29
32
|
init(config: ApiServiceConfig): void;
|
|
30
33
|
/**
|
|
@@ -32,6 +35,11 @@ export declare class ApiService {
|
|
|
32
35
|
* @param config - Partial configuration to update
|
|
33
36
|
*/
|
|
34
37
|
updateConfigs(config: Partial<ApiServiceConfig>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the current API base URL
|
|
40
|
+
* @returns The current API base URL
|
|
41
|
+
*/
|
|
42
|
+
getApiBaseUrl(): string;
|
|
35
43
|
/**
|
|
36
44
|
* Start a new debug session
|
|
37
45
|
* @param requestBody - Session start request data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.service.d.ts","sourceRoot":"","sources":["../../src/services/api.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,
|
|
1
|
+
{"version":3,"file":"api.service.d.ts","sourceRoot":"","sources":["../../src/services/api.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACvC,IAAI,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ;AAED,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,CAAC,EAAE;QAClB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAC;CACH;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAkB;;IAQhC;;;;;;OAMG;IACI,IAAI,CAAC,MAAM,EAAE,gBAAgB;IAYpC;;;OAGG;IACI,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAYtD;;;OAGG;IACI,aAAa,IAAI,MAAM;IAI9B;;;;OAIG;IACG,YAAY,CAChB,WAAW,EAAE,mBAAmB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,QAAQ,CAAC;IASpB;;;;OAIG;IACG,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC,GAAG,CAAC;IAQf;;;OAGG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAOpD;;;;OAIG;IACG,sBAAsB,CAC1B,WAAW,EAAE,mBAAmB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,GAAG,CAAC;IASf;;;;;OAKG;IACG,qBAAqB,CACzB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,mBAAmB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,GAAG,CAAC;IASf;;;OAGG;IACG,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAO5D;;OAEG;IACG,kBAAkB,CACtB,WAAW,EAAE,mBAAmB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAA;KAAE,CAAC;IASvC;;;;;;OAMG;YACW,WAAW;CAsC1B"}
|
|
@@ -5,22 +5,44 @@ const config_1 = require("../config");
|
|
|
5
5
|
class ApiService {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.config = {
|
|
8
|
-
|
|
8
|
+
apiBaseUrl: config_1.MULTIPLAYER_BASE_API_URL,
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Initialize the API service
|
|
13
13
|
* @param config - API service configuration
|
|
14
|
+
* @param config.apiKey - API key for authentication
|
|
15
|
+
* @param config.apiBaseUrl - Base URL for API endpoints (preferred)
|
|
16
|
+
* @param config.continuousRecording - Whether continuous recording is enabled
|
|
14
17
|
*/
|
|
15
18
|
init(config) {
|
|
16
|
-
|
|
19
|
+
const { apiBaseUrl: _apiBaseUrl, ...restConfig } = config;
|
|
20
|
+
const apiBaseUrl = _apiBaseUrl || config_1.MULTIPLAYER_BASE_API_URL;
|
|
21
|
+
this.config = {
|
|
22
|
+
...this.config,
|
|
23
|
+
...restConfig,
|
|
24
|
+
apiBaseUrl,
|
|
25
|
+
};
|
|
17
26
|
}
|
|
18
27
|
/**
|
|
19
28
|
* Update the API service configuration
|
|
20
29
|
* @param config - Partial configuration to update
|
|
21
30
|
*/
|
|
22
31
|
updateConfigs(config) {
|
|
23
|
-
|
|
32
|
+
const { apiBaseUrl: _apiBaseUrl, ...restConfig } = config;
|
|
33
|
+
const apiBaseUrl = _apiBaseUrl || config_1.MULTIPLAYER_BASE_API_URL;
|
|
34
|
+
this.config = {
|
|
35
|
+
...this.config,
|
|
36
|
+
...restConfig,
|
|
37
|
+
apiBaseUrl,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the current API base URL
|
|
42
|
+
* @returns The current API base URL
|
|
43
|
+
*/
|
|
44
|
+
getApiBaseUrl() {
|
|
45
|
+
return this.config.apiBaseUrl || config_1.MULTIPLAYER_BASE_API_URL;
|
|
24
46
|
}
|
|
25
47
|
/**
|
|
26
48
|
* Start a new debug session
|
|
@@ -73,7 +95,7 @@ class ApiService {
|
|
|
73
95
|
* Check debug session should be started remotely
|
|
74
96
|
*/
|
|
75
97
|
async checkRemoteSession(requestBody, signal) {
|
|
76
|
-
return this.makeRequest(
|
|
98
|
+
return this.makeRequest('/remote-debug-session/check', 'POST', requestBody, signal);
|
|
77
99
|
}
|
|
78
100
|
/**
|
|
79
101
|
* Make a request to the session API
|
|
@@ -83,7 +105,7 @@ class ApiService {
|
|
|
83
105
|
* @param signal - AbortSignal to set request's signal
|
|
84
106
|
*/
|
|
85
107
|
async makeRequest(path, method, body, signal) {
|
|
86
|
-
const url = `${this.config.
|
|
108
|
+
const url = `${this.config.apiBaseUrl}/v0/radar${path}`;
|
|
87
109
|
const params = {
|
|
88
110
|
method,
|
|
89
111
|
body: body ? JSON.stringify(body) : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.service.js","sourceRoot":"","sources":["../../src/services/api.service.ts"],"names":[],"mappings":";;;AAAA,sCAAoD;AA0BpD,MAAa,UAAU;IAGrB;QACE,IAAI,CAAC,MAAM,GAAG;YACZ,
|
|
1
|
+
{"version":3,"file":"api.service.js","sourceRoot":"","sources":["../../src/services/api.service.ts"],"names":[],"mappings":";;;AAAA,sCAAoD;AA0BpD,MAAa,UAAU;IAGrB;QACE,IAAI,CAAC,MAAM,GAAG;YACZ,UAAU,EAAE,iCAAwB;SACrC,CAAA;IACH,CAAC;IAED;;;;;;OAMG;IACI,IAAI,CAAC,MAAwB;QAClC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAA;QAEzD,MAAM,UAAU,GAAG,WAAW,IAAI,iCAAwB,CAAA;QAE1D,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,IAAI,CAAC,MAAM;YACd,GAAG,UAAU;YACb,UAAU;SACX,CAAA;IACH,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,MAAiC;QACpD,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAA;QAEzD,MAAM,UAAU,GAAG,WAAW,IAAI,iCAAwB,CAAA;QAE1D,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,IAAI,CAAC,MAAM;YACd,GAAG,UAAU;YACb,UAAU;SACX,CAAA;IACH,CAAC;IAED;;;OAGG;IACI,aAAa;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,iCAAwB,CAAA;IAC3D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAChB,WAAgC,EAChC,MAAoB;QAEpB,OAAO,IAAI,CAAC,WAAW,CACrB,uBAAuB,EAC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b,MAAM;YACN,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;YACxC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;aAC/D;SACF,CAAA;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,GAAG,MAAM;gBACT,WAAW,EAAE,SAAS;gBACtB,MAAM;aACP,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;YACxE,CAAC;YAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO,IAAI,CAAA;YACb,CAAC;YAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC9B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,YAAY,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;YACpC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3MD,gCA2MC"}
|
|
@@ -15,14 +15,19 @@ export declare class SessionRecorder {
|
|
|
15
15
|
constructor();
|
|
16
16
|
/**
|
|
17
17
|
* @description Initialize the session recorder
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
18
|
+
* @param config - Configuration object
|
|
19
|
+
* @param config.apiKey - multiplayer otlp key
|
|
20
|
+
* @param config.traceIdGenerator - multiplayer compatible trace id generator
|
|
21
|
+
* @param config.resourceAttributes - Optional resource attributes
|
|
22
|
+
* @param config.generateSessionShortIdLocally - Optional session short ID generator
|
|
23
|
+
* @param config.apiBaseUrl - Optional base API URL override
|
|
20
24
|
*/
|
|
21
25
|
init(config: {
|
|
22
26
|
apiKey: string;
|
|
23
27
|
traceIdGenerator: SessionRecorderIdGenerator;
|
|
24
28
|
resourceAttributes?: object;
|
|
25
29
|
generateSessionShortIdLocally?: boolean | (() => string);
|
|
30
|
+
apiBaseUrl?: string;
|
|
26
31
|
}): void;
|
|
27
32
|
/**
|
|
28
33
|
* @description Start a new session
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionRecorder.d.ts","sourceRoot":"","sources":["../src/sessionRecorder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,0BAA0B,EAG3B,MAAM,0CAA0C,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIlC,qBAAa,eAAe;IAC1B,OAAO,CAAC,cAAc,CAAQ;IAE9B,OAAO,CAAC,eAAe,CAA0B;IAEjD,OAAO,CAAC,iBAAiB,CAAwC;IACjE,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,wBAAwB,CAAqF;IAErH,OAAO,CAAC,mBAAmB,CAAa;IAExC;;OAEG;;IAGH
|
|
1
|
+
{"version":3,"file":"sessionRecorder.d.ts","sourceRoot":"","sources":["../src/sessionRecorder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,0BAA0B,EAG3B,MAAM,0CAA0C,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIlC,qBAAa,eAAe;IAC1B,OAAO,CAAC,cAAc,CAAQ;IAE9B,OAAO,CAAC,eAAe,CAA0B;IAEjD,OAAO,CAAC,iBAAiB,CAAwC;IACjE,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,wBAAwB,CAAqF;IAErH,OAAO,CAAC,mBAAmB,CAAa;IAExC;;OAEG;;IAGH;;;;;;;;OAQG;IACI,IAAI,CAAC,MAAM,EAAE;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,gBAAgB,EAAE,0BAA0B,CAAC;QAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,6BAA6B,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;QACzD,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,GAAG,IAAI;IAyBR;;;;;OAKG;IACU,KAAK,CAChB,WAAW,EAAE,WAAW,EACxB,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,GACrC,OAAO,CAAC,IAAI,CAAC;IAiDhB;;;;OAIG;WACU,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM;IAIjC;;;;OAIG;IACU,IAAI,CACf,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,IAAI,CAAC;IAiChB;;;;OAIG;IACU,IAAI,CACf,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,IAAI,CAAC;IAiChB;;;OAGG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BpC;;;;OAIG;IACU,4BAA4B,CACvC,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC;CAsBjB"}
|
package/dist/sessionRecorder.js
CHANGED
|
@@ -20,13 +20,17 @@ class SessionRecorder {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* @description Initialize the session recorder
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
23
|
+
* @param config - Configuration object
|
|
24
|
+
* @param config.apiKey - multiplayer otlp key
|
|
25
|
+
* @param config.traceIdGenerator - multiplayer compatible trace id generator
|
|
26
|
+
* @param config.resourceAttributes - Optional resource attributes
|
|
27
|
+
* @param config.generateSessionShortIdLocally - Optional session short ID generator
|
|
28
|
+
* @param config.apiBaseUrl - Optional base API URL override
|
|
25
29
|
*/
|
|
26
30
|
init(config) {
|
|
27
31
|
var _a, _b;
|
|
28
32
|
this._resourceAttributes = config.resourceAttributes || {
|
|
29
|
-
[session_recorder_common_1.ATTR_MULTIPLAYER_SESSION_RECORDER_VERSION]: config_1.SESSION_RECORDER_VERSION
|
|
33
|
+
[session_recorder_common_1.ATTR_MULTIPLAYER_SESSION_RECORDER_VERSION]: config_1.SESSION_RECORDER_VERSION,
|
|
30
34
|
};
|
|
31
35
|
this._isInitialized = true;
|
|
32
36
|
if (typeof config.generateSessionShortIdLocally === 'function') {
|
|
@@ -39,7 +43,10 @@ class SessionRecorder {
|
|
|
39
43
|
throw new Error('Incompatible trace id generator');
|
|
40
44
|
}
|
|
41
45
|
this._traceIdGenerator = config.traceIdGenerator;
|
|
42
|
-
this._apiService.init({
|
|
46
|
+
this._apiService.init({
|
|
47
|
+
apiKey: config.apiKey,
|
|
48
|
+
apiBaseUrl: config.apiBaseUrl,
|
|
49
|
+
});
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* @description Start a new session
|
|
@@ -67,7 +74,7 @@ class SessionRecorder {
|
|
|
67
74
|
: `Session on ${(0, helper_1.getFormattedDate)(Date.now())}`;
|
|
68
75
|
sessionPayload.resourceAttributes = {
|
|
69
76
|
...this._resourceAttributes,
|
|
70
|
-
...sessionPayload.resourceAttributes
|
|
77
|
+
...sessionPayload.resourceAttributes,
|
|
71
78
|
};
|
|
72
79
|
if (this._sessionType === session_recorder_common_1.SessionType.CONTINUOUS) {
|
|
73
80
|
session = await this._apiService.startContinuousSession(sessionPayload);
|
|
@@ -108,7 +115,7 @@ class SessionRecorder {
|
|
|
108
115
|
...(sessionData || {}),
|
|
109
116
|
name: (sessionData === null || sessionData === void 0 ? void 0 : sessionData.name)
|
|
110
117
|
? sessionData.name
|
|
111
|
-
: `Session on ${(0, helper_1.getFormattedDate)(Date.now())}
|
|
118
|
+
: `Session on ${(0, helper_1.getFormattedDate)(Date.now())}`,
|
|
112
119
|
});
|
|
113
120
|
}
|
|
114
121
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionRecorder.js","sourceRoot":"","sources":["../src/sessionRecorder.ts"],"names":[],"mappings":";;;AAAA,sFAMiD;AACjD,wDAAmD;AAEnD,qCAA2C;AAC3C,qCAAmD;AAEnD,MAAa,eAAe;IAa1B;;OAEG;IACH;QAfQ,mBAAc,GAAG,KAAK,CAAA;QAEtB,oBAAe,GAAqB,KAAK,CAAA;QAGzC,iBAAY,GAAgB,qCAAW,CAAC,KAAK,CAAA;QAC7C,kBAAa,GAAqC,SAAS,CAAA;QAC3D,gBAAW,GAAG,IAAI,wBAAU,EAAE,CAAA;QAC9B,6BAAwB,GAAG,4CAAkB,CAAC,cAAc,CAAC,yEAA+C,CAAC,CAAA;QAE7G,wBAAmB,GAAW,EAAE,CAAA;IAKxB,CAAC;IAEjB
|
|
1
|
+
{"version":3,"file":"sessionRecorder.js","sourceRoot":"","sources":["../src/sessionRecorder.ts"],"names":[],"mappings":";;;AAAA,sFAMiD;AACjD,wDAAmD;AAEnD,qCAA2C;AAC3C,qCAAmD;AAEnD,MAAa,eAAe;IAa1B;;OAEG;IACH;QAfQ,mBAAc,GAAG,KAAK,CAAA;QAEtB,oBAAe,GAAqB,KAAK,CAAA;QAGzC,iBAAY,GAAgB,qCAAW,CAAC,KAAK,CAAA;QAC7C,kBAAa,GAAqC,SAAS,CAAA;QAC3D,gBAAW,GAAG,IAAI,wBAAU,EAAE,CAAA;QAC9B,6BAAwB,GAAG,4CAAkB,CAAC,cAAc,CAAC,yEAA+C,CAAC,CAAA;QAE7G,wBAAmB,GAAW,EAAE,CAAA;IAKxB,CAAC;IAEjB;;;;;;;;OAQG;IACI,IAAI,CAAC,MAMX;;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C;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,4BAA4B,CACvC,cAAkD;QAElD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAA;QACH,CAAC;QAED,cAAc,GAAG,cAAc,IAAI,EAAE,CAAA;QAErC,cAAc,CAAC,kBAAkB,GAAG;YAClC,GAAG,CAAC,cAAc,CAAC,kBAAkB,IAAI,EAAE,CAAC;YAC5C,GAAG,IAAI,CAAC,mBAAmB;SAC5B,CAAA;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;QAE3E,IAAI,KAAK,IAAI,OAAO,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACzD,MAAM,IAAI,CAAC,KAAK,CAAC,qCAAW,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;QAC1D,CAAC;aAAM,IAAI,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YAC/D,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACnB,CAAC;IACH,CAAC;CACF;AA5QD,0CA4QC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplayer-app/session-recorder-node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1-alpha.2",
|
|
4
4
|
"description": "Multiplayer Fullstack Session Recorder for Node.js",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Multiplayer Software, Inc.",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"fullstack session recorder"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"lint": "eslint src/**/*.ts
|
|
25
|
+
"lint": "eslint src/**/*.ts",
|
|
26
26
|
"preversion": "npm run lint",
|
|
27
27
|
"postversion:skip": "git push && git push --tags",
|
|
28
28
|
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc --build tsconfig.json",
|
|
29
29
|
"prepublishOnly": "npm run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@multiplayer-app/session-recorder-common": "
|
|
32
|
+
"@multiplayer-app/session-recorder-common": "1.0.1-alpha.2",
|
|
33
33
|
"@opentelemetry/api": "^1.9.0",
|
|
34
|
-
"@opentelemetry/core": "^
|
|
35
|
-
"@opentelemetry/otlp-exporter-base": "^0.
|
|
36
|
-
"@opentelemetry/otlp-transformer": "^0.
|
|
37
|
-
"@opentelemetry/sdk-trace-base": "^
|
|
34
|
+
"@opentelemetry/core": "^2.0.1",
|
|
35
|
+
"@opentelemetry/otlp-exporter-base": "^0.203.0",
|
|
36
|
+
"@opentelemetry/otlp-transformer": "^0.203.0",
|
|
37
|
+
"@opentelemetry/sdk-trace-base": "^2.0.1",
|
|
38
38
|
"axios": "^1.10.0",
|
|
39
39
|
"to-json-schema": "^0.2.5"
|
|
40
40
|
},
|
|
@@ -42,4 +42,4 @@
|
|
|
42
42
|
"@types/node": "24.0.12",
|
|
43
43
|
"typescript": "5.8.3"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { ISession } from '../types'
|
|
|
3
3
|
|
|
4
4
|
export interface ApiServiceConfig {
|
|
5
5
|
apiKey?: string
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
apiBaseUrl?: string
|
|
7
|
+
continuousRecording?: boolean
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface StartSessionRequest {
|
|
@@ -29,16 +29,27 @@ export class ApiService {
|
|
|
29
29
|
|
|
30
30
|
constructor() {
|
|
31
31
|
this.config = {
|
|
32
|
-
|
|
32
|
+
apiBaseUrl: MULTIPLAYER_BASE_API_URL,
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Initialize the API service
|
|
38
38
|
* @param config - API service configuration
|
|
39
|
+
* @param config.apiKey - API key for authentication
|
|
40
|
+
* @param config.apiBaseUrl - Base URL for API endpoints (preferred)
|
|
41
|
+
* @param config.continuousRecording - Whether continuous recording is enabled
|
|
39
42
|
*/
|
|
40
43
|
public init(config: ApiServiceConfig) {
|
|
41
|
-
|
|
44
|
+
const { apiBaseUrl: _apiBaseUrl, ...restConfig } = config
|
|
45
|
+
|
|
46
|
+
const apiBaseUrl = _apiBaseUrl || MULTIPLAYER_BASE_API_URL
|
|
47
|
+
|
|
48
|
+
this.config = {
|
|
49
|
+
...this.config,
|
|
50
|
+
...restConfig,
|
|
51
|
+
apiBaseUrl,
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
/**
|
|
@@ -46,7 +57,23 @@ export class ApiService {
|
|
|
46
57
|
* @param config - Partial configuration to update
|
|
47
58
|
*/
|
|
48
59
|
public updateConfigs(config: Partial<ApiServiceConfig>) {
|
|
49
|
-
|
|
60
|
+
const { apiBaseUrl: _apiBaseUrl, ...restConfig } = config
|
|
61
|
+
|
|
62
|
+
const apiBaseUrl = _apiBaseUrl || MULTIPLAYER_BASE_API_URL
|
|
63
|
+
|
|
64
|
+
this.config = {
|
|
65
|
+
...this.config,
|
|
66
|
+
...restConfig,
|
|
67
|
+
apiBaseUrl,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get the current API base URL
|
|
73
|
+
* @returns The current API base URL
|
|
74
|
+
*/
|
|
75
|
+
public getApiBaseUrl(): string {
|
|
76
|
+
return this.config.apiBaseUrl || MULTIPLAYER_BASE_API_URL
|
|
50
77
|
}
|
|
51
78
|
|
|
52
79
|
/**
|
|
@@ -148,7 +175,7 @@ export class ApiService {
|
|
|
148
175
|
signal?: AbortSignal,
|
|
149
176
|
): Promise<{ state: 'START' | 'STOP' }> {
|
|
150
177
|
return this.makeRequest(
|
|
151
|
-
|
|
178
|
+
'/remote-debug-session/check',
|
|
152
179
|
'POST',
|
|
153
180
|
requestBody,
|
|
154
181
|
signal,
|
|
@@ -168,7 +195,7 @@ export class ApiService {
|
|
|
168
195
|
body?: any,
|
|
169
196
|
signal?: AbortSignal,
|
|
170
197
|
): Promise<any> {
|
|
171
|
-
const url = `${this.config.
|
|
198
|
+
const url = `${this.config.apiBaseUrl}/v0/radar${path}`
|
|
172
199
|
const params = {
|
|
173
200
|
method,
|
|
174
201
|
body: body ? JSON.stringify(body) : null,
|
package/src/sessionRecorder.ts
CHANGED
|
@@ -30,17 +30,22 @@ export class SessionRecorder {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* @description Initialize the session recorder
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
33
|
+
* @param config - Configuration object
|
|
34
|
+
* @param config.apiKey - multiplayer otlp key
|
|
35
|
+
* @param config.traceIdGenerator - multiplayer compatible trace id generator
|
|
36
|
+
* @param config.resourceAttributes - Optional resource attributes
|
|
37
|
+
* @param config.generateSessionShortIdLocally - Optional session short ID generator
|
|
38
|
+
* @param config.apiBaseUrl - Optional base API URL override
|
|
35
39
|
*/
|
|
36
40
|
public init(config: {
|
|
37
41
|
apiKey: string,
|
|
38
42
|
traceIdGenerator: SessionRecorderIdGenerator,
|
|
39
43
|
resourceAttributes?: object,
|
|
40
|
-
generateSessionShortIdLocally?: boolean | (() => string)
|
|
44
|
+
generateSessionShortIdLocally?: boolean | (() => string),
|
|
45
|
+
apiBaseUrl?: string
|
|
41
46
|
}): void {
|
|
42
47
|
this._resourceAttributes = config.resourceAttributes || {
|
|
43
|
-
[ATTR_MULTIPLAYER_SESSION_RECORDER_VERSION]: SESSION_RECORDER_VERSION
|
|
48
|
+
[ATTR_MULTIPLAYER_SESSION_RECORDER_VERSION]: SESSION_RECORDER_VERSION,
|
|
44
49
|
}
|
|
45
50
|
this._isInitialized = true
|
|
46
51
|
|
|
@@ -57,7 +62,10 @@ export class SessionRecorder {
|
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
this._traceIdGenerator = config.traceIdGenerator
|
|
60
|
-
this._apiService.init({
|
|
65
|
+
this._apiService.init({
|
|
66
|
+
apiKey: config.apiKey,
|
|
67
|
+
apiBaseUrl: config.apiBaseUrl,
|
|
68
|
+
})
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
/**
|
|
@@ -68,7 +76,7 @@ export class SessionRecorder {
|
|
|
68
76
|
*/
|
|
69
77
|
public async start(
|
|
70
78
|
sessionType: SessionType,
|
|
71
|
-
sessionPayload?: Omit<ISession, '_id'
|
|
79
|
+
sessionPayload?: Omit<ISession, '_id'>,
|
|
72
80
|
): Promise<void> {
|
|
73
81
|
if (!this._isInitialized) {
|
|
74
82
|
throw new Error(
|
|
@@ -99,7 +107,7 @@ export class SessionRecorder {
|
|
|
99
107
|
|
|
100
108
|
sessionPayload.resourceAttributes = {
|
|
101
109
|
...this._resourceAttributes,
|
|
102
|
-
...sessionPayload.resourceAttributes
|
|
110
|
+
...sessionPayload.resourceAttributes,
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
if (this._sessionType === SessionType.CONTINUOUS) {
|
|
@@ -112,7 +120,7 @@ export class SessionRecorder {
|
|
|
112
120
|
|
|
113
121
|
(this._traceIdGenerator as SessionRecorderIdGenerator).setSessionId(
|
|
114
122
|
this._shortSessionId,
|
|
115
|
-
this._sessionType
|
|
123
|
+
this._sessionType,
|
|
116
124
|
)
|
|
117
125
|
|
|
118
126
|
this._sessionState = 'STARTED'
|
|
@@ -133,7 +141,7 @@ export class SessionRecorder {
|
|
|
133
141
|
* @returns {Promise<void>}
|
|
134
142
|
*/
|
|
135
143
|
public async save(
|
|
136
|
-
sessionData?: ISession
|
|
144
|
+
sessionData?: ISession,
|
|
137
145
|
): Promise<void> {
|
|
138
146
|
try {
|
|
139
147
|
if (!this._isInitialized) {
|
|
@@ -159,7 +167,7 @@ export class SessionRecorder {
|
|
|
159
167
|
...(sessionData || {}),
|
|
160
168
|
name: sessionData?.name
|
|
161
169
|
? sessionData.name
|
|
162
|
-
: `Session on ${getFormattedDate(Date.now())}
|
|
170
|
+
: `Session on ${getFormattedDate(Date.now())}`,
|
|
163
171
|
},
|
|
164
172
|
)
|
|
165
173
|
} catch (e) {
|
|
@@ -173,7 +181,7 @@ export class SessionRecorder {
|
|
|
173
181
|
* @returns {Promise<void>}
|
|
174
182
|
*/
|
|
175
183
|
public async stop(
|
|
176
|
-
sessionData?: ISession
|
|
184
|
+
sessionData?: ISession,
|
|
177
185
|
): Promise<void> {
|
|
178
186
|
try {
|
|
179
187
|
if (!this._isInitialized) {
|
|
@@ -247,7 +255,7 @@ export class SessionRecorder {
|
|
|
247
255
|
* @returns {Promise<void>}
|
|
248
256
|
*/
|
|
249
257
|
public async checkRemoteContinuousSession(
|
|
250
|
-
sessionPayload?: Omit<ISession, '_id' | 'shortId'
|
|
258
|
+
sessionPayload?: Omit<ISession, '_id' | 'shortId'>,
|
|
251
259
|
): Promise<void> {
|
|
252
260
|
if (!this._isInitialized) {
|
|
253
261
|
throw new Error(
|