@devskin/browser-sdk 1.0.35 → 1.0.36

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.
@@ -13425,15 +13425,20 @@
13425
13425
  record.mirror = mirror;
13426
13426
 
13427
13427
  class RRWebRecorder {
13428
- constructor(sessionId, config, onEventsReady) {
13428
+ constructor(sessionId, config, onEventsReady, sessionStartTime = 0) {
13429
13429
  this.stopFn = null;
13430
13430
  this.events = [];
13431
13431
  this.onEventsReady = null;
13432
13432
  this.flushInterval = null;
13433
13433
  this.hasFullSnapshot = false;
13434
+ this.sessionStartTime = 0; // Session start time (for relative timestamps)
13435
+ this.recordingStartTime = 0; // When this recorder instance started
13434
13436
  this.sessionId = sessionId;
13435
13437
  this.config = config;
13436
13438
  this.onEventsReady = onEventsReady;
13439
+ this.sessionStartTime = sessionStartTime || Date.now();
13440
+ this.recordingStartTime = Date.now();
13441
+ console.log(`[RRWeb] Recording initialized - session started at ${this.sessionStartTime}, recording started at ${this.recordingStartTime}`);
13437
13442
  }
13438
13443
  start() {
13439
13444
  if (!this.config.enabled) {
@@ -13447,6 +13452,13 @@
13447
13452
  try {
13448
13453
  this.stopFn = record({
13449
13454
  emit: (event) => {
13455
+ // Convert absolute timestamps to relative to session start
13456
+ // This ensures continuity across page navigations within same session
13457
+ const originalTimestamp = event.timestamp;
13458
+ event.timestamp = event.timestamp - this.sessionStartTime;
13459
+ if (this.config.enabled && event.type === 2) {
13460
+ console.log(`[RRWeb] FullSnapshot - original: ${originalTimestamp}, relative: ${event.timestamp}, session start: ${this.sessionStartTime}`);
13461
+ }
13450
13462
  this.events.push(event);
13451
13463
  // Check if this is a FullSnapshot (type 2)
13452
13464
  if (event.type === 2) {
@@ -13932,6 +13944,7 @@
13932
13944
  // Initialize session recording with rrweb
13933
13945
  if ((_a = this.config.sessionRecording) === null || _a === void 0 ? void 0 : _a.enabled) {
13934
13946
  // Use RRWebRecorder for complete DOM recording
13947
+ // Pass sessionStartTime to ensure timestamp continuity across page navigations
13935
13948
  this.rrwebRecorder = new RRWebRecorder(this.sessionId, {
13936
13949
  enabled: true,
13937
13950
  sampleRate: this.config.sessionRecording.sampling || 0.5,
@@ -13954,7 +13967,8 @@
13954
13967
  var _a;
13955
13968
  // Send rrweb events to backend
13956
13969
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.sendRecordingEvents(this.sessionId, events);
13957
- });
13970
+ }, this.sessionStartTime // Pass session start time for timestamp continuity
13971
+ );
13958
13972
  // Start recording immediately (session already created)
13959
13973
  this.rrwebRecorder.start();
13960
13974
  if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debug) {