@multiplayer-app/session-recorder-common 1.0.1-alpha.2 → 1.0.1-alpha.4

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.
Files changed (40) hide show
  1. package/dist/esm/SessionRecorderIdGenerator.d.ts +6 -3
  2. package/dist/esm/SessionRecorderIdGenerator.d.ts.map +1 -1
  3. package/dist/esm/SessionRecorderIdGenerator.js +26 -41
  4. package/dist/esm/SessionRecorderIdGenerator.js.map +1 -1
  5. package/dist/esm/exporters/SessionRecorderBrowserTraceExporter.js +1 -1
  6. package/dist/esm/exporters/SessionRecorderBrowserTraceExporter.js.map +1 -1
  7. package/dist/esm/exporters/SessionRecorderHttpLogsExporter.js +1 -1
  8. package/dist/esm/exporters/SessionRecorderHttpLogsExporter.js.map +1 -1
  9. package/dist/esm/exporters/SessionRecorderHttpTraceExporter.d.ts.map +1 -1
  10. package/dist/esm/exporters/SessionRecorderHttpTraceExporter.js +3 -5
  11. package/dist/esm/exporters/SessionRecorderHttpTraceExporter.js.map +1 -1
  12. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  13. package/dist/esnext/SessionRecorderIdGenerator.d.ts +6 -3
  14. package/dist/esnext/SessionRecorderIdGenerator.d.ts.map +1 -1
  15. package/dist/esnext/SessionRecorderIdGenerator.js +21 -19
  16. package/dist/esnext/SessionRecorderIdGenerator.js.map +1 -1
  17. package/dist/esnext/exporters/SessionRecorderBrowserTraceExporter.js +1 -1
  18. package/dist/esnext/exporters/SessionRecorderBrowserTraceExporter.js.map +1 -1
  19. package/dist/esnext/exporters/SessionRecorderHttpLogsExporter.js +1 -1
  20. package/dist/esnext/exporters/SessionRecorderHttpLogsExporter.js.map +1 -1
  21. package/dist/esnext/exporters/SessionRecorderHttpTraceExporter.d.ts.map +1 -1
  22. package/dist/esnext/exporters/SessionRecorderHttpTraceExporter.js +3 -5
  23. package/dist/esnext/exporters/SessionRecorderHttpTraceExporter.js.map +1 -1
  24. package/dist/esnext/tsconfig.esnext.tsbuildinfo +1 -1
  25. package/dist/src/SessionRecorderIdGenerator.d.ts +6 -3
  26. package/dist/src/SessionRecorderIdGenerator.d.ts.map +1 -1
  27. package/dist/src/SessionRecorderIdGenerator.js +21 -19
  28. package/dist/src/SessionRecorderIdGenerator.js.map +1 -1
  29. package/dist/src/exporters/SessionRecorderBrowserTraceExporter.js +1 -1
  30. package/dist/src/exporters/SessionRecorderBrowserTraceExporter.js.map +1 -1
  31. package/dist/src/exporters/SessionRecorderHttpLogsExporter.js +1 -1
  32. package/dist/src/exporters/SessionRecorderHttpLogsExporter.js.map +1 -1
  33. package/dist/src/exporters/SessionRecorderHttpTraceExporter.d.ts.map +1 -1
  34. package/dist/src/exporters/SessionRecorderHttpTraceExporter.js +3 -5
  35. package/dist/src/exporters/SessionRecorderHttpTraceExporter.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/SessionRecorderIdGenerator.ts +26 -23
  38. package/src/exporters/SessionRecorderBrowserTraceExporter.ts +1 -1
  39. package/src/exporters/SessionRecorderHttpLogsExporter.ts +1 -1
  40. package/src/exporters/SessionRecorderHttpTraceExporter.ts +7 -6
@@ -1,33 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SessionRecorderIdGenerator = void 0;
4
- const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
5
4
  const type_1 = require("./type");
6
5
  const constants_base_1 = require("./constants/constants.base");
7
6
  const sdk_1 = require("./sdk");
8
- class SessionRecorderIdGenerator extends sdk_trace_base_1.RandomIdGenerator {
7
+ class SessionRecorderIdGenerator {
9
8
  constructor() {
10
- super();
11
9
  this.generateLongId = (0, sdk_1.getIdGenerator)(16);
10
+ this.generateShortId = (0, sdk_1.getIdGenerator)(8);
12
11
  this.sessionShortId = '';
13
12
  this.sessionType = type_1.SessionType.PLAIN;
14
- this.generateTraceId = () => {
15
- const traceId = this.generateLongId();
16
- if (this.sessionShortId) {
17
- let sessionTypePrefix = '';
18
- switch (this.sessionType) {
19
- case type_1.SessionType.CONTINUOUS:
20
- sessionTypePrefix = constants_base_1.MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX;
21
- break;
22
- default:
23
- sessionTypePrefix = constants_base_1.MULTIPLAYER_TRACE_DEBUG_PREFIX;
24
- }
25
- const prefix = `${sessionTypePrefix}${this.sessionShortId}`;
26
- const sessionTraceId = `${prefix}${traceId.substring(prefix.length, traceId.length)}`;
27
- return sessionTraceId;
13
+ }
14
+ generateTraceId() {
15
+ const traceId = this.generateLongId();
16
+ if (this.sessionShortId) {
17
+ let sessionTypePrefix = '';
18
+ switch (this.sessionType) {
19
+ case type_1.SessionType.CONTINUOUS:
20
+ sessionTypePrefix = constants_base_1.MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX;
21
+ break;
22
+ default:
23
+ sessionTypePrefix = constants_base_1.MULTIPLAYER_TRACE_DEBUG_PREFIX;
28
24
  }
29
- return traceId;
30
- };
25
+ const prefix = `${sessionTypePrefix}${this.sessionShortId}`;
26
+ const sessionTraceId = `${prefix}${traceId.substring(prefix.length, traceId.length)}`;
27
+ return sessionTraceId;
28
+ }
29
+ return traceId;
30
+ }
31
+ generateSpanId() {
32
+ return this.generateShortId();
31
33
  }
32
34
  setSessionId(sessionShortId, sessionType = type_1.SessionType.PLAIN) {
33
35
  this.sessionShortId = sessionShortId;
@@ -1 +1 @@
1
- {"version":3,"file":"SessionRecorderIdGenerator.js","sourceRoot":"","sources":["../../src/SessionRecorderIdGenerator.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AACjE,iCAAoC;AACpC,+DAGmC;AACnC,+BAAsC;AAEtC,MAAa,0BAA2B,SAAQ,kCAAiB;IAM/D;QACE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,cAAc,GAAG,IAAA,oBAAc,EAAC,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;QACxB,IAAI,CAAC,WAAW,GAAG,kBAAW,CAAC,KAAK,CAAA;QAEpC,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;YAErC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBACxB,IAAI,iBAAiB,GAAW,EAAE,CAAA;gBAClC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;oBACzB,KAAK,kBAAW,CAAC,UAAU;wBACzB,iBAAiB,GAAG,0DAAyC,CAAA;wBAC7D,MAAK;oBACP;wBACE,iBAAiB,GAAG,+CAA8B,CAAA;gBACtD,CAAC;gBAED,MAAM,MAAM,GAAG,GAAG,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;gBAE3D,MAAM,cAAc,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;gBAErF,OAAO,cAAc,CAAA;YACvB,CAAC;YAED,OAAO,OAAO,CAAA;QAChB,CAAC,CAAA;IACH,CAAC;IAED,YAAY,CACV,cAAsB,EACtB,cAA2B,kBAAW,CAAC,KAAK;QAE5C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;CACF;AA5CD,gEA4CC","sourcesContent":["import { RandomIdGenerator } from '@opentelemetry/sdk-trace-base'\nimport { SessionType } from './type'\nimport {\n MULTIPLAYER_TRACE_DEBUG_PREFIX,\n MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX,\n} from './constants/constants.base'\nimport { getIdGenerator } from './sdk'\n\nexport class SessionRecorderIdGenerator extends RandomIdGenerator {\n sessionShortId: string\n sessionType: SessionType\n\n generateLongId: () => string\n\n constructor() {\n super()\n\n this.generateLongId = getIdGenerator(16)\n this.sessionShortId = ''\n this.sessionType = SessionType.PLAIN\n\n this.generateTraceId = () => {\n const traceId = this.generateLongId()\n\n if (this.sessionShortId) {\n let sessionTypePrefix: string = ''\n switch (this.sessionType) {\n case SessionType.CONTINUOUS:\n sessionTypePrefix = MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX\n break\n default:\n sessionTypePrefix = MULTIPLAYER_TRACE_DEBUG_PREFIX\n }\n\n const prefix = `${sessionTypePrefix}${this.sessionShortId}`\n\n const sessionTraceId = `${prefix}${traceId.substring(prefix.length, traceId.length)}`\n\n return sessionTraceId\n }\n\n return traceId\n }\n }\n\n setSessionId(\n sessionShortId: string,\n sessionType: SessionType = SessionType.PLAIN,\n ) {\n this.sessionShortId = sessionShortId\n this.sessionType = sessionType\n }\n}\n"]}
1
+ {"version":3,"file":"SessionRecorderIdGenerator.js","sourceRoot":"","sources":["../../src/SessionRecorderIdGenerator.ts"],"names":[],"mappings":";;;AACA,iCAAoC;AACpC,+DAGmC;AACnC,+BAAsC;AAEtC,MAAa,0BAA0B;IAMrC;QACE,IAAI,CAAC,cAAc,GAAG,IAAA,oBAAc,EAAC,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,eAAe,GAAG,IAAA,oBAAc,EAAC,CAAC,CAAC,CAAA;QACxC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;QACxB,IAAI,CAAC,WAAW,GAAG,kBAAW,CAAC,KAAK,CAAA;IACtC,CAAC;IAED,eAAe;QACb,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;QAErC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,IAAI,iBAAiB,GAAW,EAAE,CAAA;YAClC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;gBACzB,KAAK,kBAAW,CAAC,UAAU;oBACzB,iBAAiB,GAAG,0DAAyC,CAAA;oBAC7D,MAAK;gBACP;oBACE,iBAAiB,GAAG,+CAA8B,CAAA;YACtD,CAAC;YAED,MAAM,MAAM,GAAG,GAAG,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;YAE3D,MAAM,cAAc,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;YAErF,OAAO,cAAc,CAAA;QACvB,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,eAAe,EAAE,CAAA;IAC/B,CAAC;IAED,YAAY,CACV,cAAsB,EACtB,cAA2B,kBAAW,CAAC,KAAK;QAE5C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;CACF;AA/CD,gEA+CC","sourcesContent":["import { IdGenerator } from '@opentelemetry/sdk-trace-base'\nimport { SessionType } from './type'\nimport {\n MULTIPLAYER_TRACE_DEBUG_PREFIX,\n MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX,\n} from './constants/constants.base'\nimport { getIdGenerator } from './sdk'\n\nexport class SessionRecorderIdGenerator implements IdGenerator {\n sessionShortId: string\n sessionType: SessionType\n private generateLongId: () => string\n private generateShortId: () => string\n\n constructor() {\n this.generateLongId = getIdGenerator(16)\n this.generateShortId = getIdGenerator(8)\n this.sessionShortId = ''\n this.sessionType = SessionType.PLAIN\n }\n\n generateTraceId(): string {\n const traceId = this.generateLongId()\n\n if (this.sessionShortId) {\n let sessionTypePrefix: string = ''\n switch (this.sessionType) {\n case SessionType.CONTINUOUS:\n sessionTypePrefix = MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX\n break\n default:\n sessionTypePrefix = MULTIPLAYER_TRACE_DEBUG_PREFIX\n }\n\n const prefix = `${sessionTypePrefix}${this.sessionShortId}`\n\n const sessionTraceId = `${prefix}${traceId.substring(prefix.length, traceId.length)}`\n\n return sessionTraceId\n }\n\n return traceId\n }\n\n generateSpanId(): string {\n return this.generateShortId()\n }\n\n setSessionId(\n sessionShortId: string,\n sessionType: SessionType = SessionType.PLAIN,\n ) {\n this.sessionShortId = sessionShortId\n this.sessionType = sessionType\n }\n}\n"]}
@@ -99,7 +99,7 @@ class SessionRecorderBrowserTraceExporter {
99
99
  _createExporter() {
100
100
  return new exporter_trace_otlp_http_1.OTLPTraceExporter({
101
101
  url: this.config.url,
102
- headers: Object.assign({ 'Content-Type': 'application/x-protobuf', 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0', 'authorization': this.config.apiKey }, (this.config.headers || {})),
102
+ headers: Object.assign({ 'Content-Type': 'application/json', 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0', 'authorization': this.config.apiKey }, (this.config.headers || {})),
103
103
  timeoutMillis: this.config.timeoutMillis,
104
104
  keepAlive: this.config.keepAlive,
105
105
  concurrencyLimit: this.config.concurrencyLimit,
@@ -1 +1 @@
1
- {"version":3,"file":"SessionRecorderBrowserTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderBrowserTraceExporter.ts"],"names":[],"mappings":";;;AACA,sFAA2E;AAC3E,gEAIoC;AAuBpC;;;;GAIG;AACH,MAAa,mCAAmC;IAO9C,YAAY,MAAiD;QALrD,mBAAc,GAAY,KAAK,CAAA;QAMrC,MAAM,EACJ,GAAG,GAAG,kEAAiD,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,eAAe,EAAE,CAA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E,IAAI,CAAC,QAAQ,CAAC,UAAU;gBACpC,sBAAsB,EAAE,IAAI,CAAC,QAAQ,CAAC,sBAAsB;aAC7D;SACF,CAAA;IACH,CAAC;IAEO,eAAe;QACrB,OAAO,IAAI,4CAAiB,CAAC;YAC3B,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG;YACpB,OAAO,kBACL,cAAc,EAAE,wBAAwB,EACxC,YAAY,EAAE,gDAAgD,EAC9D,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,IAChC,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;AA1ID,kFA0IC","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/x-protobuf',\n 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',\n '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
+ {"version":3,"file":"SessionRecorderBrowserTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderBrowserTraceExporter.ts"],"names":[],"mappings":";;;AACA,sFAA2E;AAC3E,gEAIoC;AAuBpC;;;;GAIG;AAC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Q,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;IACxC,CAAC;CACF;AA1ID,kFA0IC","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 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',\n '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"]}
@@ -9,7 +9,7 @@ class SessionRecorderHttpLogsExporter extends exporter_logs_otlp_http_1.OTLPLogE
9
9
  super({
10
10
  url,
11
11
  headers: {
12
- 'Content-Type': 'application/x-protobuf',
12
+ 'Content-Type': 'application/json',
13
13
  'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',
14
14
  'authorization': apiKey,
15
15
  },
@@ -1 +1 @@
1
- {"version":3,"file":"SessionRecorderHttpLogsExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpLogsExporter.ts"],"names":[],"mappings":";;;AAAA,oFAAwE;AACxE,gEAIoC;AAepC,MAAa,+BAAgC,SAAQ,yCAAe;IAClE,YAAY,MAA6C;QACvD,MAAM,EACJ,GAAG,GAAG,gEAA+C,EACrD,MAAM,EACN,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,IAAI,EAChB,gBAAgB,GAAG,EAAE,GACtB,GAAG,MAAM,CAAA;QAEV,KAAK,CAAC;YACJ,GAAG;YACH,OAAO,EAAE;gBACP,cAAc,EAAE,wBAAwB;gBACxC,YAAY,EAAE,gDAAgD;gBAC9D,eAAe,EAAE,MAAM;aACxB;YACD,aAAa;YACb,SAAS;YACT,gBAAgB;SACjB,CAAC,CAAA;IACJ,CAAC;IAEQ,MAAM,CAAC,IAAW,EAAE,cAAkD;QAC7E,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;;YACrC,MAAM,OAAO,GAAG,CAAA,MAAA,GAAG,CAAC,WAAW,0CAAE,OAAO,KAAI,GAAG,CAAC,OAAO,CAAA;YACvD,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,+CAA8B,CAAC;gBACnE,OAAO,CAAC,UAAU,CAAC,0DAAyC,CAAC,CAAC,CAAA;QAClE,CAAC,CAAC,CAAA;QAEF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;YAC3B,OAAM;QACR,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;IAC5C,CAAC;CACF;AArCD,0EAqCC","sourcesContent":["import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http'\nimport {\n MULTIPLAYER_OTEL_DEFAULT_LOGS_EXPORTER_HTTP_URL,\n MULTIPLAYER_TRACE_DEBUG_PREFIX,\n MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX,\n} from '../constants/constants.base'\n\nexport interface SessionRecorderHttpLogsExporterConfig {\n /** The URL to send logs to. Defaults to MULTIPLAYER_OTEL_DEFAULT_LOGS_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\nexport class SessionRecorderHttpLogsExporter extends OTLPLogExporter {\n constructor(config: SessionRecorderHttpLogsExporterConfig) {\n const {\n url = MULTIPLAYER_OTEL_DEFAULT_LOGS_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/x-protobuf',\n 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',\n 'authorization': apiKey,\n },\n timeoutMillis,\n keepAlive,\n concurrencyLimit,\n })\n }\n\n override export(logs: any[], resultCallback: (result: { code: number }) => void): void {\n const filteredLogs = logs.filter(log => {\n const traceId = log.spanContext?.traceId || log.traceId\n return traceId && (traceId.startsWith(MULTIPLAYER_TRACE_DEBUG_PREFIX) ||\n traceId.startsWith(MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX))\n })\n\n if (filteredLogs.length === 0) {\n resultCallback({ code: 0 })\n return\n }\n\n super.export(filteredLogs, resultCallback)\n }\n}\n"]}
1
+ {"version":3,"file":"SessionRecorderHttpLogsExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpLogsExporter.ts"],"names":[],"mappings":";;;AAAA,oFAAwE;AACxE,gEAIoC;AAepC,MAAa,+BAAgC,SAAQ,yCAAe;IAClE,YAAY,MAA6C;QACvD,MAAM,EACJ,GAAG,GAAG,gEAA+C,EACrD,MAAM,EACN,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,IAAI,EAChB,gBAAgB,GAAG,EAAE,GACtB,GAAG,MAAM,CAAA;QAEV,KAAK,CAAC;YACJ,GAAG;YACH,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,gDAAgD;gBAC9D,eAAe,EAAE,MAAM;aACxB;YACD,aAAa;YACb,SAAS;YACT,gBAAgB;SACjB,CAAC,CAAA;IACJ,CAAC;IAEQ,MAAM,CAAC,IAAW,EAAE,cAAkD;QAC7E,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;;YACrC,MAAM,OAAO,GAAG,CAAA,MAAA,GAAG,CAAC,WAAW,0CAAE,OAAO,KAAI,GAAG,CAAC,OAAO,CAAA;YACvD,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,+CAA8B,CAAC;gBACnE,OAAO,CAAC,UAAU,CAAC,0DAAyC,CAAC,CAAC,CAAA;QAClE,CAAC,CAAC,CAAA;QAEF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;YAC3B,OAAM;QACR,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;IAC5C,CAAC;CACF;AArCD,0EAqCC","sourcesContent":["import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http'\nimport {\n MULTIPLAYER_OTEL_DEFAULT_LOGS_EXPORTER_HTTP_URL,\n MULTIPLAYER_TRACE_DEBUG_PREFIX,\n MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX,\n} from '../constants/constants.base'\n\nexport interface SessionRecorderHttpLogsExporterConfig {\n /** The URL to send logs to. Defaults to MULTIPLAYER_OTEL_DEFAULT_LOGS_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\nexport class SessionRecorderHttpLogsExporter extends OTLPLogExporter {\n constructor(config: SessionRecorderHttpLogsExporterConfig) {\n const {\n url = MULTIPLAYER_OTEL_DEFAULT_LOGS_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 'authorization': apiKey,\n },\n timeoutMillis,\n keepAlive,\n concurrencyLimit,\n })\n }\n\n override export(logs: any[], resultCallback: (result: { code: number }) => void): void {\n const filteredLogs = logs.filter(log => {\n const traceId = log.spanContext?.traceId || log.traceId\n return traceId && (traceId.startsWith(MULTIPLAYER_TRACE_DEBUG_PREFIX) ||\n traceId.startsWith(MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX))\n })\n\n if (filteredLogs.length === 0) {\n resultCallback({ code: 0 })\n return\n }\n\n super.export(filteredLogs, resultCallback)\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;IAsBjD,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,IAAI;CAgBxF"}
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;IAsBjD,MAAM,CACb,KAAK,EAAE,GAAG,EAAE,EACZ,cAAc,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GACjD,IAAI;CAcR"}
@@ -14,9 +14,9 @@ class SessionRecorderHttpTraceExporter extends exporter_trace_otlp_http_1.OTLPTr
14
14
  super({
15
15
  url,
16
16
  headers: {
17
- 'Content-Type': 'application/x-protobuf',
17
+ 'Content-Type': 'application/json',
18
18
  'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',
19
- 'authorization': apiKey,
19
+ 'Authorization': apiKey,
20
20
  },
21
21
  timeoutMillis,
22
22
  keepAlive,
@@ -24,18 +24,16 @@ class SessionRecorderHttpTraceExporter extends exporter_trace_otlp_http_1.OTLPTr
24
24
  });
25
25
  }
26
26
  export(spans, resultCallback) {
27
- // Filter spans to only include those with Multiplayer trace prefixes
28
27
  const filteredSpans = spans.filter(span => {
29
28
  const traceId = span.spanContext().traceId;
30
29
  return traceId.startsWith(constants_base_1.MULTIPLAYER_TRACE_DEBUG_PREFIX) ||
31
30
  traceId.startsWith(constants_base_1.MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX);
32
31
  });
33
- // Only proceed if there are filtered spans
34
32
  if (filteredSpans.length === 0) {
35
33
  resultCallback({ code: 0 });
36
34
  return;
37
35
  }
38
- super.export(filteredSpans, resultCallback);
36
+ return super.export(filteredSpans, resultCallback);
39
37
  }
40
38
  }
41
39
  exports.SessionRecorderHttpTraceExporter = SessionRecorderHttpTraceExporter;
@@ -1 +1 @@
1
- {"version":3,"file":"SessionRecorderHttpTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpTraceExporter.ts"],"names":[],"mappings":";;;AAAA,sFAA2E;AAC3E,gEAIoC;AAepC;;;;GAIG;AACH,MAAa,gCAAiC,SAAQ,4CAAiB;IACrE,YAAY,MAA8C;QACxD,MAAM,EACJ,GAAG,GAAG,kEAAiD,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,EAAE;gBACP,cAAc,EAAE,wBAAwB;gBACxC,YAAY,EAAE,gDAAgD;gBAC9D,eAAe,EAAE,MAAM;aACxB;YACD,aAAa;YACb,SAAS;YACT,gBAAgB;SACjB,CAAC,CAAA;IACJ,CAAC;IAEQ,MAAM,CAAC,KAAY,EAAE,cAAkD;QAC9E,qEAAqE;QACrE,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,+CAA8B,CAAC;gBACvD,OAAO,CAAC,UAAU,CAAC,0DAAyC,CAAC,CAAA;QACjE,CAAC,CAAC,CAAA;QAEF,2CAA2C;QAC3C,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;AAvCD,4EAuCC","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/x-protobuf',\n 'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',\n 'authorization': apiKey,\n },\n timeoutMillis,\n keepAlive,\n concurrencyLimit,\n })\n }\n\n override export(spans: any[], resultCallback: (result: { code: number }) => void): 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 super.export(filteredSpans, resultCallback)\n }\n}\n"]}
1
+ {"version":3,"file":"SessionRecorderHttpTraceExporter.js","sourceRoot":"","sources":["../../../src/exporters/SessionRecorderHttpTraceExporter.ts"],"names":[],"mappings":";;;AAAA,sFAA2E;AAC3E,gEAIoC;AAepC;;;;GAIG;AACH,MAAa,gCAAiC,SAAQ,4CAAiB;IACrE,YAAY,MAA8C;QACxD,MAAM,EACJ,GAAG,GAAG,kEAAiD,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,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,gDAAgD;gBAC9D,eAAe,EAAE,MAAM;aACxB;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,+CAA8B,CAAC;gBACvD,OAAO,CAAC,UAAU,CAAC,0DAAyC,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,OAAO,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;IACpD,CAAC;CACF;AAxCD,4EAwCC","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 'Authorization': apiKey,\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 return super.export(filteredSpans, resultCallback)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplayer-app/session-recorder-common",
3
- "version": "1.0.1-alpha.2",
3
+ "version": "1.0.1-alpha.4",
4
4
  "description": "Multiplayer Fullstack Session Recorder - opentelemetry",
5
5
  "author": {
6
6
  "name": "Multiplayer Software, Inc.",
@@ -1,4 +1,4 @@
1
- import { RandomIdGenerator } from '@opentelemetry/sdk-trace-base'
1
+ import { IdGenerator } from '@opentelemetry/sdk-trace-base'
2
2
  import { SessionType } from './type'
3
3
  import {
4
4
  MULTIPLAYER_TRACE_DEBUG_PREFIX,
@@ -6,41 +6,44 @@ import {
6
6
  } from './constants/constants.base'
7
7
  import { getIdGenerator } from './sdk'
8
8
 
9
- export class SessionRecorderIdGenerator extends RandomIdGenerator {
9
+ export class SessionRecorderIdGenerator implements IdGenerator {
10
10
  sessionShortId: string
11
11
  sessionType: SessionType
12
-
13
- generateLongId: () => string
12
+ private generateLongId: () => string
13
+ private generateShortId: () => string
14
14
 
15
15
  constructor() {
16
- super()
17
-
18
16
  this.generateLongId = getIdGenerator(16)
17
+ this.generateShortId = getIdGenerator(8)
19
18
  this.sessionShortId = ''
20
19
  this.sessionType = SessionType.PLAIN
20
+ }
21
21
 
22
- this.generateTraceId = () => {
23
- const traceId = this.generateLongId()
22
+ generateTraceId(): string {
23
+ const traceId = this.generateLongId()
24
+
25
+ if (this.sessionShortId) {
26
+ let sessionTypePrefix: string = ''
27
+ switch (this.sessionType) {
28
+ case SessionType.CONTINUOUS:
29
+ sessionTypePrefix = MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX
30
+ break
31
+ default:
32
+ sessionTypePrefix = MULTIPLAYER_TRACE_DEBUG_PREFIX
33
+ }
24
34
 
25
- if (this.sessionShortId) {
26
- let sessionTypePrefix: string = ''
27
- switch (this.sessionType) {
28
- case SessionType.CONTINUOUS:
29
- sessionTypePrefix = MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX
30
- break
31
- default:
32
- sessionTypePrefix = MULTIPLAYER_TRACE_DEBUG_PREFIX
33
- }
35
+ const prefix = `${sessionTypePrefix}${this.sessionShortId}`
34
36
 
35
- const prefix = `${sessionTypePrefix}${this.sessionShortId}`
37
+ const sessionTraceId = `${prefix}${traceId.substring(prefix.length, traceId.length)}`
36
38
 
37
- const sessionTraceId = `${prefix}${traceId.substring(prefix.length, traceId.length)}`
39
+ return sessionTraceId
40
+ }
38
41
 
39
- return sessionTraceId
40
- }
42
+ return traceId
43
+ }
41
44
 
42
- return traceId
43
- }
45
+ generateSpanId(): string {
46
+ return this.generateShortId()
44
47
  }
45
48
 
46
49
  setSessionId(
@@ -154,7 +154,7 @@ export class SessionRecorderBrowserTraceExporter implements SpanExporter {
154
154
  return new OTLPTraceExporter({
155
155
  url: this.config.url,
156
156
  headers: {
157
- 'Content-Type': 'application/x-protobuf',
157
+ 'Content-Type': 'application/json',
158
158
  'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',
159
159
  'authorization': this.config.apiKey,
160
160
  ...(this.config.headers || {}),
@@ -31,7 +31,7 @@ export class SessionRecorderHttpLogsExporter extends OTLPLogExporter {
31
31
  super({
32
32
  url,
33
33
  headers: {
34
- 'Content-Type': 'application/x-protobuf',
34
+ 'Content-Type': 'application/json',
35
35
  'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',
36
36
  'authorization': apiKey,
37
37
  },
@@ -36,9 +36,9 @@ export class SessionRecorderHttpTraceExporter extends OTLPTraceExporter {
36
36
  super({
37
37
  url,
38
38
  headers: {
39
- 'Content-Type': 'application/x-protobuf',
39
+ 'Content-Type': 'application/json',
40
40
  'User-Agent': '@multiplayer-app/session-recorder-common/1.0.0',
41
- 'authorization': apiKey,
41
+ 'Authorization': apiKey,
42
42
  },
43
43
  timeoutMillis,
44
44
  keepAlive,
@@ -46,20 +46,21 @@ export class SessionRecorderHttpTraceExporter extends OTLPTraceExporter {
46
46
  })
47
47
  }
48
48
 
49
- override export(spans: any[], resultCallback: (result: { code: number }) => void): void {
50
- // Filter spans to only include those with Multiplayer trace prefixes
49
+ override export(
50
+ spans: any[],
51
+ resultCallback: (result: { code: number }) => void,
52
+ ): void {
51
53
  const filteredSpans = spans.filter(span => {
52
54
  const traceId = span.spanContext().traceId
53
55
  return traceId.startsWith(MULTIPLAYER_TRACE_DEBUG_PREFIX) ||
54
56
  traceId.startsWith(MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX)
55
57
  })
56
58
 
57
- // Only proceed if there are filtered spans
58
59
  if (filteredSpans.length === 0) {
59
60
  resultCallback({ code: 0 })
60
61
  return
61
62
  }
62
63
 
63
- super.export(filteredSpans, resultCallback)
64
+ return super.export(filteredSpans, resultCallback)
64
65
  }
65
66
  }