@devskin/browser-sdk 1.0.35 → 1.0.37

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.
@@ -13423,15 +13423,20 @@ record.takeFullSnapshot = (isCheckout) => {
13423
13423
  record.mirror = mirror;
13424
13424
 
13425
13425
  class RRWebRecorder {
13426
- constructor(sessionId, config, onEventsReady) {
13426
+ constructor(sessionId, config, onEventsReady, sessionStartTime = 0) {
13427
13427
  this.stopFn = null;
13428
13428
  this.events = [];
13429
13429
  this.onEventsReady = null;
13430
13430
  this.flushInterval = null;
13431
13431
  this.hasFullSnapshot = false;
13432
+ this.sessionStartTime = 0; // Session start time (for relative timestamps)
13433
+ this.recordingStartTime = 0; // When this recorder instance started
13432
13434
  this.sessionId = sessionId;
13433
13435
  this.config = config;
13434
13436
  this.onEventsReady = onEventsReady;
13437
+ this.sessionStartTime = sessionStartTime || Date.now();
13438
+ this.recordingStartTime = Date.now();
13439
+ console.log(`[RRWeb] Recording initialized - session started at ${this.sessionStartTime}, recording started at ${this.recordingStartTime}`);
13435
13440
  }
13436
13441
  start() {
13437
13442
  if (!this.config.enabled) {
@@ -13445,6 +13450,13 @@ class RRWebRecorder {
13445
13450
  try {
13446
13451
  this.stopFn = record({
13447
13452
  emit: (event) => {
13453
+ // Convert absolute timestamps to relative to session start
13454
+ // This ensures continuity across page navigations within same session
13455
+ const originalTimestamp = event.timestamp;
13456
+ event.timestamp = event.timestamp - this.sessionStartTime;
13457
+ if (this.config.enabled && event.type === 2) {
13458
+ console.log(`[RRWeb] FullSnapshot - original: ${originalTimestamp}, relative: ${event.timestamp}, session start: ${this.sessionStartTime}`);
13459
+ }
13448
13460
  this.events.push(event);
13449
13461
  // Check if this is a FullSnapshot (type 2)
13450
13462
  if (event.type === 2) {
@@ -13923,13 +13935,15 @@ class DevSkinSDK {
13923
13935
  this.heatmapCollector.start();
13924
13936
  // Initialize screenshot collector and capture page
13925
13937
  this.screenshotCollector = new ScreenshotCollector(this.config, this.transport);
13926
- this.screenshotCollector.captureAndSend(this.sessionId, window.location.href);
13938
+ // Send only the pathname (not full URL) for consistent hashing
13939
+ this.screenshotCollector.captureAndSend(this.sessionId, window.location.pathname);
13927
13940
  if (this.config.debug) {
13928
13941
  console.log('[DevSkin] Heatmap collection enabled (always on)');
13929
13942
  }
13930
13943
  // Initialize session recording with rrweb
13931
13944
  if ((_a = this.config.sessionRecording) === null || _a === void 0 ? void 0 : _a.enabled) {
13932
13945
  // Use RRWebRecorder for complete DOM recording
13946
+ // Pass sessionStartTime to ensure timestamp continuity across page navigations
13933
13947
  this.rrwebRecorder = new RRWebRecorder(this.sessionId, {
13934
13948
  enabled: true,
13935
13949
  sampleRate: this.config.sessionRecording.sampling || 0.5,
@@ -13952,7 +13966,8 @@ class DevSkinSDK {
13952
13966
  var _a;
13953
13967
  // Send rrweb events to backend
13954
13968
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.sendRecordingEvents(this.sessionId, events);
13955
- });
13969
+ }, this.sessionStartTime // Pass session start time for timestamp continuity
13970
+ );
13956
13971
  // Start recording immediately (session already created)
13957
13972
  this.rrwebRecorder.start();
13958
13973
  if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debug) {