@temps-sdk/react-analytics 0.0.1-beta.26 → 0.0.1-beta.27

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SessionRecorder.d.ts","sourceRoot":"","sources":["../src/SessionRecorder.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA2CD,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EAAG,uBAAuB;AAClC,MAAM,EACN,OAAe,EACf,aAAkB,EAClB,iBAAuB,EACvB,aAAoB,EACpB,gBAAgC,EAChC,UAAuB,EACvB,WAAyB,EACzB,aAAyB,EACzB,YAAoB,EACpB,YAAoB,EACpB,cAUC,EACD,SAAe,EACf,aAAqB,GACtB,EAAE,oBAAoB,QAoZtB"}
1
+ {"version":3,"file":"SessionRecorder.d.ts","sourceRoot":"","sources":["../src/SessionRecorder.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA2CD,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EAAG,uBAAuB;AAClC,MAAM,EACN,OAAe,EACf,aAAkB,EAClB,iBAAuB,EACvB,aAAoB,EACpB,gBAAgC,EAChC,UAAuB,EACvB,WAAyB,EACzB,aAAyB,EACzB,YAAoB,EACpB,YAAoB,EACpB,cAUC,EACD,SAAe,EACf,aAAqB,GACtB,EAAE,oBAAoB,QAmctB"}
@@ -275,7 +275,10 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
275
275
  console.error("[SessionRecorder] Failed to initialize session, not starting recording");
276
276
  return;
277
277
  }
278
- eventsRef.current = [];
278
+ // Don't clear events buffer on restart - preserve any pending events
279
+ if (!eventsRef.current) {
280
+ eventsRef.current = [];
281
+ }
279
282
  const stopFn = record({
280
283
  emit(event) {
281
284
  eventsRef.current.push(event);
@@ -288,7 +291,20 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
288
291
  sampling: {
289
292
  scroll: 150,
290
293
  media: 800,
291
- input: "last"
294
+ input: "last",
295
+ // Add mouse interactions sampling for better performance
296
+ mousemove: 50,
297
+ mouseInteraction: {
298
+ MouseUp: false,
299
+ MouseDown: false,
300
+ Click: false,
301
+ ContextMenu: false,
302
+ DblClick: false,
303
+ Focus: false,
304
+ Blur: false,
305
+ TouchStart: false,
306
+ TouchEnd: false,
307
+ },
292
308
  },
293
309
  blockSelector: "[data-private]",
294
310
  ignoreSelector: "[data-ignore]",
@@ -300,6 +316,11 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
300
316
  ignoreClass,
301
317
  maskTextClass,
302
318
  slimDOMOptions,
319
+ // Add checkoutEveryNms to force periodic full snapshots
320
+ // This helps with route changes by ensuring we get fresh snapshots
321
+ checkoutEveryNms: 60000, // Take a full snapshot every minute
322
+ // Add recordCrossOriginIframes for better iframe support
323
+ recordCrossOriginIframes: false,
303
324
  });
304
325
  if (stopFn) {
305
326
  stopFnRef.current = stopFn;
@@ -382,30 +403,54 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
382
403
  const regex = new RegExp(`^${path.replace(/\*/g, '.*')}$`);
383
404
  return regex.test(currentPath);
384
405
  });
385
- if (isExcluded && stopFnRef.current) {
406
+ // Only stop/start recording if we're actually changing exclusion status
407
+ // This prevents unnecessary restarts during normal navigation
408
+ const isCurrentlyRecording = stopFnRef.current !== null;
409
+ if (isExcluded && isCurrentlyRecording) {
410
+ // Path is excluded and we're recording - stop
386
411
  stopRecording();
387
412
  }
388
- else if (!isExcluded && !stopFnRef.current && !initFailedRef.current) {
413
+ else if (!isExcluded && !isCurrentlyRecording && !initFailedRef.current) {
414
+ // Path is not excluded and we're not recording - start
389
415
  startRecording();
390
416
  }
417
+ // If the path exclusion status hasn't changed, keep recording continuously
391
418
  };
392
419
  // Listen for route changes
393
420
  const originalPushState = window.history.pushState;
394
421
  const originalReplaceState = window.history.replaceState;
395
422
  window.history.pushState = function (...args) {
423
+ // Flush current events before route change to ensure they're captured
424
+ if (stopFnRef.current && eventsRef.current.length > 0) {
425
+ sendEvents(false);
426
+ }
396
427
  originalPushState.apply(window.history, args);
397
- checkPathAndToggleRecording();
428
+ // Use setTimeout to allow DOM updates to complete before checking
429
+ setTimeout(checkPathAndToggleRecording, 0);
398
430
  };
399
431
  window.history.replaceState = function (...args) {
432
+ // Flush current events before route change to ensure they're captured
433
+ if (stopFnRef.current && eventsRef.current.length > 0) {
434
+ sendEvents(false);
435
+ }
400
436
  originalReplaceState.apply(window.history, args);
401
- checkPathAndToggleRecording();
437
+ // Use setTimeout to allow DOM updates to complete before checking
438
+ setTimeout(checkPathAndToggleRecording, 0);
439
+ };
440
+ const handlePopState = () => {
441
+ // Flush current events before route change to ensure they're captured
442
+ if (stopFnRef.current && eventsRef.current.length > 0) {
443
+ sendEvents(false);
444
+ }
445
+ // Use setTimeout to allow DOM updates to complete before checking
446
+ setTimeout(checkPathAndToggleRecording, 0);
402
447
  };
403
- window.addEventListener("popstate", checkPathAndToggleRecording);
448
+ window.addEventListener("popstate", handlePopState);
404
449
  return () => {
405
450
  window.history.pushState = originalPushState;
406
451
  window.history.replaceState = originalReplaceState;
407
- window.removeEventListener("popstate", checkPathAndToggleRecording);
452
+ window.removeEventListener("popstate", handlePopState);
408
453
  };
409
- }, [enabled, excludedPaths, startRecording, stopRecording]);
454
+ }, [enabled, excludedPaths, startRecording, stopRecording, sendEvents]);
410
455
  return null;
411
456
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temps-sdk/react-analytics",
3
- "version": "0.0.1-beta.26",
3
+ "version": "0.0.1-beta.27",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",