@temps-sdk/react-analytics 0.0.1-beta.34 → 0.0.1-beta.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.
|
@@ -13,9 +13,17 @@ interface SessionRecorderProps {
|
|
|
13
13
|
recordCanvas?: boolean;
|
|
14
14
|
collectFonts?: boolean;
|
|
15
15
|
slimDOMOptions?: Record<string, boolean>;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Number of events to batch before sending. Default: 500
|
|
18
|
+
* Events are sent when EITHER batchSize is reached OR flushInterval elapses (whichever comes first).
|
|
19
|
+
* Increased from 200 to reduce request frequency.
|
|
20
|
+
*/
|
|
17
21
|
batchSize?: number;
|
|
18
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Interval in milliseconds to flush events. Default: 60000 (60s)
|
|
24
|
+
* Events are sent when EITHER flushInterval elapses OR batchSize is reached (whichever comes first).
|
|
25
|
+
* Increased from 30s to reduce request frequency.
|
|
26
|
+
*/
|
|
19
27
|
flushInterval?: number;
|
|
20
28
|
ignoreSelector?: string;
|
|
21
29
|
blockSelector?: string;
|
|
@@ -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,CAA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AO,CAAC;YACtB,KAAK,CAAC,EAAE,OAAO,CAAC;YAChB,IAAI,CAAC,EAAE,OAAO,CAAC;YACf,UAAU,CAAC,EAAE,OAAO,CAAC;YACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,WAAW,CAAC,EAAE,OAAO,CAAC;YACtB,IAAI,CAAC,EAAE,OAAO,CAAC;YACf,KAAK,CAAC,EAAE,OAAO,CAAC;SACjB,CAAC;QACF,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QAC7B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;KACzB,CAAC;CACH;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,cAAgC,EAChC,aAAgC,EAChC,YAAoB,EACpB,YAAoB,EACpB,cAUC,EACD,SAAe,EACf,aAAqB,EACrB,QAAa,GACd,EAAE,oBAAoB,QA0dtB"}
|
package/dist/SessionRecorder.js
CHANGED
|
@@ -60,6 +60,7 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
60
60
|
const flushTimeoutRef = useRef(null);
|
|
61
61
|
const initRetryCountRef = useRef(0);
|
|
62
62
|
const initFailedRef = useRef(false); // Track if init has permanently failed
|
|
63
|
+
const takeSnapshotRef = useRef(null); // Function to force a full snapshot
|
|
63
64
|
const maxInitRetries = 3;
|
|
64
65
|
const [isInitializing, setIsInitializing] = useState(false);
|
|
65
66
|
// Deep merge sampling defaults with proper handling of mouseInteraction
|
|
@@ -264,22 +265,19 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
264
265
|
}
|
|
265
266
|
}, [basePath]);
|
|
266
267
|
const scheduleFlush = useCallback(() => {
|
|
268
|
+
// Clear any existing timeout
|
|
267
269
|
if (flushTimeoutRef.current) {
|
|
268
270
|
clearTimeout(flushTimeoutRef.current);
|
|
269
271
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
};
|
|
276
|
-
const scheduleNextFlush = () => {
|
|
277
|
-
if (flushTimeoutRef.current) {
|
|
278
|
-
clearTimeout(flushTimeoutRef.current);
|
|
272
|
+
// Schedule the next flush after the interval
|
|
273
|
+
flushTimeoutRef.current = setTimeout(() => {
|
|
274
|
+
// Only send if we have events
|
|
275
|
+
if (eventsRef.current.length > 0) {
|
|
276
|
+
sendEvents(false);
|
|
279
277
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
// Reschedule for the next interval
|
|
279
|
+
scheduleFlush();
|
|
280
|
+
}, flushInterval);
|
|
283
281
|
}, [sendEvents, flushInterval]);
|
|
284
282
|
const startRecording = useCallback(async () => {
|
|
285
283
|
if (stopFnRef.current)
|
|
@@ -304,10 +302,11 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
304
302
|
const stopFn = record({
|
|
305
303
|
emit(event) {
|
|
306
304
|
eventsRef.current.push(event);
|
|
307
|
-
// Send when we have accumulated a full batch
|
|
305
|
+
// Send when we have accumulated a full batch (whichever comes first: time or size)
|
|
308
306
|
if (eventsRef.current.length >= batchSize) {
|
|
309
307
|
sendEvents(false);
|
|
310
|
-
//
|
|
308
|
+
// Reset the flush timer since we just sent
|
|
309
|
+
scheduleFlush();
|
|
311
310
|
}
|
|
312
311
|
},
|
|
313
312
|
sampling: samplingConfig,
|
|
@@ -321,14 +320,12 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
321
320
|
ignoreClass,
|
|
322
321
|
maskTextClass,
|
|
323
322
|
slimDOMOptions,
|
|
324
|
-
// Add checkoutEveryNms to force periodic full snapshots
|
|
325
|
-
// This helps with route changes by ensuring we get fresh snapshots
|
|
326
|
-
checkoutEveryNms: 60000, // Take a full snapshot every minute
|
|
327
|
-
// Add recordCrossOriginIframes for better iframe support
|
|
328
|
-
recordCrossOriginIframes: false,
|
|
329
323
|
});
|
|
330
324
|
if (stopFn) {
|
|
331
325
|
stopFnRef.current = stopFn;
|
|
326
|
+
// Store the takeFullSnapshot function from rrweb
|
|
327
|
+
// The record function returns an object with both stop and takeFullSnapshot methods
|
|
328
|
+
takeSnapshotRef.current = stopFn.takeFullSnapshot || null;
|
|
332
329
|
}
|
|
333
330
|
// Start the flush interval
|
|
334
331
|
scheduleFlush();
|
|
@@ -430,8 +427,15 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
430
427
|
sendEvents(false);
|
|
431
428
|
}
|
|
432
429
|
originalPushState.apply(window.history, args);
|
|
433
|
-
// Use setTimeout to allow DOM updates to complete
|
|
434
|
-
setTimeout(
|
|
430
|
+
// Use setTimeout to allow DOM updates to complete, then take snapshot
|
|
431
|
+
setTimeout(() => {
|
|
432
|
+
checkPathAndToggleRecording();
|
|
433
|
+
// Force a full snapshot after route change to capture new page state
|
|
434
|
+
// This ensures the replay shows the correct content after navigation
|
|
435
|
+
if (takeSnapshotRef.current) {
|
|
436
|
+
takeSnapshotRef.current();
|
|
437
|
+
}
|
|
438
|
+
}, 100); // Small delay to ensure DOM is updated
|
|
435
439
|
};
|
|
436
440
|
window.history.replaceState = function (...args) {
|
|
437
441
|
// Flush current events before route change to ensure they're captured
|
|
@@ -439,16 +443,30 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
439
443
|
sendEvents(false);
|
|
440
444
|
}
|
|
441
445
|
originalReplaceState.apply(window.history, args);
|
|
442
|
-
// Use setTimeout to allow DOM updates to complete
|
|
443
|
-
setTimeout(
|
|
446
|
+
// Use setTimeout to allow DOM updates to complete, then take snapshot
|
|
447
|
+
setTimeout(() => {
|
|
448
|
+
checkPathAndToggleRecording();
|
|
449
|
+
// Force a full snapshot after route change to capture new page state
|
|
450
|
+
// This ensures the replay shows the correct content after navigation
|
|
451
|
+
if (takeSnapshotRef.current) {
|
|
452
|
+
takeSnapshotRef.current();
|
|
453
|
+
}
|
|
454
|
+
}, 100); // Small delay to ensure DOM is updated
|
|
444
455
|
};
|
|
445
456
|
const handlePopState = () => {
|
|
446
457
|
// Flush current events before route change to ensure they're captured
|
|
447
458
|
if (stopFnRef.current && eventsRef.current.length > 0) {
|
|
448
459
|
sendEvents(false);
|
|
449
460
|
}
|
|
450
|
-
// Use setTimeout to allow DOM updates to complete
|
|
451
|
-
setTimeout(
|
|
461
|
+
// Use setTimeout to allow DOM updates to complete, then take snapshot
|
|
462
|
+
setTimeout(() => {
|
|
463
|
+
checkPathAndToggleRecording();
|
|
464
|
+
// Force a full snapshot after route change to capture new page state
|
|
465
|
+
// This ensures the replay shows the correct content after navigation
|
|
466
|
+
if (takeSnapshotRef.current) {
|
|
467
|
+
takeSnapshotRef.current();
|
|
468
|
+
}
|
|
469
|
+
}, 100); // Small delay to ensure DOM is updated
|
|
452
470
|
};
|
|
453
471
|
window.addEventListener("popstate", handlePopState);
|
|
454
472
|
return () => {
|