@sprig-technologies/sprig-browser 2.33.1 → 2.33.2
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-B164snRL.cjs +12 -0
- package/dist/{core-BPGg40bv.js → core-C0XvmpIu.js} +374 -437
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +2 -2
- package/dist/electron.js +2 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/metricsReporter-BLXrIaei.cjs +1 -0
- package/dist/{metricsReporter-Dsn4xUH7.js → metricsReporter-uTmb1eaJ.js} +22 -34
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +430 -499
- package/dist/{view-CHGRuuXh.js → view-DuNLA499.js} +1218 -1345
- package/dist/view-yOVTCqu5.cjs +669 -0
- package/package.json +1 -1
- package/dist/core-BSewKENy.cjs +0 -12
- package/dist/metricsReporter-Cdy0iTSw.cjs +0 -1
- package/dist/view-1IHlk1KV.cjs +0 -669
package/dist/replay.js
CHANGED
|
@@ -1,116 +1,104 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { b as d, s as
|
|
5
|
-
var
|
|
6
|
-
const
|
|
7
|
-
let
|
|
8
|
-
const
|
|
9
|
-
let
|
|
1
|
+
var st = Object.defineProperty;
|
|
2
|
+
var ot = (e, t, n) => t in e ? st(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var Q = (e, t, n) => ot(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { b as d, s as J, a as y, v as z, c as it, g as dt, P as ke, r as Re, d as ct, e as H, S as X, f as lt } from "./metricsReporter-uTmb1eaJ.js";
|
|
5
|
+
var B = ((e) => (e[e.DomContentLoaded = 0] = "DomContentLoaded", e[e.Load = 1] = "Load", e[e.FullSnapshot = 2] = "FullSnapshot", e[e.IncrementalSnapshot = 3] = "IncrementalSnapshot", e[e.Meta = 4] = "Meta", e[e.Custom = 5] = "Custom", e[e.Plugin = 6] = "Plugin", e))(B || {}), P = ((e) => (e[e.Mutation = 0] = "Mutation", e[e.MouseMove = 1] = "MouseMove", e[e.MouseInteraction = 2] = "MouseInteraction", e[e.Scroll = 3] = "Scroll", e[e.ViewportResize = 4] = "ViewportResize", e[e.Input = 5] = "Input", e[e.TouchMove = 6] = "TouchMove", e[e.MediaInteraction = 7] = "MediaInteraction", e[e.StyleSheetRule = 8] = "StyleSheetRule", e[e.CanvasMutation = 9] = "CanvasMutation", e[e.Font = 10] = "Font", e[e.Log = 11] = "Log", e[e.Drag = 12] = "Drag", e[e.StyleDeclaration = 13] = "StyleDeclaration", e[e.Selection = 14] = "Selection", e[e.AdoptedStyleSheet = 15] = "AdoptedStyleSheet", e[e.CustomElement = 16] = "CustomElement", e))(P || {});
|
|
6
|
+
const ne = (e, t) => t.some((n) => e instanceof n);
|
|
7
|
+
let he, Ie;
|
|
8
|
+
const ae = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
let re = { get(e, t, n) {
|
|
10
10
|
if (e instanceof IDBTransaction) {
|
|
11
|
-
if (t === "done")
|
|
12
|
-
|
|
13
|
-
if (t === "store")
|
|
14
|
-
return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0]);
|
|
11
|
+
if (t === "done") return ae.get(e);
|
|
12
|
+
if (t === "store") return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0]);
|
|
15
13
|
}
|
|
16
|
-
return
|
|
14
|
+
return T(e[t]);
|
|
17
15
|
}, set: (e, t, n) => (e[t] = n, !0), has: (e, t) => e instanceof IDBTransaction && (t === "done" || t === "store") || t in e };
|
|
18
|
-
function
|
|
19
|
-
|
|
16
|
+
function Ue(e) {
|
|
17
|
+
re = e(re);
|
|
20
18
|
}
|
|
21
|
-
function
|
|
22
|
-
return (
|
|
23
|
-
return e.apply(
|
|
19
|
+
function ut(e) {
|
|
20
|
+
return (Ie || (Ie = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey])).includes(e) ? function(...t) {
|
|
21
|
+
return e.apply(se(this), t), T(this.request);
|
|
24
22
|
} : function(...t) {
|
|
25
|
-
return
|
|
23
|
+
return T(e.apply(se(this), t));
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
|
-
function
|
|
29
|
-
return typeof e == "function" ?
|
|
30
|
-
if (
|
|
31
|
-
return;
|
|
26
|
+
function pt(e) {
|
|
27
|
+
return typeof e == "function" ? ut(e) : (e instanceof IDBTransaction && function(t) {
|
|
28
|
+
if (ae.has(t)) return;
|
|
32
29
|
const n = new Promise((a, r) => {
|
|
33
|
-
const
|
|
30
|
+
const s = () => {
|
|
34
31
|
r(t.error || new DOMException("AbortError", "AbortError"));
|
|
35
32
|
};
|
|
36
33
|
t.oncomplete = () => {
|
|
37
34
|
a();
|
|
38
|
-
}, t.onerror =
|
|
35
|
+
}, t.onerror = s, t.onabort = s;
|
|
39
36
|
});
|
|
40
|
-
|
|
41
|
-
}(e),
|
|
37
|
+
ae.set(t, n);
|
|
38
|
+
}(e), ne(e, he || (he = [IDBDatabase, IDBObjectStore, IDBIndex, IDBCursor, IDBTransaction])) ? new Proxy(e, re) : e);
|
|
42
39
|
}
|
|
43
|
-
function
|
|
44
|
-
if (e instanceof IDBRequest)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
n.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const t = dt(e);
|
|
58
|
-
return t !== e && (Q.set(e, t), V.set(t, e)), t;
|
|
40
|
+
function T(e) {
|
|
41
|
+
if (e instanceof IDBRequest) return function(n) {
|
|
42
|
+
const a = new Promise((r, s) => {
|
|
43
|
+
n.onsuccess = () => {
|
|
44
|
+
r(T(n.result));
|
|
45
|
+
}, n.onerror = () => {
|
|
46
|
+
s(n.error);
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
return $.set(a, n), a;
|
|
50
|
+
}(e);
|
|
51
|
+
if (Z.has(e)) return Z.get(e);
|
|
52
|
+
const t = pt(e);
|
|
53
|
+
return t !== e && (Z.set(e, t), $.set(t, e)), t;
|
|
59
54
|
}
|
|
60
|
-
const
|
|
61
|
-
function
|
|
55
|
+
const se = (e) => $.get(e);
|
|
56
|
+
function oe(e, { blocked: t } = {}) {
|
|
62
57
|
const n = indexedDB.deleteDatabase(e);
|
|
63
|
-
return t && (n.onblocked = (a) => t(a.oldVersion, a)),
|
|
58
|
+
return t && (n.onblocked = (a) => t(a.oldVersion, a)), T(n).then(() => {
|
|
64
59
|
});
|
|
65
60
|
}
|
|
66
|
-
const
|
|
67
|
-
function
|
|
68
|
-
if (!(e instanceof IDBDatabase) || t in e || typeof t != "string")
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
return;
|
|
75
|
-
const o = async function(s, ...c) {
|
|
76
|
-
const i = this.transaction(s, r ? "readwrite" : "readonly");
|
|
61
|
+
const gt = ["get", "getKey", "getAll", "getAllKeys", "count"], mt = ["put", "add", "delete", "clear"], Y = /* @__PURE__ */ new Map();
|
|
62
|
+
function ve(e, t) {
|
|
63
|
+
if (!(e instanceof IDBDatabase) || t in e || typeof t != "string") return;
|
|
64
|
+
if (Y.get(t)) return Y.get(t);
|
|
65
|
+
const n = t.replace(/FromIndex$/, ""), a = t !== n, r = mt.includes(n);
|
|
66
|
+
if (!(n in (a ? IDBIndex : IDBObjectStore).prototype) || !r && !gt.includes(n)) return;
|
|
67
|
+
const s = async function(o, ...c) {
|
|
68
|
+
const i = this.transaction(o, r ? "readwrite" : "readonly");
|
|
77
69
|
let l = i.store;
|
|
78
70
|
return a && (l = l.index(c.shift())), (await Promise.all([l[n](...c), r && i.done]))[0];
|
|
79
71
|
};
|
|
80
|
-
return
|
|
72
|
+
return Y.set(t, s), s;
|
|
81
73
|
}
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
oe.set(this, ke.get(this)[t](...a));
|
|
74
|
+
Ue((e) => ({ ...e, get: (t, n, a) => ve(t, n) || e.get(t, n, a), has: (t, n) => !!ve(t, n) || e.has(t, n) }));
|
|
75
|
+
const wt = ["continue", "continuePrimaryKey", "advance"], Se = {}, ie = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), yt = { get(e, t) {
|
|
76
|
+
if (!wt.includes(t)) return e[t];
|
|
77
|
+
let n = Se[t];
|
|
78
|
+
return n || (n = Se[t] = function(...a) {
|
|
79
|
+
ie.set(this, Pe.get(this)[t](...a));
|
|
89
80
|
}), n;
|
|
90
81
|
} };
|
|
91
|
-
async function*
|
|
82
|
+
async function* ft(...e) {
|
|
92
83
|
let t = this;
|
|
93
|
-
if (t instanceof IDBCursor || (t = await t.openCursor(...e)), !t)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (ke.set(n, t), V.set(n, ae(t)); t; )
|
|
97
|
-
yield n, t = await (oe.get(n) || t.continue()), oe.delete(n);
|
|
84
|
+
if (t instanceof IDBCursor || (t = await t.openCursor(...e)), !t) return;
|
|
85
|
+
const n = new Proxy(t, yt);
|
|
86
|
+
for (Pe.set(n, t), $.set(n, se(t)); t; ) yield n, t = await (ie.get(n) || t.continue()), ie.delete(n);
|
|
98
87
|
}
|
|
99
|
-
function
|
|
100
|
-
return t === Symbol.asyncIterator &&
|
|
88
|
+
function De(e, t) {
|
|
89
|
+
return t === Symbol.asyncIterator && ne(e, [IDBIndex, IDBObjectStore, IDBCursor]) || t === "iterate" && ne(e, [IDBIndex, IDBObjectStore]);
|
|
101
90
|
}
|
|
102
|
-
|
|
103
|
-
const
|
|
91
|
+
Ue((e) => ({ ...e, get: (t, n, a) => De(t, n) ? ft : e.get(t, n, a), has: (t, n) => De(t, n) || e.has(t, n) }));
|
|
92
|
+
const ht = "sprigReplayIframeLoaded", It = "sprigReplayIframeSettings", vt = "sprigReplayIframeTakeFullSnapshot", St = "sprigReplayTeardown", me = [], xe = new class {
|
|
104
93
|
constructor(e) {
|
|
105
|
-
|
|
106
|
-
|
|
94
|
+
Q(this, "awaitingResolvers", []);
|
|
95
|
+
Q(this, "activeCount", 0);
|
|
107
96
|
this.capacity = e;
|
|
108
97
|
}
|
|
109
98
|
async acquire() {
|
|
110
|
-
if (!(this.activeCount < this.capacity))
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
99
|
+
if (!(this.activeCount < this.capacity)) return new Promise((e) => {
|
|
100
|
+
this.awaitingResolvers.push(e);
|
|
101
|
+
});
|
|
114
102
|
this.activeCount++;
|
|
115
103
|
}
|
|
116
104
|
release() {
|
|
@@ -127,26 +115,21 @@ const Ue = new class {
|
|
|
127
115
|
setLimit(e) {
|
|
128
116
|
this.capacity = e;
|
|
129
117
|
}
|
|
130
|
-
}(2),
|
|
131
|
-
var
|
|
132
|
-
if (!i && !n && !a)
|
|
133
|
-
return void d.error("UploadErr", { isMobile: i, uploadId: n, etags: a });
|
|
118
|
+
}(2), Be = async ({ apiUrl: e, surveyId: t, uploadId: n, etags: a, headers: r, responseGroupUuid: s, replayDuration: o, eventDigest: c }, i = !1) => {
|
|
119
|
+
var w;
|
|
120
|
+
if (!i && !n && !a) return void d.error("UploadErr", { isMobile: i, uploadId: n, etags: a });
|
|
134
121
|
d.info("MarkUploadComplete", { surveyId: t });
|
|
135
|
-
const l = await
|
|
122
|
+
const l = await J(`${e}/sdk/1/completeSessionReplay`, { method: "POST", body: JSON.stringify({ etags: a, uploadId: n, responseGroupUuid: s, surveyId: t, replayDuration: o, eventDigest: c, userAgent: (w = window == null ? void 0 : window.navigator) == null ? void 0 : w.userAgent }), headers: r, shouldRetryRequest: !0 });
|
|
136
123
|
return d.info("MarkUploadDone", { surveyId: t }), l;
|
|
137
|
-
},
|
|
138
|
-
if (e instanceof Attr)
|
|
139
|
-
return null;
|
|
124
|
+
}, Dt = (e) => {
|
|
125
|
+
if (e instanceof Attr) return null;
|
|
140
126
|
let t = 1;
|
|
141
|
-
for (let n = e.previousSibling; n; n = n.previousSibling)
|
|
142
|
-
n.nodeName === e.nodeName && ++t;
|
|
127
|
+
for (let n = e.previousSibling; n; n = n.previousSibling) n.nodeName === e.nodeName && ++t;
|
|
143
128
|
return t;
|
|
144
|
-
},
|
|
145
|
-
if (e === null)
|
|
146
|
-
return "";
|
|
129
|
+
}, Te = (e) => {
|
|
130
|
+
if (e === null) return "";
|
|
147
131
|
const t = [];
|
|
148
|
-
if (e instanceof Document)
|
|
149
|
-
return "/";
|
|
132
|
+
if (e instanceof Document) return "/";
|
|
150
133
|
for (let n = e; n && !(n instanceof Document) && n !== null; n = n instanceof Attr ? n.ownerElement : n.parentElement) {
|
|
151
134
|
const a = t[t.length] = { name: void 0, position: null };
|
|
152
135
|
switch (n.nodeType) {
|
|
@@ -165,146 +148,135 @@ const Ue = new class {
|
|
|
165
148
|
case Node.ELEMENT_NODE:
|
|
166
149
|
a.name = n.nodeName;
|
|
167
150
|
}
|
|
168
|
-
a.position =
|
|
151
|
+
a.position = Dt(n);
|
|
169
152
|
}
|
|
170
153
|
return "/" + t.reverse().map((n) => n.position !== null ? `/${n.name}[${n.position}]` : `/${n.name}`).join("");
|
|
171
|
-
},
|
|
172
|
-
let
|
|
173
|
-
const
|
|
154
|
+
}, we = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(/\r?\n|\r/g, " ").substring(0, 250), k = { capture: !0, passive: !0 }, bt = ["a", "button", "input", "option", "li", "link"], Et = ["Escape", "Enter", "Backspace", "F5", "Tab"];
|
|
155
|
+
let K = !1, b = null, j = null;
|
|
156
|
+
const be = (e) => {
|
|
157
|
+
var n;
|
|
158
|
+
if (((n = e.tagName) == null ? void 0 : n.toLowerCase()) === "html") return { element: "html" };
|
|
159
|
+
const t = {};
|
|
160
|
+
return t.element = ((a) => {
|
|
161
|
+
if (!a.tagName) return "No tagName";
|
|
162
|
+
const r = a.getAttribute("type");
|
|
163
|
+
return r ? `${r} ${a.tagName.toLowerCase()}` : a.tagName.toLowerCase();
|
|
164
|
+
})(e), t;
|
|
165
|
+
}, Ct = (e) => {
|
|
174
166
|
var a;
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (!r.tagName)
|
|
180
|
-
return "No tagName";
|
|
181
|
-
const o = r.getAttribute("type");
|
|
182
|
-
return o ? `${o} ${r.tagName.toLowerCase()}` : r.tagName.toLowerCase();
|
|
183
|
-
})(e);
|
|
184
|
-
for (const r of e.attributes) {
|
|
185
|
-
let o = r.name;
|
|
186
|
-
const s = r.value;
|
|
187
|
-
o.startsWith(ht) && (o = o.substring(5)), ft.includes(o) && (n[o] = s);
|
|
188
|
-
}
|
|
189
|
-
return n;
|
|
190
|
-
}, It = (e) => {
|
|
191
|
-
var a;
|
|
192
|
-
if (!e)
|
|
193
|
-
return {};
|
|
194
|
-
const t = { ...ve(e) }, n = e.parentElement;
|
|
195
|
-
if (n && wt.includes((a = n.tagName) == null ? void 0 : a.toLowerCase())) {
|
|
196
|
-
const r = ve(n);
|
|
167
|
+
if (!e) return {};
|
|
168
|
+
const t = { ...be(e) }, n = e.parentElement;
|
|
169
|
+
if (n && bt.includes((a = n.tagName) == null ? void 0 : a.toLowerCase())) {
|
|
170
|
+
const r = be(n);
|
|
197
171
|
Object.assign(t, r);
|
|
198
172
|
}
|
|
199
173
|
return t;
|
|
200
|
-
},
|
|
201
|
-
var
|
|
174
|
+
}, Me = (e, t) => {
|
|
175
|
+
var r, s;
|
|
202
176
|
let n = t.target;
|
|
203
|
-
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
|
|
177
|
+
var a;
|
|
178
|
+
t.target === ((r = window.document) == null ? void 0 : r.body) && window.Sprig.pointerDownTarget && (n = window.Sprig.pointerDownTarget), a = { x: t.x, y: t.y, type: e, elementAttributes: Ct(n), windowHeight: window.innerHeight, windowWidth: window.innerWidth, ...n instanceof HTMLElement ? { rect: n == null ? void 0 : n.getBoundingClientRect(), xPath: Te(n) } : {} }, (s = a == null ? void 0 : a.elementAttributes) != null && s.text && (a.elementAttributes.text = we(a.elementAttributes.text)), b == null || b("Sprig_Click", a);
|
|
179
|
+
}, Ae = (e) => {
|
|
180
|
+
var t;
|
|
181
|
+
Et.includes(e.key) && (t = { key: e.key }, b == null || b("Sprig_Keystroke", t));
|
|
182
|
+
}, kt = () => {
|
|
183
|
+
var e;
|
|
184
|
+
window.performance.getEntriesByType("navigation").map((t) => t.type).includes("reload") && (e = { url: window.location.href, currentPageTitle: document.title }, b == null || b("Sprig_Refresh", e));
|
|
185
|
+
}, Rt = () => {
|
|
186
|
+
var e;
|
|
187
|
+
window.performance.getEntriesByType("navigation").map((t) => t.type).includes("back_forward") && ((e = { curUrl: window.location.href, fromUrl: document.referrer, currentPageTitle: document.title }).currentPageTitle && (e.currentPageTitle = we(e.currentPageTitle)), b == null || b("Sprig_BackForward", e));
|
|
188
|
+
}, _e = /* @__PURE__ */ ((e, t) => {
|
|
207
189
|
let n;
|
|
208
190
|
return (a) => {
|
|
209
191
|
clearTimeout(n), n = window.setTimeout(() => e(a), t);
|
|
210
192
|
};
|
|
211
193
|
})((e) => {
|
|
212
|
-
if (!(e.target instanceof HTMLElement || e.target instanceof Document))
|
|
213
|
-
return;
|
|
194
|
+
if (!(e.target instanceof HTMLElement || e.target instanceof Document)) return;
|
|
214
195
|
let t = e.target;
|
|
215
|
-
"scrollTop" in t || (t = t.documentElement),
|
|
216
|
-
}, 750),
|
|
217
|
-
var
|
|
218
|
-
const
|
|
219
|
-
e.button === 2 &&
|
|
220
|
-
},
|
|
196
|
+
"scrollTop" in t || (t = t.documentElement), j == null || j({ xPath: Te(t), x: t.scrollLeft, y: t.scrollTop, elementAttributes: { targetScrollWidth: t.scrollWidth, targetClientWidth: t.clientWidth, targetScrollHeight: t.scrollHeight, targetClientHeight: t.clientHeight } });
|
|
197
|
+
}, 750), Ne = (Ee = "left_click", (e) => Me(Ee, e));
|
|
198
|
+
var Ee;
|
|
199
|
+
const Le = (e) => {
|
|
200
|
+
e.button === 2 && Me("right_click", e);
|
|
201
|
+
}, Oe = (e) => {
|
|
221
202
|
window.Sprig && (window.Sprig.pointerDownTarget = e.target);
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
if (e)
|
|
228
|
-
return d.info("SessionIDFound", { savedSessionId: e }), f.removeItem("sprig.sessionId"), e;
|
|
229
|
-
const t = W();
|
|
203
|
+
}, g = { isRecording: !1, scrollEventUuids: {}, stopRecording: () => {
|
|
204
|
+
} }, Fe = () => window.indexedDB && window.IDBKeyRange && window.CompressionStream, I = (() => {
|
|
205
|
+
const e = y.getItem("sprig.sessionId");
|
|
206
|
+
if (e) return d.info("SessionIDFound", { savedSessionId: e }), y.removeItem("sprig.sessionId"), e;
|
|
207
|
+
const t = z();
|
|
230
208
|
return d.info("GeneratedSessionID", { uuid: t }), t;
|
|
231
|
-
})(),
|
|
232
|
-
|
|
233
|
-
},
|
|
209
|
+
})(), de = () => {
|
|
210
|
+
y.setItem("sprig.disableReplayRecording", "disabled");
|
|
211
|
+
}, R = () => !!y.getItem("sprig.disableReplayRecording");
|
|
234
212
|
window.addEventListener("beforeunload", () => {
|
|
235
|
-
d.info("BeforeUnload", { sessionId:
|
|
213
|
+
d.info("BeforeUnload", { sessionId: I }), y.setItem("sprig.sessionId", I);
|
|
236
214
|
});
|
|
237
|
-
const
|
|
215
|
+
const A = (e, t) => {
|
|
238
216
|
var n, a;
|
|
239
|
-
if (!
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
D("Sprig_Scroll", e);
|
|
267
|
-
}, "Error updating scroll event");
|
|
268
|
-
D("Sprig_Scroll", e);
|
|
269
|
-
}, Le = () => {
|
|
270
|
-
w.stopRecording && (w.stopRecording(), w.stopRecording = void 0), w.isRecording = !1, ["cleanupInterval", "inactivityInterval", "pendingCheckInterval"].forEach((e) => {
|
|
271
|
-
w[e] && (clearInterval(w[e]), w[e] = void 0);
|
|
272
|
-
}), G && (window.removeEventListener("click", Me, S), window.removeEventListener("pointerdown", _e, S), window.removeEventListener("mousedown", Ae, S), window.removeEventListener("keydown", Be, S), window.removeEventListener("scroll", Te, S), G = !1);
|
|
273
|
-
}, kt = ["did not allow mutations", "called in an invalid security context"], Ut = (e, t, { reportError: n = !0, extraInfo: a = {} }) => {
|
|
274
|
-
if (!b() && t instanceof Error) {
|
|
275
|
-
if (se(), t.name === "VersionError")
|
|
276
|
-
return d.error("VersionErr", { message: e }), u.deleteDB();
|
|
217
|
+
if (!R() && g.isRecording) try {
|
|
218
|
+
(a = (n = window.rrwebRecord) == null ? void 0 : n.addCustomEvent) == null || a.call(n, e, t);
|
|
219
|
+
} catch (r) {
|
|
220
|
+
q("Error recording custom event", r);
|
|
221
|
+
}
|
|
222
|
+
}, Ut = async (e) => {
|
|
223
|
+
const { x: t, xPath: n, y: a } = e, r = g.scrollEventUuids[n];
|
|
224
|
+
if (r) return D(async () => {
|
|
225
|
+
var c, i, l, w;
|
|
226
|
+
const s = await u.openDB(), o = await s.get("events", r);
|
|
227
|
+
if (o != null && o.event) {
|
|
228
|
+
const p = JSON.parse(o.event), h = t > ((i = (c = p.data) == null ? void 0 : c.payload) == null ? void 0 : i.x), m = a > ((w = (l = p.data) == null ? void 0 : l.payload) == null ? void 0 : w.y);
|
|
229
|
+
if (!h && !m) return null;
|
|
230
|
+
h && (p.data.payload.x = t), m && (p.data.payload.y = a), p.data.payload.elementAttributes = e.elementAttributes, o.event = JSON.stringify(p), await s.put("events", o);
|
|
231
|
+
} else A("Sprig_Scroll", e);
|
|
232
|
+
}, "Error updating scroll event");
|
|
233
|
+
A("Sprig_Scroll", e);
|
|
234
|
+
}, He = () => {
|
|
235
|
+
g.stopRecording && (g.stopRecording(), g.stopRecording = void 0), g.isRecording = !1, ["cleanupInterval", "inactivityInterval", "pendingCheckInterval"].forEach((e) => {
|
|
236
|
+
g[e] && (clearInterval(g[e]), g[e] = void 0);
|
|
237
|
+
}), K && (window.removeEventListener("click", Ne, k), window.removeEventListener("pointerdown", Oe, k), window.removeEventListener("mousedown", Le, k), window.removeEventListener("keydown", Ae, k), window.removeEventListener("scroll", _e, k), K = !1), me.forEach((e) => {
|
|
238
|
+
var t;
|
|
239
|
+
(t = e.source) == null || t.postMessage({ type: St }, { targetOrigin: e.origin });
|
|
240
|
+
});
|
|
241
|
+
}, Pt = ["did not allow mutations", "called in an invalid security context"], xt = (e, t, { reportError: n = !0, extraInfo: a = {} }) => {
|
|
242
|
+
if (!R() && t instanceof Error) {
|
|
243
|
+
if (de(), t.name === "VersionError") return d.error("VersionErr", { message: e }), u.deleteDB();
|
|
277
244
|
((r) => {
|
|
278
|
-
if (!r)
|
|
279
|
-
|
|
280
|
-
for (const o of kt)
|
|
281
|
-
if (r.toLowerCase().includes(o))
|
|
282
|
-
return !1;
|
|
245
|
+
if (!r) return !0;
|
|
246
|
+
for (const s of Pt) if (r.toLowerCase().includes(s)) return !1;
|
|
283
247
|
return !0;
|
|
284
248
|
})(t == null ? void 0 : t.message) && (n && window.UserLeap.reportError(e, t, a), u.clearAll());
|
|
285
249
|
}
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
},
|
|
250
|
+
}, q = (e, t, { reportError: n } = { reportError: !0 }) => {
|
|
251
|
+
He(), d.error("ReplayErr", { code: t.code, name: t.name }), xt(e, t, { reportError: n });
|
|
252
|
+
}, D = async (e, t) => {
|
|
289
253
|
try {
|
|
290
254
|
return await e();
|
|
291
255
|
} catch (n) {
|
|
292
|
-
|
|
256
|
+
q(t, n);
|
|
293
257
|
}
|
|
258
|
+
}, je = () => {
|
|
259
|
+
g.isRecording && (D(() => {
|
|
260
|
+
var e, t;
|
|
261
|
+
return (t = (e = window.rrwebRecord) == null ? void 0 : e.takeFullSnapshot) == null ? void 0 : t.call(e, !0);
|
|
262
|
+
}, "Error recording full snapshot"), me.forEach((e) => {
|
|
263
|
+
var t;
|
|
264
|
+
(t = e.source) == null || t.postMessage({ type: vt }, { targetOrigin: e.origin });
|
|
265
|
+
}));
|
|
294
266
|
};
|
|
295
|
-
|
|
267
|
+
Fe() && (oe("replayStorage").catch(console.error), oe("sprig.replay").catch(console.error));
|
|
296
268
|
const u = new class {
|
|
297
269
|
openDB() {
|
|
298
|
-
return function(e, t, { blocked: n, upgrade: a, blocking: r, terminated:
|
|
299
|
-
const
|
|
300
|
-
return a && (
|
|
301
|
-
a(
|
|
302
|
-
}), n && (
|
|
303
|
-
|
|
270
|
+
return function(e, t, { blocked: n, upgrade: a, blocking: r, terminated: s } = {}) {
|
|
271
|
+
const o = indexedDB.open(e, t), c = T(o);
|
|
272
|
+
return a && (o.onupgradeneeded = (i) => {
|
|
273
|
+
a(T(o.result), i.oldVersion, i.newVersion, T(o.transaction), i);
|
|
274
|
+
}), n && (o.onblocked = (i) => n(i.oldVersion, i.newVersion, i)), c.then((i) => {
|
|
275
|
+
s && (i.onclose = () => s()), r && (i.onversionchange = (l) => r(l.oldVersion, l.newVersion, l));
|
|
304
276
|
}).catch(() => {
|
|
305
277
|
}), c;
|
|
306
278
|
}("sprigReplay", 1, { upgrade: (e, t, n) => {
|
|
307
|
-
if (n === 0 &&
|
|
279
|
+
if (n === 0 && y.setItem("sprig.pendingCount", "0"), !e.objectStoreNames.contains("events")) {
|
|
308
280
|
const a = e.createObjectStore("events", { keyPath: "uuid" });
|
|
309
281
|
a.createIndex("sessionId", "sessionId"), a.createIndex("timestamp", "timestamp"), a.createIndex("[sessionId+timestamp]", ["sessionId", "timestamp"]);
|
|
310
282
|
}
|
|
@@ -319,7 +291,7 @@ const u = new class {
|
|
|
319
291
|
} });
|
|
320
292
|
}
|
|
321
293
|
deleteDB() {
|
|
322
|
-
return
|
|
294
|
+
return oe("sprigReplay").catch(console.error);
|
|
323
295
|
}
|
|
324
296
|
async bulkAdd(e, t) {
|
|
325
297
|
const n = (await this.openDB()).transaction(e, "readwrite");
|
|
@@ -331,8 +303,7 @@ const u = new class {
|
|
|
331
303
|
}
|
|
332
304
|
async deleteBySessionId(e, t) {
|
|
333
305
|
const n = IDBKeyRange.only(t), a = (await this.openDB()).transaction(e, "readwrite"), r = a.store.index("sessionId");
|
|
334
|
-
for await (const
|
|
335
|
-
await o.delete();
|
|
306
|
+
for await (const s of r.iterate(n)) await s.delete();
|
|
336
307
|
await a.done;
|
|
337
308
|
}
|
|
338
309
|
async updatePartial(e, t, n) {
|
|
@@ -340,420 +311,380 @@ const u = new class {
|
|
|
340
311
|
r && await a.store.put({ ...r, ...n }), await a.done;
|
|
341
312
|
}
|
|
342
313
|
async deleteRowsBefore(e, t, n = () => !0) {
|
|
343
|
-
const a = IDBKeyRange.upperBound(t, !0), r = (await this.openDB()).transaction(e, "readwrite"),
|
|
344
|
-
for await (const
|
|
345
|
-
n(s.value) && await s.delete();
|
|
314
|
+
const a = IDBKeyRange.upperBound(t, !0), r = (await this.openDB()).transaction(e, "readwrite"), s = r.store.index("timestamp");
|
|
315
|
+
for await (const o of s.iterate(a)) n(o.value) && await o.delete();
|
|
346
316
|
await r.done;
|
|
347
317
|
}
|
|
348
318
|
async getEventsBetween(e, t = Date.now()) {
|
|
349
|
-
if (e >= t)
|
|
350
|
-
|
|
351
|
-
const n = IDBKeyRange.bound([h, e], [h, t], !1, !0);
|
|
319
|
+
if (e >= t) return Promise.resolve([]);
|
|
320
|
+
const n = IDBKeyRange.bound([I, e], [I, t], !1, !0);
|
|
352
321
|
return (await this.openDB()).getAllFromIndex("events", "[sessionId+timestamp]", n);
|
|
353
322
|
}
|
|
354
323
|
async updateEventsExpiredAt(e, t, n = 30) {
|
|
355
|
-
const a = /* @__PURE__ */ new Date(), r = a.setMinutes(a.getMinutes() + (n ?? 30)),
|
|
356
|
-
for await (const i of
|
|
357
|
-
|
|
358
|
-
await o.done;
|
|
324
|
+
const a = /* @__PURE__ */ new Date(), r = a.setMinutes(a.getMinutes() + (n ?? 30)), s = (await this.openDB()).transaction("events", "readwrite"), o = s.store.index("[sessionId+timestamp]"), c = IDBKeyRange.bound([I, e], [I, t], !1, !0);
|
|
325
|
+
for await (const i of o.iterate(c)) await i.update({ ...i.value, expiredAt: r });
|
|
326
|
+
await s.done;
|
|
359
327
|
}
|
|
360
328
|
async deleteChunkUploads(e, t) {
|
|
361
329
|
const n = IDBKeyRange.only([t, e]), a = (await this.openDB()).transaction("chunkUploads", "readwrite");
|
|
362
|
-
let
|
|
363
|
-
for (;
|
|
364
|
-
o.delete(), o = await o.continue();
|
|
330
|
+
let s = await a.store.index("[uploadId+status]").openCursor(n);
|
|
331
|
+
for (; s; ) s.delete(), s = await s.continue();
|
|
365
332
|
await a.done;
|
|
366
333
|
}
|
|
367
334
|
async getChunkUploadsByStatus({ sessionId: e, status: t, uploadId: n }) {
|
|
368
|
-
const a = (await this.openDB()).transaction("chunkUploads", "readonly"), r = n ? a.store.index("[uploadId+status]") : a.store.index("[sessionId+status]"),
|
|
369
|
-
return r.getAll(
|
|
335
|
+
const a = (await this.openDB()).transaction("chunkUploads", "readonly"), r = n ? a.store.index("[uploadId+status]") : a.store.index("[sessionId+status]"), s = n ? IDBKeyRange.only([n, t]) : IDBKeyRange.only([e, t]);
|
|
336
|
+
return r.getAll(s);
|
|
370
337
|
}
|
|
371
338
|
async getPendingCaptures(e = {}) {
|
|
372
|
-
return (await (await this.openDB()).getAllFromIndex("pendingCaptures", "sessionId",
|
|
339
|
+
return (await (await this.openDB()).getAllFromIndex("pendingCaptures", "sessionId", I)).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));
|
|
373
340
|
}
|
|
374
341
|
async markPendingCaptureToCanUpload(e) {
|
|
375
342
|
const t = (await this.openDB()).transaction("pendingCaptures", "readwrite"), n = t.store.index("sessionId");
|
|
376
|
-
for await (const a of n.iterate(
|
|
343
|
+
for await (const a of n.iterate(I)) {
|
|
377
344
|
const r = a.value;
|
|
378
345
|
r.captureParams.responseGroupId === e && await a.update({ ...r, canUpload: !0 });
|
|
379
346
|
}
|
|
380
347
|
await t.done;
|
|
381
348
|
}
|
|
382
349
|
async markPendingHeatmapsReady(e) {
|
|
383
|
-
if (parseInt(
|
|
384
|
-
return null;
|
|
350
|
+
if (parseInt(y.getItem("sprig.pendingCount") ?? "0") === 0) return null;
|
|
385
351
|
const t = Date.now(), n = (await this.openDB()).transaction("pendingCaptures", "readwrite"), a = n.store.index("sessionId");
|
|
386
|
-
for await (const r of a.iterate(
|
|
387
|
-
const
|
|
388
|
-
!
|
|
352
|
+
for await (const r of a.iterate(I)) {
|
|
353
|
+
const s = r.value;
|
|
354
|
+
!s.captureParams.isHeatmap || e && !e.includes(s.uuid) || await r.update({ ...s, targetTimestamp: t, captureParams: { ...s.captureParams, triggerTimestamp: t, replayParams: { ...s.captureParams.replayParams, replayDurationSeconds: Math.floor((t - s.timestamp) / 1e3) } } });
|
|
389
355
|
}
|
|
390
356
|
await n.done;
|
|
391
357
|
}
|
|
392
|
-
}(),
|
|
393
|
-
let
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
},
|
|
397
|
-
if (!
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return void (M = !0);
|
|
410
|
-
ge.splice(0, e.length).forEach((t) => t(e.shift())), e.forEach((t) => R.push(t)), Y = !1;
|
|
411
|
-
}, Tt = () => {
|
|
412
|
-
const e = f.getItem("sprig.alwayson.info");
|
|
358
|
+
}(), x = [];
|
|
359
|
+
let F, Ve, W, Ge, V, $e, _ = [], L = !1, N = 0, G = !1, Ke = !1, ye = [], ee = !1;
|
|
360
|
+
const O = () => G && !L && Date.now() <= W, Bt = ({ apiUrl: e, config: t, triggerSnapshot: n, forceInit: a = !1 }) => {
|
|
361
|
+
G && !a || (y.isStorageAvailable ? (_ = [], ye.splice(0), x.splice(0), N = 0, V = n, Ve = e, F = { responseGroupUuid: t.responseGroupUuid, surveyId: t.surveyId, userAgent: t.userAgent, sdkVersion: t.sdkVersion }, Ge = t.maxDurationSeconds, _t(), G || ($e = window.setInterval(At, 500)), G = !0) : L = !0);
|
|
362
|
+
}, Tt = [P.Drag, P.Input, P.MediaInteraction, P.MouseInteraction, P.MouseMove, P.Scroll, P.Selection, P.TouchMove], Mt = (e) => e.type === B.Custom || e.type === B.IncrementalSnapshot && Tt.includes(e.data.source), fe = (e) => e.some(Mt), At = async () => {
|
|
363
|
+
if (!O()) return void window.clearInterval($e);
|
|
364
|
+
if (We(), !fe(x)) return;
|
|
365
|
+
const e = x[0].timestamp;
|
|
366
|
+
Date.now() - e > 35e3 && (V == null || V());
|
|
367
|
+
}, We = async () => {
|
|
368
|
+
if (_.length || ee) return;
|
|
369
|
+
ee = !0;
|
|
370
|
+
const e = await Lt();
|
|
371
|
+
if (!e) return void (L = !0);
|
|
372
|
+
ye.splice(0, e.length).forEach((t) => t(e.shift())), e.forEach((t) => _.push(t)), ee = !1;
|
|
373
|
+
}, _t = () => {
|
|
374
|
+
const e = y.getItem("sprig.alwayson.info");
|
|
413
375
|
if (e) {
|
|
414
376
|
d.info("Read stored session state", e);
|
|
415
377
|
const t = JSON.parse(e);
|
|
416
|
-
|
|
417
|
-
} else
|
|
418
|
-
|
|
419
|
-
}, Mt = async (e) => {
|
|
378
|
+
L = t.disabled, F = t.metadata, _ = t.uploadUrls, N = t.currentIndex, W = t.expirationTimestamp, t.pendingEventTimestamp && (d.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`), Nt(t.pendingEventTimestamp));
|
|
379
|
+
} else W = 1e3 * Ge + Date.now();
|
|
380
|
+
}, Nt = async (e) => {
|
|
420
381
|
const t = Date.now(), n = (await u.getEventsBetween(e, t)).map((r) => JSON.parse(r.event));
|
|
421
|
-
if (!
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}, Ge = async (e, t) => {
|
|
382
|
+
if (!fe(n)) return;
|
|
383
|
+
Qe(n);
|
|
384
|
+
const a = await qe();
|
|
385
|
+
a && await ze(a, n);
|
|
386
|
+
}, Je = async (e, t) => {
|
|
427
387
|
try {
|
|
428
388
|
const n = await e();
|
|
429
|
-
if (!n.ok)
|
|
430
|
-
throw new Error(`Error ${t}`);
|
|
389
|
+
if (!n.ok) throw new Error(`Error ${t}`);
|
|
431
390
|
return n;
|
|
432
391
|
} catch {
|
|
433
|
-
|
|
392
|
+
L = !0;
|
|
434
393
|
}
|
|
435
|
-
},
|
|
436
|
-
if (!
|
|
437
|
-
return;
|
|
394
|
+
}, ze = async (e, t) => {
|
|
395
|
+
if (!O() || !e) return;
|
|
438
396
|
const n = await (async (a) => {
|
|
439
|
-
const r = new TextEncoder(),
|
|
440
|
-
return
|
|
397
|
+
const r = new TextEncoder(), s = new CompressionStream("gzip"), o = s.writable.getWriter(), c = r.encode(JSON.stringify(a));
|
|
398
|
+
return o.write(c), o.close(), new Uint8Array(await new Response(s.readable).arrayBuffer());
|
|
441
399
|
})(t);
|
|
442
|
-
d.info("Uploading always-on events with presigned url"), await
|
|
443
|
-
},
|
|
444
|
-
if (!
|
|
445
|
-
|
|
446
|
-
const { surveyId: e, responseGroupUuid: t } = _, n = { responseGroupUuid: t, surveyId: e, index: T + 1 };
|
|
400
|
+
d.info("Uploading always-on events with presigned url"), await Je(() => J(e, { body: n, method: "PUT" }), "uploading always-on with presigned url");
|
|
401
|
+
}, Lt = async () => {
|
|
402
|
+
if (!O()) return;
|
|
403
|
+
const { surveyId: e, responseGroupUuid: t } = F, n = { responseGroupUuid: t, surveyId: e, index: N + 1 };
|
|
447
404
|
d.info("Fetching always-on upload urls", n);
|
|
448
|
-
const a = await
|
|
449
|
-
if (!a)
|
|
450
|
-
return;
|
|
405
|
+
const a = await Je(() => J(`${Ve}/sdk/1/replayUrls`, { method: "POST", body: JSON.stringify(n), headers: dt(window.UserLeap) }), "fetching always-on signed urls");
|
|
406
|
+
if (!a) return;
|
|
451
407
|
const r = a.json.signedUrls;
|
|
452
408
|
return d.info("Fetched more always-on upload urls", { body: n, urls: r }), r;
|
|
453
|
-
},
|
|
454
|
-
if (
|
|
455
|
-
return R.shift();
|
|
409
|
+
}, qe = async () => {
|
|
410
|
+
if (_.length) return _.shift();
|
|
456
411
|
const e = new Promise((t) => {
|
|
457
|
-
|
|
412
|
+
ye.push(t);
|
|
458
413
|
});
|
|
459
|
-
return
|
|
460
|
-
},
|
|
461
|
-
var r,
|
|
462
|
-
const t = e.length ? e[e.length - 1].timestamp : Date.now(), n =
|
|
463
|
-
|
|
464
|
-
},
|
|
465
|
-
|
|
466
|
-
const n =
|
|
467
|
-
if (!
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
})(), C.push(t));
|
|
414
|
+
return We(), e;
|
|
415
|
+
}, Qe = (e) => {
|
|
416
|
+
var r, s, o;
|
|
417
|
+
const t = e.length ? e[e.length - 1].timestamp : Date.now(), n = N, a = ((s = (r = window.UserLeap) == null ? void 0 : r.config) == null ? void 0 : s.customMetadata) ?? ((o = window.__cfg) == null ? void 0 : o.customMetadata);
|
|
418
|
+
N++, e.push({ timestamp: t, type: B.Custom, data: { tag: "Sprig_Meta", payload: { ...F, index: n, visitorId: window.UserLeap.visitorId ?? "", timestamp: t, customMetadata: a } } });
|
|
419
|
+
}, Ot = (e, t) => {
|
|
420
|
+
O() && !Ke && (e || x.length) && (e && x.length && (async () => {
|
|
421
|
+
const n = x.splice(0);
|
|
422
|
+
if (!fe(n)) return;
|
|
423
|
+
d.info("Capturing always-on event array to upload"), Qe(n);
|
|
424
|
+
const a = await qe();
|
|
425
|
+
a && await ze(a, n);
|
|
426
|
+
})(), x.push(t));
|
|
473
427
|
};
|
|
474
428
|
window.addEventListener("beforeunload", async () => {
|
|
475
|
-
|
|
429
|
+
Ke = !0, O() && (d.info("Always On handle page unload"), (() => {
|
|
476
430
|
let e;
|
|
477
|
-
|
|
478
|
-
const t = { disabled:
|
|
479
|
-
d.info("Storing session state on unload", t),
|
|
431
|
+
x.length && (e = x[0].timestamp);
|
|
432
|
+
const t = { disabled: L, metadata: F, uploadUrls: _, currentIndex: N, pendingEventTimestamp: e, expirationTimestamp: W };
|
|
433
|
+
d.info("Storing session state on unload", t), y.setItem("sprig.alwayson.info", JSON.stringify(t));
|
|
480
434
|
})());
|
|
481
435
|
});
|
|
482
|
-
const
|
|
436
|
+
const Xe = async (e, t) => {
|
|
483
437
|
const n = performance.now();
|
|
484
438
|
let a;
|
|
485
439
|
try {
|
|
486
440
|
a = await e();
|
|
487
441
|
} finally {
|
|
488
442
|
const r = performance.now() - n;
|
|
489
|
-
let
|
|
490
|
-
|
|
443
|
+
let s = ke[t];
|
|
444
|
+
s || (s = Re(t)), s.report(r / 1e3);
|
|
491
445
|
}
|
|
492
446
|
return a;
|
|
493
|
-
},
|
|
447
|
+
}, Ze = (e, t) => {
|
|
494
448
|
const n = performance.now();
|
|
495
449
|
try {
|
|
496
450
|
e();
|
|
497
451
|
} finally {
|
|
498
452
|
const a = performance.now() - n;
|
|
499
|
-
let r =
|
|
500
|
-
r || (r =
|
|
453
|
+
let r = ke[t];
|
|
454
|
+
r || (r = Re(t)), r.report(a / 1e3);
|
|
501
455
|
}
|
|
502
456
|
};
|
|
503
|
-
let
|
|
504
|
-
const
|
|
457
|
+
let Ye = 5e3, ce = 6e4, le = 0, M, ue = !1, pe = [];
|
|
458
|
+
const Ft = (e) => {
|
|
505
459
|
var t, n, a, r;
|
|
506
460
|
if ((t = e.event) != null && t.includes("Sprig_Scroll")) {
|
|
507
|
-
const
|
|
508
|
-
if (!
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const e = le;
|
|
518
|
-
le = [], ce = !1, ze(async () => {
|
|
461
|
+
const s = (r = (a = (n = JSON.parse(e.event)) == null ? void 0 : n.data) == null ? void 0 : a.payload) == null ? void 0 : r.xPath;
|
|
462
|
+
if (!s) return;
|
|
463
|
+
g.scrollEventUuids[s] = e.uuid;
|
|
464
|
+
}
|
|
465
|
+
pe.push(e), ue || Ht();
|
|
466
|
+
}, Ht = () => {
|
|
467
|
+
ue = !0, setTimeout(async () => {
|
|
468
|
+
if (R()) return;
|
|
469
|
+
const e = pe;
|
|
470
|
+
pe = [], ue = !1, Ze(async () => {
|
|
519
471
|
await (async (t) => {
|
|
520
|
-
const n = t.map((a) => ({ ...a, sessionId: a.sessionId ??
|
|
521
|
-
if (n.length !== 0)
|
|
522
|
-
return I(() => u.bulkAdd("events", n), "Error storing replay events");
|
|
472
|
+
const n = t.map((a) => ({ ...a, sessionId: a.sessionId ?? I }));
|
|
473
|
+
if (n.length !== 0) return D(() => u.bulkAdd("events", n), "Error storing replay events");
|
|
523
474
|
})(e);
|
|
524
475
|
}, "sdk_replay_add_event_batch_seconds");
|
|
525
476
|
}, 500);
|
|
526
|
-
},
|
|
527
|
-
|
|
477
|
+
}, jt = (e, t, n) => {
|
|
478
|
+
g.cleanupInterval = window.setInterval(() => {
|
|
528
479
|
const a = Date.now();
|
|
529
|
-
|
|
530
|
-
|
|
480
|
+
Xe(() => D(async () => {
|
|
481
|
+
R() || await Promise.all([u.deleteRowsBefore("events", a - 1e3 * e, (r) => r.expiredAt === void 0 || r.expiredAt < a - 1e3 * e), u.deleteRowsBefore("chunkUploads", a - 1e3 * t), u.deleteRowsBefore("pendingCaptures", a - 1e3 * n, (r) => !r.canUpload)]);
|
|
531
482
|
}, "Error deleting table rows"), "sdk_replay_cleanup_seconds"), d.debug("CleanupComplete");
|
|
532
483
|
}, 3e4);
|
|
533
|
-
},
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
await
|
|
484
|
+
}, Vt = () => {
|
|
485
|
+
g.pendingCheckInterval = window.setInterval(async () => {
|
|
486
|
+
D(async () => {
|
|
487
|
+
await ge();
|
|
537
488
|
}, "Error initiating pending captures");
|
|
538
489
|
}, 5e3);
|
|
539
490
|
};
|
|
540
|
-
let
|
|
541
|
-
const
|
|
542
|
-
if (!
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const o = Math.min(e + r, n), s = await Je(() => u.getEventsBetween(e, o), "sdk_replay_get_events_between_seconds");
|
|
555
|
-
if (!(s != null && s.length))
|
|
556
|
-
return d.debug("NoEventsFound"), { validStartFound: a, events: [] };
|
|
491
|
+
let te = !1;
|
|
492
|
+
const ge = async (e = !1) => {
|
|
493
|
+
if (!te) try {
|
|
494
|
+
te = !0;
|
|
495
|
+
const t = parseInt(M ?? "0");
|
|
496
|
+
if (t === 0) return;
|
|
497
|
+
const n = await u.getPendingCaptures({ beforePresent: !0, isBeforeType: e }), a = await u.openDB();
|
|
498
|
+
await Promise.all(n.map(async (r) => (await a.delete("pendingCaptures", r.uuid), nt(r.captureParams, r.canUpload)))), M = (t - n.length).toString(), y.setItem("sprig.pendingCount", M);
|
|
499
|
+
} finally {
|
|
500
|
+
te = !1;
|
|
501
|
+
}
|
|
502
|
+
}, Gt = async (e, t, n, a, r) => {
|
|
503
|
+
const s = Math.min(e + r, n), o = await Xe(() => u.getEventsBetween(e, s), "sdk_replay_get_events_between_seconds");
|
|
504
|
+
if (!(o != null && o.length)) return d.debug("NoEventsFound"), { validStartFound: a, events: [] };
|
|
557
505
|
if (!a) {
|
|
558
506
|
d.debug("ValidStartSearch");
|
|
559
507
|
let c = -1;
|
|
560
|
-
return
|
|
561
|
-
if (!i.isValidStart)
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
var s;
|
|
508
|
+
return o == null || o.forEach((i, l) => {
|
|
509
|
+
if (!i.isValidStart) return;
|
|
510
|
+
const w = i.timestamp <= t;
|
|
511
|
+
(c < 0 || w) && (c = l);
|
|
512
|
+
}), c < 0 ? (d.debug("ValidStartNotFound"), { validStartFound: a, events: [] }) : { validStartFound: !0, events: o == null ? void 0 : o.slice(c) };
|
|
513
|
+
}
|
|
514
|
+
return { validStartFound: a, events: o };
|
|
515
|
+
}, et = (e) => Promise.all(e.map(async (t) => {
|
|
516
|
+
const n = await (async (a) => xe.execute(async () => {
|
|
517
|
+
var o;
|
|
571
518
|
d.info("UploadChunkStart", { chunkIndex: a.chunkIndex, surveyId: a.surveyId });
|
|
572
|
-
const r = await
|
|
519
|
+
const r = await J(a.uploadUrl, { body: a.data, method: "PUT" });
|
|
573
520
|
d.http("UploadChunkEnd", { url: a.uploadUrl, method: "PUT", status_code: r.status, reason: r.statusText ?? "OK", chunkIndex: a.chunkIndex, surveyId: a.surveyId });
|
|
574
|
-
const
|
|
575
|
-
if (!
|
|
576
|
-
|
|
577
|
-
return o;
|
|
521
|
+
const s = (o = r.headers) == null ? void 0 : o.get("ETag");
|
|
522
|
+
if (!s) throw new Error(`Upload response did not include etag for upload ${a.uploadId}, part ${a.chunkIndex}`);
|
|
523
|
+
return s;
|
|
578
524
|
}))(t);
|
|
579
525
|
return await u.updatePartial("chunkUploads", t.uuid, { data: null, etag: n, status: "UploadComplete" }), t.uploadId;
|
|
580
|
-
})),
|
|
526
|
+
})), tt = async (e) => {
|
|
581
527
|
const t = await u.getChunkUploadsByStatus({ status: "UploadComplete", uploadId: e });
|
|
582
|
-
if (!(t != null && t.length))
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
n.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
return;
|
|
593
|
-
const t = await Qe(e);
|
|
528
|
+
if (!(t != null && t.length)) return void d.info("NoChunksForUpload", { uploadId: e });
|
|
529
|
+
const n = t.reduce((s, o) => (s.find((c) => c.chunkIndex === o.chunkIndex) || s.push(o), s), []);
|
|
530
|
+
n.sort((s, o) => s.chunkIndex - o.chunkIndex);
|
|
531
|
+
const a = n.map((s) => ({ ETag: s.etag, PartNumber: s.chunkIndex })).filter((s) => s.ETag !== null), r = n[0];
|
|
532
|
+
await Be({ apiUrl: r.apiUrl, surveyId: r.surveyId, uploadId: e, responseGroupUuid: r.responseGroupId, etags: a, headers: r.completeUploadHeaders, replayDuration: r.replayDuration }), await u.deleteChunkUploads("UploadComplete", e);
|
|
533
|
+
}, $t = () => {
|
|
534
|
+
D(async () => {
|
|
535
|
+
const e = await u.getChunkUploadsByStatus({ sessionId: I, status: "ReadyForUpload" });
|
|
536
|
+
if (!(e != null && e.length)) return;
|
|
537
|
+
const t = await et(e);
|
|
594
538
|
t != null && t.length && await Promise.all(t.map((n) => {
|
|
595
|
-
if (n)
|
|
596
|
-
return Xe(n);
|
|
539
|
+
if (n) return tt(n);
|
|
597
540
|
}));
|
|
598
541
|
}, "Error uploading unfinished chunks");
|
|
599
|
-
},
|
|
542
|
+
}, Kt = async (e, t) => {
|
|
600
543
|
const n = t ?? Date.now();
|
|
601
544
|
return (async (a, r) => {
|
|
602
|
-
const
|
|
603
|
-
let
|
|
545
|
+
const s = new TextEncoder();
|
|
546
|
+
let o = null;
|
|
604
547
|
const c = new CompressionStream("gzip"), i = c.writable.getWriter();
|
|
605
|
-
let l = !1,
|
|
606
|
-
for (let
|
|
607
|
-
if ({ validStartFound:
|
|
548
|
+
let l = !1, w = !1, [p, h] = [0, 0], m = [];
|
|
549
|
+
for (let U = a - 35e3; U < r; U += ce) {
|
|
550
|
+
if ({ validStartFound: w, events: m } = await Gt(U, a, r, w, ce), !(m != null && m.length)) {
|
|
608
551
|
d.debug("NoEventsFound");
|
|
609
552
|
continue;
|
|
610
553
|
}
|
|
611
|
-
p === 0 && (p =
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
i.write(
|
|
554
|
+
p === 0 && (p = m[0].timestamp), h = m[m.length - 1].timestamp;
|
|
555
|
+
const f = m.map((C) => C.event);
|
|
556
|
+
f.push(`{"timestamp":${r}}`);
|
|
557
|
+
const v = `${l ? "," : "["}${f}`, S = s.encode(v);
|
|
558
|
+
Ze(() => {
|
|
559
|
+
i.write(S);
|
|
617
560
|
}, "sdk_replay_compression_seconds"), l = !0;
|
|
618
561
|
}
|
|
619
|
-
if (
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
return i.write(v), i.close(), s = new Uint8Array(await new Response(c.readable).arrayBuffer()), s;
|
|
562
|
+
if (h - p < Ye) return d.debug("ReplayTooShort"), null;
|
|
563
|
+
const E = s.encode("]");
|
|
564
|
+
return i.write(E), i.close(), o = new Uint8Array(await new Response(c.readable).arrayBuffer()), o;
|
|
623
565
|
})(n - e, n);
|
|
624
|
-
},
|
|
625
|
-
const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders:
|
|
626
|
-
if (!(i != null && i.length))
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
const g = W(), v = { apiUrl: r, chunkIndex: m + 1, completeUploadHeaders: o, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: c, totalChunks: l.length, data: p, uploadId: s.uploadId, uploadUrl: s.signedUrls[m].url, uuid: g, visitorId: a };
|
|
636
|
-
return await (await u.openDB()).add("chunkUploads", { ...v, sessionId: v.sessionId ?? h }), v;
|
|
566
|
+
}, Ce = async (e) => {
|
|
567
|
+
const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: s, replayParams: o, triggerTimestamp: c } = e, i = await Kt(1e3 * o.replayDurationSeconds, c);
|
|
568
|
+
if (!(i != null && i.length)) return void d.info("FileDataEmpty", { surveyId: t });
|
|
569
|
+
const l = ((p, h, m) => {
|
|
570
|
+
const E = p.length, U = 1024 * h * 1024, f = Math.ceil(E / m), v = Math.max(U, f), S = [];
|
|
571
|
+
let C = 0;
|
|
572
|
+
for (; C < E; ) S.push(p.slice(C, C + v)), C += v;
|
|
573
|
+
return S;
|
|
574
|
+
})(i, o.minimumChunkSizeMb, o.signedUrls.length), w = await Promise.all(l.map(async (p, h) => {
|
|
575
|
+
const m = z(), E = { apiUrl: r, chunkIndex: h + 1, completeUploadHeaders: s, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: c, totalChunks: l.length, data: p, uploadId: o.uploadId, uploadUrl: o.signedUrls[h].url, uuid: m, visitorId: a };
|
|
576
|
+
return await (await u.openDB()).add("chunkUploads", { ...E, sessionId: E.sessionId ?? I }), E;
|
|
637
577
|
}));
|
|
638
|
-
await (async (p,
|
|
639
|
-
await
|
|
640
|
-
})([
|
|
641
|
-
},
|
|
642
|
-
if (
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
r.replayDurationType === "before" ? await De(e) : await u.markPendingCaptureToCanUpload(s);
|
|
578
|
+
await (async (p, h) => {
|
|
579
|
+
await et(h), await Promise.all(p.map((m) => tt(m)));
|
|
580
|
+
})([o.uploadId], w);
|
|
581
|
+
}, nt = async (e, t) => {
|
|
582
|
+
if (R()) return d.debug("ReplayDisabled-ScheduleOrCapture");
|
|
583
|
+
const { isHeatmap: n, isStandalone: a, replayParams: r, triggerTimestamp: s, responseGroupId: o } = e, c = async () => {
|
|
584
|
+
setTimeout(() => H.removeListener(X.QuestionAnswered, c), 0), D(async () => {
|
|
585
|
+
r.replayDurationType === "before" ? await Ce(e) : await u.markPendingCaptureToCanUpload(o);
|
|
647
586
|
}, "Error in schedule/capture callback");
|
|
648
587
|
};
|
|
649
|
-
|
|
588
|
+
D(async () => {
|
|
650
589
|
if (r.replayDurationType === "after" || r.replayDurationType === "beforeAndAfter")
|
|
651
|
-
return !a && !n &&
|
|
652
|
-
if (a || n || t)
|
|
653
|
-
await De(e), n && Gt();
|
|
590
|
+
return !a && !n && H.on(X.QuestionAnswered, c), void await rt(e);
|
|
591
|
+
if (a || n || t) await Ce(e), n && Wt();
|
|
654
592
|
else {
|
|
655
|
-
const i = 35 + r.replayDurationSeconds, l =
|
|
656
|
-
await u.updateEventsExpiredAt(l,
|
|
593
|
+
const i = 35 + r.replayDurationSeconds, l = s - 1e3 * i, w = s;
|
|
594
|
+
await u.updateEventsExpiredAt(l, w, r.expirationTimeLimitMinutes), H.on(X.QuestionAnswered, c);
|
|
657
595
|
}
|
|
658
596
|
}, "Error in scheduling/capturing replay");
|
|
659
|
-
},
|
|
660
|
-
parseInt(
|
|
661
|
-
},
|
|
662
|
-
|
|
663
|
-
}),
|
|
664
|
-
if (
|
|
665
|
-
return;
|
|
597
|
+
}, Wt = async () => {
|
|
598
|
+
parseInt(M ?? "0") || y.removeItem("sprig.isCapturingHeatmap"), y.getItem("sprig.teardownAfterCapture") && (He(), at(), y.removeItem("sprig.teardownAfterCapture"));
|
|
599
|
+
}, at = async () => R() ? d.debug("ReplayDisabled-ClearData") : Promise.all([u.deleteBySessionId("events", I), u.deleteBySessionId("pendingCaptures", I)]).catch((e) => {
|
|
600
|
+
q("Error clearing user replay data", e);
|
|
601
|
+
}), rt = async (e) => {
|
|
602
|
+
if (R()) return;
|
|
666
603
|
const { isHeatmap: t, surveyId: n } = e, a = await u.getPendingCaptures(), r = a == null ? void 0 : a.filter((i) => i.captureParams.surveyId === n);
|
|
667
|
-
if (r != null && r.length)
|
|
668
|
-
|
|
669
|
-
t && (w.isRecording && I(() => {
|
|
670
|
-
var i, l;
|
|
671
|
-
return (l = (i = window.rrwebRecord) == null ? void 0 : i.takeFullSnapshot) == null ? void 0 : l.call(i, !0);
|
|
672
|
-
}, "Error recording full snapshot"), f.setItem("sprig.isCapturingHeatmap", "true"), de = Date.now(), w.inactivityInterval || (w.inactivityInterval = window.setInterval(() => {
|
|
604
|
+
if (r != null && r.length) return void d.info("PendingCaptureExists", { surveyId: n });
|
|
605
|
+
t && (je(), y.setItem("sprig.isCapturingHeatmap", "true"), le = Date.now(), g.inactivityInterval || (g.inactivityInterval = window.setInterval(() => {
|
|
673
606
|
var i;
|
|
674
|
-
i =
|
|
607
|
+
i = le, Date.now() - i >= 3e4 && D(() => u.markPendingHeatmapsReady(), "Error in heatmap inactivity");
|
|
675
608
|
}, 1e3)));
|
|
676
|
-
const
|
|
677
|
-
e.replayParams.replayDurationType === "beforeAndAfter" && (
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
},
|
|
681
|
-
|
|
609
|
+
const s = { ...e, replayParams: { ...e.replayParams } };
|
|
610
|
+
e.replayParams.replayDurationType === "beforeAndAfter" && (s.replayParams.replayDurationSeconds *= 2), s.replayParams.replayDurationType = "before";
|
|
611
|
+
const o = e.triggerTimestamp + 1e3 * e.replayParams.replayDurationSeconds;
|
|
612
|
+
s.triggerTimestamp = o, M = (parseInt(M ?? "0") + 1).toString(), y.setItem("sprig.pendingCount", M), await (await u.openDB()).add("pendingCaptures", { canUpload: !1, captureParams: s, sessionId: I, targetTimestamp: o, timestamp: Date.now(), uuid: z() });
|
|
613
|
+
}, Jt = Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
|
|
614
|
+
A("Sprig_TrackEvent", e);
|
|
682
615
|
}, RecordPageView: (e) => {
|
|
683
|
-
e.description && (e.description =
|
|
616
|
+
e.description && (e.description = we(e.description)), A("Sprig_PageView", e);
|
|
684
617
|
}, RecordSurveyShown: (e) => {
|
|
685
|
-
|
|
618
|
+
A("Sprig_ShowSurvey", e);
|
|
686
619
|
}, _completeSessionReplay: async ({ surveyId: e, responseGroupUuid: t, eventDigest: n, headers: a }) => {
|
|
687
|
-
if (!e || !t)
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
const e = (await u.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !at(t)).map(({ uuid: t }) => t);
|
|
620
|
+
if (!e || !t) return !1;
|
|
621
|
+
const r = window.UserLeap._API_URL, s = await Be({ surveyId: e, responseGroupUuid: t, eventDigest: n, apiUrl: r, headers: a }, !0);
|
|
622
|
+
return !(s != null && s.error);
|
|
623
|
+
}, checkPendingHeatmapsUrl: () => R() ? d.debug("ReplayDisabled-PendingHeatmaps") : D(async () => {
|
|
624
|
+
const e = (await u.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !it(t)).map(({ uuid: t }) => t);
|
|
693
625
|
return d.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await u.markPendingHeatmapsReady(e), d.info("MarkedPendingHeatmapsReady")), e.length;
|
|
694
|
-
}, "Error marking pending heatmaps ready"), clearUserReplayData:
|
|
695
|
-
if (
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
return;
|
|
700
|
-
if (a && f.setItem("sprig.teardownAfterCapture", "true"), b())
|
|
701
|
-
return d.debug("ReplayDisabled");
|
|
626
|
+
}, "Error marking pending heatmaps ready"), clearUserReplayData: at, disableRecording: q, initializeReplay: async ({ maxReplayDurationSeconds: e, maxInflightRequests: t = 2, replaySettings: n, teardownAfter: a = !1, apiUrl: r, alwaysOnConfig: s }) => {
|
|
627
|
+
if (s && Bt({ apiUrl: r, config: s, triggerSnapshot: () => {
|
|
628
|
+
je();
|
|
629
|
+
} }), M = y.getItem("sprig.pendingCount"), g.isRecording) return;
|
|
630
|
+
if (a && y.setItem("sprig.teardownAfterCapture", "true"), R()) return d.debug("ReplayDisabled");
|
|
702
631
|
if (await (async () => {
|
|
703
632
|
var i;
|
|
704
|
-
if (!
|
|
633
|
+
if (!Fe()) return !0;
|
|
634
|
+
if ((i = window.navigator.storage) != null && i.estimate) try {
|
|
635
|
+
const { quota: l = 0, usage: w = 0 } = await window.navigator.storage.estimate(), p = (l - w) / 1024 ** 3;
|
|
636
|
+
return d.info("Storage", { availableGb: p }), p < 0.5;
|
|
637
|
+
} catch {
|
|
705
638
|
return !0;
|
|
706
|
-
|
|
707
|
-
try {
|
|
708
|
-
const { quota: l = 0, usage: y = 0 } = await window.navigator.storage.estimate(), p = (l - y) / 1024 ** 3;
|
|
709
|
-
return d.info("Storage", { availableGb: p }), p < 0.5;
|
|
710
|
-
} catch {
|
|
711
|
-
return !0;
|
|
712
|
-
}
|
|
639
|
+
}
|
|
713
640
|
return !1;
|
|
714
|
-
})())
|
|
715
|
-
return d.debug("IDBNotSupported"), se();
|
|
641
|
+
})()) return d.debug("IDBNotSupported"), de();
|
|
716
642
|
try {
|
|
717
643
|
const i = await u.openDB();
|
|
718
644
|
d.info("DBVersion", { version: i.version });
|
|
719
645
|
} catch (i) {
|
|
720
|
-
return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" && u.deleteDB(),
|
|
646
|
+
return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" && u.deleteDB(), de();
|
|
721
647
|
}
|
|
722
|
-
|
|
723
|
-
await
|
|
648
|
+
D(async () => {
|
|
649
|
+
await ge(!0);
|
|
724
650
|
}, "Error uploading ready pending captures");
|
|
725
|
-
const
|
|
726
|
-
if (!c)
|
|
727
|
-
|
|
728
|
-
d.debug("ReplayInit"), await I(async () => {
|
|
651
|
+
const o = O() ? 30 : 0, c = Math.max(e ?? 0, o);
|
|
652
|
+
if (!c) return d.debug("MissingDuration");
|
|
653
|
+
d.debug("ReplayInit"), await D(async () => {
|
|
729
654
|
var i;
|
|
730
|
-
|
|
731
|
-
|
|
655
|
+
n != null && n.minDuration && (Ye = n.minDuration), n != null && n.batchDuration && (ce = n.batchDuration), i = t, xe.setLimit(i), $t(), jt(c + 35, 1800, c + 35), Vt();
|
|
656
|
+
const l = window.UserLeap.replayLibraryURL ?? "https://cdn.sprig.com/dependencies/record-2.0.0-alpha.17.min.js";
|
|
657
|
+
if (!window.rrwebRecord) {
|
|
658
|
+
const { record: f } = await import(
|
|
732
659
|
/* webpackIgnore: true */
|
|
733
660
|
/* @vite-ignore */
|
|
734
|
-
|
|
661
|
+
l
|
|
735
662
|
);
|
|
736
|
-
window.rrwebRecord =
|
|
663
|
+
window.rrwebRecord = f;
|
|
737
664
|
}
|
|
738
|
-
const
|
|
739
|
-
if (!
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
if (
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
ot("sdk_replay_snapshot_seconds", k / 1e3);
|
|
665
|
+
const w = window.rrwebRecord;
|
|
666
|
+
if (!w) return d.error("RecordScriptFailed");
|
|
667
|
+
let p = !0, h = 0;
|
|
668
|
+
const m = { checkoutEveryNms: 3e4, sampling: { input: "last", scroll: 250, media: 800 }, ...n };
|
|
669
|
+
var E, U;
|
|
670
|
+
g.stopRecording = w({ emit: (f, v) => {
|
|
671
|
+
if (f.type === B.Custom && (le = Date.now()), R()) return;
|
|
672
|
+
if (v && f.type === B.Meta) h = performance.now();
|
|
673
|
+
else if (v && h && f.type === B.FullSnapshot) {
|
|
674
|
+
const C = performance.now() - h;
|
|
675
|
+
ct("sdk_replay_snapshot_seconds", C / 1e3);
|
|
750
676
|
}
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
}, ...
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
677
|
+
const S = p || !!v && f.type === B.Meta;
|
|
678
|
+
p = !1, Ot(S, f), Ft({ uuid: z(), event: JSON.stringify(f), isValidStart: S, timestamp: Date.now() });
|
|
679
|
+
}, ...m }), g.isRecording = !!g.stopRecording, g.isRecording && (((f, v) => {
|
|
680
|
+
window.addEventListener("message", (S) => {
|
|
681
|
+
var C;
|
|
682
|
+
S.data.type === ht && (me.push({ source: S.source, origin: S.origin }), (C = S.source) == null || C.postMessage({ type: It, settings: f, replayLibraryUrl: v }, { targetOrigin: S.origin }));
|
|
683
|
+
});
|
|
684
|
+
})(m, l), H.on("survey.complete", (f) => {
|
|
685
|
+
var v;
|
|
686
|
+
v = { id: f, userAgent: window.navigator.userAgent }, A("Sprig_SubmitSurvey", v);
|
|
687
|
+
}), E = A, U = Ut, K || (b = E, j = U, window.addEventListener("click", Ne, k), window.addEventListener("pointerdown", Oe, k), window.addEventListener("mousedown", Le, k), window.addEventListener("keydown", Ae, k), window.addEventListener("scroll", _e, k), K = !0, kt(), Rt()));
|
|
757
688
|
}, "Error initializing replay");
|
|
758
|
-
}, isReplayRecording: () =>
|
|
759
|
-
|
|
689
|
+
}, isReplayRecording: () => g.isRecording, scheduleCapture: rt, scheduleOrCaptureReplay: nt, tryReplayAction: D, uploadReadyPendingCaptures: ge }, Symbol.toStringTag, { value: "Module" }));
|
|
690
|
+
lt(Jt);
|