@temps-sdk/react-analytics 0.0.1-beta.34 → 0.0.1-beta.35
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,QA+dtB"}
|
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,
|
|
@@ -329,6 +328,9 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
329
328
|
});
|
|
330
329
|
if (stopFn) {
|
|
331
330
|
stopFnRef.current = stopFn;
|
|
331
|
+
// Store the takeFullSnapshot function from rrweb
|
|
332
|
+
// The record function returns an object with both stop and takeFullSnapshot methods
|
|
333
|
+
takeSnapshotRef.current = stopFn.takeFullSnapshot || null;
|
|
332
334
|
}
|
|
333
335
|
// Start the flush interval
|
|
334
336
|
scheduleFlush();
|
|
@@ -430,8 +432,15 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
430
432
|
sendEvents(false);
|
|
431
433
|
}
|
|
432
434
|
originalPushState.apply(window.history, args);
|
|
433
|
-
// Use setTimeout to allow DOM updates to complete
|
|
434
|
-
setTimeout(
|
|
435
|
+
// Use setTimeout to allow DOM updates to complete, then take snapshot
|
|
436
|
+
setTimeout(() => {
|
|
437
|
+
checkPathAndToggleRecording();
|
|
438
|
+
// Force a full snapshot after route change to capture new page state
|
|
439
|
+
// This ensures the replay shows the correct content after navigation
|
|
440
|
+
if (takeSnapshotRef.current) {
|
|
441
|
+
takeSnapshotRef.current();
|
|
442
|
+
}
|
|
443
|
+
}, 100); // Small delay to ensure DOM is updated
|
|
435
444
|
};
|
|
436
445
|
window.history.replaceState = function (...args) {
|
|
437
446
|
// Flush current events before route change to ensure they're captured
|
|
@@ -439,16 +448,30 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
|
|
|
439
448
|
sendEvents(false);
|
|
440
449
|
}
|
|
441
450
|
originalReplaceState.apply(window.history, args);
|
|
442
|
-
// Use setTimeout to allow DOM updates to complete
|
|
443
|
-
setTimeout(
|
|
451
|
+
// Use setTimeout to allow DOM updates to complete, then take snapshot
|
|
452
|
+
setTimeout(() => {
|
|
453
|
+
checkPathAndToggleRecording();
|
|
454
|
+
// Force a full snapshot after route change to capture new page state
|
|
455
|
+
// This ensures the replay shows the correct content after navigation
|
|
456
|
+
if (takeSnapshotRef.current) {
|
|
457
|
+
takeSnapshotRef.current();
|
|
458
|
+
}
|
|
459
|
+
}, 100); // Small delay to ensure DOM is updated
|
|
444
460
|
};
|
|
445
461
|
const handlePopState = () => {
|
|
446
462
|
// Flush current events before route change to ensure they're captured
|
|
447
463
|
if (stopFnRef.current && eventsRef.current.length > 0) {
|
|
448
464
|
sendEvents(false);
|
|
449
465
|
}
|
|
450
|
-
// Use setTimeout to allow DOM updates to complete
|
|
451
|
-
setTimeout(
|
|
466
|
+
// Use setTimeout to allow DOM updates to complete, then take snapshot
|
|
467
|
+
setTimeout(() => {
|
|
468
|
+
checkPathAndToggleRecording();
|
|
469
|
+
// Force a full snapshot after route change to capture new page state
|
|
470
|
+
// This ensures the replay shows the correct content after navigation
|
|
471
|
+
if (takeSnapshotRef.current) {
|
|
472
|
+
takeSnapshotRef.current();
|
|
473
|
+
}
|
|
474
|
+
}, 100); // Small delay to ensure DOM is updated
|
|
452
475
|
};
|
|
453
476
|
window.addEventListener("popstate", handlePopState);
|
|
454
477
|
return () => {
|