@sprig-technologies/sprig-browser 2.36.0 → 2.36.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/{core-PNM_2mYx.js → core-BVtQnihE.js} +3 -3
- package/dist/{core-B-mNVA8c.cjs → core-Bzv2KQOu.cjs} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-CWGtDAqh.cjs → metricsReporter-DbEyJSwA.cjs} +1 -1
- package/dist/{metricsReporter-B_p_qsZJ.js → metricsReporter-M_tu1Yrx.js} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +54 -54
- package/dist/{view-C3-nqngP.js → view-DJdeN4-t.js} +1182 -1146
- package/dist/view-qqhfcMHd.cjs +669 -0
- package/package.json +1 -1
- package/dist/view-Cji0PL_w.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 lt, P as ke, r as Ue, d as ut, e as V, S as Z, f as pt } from "./metricsReporter-M_tu1Yrx.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 l = i.store;
|
|
70
|
+
return a && (l = l.index(c.shift())), (await Promise.all([l[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 l = 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 }), l;
|
|
124
124
|
}, Et = (e) => {
|
|
125
125
|
if (e instanceof Attr) return null;
|
|
126
126
|
let t = 1;
|
|
@@ -175,7 +175,7 @@ const Ce = (e) => {
|
|
|
175
175
|
var r, o;
|
|
176
176
|
let n = t.target;
|
|
177
177
|
var a;
|
|
178
|
-
t.target === ((r = window.document) == null ? void 0 : r.body) && window.Sprig.pointerDownTarget && (n = window.Sprig.pointerDownTarget), a = { x: t.x, y: t.y, type: e, elementAttributes: Tt(n), windowHeight: window.innerHeight, windowWidth: window.innerWidth, ...n instanceof HTMLElement ? { rect: n == null ? void 0 : n.getBoundingClientRect(), xPath: Ae(n) } : {} }, (o = a == null ? void 0 : a.elementAttributes) != null && o.text && (a.elementAttributes.text = he(a.elementAttributes.text)), b == null || b("Sprig_Click", a);
|
|
178
|
+
t.target === ((r = window.document) == null ? void 0 : r.body) && window.Sprig.pointerDownTarget && (n = window.Sprig.pointerDownTarget), a = { x: t.x, y: t.y, type: e, elementAttributes: Tt(n), windowHeight: window.innerHeight, windowWidth: window.innerWidth, ...n instanceof HTMLElement || n instanceof SVGElement || n instanceof MathMLElement ? { rect: n == null ? void 0 : n.getBoundingClientRect(), xPath: Ae(n) } : {} }, (o = a == null ? void 0 : a.elementAttributes) != null && o.text && (a.elementAttributes.text = he(a.elementAttributes.text)), b == null || b("Sprig_Click", a);
|
|
179
179
|
}, Le = (e) => {
|
|
180
180
|
var t;
|
|
181
181
|
Ct.includes(e.key) && (t = { key: e.key }, b == null || b("Sprig_Keystroke", t));
|
|
@@ -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
|
+
})(), le = () => {
|
|
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, l, y;
|
|
226
|
+
const o = await u.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 = (l = p.data) == null ? void 0 : l.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 (le(), t.name === "VersionError") return d.error("VersionErr", { message: e }), void u.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), u.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
|
+
}, ue = () => {
|
|
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 u = new class {
|
|
270
270
|
constructor() {
|
|
271
271
|
F(this, "wrapTransactionWithCounter", (e) => {
|
|
272
272
|
var a, r;
|
|
@@ -290,7 +290,7 @@ const l = 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 = (l) => r(l.oldVersion, l.newVersion, l));
|
|
294
294
|
}).catch(() => {
|
|
295
295
|
}), c;
|
|
296
296
|
}("sprigReplay", 1, { upgrade: (e, t, n) => {
|
|
@@ -401,7 +401,7 @@ const O = () => $ && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
|
|
|
401
401
|
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
402
|
} else q = 1e3 * $e + Date.now();
|
|
403
403
|
}, Ot = async (e) => {
|
|
404
|
-
const t = Date.now(), n = (await
|
|
404
|
+
const t = Date.now(), n = (await u.getEventsBetween(e, t)).map((r) => JSON.parse(r.event));
|
|
405
405
|
if (!ve(n)) return;
|
|
406
406
|
Ze(n);
|
|
407
407
|
const a = await Xe();
|
|
@@ -425,7 +425,7 @@ const O = () => $ && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
|
|
|
425
425
|
if (!O()) return;
|
|
426
426
|
const { surveyId: e, responseGroupUuid: t } = j, n = { responseGroupUuid: t, surveyId: e, index: N + 1 };
|
|
427
427
|
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:
|
|
428
|
+
const a = await qe(() => Q(`${We}/sdk/1/replayUrls`, { method: "POST", body: JSON.stringify(n), headers: lt(window.UserLeap) }), "fetching always-on signed urls");
|
|
429
429
|
if (!a) return;
|
|
430
430
|
const r = a.json.signedUrls;
|
|
431
431
|
return d.info("Fetched more always-on upload urls", { body: n, urls: r }), r;
|
|
@@ -493,7 +493,7 @@ const jt = (e) => {
|
|
|
493
493
|
we = [], me = !1, et(async () => {
|
|
494
494
|
await (async (t) => {
|
|
495
495
|
const n = t.map((a) => ({ ...a, sessionId: a.sessionId ?? I }));
|
|
496
|
-
if (n.length !== 0) return D(() =>
|
|
496
|
+
if (n.length !== 0) return D(() => u.bulkAdd("events", n), "Error storing replay events");
|
|
497
497
|
})(e);
|
|
498
498
|
}, "sdk_replay_add_event_batch_seconds");
|
|
499
499
|
}, 500);
|
|
@@ -501,7 +501,7 @@ const jt = (e) => {
|
|
|
501
501
|
g.cleanupInterval = window.setInterval(() => {
|
|
502
502
|
const a = Date.now();
|
|
503
503
|
Ye(() => D(async () => {
|
|
504
|
-
T() || await Promise.all([
|
|
504
|
+
T() || await Promise.all([u.deleteRowsBefore("events", a - 1e3 * e, (r) => r.expiredAt === void 0 || r.expiredAt < a - 1e3 * e), u.deleteRowsBefore("chunkUploads", a - 1e3 * t), u.deleteRowsBefore("pendingCaptures", a - 1e3 * n, (r) => !r.canUpload)]);
|
|
505
505
|
}, "Error deleting table rows"), "sdk_replay_cleanup_seconds"), d.debug("CleanupComplete");
|
|
506
506
|
}, 3e4);
|
|
507
507
|
}, Wt = () => {
|
|
@@ -517,21 +517,21 @@ const ye = async (e = !1) => {
|
|
|
517
517
|
ae = !0;
|
|
518
518
|
const t = parseInt(_ ?? "0");
|
|
519
519
|
if (t === 0) return;
|
|
520
|
-
const n = await
|
|
520
|
+
const n = await u.getPendingCaptures({ beforePresent: !0, isBeforeType: e }), a = await u.openDB();
|
|
521
521
|
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
522
|
} finally {
|
|
523
523
|
ae = !1;
|
|
524
524
|
}
|
|
525
525
|
}, $t = async (e, t, n, a, r) => {
|
|
526
|
-
const o = Math.min(e + r, n), s = await Ye(() =>
|
|
526
|
+
const o = Math.min(e + r, n), s = await Ye(() => u.getEventsBetween(e, o), "sdk_replay_get_events_between_seconds");
|
|
527
527
|
if (!(s != null && s.length)) return d.debug("NoEventsFound"), { validStartFound: a, events: [] };
|
|
528
528
|
if (!a) {
|
|
529
529
|
d.debug("ValidStartSearch");
|
|
530
530
|
let c = -1;
|
|
531
|
-
return s == null || s.forEach((i,
|
|
531
|
+
return s == null || s.forEach((i, l) => {
|
|
532
532
|
if (!i.isValidStart) return;
|
|
533
533
|
const y = i.timestamp <= t;
|
|
534
|
-
(c < 0 || y) && (c =
|
|
534
|
+
(c < 0 || y) && (c = l);
|
|
535
535
|
}), c < 0 ? (d.debug("ValidStartNotFound"), { validStartFound: a, events: [] }) : { validStartFound: !0, events: s == null ? void 0 : s.slice(c) };
|
|
536
536
|
}
|
|
537
537
|
return { validStartFound: a, events: s };
|
|
@@ -545,17 +545,17 @@ const ye = async (e = !1) => {
|
|
|
545
545
|
if (!o) throw new Error(`Upload response did not include etag for upload ${a.uploadId}, part ${a.chunkIndex}`);
|
|
546
546
|
return o;
|
|
547
547
|
}))(t);
|
|
548
|
-
return await
|
|
548
|
+
return await u.updatePartial("chunkUploads", t.uuid, { data: null, etag: n, status: "UploadComplete" }), t.uploadId;
|
|
549
549
|
})), at = async (e) => {
|
|
550
|
-
const t = await
|
|
550
|
+
const t = await u.getChunkUploadsByStatus({ status: "UploadComplete", uploadId: e });
|
|
551
551
|
if (!(t != null && t.length)) return void d.info("NoChunksForUpload", { uploadId: e });
|
|
552
552
|
const n = t.reduce((o, s) => (o.find((c) => c.chunkIndex === s.chunkIndex) || o.push(s), o), []);
|
|
553
553
|
n.sort((o, s) => o.chunkIndex - s.chunkIndex);
|
|
554
554
|
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
|
|
555
|
+
await _e({ apiUrl: r.apiUrl, surveyId: r.surveyId, uploadId: e, responseGroupUuid: r.responseGroupId, etags: a, headers: r.completeUploadHeaders, replayDuration: r.replayDuration }), await u.deleteChunkUploads("UploadComplete", e);
|
|
556
556
|
}, Kt = () => {
|
|
557
557
|
D(async () => {
|
|
558
|
-
const e = await
|
|
558
|
+
const e = await u.getChunkUploadsByStatus({ sessionId: I, status: "ReadyForUpload" });
|
|
559
559
|
if (!(e != null && e.length)) return;
|
|
560
560
|
const t = await nt(e);
|
|
561
561
|
t != null && t.length && await Promise.all(t.map((n) => {
|
|
@@ -568,7 +568,7 @@ const ye = async (e = !1) => {
|
|
|
568
568
|
const o = new TextEncoder();
|
|
569
569
|
let s = null;
|
|
570
570
|
const c = new CompressionStream("gzip"), i = c.writable.getWriter();
|
|
571
|
-
let
|
|
571
|
+
let l = !1, y = !1, [p, h] = [0, 0], w = [];
|
|
572
572
|
for (let P = a - 35e3; P < r; P += pe) {
|
|
573
573
|
if ({ validStartFound: y, events: w } = await $t(P, a, r, y, pe), !(w != null && w.length)) {
|
|
574
574
|
d.debug("NoEventsFound");
|
|
@@ -577,10 +577,10 @@ const ye = async (e = !1) => {
|
|
|
577
577
|
p === 0 && (p = w[0].timestamp), h = w[w.length - 1].timestamp;
|
|
578
578
|
const f = w.map((R) => R.event);
|
|
579
579
|
f.push(`{"timestamp":${r}}`);
|
|
580
|
-
const v = `${
|
|
580
|
+
const v = `${l ? "," : "["}${f}`, S = o.encode(v);
|
|
581
581
|
et(() => {
|
|
582
582
|
i.write(S);
|
|
583
|
-
}, "sdk_replay_compression_seconds"),
|
|
583
|
+
}, "sdk_replay_compression_seconds"), l = !0;
|
|
584
584
|
}
|
|
585
585
|
if (h - p < tt) return d.debug("ReplayTooShort"), null;
|
|
586
586
|
const E = o.encode("]");
|
|
@@ -589,14 +589,14 @@ const ye = async (e = !1) => {
|
|
|
589
589
|
}, Pe = async (e) => {
|
|
590
590
|
const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: o, replayParams: s, triggerTimestamp: c } = e, i = await Jt(1e3 * s.replayDurationSeconds, c);
|
|
591
591
|
if (!(i != null && i.length)) return void d.info("FileDataEmpty", { surveyId: t });
|
|
592
|
-
const
|
|
592
|
+
const l = ((p, h, w) => {
|
|
593
593
|
const E = p.length, P = 1024 * h * 1024, f = Math.ceil(E / w), v = Math.max(P, f), S = [];
|
|
594
594
|
let R = 0;
|
|
595
595
|
for (; R < E; ) S.push(p.slice(R, R + v)), R += v;
|
|
596
596
|
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
|
|
597
|
+
})(i, s.minimumChunkSizeMb, s.signedUrls.length), y = await Promise.all(l.map(async (p, h) => {
|
|
598
|
+
const w = X(), E = { apiUrl: r, chunkIndex: h + 1, completeUploadHeaders: o, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: c, totalChunks: l.length, data: p, uploadId: s.uploadId, uploadUrl: s.signedUrls[h].url, uuid: w, visitorId: a };
|
|
599
|
+
return await (await u.openDB()).add("chunkUploads", { ...E, sessionId: E.sessionId ?? I }), E;
|
|
600
600
|
}));
|
|
601
601
|
await (async (p, h) => {
|
|
602
602
|
await nt(h), await Promise.all(p.map((w) => at(w)));
|
|
@@ -605,7 +605,7 @@ const ye = async (e = !1) => {
|
|
|
605
605
|
if (T()) return d.debug("ReplayDisabled-ScheduleOrCapture");
|
|
606
606
|
const { isHeatmap: n, isStandalone: a, replayParams: r, triggerTimestamp: o, responseGroupId: s } = e, c = async () => {
|
|
607
607
|
setTimeout(() => V.removeListener(Z.QuestionAnswered, c), 0), D(async () => {
|
|
608
|
-
r.replayDurationType === "before" ? await Pe(e) : await
|
|
608
|
+
r.replayDurationType === "before" ? await Pe(e) : await u.markPendingCaptureToCanUpload(s);
|
|
609
609
|
}, "Error in schedule/capture callback");
|
|
610
610
|
};
|
|
611
611
|
D(async () => {
|
|
@@ -613,26 +613,26 @@ const ye = async (e = !1) => {
|
|
|
613
613
|
return !a && !n && V.on(Z.QuestionAnswered, c), void await st(e);
|
|
614
614
|
if (a || n || t) await Pe(e), n && zt();
|
|
615
615
|
else {
|
|
616
|
-
const i = 35 + r.replayDurationSeconds,
|
|
617
|
-
await
|
|
616
|
+
const i = 35 + r.replayDurationSeconds, l = o - 1e3 * i, y = o;
|
|
617
|
+
await u.updateEventsExpiredAt(l, y, r.expirationTimeLimitMinutes), V.on(Z.QuestionAnswered, c);
|
|
618
618
|
}
|
|
619
619
|
}, "Error in scheduling/capturing replay");
|
|
620
620
|
}, zt = async () => {
|
|
621
621
|
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([
|
|
622
|
+
}, ot = async () => T() ? d.debug("ReplayDisabled-ClearData") : Promise.all([u.deleteBySessionId("events", I), u.deleteBySessionId("pendingCaptures", I)]).catch((e) => {
|
|
623
623
|
H("Error clearing user replay data", e);
|
|
624
624
|
}), st = async (e) => {
|
|
625
625
|
if (T()) return;
|
|
626
|
-
const { isHeatmap: t, surveyId: n } = e, a = await
|
|
626
|
+
const { isHeatmap: t, surveyId: n } = e, a = await u.getPendingCaptures(), r = a == null ? void 0 : a.filter((i) => i.captureParams.surveyId === n);
|
|
627
627
|
if (r != null && r.length) return void d.info("PendingCaptureExists", { surveyId: n });
|
|
628
|
-
t && (
|
|
628
|
+
t && (ue(), m.setItem("sprig.isCapturingHeatmap", "true"), ge = Date.now(), g.inactivityInterval || (g.inactivityInterval = window.setInterval(() => {
|
|
629
629
|
var i;
|
|
630
|
-
i = ge, Date.now() - i >= 3e4 && D(() =>
|
|
630
|
+
i = ge, Date.now() - i >= 3e4 && D(() => u.markPendingHeatmapsReady(), "Error in heatmap inactivity");
|
|
631
631
|
}, 1e3)));
|
|
632
632
|
const o = { ...e, replayParams: { ...e.replayParams } };
|
|
633
633
|
e.replayParams.replayDurationType === "beforeAndAfter" && (o.replayParams.replayDurationSeconds *= 2), o.replayParams.replayDurationType = "before";
|
|
634
634
|
const s = e.triggerTimestamp + 1e3 * e.replayParams.replayDurationSeconds;
|
|
635
|
-
o.triggerTimestamp = s, _ = (parseInt(_ ?? "0") + 1).toString(), m.setItem("sprig.pendingCount", _), await (await
|
|
635
|
+
o.triggerTimestamp = s, _ = (parseInt(_ ?? "0") + 1).toString(), m.setItem("sprig.pendingCount", _), await (await u.openDB()).add("pendingCaptures", { canUpload: !1, captureParams: o, sessionId: I, targetTimestamp: s, timestamp: Date.now(), uuid: X() });
|
|
636
636
|
}, qt = Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
637
637
|
U("Sprig_TrackEvent", e);
|
|
638
638
|
}, RecordPageView: (e) => {
|
|
@@ -644,29 +644,29 @@ const ye = async (e = !1) => {
|
|
|
644
644
|
const r = window.UserLeap._API_URL, o = await _e({ surveyId: e, responseGroupUuid: t, eventDigest: n, apiUrl: r, headers: a }, !0);
|
|
645
645
|
return !(o != null && o.error);
|
|
646
646
|
}, checkPendingHeatmapsUrl: () => T() ? d.debug("ReplayDisabled-PendingHeatmaps") : D(async () => {
|
|
647
|
-
const e = (await
|
|
648
|
-
return d.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await
|
|
647
|
+
const e = (await u.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !ct(t)).map(({ uuid: t }) => t);
|
|
648
|
+
return d.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await u.markPendingHeatmapsReady(e), d.info("MarkedPendingHeatmapsReady")), e.length;
|
|
649
649
|
}, "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
650
|
if (o && Mt({ apiUrl: r, config: o, triggerSnapshot: () => {
|
|
651
|
-
|
|
651
|
+
ue();
|
|
652
652
|
} }), _ = m.getItem("sprig.pendingCount"), g.isRecording) return;
|
|
653
653
|
if (a && m.setItem("sprig.teardownAfterCapture", "true"), T()) return d.debug("ReplayDisabled");
|
|
654
654
|
if (await (async () => {
|
|
655
655
|
var i;
|
|
656
656
|
if (!Ve()) return !0;
|
|
657
657
|
if ((i = window.navigator.storage) != null && i.estimate) try {
|
|
658
|
-
const { quota:
|
|
658
|
+
const { quota: l = 0, usage: y = 0 } = await window.navigator.storage.estimate(), p = (l - y) / 1024 ** 3;
|
|
659
659
|
return d.info("Storage", { availableGb: p }), p < 0.5;
|
|
660
660
|
} catch {
|
|
661
661
|
return !0;
|
|
662
662
|
}
|
|
663
663
|
return !1;
|
|
664
|
-
})()) return d.debug("IDBNotSupported"),
|
|
664
|
+
})()) return d.debug("IDBNotSupported"), le();
|
|
665
665
|
try {
|
|
666
|
-
const i = await
|
|
666
|
+
const i = await u.openDB();
|
|
667
667
|
d.info("DBVersion", { version: i.version });
|
|
668
668
|
} catch (i) {
|
|
669
|
-
return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" &&
|
|
669
|
+
return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" && u.deleteDB(), le();
|
|
670
670
|
}
|
|
671
671
|
D(async () => {
|
|
672
672
|
await ye(!0);
|
|
@@ -676,12 +676,12 @@ const ye = async (e = !1) => {
|
|
|
676
676
|
d.debug("ReplayInit"), await D(async () => {
|
|
677
677
|
var i;
|
|
678
678
|
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
|
|
679
|
+
const l = window.UserLeap.replayLibraryURL ?? "https://cdn.sprig.com/dependencies/record-2.0.0-alpha.17.min.js";
|
|
680
680
|
if (!window.rrwebRecord) {
|
|
681
681
|
const { record: f } = await import(
|
|
682
682
|
/* webpackIgnore: true */
|
|
683
683
|
/* @vite-ignore */
|
|
684
|
-
|
|
684
|
+
l
|
|
685
685
|
);
|
|
686
686
|
window.rrwebRecord = f;
|
|
687
687
|
}
|
|
@@ -695,7 +695,7 @@ const ye = async (e = !1) => {
|
|
|
695
695
|
if (v && f.type === B.Meta) h = performance.now();
|
|
696
696
|
else if (v && h && f.type === B.FullSnapshot) {
|
|
697
697
|
const R = performance.now() - h;
|
|
698
|
-
|
|
698
|
+
ut("sdk_replay_snapshot_seconds", R / 1e3);
|
|
699
699
|
}
|
|
700
700
|
const S = p || !!v && f.type === B.Meta;
|
|
701
701
|
p = !1, Ht(S, f), jt({ uuid: X(), event: JSON.stringify(f), isValidStart: S, timestamp: Date.now() });
|
|
@@ -704,12 +704,12 @@ const ye = async (e = !1) => {
|
|
|
704
704
|
var R;
|
|
705
705
|
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
706
|
});
|
|
707
|
-
})(w,
|
|
707
|
+
})(w, l), V.on("survey.complete", (f) => {
|
|
708
708
|
var v;
|
|
709
709
|
v = { id: f, userAgent: window.navigator.userAgent }, U("Sprig_SubmitSurvey", v);
|
|
710
710
|
}), 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
711
|
}, "Error initializing replay");
|
|
712
|
-
}, isReplayPaused: z, isReplayRecording: () => g.isRecording, recordFullSnapshot:
|
|
712
|
+
}, isReplayPaused: z, isReplayRecording: () => g.isRecording, recordFullSnapshot: ue, recordReplayPaused: () => {
|
|
713
713
|
U("Sprig_ReplayPaused", { timestamp: Date.now() }), m.setItem("sprig.isReplayPaused", "true");
|
|
714
714
|
}, recordReplayResumed: () => {
|
|
715
715
|
m.removeItem("sprig.isReplayPaused"), U("Sprig_ReplayResumed", { timestamp: Date.now() });
|