@sprig-technologies/sprig-browser 2.32.2 → 2.32.4
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-BuTAnr1A.cjs +12 -0
- package/dist/core-DX7Qkopv.js +1000 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +4 -0
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -2
- package/dist/metricsReporter-CHOlWEKF.cjs +1 -0
- package/dist/{metricsReporter-D0VZ2ZgI.js → metricsReporter-Dh_342TQ.js} +46 -29
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +149 -144
- package/dist/view-BkqDP9V8.js +2841 -0
- package/dist/view-CZBsyFUR.cjs +669 -0
- package/package.json +1 -1
- package/dist/core-D-LZZjJw.cjs +0 -12
- package/dist/core-DJ-C8ZCy.js +0 -983
- package/dist/metricsReporter-CiE5uf1B.cjs +0 -1
- package/dist/view-CDdG2lXT.js +0 -2830
- package/dist/view-CW-37QDp.cjs +0 -669
package/dist/replay.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
|
|
5
|
-
var
|
|
1
|
+
var Ue = Object.defineProperty;
|
|
2
|
+
var Te = (e, t, n) => t in e ? Ue(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var M = (e, t, n) => (Te(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
+
import { b as u, s as ie, a as f, v as N, c as _e, P as de, r as ce, d as Ae, e as T, S as O, f as Ne } from "./metricsReporter-Dh_342TQ.js";
|
|
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) {
|
|
8
8
|
M(this, "awaitingResolvers", []);
|
|
@@ -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 Le(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 Me(e) {
|
|
63
|
+
return typeof e == "function" ? Le(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 = Me(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 Oe = ["get", "getKey", "getAll", "getAllKeys", "count"], He = ["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 = He.includes(n);
|
|
107
|
+
if (!(n in (a ? IDBIndex : IDBObjectStore).prototype) || !r && !Oe.includes(n))
|
|
108
108
|
return;
|
|
109
109
|
const s = async function(o, ...d) {
|
|
110
110
|
const i = this.transaction(o, r ? "readwrite" : "readonly");
|
|
@@ -114,34 +114,34 @@ 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 Fe = ["continue", "continuePrimaryKey", "advance"], ne = {}, $ = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), je = { get(e, t) {
|
|
118
|
+
if (!Fe.includes(t))
|
|
119
119
|
return e[t];
|
|
120
120
|
let n = ne[t];
|
|
121
121
|
return n || (n = ne[t] = function(...a) {
|
|
122
|
-
$.set(this,
|
|
122
|
+
$.set(this, ge.get(this)[t](...a));
|
|
123
123
|
}), n;
|
|
124
124
|
} };
|
|
125
|
-
async function*
|
|
125
|
+
async function* Ve(...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,
|
|
130
|
-
for (
|
|
129
|
+
const n = new Proxy(t, je);
|
|
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) ? Ve : e.get(t, n, a), has: (t, n) => ae(t, n) || e.has(t, n) }));
|
|
137
|
+
const Ke = (e) => {
|
|
138
138
|
if (e instanceof Attr)
|
|
139
139
|
return null;
|
|
140
140
|
let t = 1;
|
|
141
141
|
for (let n = e.previousSibling; n; n = n.previousSibling)
|
|
142
142
|
n.nodeName === e.nodeName && ++t;
|
|
143
143
|
return t;
|
|
144
|
-
},
|
|
144
|
+
}, me = (e) => {
|
|
145
145
|
if (e === null)
|
|
146
146
|
return "";
|
|
147
147
|
const t = [];
|
|
@@ -165,12 +165,12 @@ const je = (e) => {
|
|
|
165
165
|
case Node.ELEMENT_NODE:
|
|
166
166
|
a.name = n.nodeName;
|
|
167
167
|
}
|
|
168
|
-
a.position =
|
|
168
|
+
a.position = Ke(n);
|
|
169
169
|
}
|
|
170
170
|
return "/" + t.reverse().map((n) => n.position !== null ? `/${n.name}[${n.position}]` : `/${n.name}`).join("");
|
|
171
|
-
},
|
|
171
|
+
}, v = { capture: !0, passive: !0 }, Ge = ["a", "button", "input", "option", "li", "link"], We = ["Escape", "Enter", "Backspace", "F5", "Tab"];
|
|
172
172
|
let A = !1;
|
|
173
|
-
const
|
|
173
|
+
const $e = ["label", "type", "role", "title", "placeholder", "errormessage", "valuetext", "href"], qe = "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,24 +184,25 @@ const Ge = ["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(qe) && (s = s.substring(5)), $e.includes(s) && (n[s] = o);
|
|
188
188
|
}
|
|
189
189
|
return n;
|
|
190
|
-
},
|
|
190
|
+
}, ze = (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 && Ge.includes((a = n.tagName) == null ? void 0 : a.toLowerCase())) {
|
|
196
196
|
const r = re(n);
|
|
197
197
|
Object.assign(t, r);
|
|
198
198
|
}
|
|
199
199
|
return t;
|
|
200
200
|
}, we = (e, t) => {
|
|
201
|
-
var
|
|
202
|
-
|
|
201
|
+
var a;
|
|
202
|
+
let n = t.target;
|
|
203
|
+
t.target === ((a = window.document) == null ? void 0 : a.body) && window.Sprig.pointerDownTarget && (n = window.Sprig.pointerDownTarget), Qe({ x: t.x, y: t.y, type: e, elementAttributes: ze(n), windowHeight: window.innerHeight, windowWidth: window.innerWidth, ...n instanceof HTMLElement ? { rect: n == null ? void 0 : n.getBoundingClientRect(), xPath: me(n) } : {} });
|
|
203
204
|
}, ye = (e) => {
|
|
204
|
-
|
|
205
|
+
We.includes(e.key) && Ze({ key: e.key });
|
|
205
206
|
}, fe = /* @__PURE__ */ ((e, t) => {
|
|
206
207
|
let n;
|
|
207
208
|
return (a) => {
|
|
@@ -211,13 +212,15 @@ const Ge = ["label", "type", "role", "title", "placeholder", "errormessage", "va
|
|
|
211
212
|
if (!(e.target instanceof HTMLElement || e.target instanceof Document))
|
|
212
213
|
return;
|
|
213
214
|
let t = e.target;
|
|
214
|
-
"scrollTop" in t || (t = t.documentElement),
|
|
215
|
+
"scrollTop" in t || (t = t.documentElement), et({ xPath: me(t), x: t.scrollLeft, y: t.scrollTop, elementAttributes: { targetScrollWidth: t.scrollWidth, targetClientWidth: t.clientWidth, targetScrollHeight: t.scrollHeight, targetClientHeight: t.clientHeight } });
|
|
215
216
|
}, 750), Ie = (se = "left_click", (e) => we(se, e));
|
|
216
217
|
var se;
|
|
217
218
|
const he = (e) => {
|
|
218
219
|
e.button === 2 && we("right_click", e);
|
|
219
|
-
},
|
|
220
|
-
|
|
220
|
+
}, ve = (e) => {
|
|
221
|
+
window.Sprig && (window.Sprig.pointerDownTarget = e.target);
|
|
222
|
+
}, Je = () => {
|
|
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") && Xe({ url: window.location.href, currentPageTitle: document.title }), window.performance.getEntriesByType("navigation").map((e) => e.type).includes("back_forward") && Ye({ curUrl: window.location.href, fromUrl: document.referrer, currentPageTitle: document.title }));
|
|
221
224
|
}, p = { isRecording: !1, scrollEventUuids: {}, stopRecording: () => {
|
|
222
225
|
} }, y = (() => {
|
|
223
226
|
const e = f.getItem("sprig.sessionId");
|
|
@@ -227,62 +230,62 @@ const he = (e) => {
|
|
|
227
230
|
return u.info("GeneratedSessionID", { uuid: t }), t;
|
|
228
231
|
})(), q = () => {
|
|
229
232
|
f.setItem("sprig.disableReplayRecording", "disabled");
|
|
230
|
-
},
|
|
233
|
+
}, b = () => !!f.getItem("sprig.disableReplayRecording");
|
|
231
234
|
window.addEventListener("beforeunload", () => {
|
|
232
235
|
u.info("BeforeUnload", { sessionId: y }), f.setItem("sprig.sessionId", y);
|
|
233
236
|
});
|
|
234
|
-
const Y = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(/\r?\n|\r/g, " ").substring(0, 250),
|
|
237
|
+
const Y = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(/\r?\n|\r/g, " ").substring(0, 250), D = (e, t) => {
|
|
235
238
|
var n, a;
|
|
236
|
-
if (!
|
|
239
|
+
if (!b() && p.isRecording)
|
|
237
240
|
try {
|
|
238
241
|
(a = (n = window.rrwebRecord) == null ? void 0 : n.addCustomEvent) == null || a.call(n, e, t);
|
|
239
242
|
} catch (r) {
|
|
240
243
|
L("Error recording custom event", r);
|
|
241
244
|
}
|
|
242
|
-
}, ze = (e) => {
|
|
243
|
-
var t;
|
|
244
|
-
(t = e == null ? void 0 : e.elementAttributes) != null && t.text && (e.elementAttributes.text = Y(e.elementAttributes.text)), v("Sprig_Click", e);
|
|
245
|
-
}, Je = (e) => {
|
|
246
|
-
v("Sprig_Refresh", e);
|
|
247
245
|
}, Qe = (e) => {
|
|
248
|
-
|
|
246
|
+
var t;
|
|
247
|
+
(t = e == null ? void 0 : e.elementAttributes) != null && t.text && (e.elementAttributes.text = Y(e.elementAttributes.text)), D("Sprig_Click", e);
|
|
249
248
|
}, Xe = (e) => {
|
|
250
|
-
|
|
251
|
-
}, Ye =
|
|
249
|
+
D("Sprig_Refresh", e);
|
|
250
|
+
}, Ye = (e) => {
|
|
251
|
+
e.currentPageTitle && (e.currentPageTitle = Y(e.currentPageTitle)), D("Sprig_BackForward", e);
|
|
252
|
+
}, Ze = (e) => {
|
|
253
|
+
D("Sprig_Keystroke", e);
|
|
254
|
+
}, et = async (e) => {
|
|
252
255
|
const { x: t, xPath: n, y: a } = e, r = p.scrollEventUuids[n];
|
|
253
256
|
if (r)
|
|
254
|
-
return
|
|
257
|
+
return I(async () => {
|
|
255
258
|
var d, i, c, w;
|
|
256
259
|
const s = await l.openDB(), o = await s.get("events", r);
|
|
257
260
|
if (o != null && o.event) {
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
261
|
+
const g = JSON.parse(o.event), h = t > ((i = (d = g.data) == null ? void 0 : d.payload) == null ? void 0 : i.x), m = a > ((w = (c = g.data) == null ? void 0 : c.payload) == null ? void 0 : w.y);
|
|
262
|
+
if (!h && !m)
|
|
260
263
|
return null;
|
|
261
|
-
|
|
264
|
+
h && (g.data.payload.x = t), m && (g.data.payload.y = a), g.data.payload.elementAttributes = e.elementAttributes, o.event = JSON.stringify(g), await s.put("events", o);
|
|
262
265
|
} else
|
|
263
|
-
|
|
266
|
+
D("Sprig_Scroll", e);
|
|
264
267
|
}, "Error updating scroll event");
|
|
265
|
-
|
|
266
|
-
},
|
|
268
|
+
D("Sprig_Scroll", e);
|
|
269
|
+
}, De = () => {
|
|
267
270
|
p.stopRecording && (p.stopRecording(), p.stopRecording = void 0), p.isRecording = !1, ["cleanupInterval", "inactivityInterval", "pendingCheckInterval"].forEach((e) => {
|
|
268
271
|
p[e] && (clearInterval(p[e]), p[e] = void 0);
|
|
269
|
-
}), A && (window.removeEventListener("click", Ie,
|
|
270
|
-
},
|
|
271
|
-
if (!
|
|
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
|
+
}, tt = ["did not allow mutations", "called in an invalid security context"], nt = (e, t, { reportError: n = !0, extraInfo: a = {} }) => {
|
|
274
|
+
if (!b() && t instanceof Error) {
|
|
272
275
|
if (q(), t.name === "VersionError")
|
|
273
276
|
return u.error("VersionErr", { message: e }), l.deleteDB();
|
|
274
277
|
((r) => {
|
|
275
278
|
if (!r)
|
|
276
279
|
return !0;
|
|
277
|
-
for (const s of
|
|
280
|
+
for (const s of tt)
|
|
278
281
|
if (r.toLowerCase().includes(s))
|
|
279
282
|
return !1;
|
|
280
283
|
return !0;
|
|
281
284
|
})(t == null ? void 0 : t.message) && (n && window.UserLeap.reportError(e, t, a), l.clearAll());
|
|
282
285
|
}
|
|
283
286
|
}, L = (e, t, { reportError: n } = { reportError: !0 }) => {
|
|
284
|
-
|
|
285
|
-
},
|
|
287
|
+
De(), u.error("ReplayErr", { code: t.code, name: t.name }), nt(e, t, { reportError: n });
|
|
288
|
+
}, I = async (e, t) => {
|
|
286
289
|
try {
|
|
287
290
|
await e();
|
|
288
291
|
} catch (n) {
|
|
@@ -366,7 +369,7 @@ const l = new class {
|
|
|
366
369
|
return r.getAll(s);
|
|
367
370
|
}
|
|
368
371
|
async getPendingCaptures(e = {}) {
|
|
369
|
-
return (await (await this.openDB()).getAllFromIndex("pendingCaptures", "sessionId", y)).filter((n) => !e.beforePresent || n.targetTimestamp < Date.now()).filter((n) => !e.isHeatmap || (n.captureParams.isHeatmap ?? !1));
|
|
372
|
+
return (await (await this.openDB()).getAllFromIndex("pendingCaptures", "sessionId", y)).filter((n) => !e.beforePresent || n.targetTimestamp < Date.now()).filter((n) => !e.isBeforeType || n.captureParams.replayParams.replayDurationType === "before").filter((n) => !e.isHeatmap || (n.captureParams.isHeatmap ?? !1));
|
|
370
373
|
}
|
|
371
374
|
async markPendingCaptureToCanUpload(e) {
|
|
372
375
|
const t = (await this.openDB()).transaction("pendingCaptures", "readwrite"), n = t.store.index("sessionId");
|
|
@@ -386,7 +389,7 @@ const l = new class {
|
|
|
386
389
|
}
|
|
387
390
|
await n.done;
|
|
388
391
|
}
|
|
389
|
-
}(),
|
|
392
|
+
}(), be = async (e, t) => {
|
|
390
393
|
const n = performance.now();
|
|
391
394
|
let a;
|
|
392
395
|
try {
|
|
@@ -397,7 +400,7 @@ const l = new class {
|
|
|
397
400
|
s || (s = ce(t)), s.report(r / 1e3);
|
|
398
401
|
}
|
|
399
402
|
return a;
|
|
400
|
-
},
|
|
403
|
+
}, Se = (e, t) => {
|
|
401
404
|
const n = performance.now();
|
|
402
405
|
try {
|
|
403
406
|
e();
|
|
@@ -407,8 +410,8 @@ const l = new class {
|
|
|
407
410
|
r || (r = ce(t)), r.report(a / 1e3);
|
|
408
411
|
}
|
|
409
412
|
};
|
|
410
|
-
let
|
|
411
|
-
const
|
|
413
|
+
let ke = 5e3, z = 6e4, J = 0, C, Q = !1, X = [];
|
|
414
|
+
const at = (e) => {
|
|
412
415
|
var t, n, a, r;
|
|
413
416
|
if ((t = e.event) != null && t.includes("Sprig_Scroll")) {
|
|
414
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;
|
|
@@ -416,39 +419,41 @@ const tt = (e) => {
|
|
|
416
419
|
return;
|
|
417
420
|
p.scrollEventUuids[s] = e.uuid;
|
|
418
421
|
}
|
|
419
|
-
X.push(e), Q ||
|
|
420
|
-
},
|
|
422
|
+
X.push(e), Q || rt();
|
|
423
|
+
}, rt = () => {
|
|
421
424
|
Q = !0, setTimeout(async () => {
|
|
422
|
-
if (
|
|
425
|
+
if (b())
|
|
423
426
|
return;
|
|
424
427
|
const e = X;
|
|
425
|
-
X = [], Q = !1,
|
|
428
|
+
X = [], Q = !1, Se(async () => {
|
|
426
429
|
await (async (t) => {
|
|
427
430
|
const n = t.map((a) => ({ ...a, sessionId: a.sessionId ?? y }));
|
|
428
431
|
if (n.length !== 0)
|
|
429
|
-
return
|
|
432
|
+
return I(() => l.bulkAdd("events", n), "Error storing replay events");
|
|
430
433
|
})(e);
|
|
431
434
|
}, "sdk_replay_add_event_batch_seconds");
|
|
432
435
|
}, 500);
|
|
433
|
-
},
|
|
436
|
+
}, st = (e, t, n) => {
|
|
434
437
|
p.cleanupInterval = window.setInterval(() => {
|
|
435
438
|
const a = Date.now();
|
|
436
|
-
|
|
437
|
-
|
|
439
|
+
be(() => I(async () => {
|
|
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)]);
|
|
438
441
|
}, "Error deleting table rows"), "sdk_replay_cleanup_seconds"), u.debug("CleanupComplete");
|
|
439
442
|
}, 3e4);
|
|
440
|
-
},
|
|
443
|
+
}, ot = () => {
|
|
441
444
|
p.pendingCheckInterval = window.setInterval(async () => {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
if (e === 0)
|
|
445
|
-
return;
|
|
446
|
-
const t = await l.getPendingCaptures({ beforePresent: !0 }), n = await l.openDB();
|
|
447
|
-
await Promise.all(t.map(async (a) => (await n.delete("pendingCaptures", a.uuid), Ee(a.captureParams, a.canUpload)))), C = (e - t.length).toString(), f.setItem("sprig.pendingCount", C);
|
|
445
|
+
I(async () => {
|
|
446
|
+
await Ce();
|
|
448
447
|
}, "Error initiating pending captures");
|
|
449
448
|
}, 5e3);
|
|
450
|
-
},
|
|
451
|
-
const
|
|
449
|
+
}, Ce = async (e = !1) => {
|
|
450
|
+
const t = parseInt(C ?? "0");
|
|
451
|
+
if (t === 0)
|
|
452
|
+
return;
|
|
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), Re(r.captureParams, r.canUpload)))), C = (t - n.length).toString(), f.setItem("sprig.pendingCount", C);
|
|
455
|
+
}, it = async (e, t, n, a, r) => {
|
|
456
|
+
const s = Math.min(e + r, n), o = await be(() => l.getEventsBetween(e, s), "sdk_replay_get_events_between_seconds");
|
|
452
457
|
if (!(o != null && o.length))
|
|
453
458
|
return u.debug("NoEventsFound"), { validStartFound: a, events: [] };
|
|
454
459
|
if (!a) {
|
|
@@ -462,7 +467,7 @@ const tt = (e) => {
|
|
|
462
467
|
}), d < 0 ? (u.debug("ValidStartNotFound"), { validStartFound: a, events: [] }) : { validStartFound: !0, events: o == null ? void 0 : o.slice(d) };
|
|
463
468
|
}
|
|
464
469
|
return { validStartFound: a, events: o };
|
|
465
|
-
},
|
|
470
|
+
}, Ee = (e) => Promise.all(e.map(async (t) => {
|
|
466
471
|
const n = await (async (a) => ue.execute(async () => {
|
|
467
472
|
var o;
|
|
468
473
|
u.info("UploadChunkStart", { chunkIndex: a.chunkIndex, surveyId: a.surveyId });
|
|
@@ -474,7 +479,7 @@ const tt = (e) => {
|
|
|
474
479
|
return s;
|
|
475
480
|
}))(t);
|
|
476
481
|
return await l.updatePartial("chunkUploads", t.uuid, { data: null, etag: n, status: "UploadComplete" }), t.uploadId;
|
|
477
|
-
})),
|
|
482
|
+
})), Pe = async (e) => {
|
|
478
483
|
const t = await l.getChunkUploadsByStatus({ status: "UploadComplete", uploadId: e });
|
|
479
484
|
if (!(t != null && t.length))
|
|
480
485
|
return void u.info("NoChunksForUpload", { uploadId: e });
|
|
@@ -482,118 +487,116 @@ const tt = (e) => {
|
|
|
482
487
|
n.sort((s, o) => s.chunkIndex - o.chunkIndex);
|
|
483
488
|
const a = n.map((s) => ({ ETag: s.etag, PartNumber: s.chunkIndex })).filter((s) => s.ETag !== null), r = n[0];
|
|
484
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);
|
|
485
|
-
},
|
|
486
|
-
|
|
490
|
+
}, dt = () => {
|
|
491
|
+
I(async () => {
|
|
487
492
|
const e = await l.getChunkUploadsByStatus({ sessionId: y, status: "ReadyForUpload" });
|
|
488
493
|
if (!(e != null && e.length))
|
|
489
494
|
return;
|
|
490
|
-
const t = await
|
|
495
|
+
const t = await Ee(e);
|
|
491
496
|
t != null && t.length && await Promise.all(t.map((n) => {
|
|
492
497
|
if (n)
|
|
493
|
-
return
|
|
498
|
+
return Pe(n);
|
|
494
499
|
}));
|
|
495
500
|
}, "Error uploading unfinished chunks");
|
|
496
|
-
},
|
|
501
|
+
}, ct = async (e, t) => {
|
|
497
502
|
const n = t ?? Date.now();
|
|
498
503
|
return (async (a, r) => {
|
|
499
504
|
const s = new TextEncoder();
|
|
500
505
|
let o = null;
|
|
501
506
|
const d = new CompressionStream("gzip"), i = d.writable.getWriter();
|
|
502
|
-
let c = !1, w = !1, [
|
|
507
|
+
let c = !1, w = !1, [g, h] = [0, 0], m = [];
|
|
503
508
|
for (let E = a - 35e3; E < r; E += z) {
|
|
504
|
-
if ({ validStartFound: w, events:
|
|
509
|
+
if ({ validStartFound: w, events: m } = await it(E, a, r, w, z), !(m != null && m.length)) {
|
|
505
510
|
u.debug("NoEventsFound");
|
|
506
511
|
continue;
|
|
507
512
|
}
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
+
g === 0 && (g = m[0].timestamp), h = m[m.length - 1].timestamp;
|
|
514
|
+
const B = m.map((P) => P.event);
|
|
515
|
+
B.push(`{"timestamp":${r}}`);
|
|
516
|
+
const x = `${c ? "," : "["}${B}`, U = s.encode(x);
|
|
517
|
+
Se(() => {
|
|
513
518
|
i.write(U);
|
|
514
519
|
}, "sdk_replay_compression_seconds"), c = !0;
|
|
515
520
|
}
|
|
516
|
-
if (
|
|
521
|
+
if (h - g < ke)
|
|
517
522
|
return u.debug("ReplayTooShort"), null;
|
|
518
|
-
const
|
|
519
|
-
return i.write(
|
|
523
|
+
const S = s.encode("]");
|
|
524
|
+
return i.write(S), i.close(), o = new Uint8Array(await new Response(d.readable).arrayBuffer()), o;
|
|
520
525
|
})(n - e, n);
|
|
521
526
|
}, oe = async (e) => {
|
|
522
|
-
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 ct(1e3 * o.replayDurationSeconds, d);
|
|
523
528
|
if (!(i != null && i.length))
|
|
524
529
|
return void u.info("FileDataEmpty", { surveyId: t });
|
|
525
|
-
const c = ((
|
|
526
|
-
const
|
|
527
|
-
let
|
|
528
|
-
for (;
|
|
529
|
-
U.push(
|
|
530
|
+
const c = ((g, h, m) => {
|
|
531
|
+
const S = g.length, E = 1024 * h * 1024, B = Math.ceil(S / m), x = Math.max(E, B), U = [];
|
|
532
|
+
let P = 0;
|
|
533
|
+
for (; P < S; )
|
|
534
|
+
U.push(g.slice(P, P + x)), P += x;
|
|
530
535
|
return U;
|
|
531
|
-
})(i, o.minimumChunkSizeMb, o.signedUrls.length), w = await Promise.all(c.map(async (
|
|
532
|
-
const
|
|
533
|
-
return await (await l.openDB()).add("chunkUploads", { ...
|
|
536
|
+
})(i, o.minimumChunkSizeMb, o.signedUrls.length), w = await Promise.all(c.map(async (g, h) => {
|
|
537
|
+
const m = N(), S = { apiUrl: r, chunkIndex: h + 1, completeUploadHeaders: s, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: d, totalChunks: c.length, data: g, uploadId: o.uploadId, uploadUrl: o.signedUrls[h].url, uuid: m, visitorId: a };
|
|
538
|
+
return await (await l.openDB()).add("chunkUploads", { ...S, sessionId: S.sessionId ?? y }), S;
|
|
534
539
|
}));
|
|
535
|
-
await (async (
|
|
536
|
-
await
|
|
540
|
+
await (async (g, h) => {
|
|
541
|
+
await Ee(h), await Promise.all(g.map((m) => Pe(m)));
|
|
537
542
|
})([o.uploadId], w);
|
|
538
|
-
},
|
|
539
|
-
if (
|
|
543
|
+
}, Re = async (e, t) => {
|
|
544
|
+
if (b())
|
|
540
545
|
return u.debug("ReplayDisabled-ScheduleOrCapture");
|
|
541
546
|
const { isHeatmap: n, isStandalone: a, replayParams: r, triggerTimestamp: s, responseGroupId: o } = e, d = async () => {
|
|
542
|
-
setTimeout(() => T.removeListener(O.QuestionAnswered, d), 0),
|
|
547
|
+
setTimeout(() => T.removeListener(O.QuestionAnswered, d), 0), I(async () => {
|
|
543
548
|
r.replayDurationType === "before" ? await oe(e) : await l.markPendingCaptureToCanUpload(o);
|
|
544
549
|
}, "Error in schedule/capture callback");
|
|
545
550
|
};
|
|
546
|
-
|
|
551
|
+
I(async () => {
|
|
547
552
|
if (r.replayDurationType === "after" || r.replayDurationType === "beforeAndAfter")
|
|
548
|
-
return !a && !n && T.on(O.QuestionAnswered, d), void await
|
|
553
|
+
return !a && !n && T.on(O.QuestionAnswered, d), void await xe(e);
|
|
549
554
|
if (a || n || t)
|
|
550
|
-
await oe(e), n &&
|
|
555
|
+
await oe(e), n && ut();
|
|
551
556
|
else {
|
|
552
557
|
const i = 35 + r.replayDurationSeconds, c = s - 1e3 * i, w = s;
|
|
553
558
|
await l.updateEventsExpiredAt(c, w, r.expirationTimeLimitMinutes), T.on(O.QuestionAnswered, d);
|
|
554
559
|
}
|
|
555
560
|
}, "Error in scheduling/capturing replay");
|
|
556
|
-
},
|
|
557
|
-
parseInt(C ?? "0") || f.removeItem("sprig.isCapturingHeatmap"), f.getItem("sprig.teardownAfterCapture") && (
|
|
558
|
-
},
|
|
561
|
+
}, ut = async () => {
|
|
562
|
+
parseInt(C ?? "0") || f.removeItem("sprig.isCapturingHeatmap"), f.getItem("sprig.teardownAfterCapture") && (De(), Be(), f.removeItem("sprig.teardownAfterCapture"));
|
|
563
|
+
}, Be = async () => b() ? u.debug("ReplayDisabled-ClearData") : Promise.all([l.deleteBySessionId("events", y), l.deleteBySessionId("pendingCaptures", y)]).catch((e) => {
|
|
559
564
|
L("Error clearing user replay data", e);
|
|
560
|
-
}),
|
|
561
|
-
if (
|
|
565
|
+
}), xe = async (e) => {
|
|
566
|
+
if (b())
|
|
562
567
|
return;
|
|
563
568
|
const { isHeatmap: t, surveyId: n } = e, a = await l.getPendingCaptures(), r = a == null ? void 0 : a.filter((i) => i.captureParams.surveyId === n);
|
|
564
569
|
if (r != null && r.length)
|
|
565
570
|
return void u.info("PendingCaptureExists", { surveyId: n });
|
|
566
|
-
t && (p.isRecording &&
|
|
571
|
+
t && (p.isRecording && I(() => {
|
|
567
572
|
var i, c;
|
|
568
573
|
return (c = (i = window.rrwebRecord) == null ? void 0 : i.takeFullSnapshot) == null ? void 0 : c.call(i, !0);
|
|
569
574
|
}, "Error recording full snapshot"), f.setItem("sprig.isCapturingHeatmap", "true"), J = Date.now(), p.inactivityInterval || (p.inactivityInterval = window.setInterval(() => {
|
|
570
575
|
var i;
|
|
571
|
-
i = J, Date.now() - i >= 3e4 &&
|
|
576
|
+
i = J, Date.now() - i >= 3e4 && I(() => l.markPendingHeatmapsReady(), "Error in heatmap inactivity");
|
|
572
577
|
}, 1e3)));
|
|
573
578
|
const s = { ...e, replayParams: { ...e.replayParams } };
|
|
574
579
|
e.replayParams.replayDurationType === "beforeAndAfter" && (s.replayParams.replayDurationSeconds *= 2), s.replayParams.replayDurationType = "before";
|
|
575
580
|
const o = e.triggerTimestamp + 1e3 * e.replayParams.replayDurationSeconds;
|
|
576
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() });
|
|
577
582
|
};
|
|
578
|
-
|
|
579
|
-
|
|
583
|
+
Ne(Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
584
|
+
D("Sprig_TrackEvent", e);
|
|
580
585
|
}, RecordPageView: (e) => {
|
|
581
|
-
e.description && (e.description = Y(e.description)),
|
|
586
|
+
e.description && (e.description = Y(e.description)), D("Sprig_PageView", e);
|
|
582
587
|
}, RecordSurveyShown: (e) => {
|
|
583
|
-
|
|
588
|
+
D("Sprig_ShowSurvey", e);
|
|
584
589
|
}, _completeSessionReplay: async ({ surveyId: e, responseGroupUuid: t, eventDigest: n, headers: a }) => {
|
|
585
590
|
if (!e || !t)
|
|
586
591
|
return !1;
|
|
587
592
|
const r = window.UserLeap._API_URL, s = await le({ surveyId: e, responseGroupUuid: t, eventDigest: n, apiUrl: r, headers: a }, !0);
|
|
588
593
|
return !(s != null && s.error);
|
|
589
|
-
}, checkPendingHeatmapsUrl: () =>
|
|
590
|
-
const e = (await l.getPendingCaptures({ isHeatmap: !0 })).map((
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
}), t.length && await l.markPendingHeatmapsReady(t);
|
|
594
|
-
}, "Error marking pending heatmaps ready"), clearUserReplayData: Re, disableRecording: L, initializeReplay: async ({ maxReplayDurationSeconds: e, maxInflightRequests: t = 2, replaySettings: n, teardownAfter: a = !1 }) => {
|
|
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 }) => !_e(t)).map(({ uuid: t }) => t);
|
|
596
|
+
u.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await l.markPendingHeatmapsReady(e), u.info("MarkedPendingHeatmapsReady"));
|
|
597
|
+
}, "Error marking pending heatmaps ready"), clearUserReplayData: Be, disableRecording: L, initializeReplay: async ({ maxReplayDurationSeconds: e, maxInflightRequests: t = 2, replaySettings: n, teardownAfter: a = !1 }) => {
|
|
595
598
|
if (C = f.getItem("sprig.pendingCount"), !p.isRecording) {
|
|
596
|
-
if (a && f.setItem("sprig.teardownAfterCapture", "true"),
|
|
599
|
+
if (a && f.setItem("sprig.teardownAfterCapture", "true"), b())
|
|
597
600
|
return u.debug("ReplayDisabled");
|
|
598
601
|
if (await (async () => {
|
|
599
602
|
var r;
|
|
@@ -615,11 +618,13 @@ _e(Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
|
615
618
|
} catch (r) {
|
|
616
619
|
return u.error("ReplayOpenErr", { name: r.name }), r.name === "VersionError" && l.deleteDB(), q();
|
|
617
620
|
}
|
|
618
|
-
if (
|
|
621
|
+
if (I(async () => {
|
|
622
|
+
await Ce(!0);
|
|
623
|
+
}, "Error uploading ready pending captures"), !e)
|
|
619
624
|
return u.debug("MissingDuration");
|
|
620
|
-
u.debug("ReplayInit"), await
|
|
625
|
+
u.debug("ReplayInit"), await I(async () => {
|
|
621
626
|
var r;
|
|
622
|
-
if (n != null && n.minDuration && (
|
|
627
|
+
if (n != null && n.minDuration && (ke = n.minDuration), n != null && n.batchDuration && (z = n.batchDuration), r = t, ue.setLimit(r), dt(), st(e + 35, 1800, e + 35), ot(), !window.rrwebRecord) {
|
|
623
628
|
const { record: i } = await import(
|
|
624
629
|
/* webpackIgnore: true */
|
|
625
630
|
/* @vite-ignore */
|
|
@@ -632,20 +637,20 @@ _e(Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
|
632
637
|
return u.error("RecordScriptFailed");
|
|
633
638
|
let o = !0, d = 0;
|
|
634
639
|
p.stopRecording = s({ checkoutEveryNms: 3e4, sampling: { input: "last", scroll: 250, media: 800 }, emit: (i, c) => {
|
|
635
|
-
if (i.type ===
|
|
640
|
+
if (i.type === R.Custom && (J = Date.now()), b())
|
|
636
641
|
return;
|
|
637
|
-
if (c && i.type ===
|
|
642
|
+
if (c && i.type === R.Meta)
|
|
638
643
|
d = performance.now();
|
|
639
|
-
else if (c && d && i.type ===
|
|
640
|
-
const
|
|
641
|
-
|
|
644
|
+
else if (c && d && i.type === R.FullSnapshot) {
|
|
645
|
+
const g = performance.now() - d;
|
|
646
|
+
Ae("sdk_replay_snapshot_seconds", g / 1e3);
|
|
642
647
|
}
|
|
643
|
-
const w = o || !!c && i.type ===
|
|
644
|
-
o = !1,
|
|
648
|
+
const w = o || !!c && i.type === R.Meta;
|
|
649
|
+
o = !1, at({ uuid: N(), event: JSON.stringify(i), isValidStart: w, timestamp: Date.now() });
|
|
645
650
|
}, ...n }), p.isRecording = !!p.stopRecording, p.isRecording && (T.on("survey.complete", (i) => {
|
|
646
651
|
var c;
|
|
647
|
-
c = { id: i, userAgent: window.navigator.userAgent },
|
|
648
|
-
}),
|
|
652
|
+
c = { id: i, userAgent: window.navigator.userAgent }, D("Sprig_SubmitSurvey", c);
|
|
653
|
+
}), Je());
|
|
649
654
|
}, "Error initializing replay");
|
|
650
655
|
}
|
|
651
|
-
}, isReplayRecording: () => p.isRecording, scheduleCapture:
|
|
656
|
+
}, isReplayRecording: () => p.isRecording, scheduleCapture: xe, scheduleOrCaptureReplay: Re, tryReplayAction: I }, Symbol.toStringTag, { value: "Module" })));
|