@multiplayer-app/session-recorder-node 1.2.2 → 1.2.3

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.
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "cli-example",
3
+ "version": "1.0.0",
4
+ "description": "CLI demo",
5
+ "author": {
6
+ "name": "Multiplayer Software, Inc.",
7
+ "url": "https://www.multiplayer.app"
8
+ },
9
+ "license": "MIT",
10
+ "main": "dist/index.js",
11
+ "engines": {
12
+ "node": ">=18",
13
+ "npm": ">=8"
14
+ },
15
+ "keywords": [
16
+ "multiplayer",
17
+ "debugger",
18
+ "platform",
19
+ "platform debugger",
20
+ "session recorder",
21
+ "otlp",
22
+ "fullstack session recorder"
23
+ ],
24
+ "scripts": {
25
+ "start": "node dist/index.js",
26
+ "dev": "ts-node src/index.ts",
27
+ "build": "npm run clean && npm run compile",
28
+ "clean": "rm -rf ./dist",
29
+ "compile": "tsc --build --force",
30
+ "lint": "eslint src/**/*.ts --config ../../.eslintrc"
31
+ },
32
+ "dependencies": {
33
+ "@multiplayer-app/session-recorder-common": "1.2.2",
34
+ "@opentelemetry/api": "1.9.0",
35
+ "@opentelemetry/api-logs": "0.203.0",
36
+ "@opentelemetry/auto-instrumentations-node": "0.62.1",
37
+ "@opentelemetry/core": "2.0.1",
38
+ "@opentelemetry/exporter-trace-otlp-http": "0.203.0",
39
+ "@opentelemetry/exporter-logs-otlp-http": "0.203.0",
40
+ "@opentelemetry/resources": "2.0.1",
41
+ "@opentelemetry/sdk-logs": "0.203.0",
42
+ "@opentelemetry/sdk-trace-base": "2.0.1",
43
+ "@opentelemetry/sdk-trace-node": "2.0.1",
44
+ "@opentelemetry/semantic-conventions": "1.36.0",
45
+ "axios": "^1.10.0",
46
+ "to-json-schema": "^0.2.5"
47
+ },
48
+ "devDependencies": {
49
+ "@types/jest": "29.5.4",
50
+ "@types/node": "20.5.7",
51
+ "@types/restify-errors": "4.3.5",
52
+ "eslint": "8.48.0",
53
+ "ts-node": "10.9.1",
54
+ "typescript": "5.7.3"
55
+ }
56
+ }
@@ -0,0 +1,47 @@
1
+ export const NODE_ENV = process.env.NODE_ENV || 'development'
2
+ export const isProduction = NODE_ENV === 'production'
3
+
4
+ export const LOG_LEVEL = process.env.LOG_LEVEL || (isProduction ? 'info' : 'debug')
5
+
6
+ export const COMPONENT_NAME = process.env.npm_package_name?.split('/').pop() as string || process.env.SERVICE_NAME || 'timegate'
7
+ export const COMPONENT_VERSION = process.env.npm_package_version || '0.0.1'
8
+ export const ENVIRONMENT = process.env.ENVIRONMENT || 'staging'
9
+
10
+ export const MULTIPLAYER_OTLP_KEY = process.env.MULTIPLAYER_OTLP_KEY as string
11
+
12
+ if (!MULTIPLAYER_OTLP_KEY) {
13
+ throw new Error('MULTIPLAYER_OTLP_KEY is not set')
14
+ }
15
+
16
+ export const OTLP_TRACES_ENDPOINT = process.env.OTLP_TRACES_ENDPOINT || 'https://api.multiplayer.app/v1/traces'
17
+ export const OTLP_LOGS_ENDPOINT = process.env.OTLP_LOGS_ENDPOINT || 'https://api.multiplayer.app/v1/logs'
18
+
19
+ export const MULTIPLAYER_OTLP_SPAN_RATIO = process.env.MULTIPLAYER_OTLP_SPAN_RATIO
20
+ ? Number(process.env.MULTIPLAYER_OTLP_SPAN_RATIO)
21
+ : 0.01
22
+
23
+ export let DIALOGUE_HUB_SERVICE_URL = ''
24
+ export let EPOCH_ENGINE_SERVICE_URL = ''
25
+ export let MINDS_OF_TIME_SERVICE_URL = ''
26
+ export let VAULT_OF_TIME_SERVICE_URL = ''
27
+
28
+ export const MULTIPLAYER_BACKEND_SOURCE = process.env.MULTIPLAYER_BACKEND_SOURCE || 'production'
29
+
30
+ switch (process.env.MULTIPLAYER_BACKEND_SOURCE) {
31
+ case 'production':
32
+ DIALOGUE_HUB_SERVICE_URL = 'https://api.demo.multiplayer.app/v1/dialogue-hub'
33
+ EPOCH_ENGINE_SERVICE_URL = 'https://api.demo.multiplayer.app/v1/epoch-engine'
34
+ MINDS_OF_TIME_SERVICE_URL = 'https://api.demo.multiplayer.app/v1/minds-of-time'
35
+ VAULT_OF_TIME_SERVICE_URL = 'https://api.demo.multiplayer.app/v1/vault-of-time'
36
+ break
37
+ default:
38
+ DIALOGUE_HUB_SERVICE_URL = 'http://localhost:3000/v1/dialogue-hub'
39
+ EPOCH_ENGINE_SERVICE_URL = 'http://localhost:3000/v1/epoch-engine'
40
+ MINDS_OF_TIME_SERVICE_URL = 'http://localhost:3000/v1/minds-of-time'
41
+ VAULT_OF_TIME_SERVICE_URL = 'http://localhost:3000/v1/vault-of-time'
42
+ }
43
+
44
+ DIALOGUE_HUB_SERVICE_URL = process.env.DIALOGUE_HUB_SERVICE_URL || DIALOGUE_HUB_SERVICE_URL
45
+ EPOCH_ENGINE_SERVICE_URL = process.env.EPOCH_ENGINE_SERVICE_URL || EPOCH_ENGINE_SERVICE_URL
46
+ MINDS_OF_TIME_SERVICE_URL = process.env.MINDS_OF_TIME_SERVICE_URL || MINDS_OF_TIME_SERVICE_URL
47
+ VAULT_OF_TIME_SERVICE_URL = process.env.VAULT_OF_TIME_SERVICE_URL || VAULT_OF_TIME_SERVICE_URL
@@ -0,0 +1,43 @@
1
+ import { idGenerator } from './opentelemetry'
2
+ import {
3
+ sessionRecorder,
4
+ SessionType,
5
+ } from '@multiplayer-app/session-recorder-node'
6
+ import {
7
+ MULTIPLAYER_OTLP_KEY,
8
+ ENVIRONMENT,
9
+ COMPONENT_VERSION,
10
+ COMPONENT_NAME,
11
+ } from './config'
12
+
13
+ const main = async () => {
14
+ sessionRecorder.init({
15
+ apiKey: MULTIPLAYER_OTLP_KEY,
16
+ traceIdGenerator: idGenerator,
17
+ resourceAttributes: {
18
+ componentName: COMPONENT_NAME,
19
+ componentVersion: COMPONENT_VERSION,
20
+ environment: ENVIRONMENT,
21
+ },
22
+ })
23
+
24
+ await sessionRecorder.start(
25
+ SessionType.PLAIN,
26
+ {
27
+ name: 'Test nodejs cli app debug session',
28
+ resourceAttributes: {
29
+ version: 1,
30
+ },
31
+ },
32
+ )
33
+
34
+ // do something here
35
+
36
+ await sessionRecorder.stop()
37
+
38
+ setTimeout(() => {
39
+ process.exit(0)
40
+ }, 15000)
41
+ }
42
+
43
+ main()
@@ -34,13 +34,15 @@ import { LoggerProvider, BatchLogRecordProcessor } from '@opentelemetry/sdk-logs
34
34
  import * as apiLogs from '@opentelemetry/api-logs'
35
35
  // import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http'
36
36
 
37
- const SERVICE_NAME = ''
38
- const SERVICE_VERSION = ''
39
- const PLATFORM_ENV = ''
40
- const MULTIPLAYER_OTLP_KEY = ''
41
- const OTLP_TRACES_ENDPOINT = ''
42
- const OTLP_LOGS_ENDPOINT = ''
43
- const MULTIPLAYER_OTLP_SPAN_RATIO = ''
37
+ import {
38
+ OTLP_TRACES_ENDPOINT,
39
+ OTLP_LOGS_ENDPOINT,
40
+ MULTIPLAYER_OTLP_KEY,
41
+ MULTIPLAYER_OTLP_SPAN_RATIO,
42
+ COMPONENT_NAME,
43
+ COMPONENT_VERSION,
44
+ ENVIRONMENT,
45
+ } from './config'
44
46
 
45
47
  // NOTE: Update instrumentation configuration as needed
46
48
  // For more see: https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node
@@ -65,10 +67,10 @@ const instrumentations = [
65
67
 
66
68
  const getResource = () => {
67
69
  const resourceWithAttributes = resourceFromAttributes({
68
- [ATTR_SERVICE_NAME]: SERVICE_NAME,
69
- [ATTR_SERVICE_VERSION]: SERVICE_VERSION,
70
+ [ATTR_SERVICE_NAME]: COMPONENT_NAME,
71
+ [ATTR_SERVICE_VERSION]: COMPONENT_VERSION,
70
72
  [SEMRESATTRS_HOST_NAME]: hostname(),
71
- [SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: PLATFORM_ENV,
73
+ [SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: ENVIRONMENT,
72
74
  [SEMRESATTRS_PROCESS_RUNTIME_VERSION]: process.version,
73
75
  [SEMRESATTRS_PROCESS_PID]: process.pid,
74
76
  })
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "declarationMap": true,
5
+ "baseUrl": ".",
6
+ "module": "commonjs",
7
+ "noImplicitAny": false,
8
+ "noUnusedParameters": false,
9
+ "allowJs": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "esModuleInterop": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "isolatedModules": true,
14
+ "moduleResolution": "node",
15
+ "noImplicitReturns": true,
16
+ "noImplicitThis": true,
17
+ "noUnusedLocals": false,
18
+ "preserveConstEnums": true,
19
+ "removeComments": false,
20
+ "resolveJsonModule": true,
21
+ "skipLibCheck": true,
22
+ "sourceMap": true,
23
+ "target": "ES2018",
24
+ "downlevelIteration": true,
25
+ "strict": true,
26
+ "composite": true,
27
+ "outDir": "./dist/",
28
+ "rootDir": "./src/",
29
+ "preserveSymlinks": true
30
+ },
31
+ "exclude": ["dist", "coverage", "jest.config.js", "__tests__", "migration"],
32
+ "references": [],
33
+ "ts-node": {
34
+ "files": true
35
+ }
36
+ }