@multiplayer-app/session-recorder-common 1.1.0 → 1.2.0
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/esm/exporters/SessionRecorderBrowserTraceExporter.d.ts +2 -2
- package/dist/esm/exporters/SessionRecorderBrowserTraceExporter.d.ts.map +1 -1
- package/dist/esm/exporters/SessionRecorderBrowserTraceExporter.js +2 -1
- package/dist/esm/exporters/SessionRecorderBrowserTraceExporter.js.map +1 -1
- package/dist/esm/exporters/SessionRecorderHttpTraceExporter.d.ts.map +1 -1
- package/dist/esm/exporters/SessionRecorderHttpTraceExporter.js +14 -5
- package/dist/esm/exporters/SessionRecorderHttpTraceExporter.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esnext/exporters/SessionRecorderBrowserTraceExporter.d.ts +2 -2
- package/dist/esnext/exporters/SessionRecorderBrowserTraceExporter.d.ts.map +1 -1
- package/dist/esnext/exporters/SessionRecorderBrowserTraceExporter.js +2 -2
- package/dist/esnext/exporters/SessionRecorderBrowserTraceExporter.js.map +1 -1
- package/dist/esnext/exporters/SessionRecorderHttpTraceExporter.d.ts.map +1 -1
- package/dist/esnext/exporters/SessionRecorderHttpTraceExporter.js +3 -5
- package/dist/esnext/exporters/SessionRecorderHttpTraceExporter.js.map +1 -1
- package/dist/esnext/tsconfig.esnext.tsbuildinfo +1 -1
- package/dist/src/exporters/SessionRecorderBrowserTraceExporter.d.ts +2 -2
- package/dist/src/exporters/SessionRecorderBrowserTraceExporter.d.ts.map +1 -1
- package/dist/src/exporters/SessionRecorderBrowserTraceExporter.js +2 -2
- package/dist/src/exporters/SessionRecorderBrowserTraceExporter.js.map +1 -1
- package/dist/src/exporters/SessionRecorderHttpTraceExporter.d.ts.map +1 -1
- package/dist/src/exporters/SessionRecorderHttpTraceExporter.js +3 -5
- package/dist/src/exporters/SessionRecorderHttpTraceExporter.js.map +1 -1
- package/package.json +1 -1
- package/src/exporters/SessionRecorderBrowserTraceExporter.ts +3 -4
- package/src/exporters/SessionRecorderHttpTraceExporter.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionRecorderBrowserTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderBrowserTraceExporter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EACL,iDAAiD,EACjD,8BAA8B,EAC9B,yCAAyC,GAC1C,MAAM,6BAA6B,CAAA;AAuBpC;;;;GAIG;AACH,MAAM,OAAO,mCAAmC;IAO9C,YAAY,
|
|
1
|
+
{"version":3,"file":"SessionRecorderBrowserTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderBrowserTraceExporter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EACL,iDAAiD,EACjD,8BAA8B,EAC9B,yCAAyC,GAC1C,MAAM,6BAA6B,CAAA;AAuBpC;;;;GAIG;AACH,MAAM,OAAO,mCAAmC;IAO9C,YAAY,SAAoD,EAAE;QAL1D,mBAAc,GAAY,KAAK,CAAA;QAMrC,MAAM,EACJ,GAAG,GAAG,iDAAiD,EACvD,MAAM,EACN,OAAO,GAAG,EAAE,EACZ,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,IAAI,EAChB,gBAAgB,GAAG,EAAE,EACrB,eAAe,GAAG,kCAAkC,EACpD,uBAAuB,GAAG,GAAG,GAC9B,GAAG,MAAM,CAAA;QAEV,IAAI,CAAC,MAAM,mCACN,MAAM,KACT,GAAG;YACH,MAAM;YACN,OAAO;YACP,aAAa;YACb,SAAS;YACT,gBAAgB,GACjB,CAAA;QACD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;QACtC,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAA;QAEtD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,e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BACR,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU;gBACpC,sBAAsB,EAAE,IAAI,CAAC,QAAQ,CAAC,sBAAsB;aAC7D;SACF,CAAA;IACH,CAAC;IAEO,eAAe;QACrB,OAAO,IAAI,iBAAiB,CAAC;YAC3B,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG;YACpB,OAAO,gCACL,cAAc,EAAE,kBAAkB,IAC/B,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACnE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAC/B;YACD,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;YACxC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;SAC/C,CAAC,CAAA;IACJ,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;QAE3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;IACxC,CAAC;CACF","sourcesContent":["import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base'\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'\nimport {\n MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_HTTP_URL,\n MULTIPLAYER_TRACE_DEBUG_PREFIX,\n MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX,\n} from '../constants/constants.base'\n\nexport interface SessionRecorderBrowserTraceExporterConfig {\n /** URL for the OTLP endpoint. Defaults to Multiplayer's default traces endpoint. */\n url?: string\n /** API key for authentication. Required. */\n apiKey?: string\n /** Additional headers to include in requests */\n headers?: Record<string, string>\n /** Request timeout in milliseconds */\n timeoutMillis?: number\n /** Whether to use keep-alive connections */\n keepAlive?: boolean\n /** Maximum number of concurrent requests */\n concurrencyLimit?: number\n /** Whether to use postMessage fallback for cross-origin requests */\n usePostMessageFallback?: boolean\n /** PostMessage type identifier */\n postMessageType?: string\n /** PostMessage target origin */\n postMessageTargetOrigin?: string\n}\n\n/**\n * Browser-specific trace exporter for Session Recorder\n * Exports traces via HTTP to Multiplayer's OTLP endpoint with browser-specific optimizations\n * Only exports spans with trace IDs starting with Multiplayer prefixes\n */\nexport class SessionRecorderBrowserTraceExporter implements SpanExporter {\n private exporter: OTLPTraceExporter\n private usePostMessage: boolean = false\n private readonly postMessageType: string\n private readonly postMessageTargetOrigin: string\n private readonly config: SessionRecorderBrowserTraceExporterConfig\n\n constructor(config: SessionRecorderBrowserTraceExporterConfig = {}) {\n const {\n url = MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_HTTP_URL,\n apiKey,\n headers = {},\n timeoutMillis = 30000,\n keepAlive = true,\n concurrencyLimit = 20,\n postMessageType = 'MULTIPLAYER_SESSION_DEBUGGER_LIB',\n postMessageTargetOrigin = '*',\n } = config\n\n this.config = {\n ...config,\n url,\n apiKey,\n headers,\n timeoutMillis,\n keepAlive,\n concurrencyLimit,\n }\n this.postMessageType = postMessageType\n this.postMessageTargetOrigin = postMessageTargetOrigin\n\n this.exporter = this._createExporter()\n }\n\n export(\n spans: ReadableSpan[],\n resultCallback: (result: { code: number }) => void,\n ): void {\n // Filter spans to only include those with Multiplayer trace prefixes\n const filteredSpans = spans.filter(span => {\n const traceId = span.spanContext().traceId\n return traceId.startsWith(MULTIPLAYER_TRACE_DEBUG_PREFIX) ||\n traceId.startsWith(MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX)\n })\n\n // Only proceed if there are filtered spans\n if (filteredSpans.length === 0) {\n resultCallback({ code: 0 })\n return\n }\n\n if (this.usePostMessage) {\n this.exportViaPostMessage(filteredSpans, resultCallback)\n return\n }\n\n this.exporter.export(filteredSpans, (result) => {\n if (result.code === 0) {\n resultCallback(result)\n } else if (this.config.usePostMessageFallback) {\n this.usePostMessage = true\n this.exportViaPostMessage(filteredSpans, resultCallback)\n } else {\n resultCallback(result)\n }\n })\n }\n\n shutdown(): Promise<void> {\n return this.exporter.shutdown()\n }\n\n private exportViaPostMessage(spans: ReadableSpan[], resultCallback: (result: { code: number }) => void): void {\n if (typeof window === 'undefined') {\n resultCallback({ code: 1 })\n return\n }\n\n try {\n window.postMessage(\n {\n action: 'traces',\n type: this.postMessageType,\n payload: spans.map(span => this._serializeSpan(span)),\n },\n this.postMessageTargetOrigin,\n )\n resultCallback({ code: 0 })\n } catch (e) {\n resultCallback({ code: 1 })\n }\n }\n\n private _serializeSpan(span: ReadableSpan): any {\n const spanContext = span.spanContext()\n return {\n _spanContext: spanContext,\n name: span.name,\n kind: span.kind,\n links: span.links,\n ended: span.ended,\n events: span.events,\n status: span.status,\n endTime: span.endTime,\n startTime: span.startTime,\n duration: span.duration,\n attributes: span.attributes,\n parentSpanId: span.parentSpanContext?.spanId,\n droppedAttributesCount: span.droppedAttributesCount,\n droppedEventsCount: span.droppedEventsCount,\n droppedLinksCount: span.droppedLinksCount,\n resource: {\n attributes: span.resource.attributes,\n asyncAttributesPending: span.resource.asyncAttributesPending,\n },\n }\n }\n\n private _createExporter(): OTLPTraceExporter {\n return new OTLPTraceExporter({\n url: this.config.url,\n headers: {\n 'Content-Type': 'application/json',\n ...(this.config.apiKey ? { 'Authorization': this.config.apiKey } : {}),\n ...(this.config.headers || {}),\n },\n timeoutMillis: this.config.timeoutMillis,\n keepAlive: this.config.keepAlive,\n concurrencyLimit: this.config.concurrencyLimit,\n })\n }\n\n setApiKey(apiKey: string): void {\n this.config.apiKey = apiKey\n\n this.exporter = this._createExporter()\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionRecorderHttpTraceExporter.d.ts","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpTraceExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAO3E,MAAM,WAAW,sCAAsC;IACrD,+FAA+F;IAC/F,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;GAIG;AACH,qBAAa,gCAAiC,SAAQ,iBAAiB;gBACzD,MAAM,EAAE,sCAAsC;
|
|
1
|
+
{"version":3,"file":"SessionRecorderHttpTraceExporter.d.ts","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpTraceExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAO3E,MAAM,WAAW,sCAAsC;IACrD,+FAA+F;IAC/F,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;GAIG;AACH,qBAAa,gCAAiC,SAAQ,iBAAiB;gBACzD,MAAM,EAAE,sCAAsC;IAwBjD,MAAM,CACb,KAAK,EAAE,GAAG,EAAE,EACZ,cAAc,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GACjD,IAAI;CAcR"}
|
|
@@ -10,11 +10,9 @@ export class SessionRecorderHttpTraceExporter extends OTLPTraceExporter {
|
|
|
10
10
|
const { url = MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_HTTP_URL, apiKey, timeoutMillis = 30000, keepAlive = true, concurrencyLimit = 20, } = config;
|
|
11
11
|
super({
|
|
12
12
|
url,
|
|
13
|
-
headers: {
|
|
14
|
-
'
|
|
15
|
-
|
|
16
|
-
'Authorization': apiKey,
|
|
17
|
-
},
|
|
13
|
+
headers: Object.assign({ 'Content-Type': 'application/json', 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0' }, apiKey
|
|
14
|
+
? { 'Authorization': apiKey }
|
|
15
|
+
: {}),
|
|
18
16
|
timeoutMillis,
|
|
19
17
|
keepAlive,
|
|
20
18
|
concurrencyLimit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionRecorderHttpTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpTraceExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EACL,iDAAiD,EACjD,8BAA8B,EAC9B,yCAAyC,GAC1C,MAAM,6BAA6B,CAAA;AAepC;;;;GAIG;AACH,MAAM,OAAO,gCAAiC,SAAQ,iBAAiB;IACrE,YAAY,MAA8C;QACxD,MAAM,EACJ,GAAG,GAAG,iDAAiD,EACvD,MAAM,EACN,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,IAAI,EAChB,gBAAgB,GAAG,EAAE,GACtB,GAAG,MAAM,CAAA;QAEV,KAAK,CAAC;YACJ,GAAG;YACH,OAAO,
|
|
1
|
+
{"version":3,"file":"SessionRecorderHttpTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpTraceExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EACL,iDAAiD,EACjD,8BAA8B,EAC9B,yCAAyC,GAC1C,MAAM,6BAA6B,CAAA;AAepC;;;;GAIG;AACH,MAAM,OAAO,gCAAiC,SAAQ,iBAAiB;IACrE,YAAY,MAA8C;QACxD,MAAM,EACJ,GAAG,GAAG,iDAAiD,EACvD,MAAM,EACN,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,IAAI,EAChB,gBAAgB,GAAG,EAAE,GACtB,GAAG,MAAM,CAAA;QAEV,KAAK,CAAC;YACJ,GAAG;YACH,OAAO,kBACL,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,gDAAgD,IAC3D,MAAM;gBACP,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE;gBAC7B,CAAC,CAAC,EAAE,CACP;YACD,aAAa;YACb,SAAS;YACT,gBAAgB;SACjB,CAAC,CAAA;IACJ,CAAC;IAEQ,MAAM,CACb,KAAY,EACZ,cAAkD;QAElD,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAA;YAC1C,OAAO,OAAO,CAAC,UAAU,CAAC,8BAA8B,CAAC;gBACvD,OAAO,CAAC,UAAU,CAAC,yCAAyC,CAAC,CAAA;QACjE,CAAC,CAAC,CAAA;QAEF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;YAC3B,OAAM;QACR,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;IAC7C,CAAC;CACF","sourcesContent":["import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'\nimport {\n MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_HTTP_URL,\n MULTIPLAYER_TRACE_DEBUG_PREFIX,\n MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX,\n} from '../constants/constants.base'\n\nexport interface SessionRecorderHttpTraceExporterConfig {\n /** The URL to send traces to. Defaults to MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_HTTP_URL */\n url?: string\n /** API key for authentication. Required. */\n apiKey: string\n /** Timeout for HTTP requests in milliseconds. Defaults to 30000 */\n timeoutMillis?: number\n /** Whether to keep the connection alive. Defaults to true */\n keepAlive?: boolean\n /** Maximum number of concurrent requests. Defaults to 20 */\n concurrencyLimit?: number\n}\n\n/**\n * HTTP trace exporter for Session Recorder\n * Exports traces via HTTP to Multiplayer's OTLP endpoint\n * Only exports spans with trace IDs starting with Multiplayer prefixes\n */\nexport class SessionRecorderHttpTraceExporter extends OTLPTraceExporter {\n constructor(config: SessionRecorderHttpTraceExporterConfig) {\n const {\n url = MULTIPLAYER_OTEL_DEFAULT_TRACES_EXPORTER_HTTP_URL,\n apiKey,\n timeoutMillis = 30000,\n keepAlive = true,\n concurrencyLimit = 20,\n } = config\n\n super({\n url,\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',\n ...apiKey\n ? { 'Authorization': apiKey }\n : {},\n },\n timeoutMillis,\n keepAlive,\n concurrencyLimit,\n })\n }\n\n override export(\n spans: any[],\n resultCallback: (result: { code: number }) => void,\n ): void {\n const filteredSpans = spans.filter(span => {\n const traceId = span.spanContext().traceId\n return traceId.startsWith(MULTIPLAYER_TRACE_DEBUG_PREFIX) ||\n traceId.startsWith(MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX)\n })\n\n if (filteredSpans.length === 0) {\n resultCallback({ code: 0 })\n return\n }\n\n super.export(filteredSpans, resultCallback)\n }\n}\n"]}
|