@logspace/sdk 1.1.2 → 1.1.6
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.
- package/logspace.esm.js +28 -4
- package/logspace.esm.js.map +1 -1
- package/logspace.iife.js +1 -1
- package/logspace.iife.js.map +1 -1
- package/logspace.umd.js +1 -1
- package/logspace.umd.js.map +1 -1
- package/package.json +1 -1
- package/sdk/types.d.ts +2 -2
package/logspace.esm.js
CHANGED
|
@@ -14588,8 +14588,8 @@ const DEFAULT_CONFIG = {
|
|
|
14588
14588
|
},
|
|
14589
14589
|
limits: {
|
|
14590
14590
|
maxLogs: 1e4,
|
|
14591
|
-
maxSize:
|
|
14592
|
-
//
|
|
14591
|
+
maxSize: 50 * 1024 * 1024,
|
|
14592
|
+
// 50MB
|
|
14593
14593
|
maxDuration: 1800,
|
|
14594
14594
|
// 30 minutes
|
|
14595
14595
|
idleTimeout: 120,
|
|
@@ -15497,13 +15497,21 @@ async function sendPayload(payload) {
|
|
|
15497
15497
|
const type = log.type || "unknown";
|
|
15498
15498
|
logsByType[type] = (logsByType[type] || 0) + 1;
|
|
15499
15499
|
}
|
|
15500
|
+
let rrwebDuration = payload.duration;
|
|
15501
|
+
if (payload.rrwebEvents && payload.rrwebEvents.length > 0) {
|
|
15502
|
+
const timestamps = payload.rrwebEvents.map((e) => e.timestamp);
|
|
15503
|
+
const minTs = Math.min(...timestamps);
|
|
15504
|
+
const maxTs = Math.max(...timestamps);
|
|
15505
|
+
rrwebDuration = maxTs - minTs;
|
|
15506
|
+
}
|
|
15500
15507
|
const metadata = {
|
|
15501
15508
|
totalLogs: payload.logs.length,
|
|
15502
15509
|
logsByType,
|
|
15503
15510
|
videoSize: 0,
|
|
15504
15511
|
// SDK uses rrweb, not video
|
|
15505
15512
|
videoType: "rrweb",
|
|
15506
|
-
videoDuration:
|
|
15513
|
+
videoDuration: rrwebDuration,
|
|
15514
|
+
// Use actual rrweb duration, not session wall-clock time
|
|
15507
15515
|
userAgent: payload.userAgent,
|
|
15508
15516
|
timestamp: payload.startTime,
|
|
15509
15517
|
// Use actual session start time for correct video seek calculation
|
|
@@ -15512,6 +15520,7 @@ async function sendPayload(payload) {
|
|
|
15512
15520
|
userId: payload.userId,
|
|
15513
15521
|
userTraits: payload.userTraits,
|
|
15514
15522
|
duration: payload.duration,
|
|
15523
|
+
// Keep session wall-clock duration for reference
|
|
15515
15524
|
stats: payload.stats
|
|
15516
15525
|
};
|
|
15517
15526
|
formData.append("log_metadata", JSON.stringify(metadata));
|
|
@@ -15565,12 +15574,20 @@ async function sendPayloadToServer(payload) {
|
|
|
15565
15574
|
const type = log.type || "unknown";
|
|
15566
15575
|
logsByType[type] = (logsByType[type] || 0) + 1;
|
|
15567
15576
|
}
|
|
15577
|
+
let rrwebDuration = payload.duration;
|
|
15578
|
+
if (payload.rrwebEvents && payload.rrwebEvents.length > 0) {
|
|
15579
|
+
const timestamps = payload.rrwebEvents.map((e) => e.timestamp);
|
|
15580
|
+
const minTs = Math.min(...timestamps);
|
|
15581
|
+
const maxTs = Math.max(...timestamps);
|
|
15582
|
+
rrwebDuration = maxTs - minTs;
|
|
15583
|
+
}
|
|
15568
15584
|
const metadata = {
|
|
15569
15585
|
totalLogs: payload.logs.length,
|
|
15570
15586
|
logsByType,
|
|
15571
15587
|
videoSize: 0,
|
|
15572
15588
|
videoType: "rrweb",
|
|
15573
|
-
videoDuration:
|
|
15589
|
+
videoDuration: rrwebDuration,
|
|
15590
|
+
// Use actual rrweb duration, not session wall-clock time
|
|
15574
15591
|
userAgent: payload.userAgent,
|
|
15575
15592
|
timestamp: payload.startTime,
|
|
15576
15593
|
// Use actual session start time for correct video seek calculation
|
|
@@ -15581,6 +15598,7 @@ async function sendPayloadToServer(payload) {
|
|
|
15581
15598
|
userId: payload.userId,
|
|
15582
15599
|
userTraits: payload.userTraits,
|
|
15583
15600
|
duration: payload.duration,
|
|
15601
|
+
// Keep session wall-clock duration for reference
|
|
15584
15602
|
stats: payload.stats
|
|
15585
15603
|
};
|
|
15586
15604
|
formData.append("log_metadata", JSON.stringify(metadata));
|
|
@@ -15670,6 +15688,12 @@ function mergeRecoveredData(recoveredLogs, recoveredEvents) {
|
|
|
15670
15688
|
for (const event of newEvents) {
|
|
15671
15689
|
rrwebSize += JSON.stringify(event).length;
|
|
15672
15690
|
}
|
|
15691
|
+
if (config?.sampling.enabled && samplingTrimTimer) {
|
|
15692
|
+
stopSamplingTrimTimer();
|
|
15693
|
+
if (config?.debug) {
|
|
15694
|
+
console.log("[LogSpace] Stopped sampling trim timer to preserve recovered rrweb events");
|
|
15695
|
+
}
|
|
15696
|
+
}
|
|
15673
15697
|
if (config?.debug) {
|
|
15674
15698
|
console.log(
|
|
15675
15699
|
`[LogSpace] Merged ${newEvents.length} recovered rrweb events (${recoveredEvents.length - newEvents.length} duplicates skipped)`
|