@faststats/web 0.8.0 → 0.8.1
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/dist/error.js +1 -1
- package/dist/replay.d.ts +2 -0
- package/dist/replay.js +32 -2
- package/package.json +1 -1
package/dist/error.js
CHANGED
|
@@ -3,7 +3,7 @@ import { r as getSessionContext, t as sendData } from "./chunks/send-data-DFZnsa
|
|
|
3
3
|
import { t as getAnonymousId } from "./chunks/identifiers-KgQDX74Q.js";
|
|
4
4
|
//#region src/error.ts
|
|
5
5
|
const SDK_NAME = "@faststats/web";
|
|
6
|
-
const SDK_VERSION = "0.8.
|
|
6
|
+
const SDK_VERSION = "0.8.1";
|
|
7
7
|
function errorTracking(options = {}) {
|
|
8
8
|
return {
|
|
9
9
|
name: "error-tracking",
|
package/dist/replay.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ declare class ReplayTracker {
|
|
|
78
78
|
private retryAttempt;
|
|
79
79
|
private minLengthFlushTask;
|
|
80
80
|
private stopRecording?;
|
|
81
|
+
private activeSessionId;
|
|
81
82
|
private sending;
|
|
82
83
|
private inFlightBatch;
|
|
83
84
|
private queuedFlush;
|
|
@@ -105,6 +106,7 @@ declare class ReplayTracker {
|
|
|
105
106
|
private onSessionRotated;
|
|
106
107
|
private subscribeToSessionRotation;
|
|
107
108
|
private applySessionRotation;
|
|
109
|
+
private beginReplayStream;
|
|
108
110
|
private resetSessionTiming;
|
|
109
111
|
private onEvent;
|
|
110
112
|
private onUnload;
|
package/dist/replay.js
CHANGED
|
@@ -115,6 +115,7 @@ var ReplayTracker = class {
|
|
|
115
115
|
retryAttempt = 0;
|
|
116
116
|
minLengthFlushTask = null;
|
|
117
117
|
stopRecording;
|
|
118
|
+
activeSessionId = "";
|
|
118
119
|
sending = false;
|
|
119
120
|
inFlightBatch = null;
|
|
120
121
|
queuedFlush = null;
|
|
@@ -192,8 +193,11 @@ var ReplayTracker = class {
|
|
|
192
193
|
if (this.started) this.subscribeToSessionRotation();
|
|
193
194
|
this.clearQueues();
|
|
194
195
|
this.clearFlushTimers();
|
|
195
|
-
|
|
196
|
+
const context = getSessionContext(this.options.siteKey, this.lastCookielessMode);
|
|
197
|
+
this.activeSessionId = context.sessionId;
|
|
198
|
+
this.startTime = context.sessionStart;
|
|
196
199
|
this.chunkStartedAt = Date.now();
|
|
200
|
+
this.beginReplayStream();
|
|
197
201
|
}
|
|
198
202
|
start() {
|
|
199
203
|
if (this.started || typeof window === "undefined") return;
|
|
@@ -201,9 +205,12 @@ var ReplayTracker = class {
|
|
|
201
205
|
this.disposed = false;
|
|
202
206
|
this.terminalFlushRequested = false;
|
|
203
207
|
this.overflowed = false;
|
|
208
|
+
this.replayEventSequence = 0;
|
|
204
209
|
this.viewId = createId();
|
|
205
210
|
this.viewUrl = sanitizeUrl(window.location.href, this.options.trackHash ?? false);
|
|
206
|
-
|
|
211
|
+
const context = getSessionContext(this.options.siteKey, this.lastCookielessMode);
|
|
212
|
+
this.activeSessionId = context.sessionId;
|
|
213
|
+
this.startTime = context.sessionStart;
|
|
207
214
|
this.chunkStartedAt = Date.now();
|
|
208
215
|
this.subscribeToSessionRotation();
|
|
209
216
|
this.beginRecording();
|
|
@@ -328,13 +335,36 @@ var ReplayTracker = class {
|
|
|
328
335
|
this.unsubscribeRotation = onSessionRotated(this.options.siteKey, this.lastCookielessMode, (prev, next) => this.onSessionRotated(prev, next));
|
|
329
336
|
}
|
|
330
337
|
applySessionRotation(prev, next) {
|
|
338
|
+
if (this.activeSessionId === next.sessionId) return;
|
|
331
339
|
this.enqueueEventsIfReady(prev, {
|
|
332
340
|
isFinal: true,
|
|
333
341
|
flushReason: "sessionRotate"
|
|
334
342
|
});
|
|
335
343
|
this.finalizeSessionPending(prev, "sessionRotate");
|
|
336
344
|
this.unblockSessionBatches(prev.sessionId);
|
|
345
|
+
this.activeSessionId = next.sessionId;
|
|
337
346
|
this.resetSessionTiming(next);
|
|
347
|
+
this.beginReplayStream();
|
|
348
|
+
}
|
|
349
|
+
beginReplayStream() {
|
|
350
|
+
this.replayEventSequence = 0;
|
|
351
|
+
const stopRecording = this.stopRecording;
|
|
352
|
+
if (!stopRecording) return;
|
|
353
|
+
try {
|
|
354
|
+
record.takeFullSnapshot(true);
|
|
355
|
+
} catch (snapshotError) {
|
|
356
|
+
this.stopRecording = void 0;
|
|
357
|
+
try {
|
|
358
|
+
stopRecording();
|
|
359
|
+
this.replayEventSequence = 0;
|
|
360
|
+
this.beginRecording();
|
|
361
|
+
} catch (restartError) {
|
|
362
|
+
this.log("Failed to restart replay stream", {
|
|
363
|
+
snapshotError,
|
|
364
|
+
restartError
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
338
368
|
}
|
|
339
369
|
resetSessionTiming(next) {
|
|
340
370
|
if (this.minLengthFlushTask) clearTimeout(this.minLengthFlushTask);
|