@sprig-technologies/sprig-browser 2.36.1 → 2.37.0
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/{core-Bzv2KQOu.cjs → core-BRS09IB6.cjs} +2 -2
- package/dist/{core-BVtQnihE.js → core-Bm1eJsD-.js} +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +8 -0
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-M_tu1Yrx.js → metricsReporter-C-byY7_U.js} +1 -1
- package/dist/{metricsReporter-DbEyJSwA.cjs → metricsReporter-Hw5GZJnq.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +64 -62
- package/dist/view-C0FQQs2x.cjs +669 -0
- package/dist/{view-DJdeN4-t.js → view-dfp5ccm1.js} +1253 -1238
- package/package.json +1 -1
- package/dist/view-qqhfcMHd.cjs +0 -669
package/dist/replay.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var it = Object.defineProperty;
|
|
2
2
|
var dt = (e, t, n) => t in e ? it(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var F = (e, t, n) => dt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { b as d, s as Q, a as m, v as X, c as ct, g as
|
|
4
|
+
import { b as d, s as Q, a as m, v as X, c as ct, g as ut, P as ke, r as Ue, d as lt, e as V, S as Z, f as pt } from "./metricsReporter-C-byY7_U.js";
|
|
5
5
|
var B = ((e) => (e[e.DomContentLoaded = 0] = "DomContentLoaded", e[e.Load = 1] = "Load", e[e.FullSnapshot = 2] = "FullSnapshot", e[e.IncrementalSnapshot = 3] = "IncrementalSnapshot", e[e.Meta = 4] = "Meta", e[e.Custom = 5] = "Custom", e[e.Plugin = 6] = "Plugin", e))(B || {}), k = ((e) => (e[e.Mutation = 0] = "Mutation", e[e.MouseMove = 1] = "MouseMove", e[e.MouseInteraction = 2] = "MouseInteraction", e[e.Scroll = 3] = "Scroll", e[e.ViewportResize = 4] = "ViewportResize", e[e.Input = 5] = "Input", e[e.TouchMove = 6] = "TouchMove", e[e.MediaInteraction = 7] = "MediaInteraction", e[e.StyleSheetRule = 8] = "StyleSheetRule", e[e.CanvasMutation = 9] = "CanvasMutation", e[e.Font = 10] = "Font", e[e.Log = 11] = "Log", e[e.Drag = 12] = "Drag", e[e.StyleDeclaration = 13] = "StyleDeclaration", e[e.Selection = 14] = "Selection", e[e.AdoptedStyleSheet = 15] = "AdoptedStyleSheet", e[e.CustomElement = 16] = "CustomElement", e))(k || {});
|
|
6
6
|
const re = (e, t) => t.some((n) => e instanceof n);
|
|
7
7
|
let Se, De;
|
|
@@ -66,8 +66,8 @@ function be(e, t) {
|
|
|
66
66
|
if (!(n in (a ? IDBIndex : IDBObjectStore).prototype) || !r && !wt.includes(n)) return;
|
|
67
67
|
const o = async function(s, ...c) {
|
|
68
68
|
const i = this.transaction(s, r ? "readwrite" : "readonly");
|
|
69
|
-
let
|
|
70
|
-
return a && (
|
|
69
|
+
let u = i.store;
|
|
70
|
+
return a && (u = u.index(c.shift())), (await Promise.all([u[n](...c), r && i.done]))[0];
|
|
71
71
|
};
|
|
72
72
|
return ee.set(t, o), o;
|
|
73
73
|
}
|
|
@@ -119,8 +119,8 @@ const vt = "sprigReplayIframeLoaded", St = "sprigReplayIframeSettings", Dt = "sp
|
|
|
119
119
|
var y;
|
|
120
120
|
if (!i && !n && !a) return void d.error("UploadErr", { isMobile: i, uploadId: n, etags: a });
|
|
121
121
|
d.info("MarkUploadComplete", { surveyId: t });
|
|
122
|
-
const
|
|
123
|
-
return d.info("MarkUploadDone", { surveyId: t }),
|
|
122
|
+
const u = await Q(`${e}/sdk/1/completeSessionReplay`, { method: "POST", body: JSON.stringify({ etags: a, uploadId: n, responseGroupUuid: o, surveyId: t, replayDuration: s, eventDigest: c, userAgent: (y = window == null ? void 0 : window.navigator) == null ? void 0 : y.userAgent }), headers: r, shouldRetryRequest: !0 });
|
|
123
|
+
return d.info("MarkUploadDone", { surveyId: t }), u;
|
|
124
124
|
}, Et = (e) => {
|
|
125
125
|
if (e instanceof Attr) return null;
|
|
126
126
|
let t = 1;
|
|
@@ -206,7 +206,7 @@ const He = (e) => {
|
|
|
206
206
|
if (e) return d.info("SessionIDFound", { savedSessionId: e }), m.removeItem("sprig.sessionId"), e;
|
|
207
207
|
const t = X();
|
|
208
208
|
return d.info("GeneratedSessionID", { uuid: t }), t;
|
|
209
|
-
})(),
|
|
209
|
+
})(), ue = () => {
|
|
210
210
|
m.setItem("sprig.disableReplayRecording", "disabled");
|
|
211
211
|
}, T = () => !!m.getItem("sprig.disableReplayRecording"), z = () => !!m.getItem("sprig.isReplayPaused");
|
|
212
212
|
window.addEventListener("beforeunload", () => {
|
|
@@ -222,10 +222,10 @@ const U = (e, t) => {
|
|
|
222
222
|
}, Ut = async (e) => {
|
|
223
223
|
const { x: t, xPath: n, y: a } = e, r = g.scrollEventUuids[n];
|
|
224
224
|
if (r) return D(async () => {
|
|
225
|
-
var c, i,
|
|
226
|
-
const o = await
|
|
225
|
+
var c, i, u, y;
|
|
226
|
+
const o = await l.openDB(), s = await o.get("events", r);
|
|
227
227
|
if (s != null && s.event) {
|
|
228
|
-
const p = JSON.parse(s.event), h = t > ((i = (c = p.data) == null ? void 0 : c.payload) == null ? void 0 : i.x), w = a > ((y = (
|
|
228
|
+
const p = JSON.parse(s.event), h = t > ((i = (c = p.data) == null ? void 0 : c.payload) == null ? void 0 : i.x), w = a > ((y = (u = p.data) == null ? void 0 : u.payload) == null ? void 0 : y.y);
|
|
229
229
|
if (!h && !w) return null;
|
|
230
230
|
h && (p.data.payload.x = t), w && (p.data.payload.y = a), p.data.payload.elementAttributes = e.elementAttributes, s.event = JSON.stringify(p), await o.put("events", s);
|
|
231
231
|
} else U("Sprig_Scroll", e);
|
|
@@ -240,12 +240,12 @@ const U = (e, t) => {
|
|
|
240
240
|
});
|
|
241
241
|
}, xt = ["did not allow mutations", "called in an invalid security context"], Bt = (e, t, { reportError: n = !0, extraInfo: a = {} }) => {
|
|
242
242
|
if (!T() && t instanceof Error) {
|
|
243
|
-
if (
|
|
243
|
+
if (ue(), t.name === "VersionError") return d.error("VersionErr", { message: e }), void l.deleteDB();
|
|
244
244
|
((r) => {
|
|
245
245
|
if (!r) return !0;
|
|
246
246
|
for (const o of xt) if (r.toLowerCase().includes(o)) return !1;
|
|
247
247
|
return !0;
|
|
248
|
-
})(t == null ? void 0 : t.message) && (n && window.UserLeap.reportError(e, t, a),
|
|
248
|
+
})(t == null ? void 0 : t.message) && (n && window.UserLeap.reportError(e, t, a), l.clearAll());
|
|
249
249
|
}
|
|
250
250
|
}, H = (e, t, { reportError: n } = { reportError: !0 }) => {
|
|
251
251
|
Ge(), d.error("ReplayErr", { code: t.code, name: t.name }), Bt(e, t, { reportError: n });
|
|
@@ -255,7 +255,7 @@ const U = (e, t) => {
|
|
|
255
255
|
} catch (n) {
|
|
256
256
|
H(t, n);
|
|
257
257
|
}
|
|
258
|
-
},
|
|
258
|
+
}, le = () => {
|
|
259
259
|
g.isRecording && (D(() => {
|
|
260
260
|
var e, t;
|
|
261
261
|
return (t = (e = window.rrwebRecord) == null ? void 0 : e.takeFullSnapshot) == null ? void 0 : t.call(e, !0);
|
|
@@ -266,7 +266,7 @@ const U = (e, t) => {
|
|
|
266
266
|
};
|
|
267
267
|
let te = 0;
|
|
268
268
|
(async () => Ve() && Promise.allSettled([de("replayStorage"), de("sprig.replay")]))();
|
|
269
|
-
const
|
|
269
|
+
const l = new class {
|
|
270
270
|
constructor() {
|
|
271
271
|
F(this, "wrapTransactionWithCounter", (e) => {
|
|
272
272
|
var a, r;
|
|
@@ -290,7 +290,7 @@ const u = new class {
|
|
|
290
290
|
return a && (s.onupgradeneeded = (i) => {
|
|
291
291
|
a(M(s.result), i.oldVersion, i.newVersion, M(s.transaction), i);
|
|
292
292
|
}), n && (s.onblocked = (i) => n(i.oldVersion, i.newVersion, i)), c.then((i) => {
|
|
293
|
-
o && (i.onclose = () => o()), r && (i.onversionchange = (
|
|
293
|
+
o && (i.onclose = () => o()), r && (i.onversionchange = (u) => r(u.oldVersion, u.newVersion, u));
|
|
294
294
|
}).catch(() => {
|
|
295
295
|
}), c;
|
|
296
296
|
}("sprigReplay", 1, { upgrade: (e, t, n) => {
|
|
@@ -379,14 +379,16 @@ const u = new class {
|
|
|
379
379
|
await n.done;
|
|
380
380
|
}
|
|
381
381
|
}(), x = [];
|
|
382
|
-
let j, We,
|
|
383
|
-
const
|
|
384
|
-
|
|
382
|
+
let j, We, A = [], L = !1, N = 0, W = !1, $e = !1;
|
|
383
|
+
const Ie = [];
|
|
384
|
+
let q, Ke, $, Je, ne = !1;
|
|
385
|
+
const O = () => W && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, triggerSnapshot: n, forceInit: a = !1 }) => {
|
|
386
|
+
W && !a || (m.isStorageAvailable ? (A = [], Ie.splice(0), x.splice(0), N = 0, $ = n, We = e, j = { responseGroupUuid: t.responseGroupUuid, surveyId: t.surveyId, userAgent: t.userAgent, sdkVersion: t.sdkVersion }, Ke = t.maxDurationSeconds, Lt(), W || (Je = window.setInterval(Nt, 500)), W = !0) : L = !0);
|
|
385
387
|
}, _t = [k.Drag, k.Input, k.MediaInteraction, k.MouseInteraction, k.MouseMove, k.Scroll, k.Selection, k.TouchMove], At = (e) => e.type === B.Custom || e.type === B.IncrementalSnapshot && _t.includes(e.data.source), ve = (e) => e.some(At), Nt = async () => {
|
|
386
|
-
if (!O()) return void window.clearInterval(
|
|
388
|
+
if (!O()) return void window.clearInterval(Je);
|
|
387
389
|
if (ze(), !ve(x)) return;
|
|
388
390
|
const e = x[0].timestamp;
|
|
389
|
-
Date.now() - e > 35e3 && (
|
|
391
|
+
Date.now() - e > 35e3 && ($ == null || $());
|
|
390
392
|
}, ze = async () => {
|
|
391
393
|
if (A.length || ne) return;
|
|
392
394
|
ne = !0;
|
|
@@ -399,9 +401,9 @@ const O = () => $ && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
|
|
|
399
401
|
d.info("Read stored session state", e);
|
|
400
402
|
const t = JSON.parse(e);
|
|
401
403
|
L = t.disabled, j = t.metadata, A = t.uploadUrls, N = t.currentIndex, q = t.expirationTimestamp, t.pendingEventTimestamp && (d.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`), Ot(t.pendingEventTimestamp));
|
|
402
|
-
} else q = 1e3 *
|
|
404
|
+
} else q = 1e3 * Ke + Date.now();
|
|
403
405
|
}, Ot = async (e) => {
|
|
404
|
-
const t = Date.now(), n = (await
|
|
406
|
+
const t = Date.now(), n = (await l.getEventsBetween(e, t)).map((r) => JSON.parse(r.event));
|
|
405
407
|
if (!ve(n)) return;
|
|
406
408
|
Ze(n);
|
|
407
409
|
const a = await Xe();
|
|
@@ -425,7 +427,7 @@ const O = () => $ && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
|
|
|
425
427
|
if (!O()) return;
|
|
426
428
|
const { surveyId: e, responseGroupUuid: t } = j, n = { responseGroupUuid: t, surveyId: e, index: N + 1 };
|
|
427
429
|
d.info("Fetching always-on upload urls", n);
|
|
428
|
-
const a = await qe(() => Q(`${We}/sdk/1/replayUrls`, { method: "POST", body: JSON.stringify(n), headers:
|
|
430
|
+
const a = await qe(() => Q(`${We}/sdk/1/replayUrls`, { method: "POST", body: JSON.stringify(n), headers: ut(window.UserLeap) }), "fetching always-on signed urls");
|
|
429
431
|
if (!a) return;
|
|
430
432
|
const r = a.json.signedUrls;
|
|
431
433
|
return d.info("Fetched more always-on upload urls", { body: n, urls: r }), r;
|
|
@@ -440,7 +442,7 @@ const O = () => $ && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
|
|
|
440
442
|
const t = e.length ? e[e.length - 1].timestamp : Date.now(), n = N, a = ((o = (r = window.UserLeap) == null ? void 0 : r.config) == null ? void 0 : o.customMetadata) ?? ((s = window.__cfg) == null ? void 0 : s.customMetadata);
|
|
441
443
|
N++, e.push({ timestamp: t, type: B.Custom, data: { tag: "Sprig_Meta", payload: { ...j, index: n, visitorId: window.UserLeap.visitorId ?? "", timestamp: t, customMetadata: a } } });
|
|
442
444
|
}, Ht = (e, t) => {
|
|
443
|
-
O() &&
|
|
445
|
+
O() && !$e && (e || x.length) && (e && x.length && (async () => {
|
|
444
446
|
const n = x.splice(0);
|
|
445
447
|
if (!ve(n)) return;
|
|
446
448
|
d.info("Capturing always-on event array to upload"), Ze(n);
|
|
@@ -449,7 +451,7 @@ const O = () => $ && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
|
|
|
449
451
|
})(), x.push(t));
|
|
450
452
|
};
|
|
451
453
|
window.addEventListener("beforeunload", async () => {
|
|
452
|
-
|
|
454
|
+
$e = !0, O() && (d.info("Always On handle page unload"), (() => {
|
|
453
455
|
let e;
|
|
454
456
|
x.length && (e = x[0].timestamp);
|
|
455
457
|
const t = { disabled: L, metadata: j, uploadUrls: A, currentIndex: N, pendingEventTimestamp: e, expirationTimestamp: q };
|
|
@@ -493,7 +495,7 @@ const jt = (e) => {
|
|
|
493
495
|
we = [], me = !1, et(async () => {
|
|
494
496
|
await (async (t) => {
|
|
495
497
|
const n = t.map((a) => ({ ...a, sessionId: a.sessionId ?? I }));
|
|
496
|
-
if (n.length !== 0) return D(() =>
|
|
498
|
+
if (n.length !== 0) return D(() => l.bulkAdd("events", n), "Error storing replay events");
|
|
497
499
|
})(e);
|
|
498
500
|
}, "sdk_replay_add_event_batch_seconds");
|
|
499
501
|
}, 500);
|
|
@@ -501,7 +503,7 @@ const jt = (e) => {
|
|
|
501
503
|
g.cleanupInterval = window.setInterval(() => {
|
|
502
504
|
const a = Date.now();
|
|
503
505
|
Ye(() => D(async () => {
|
|
504
|
-
T() || await Promise.all([
|
|
506
|
+
T() || await Promise.all([l.deleteRowsBefore("events", a - 1e3 * e, (r) => r.expiredAt === void 0 || r.expiredAt < a - 1e3 * e), l.deleteRowsBefore("chunkUploads", a - 1e3 * t), l.deleteRowsBefore("pendingCaptures", a - 1e3 * n, (r) => !r.canUpload)]);
|
|
505
507
|
}, "Error deleting table rows"), "sdk_replay_cleanup_seconds"), d.debug("CleanupComplete");
|
|
506
508
|
}, 3e4);
|
|
507
509
|
}, Wt = () => {
|
|
@@ -517,21 +519,21 @@ const ye = async (e = !1) => {
|
|
|
517
519
|
ae = !0;
|
|
518
520
|
const t = parseInt(_ ?? "0");
|
|
519
521
|
if (t === 0) return;
|
|
520
|
-
const n = await
|
|
522
|
+
const n = await l.getPendingCaptures({ beforePresent: !0, isBeforeType: e }), a = await l.openDB();
|
|
521
523
|
await Promise.all(n.map(async (r) => (await a.delete("pendingCaptures", r.uuid), rt(r.captureParams, r.canUpload)))), _ = (t - n.length).toString(), m.setItem("sprig.pendingCount", _);
|
|
522
524
|
} finally {
|
|
523
525
|
ae = !1;
|
|
524
526
|
}
|
|
525
527
|
}, $t = async (e, t, n, a, r) => {
|
|
526
|
-
const o = Math.min(e + r, n), s = await Ye(() =>
|
|
528
|
+
const o = Math.min(e + r, n), s = await Ye(() => l.getEventsBetween(e, o), "sdk_replay_get_events_between_seconds");
|
|
527
529
|
if (!(s != null && s.length)) return d.debug("NoEventsFound"), { validStartFound: a, events: [] };
|
|
528
530
|
if (!a) {
|
|
529
531
|
d.debug("ValidStartSearch");
|
|
530
532
|
let c = -1;
|
|
531
|
-
return s == null || s.forEach((i,
|
|
533
|
+
return s == null || s.forEach((i, u) => {
|
|
532
534
|
if (!i.isValidStart) return;
|
|
533
535
|
const y = i.timestamp <= t;
|
|
534
|
-
(c < 0 || y) && (c =
|
|
536
|
+
(c < 0 || y) && (c = u);
|
|
535
537
|
}), c < 0 ? (d.debug("ValidStartNotFound"), { validStartFound: a, events: [] }) : { validStartFound: !0, events: s == null ? void 0 : s.slice(c) };
|
|
536
538
|
}
|
|
537
539
|
return { validStartFound: a, events: s };
|
|
@@ -545,17 +547,17 @@ const ye = async (e = !1) => {
|
|
|
545
547
|
if (!o) throw new Error(`Upload response did not include etag for upload ${a.uploadId}, part ${a.chunkIndex}`);
|
|
546
548
|
return o;
|
|
547
549
|
}))(t);
|
|
548
|
-
return await
|
|
550
|
+
return await l.updatePartial("chunkUploads", t.uuid, { data: null, etag: n, status: "UploadComplete" }), t.uploadId;
|
|
549
551
|
})), at = async (e) => {
|
|
550
|
-
const t = await
|
|
552
|
+
const t = await l.getChunkUploadsByStatus({ status: "UploadComplete", uploadId: e });
|
|
551
553
|
if (!(t != null && t.length)) return void d.info("NoChunksForUpload", { uploadId: e });
|
|
552
554
|
const n = t.reduce((o, s) => (o.find((c) => c.chunkIndex === s.chunkIndex) || o.push(s), o), []);
|
|
553
555
|
n.sort((o, s) => o.chunkIndex - s.chunkIndex);
|
|
554
556
|
const a = n.map((o) => ({ ETag: o.etag, PartNumber: o.chunkIndex })).filter((o) => o.ETag !== null), r = n[0];
|
|
555
|
-
await _e({ apiUrl: r.apiUrl, surveyId: r.surveyId, uploadId: e, responseGroupUuid: r.responseGroupId, etags: a, headers: r.completeUploadHeaders, replayDuration: r.replayDuration }), await
|
|
557
|
+
await _e({ apiUrl: r.apiUrl, surveyId: r.surveyId, uploadId: e, responseGroupUuid: r.responseGroupId, etags: a, headers: r.completeUploadHeaders, replayDuration: r.replayDuration }), await l.deleteChunkUploads("UploadComplete", e);
|
|
556
558
|
}, Kt = () => {
|
|
557
559
|
D(async () => {
|
|
558
|
-
const e = await
|
|
560
|
+
const e = await l.getChunkUploadsByStatus({ sessionId: I, status: "ReadyForUpload" });
|
|
559
561
|
if (!(e != null && e.length)) return;
|
|
560
562
|
const t = await nt(e);
|
|
561
563
|
t != null && t.length && await Promise.all(t.map((n) => {
|
|
@@ -568,7 +570,7 @@ const ye = async (e = !1) => {
|
|
|
568
570
|
const o = new TextEncoder();
|
|
569
571
|
let s = null;
|
|
570
572
|
const c = new CompressionStream("gzip"), i = c.writable.getWriter();
|
|
571
|
-
let
|
|
573
|
+
let u = !1, y = !1, [p, h] = [0, 0], w = [];
|
|
572
574
|
for (let P = a - 35e3; P < r; P += pe) {
|
|
573
575
|
if ({ validStartFound: y, events: w } = await $t(P, a, r, y, pe), !(w != null && w.length)) {
|
|
574
576
|
d.debug("NoEventsFound");
|
|
@@ -577,10 +579,10 @@ const ye = async (e = !1) => {
|
|
|
577
579
|
p === 0 && (p = w[0].timestamp), h = w[w.length - 1].timestamp;
|
|
578
580
|
const f = w.map((R) => R.event);
|
|
579
581
|
f.push(`{"timestamp":${r}}`);
|
|
580
|
-
const v = `${
|
|
582
|
+
const v = `${u ? "," : "["}${f}`, S = o.encode(v);
|
|
581
583
|
et(() => {
|
|
582
584
|
i.write(S);
|
|
583
|
-
}, "sdk_replay_compression_seconds"),
|
|
585
|
+
}, "sdk_replay_compression_seconds"), u = !0;
|
|
584
586
|
}
|
|
585
587
|
if (h - p < tt) return d.debug("ReplayTooShort"), null;
|
|
586
588
|
const E = o.encode("]");
|
|
@@ -589,14 +591,14 @@ const ye = async (e = !1) => {
|
|
|
589
591
|
}, Pe = async (e) => {
|
|
590
592
|
const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: o, replayParams: s, triggerTimestamp: c } = e, i = await Jt(1e3 * s.replayDurationSeconds, c);
|
|
591
593
|
if (!(i != null && i.length)) return void d.info("FileDataEmpty", { surveyId: t });
|
|
592
|
-
const
|
|
594
|
+
const u = ((p, h, w) => {
|
|
593
595
|
const E = p.length, P = 1024 * h * 1024, f = Math.ceil(E / w), v = Math.max(P, f), S = [];
|
|
594
596
|
let R = 0;
|
|
595
597
|
for (; R < E; ) S.push(p.slice(R, R + v)), R += v;
|
|
596
598
|
return S;
|
|
597
|
-
})(i, s.minimumChunkSizeMb, s.signedUrls.length), y = await Promise.all(
|
|
598
|
-
const w = X(), E = { apiUrl: r, chunkIndex: h + 1, completeUploadHeaders: o, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: c, totalChunks:
|
|
599
|
-
return await (await
|
|
599
|
+
})(i, s.minimumChunkSizeMb, s.signedUrls.length), y = await Promise.all(u.map(async (p, h) => {
|
|
600
|
+
const w = X(), E = { apiUrl: r, chunkIndex: h + 1, completeUploadHeaders: o, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: c, totalChunks: u.length, data: p, uploadId: s.uploadId, uploadUrl: s.signedUrls[h].url, uuid: w, visitorId: a };
|
|
601
|
+
return await (await l.openDB()).add("chunkUploads", { ...E, sessionId: E.sessionId ?? I }), E;
|
|
600
602
|
}));
|
|
601
603
|
await (async (p, h) => {
|
|
602
604
|
await nt(h), await Promise.all(p.map((w) => at(w)));
|
|
@@ -605,7 +607,7 @@ const ye = async (e = !1) => {
|
|
|
605
607
|
if (T()) return d.debug("ReplayDisabled-ScheduleOrCapture");
|
|
606
608
|
const { isHeatmap: n, isStandalone: a, replayParams: r, triggerTimestamp: o, responseGroupId: s } = e, c = async () => {
|
|
607
609
|
setTimeout(() => V.removeListener(Z.QuestionAnswered, c), 0), D(async () => {
|
|
608
|
-
r.replayDurationType === "before" ? await Pe(e) : await
|
|
610
|
+
r.replayDurationType === "before" ? await Pe(e) : await l.markPendingCaptureToCanUpload(s);
|
|
609
611
|
}, "Error in schedule/capture callback");
|
|
610
612
|
};
|
|
611
613
|
D(async () => {
|
|
@@ -613,26 +615,26 @@ const ye = async (e = !1) => {
|
|
|
613
615
|
return !a && !n && V.on(Z.QuestionAnswered, c), void await st(e);
|
|
614
616
|
if (a || n || t) await Pe(e), n && zt();
|
|
615
617
|
else {
|
|
616
|
-
const i = 35 + r.replayDurationSeconds,
|
|
617
|
-
await
|
|
618
|
+
const i = 35 + r.replayDurationSeconds, u = o - 1e3 * i, y = o;
|
|
619
|
+
await l.updateEventsExpiredAt(u, y, r.expirationTimeLimitMinutes), V.on(Z.QuestionAnswered, c);
|
|
618
620
|
}
|
|
619
621
|
}, "Error in scheduling/capturing replay");
|
|
620
622
|
}, zt = async () => {
|
|
621
623
|
parseInt(_ ?? "0") || m.removeItem("sprig.isCapturingHeatmap"), m.getItem("sprig.teardownAfterCapture") && (Ge(), ot(), m.removeItem("sprig.teardownAfterCapture"));
|
|
622
|
-
}, ot = async () => T() ? d.debug("ReplayDisabled-ClearData") : Promise.all([
|
|
624
|
+
}, ot = async () => T() ? d.debug("ReplayDisabled-ClearData") : Promise.all([l.deleteBySessionId("events", I), l.deleteBySessionId("pendingCaptures", I)]).catch((e) => {
|
|
623
625
|
H("Error clearing user replay data", e);
|
|
624
626
|
}), st = async (e) => {
|
|
625
627
|
if (T()) return;
|
|
626
|
-
const { isHeatmap: t, surveyId: n } = e, a = await
|
|
628
|
+
const { isHeatmap: t, surveyId: n } = e, a = await l.getPendingCaptures(), r = a == null ? void 0 : a.filter((i) => i.captureParams.surveyId === n);
|
|
627
629
|
if (r != null && r.length) return void d.info("PendingCaptureExists", { surveyId: n });
|
|
628
|
-
t && (
|
|
630
|
+
t && (le(), m.setItem("sprig.isCapturingHeatmap", "true"), ge = Date.now(), g.inactivityInterval || (g.inactivityInterval = window.setInterval(() => {
|
|
629
631
|
var i;
|
|
630
|
-
i = ge, Date.now() - i >= 3e4 && D(() =>
|
|
632
|
+
i = ge, Date.now() - i >= 3e4 && D(() => l.markPendingHeatmapsReady(), "Error in heatmap inactivity");
|
|
631
633
|
}, 1e3)));
|
|
632
634
|
const o = { ...e, replayParams: { ...e.replayParams } };
|
|
633
635
|
e.replayParams.replayDurationType === "beforeAndAfter" && (o.replayParams.replayDurationSeconds *= 2), o.replayParams.replayDurationType = "before";
|
|
634
636
|
const s = e.triggerTimestamp + 1e3 * e.replayParams.replayDurationSeconds;
|
|
635
|
-
o.triggerTimestamp = s, _ = (parseInt(_ ?? "0") + 1).toString(), m.setItem("sprig.pendingCount", _), await (await
|
|
637
|
+
o.triggerTimestamp = s, _ = (parseInt(_ ?? "0") + 1).toString(), m.setItem("sprig.pendingCount", _), await (await l.openDB()).add("pendingCaptures", { canUpload: !1, captureParams: o, sessionId: I, targetTimestamp: s, timestamp: Date.now(), uuid: X() });
|
|
636
638
|
}, qt = Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
637
639
|
U("Sprig_TrackEvent", e);
|
|
638
640
|
}, RecordPageView: (e) => {
|
|
@@ -644,29 +646,29 @@ const ye = async (e = !1) => {
|
|
|
644
646
|
const r = window.UserLeap._API_URL, o = await _e({ surveyId: e, responseGroupUuid: t, eventDigest: n, apiUrl: r, headers: a }, !0);
|
|
645
647
|
return !(o != null && o.error);
|
|
646
648
|
}, checkPendingHeatmapsUrl: () => T() ? d.debug("ReplayDisabled-PendingHeatmaps") : D(async () => {
|
|
647
|
-
const e = (await
|
|
648
|
-
return d.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await
|
|
649
|
+
const e = (await l.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !ct(t)).map(({ uuid: t }) => t);
|
|
650
|
+
return d.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await l.markPendingHeatmapsReady(e), d.info("MarkedPendingHeatmapsReady")), e.length;
|
|
649
651
|
}, "Error marking pending heatmaps ready"), clearUserReplayData: ot, disableRecording: H, initializeReplay: async ({ maxReplayDurationSeconds: e, maxInflightRequests: t = 2, replaySettings: n, teardownAfter: a = !1, apiUrl: r, alwaysOnConfig: o }) => {
|
|
650
652
|
if (o && Mt({ apiUrl: r, config: o, triggerSnapshot: () => {
|
|
651
|
-
|
|
653
|
+
le();
|
|
652
654
|
} }), _ = m.getItem("sprig.pendingCount"), g.isRecording) return;
|
|
653
655
|
if (a && m.setItem("sprig.teardownAfterCapture", "true"), T()) return d.debug("ReplayDisabled");
|
|
654
656
|
if (await (async () => {
|
|
655
657
|
var i;
|
|
656
658
|
if (!Ve()) return !0;
|
|
657
659
|
if ((i = window.navigator.storage) != null && i.estimate) try {
|
|
658
|
-
const { quota:
|
|
660
|
+
const { quota: u = 0, usage: y = 0 } = await window.navigator.storage.estimate(), p = (u - y) / 1024 ** 3;
|
|
659
661
|
return d.info("Storage", { availableGb: p }), p < 0.5;
|
|
660
662
|
} catch {
|
|
661
663
|
return !0;
|
|
662
664
|
}
|
|
663
665
|
return !1;
|
|
664
|
-
})()) return d.debug("IDBNotSupported"),
|
|
666
|
+
})()) return d.debug("IDBNotSupported"), ue();
|
|
665
667
|
try {
|
|
666
|
-
const i = await
|
|
668
|
+
const i = await l.openDB();
|
|
667
669
|
d.info("DBVersion", { version: i.version });
|
|
668
670
|
} catch (i) {
|
|
669
|
-
return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" &&
|
|
671
|
+
return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" && l.deleteDB(), ue();
|
|
670
672
|
}
|
|
671
673
|
D(async () => {
|
|
672
674
|
await ye(!0);
|
|
@@ -676,26 +678,26 @@ const ye = async (e = !1) => {
|
|
|
676
678
|
d.debug("ReplayInit"), await D(async () => {
|
|
677
679
|
var i;
|
|
678
680
|
n != null && n.minDuration && (tt = n.minDuration), n != null && n.batchDuration && (pe = n.batchDuration), i = t, Me.setLimit(i), Kt(), Gt(c + 35, 1800, c + 35), Wt();
|
|
679
|
-
const
|
|
681
|
+
const u = window.UserLeap.replayLibraryURL ?? "https://cdn.sprig.com/dependencies/record.min.js";
|
|
680
682
|
if (!window.rrwebRecord) {
|
|
681
683
|
const { record: f } = await import(
|
|
682
684
|
/* webpackIgnore: true */
|
|
683
685
|
/* @vite-ignore */
|
|
684
|
-
|
|
686
|
+
u
|
|
685
687
|
);
|
|
686
688
|
window.rrwebRecord = f;
|
|
687
689
|
}
|
|
688
690
|
const y = window.rrwebRecord;
|
|
689
691
|
if (!y) return d.error("RecordScriptFailed");
|
|
690
692
|
let p = !0, h = 0;
|
|
691
|
-
const w = { checkoutEveryNms: 3e4, sampling: { input: "last", scroll: 250, media: 800 }, ...n };
|
|
693
|
+
const w = { checkoutEveryNms: 3e4, sampling: { input: "last", scroll: 250, media: 800 }, ...n, mutationQueueEnabled: n == null ? void 0 : n.enableMutationQueue };
|
|
692
694
|
var E, P;
|
|
693
695
|
g.stopRecording = y({ emit: (f, v) => {
|
|
694
696
|
if (f.type === B.Custom && (ge = Date.now()), T() || z()) return;
|
|
695
697
|
if (v && f.type === B.Meta) h = performance.now();
|
|
696
698
|
else if (v && h && f.type === B.FullSnapshot) {
|
|
697
699
|
const R = performance.now() - h;
|
|
698
|
-
|
|
700
|
+
lt("sdk_replay_snapshot_seconds", R / 1e3);
|
|
699
701
|
}
|
|
700
702
|
const S = p || !!v && f.type === B.Meta;
|
|
701
703
|
p = !1, Ht(S, f), jt({ uuid: X(), event: JSON.stringify(f), isValidStart: S, timestamp: Date.now() });
|
|
@@ -704,12 +706,12 @@ const ye = async (e = !1) => {
|
|
|
704
706
|
var R;
|
|
705
707
|
S.data.type === vt && (fe.push({ source: S.source, origin: S.origin }), (R = S.source) == null || R.postMessage({ type: St, settings: f, replayLibraryUrl: v }, { targetOrigin: S.origin }));
|
|
706
708
|
});
|
|
707
|
-
})(w,
|
|
709
|
+
})(w, u), V.on("survey.complete", (f) => {
|
|
708
710
|
var v;
|
|
709
711
|
v = { id: f, userAgent: window.navigator.userAgent }, U("Sprig_SubmitSurvey", v);
|
|
710
712
|
}), E = U, P = Ut, J || (b = E, G = P, window.addEventListener("click", Fe, C), window.addEventListener("pointerdown", je, C), window.addEventListener("mousedown", He, C), window.addEventListener("keydown", Le, C), window.addEventListener("scroll", Oe, C), J = !0, Pt(), kt()));
|
|
711
713
|
}, "Error initializing replay");
|
|
712
|
-
}, isReplayPaused: z, isReplayRecording: () => g.isRecording, recordFullSnapshot:
|
|
714
|
+
}, isReplayPaused: z, isReplayRecording: () => g.isRecording, recordFullSnapshot: le, recordReplayPaused: () => {
|
|
713
715
|
U("Sprig_ReplayPaused", { timestamp: Date.now() }), m.setItem("sprig.isReplayPaused", "true");
|
|
714
716
|
}, recordReplayResumed: () => {
|
|
715
717
|
m.removeItem("sprig.isReplayPaused"), U("Sprig_ReplayResumed", { timestamp: Date.now() });
|