@multiplayer-app/session-recorder-browser 1.3.22 → 1.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24152,7 +24152,7 @@ const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
24152
24152
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
24153
24153
  const REMOTE_SESSION_RECORDING_START = 'remote-session-recording:start';
24154
24154
  const REMOTE_SESSION_RECORDING_STOP = 'remote-session-recording:stop';
24155
- const PACKAGE_VERSION_EXPORT = "1.3.22" || 0;
24155
+ const PACKAGE_VERSION_EXPORT = "1.3.24" || 0;
24156
24156
  // Regex patterns for OpenTelemetry ignore URLs
24157
24157
  const OTEL_IGNORE_URLS = [
24158
24158
  // Traces endpoint
@@ -24840,8 +24840,8 @@ class CrashBufferSpanProcessor {
24840
24840
  this._crashBuffer.appendSpans([
24841
24841
  {
24842
24842
  ts: span.startTime[0] * 1000 + span.startTime[1] / 1000000,
24843
- span: this._serializeSpan(span)
24844
- }
24843
+ span: this._serializeSpan(span),
24844
+ },
24845
24845
  ]);
24846
24846
  }
24847
24847
  return;
@@ -25118,13 +25118,14 @@ const getElementTextContent = (element) => {
25118
25118
 
25119
25119
 
25120
25120
 
25121
+ const clientIdGenerator = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderSdk.getIdGenerator(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.MULTIPLAYER_TRACE_CLIENT_ID_LENGTH);
25121
25122
  class TracerBrowserSDK {
25122
25123
  constructor() {
25123
25124
  this.clientId = '';
25124
25125
  this.sessionId = '';
25125
25126
  this.globalErrorListenersRegistered = false;
25126
25127
  }
25127
- setSessionId(sessionId, sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionType.MANUAL) {
25128
+ _setSessionId(sessionId, sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionType.MANUAL) {
25128
25129
  this.sessionId = sessionId;
25129
25130
  if (!this.idGenerator) {
25130
25131
  throw new Error('Id generator not initialized');
@@ -25133,32 +25134,32 @@ class TracerBrowserSDK {
25133
25134
  }
25134
25135
  init(options) {
25135
25136
  this.config = options;
25136
- this.clientId = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderSdk.getIdGenerator(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.MULTIPLAYER_TRACE_CLIENT_ID_LENGTH)();
25137
+ this.clientId = clientIdGenerator();
25137
25138
  const { application, version, environment } = this.config;
25138
25139
  this.idGenerator = new _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderIdGenerator();
25139
- this.setSessionId('', _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionType.SESSION_CACHE);
25140
+ this._setSessionId('', _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionType.SESSION_CACHE);
25140
25141
  this.exporter = new _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderBrowserTraceExporter({
25141
25142
  apiKey: options.apiKey,
25142
25143
  url: (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getExporterEndpoint)(options.exporterEndpoint),
25143
- usePostMessageFallback: options.usePostMessageFallback
25144
+ usePostMessageFallback: options.usePostMessageFallback,
25144
25145
  });
25145
25146
  this.batchSpanProcessor = new _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_5__.BatchSpanProcessor(this.exporter);
25146
25147
  this.tracerProvider = new _opentelemetry_sdk_trace_web__WEBPACK_IMPORTED_MODULE_6__.WebTracerProvider({
25147
25148
  resource: (0,_opentelemetry_resources__WEBPACK_IMPORTED_MODULE_7__.resourceFromAttributes)({
25148
25149
  [_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_8__.SEMRESATTRS_SERVICE_NAME]: application,
25149
25150
  [_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_8__.SEMRESATTRS_SERVICE_VERSION]: version,
25150
- [_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_8__.SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: environment
25151
+ [_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_8__.SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: environment,
25151
25152
  }),
25152
25153
  idGenerator: this.idGenerator,
25153
25154
  sampler: new _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderTraceIdRatioBasedSampler(this.config.sampleTraceRatio),
25154
25155
  spanProcessors: [
25155
25156
  this._getSpanSessionIdProcessor(),
25156
- new _CrashBufferSpanProcessor__WEBPACK_IMPORTED_MODULE_4__.CrashBufferSpanProcessor(this.batchSpanProcessor, this.crashBuffer, this.exporter.serializeSpan.bind(this.exporter))
25157
- ]
25157
+ new _CrashBufferSpanProcessor__WEBPACK_IMPORTED_MODULE_4__.CrashBufferSpanProcessor(this.batchSpanProcessor, this.crashBuffer, this.exporter.serializeSpan.bind(this.exporter)),
25158
+ ],
25158
25159
  });
25159
25160
  this.tracerProvider.register({
25160
25161
  // contextManager: new ZoneContextManager(),
25161
- propagator: new _opentelemetry_core__WEBPACK_IMPORTED_MODULE_9__.W3CTraceContextPropagator()
25162
+ propagator: new _opentelemetry_core__WEBPACK_IMPORTED_MODULE_9__.W3CTraceContextPropagator(),
25162
25163
  });
25163
25164
  (0,_opentelemetry_instrumentation__WEBPACK_IMPORTED_MODULE_10__.registerInstrumentations)({
25164
25165
  tracerProvider: this.tracerProvider,
@@ -25186,7 +25187,7 @@ class TracerBrowserSDK {
25186
25187
  requestBody,
25187
25188
  responseBody,
25188
25189
  requestHeaders,
25189
- responseHeaders
25190
+ responseHeaders,
25190
25191
  };
25191
25192
  (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.processHttpPayload)(payload, this.config, span);
25192
25193
  }
@@ -25194,7 +25195,7 @@ class TracerBrowserSDK {
25194
25195
  // eslint-disable-next-line
25195
25196
  console.error('[MULTIPLAYER_SESSION_RECORDER] Failed to capture xml-http payload', error);
25196
25197
  }
25197
- }
25198
+ },
25198
25199
  },
25199
25200
  '@opentelemetry/instrumentation-fetch': {
25200
25201
  clearTimingResources: true,
@@ -25235,7 +25236,7 @@ class TracerBrowserSDK {
25235
25236
  requestBody,
25236
25237
  responseBody,
25237
25238
  requestHeaders,
25238
- responseHeaders
25239
+ responseHeaders,
25239
25240
  };
25240
25241
  (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.processHttpPayload)(payload, this.config, span);
25241
25242
  }
@@ -25243,7 +25244,7 @@ class TracerBrowserSDK {
25243
25244
  // eslint-disable-next-line
25244
25245
  console.error('[MULTIPLAYER_SESSION_RECORDER] Failed to capture fetch payload', error);
25245
25246
  }
25246
- }
25247
+ },
25247
25248
  },
25248
25249
  '@opentelemetry/instrumentation-user-interaction': {
25249
25250
  shouldPreventSpanCreation: (_event, element, span) => {
@@ -25256,10 +25257,10 @@ class TracerBrowserSDK {
25256
25257
  span.setAttribute(`target.attribute.${attribute.name}`, attribute.value);
25257
25258
  });
25258
25259
  return false;
25259
- }
25260
- }
25261
- })
25262
- ]
25260
+ },
25261
+ },
25262
+ }),
25263
+ ],
25263
25264
  });
25264
25265
  this._registerGlobalErrorListeners();
25265
25266
  }
@@ -25270,13 +25271,13 @@ class TracerBrowserSDK {
25270
25271
  if (!this.tracerProvider) {
25271
25272
  throw new Error('Configuration not initialized. Call init() before start().');
25272
25273
  }
25273
- this.setSessionId(sessionId, sessionType);
25274
+ this._setSessionId(sessionId, sessionType);
25274
25275
  }
25275
25276
  stop() {
25276
25277
  if (!this.tracerProvider) {
25277
25278
  throw new Error('Configuration not initialized. Call init() before start().');
25278
25279
  }
25279
- this.setSessionId('', _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionType.SESSION_CACHE);
25280
+ this._setSessionId('', _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionType.SESSION_CACHE);
25280
25281
  }
25281
25282
  setApiKey(apiKey) {
25282
25283
  if (!this.exporter) {
@@ -25284,6 +25285,14 @@ class TracerBrowserSDK {
25284
25285
  }
25285
25286
  this.exporter.setApiKey(apiKey);
25286
25287
  }
25288
+ async exportTraces(spans) {
25289
+ var _a;
25290
+ if ((_a = this === null || this === void 0 ? void 0 : this.batchSpanProcessor) === null || _a === void 0 ? void 0 : _a.onEnd) {
25291
+ spans.map((span) => { var _a; return (_a = this === null || this === void 0 ? void 0 : this.batchSpanProcessor) === null || _a === void 0 ? void 0 : _a.onEnd(span); });
25292
+ // return this.batchSpanProcessor.onEnd()
25293
+ }
25294
+ throw new Error('Buffer span processor not initialized');
25295
+ }
25287
25296
  /**
25288
25297
  * Capture an exception as an error span/event.
25289
25298
  * If there is an active span, the exception will be recorded on it.
@@ -25315,14 +25324,6 @@ class TracerBrowserSDK {
25315
25324
  }
25316
25325
  catch (_ignored) { }
25317
25326
  }
25318
- async exportTraces(spans) {
25319
- var _a;
25320
- if ((_a = this === null || this === void 0 ? void 0 : this.batchSpanProcessor) === null || _a === void 0 ? void 0 : _a.onEnd) {
25321
- spans.map((span) => { var _a; return (_a = this === null || this === void 0 ? void 0 : this.batchSpanProcessor) === null || _a === void 0 ? void 0 : _a.onEnd(span); });
25322
- // return this.batchSpanProcessor.onEnd()
25323
- }
25324
- throw new Error('Buffer span processor not initialized');
25325
- }
25326
25327
  _recordException(span, error, errorInfo) {
25327
25328
  span.recordException(error);
25328
25329
  span.setStatus({ code: _opentelemetry_api__WEBPACK_IMPORTED_MODULE_13__.SpanStatusCode.ERROR, message: error.message });
@@ -25345,7 +25346,7 @@ class TracerBrowserSDK {
25345
25346
  if ((_a = this.sessionId) === null || _a === void 0 ? void 0 : _a.length) {
25346
25347
  span.setAttribute(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.ATTR_MULTIPLAYER_SESSION_ID, this.sessionId);
25347
25348
  }
25348
- }
25349
+ },
25349
25350
  };
25350
25351
  }
25351
25352
  _registerGlobalErrorListeners() {
@@ -25803,7 +25804,7 @@ class RecorderBrowserSDK {
25803
25804
  constructor() {
25804
25805
  this.intervals = {
25805
25806
  restart: null,
25806
- bufferSnapshot: null
25807
+ bufferSnapshot: null,
25807
25808
  };
25808
25809
  this.startedAt = '';
25809
25810
  this.stoppedAt = '';
@@ -25845,7 +25846,7 @@ class RecorderBrowserSDK {
25845
25846
  return;
25846
25847
  }
25847
25848
  this._handleLiveSessionEvent(event, ts, sessionId, sessionType);
25848
- }
25849
+ },
25849
25850
  });
25850
25851
  this.takeFullSnapshot();
25851
25852
  this._setupPeriodicSnapshots(sessionId, sessionType);
@@ -25922,8 +25923,8 @@ class RecorderBrowserSDK {
25922
25923
  event: {
25923
25924
  event: packedEvent,
25924
25925
  eventType: event.type,
25925
- timestamp: ts
25926
- }
25926
+ timestamp: ts,
25927
+ },
25927
25928
  });
25928
25929
  }
25929
25930
  catch (error) {
@@ -25948,7 +25949,7 @@ class RecorderBrowserSDK {
25948
25949
  eventType: event.type,
25949
25950
  timestamp: ts,
25950
25951
  debugSessionId: sessionId,
25951
- debugSessionType: sessionType
25952
+ debugSessionType: sessionType,
25952
25953
  });
25953
25954
  }
25954
25955
  /**
@@ -25962,7 +25963,7 @@ class RecorderBrowserSDK {
25962
25963
  sampling: { canvas: 5 },
25963
25964
  recordCanvas: (_c = this.config) === null || _c === void 0 ? void 0 : _c.recordCanvas,
25964
25965
  dataURLOptions: { type: 'image/webp', quality: 0.1 },
25965
- plugins: [(0,_rrweb_rrweb_plugin_console_record__WEBPACK_IMPORTED_MODULE_3__.getRecordConsolePlugin)({ level: ['log', 'error'] })]
25966
+ plugins: [(0,_rrweb_rrweb_plugin_console_record__WEBPACK_IMPORTED_MODULE_3__.getRecordConsolePlugin)({ level: ['log', 'error'] })],
25966
25967
  };
25967
25968
  if (maskingConfig.maskInputOptions) {
25968
25969
  options.maskInputOptions = maskingConfig.maskInputOptions;
@@ -26022,7 +26023,7 @@ class ApiService {
26022
26023
  this.config = {
26023
26024
  apiKey: '',
26024
26025
  apiBaseUrl: '',
26025
- exporterEndpoint: ''
26026
+ exporterEndpoint: '',
26026
26027
  };
26027
26028
  }
26028
26029
  /**
@@ -26032,7 +26033,7 @@ class ApiService {
26032
26033
  init(config) {
26033
26034
  this.config = {
26034
26035
  ...this.config,
26035
- ...config
26036
+ ...config,
26036
26037
  };
26037
26038
  }
26038
26039
  /**
@@ -26126,14 +26127,14 @@ class ApiService {
26126
26127
  body: body ? JSON.stringify(body) : null,
26127
26128
  headers: {
26128
26129
  'Content-Type': 'application/json',
26129
- ...(this.config.apiKey && { 'X-Api-Key': this.config.apiKey })
26130
- }
26130
+ ...(this.config.apiKey && { 'X-Api-Key': this.config.apiKey }),
26131
+ },
26131
26132
  };
26132
26133
  try {
26133
26134
  const response = await fetch(url, {
26134
26135
  ...params,
26135
26136
  credentials: 'include',
26136
- signal
26137
+ signal,
26137
26138
  });
26138
26139
  if (!response.ok) {
26139
26140
  throw new Error('Network response was not ok: ' + response.statusText);
@@ -26206,7 +26207,7 @@ class CrashBufferService {
26206
26207
  await this._safe(async () => {
26207
26208
  await this.db.setAttrs({
26208
26209
  tabId: this.tabId,
26209
- ...attrs
26210
+ ...attrs,
26210
26211
  });
26211
26212
  }, undefined);
26212
26213
  }
@@ -26224,7 +26225,7 @@ class CrashBufferService {
26224
26225
  tabId: this.tabId,
26225
26226
  ts: payload.ts,
26226
26227
  isFullSnapshot: payload.isFullSnapshot,
26227
- event: payload.event
26228
+ event: payload.event,
26228
26229
  });
26229
26230
  }, undefined);
26230
26231
  if (isFullSnapshot && this.requiresFullSnapshot) {
@@ -26254,7 +26255,7 @@ class CrashBufferService {
26254
26255
  return {
26255
26256
  tabId: this.tabId,
26256
26257
  ts: p.ts,
26257
- span: p.span
26258
+ span: p.span,
26258
26259
  };
26259
26260
  });
26260
26261
  await this.db.appendSpans(records);
@@ -26303,7 +26304,7 @@ class CrashBufferService {
26303
26304
  const [rrweb, spans, attrs] = await Promise.all([
26304
26305
  this._safe(() => this.db.getRrwebEventsWindow(this.tabId, rrwebFromTs, toTs), []),
26305
26306
  this._safe(() => this.db.getOtelSpansWindow(this.tabId, fromTs, toTs), []),
26306
- this._safe(() => this.db.getAttrs(this.tabId), null)
26307
+ this._safe(() => this.db.getAttrs(this.tabId), null),
26307
26308
  ]);
26308
26309
  const rrwebSorted = rrweb
26309
26310
  .sort((a, b) => a.ts - b.ts)
@@ -26324,12 +26325,12 @@ class CrashBufferService {
26324
26325
  ? {
26325
26326
  sessionAttributes: attrs.sessionAttributes,
26326
26327
  resourceAttributes: attrs.resourceAttributes,
26327
- userAttributes: attrs.userAttributes
26328
+ userAttributes: attrs.userAttributes,
26328
26329
  }
26329
26330
  : null,
26330
26331
  windowMs: this.windowMs,
26331
26332
  fromTs: replayStartTs,
26332
- toTs
26333
+ toTs,
26333
26334
  };
26334
26335
  }
26335
26336
  async clear() {
@@ -26481,7 +26482,7 @@ class IndexedDBService {
26481
26482
  const db = await this.dbPromise;
26482
26483
  const payload = {
26483
26484
  ...attrs,
26484
- updatedAt: (_a = attrs.updatedAt) !== null && _a !== void 0 ? _a : Date.now()
26485
+ updatedAt: (_a = attrs.updatedAt) !== null && _a !== void 0 ? _a : Date.now(),
26485
26486
  };
26486
26487
  return new Promise((resolve, reject) => {
26487
26488
  const tx = db.transaction(attrsStore, 'readwrite');
@@ -26724,7 +26725,7 @@ class IndexedDBService {
26724
26725
  const r = attr.delete(tabId);
26725
26726
  r.onsuccess = () => res();
26726
26727
  r.onerror = () => rej(r.error);
26727
- })
26728
+ }),
26728
26729
  ])
26729
26730
  .then(() => {
26730
26731
  // noop
@@ -29971,13 +29972,13 @@ var SessionRecorderIdGenerator = /** @class */ (function () {
29971
29972
  this.generateShortId = (0,_sdk__WEBPACK_IMPORTED_MODULE_1__.getIdGenerator)(8);
29972
29973
  this.sessionShortId = '';
29973
29974
  this.clientId = '';
29974
- this.sessionType = _type__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL;
29975
+ this.sessionType;
29975
29976
  }
29976
29977
  SessionRecorderIdGenerator.prototype.generateTraceId = function () {
29977
29978
  var traceId = this.generateLongId();
29978
- if (!this.sessionShortId
29979
- && !this.sessionType
29980
- && !this.clientId) {
29979
+ if ((!this.sessionShortId
29980
+ && !this.clientId)
29981
+ || !this.sessionType) {
29981
29982
  return traceId;
29982
29983
  }
29983
29984
  var sessionTypePrefix = _constants_constants_base__WEBPACK_IMPORTED_MODULE_2__.MULTIPLAYER_TRACE_PREFIX_MAP[this.sessionType];
@@ -29989,7 +29990,6 @@ var SessionRecorderIdGenerator = /** @class */ (function () {
29989
29990
  return this.generateShortId();
29990
29991
  };
29991
29992
  SessionRecorderIdGenerator.prototype.setSessionId = function (sessionShortId, sessionType, clientId) {
29992
- if (sessionType === void 0) { sessionType = _type__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL; }
29993
29993
  if (clientId === void 0) { clientId = ''; }
29994
29994
  if (!clientId &&
29995
29995
  [
@@ -30349,7 +30349,7 @@ var SessionRecorderBrowserTraceExporter = /** @class */ (function () {
30349
30349
  window.postMessage({
30350
30350
  action: 'traces',
30351
30351
  type: this.postMessageType,
30352
- payload: spans.map(function (span) { return _this.serializeSpan(span); })
30352
+ payload: spans.map(function (span) { return _this.serializeSpan(span); }),
30353
30353
  }, this.postMessageTargetOrigin);
30354
30354
  resultCallback({ code: 0 });
30355
30355
  }
@@ -30367,7 +30367,7 @@ var SessionRecorderBrowserTraceExporter = /** @class */ (function () {
30367
30367
  headers: __assign(__assign({ 'Content-Type': 'application/json' }, (this.config.apiKey ? { Authorization: this.config.apiKey } : {})), (this.config.headers || {})),
30368
30368
  timeoutMillis: this.config.timeoutMillis,
30369
30369
  keepAlive: this.config.keepAlive,
30370
- concurrencyLimit: this.config.concurrencyLimit
30370
+ concurrencyLimit: this.config.concurrencyLimit,
30371
30371
  });
30372
30372
  };
30373
30373
  SessionRecorderBrowserTraceExporter.prototype.setApiKey = function (apiKey) {