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