@sprig-technologies/sprig-browser 2.32.9 → 2.32.11
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-BSTFIb-W.cjs} +2 -2
- package/dist/{core-Cpj6ibvg.js → core-W9d5YBLU.js} +9 -6
- 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-BTxa6IPB.cjs} +1 -1
- package/dist/{metricsReporter-Cl6wG1Dn.js → metricsReporter-DNUK7N1y.js} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +134 -134
- package/dist/view-BJGU0X44.cjs +669 -0
- package/dist/{view-CxqsZLB6.js → view-kaPnONCv.js} +677 -642
- package/package.json +1 -1
- package/dist/view-PhfA05rs.cjs +0 -669
package/dist/replay.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (e, t, n) => (
|
|
4
|
-
import { b as u, s 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 de, a as f, v as N, c as Ae, P as ce, r as ue, d as Ne, e as T, S as O, f as Le } from "./metricsReporter-DNUK7N1y.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
|
-
const
|
|
6
|
+
const le = new class {
|
|
7
7
|
constructor(e) {
|
|
8
8
|
M(this, "awaitingResolvers", []);
|
|
9
9
|
M(this, "activeCount", 0);
|
|
@@ -30,15 +30,15 @@ const ue = new class {
|
|
|
30
30
|
setLimit(e) {
|
|
31
31
|
this.capacity = e;
|
|
32
32
|
}
|
|
33
|
-
}(2),
|
|
33
|
+
}(2), pe = async ({ apiUrl: e, surveyId: t, uploadId: n, etags: a, headers: r, responseGroupUuid: s, replayDuration: o, eventDigest: d }, i = !1) => {
|
|
34
34
|
var w;
|
|
35
35
|
if (!i && !n && !a)
|
|
36
36
|
return void u.error("UploadErr", { isMobile: i, uploadId: n, etags: a });
|
|
37
37
|
u.info("MarkUploadComplete", { surveyId: t });
|
|
38
|
-
const c = await
|
|
38
|
+
const c = await de(`${e}/sdk/1/completeSessionReplay`, { method: "POST", body: JSON.stringify({ etags: a, uploadId: n, responseGroupUuid: s, surveyId: t, replayDuration: o, eventDigest: d, userAgent: (w = window == null ? void 0 : window.navigator) == null ? void 0 : w.userAgent }), headers: r, shouldRetryRequest: !0 });
|
|
39
39
|
return u.info("MarkUploadDone", { surveyId: t }), c;
|
|
40
40
|
}, j = (e, t) => t.some((n) => e instanceof n);
|
|
41
|
-
let
|
|
41
|
+
let ee, te;
|
|
42
42
|
const V = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap();
|
|
43
43
|
let K = { get(e, t, n) {
|
|
44
44
|
if (e instanceof IDBTransaction) {
|
|
@@ -47,20 +47,20 @@ let K = { get(e, t, n) {
|
|
|
47
47
|
if (t === "store")
|
|
48
48
|
return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0]);
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return C(e[t]);
|
|
51
51
|
}, set: (e, t, n) => (e[t] = n, !0), has: (e, t) => e instanceof IDBTransaction && (t === "done" || t === "store") || t in e };
|
|
52
|
-
function
|
|
52
|
+
function ge(e) {
|
|
53
53
|
K = e(K);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
return (
|
|
57
|
-
return e.apply(G(this), t),
|
|
55
|
+
function Me(e) {
|
|
56
|
+
return (te || (te = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey])).includes(e) ? function(...t) {
|
|
57
|
+
return e.apply(G(this), t), C(this.request);
|
|
58
58
|
} : function(...t) {
|
|
59
|
-
return
|
|
59
|
+
return C(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) => {
|
|
@@ -72,14 +72,14 @@ function Me(e) {
|
|
|
72
72
|
}, t.onerror = s, t.onabort = s;
|
|
73
73
|
});
|
|
74
74
|
V.set(t, n);
|
|
75
|
-
}(e), j(e,
|
|
75
|
+
}(e), j(e, ee || (ee = [IDBDatabase, IDBObjectStore, IDBIndex, IDBCursor, IDBTransaction])) ? new Proxy(e, K) : e);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function C(e) {
|
|
78
78
|
if (e instanceof IDBRequest)
|
|
79
79
|
return function(n) {
|
|
80
80
|
const a = new Promise((r, s) => {
|
|
81
81
|
n.onsuccess = () => {
|
|
82
|
-
r(
|
|
82
|
+
r(C(n.result));
|
|
83
83
|
}, n.onerror = () => {
|
|
84
84
|
s(n.error);
|
|
85
85
|
};
|
|
@@ -88,23 +88,23 @@ 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);
|
|
95
95
|
function W(e, { blocked: t } = {}) {
|
|
96
96
|
const n = indexedDB.deleteDatabase(e);
|
|
97
|
-
return t && (n.onblocked = (a) => t(a.oldVersion, a)),
|
|
97
|
+
return t && (n.onblocked = (a) => t(a.oldVersion, a)), C(n).then(() => {
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
const
|
|
101
|
-
function
|
|
100
|
+
const He = ["get", "getKey", "getAll", "getAllKeys", "count"], Fe = ["put", "add", "delete", "clear"], F = /* @__PURE__ */ new Map();
|
|
101
|
+
function ne(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");
|
|
@@ -113,35 +113,35 @@ function te(e, t) {
|
|
|
113
113
|
};
|
|
114
114
|
return F.set(t, s), s;
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
116
|
+
ge((e) => ({ ...e, get: (t, n, a) => ne(t, n) || e.get(t, n, a), has: (t, n) => !!ne(t, n) || e.has(t, n) }));
|
|
117
|
+
const je = ["continue", "continuePrimaryKey", "advance"], ae = {}, $ = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), Ve = { get(e, t) {
|
|
118
|
+
if (!je.includes(t))
|
|
119
119
|
return e[t];
|
|
120
|
-
let n =
|
|
121
|
-
return n || (n =
|
|
122
|
-
$.set(this,
|
|
120
|
+
let n = ae[t];
|
|
121
|
+
return n || (n = ae[t] = function(...a) {
|
|
122
|
+
$.set(this, me.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,
|
|
130
|
-
for (
|
|
129
|
+
const n = new Proxy(t, Ve);
|
|
130
|
+
for (me.set(n, t), _.set(n, G(t)); t; )
|
|
131
131
|
yield n, t = await ($.get(n) || t.continue()), $.delete(n);
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function re(e, t) {
|
|
134
134
|
return t === Symbol.asyncIterator && j(e, [IDBIndex, IDBObjectStore, IDBCursor]) || t === "iterate" && j(e, [IDBIndex, IDBObjectStore]);
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
const
|
|
136
|
+
ge((e) => ({ ...e, get: (t, n, a) => re(t, n) ? Ke : e.get(t, n, a), has: (t, n) => re(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;
|
|
141
141
|
for (let n = e.previousSibling; n; n = n.previousSibling)
|
|
142
142
|
n.nodeName === e.nodeName && ++t;
|
|
143
143
|
return t;
|
|
144
|
-
},
|
|
144
|
+
}, we = (e) => {
|
|
145
145
|
if (e === null)
|
|
146
146
|
return "";
|
|
147
147
|
const t = [];
|
|
@@ -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-", se = (e) => {
|
|
174
174
|
var a;
|
|
175
175
|
if (((a = e.tagName) == null ? void 0 : a.toLowerCase()) === "html")
|
|
176
176
|
return { element: "html" };
|
|
@@ -184,26 +184,26 @@ 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
|
-
const t = { ...
|
|
195
|
-
if (n &&
|
|
196
|
-
const r =
|
|
194
|
+
const t = { ...se(e) }, n = e.parentElement;
|
|
195
|
+
if (n && We.includes((a = n.tagName) == null ? void 0 : a.toLowerCase())) {
|
|
196
|
+
const r = se(n);
|
|
197
197
|
Object.assign(t, r);
|
|
198
198
|
}
|
|
199
199
|
return t;
|
|
200
|
-
},
|
|
200
|
+
}, ye = (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),
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
},
|
|
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: we(n) } : {} });
|
|
204
|
+
}, fe = (e) => {
|
|
205
|
+
$e.includes(e.key) && et({ key: e.key });
|
|
206
|
+
}, Ie = /* @__PURE__ */ ((e, t) => {
|
|
207
207
|
let n;
|
|
208
208
|
return (a) => {
|
|
209
209
|
clearTimeout(n), n = window.setTimeout(() => e(a), t);
|
|
@@ -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),
|
|
216
|
-
}, 750),
|
|
217
|
-
var
|
|
218
|
-
const
|
|
219
|
-
e.button === 2 &&
|
|
220
|
-
},
|
|
215
|
+
"scrollTop" in t || (t = t.documentElement), tt({ xPath: we(t), x: t.scrollLeft, y: t.scrollTop, elementAttributes: { targetScrollWidth: t.scrollWidth, targetClientWidth: t.clientWidth, targetScrollHeight: t.scrollHeight, targetClientHeight: t.clientHeight } });
|
|
216
|
+
}, 750), he = (oe = "left_click", (e) => ye(oe, e));
|
|
217
|
+
var oe;
|
|
218
|
+
const ve = (e) => {
|
|
219
|
+
e.button === 2 && ye("right_click", e);
|
|
220
|
+
}, De = (e) => {
|
|
221
221
|
window.Sprig && (window.Sprig.pointerDownTarget = e.target);
|
|
222
|
-
},
|
|
223
|
-
A || (window.addEventListener("click",
|
|
222
|
+
}, Qe = () => {
|
|
223
|
+
A || (window.addEventListener("click", he, v), window.addEventListener("pointerdown", De, v), window.addEventListener("mousedown", ve, v), window.addEventListener("keydown", fe, v), window.addEventListener("scroll", Ie, 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
|
+
} }, be = () => 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;
|
|
@@ -234,7 +234,7 @@ const he = (e) => {
|
|
|
234
234
|
window.addEventListener("beforeunload", () => {
|
|
235
235
|
u.info("BeforeUnload", { sessionId: y }), f.setItem("sprig.sessionId", y);
|
|
236
236
|
});
|
|
237
|
-
const
|
|
237
|
+
const Z = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(/\r?\n|\r/g, " ").substring(0, 250), D = (e, t) => {
|
|
238
238
|
var n, a;
|
|
239
239
|
if (!b() && p.isRecording)
|
|
240
240
|
try {
|
|
@@ -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
|
-
}, Qe = (e) => {
|
|
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);
|
|
248
245
|
}, Xe = (e) => {
|
|
249
|
-
|
|
246
|
+
var t;
|
|
247
|
+
(t = e == null ? void 0 : e.elementAttributes) != null && t.text && (e.elementAttributes.text = Z(e.elementAttributes.text)), D("Sprig_Click", e);
|
|
250
248
|
}, Ye = (e) => {
|
|
251
|
-
|
|
249
|
+
D("Sprig_Refresh", e);
|
|
252
250
|
}, Ze = (e) => {
|
|
251
|
+
e.currentPageTitle && (e.currentPageTitle = Z(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,39 +266,39 @@ 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
|
+
}, Se = () => {
|
|
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
|
-
}), A && (window.removeEventListener("click",
|
|
273
|
-
},
|
|
272
|
+
}), A && (window.removeEventListener("click", he, v), window.removeEventListener("pointerdown", De, v), window.removeEventListener("mousedown", ve, v), window.removeEventListener("keydown", fe, v), window.removeEventListener("scroll", Ie, v), A = !1);
|
|
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
|
+
Se(), u.error("ReplayErr", { code: t.code, name: t.name }), at(e, t, { reportError: n });
|
|
288
288
|
}, I = async (e, t) => {
|
|
289
289
|
try {
|
|
290
|
-
await e();
|
|
290
|
+
return await e();
|
|
291
291
|
} catch (n) {
|
|
292
292
|
L(t, n);
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
W("replayStorage").catch(console.error), W("sprig.replay").catch(console.error);
|
|
295
|
+
be() && (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 } = {}) {
|
|
299
|
-
const o = indexedDB.open(e, t), d =
|
|
299
|
+
const o = indexedDB.open(e, t), d = C(o);
|
|
300
300
|
return a && (o.onupgradeneeded = (i) => {
|
|
301
|
-
a(
|
|
301
|
+
a(C(o.result), i.oldVersion, i.newVersion, C(o.transaction), i);
|
|
302
302
|
}), n && (o.onblocked = (i) => n(i.oldVersion, i.newVersion, i)), d.then((i) => {
|
|
303
303
|
s && (i.onclose = () => s()), r && (i.onversionchange = (c) => r(c.oldVersion, c.newVersion, c));
|
|
304
304
|
}).catch(() => {
|
|
@@ -389,29 +389,29 @@ const l = new class {
|
|
|
389
389
|
}
|
|
390
390
|
await n.done;
|
|
391
391
|
}
|
|
392
|
-
}(),
|
|
392
|
+
}(), Ce = async (e, t) => {
|
|
393
393
|
const n = performance.now();
|
|
394
394
|
let a;
|
|
395
395
|
try {
|
|
396
396
|
a = await e();
|
|
397
397
|
} finally {
|
|
398
398
|
const r = performance.now() - n;
|
|
399
|
-
let s =
|
|
400
|
-
s || (s =
|
|
399
|
+
let s = ce[t];
|
|
400
|
+
s || (s = ue(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();
|
|
407
407
|
} finally {
|
|
408
408
|
const a = performance.now() - n;
|
|
409
|
-
let r =
|
|
410
|
-
r || (r =
|
|
409
|
+
let r = ce[t];
|
|
410
|
+
r || (r = ue(t)), r.report(a / 1e3);
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
|
-
let
|
|
414
|
-
const
|
|
413
|
+
let Ee = 5e3, z = 6e4, J = 0, k, 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
|
+
Ce(() => 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 Y();
|
|
447
447
|
}, "Error initiating pending captures");
|
|
448
448
|
}, 5e3);
|
|
449
|
-
},
|
|
450
|
-
const t = parseInt(
|
|
449
|
+
}, Y = async (e = !1) => {
|
|
450
|
+
const t = parseInt(k ?? "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)))), k = (t - n.length).toString(), f.setItem("sprig.pendingCount", k);
|
|
455
|
+
}, dt = async (e, t, n, a, r) => {
|
|
456
|
+
const s = Math.min(e + r, n), o = await Ce(() => 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,11 +467,11 @@ 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
|
-
},
|
|
471
|
-
const n = await (async (a) =>
|
|
470
|
+
}, Pe = (e) => Promise.all(e.map(async (t) => {
|
|
471
|
+
const n = await (async (a) => le.execute(async () => {
|
|
472
472
|
var o;
|
|
473
473
|
u.info("UploadChunkStart", { chunkIndex: a.chunkIndex, surveyId: a.surveyId });
|
|
474
|
-
const r = await
|
|
474
|
+
const r = await de(a.uploadUrl, { body: a.data, method: "PUT" });
|
|
475
475
|
u.http("UploadChunkEnd", { url: a.uploadUrl, method: "PUT", status_code: r.status, reason: r.statusText ?? "OK", chunkIndex: a.chunkIndex, surveyId: a.surveyId });
|
|
476
476
|
const s = (o = r.headers) == null ? void 0 : o.get("ETag");
|
|
477
477
|
if (!s)
|
|
@@ -479,26 +479,26 @@ 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 });
|
|
486
486
|
const n = t.reduce((s, o) => (s.find((d) => d.chunkIndex === o.chunkIndex) || s.push(o), s), []);
|
|
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
|
-
await
|
|
490
|
-
},
|
|
489
|
+
await pe({ 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
|
+
}, 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 < Ee)
|
|
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
|
-
},
|
|
527
|
-
const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: s, replayParams: o, triggerTimestamp: d } = e, i = await
|
|
526
|
+
}, ie = async (e) => {
|
|
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,31 +538,31 @@ 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 () => {
|
|
547
547
|
setTimeout(() => T.removeListener(O.QuestionAnswered, d), 0), I(async () => {
|
|
548
|
-
r.replayDurationType === "before" ? await
|
|
548
|
+
r.replayDurationType === "before" ? await ie(e) : await l.markPendingCaptureToCanUpload(o);
|
|
549
549
|
}, "Error in schedule/capture callback");
|
|
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
|
|
555
|
+
await ie(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(
|
|
563
|
-
},
|
|
561
|
+
}, lt = async () => {
|
|
562
|
+
parseInt(k ?? "0") || f.removeItem("sprig.isCapturingHeatmap"), f.getItem("sprig.teardownAfterCapture") && (Se(), 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);
|
|
@@ -578,29 +578,29 @@ const at = (e) => {
|
|
|
578
578
|
const s = { ...e, replayParams: { ...e.replayParams } };
|
|
579
579
|
e.replayParams.replayDurationType === "beforeAndAfter" && (s.replayParams.replayDurationSeconds *= 2), s.replayParams.replayDurationType = "before";
|
|
580
580
|
const o = e.triggerTimestamp + 1e3 * e.replayParams.replayDurationSeconds;
|
|
581
|
-
s.triggerTimestamp = o,
|
|
581
|
+
s.triggerTimestamp = o, k = (parseInt(k ?? "0") + 1).toString(), f.setItem("sprig.pendingCount", k), 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
|
-
e.description && (e.description =
|
|
586
|
+
e.description && (e.description = Z(e.description)), D("Sprig_PageView", e);
|
|
587
587
|
}, RecordSurveyShown: (e) => {
|
|
588
588
|
D("Sprig_ShowSurvey", e);
|
|
589
589
|
}, _completeSessionReplay: async ({ surveyId: e, responseGroupUuid: t, eventDigest: n, headers: a }) => {
|
|
590
590
|
if (!e || !t)
|
|
591
591
|
return !1;
|
|
592
|
-
const r = window.UserLeap._API_URL, s = await
|
|
592
|
+
const r = window.UserLeap._API_URL, s = await pe({ 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 }) => !
|
|
596
|
-
u.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await l.markPendingHeatmapsReady(e), u.info("MarkedPendingHeatmapsReady"));
|
|
597
|
-
}, "Error marking pending heatmaps ready"), clearUserReplayData:
|
|
598
|
-
if (
|
|
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
|
+
return u.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await l.markPendingHeatmapsReady(e), u.info("MarkedPendingHeatmapsReady")), e.length;
|
|
597
|
+
}, "Error marking pending heatmaps ready"), clearUserReplayData: xe, disableRecording: L, initializeReplay: async ({ maxReplayDurationSeconds: e, maxInflightRequests: t = 2, replaySettings: n, teardownAfter: a = !1 }) => {
|
|
598
|
+
if (k = 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 (!be())
|
|
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 Y(!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 && (Ee = n.minDuration), n != null && n.batchDuration && (z = n.batchDuration), r = t, le.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, uploadReadyPendingCaptures: Y }, Symbol.toStringTag, { value: "Module" })));
|