@multiplayer-app/session-recorder-browser 2.0.38 → 2.0.39

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.umd.js CHANGED
@@ -24436,7 +24436,7 @@ const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
24436
24436
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
24437
24437
  const REMOTE_SESSION_RECORDING_START = 'remote-session-recording:start';
24438
24438
  const REMOTE_SESSION_RECORDING_STOP = 'remote-session-recording:stop';
24439
- const PACKAGE_VERSION_EXPORT = "2.0.38" || 0;
24439
+ const PACKAGE_VERSION_EXPORT = "2.0.39" || 0;
24440
24440
  // Regex patterns for OpenTelemetry ignore URLs
24441
24441
  const OTEL_IGNORE_URLS = [
24442
24442
  // Traces endpoint
@@ -26144,6 +26144,7 @@ if (typeof XMLHttpRequest !== 'undefined') {
26144
26144
 
26145
26145
  class RecorderBrowserSDK {
26146
26146
  constructor() {
26147
+ this.generation = 0;
26147
26148
  this.intervals = {
26148
26149
  restart: null,
26149
26150
  bufferSnapshot: null,
@@ -26179,12 +26180,15 @@ class RecorderBrowserSDK {
26179
26180
  throw new Error('Configuration not initialized. Call init() before start().');
26180
26181
  }
26181
26182
  this.startedAt = new Date().toISOString();
26183
+ const gen = ++this.generation;
26182
26184
  this.stopFn = (0,rrweb__WEBPACK_IMPORTED_MODULE_6__.record)({
26183
26185
  ...this._buildRecordOptions(),
26184
26186
  emit: async (event) => {
26187
+ if (gen !== this.generation)
26188
+ return;
26185
26189
  const ts = event.timestamp;
26186
26190
  if (!sessionId) {
26187
- await this._handleBufferOnlyEvent(event, ts);
26191
+ await this._handleBufferOnlyEvent(event, ts, gen);
26188
26192
  return;
26189
26193
  }
26190
26194
  this._handleLiveSessionEvent(event, ts, sessionId, sessionType);
@@ -26200,6 +26204,7 @@ class RecorderBrowserSDK {
26200
26204
  var _a;
26201
26205
  try {
26202
26206
  (_a = this.stopFn) === null || _a === void 0 ? void 0 : _a.call(this);
26207
+ this.stopFn = undefined;
26203
26208
  this.start(sessionId, sessionType);
26204
26209
  }
26205
26210
  catch (_e) {
@@ -26213,6 +26218,7 @@ class RecorderBrowserSDK {
26213
26218
  var _a, _b, _c;
26214
26219
  (_a = this.stopFn) === null || _a === void 0 ? void 0 : _a.call(this);
26215
26220
  this.stopFn = undefined;
26221
+ this.generation++;
26216
26222
  if (!((_b = this.config) === null || _b === void 0 ? void 0 : _b.useWebsocket)) {
26217
26223
  (_c = this.socketService) === null || _c === void 0 ? void 0 : _c.close();
26218
26224
  }
@@ -26252,13 +26258,15 @@ class RecorderBrowserSDK {
26252
26258
  * @param event - Event.
26253
26259
  * @param ts - Timestamp.
26254
26260
  */
26255
- async _handleBufferOnlyEvent(event, ts) {
26261
+ async _handleBufferOnlyEvent(event, ts, gen) {
26256
26262
  if (!this.crashBuffer)
26257
26263
  return;
26258
26264
  try {
26259
26265
  this._applyConsoleMasking(event);
26260
26266
  const packedEvent = (0,_rrweb_packer__WEBPACK_IMPORTED_MODULE_0__.pack)(event);
26261
26267
  this.stoppedAt = new Date(ts).toISOString();
26268
+ if (gen !== this.generation)
26269
+ return;
26262
26270
  await this.crashBuffer.appendEvent({
26263
26271
  ts,
26264
26272
  isFullSnapshot: event.type === _rrweb_types__WEBPACK_IMPORTED_MODULE_1__.EventType.FullSnapshot,
@@ -28206,7 +28214,11 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
28206
28214
  this._tracer.stop();
28207
28215
  this._recorder.stop();
28208
28216
  this._navigationRecorder.stop();
28209
- this._startBufferOnlyRecording();
28217
+ // rrweb assigns new node IDs on each record() call, so the next buffer
28218
+ // segment must not carry events from the previous generation. Await the
28219
+ // clear so its IDB tx can't race past the fresh FullSnapshot.
28220
+ const cleared = this._crashBuffer ? this._crashBuffer.clear() : Promise.resolve();
28221
+ void cleared.catch(() => undefined).then(() => this._startBufferOnlyRecording());
28210
28222
  }
28211
28223
  /**
28212
28224
  * Pause the session tracing and recording