@sprig-technologies/sprig-browser 2.32.9 → 2.32.10
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-DHmPygfT.cjs → core-B_CnBIaq.cjs} +1 -1
- package/dist/{core-Cpj6ibvg.js → core-s7v77Fsd.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-D1E3ePJA.cjs → metricsReporter-eI04W7R0.cjs} +1 -1
- package/dist/{metricsReporter-Cl6wG1Dn.js → metricsReporter-lf84Y5sr.js} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +82 -82
- package/dist/{view-PhfA05rs.cjs → view-2CSaceDW.cjs} +4 -4
- package/dist/{view-CxqsZLB6.js → view-CGgXNSb2.js} +205 -190
- package/package.json +1 -1
package/dist/replay.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (e, t, n) => (
|
|
4
|
-
import { b as u, s as ie, a as f, v as N, c as
|
|
1
|
+
var Te = Object.defineProperty;
|
|
2
|
+
var _e = (e, t, n) => t in e ? Te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var M = (e, t, n) => (_e(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
+
import { b as u, s as ie, a as f, v as N, c as Ae, P as de, r as ce, d as Ne, e as T, S as O, f as Le } from "./metricsReporter-lf84Y5sr.js";
|
|
5
5
|
var R = ((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))(R || {});
|
|
6
6
|
const ue = new class {
|
|
7
7
|
constructor(e) {
|
|
@@ -52,15 +52,15 @@ let K = { get(e, t, n) {
|
|
|
52
52
|
function pe(e) {
|
|
53
53
|
K = e(K);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function Me(e) {
|
|
56
56
|
return (ee || (ee = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey])).includes(e) ? function(...t) {
|
|
57
57
|
return e.apply(G(this), t), k(this.request);
|
|
58
58
|
} : function(...t) {
|
|
59
59
|
return k(e.apply(G(this), t));
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return typeof e == "function" ?
|
|
62
|
+
function Oe(e) {
|
|
63
|
+
return typeof e == "function" ? Me(e) : (e instanceof IDBTransaction && function(t) {
|
|
64
64
|
if (V.has(t))
|
|
65
65
|
return;
|
|
66
66
|
const n = new Promise((a, r) => {
|
|
@@ -88,7 +88,7 @@ function k(e) {
|
|
|
88
88
|
}(e);
|
|
89
89
|
if (H.has(e))
|
|
90
90
|
return H.get(e);
|
|
91
|
-
const t =
|
|
91
|
+
const t = Oe(e);
|
|
92
92
|
return t !== e && (H.set(e, t), _.set(t, e)), t;
|
|
93
93
|
}
|
|
94
94
|
const G = (e) => _.get(e);
|
|
@@ -97,14 +97,14 @@ function W(e, { blocked: t } = {}) {
|
|
|
97
97
|
return t && (n.onblocked = (a) => t(a.oldVersion, a)), k(n).then(() => {
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
const
|
|
100
|
+
const He = ["get", "getKey", "getAll", "getAllKeys", "count"], Fe = ["put", "add", "delete", "clear"], F = /* @__PURE__ */ new Map();
|
|
101
101
|
function te(e, t) {
|
|
102
102
|
if (!(e instanceof IDBDatabase) || t in e || typeof t != "string")
|
|
103
103
|
return;
|
|
104
104
|
if (F.get(t))
|
|
105
105
|
return F.get(t);
|
|
106
|
-
const n = t.replace(/FromIndex$/, ""), a = t !== n, r =
|
|
107
|
-
if (!(n in (a ? IDBIndex : IDBObjectStore).prototype) || !r && !
|
|
106
|
+
const n = t.replace(/FromIndex$/, ""), a = t !== n, r = Fe.includes(n);
|
|
107
|
+
if (!(n in (a ? IDBIndex : IDBObjectStore).prototype) || !r && !He.includes(n))
|
|
108
108
|
return;
|
|
109
109
|
const s = async function(o, ...d) {
|
|
110
110
|
const i = this.transaction(o, r ? "readwrite" : "readonly");
|
|
@@ -114,27 +114,27 @@ function te(e, t) {
|
|
|
114
114
|
return F.set(t, s), s;
|
|
115
115
|
}
|
|
116
116
|
pe((e) => ({ ...e, get: (t, n, a) => te(t, n) || e.get(t, n, a), has: (t, n) => !!te(t, n) || e.has(t, n) }));
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
117
|
+
const je = ["continue", "continuePrimaryKey", "advance"], ne = {}, $ = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), Ve = { get(e, t) {
|
|
118
|
+
if (!je.includes(t))
|
|
119
119
|
return e[t];
|
|
120
120
|
let n = ne[t];
|
|
121
121
|
return n || (n = ne[t] = function(...a) {
|
|
122
122
|
$.set(this, ge.get(this)[t](...a));
|
|
123
123
|
}), n;
|
|
124
124
|
} };
|
|
125
|
-
async function*
|
|
125
|
+
async function* Ke(...e) {
|
|
126
126
|
let t = this;
|
|
127
127
|
if (t instanceof IDBCursor || (t = await t.openCursor(...e)), !t)
|
|
128
128
|
return;
|
|
129
|
-
const n = new Proxy(t,
|
|
129
|
+
const n = new Proxy(t, Ve);
|
|
130
130
|
for (ge.set(n, t), _.set(n, G(t)); t; )
|
|
131
131
|
yield n, t = await ($.get(n) || t.continue()), $.delete(n);
|
|
132
132
|
}
|
|
133
133
|
function ae(e, t) {
|
|
134
134
|
return t === Symbol.asyncIterator && j(e, [IDBIndex, IDBObjectStore, IDBCursor]) || t === "iterate" && j(e, [IDBIndex, IDBObjectStore]);
|
|
135
135
|
}
|
|
136
|
-
pe((e) => ({ ...e, get: (t, n, a) => ae(t, n) ?
|
|
137
|
-
const
|
|
136
|
+
pe((e) => ({ ...e, get: (t, n, a) => ae(t, n) ? Ke : e.get(t, n, a), has: (t, n) => ae(t, n) || e.has(t, n) }));
|
|
137
|
+
const Ge = (e) => {
|
|
138
138
|
if (e instanceof Attr)
|
|
139
139
|
return null;
|
|
140
140
|
let t = 1;
|
|
@@ -165,12 +165,12 @@ const Ke = (e) => {
|
|
|
165
165
|
case Node.ELEMENT_NODE:
|
|
166
166
|
a.name = n.nodeName;
|
|
167
167
|
}
|
|
168
|
-
a.position =
|
|
168
|
+
a.position = Ge(n);
|
|
169
169
|
}
|
|
170
170
|
return "/" + t.reverse().map((n) => n.position !== null ? `/${n.name}[${n.position}]` : `/${n.name}`).join("");
|
|
171
|
-
}, v = { capture: !0, passive: !0 },
|
|
171
|
+
}, v = { capture: !0, passive: !0 }, We = ["a", "button", "input", "option", "li", "link"], $e = ["Escape", "Enter", "Backspace", "F5", "Tab"];
|
|
172
172
|
let A = !1;
|
|
173
|
-
const
|
|
173
|
+
const qe = ["label", "type", "role", "title", "placeholder", "errormessage", "valuetext", "href"], ze = "aria-", re = (e) => {
|
|
174
174
|
var a;
|
|
175
175
|
if (((a = e.tagName) == null ? void 0 : a.toLowerCase()) === "html")
|
|
176
176
|
return { element: "html" };
|
|
@@ -184,15 +184,15 @@ const $e = ["label", "type", "role", "title", "placeholder", "errormessage", "va
|
|
|
184
184
|
for (const r of e.attributes) {
|
|
185
185
|
let s = r.name;
|
|
186
186
|
const o = r.value;
|
|
187
|
-
s.startsWith(
|
|
187
|
+
s.startsWith(ze) && (s = s.substring(5)), qe.includes(s) && (n[s] = o);
|
|
188
188
|
}
|
|
189
189
|
return n;
|
|
190
|
-
},
|
|
190
|
+
}, Je = (e) => {
|
|
191
191
|
var a;
|
|
192
192
|
if (!e)
|
|
193
193
|
return {};
|
|
194
194
|
const t = { ...re(e) }, n = e.parentElement;
|
|
195
|
-
if (n &&
|
|
195
|
+
if (n && We.includes((a = n.tagName) == null ? void 0 : a.toLowerCase())) {
|
|
196
196
|
const r = re(n);
|
|
197
197
|
Object.assign(t, r);
|
|
198
198
|
}
|
|
@@ -200,9 +200,9 @@ const $e = ["label", "type", "role", "title", "placeholder", "errormessage", "va
|
|
|
200
200
|
}, we = (e, t) => {
|
|
201
201
|
var a;
|
|
202
202
|
let n = t.target;
|
|
203
|
-
t.target === ((a = window.document) == null ? void 0 : a.body) && window.Sprig.pointerDownTarget && (n = window.Sprig.pointerDownTarget),
|
|
203
|
+
t.target === ((a = window.document) == null ? void 0 : a.body) && window.Sprig.pointerDownTarget && (n = window.Sprig.pointerDownTarget), Xe({ x: t.x, y: t.y, type: e, elementAttributes: Je(n), windowHeight: window.innerHeight, windowWidth: window.innerWidth, ...n instanceof HTMLElement ? { rect: n == null ? void 0 : n.getBoundingClientRect(), xPath: me(n) } : {} });
|
|
204
204
|
}, ye = (e) => {
|
|
205
|
-
|
|
205
|
+
$e.includes(e.key) && et({ key: e.key });
|
|
206
206
|
}, fe = /* @__PURE__ */ ((e, t) => {
|
|
207
207
|
let n;
|
|
208
208
|
return (a) => {
|
|
@@ -212,17 +212,17 @@ const $e = ["label", "type", "role", "title", "placeholder", "errormessage", "va
|
|
|
212
212
|
if (!(e.target instanceof HTMLElement || e.target instanceof Document))
|
|
213
213
|
return;
|
|
214
214
|
let t = e.target;
|
|
215
|
-
"scrollTop" in t || (t = t.documentElement),
|
|
215
|
+
"scrollTop" in t || (t = t.documentElement), tt({ xPath: me(t), x: t.scrollLeft, y: t.scrollTop, elementAttributes: { targetScrollWidth: t.scrollWidth, targetClientWidth: t.clientWidth, targetScrollHeight: t.scrollHeight, targetClientHeight: t.clientHeight } });
|
|
216
216
|
}, 750), Ie = (se = "left_click", (e) => we(se, e));
|
|
217
217
|
var se;
|
|
218
218
|
const he = (e) => {
|
|
219
219
|
e.button === 2 && we("right_click", e);
|
|
220
220
|
}, ve = (e) => {
|
|
221
221
|
window.Sprig && (window.Sprig.pointerDownTarget = e.target);
|
|
222
|
-
},
|
|
223
|
-
A || (window.addEventListener("click", Ie, v), window.addEventListener("pointerdown", ve, v), window.addEventListener("mousedown", he, v), window.addEventListener("keydown", ye, v), window.addEventListener("scroll", fe, v), A = !0, window.performance.getEntriesByType("navigation").map((e) => e.type).includes("reload") &&
|
|
222
|
+
}, Qe = () => {
|
|
223
|
+
A || (window.addEventListener("click", Ie, v), window.addEventListener("pointerdown", ve, v), window.addEventListener("mousedown", he, v), window.addEventListener("keydown", ye, v), window.addEventListener("scroll", fe, v), A = !0, window.performance.getEntriesByType("navigation").map((e) => e.type).includes("reload") && Ye({ url: window.location.href, currentPageTitle: document.title }), window.performance.getEntriesByType("navigation").map((e) => e.type).includes("back_forward") && Ze({ curUrl: window.location.href, fromUrl: document.referrer, currentPageTitle: document.title }));
|
|
224
224
|
}, p = { isRecording: !1, scrollEventUuids: {}, stopRecording: () => {
|
|
225
|
-
} }, y = (() => {
|
|
225
|
+
} }, De = () => window.indexedDB && window.IDBKeyRange && window.CompressionStream, y = (() => {
|
|
226
226
|
const e = f.getItem("sprig.sessionId");
|
|
227
227
|
if (e)
|
|
228
228
|
return u.info("SessionIDFound", { savedSessionId: e }), f.removeItem("sprig.sessionId"), e;
|
|
@@ -242,16 +242,16 @@ const Y = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(
|
|
|
242
242
|
} catch (r) {
|
|
243
243
|
L("Error recording custom event", r);
|
|
244
244
|
}
|
|
245
|
-
},
|
|
245
|
+
}, Xe = (e) => {
|
|
246
246
|
var t;
|
|
247
247
|
(t = e == null ? void 0 : e.elementAttributes) != null && t.text && (e.elementAttributes.text = Y(e.elementAttributes.text)), D("Sprig_Click", e);
|
|
248
|
-
}, Xe = (e) => {
|
|
249
|
-
D("Sprig_Refresh", e);
|
|
250
248
|
}, Ye = (e) => {
|
|
251
|
-
|
|
249
|
+
D("Sprig_Refresh", e);
|
|
252
250
|
}, Ze = (e) => {
|
|
251
|
+
e.currentPageTitle && (e.currentPageTitle = Y(e.currentPageTitle)), D("Sprig_BackForward", e);
|
|
252
|
+
}, et = (e) => {
|
|
253
253
|
D("Sprig_Keystroke", e);
|
|
254
|
-
},
|
|
254
|
+
}, tt = async (e) => {
|
|
255
255
|
const { x: t, xPath: n, y: a } = e, r = p.scrollEventUuids[n];
|
|
256
256
|
if (r)
|
|
257
257
|
return I(async () => {
|
|
@@ -266,25 +266,25 @@ const Y = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(
|
|
|
266
266
|
D("Sprig_Scroll", e);
|
|
267
267
|
}, "Error updating scroll event");
|
|
268
268
|
D("Sprig_Scroll", e);
|
|
269
|
-
},
|
|
269
|
+
}, be = () => {
|
|
270
270
|
p.stopRecording && (p.stopRecording(), p.stopRecording = void 0), p.isRecording = !1, ["cleanupInterval", "inactivityInterval", "pendingCheckInterval"].forEach((e) => {
|
|
271
271
|
p[e] && (clearInterval(p[e]), p[e] = void 0);
|
|
272
272
|
}), A && (window.removeEventListener("click", Ie, v), window.removeEventListener("pointerdown", ve, v), window.removeEventListener("mousedown", he, v), window.removeEventListener("keydown", ye, v), window.removeEventListener("scroll", fe, v), A = !1);
|
|
273
|
-
},
|
|
273
|
+
}, nt = ["did not allow mutations", "called in an invalid security context"], at = (e, t, { reportError: n = !0, extraInfo: a = {} }) => {
|
|
274
274
|
if (!b() && t instanceof Error) {
|
|
275
275
|
if (q(), t.name === "VersionError")
|
|
276
276
|
return u.error("VersionErr", { message: e }), l.deleteDB();
|
|
277
277
|
((r) => {
|
|
278
278
|
if (!r)
|
|
279
279
|
return !0;
|
|
280
|
-
for (const s of
|
|
280
|
+
for (const s of nt)
|
|
281
281
|
if (r.toLowerCase().includes(s))
|
|
282
282
|
return !1;
|
|
283
283
|
return !0;
|
|
284
284
|
})(t == null ? void 0 : t.message) && (n && window.UserLeap.reportError(e, t, a), l.clearAll());
|
|
285
285
|
}
|
|
286
286
|
}, L = (e, t, { reportError: n } = { reportError: !0 }) => {
|
|
287
|
-
|
|
287
|
+
be(), u.error("ReplayErr", { code: t.code, name: t.name }), at(e, t, { reportError: n });
|
|
288
288
|
}, I = async (e, t) => {
|
|
289
289
|
try {
|
|
290
290
|
await e();
|
|
@@ -292,7 +292,7 @@ const Y = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(
|
|
|
292
292
|
L(t, n);
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
W("replayStorage").catch(console.error), W("sprig.replay").catch(console.error);
|
|
295
|
+
De() && (W("replayStorage").catch(console.error), W("sprig.replay").catch(console.error));
|
|
296
296
|
const l = new class {
|
|
297
297
|
openDB() {
|
|
298
298
|
return function(e, t, { blocked: n, upgrade: a, blocking: r, terminated: s } = {}) {
|
|
@@ -389,7 +389,7 @@ const l = new class {
|
|
|
389
389
|
}
|
|
390
390
|
await n.done;
|
|
391
391
|
}
|
|
392
|
-
}(),
|
|
392
|
+
}(), Se = async (e, t) => {
|
|
393
393
|
const n = performance.now();
|
|
394
394
|
let a;
|
|
395
395
|
try {
|
|
@@ -400,7 +400,7 @@ const l = new class {
|
|
|
400
400
|
s || (s = ce(t)), s.report(r / 1e3);
|
|
401
401
|
}
|
|
402
402
|
return a;
|
|
403
|
-
},
|
|
403
|
+
}, ke = (e, t) => {
|
|
404
404
|
const n = performance.now();
|
|
405
405
|
try {
|
|
406
406
|
e();
|
|
@@ -410,8 +410,8 @@ const l = new class {
|
|
|
410
410
|
r || (r = ce(t)), r.report(a / 1e3);
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
|
-
let
|
|
414
|
-
const
|
|
413
|
+
let Ce = 5e3, z = 6e4, J = 0, C, Q = !1, X = [];
|
|
414
|
+
const rt = (e) => {
|
|
415
415
|
var t, n, a, r;
|
|
416
416
|
if ((t = e.event) != null && t.includes("Sprig_Scroll")) {
|
|
417
417
|
const s = (r = (a = (n = JSON.parse(e.event)) == null ? void 0 : n.data) == null ? void 0 : a.payload) == null ? void 0 : r.xPath;
|
|
@@ -419,13 +419,13 @@ const at = (e) => {
|
|
|
419
419
|
return;
|
|
420
420
|
p.scrollEventUuids[s] = e.uuid;
|
|
421
421
|
}
|
|
422
|
-
X.push(e), Q ||
|
|
423
|
-
},
|
|
422
|
+
X.push(e), Q || st();
|
|
423
|
+
}, st = () => {
|
|
424
424
|
Q = !0, setTimeout(async () => {
|
|
425
425
|
if (b())
|
|
426
426
|
return;
|
|
427
427
|
const e = X;
|
|
428
|
-
X = [], Q = !1,
|
|
428
|
+
X = [], Q = !1, ke(async () => {
|
|
429
429
|
await (async (t) => {
|
|
430
430
|
const n = t.map((a) => ({ ...a, sessionId: a.sessionId ?? y }));
|
|
431
431
|
if (n.length !== 0)
|
|
@@ -433,27 +433,27 @@ const at = (e) => {
|
|
|
433
433
|
})(e);
|
|
434
434
|
}, "sdk_replay_add_event_batch_seconds");
|
|
435
435
|
}, 500);
|
|
436
|
-
},
|
|
436
|
+
}, ot = (e, t, n) => {
|
|
437
437
|
p.cleanupInterval = window.setInterval(() => {
|
|
438
438
|
const a = Date.now();
|
|
439
|
-
|
|
439
|
+
Se(() => I(async () => {
|
|
440
440
|
b() || 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)]);
|
|
441
441
|
}, "Error deleting table rows"), "sdk_replay_cleanup_seconds"), u.debug("CleanupComplete");
|
|
442
442
|
}, 3e4);
|
|
443
|
-
},
|
|
443
|
+
}, it = () => {
|
|
444
444
|
p.pendingCheckInterval = window.setInterval(async () => {
|
|
445
445
|
I(async () => {
|
|
446
|
-
await
|
|
446
|
+
await Ee();
|
|
447
447
|
}, "Error initiating pending captures");
|
|
448
448
|
}, 5e3);
|
|
449
|
-
},
|
|
449
|
+
}, Ee = async (e = !1) => {
|
|
450
450
|
const t = parseInt(C ?? "0");
|
|
451
451
|
if (t === 0)
|
|
452
452
|
return;
|
|
453
453
|
const n = await l.getPendingCaptures({ beforePresent: !0, isBeforeType: e }), a = await l.openDB();
|
|
454
|
-
await Promise.all(n.map(async (r) => (await a.delete("pendingCaptures", r.uuid),
|
|
455
|
-
},
|
|
456
|
-
const s = Math.min(e + r, n), o = await
|
|
454
|
+
await Promise.all(n.map(async (r) => (await a.delete("pendingCaptures", r.uuid), Be(r.captureParams, r.canUpload)))), C = (t - n.length).toString(), f.setItem("sprig.pendingCount", C);
|
|
455
|
+
}, dt = async (e, t, n, a, r) => {
|
|
456
|
+
const s = Math.min(e + r, n), o = await Se(() => l.getEventsBetween(e, s), "sdk_replay_get_events_between_seconds");
|
|
457
457
|
if (!(o != null && o.length))
|
|
458
458
|
return u.debug("NoEventsFound"), { validStartFound: a, events: [] };
|
|
459
459
|
if (!a) {
|
|
@@ -467,7 +467,7 @@ const at = (e) => {
|
|
|
467
467
|
}), d < 0 ? (u.debug("ValidStartNotFound"), { validStartFound: a, events: [] }) : { validStartFound: !0, events: o == null ? void 0 : o.slice(d) };
|
|
468
468
|
}
|
|
469
469
|
return { validStartFound: a, events: o };
|
|
470
|
-
},
|
|
470
|
+
}, Pe = (e) => Promise.all(e.map(async (t) => {
|
|
471
471
|
const n = await (async (a) => ue.execute(async () => {
|
|
472
472
|
var o;
|
|
473
473
|
u.info("UploadChunkStart", { chunkIndex: a.chunkIndex, surveyId: a.surveyId });
|
|
@@ -479,7 +479,7 @@ const at = (e) => {
|
|
|
479
479
|
return s;
|
|
480
480
|
}))(t);
|
|
481
481
|
return await l.updatePartial("chunkUploads", t.uuid, { data: null, etag: n, status: "UploadComplete" }), t.uploadId;
|
|
482
|
-
})),
|
|
482
|
+
})), Re = async (e) => {
|
|
483
483
|
const t = await l.getChunkUploadsByStatus({ status: "UploadComplete", uploadId: e });
|
|
484
484
|
if (!(t != null && t.length))
|
|
485
485
|
return void u.info("NoChunksForUpload", { uploadId: e });
|
|
@@ -487,18 +487,18 @@ const at = (e) => {
|
|
|
487
487
|
n.sort((s, o) => s.chunkIndex - o.chunkIndex);
|
|
488
488
|
const a = n.map((s) => ({ ETag: s.etag, PartNumber: s.chunkIndex })).filter((s) => s.ETag !== null), r = n[0];
|
|
489
489
|
await le({ apiUrl: r.apiUrl, surveyId: r.surveyId, uploadId: e, responseGroupUuid: r.responseGroupId, etags: a, headers: r.completeUploadHeaders, replayDuration: r.replayDuration }), await l.deleteChunkUploads("UploadComplete", e);
|
|
490
|
-
},
|
|
490
|
+
}, ct = () => {
|
|
491
491
|
I(async () => {
|
|
492
492
|
const e = await l.getChunkUploadsByStatus({ sessionId: y, status: "ReadyForUpload" });
|
|
493
493
|
if (!(e != null && e.length))
|
|
494
494
|
return;
|
|
495
|
-
const t = await
|
|
495
|
+
const t = await Pe(e);
|
|
496
496
|
t != null && t.length && await Promise.all(t.map((n) => {
|
|
497
497
|
if (n)
|
|
498
|
-
return
|
|
498
|
+
return Re(n);
|
|
499
499
|
}));
|
|
500
500
|
}, "Error uploading unfinished chunks");
|
|
501
|
-
},
|
|
501
|
+
}, ut = async (e, t) => {
|
|
502
502
|
const n = t ?? Date.now();
|
|
503
503
|
return (async (a, r) => {
|
|
504
504
|
const s = new TextEncoder();
|
|
@@ -506,7 +506,7 @@ const at = (e) => {
|
|
|
506
506
|
const d = new CompressionStream("gzip"), i = d.writable.getWriter();
|
|
507
507
|
let c = !1, w = !1, [g, h] = [0, 0], m = [];
|
|
508
508
|
for (let E = a - 35e3; E < r; E += z) {
|
|
509
|
-
if ({ validStartFound: w, events: m } = await
|
|
509
|
+
if ({ validStartFound: w, events: m } = await dt(E, a, r, w, z), !(m != null && m.length)) {
|
|
510
510
|
u.debug("NoEventsFound");
|
|
511
511
|
continue;
|
|
512
512
|
}
|
|
@@ -514,17 +514,17 @@ const at = (e) => {
|
|
|
514
514
|
const B = m.map((P) => P.event);
|
|
515
515
|
B.push(`{"timestamp":${r}}`);
|
|
516
516
|
const x = `${c ? "," : "["}${B}`, U = s.encode(x);
|
|
517
|
-
|
|
517
|
+
ke(() => {
|
|
518
518
|
i.write(U);
|
|
519
519
|
}, "sdk_replay_compression_seconds"), c = !0;
|
|
520
520
|
}
|
|
521
|
-
if (h - g <
|
|
521
|
+
if (h - g < Ce)
|
|
522
522
|
return u.debug("ReplayTooShort"), null;
|
|
523
523
|
const S = s.encode("]");
|
|
524
524
|
return i.write(S), i.close(), o = new Uint8Array(await new Response(d.readable).arrayBuffer()), o;
|
|
525
525
|
})(n - e, n);
|
|
526
526
|
}, oe = async (e) => {
|
|
527
|
-
const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: s, replayParams: o, triggerTimestamp: d } = e, i = await
|
|
527
|
+
const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: s, replayParams: o, triggerTimestamp: d } = e, i = await ut(1e3 * o.replayDurationSeconds, d);
|
|
528
528
|
if (!(i != null && i.length))
|
|
529
529
|
return void u.info("FileDataEmpty", { surveyId: t });
|
|
530
530
|
const c = ((g, h, m) => {
|
|
@@ -538,9 +538,9 @@ const at = (e) => {
|
|
|
538
538
|
return await (await l.openDB()).add("chunkUploads", { ...S, sessionId: S.sessionId ?? y }), S;
|
|
539
539
|
}));
|
|
540
540
|
await (async (g, h) => {
|
|
541
|
-
await
|
|
541
|
+
await Pe(h), await Promise.all(g.map((m) => Re(m)));
|
|
542
542
|
})([o.uploadId], w);
|
|
543
|
-
},
|
|
543
|
+
}, Be = async (e, t) => {
|
|
544
544
|
if (b())
|
|
545
545
|
return u.debug("ReplayDisabled-ScheduleOrCapture");
|
|
546
546
|
const { isHeatmap: n, isStandalone: a, replayParams: r, triggerTimestamp: s, responseGroupId: o } = e, d = async () => {
|
|
@@ -550,19 +550,19 @@ const at = (e) => {
|
|
|
550
550
|
};
|
|
551
551
|
I(async () => {
|
|
552
552
|
if (r.replayDurationType === "after" || r.replayDurationType === "beforeAndAfter")
|
|
553
|
-
return !a && !n && T.on(O.QuestionAnswered, d), void await
|
|
553
|
+
return !a && !n && T.on(O.QuestionAnswered, d), void await Ue(e);
|
|
554
554
|
if (a || n || t)
|
|
555
|
-
await oe(e), n &&
|
|
555
|
+
await oe(e), n && lt();
|
|
556
556
|
else {
|
|
557
557
|
const i = 35 + r.replayDurationSeconds, c = s - 1e3 * i, w = s;
|
|
558
558
|
await l.updateEventsExpiredAt(c, w, r.expirationTimeLimitMinutes), T.on(O.QuestionAnswered, d);
|
|
559
559
|
}
|
|
560
560
|
}, "Error in scheduling/capturing replay");
|
|
561
|
-
},
|
|
562
|
-
parseInt(C ?? "0") || f.removeItem("sprig.isCapturingHeatmap"), f.getItem("sprig.teardownAfterCapture") && (
|
|
563
|
-
},
|
|
561
|
+
}, lt = async () => {
|
|
562
|
+
parseInt(C ?? "0") || f.removeItem("sprig.isCapturingHeatmap"), f.getItem("sprig.teardownAfterCapture") && (be(), xe(), f.removeItem("sprig.teardownAfterCapture"));
|
|
563
|
+
}, xe = async () => b() ? u.debug("ReplayDisabled-ClearData") : Promise.all([l.deleteBySessionId("events", y), l.deleteBySessionId("pendingCaptures", y)]).catch((e) => {
|
|
564
564
|
L("Error clearing user replay data", e);
|
|
565
|
-
}),
|
|
565
|
+
}), Ue = async (e) => {
|
|
566
566
|
if (b())
|
|
567
567
|
return;
|
|
568
568
|
const { isHeatmap: t, surveyId: n } = e, a = await l.getPendingCaptures(), r = a == null ? void 0 : a.filter((i) => i.captureParams.surveyId === n);
|
|
@@ -580,7 +580,7 @@ const at = (e) => {
|
|
|
580
580
|
const o = e.triggerTimestamp + 1e3 * e.replayParams.replayDurationSeconds;
|
|
581
581
|
s.triggerTimestamp = o, C = (parseInt(C ?? "0") + 1).toString(), f.setItem("sprig.pendingCount", C), await (await l.openDB()).add("pendingCaptures", { canUpload: !1, captureParams: s, sessionId: y, targetTimestamp: o, timestamp: Date.now(), uuid: N() });
|
|
582
582
|
};
|
|
583
|
-
|
|
583
|
+
Le(Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
584
584
|
D("Sprig_TrackEvent", e);
|
|
585
585
|
}, RecordPageView: (e) => {
|
|
586
586
|
e.description && (e.description = Y(e.description)), D("Sprig_PageView", e);
|
|
@@ -592,15 +592,15 @@ Ne(Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
|
592
592
|
const r = window.UserLeap._API_URL, s = await le({ surveyId: e, responseGroupUuid: t, eventDigest: n, apiUrl: r, headers: a }, !0);
|
|
593
593
|
return !(s != null && s.error);
|
|
594
594
|
}, checkPendingHeatmapsUrl: () => b() ? u.debug("ReplayDisabled-PendingHeatmaps") : I(async () => {
|
|
595
|
-
const e = (await l.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !
|
|
595
|
+
const e = (await l.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !Ae(t)).map(({ uuid: t }) => t);
|
|
596
596
|
u.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await l.markPendingHeatmapsReady(e), u.info("MarkedPendingHeatmapsReady"));
|
|
597
|
-
}, "Error marking pending heatmaps ready"), clearUserReplayData:
|
|
597
|
+
}, "Error marking pending heatmaps ready"), clearUserReplayData: xe, disableRecording: L, initializeReplay: async ({ maxReplayDurationSeconds: e, maxInflightRequests: t = 2, replaySettings: n, teardownAfter: a = !1 }) => {
|
|
598
598
|
if (C = f.getItem("sprig.pendingCount"), !p.isRecording) {
|
|
599
599
|
if (a && f.setItem("sprig.teardownAfterCapture", "true"), b())
|
|
600
600
|
return u.debug("ReplayDisabled");
|
|
601
601
|
if (await (async () => {
|
|
602
602
|
var r;
|
|
603
|
-
if (!
|
|
603
|
+
if (!De())
|
|
604
604
|
return !0;
|
|
605
605
|
if ((r = window.navigator.storage) != null && r.estimate)
|
|
606
606
|
try {
|
|
@@ -619,12 +619,12 @@ Ne(Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
|
619
619
|
return u.error("ReplayOpenErr", { name: r.name }), r.name === "VersionError" && l.deleteDB(), q();
|
|
620
620
|
}
|
|
621
621
|
if (I(async () => {
|
|
622
|
-
await
|
|
622
|
+
await Ee(!0);
|
|
623
623
|
}, "Error uploading ready pending captures"), !e)
|
|
624
624
|
return u.debug("MissingDuration");
|
|
625
625
|
u.debug("ReplayInit"), await I(async () => {
|
|
626
626
|
var r;
|
|
627
|
-
if (n != null && n.minDuration && (
|
|
627
|
+
if (n != null && n.minDuration && (Ce = n.minDuration), n != null && n.batchDuration && (z = n.batchDuration), r = t, ue.setLimit(r), ct(), ot(e + 35, 1800, e + 35), it(), !window.rrwebRecord) {
|
|
628
628
|
const { record: i } = await import(
|
|
629
629
|
/* webpackIgnore: true */
|
|
630
630
|
/* @vite-ignore */
|
|
@@ -643,14 +643,14 @@ Ne(Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
|
643
643
|
d = performance.now();
|
|
644
644
|
else if (c && d && i.type === R.FullSnapshot) {
|
|
645
645
|
const g = performance.now() - d;
|
|
646
|
-
|
|
646
|
+
Ne("sdk_replay_snapshot_seconds", g / 1e3);
|
|
647
647
|
}
|
|
648
648
|
const w = o || !!c && i.type === R.Meta;
|
|
649
|
-
o = !1,
|
|
649
|
+
o = !1, rt({ uuid: N(), event: JSON.stringify(i), isValidStart: w, timestamp: Date.now() });
|
|
650
650
|
}, ...n }), p.isRecording = !!p.stopRecording, p.isRecording && (T.on("survey.complete", (i) => {
|
|
651
651
|
var c;
|
|
652
652
|
c = { id: i, userAgent: window.navigator.userAgent }, D("Sprig_SubmitSurvey", c);
|
|
653
|
-
}),
|
|
653
|
+
}), Qe());
|
|
654
654
|
}, "Error initializing replay");
|
|
655
655
|
}
|
|
656
|
-
}, isReplayRecording: () => p.isRecording, scheduleCapture:
|
|
656
|
+
}, isReplayRecording: () => p.isRecording, scheduleCapture: Ue, scheduleOrCaptureReplay: Be, tryReplayAction: I }, Symbol.toStringTag, { value: "Module" })));
|