@sprig-technologies/sprig-browser 2.41.3 → 2.42.1
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-CA3qI7QP.cjs → conversational-ui-Bxn2-bHk.cjs} +1 -1
- package/dist/{conversational-ui-Dh8pa8lZ.js → conversational-ui-D6UnLFmt.js} +4 -4
- package/dist/core-C7eAp3i8.cjs +12 -0
- package/dist/core-D9RfS2Z8.js +1003 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +34 -50
- package/dist/core.js +6 -5
- package/dist/{getAttributedUrl-DUf8Ossa.js → getAttributedUrl-BkFxZZq1.js} +3 -3
- package/dist/{getAttributedUrl-NpiI9_tt.cjs → getAttributedUrl-DndmCZhi.cjs} +1 -1
- package/dist/{index-Dx7xdcFy.cjs → index-C3QpXMSG.cjs} +1 -1
- package/dist/{index-D3K1BCMf.js → index-CygVREGR.js} +68 -68
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +34 -50
- package/dist/index.js +7 -6
- package/dist/{metricsReporter-BGxaFPwL.js → metricsReporter-DqmmYkn-.js} +1 -1
- package/dist/{metricsReporter-DYupscmb.cjs → metricsReporter-Dy6jXbOf.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +410 -408
- package/dist/view-BlV4gOTD.cjs +1 -0
- package/dist/{view-CbuHTm4G.js → view-q6KAoLll.js} +461 -458
- package/package.json +1 -1
- package/dist/core-Ciwf_Oir.cjs +0 -12
- package/dist/core-DcjPmwAM.js +0 -975
- package/dist/view-D7g2wJX6.cjs +0 -1
|
@@ -0,0 +1,1003 @@
|
|
|
1
|
+
var At = Object.defineProperty;
|
|
2
|
+
var Ot = (r, e, i) => e in r ? At(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i;
|
|
3
|
+
var B = (r, e, i) => Ot(r, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { l as H, g as O, s as lt, e as g, S as u, v as dt, m as T, b as P, h as ct, E as se, a as Q, D as C, c as Ct, r as K, i as Pt, j as Mt, k as jt, n as Ge, o as Ke, d as Ft, p as pt, q as ut } from "./metricsReporter-DqmmYkn-.js";
|
|
5
|
+
const ur = 360, gr = "ul-app", hr = "#e6e6e6", yr = "#bd282a", br = 1030, Je = () => {
|
|
6
|
+
try {
|
|
7
|
+
return window.parent.Intercom;
|
|
8
|
+
} catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
}, Qe = [Object.freeze(Object.defineProperty({ __proto__: null, disable: () => {
|
|
12
|
+
const r = Je();
|
|
13
|
+
r && (r.ul_wasVisible = !!document.querySelector("iframe.intercom-launcher-frame"), r.ul_wasVisible && r("update", { hide_default_launcher: !0 }));
|
|
14
|
+
}, enable: () => {
|
|
15
|
+
const r = Je();
|
|
16
|
+
r && (r.ul_wasVisible && r("update", { hide_default_launcher: !1 }), delete r.ul_wasVisible);
|
|
17
|
+
} }, Symbol.toStringTag, { value: "Module" }))];
|
|
18
|
+
class qt {
|
|
19
|
+
static disable() {
|
|
20
|
+
Qe.forEach((e) => e.disable());
|
|
21
|
+
}
|
|
22
|
+
static enable() {
|
|
23
|
+
Qe.forEach((e) => e.enable());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const Ye = "ul-view-sdk-script", Ht = /* @__PURE__ */ new Set(["ios", "android"]), F = "visitors", q = "environments";
|
|
27
|
+
async function D(r, e) {
|
|
28
|
+
var s, n, o;
|
|
29
|
+
const { shouldDropOnRateLimit: i, ...a } = e;
|
|
30
|
+
a.headers = Object.assign(O(window.UserLeap), a.headers);
|
|
31
|
+
const t = await lt(r, { ...a, shouldDropOnRateLimit: i });
|
|
32
|
+
if (t.ok) {
|
|
33
|
+
const l = (s = t.headers) == null ? void 0 : s.get("Authorization"), c = l ? l.split(" ") : void 0, d = c && c.length === 2 ? c[1] : void 0, p = (n = t.headers) == null ? void 0 : n.get("x-ul-visitor-id");
|
|
34
|
+
if (window.UserLeap.userId && p === window.UserLeap.visitorId) {
|
|
35
|
+
const m = H.getItemObject("sprig.anon.env.vid.map");
|
|
36
|
+
m && m[window.UserLeap.envId] === p && (delete m[window.UserLeap.envId], H.setItemObject("sprig.anon.env.vid.map", m));
|
|
37
|
+
}
|
|
38
|
+
d && p && (p !== window.UserLeap.visitorId || window.UserLeap.token !== d) && (E("token", d), E("vid", p), g.emit(u.VisitorIDUpdated, { visitorId: p }), window.UserLeap.token = d, window.UserLeap.visitorId = p);
|
|
39
|
+
}
|
|
40
|
+
return (o = t.json) != null && o.logMessage && console.warn(`[Sprig] ${t.json.logMessage}`), t;
|
|
41
|
+
}
|
|
42
|
+
function E(r, e) {
|
|
43
|
+
const i = H.getItemObject("userleap.ids");
|
|
44
|
+
let a = i[window.UserLeap.envId];
|
|
45
|
+
a ? a[r] = e : a = { [r]: e }, i[window.UserLeap.envId] = a, H.setItemObject("userleap.ids", i);
|
|
46
|
+
}
|
|
47
|
+
function Oe() {
|
|
48
|
+
return window.previewMode ? "0" : window.UserLeap.visitorId ?? "";
|
|
49
|
+
}
|
|
50
|
+
function R(r, e, i) {
|
|
51
|
+
const a = [window.UserLeap._API_URL, "sdk", r];
|
|
52
|
+
return e && e.forEach((t) => {
|
|
53
|
+
a.push(t), t === q ? a.push(window.UserLeap.envId) : t === F && a.push(Oe());
|
|
54
|
+
}), i && a.push(i), a.join("/");
|
|
55
|
+
}
|
|
56
|
+
const ee = async (r, e, i) => {
|
|
57
|
+
var Ve, We, Ne, Be;
|
|
58
|
+
const { context: a, delay: t, avatars: s, forceBrandedLogo: n, endCard: o, isFeedback: l = !1, heatmap: c, locale: d, layout: p, previewMode: m, productConfig: h, questions: y, responseGroupUid: f, surveyId: b, uuid: v, vid: I, sessionReplay: S, studyType: k, surveyVisitorAttributes: z } = r, w = O(window.UserLeap), V = ae(w), x = ve(w);
|
|
59
|
+
if (S) if (V) g.emit(u.ReplayCapture, { responseGroupUid: f, hasQuestions: !!(y != null && y.length), surveyId: b, uploadId: S.uploadId, replayType: S.replayDurationType ?? "before", seconds: S.replayDurationSeconds, generateVideoUploadUrlPayload: { mediaRecordingUid: dt(), mediaType: "screen", questionId: 1, responseGroupUid: f, surveyId: b, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), visitorId: window.UserLeap.visitorId, isReplay: !0 } });
|
|
60
|
+
else {
|
|
61
|
+
if (!T.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
|
|
62
|
+
T.replay.scheduleOrCaptureReplay({ responseGroupId: f, surveyId: b, visitorId: I, replayParams: S, completeUploadHeaders: w, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: y.length === 0 });
|
|
63
|
+
}
|
|
64
|
+
if (c) {
|
|
65
|
+
if (!T.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
|
|
66
|
+
const { eventId: U, replayParams: N, responseGroupUid: Se, surveyId: Ue } = c;
|
|
67
|
+
await T.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0, apiUrl: window.UserLeap._API_URL, replaySettings: i }), T.replay.tryReplayAction(() => {
|
|
68
|
+
var $e;
|
|
69
|
+
return ($e = T.replay) == null ? void 0 : $e.scheduleCapture({ apiUrl: window.UserLeap._API_URL, completeUploadHeaders: w, eventId: U, isHeatmap: !0, replayParams: N, responseGroupId: Se, surveyId: Ue, triggerTimestamp: Date.now(), visitorId: I });
|
|
70
|
+
}, "Error in scheduling/capturing replay");
|
|
71
|
+
}
|
|
72
|
+
if (I == null || !(y != null && y.length)) return P.info("CannotDisplaySurvey", { vid: I }), { success: !1, message: "[Sprig] no survey found", surveyState: window.UserLeap.container ? "previous survey ready" : "no survey" };
|
|
73
|
+
if (window.UserLeap.container) {
|
|
74
|
+
P.info("AlreadyDisplayingSurvey");
|
|
75
|
+
const U = "[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";
|
|
76
|
+
return console.warn(U), { success: !1, message: U, surveyState: "previous survey ready" };
|
|
77
|
+
}
|
|
78
|
+
if (I !== window.UserLeap.visitorId && v !== window.UserLeap.visitorId && !window.previewMode) {
|
|
79
|
+
const U = "Attempted to display survey to a different visitor";
|
|
80
|
+
return window.UserLeap.reportError("DisplaySurvey", new Error(U)), { success: !1, message: U, surveyState: "no survey" };
|
|
81
|
+
}
|
|
82
|
+
P.info("ShowingSurvey", { surveyId: b }), (Ve = T.replay) == null || Ve.RecordSurveyShown({ id: b, userAgent: window.navigator.userAgent }), qt.disable(), g.emit(u.SurveyWillPresent, { name: u.SurveyWillPresent, "survey.id": b, layout: p });
|
|
83
|
+
let W, M, _, oe, ne = document.createElement("div");
|
|
84
|
+
const Fe = (U) => {
|
|
85
|
+
const { "view.version": N } = U;
|
|
86
|
+
N !== w["x-ul-sdk-version"] && ht(), g.removeListener("verify.view.version", Fe);
|
|
87
|
+
};
|
|
88
|
+
g.on("verify.view.version", Fe), window.UserLeap.useMobileStyling = x, ct(w) ? (W = "ul-direct-embeded-frame", M = document.head, _ = window, oe = !1, (() => {
|
|
89
|
+
const U = O(window.UserLeap), N = ae(U), Se = window.UserLeap.forceDirectEmbed, Ue = U["userleap-platform"] === "web";
|
|
90
|
+
return N || Se && Ue;
|
|
91
|
+
})() && (gt(b, l), ne.id = W, window.UserLeap.container.appendChild(ne), yt(), g.emit(u.SurveyLifeCycle, { state: "presented" }), g.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": b }))) : { frameId: W, contentWinDocHead: M, contentWindow: _, hasOverlay: oe, iframe: ne } = Wt({ productConfig: h, useMobileStyling: x, surveyId: b, isFeedback: l, enableCspTrustedTypes: (We = window.UserLeap._config) == null ? void 0 : We.enableCspTrustedTypes }), window.UserLeap.frameId = W;
|
|
92
|
+
const J = { apiURL: window.UserLeap._API_URL, avatars: s, cards: y, configureExitOnOverlayClick: (U) => {
|
|
93
|
+
g.once(u.CloseSurveyOnOverlayClick, U);
|
|
94
|
+
}, context: a, endCard: o, envId: window.UserLeap.envId, eventEmitFn: g.emit.bind(g), fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: n, frame: ne, headers: w, layout: p, locale: d, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: Q.getItem("sprig.previewKey"), previewMode: m || !!window.previewMode, productConfig: { framePosition: h == null ? void 0 : h.framePosition, desktopDisplay: h == null ? void 0 : h.desktopDisplay, placement: h == null ? void 0 : h.placement }, responseGroupUid: f, startingQuestionIdx: (Ne = window.UserLeap.config) == null ? void 0 : Ne.startingQuestionIdx, studyType: k, styleNonce: window.UserLeap.styleNonce, surveyId: b, tabTitle: document.title, trackPageViewUrl: e, ulEvents: se, upchunkLibraryURL: window.UserLeap.upchunkLibraryURL, useMobileStyling: x, userId: v, viewDocument: _ == null ? void 0 : _.document, viewWindow: _, visitorAttributes: { externalUserId: window.UserLeap.userId, email: window.UserLeap.email }, surveyVisitorAttributes: z || {}, ...window.UserLeap._config };
|
|
95
|
+
(Be = window.UserLeap._config) != null && Be.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null });
|
|
96
|
+
const Dt = (l ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? h.customStyles;
|
|
97
|
+
J.customStyles = Dt, _ && (_.__cfg = J);
|
|
98
|
+
const we = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : J.path, qe = document.getElementById(Ye);
|
|
99
|
+
qe && qe.remove();
|
|
100
|
+
const Le = function() {
|
|
101
|
+
const U = document.createElement("script");
|
|
102
|
+
return window.UserLeap.isMobileSDK || U.setAttribute("type", "module"), window.UserLeap.nonce && U.setAttribute("nonce", window.UserLeap.nonce), U.id = Ye, U;
|
|
103
|
+
}(), He = () => {
|
|
104
|
+
window.UserLeap.container && Object.assign(window.UserLeap.container.style, { display: "flex" });
|
|
105
|
+
};
|
|
106
|
+
if (J.installationMethod === "web-npm" || J.installationMethod === "web-npm-bundled") {
|
|
107
|
+
const { default: U } = await import("./view-q6KAoLll.js").then((N) => N.z);
|
|
108
|
+
U.configure(J), oe && window.UserLeap.container && He();
|
|
109
|
+
} else we && (Le.src = `${we}${window.UserLeap.isMobileSDK ? "" : `?t=${Date.now()}`}`, oe && Le.addEventListener("load", () => {
|
|
110
|
+
window.UserLeap.container && He();
|
|
111
|
+
}), _ == null || _.addEventListener("error", (U) => {
|
|
112
|
+
U.target instanceof HTMLScriptElement && U.target.src === we && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load"));
|
|
113
|
+
}, { capture: !0, once: !0 }));
|
|
114
|
+
M == null || M.appendChild(Le);
|
|
115
|
+
const ze = { success: !0, surveyState: "ready", surveyId: b, responseGroupUid: f };
|
|
116
|
+
return window.UserLeap.isMobileSDK && t && (ze.delay = t), ze;
|
|
117
|
+
};
|
|
118
|
+
function ve(r) {
|
|
119
|
+
var i;
|
|
120
|
+
if (window.UserLeap.useMobileStyling !== void 0) return window.UserLeap.useMobileStyling;
|
|
121
|
+
const e = ((i = window.UserLeap.windowDimensions) == null ? void 0 : i.width) ?? document.body.clientWidth;
|
|
122
|
+
return ae(r) || e > 10 && e < 500;
|
|
123
|
+
}
|
|
124
|
+
function ae(r) {
|
|
125
|
+
return Ht.has(r["userleap-platform"]);
|
|
126
|
+
}
|
|
127
|
+
const Xe = /* @__PURE__ */ new WeakMap(), zt = (r, e) => {
|
|
128
|
+
try {
|
|
129
|
+
return ((a) => {
|
|
130
|
+
var n, o;
|
|
131
|
+
const t = Xe.get(a);
|
|
132
|
+
if (t) return t;
|
|
133
|
+
if (!((n = a.trustedTypes) != null && n.createPolicy)) throw new Error("Trusted types not supported");
|
|
134
|
+
const s = (o = a.trustedTypes) == null ? void 0 : o.createPolicy("sprig-sdk", { createHTML: (l) => l, createScript: (l) => l, createScriptURL: (l) => l });
|
|
135
|
+
return Xe.set(a, s), s;
|
|
136
|
+
})(e).createHTML(r);
|
|
137
|
+
} catch (i) {
|
|
138
|
+
return console.warn("Could not create TrustedHTML object", i), r;
|
|
139
|
+
}
|
|
140
|
+
}, Ce = (r, e, i = window) => {
|
|
141
|
+
var a;
|
|
142
|
+
return e && ((a = i.trustedTypes) != null && a.createPolicy) ? zt(r, i) : r;
|
|
143
|
+
}, Pe = "ul-frame";
|
|
144
|
+
globalThis.UserLeap && globalThis.Sprig && (globalThis.Sprig._gtm ? globalThis.Sprig = globalThis.UserLeap : globalThis.UserLeap = globalThis.Sprig), globalThis.UserLeap || (globalThis.UserLeap = globalThis.Sprig), globalThis.Sprig || (globalThis.Sprig = globalThis.UserLeap);
|
|
145
|
+
const Te = "0px", gt = (r, e, i) => {
|
|
146
|
+
globalThis.UserLeap.container = document.createElement("div"), globalThis.UserLeap.container.className = "ul-container" + (e ? " ul-container-feedback" : ""), r && (globalThis.UserLeap.container.dataset.studyId = r.toString());
|
|
147
|
+
const a = mt();
|
|
148
|
+
i && a && !globalThis.UserLeap.useMobileStyling ? a.appendChild(globalThis.UserLeap.container) : document.body.appendChild(globalThis.UserLeap.container);
|
|
149
|
+
}, ht = (r, e) => {
|
|
150
|
+
var a;
|
|
151
|
+
Bt();
|
|
152
|
+
const i = globalThis.UserLeap.container;
|
|
153
|
+
if (i) try {
|
|
154
|
+
(a = i.parentNode) == null || a.removeChild(i), globalThis.UserLeap.container = null, E("trackStartUrl", null), g.emit(u.SurveyLifeCycle, { state: "dismissed" }), g.emit(u.SurveyClosed, { name: u.SurveyClosed, initiator: r, "survey.id": parseInt(i.dataset.studyId), ...e && { studyType: e } });
|
|
155
|
+
} catch (t) {
|
|
156
|
+
console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${r} ` + i), t instanceof Error && globalThis.UserLeap.reportError("dismissActiveSurvey", t);
|
|
157
|
+
}
|
|
158
|
+
}, yt = () => {
|
|
159
|
+
g.once(u.SurveyWillClose, ({ initiator: r, studyType: e }) => {
|
|
160
|
+
g.removeAllListeners(u.CloseSurveyOnOverlayClick), ht(r, e);
|
|
161
|
+
});
|
|
162
|
+
}, Vt = (r, e, i, a) => {
|
|
163
|
+
var d, p;
|
|
164
|
+
const t = { position: "fixed", bottom: "0px", right: Te, border: 0, backgroundColor: "rgba(0,0,0,0)", zIndex: 2147483646, transition: "width 0.2s ease-in-out, height 0.2s ease-in-out", maxWidth: "100%" }, s = Object.assign({}, e, globalThis.UserLeap), { desktopDisplay: n } = e || {}, o = n === "center-modal";
|
|
165
|
+
let l;
|
|
166
|
+
o && (s.framePosition = "center");
|
|
167
|
+
let c = !1;
|
|
168
|
+
if (i) (d = globalThis.UserLeap.windowDimensions) != null && d.width ? t.width = `${globalThis.UserLeap.windowDimensions.width}px` : t.width = "100%", (p = globalThis.UserLeap.windowDimensions) != null && p.height ? t.maxHeight = globalThis.UserLeap.windowDimensions.height - 20 + "px" : globalThis.UserLeap.maxHeight ? t.maxHeight = globalThis.UserLeap.maxHeight : t.maxHeight = document.body.clientHeight - 20 + "px", ["light", "dark"].includes(s.overlayStyleMobile) && (c = !0);
|
|
169
|
+
else {
|
|
170
|
+
t.width = "360px", t.maxHeight = globalThis.UserLeap.maxHeight || "66vh";
|
|
171
|
+
const m = () => {
|
|
172
|
+
c = !0, l = { margin: "auto", position: "static" };
|
|
173
|
+
};
|
|
174
|
+
if (a) o ? m() : l = { position: "relative", height: "300px" };
|
|
175
|
+
else switch (s.framePosition) {
|
|
176
|
+
case "bottomLeft":
|
|
177
|
+
l = { left: Te };
|
|
178
|
+
break;
|
|
179
|
+
case "topLeft":
|
|
180
|
+
l = { left: Te, top: 0 };
|
|
181
|
+
break;
|
|
182
|
+
case "topRight":
|
|
183
|
+
l = { top: 0 };
|
|
184
|
+
break;
|
|
185
|
+
case "center":
|
|
186
|
+
m();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return c && ((m, h) => {
|
|
190
|
+
const y = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, f = h ? m.overlayStyleMobile : m.overlayStyle;
|
|
191
|
+
y["background-color"] = f === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)", h || (y.margin = "auto"), globalThis.UserLeap.container && Object.assign(globalThis.UserLeap.container.style, y);
|
|
192
|
+
})(s, i), Object.assign(r.style, t, l), c;
|
|
193
|
+
}, Wt = ({ productConfig: r, useMobileStyling: e, surveyId: i, isFeedback: a, enableCspTrustedTypes: t }) => {
|
|
194
|
+
var h, y;
|
|
195
|
+
const s = Pe, n = a && r.desktopDisplay === "slider";
|
|
196
|
+
gt(i, a, n), Nt();
|
|
197
|
+
const o = document.createElement("iframe");
|
|
198
|
+
o.id = s, o.setAttribute("title", "Sprig User Feedback Dialog");
|
|
199
|
+
const l = Vt(o, r, e, a);
|
|
200
|
+
yt();
|
|
201
|
+
let c = !1;
|
|
202
|
+
o.setHeight = (f) => {
|
|
203
|
+
parseInt(o.style.height) == f && c || (c = !0, o.style.height = `${f}px`, g.emit(u.SurveyHeight, { name: u.SurveyHeight, contentFrameHeight: f, "survey.id": i }));
|
|
204
|
+
};
|
|
205
|
+
let d = !1;
|
|
206
|
+
o.setWidth = (f) => {
|
|
207
|
+
parseInt(o.style.width) == f && d || (d = !0, o.style.width = `${f}px`, g.emit(u.SurveyWidth, { name: u.SurveyWidth, contentFrameWidth: f, "survey.id": i }));
|
|
208
|
+
}, (h = globalThis.UserLeap.container) == null || h.appendChild(o), r && (e ? r.exitOnOverlayClickMobile : r.exitOnOverlayClick) && globalThis.UserLeap.container && (globalThis.UserLeap.container.onclick = () => {
|
|
209
|
+
g.emit(u.CloseSurveyOnOverlayClick);
|
|
210
|
+
}), g.emit(u.SurveyLifeCycle, { state: "presented" }), g.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": i });
|
|
211
|
+
const p = (y = o.contentWindow) == null ? void 0 : y.document;
|
|
212
|
+
if (p && (p.open("text/html", "replace"), p.write(Ce("<!doctype html><head></head><body></body></html>", t, o.contentWindow)), p.close(), !e)) {
|
|
213
|
+
const f = p.body;
|
|
214
|
+
f.style.display = "flex", f.style.alignItems = "center";
|
|
215
|
+
}
|
|
216
|
+
const m = p == null ? void 0 : p.head;
|
|
217
|
+
return { frameId: s, contentWinDocHead: m, contentWindow: o.contentWindow, hasOverlay: l, iframe: o };
|
|
218
|
+
}, bt = { [u.SurveyFadingOut]: () => {
|
|
219
|
+
globalThis.UserLeap.container && Object.assign(globalThis.UserLeap.container.style, { "background-color": "rgba(0,0,0,0)" });
|
|
220
|
+
} }, Nt = () => {
|
|
221
|
+
Object.entries(bt).forEach(([r, e]) => {
|
|
222
|
+
g.on(r, e);
|
|
223
|
+
});
|
|
224
|
+
}, Bt = () => {
|
|
225
|
+
Object.entries(bt).forEach(([r, e]) => {
|
|
226
|
+
g.off(r, e);
|
|
227
|
+
});
|
|
228
|
+
}, j = (r) => !!r && r.nodeType === Node.ELEMENT_NODE, Ze = (r) => r instanceof HTMLElement || r instanceof SVGElement, ce = ({ document: r, elementId: e, styleString: i, nonce: a }) => {
|
|
229
|
+
const t = r.getElementById(e);
|
|
230
|
+
if (t) return void (t.textContent = i);
|
|
231
|
+
const s = r.createElement("style");
|
|
232
|
+
a && (s.nonce = a), s.textContent = i, s.id = e, r.head.appendChild(s);
|
|
233
|
+
}, et = (r, e) => {
|
|
234
|
+
const i = e.querySelector(r);
|
|
235
|
+
if (!j(i)) return 0;
|
|
236
|
+
const a = getComputedStyle(i);
|
|
237
|
+
return parseFloat(a.paddingLeft) + parseFloat(a.paddingRight) + (parseFloat(a.marginLeft) + parseFloat(a.marginRight)) + (parseFloat(a.borderLeftWidth) + parseFloat(a.borderRightWidth));
|
|
238
|
+
}, $t = (r, e, i) => {
|
|
239
|
+
const a = r.querySelector(".ul-card__container"), t = r.querySelector(".ul-app");
|
|
240
|
+
let s = 600, n = 360;
|
|
241
|
+
if (j(a) && j(t)) {
|
|
242
|
+
const o = a.querySelector(".ul-card--matrix_grid"), l = !o && e && i;
|
|
243
|
+
try {
|
|
244
|
+
l && (t.style.width = "360px"), s = a.scrollHeight, s += ((p) => {
|
|
245
|
+
const m = p.querySelector(".sprig-question-body"), h = p.querySelector(".ul-card"), y = p.querySelector(".ul-card-main-content"), f = p.querySelector(".ul-footer"), b = p.querySelector(".sprig-container");
|
|
246
|
+
let v = 0;
|
|
247
|
+
return j(h) && (v += h.scrollHeight - h.clientHeight), j(y) && (v += y.scrollHeight - y.clientHeight), j(m) && (v += m.scrollHeight - m.clientHeight), j(f) && j(b) && b.clientHeight === 0 && (v += f.clientHeight), v;
|
|
248
|
+
})(r);
|
|
249
|
+
const c = getComputedStyle(a), d = parseFloat(c.marginTop) + parseFloat(c.marginBottom);
|
|
250
|
+
s += d + (parseFloat(c.borderTopWidth) + parseFloat(c.borderBottomWidth)), o && (n = o.scrollWidth, n += et(".ul-card__container", r), n += et(".sprig-question-body", r));
|
|
251
|
+
} finally {
|
|
252
|
+
l && t.style.removeProperty("width");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return [s + 2, n];
|
|
256
|
+
}, mr = (r) => {
|
|
257
|
+
const e = r.querySelector(".ul-card__container");
|
|
258
|
+
e && (e.scrollTop = 0);
|
|
259
|
+
}, mt = () => L, Y = () => document.getElementById("sprig-feedback-container"), _e = () => document.getElementById("sprig-feedback-loading-animation"), ft = () => !!document.getElementById(Pe);
|
|
260
|
+
let tt = !1, L = null, A = null, Me = !1, te = null, $ = null;
|
|
261
|
+
const Gt = ["bottom-left", "bottom-right", "center-left", "center-right"], pe = () => {
|
|
262
|
+
var e;
|
|
263
|
+
const r = window.UserLeap.container;
|
|
264
|
+
return ((e = r == null ? void 0 : r.parentElement) == null ? void 0 : e.id) === "sprig-feedback-loading-container";
|
|
265
|
+
}, vt = () => document.getElementById("sprig-feedback-error-container"), wt = () => {
|
|
266
|
+
if (!L) return 0;
|
|
267
|
+
const r = L == null ? void 0 : L.clientWidth, e = window.getComputedStyle(L);
|
|
268
|
+
return r + parseInt(e.borderRightWidth || "0") + parseInt(e.borderLeftWidth || "0");
|
|
269
|
+
}, ue = (r) => {
|
|
270
|
+
const e = Y();
|
|
271
|
+
e && ($ != null && $.endsWith("right") ? e.style.right = `${r}px` : $ != null && $.endsWith("left") && (e.style.left = `${r}px`));
|
|
272
|
+
}, Ie = () => {
|
|
273
|
+
if (L && (pe() || vt())) {
|
|
274
|
+
g.off(u.SurveyAppeared, Z), Re();
|
|
275
|
+
const r = wt();
|
|
276
|
+
return ue(-r), !0;
|
|
277
|
+
}
|
|
278
|
+
return !1;
|
|
279
|
+
}, Z = () => {
|
|
280
|
+
if (!L || !A) return;
|
|
281
|
+
const r = _e();
|
|
282
|
+
r && r.remove(), L.style.height = "auto", L.style.width = "auto", A.disabled = !1, Me = !1;
|
|
283
|
+
}, Re = () => {
|
|
284
|
+
if (L && !_e()) {
|
|
285
|
+
const r = (() => {
|
|
286
|
+
var i;
|
|
287
|
+
if (_e()) return;
|
|
288
|
+
const e = document.createElement("div");
|
|
289
|
+
return e.className = "ul-loading-spinner-container", e.id = "sprig-feedback-loading-animation", e.role = "progressbar", e.setAttribute("aria-live", "polite"), e.setAttribute("aria-busy", "true"), e.setAttribute("aria-label", "Processing..."), e.innerHTML = Ce(`
|
|
290
|
+
<div class="ul-loading-spinner">
|
|
291
|
+
<div class="first"></div>
|
|
292
|
+
<div class="second"></div>
|
|
293
|
+
<div class="third"></div>
|
|
294
|
+
<div class="fourth"></div>
|
|
295
|
+
</div>
|
|
296
|
+
`, (i = window.UserLeap._config) == null ? void 0 : i.enableCspTrustedTypes), e;
|
|
297
|
+
})();
|
|
298
|
+
r && (L.style.height = "300px", L.style.width = "360px", L.appendChild(r));
|
|
299
|
+
}
|
|
300
|
+
}, rt = () => {
|
|
301
|
+
L && A && (ue(0), A.disabled = !0, Me = !0);
|
|
302
|
+
}, Lt = async (r, e, i) => {
|
|
303
|
+
const { buttonTheme: a, customStyles: t, eventId: s, placement: n, desktopDisplay: o, feedbackLabel: l, surveyUuid: c, surveyId: d } = r;
|
|
304
|
+
window.UserLeap.feedbackCustomStyles = void 0;
|
|
305
|
+
let p = Y();
|
|
306
|
+
if (p) {
|
|
307
|
+
if (!e && s === te) return;
|
|
308
|
+
p.remove(), g.off(se.SURVEY_FADING_OUT, Ie);
|
|
309
|
+
}
|
|
310
|
+
te = s, ce({ document, elementId: "sprig-feedback-style", styleString: '.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}', nonce: window.UserLeap.styleNonce }), ce({ document, elementId: "ul-custom-style", styleString: t ?? "", nonce: window.UserLeap.styleNonce }), tt = o === "center-modal", $ = n;
|
|
311
|
+
const [m, h] = n.split("-");
|
|
312
|
+
((v) => {
|
|
313
|
+
if (Y() || !Gt.includes(v)) return;
|
|
314
|
+
const [I, S] = v.split("-"), k = document.createElement("div");
|
|
315
|
+
k.id = "sprig-feedback-container", k.classList.add(`sprig-feedback-container-${S}`, `sprig-feedback-container-${I}`), document.body.appendChild(k);
|
|
316
|
+
})(n), p = Y(), A = document.createElement("button");
|
|
317
|
+
const y = document.createElement("div");
|
|
318
|
+
y.className = "sprig-feedback-button-label", y.innerText = l, A.appendChild(y), A.id = "sprig-feedback-button", A.classList.add(`sprig-feedback-button-${h}`, `sprig-feedback-button-${m}`, `sprig-feedback-button-${a}`, "fade-in-transition"), g.on(se.SURVEY_FADING_OUT, Ie), A.addEventListener("click", async () => {
|
|
319
|
+
const v = document.getElementById("sprig-feedback-error-container");
|
|
320
|
+
if (ft() || vt()) {
|
|
321
|
+
if (Ie()) {
|
|
322
|
+
g.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: C.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }), g.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: C.FeedbackClosed, studyType: "feedbackButton", "survey.id": d });
|
|
323
|
+
const S = Y();
|
|
324
|
+
v && S && (S.remove(), te = null, L = null);
|
|
325
|
+
}
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (ve(O(window.UserLeap)) || Me || rt(), e) return L && L.classList.add("sprig-feedback-loading-container-previews"), await ee(e), void Z();
|
|
329
|
+
const I = await (async (S) => {
|
|
330
|
+
const k = await D(R("1", [F], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: S }), method: "POST" });
|
|
331
|
+
return k.ok ? k.json : null;
|
|
332
|
+
})(c);
|
|
333
|
+
if (I) g.once(u.SurveyAppeared, Z), ee({ ...I, studyType: "feedbackButton" }, i);
|
|
334
|
+
else if (L) {
|
|
335
|
+
const S = Kt();
|
|
336
|
+
L.appendChild(S), Z(), L.style.height = "300px", L.style.width = "360px";
|
|
337
|
+
}
|
|
338
|
+
}), p == null || p.appendChild(A), g.emit(u.FeedbackButtonLoaded, { name: u.FeedbackButtonLoaded, "survey.id": d });
|
|
339
|
+
const { useMobileStyling: f, _config: { border: b } } = window.UserLeap;
|
|
340
|
+
if (tt || f) ue(0);
|
|
341
|
+
else {
|
|
342
|
+
const v = document.createElement("div");
|
|
343
|
+
v.id = "sprig-feedback-loading-container", v.className = `sprig-feedback-loading-container sprig-feedback-loading-container-${h}`, v.style.setProperty("--feedback-border", b), L = v, Re(), p == null || p.appendChild(v);
|
|
344
|
+
const I = wt();
|
|
345
|
+
ue(-I);
|
|
346
|
+
}
|
|
347
|
+
window.UserLeap._config.isOnQuestionsTab && e && !pe() && L && (rt(), Re(), L && L.classList.add("sprig-feedback-loading-container-previews"), ee(e), Z());
|
|
348
|
+
}, Kt = () => {
|
|
349
|
+
var i;
|
|
350
|
+
const r = document.createElement("div");
|
|
351
|
+
r.id = "sprig-feedback-error-container", r.innerHTML = Ce(`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
|
|
352
|
+
<circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
|
|
353
|
+
<path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
|
|
354
|
+
<circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
|
|
355
|
+
</svg>`, (i = window.UserLeap._config) == null ? void 0 : i.enableCspTrustedTypes);
|
|
356
|
+
const e = document.createElement("h3");
|
|
357
|
+
return e.className = "sprig-feedback-error-text", e.innerText = "There was an error while loading the survey", r.appendChild(e), r;
|
|
358
|
+
}, xe = new class {
|
|
359
|
+
constructor() {
|
|
360
|
+
B(this, "_ldData", {});
|
|
361
|
+
}
|
|
362
|
+
getAllLaunchDarklyVariations() {
|
|
363
|
+
return this._ldData;
|
|
364
|
+
}
|
|
365
|
+
setLDFlagsVariations(r) {
|
|
366
|
+
try {
|
|
367
|
+
return !(!r || typeof r != "object" || Array.isArray(r)) && (Object.keys(this._ldData).forEach((e) => {
|
|
368
|
+
delete this._ldData[e];
|
|
369
|
+
}), Object.keys(r).forEach((e) => this._ldData[`!launch_darkly_${e}`] = (r[e] ?? 0) + 1), !0);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
return e instanceof Error && window.UserLeap.reportError("setAllLDFlagsVariations", e), console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."), !1;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}();
|
|
375
|
+
Object.freeze(xe);
|
|
376
|
+
const de = new class {
|
|
377
|
+
constructor() {
|
|
378
|
+
B(this, "_optimizelyData", {});
|
|
379
|
+
}
|
|
380
|
+
setOptimizelyExperiment(r, e = !0) {
|
|
381
|
+
if (!r || typeof r != "object") return !1;
|
|
382
|
+
const { experiments: i } = r;
|
|
383
|
+
try {
|
|
384
|
+
return e && Object.keys(this._optimizelyData).map((a) => {
|
|
385
|
+
delete this._optimizelyData[a];
|
|
386
|
+
}), i && i.map((a) => {
|
|
387
|
+
const { id: t, variation: s } = a, n = this.transformExperimentId(t);
|
|
388
|
+
s && typeof s == "string" && (this._optimizelyData[n] = s);
|
|
389
|
+
}), !0;
|
|
390
|
+
} catch (a) {
|
|
391
|
+
return a instanceof Error && window.UserLeap.reportError("setOptimizelyExperiment", a), !1;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
getAllOptimizelyExperiments() {
|
|
395
|
+
return this._optimizelyData;
|
|
396
|
+
}
|
|
397
|
+
getOptimizelyVariationName(r) {
|
|
398
|
+
return this._optimizelyData[this.transformExperimentId(r)];
|
|
399
|
+
}
|
|
400
|
+
transformExperimentId(r) {
|
|
401
|
+
return "!optimizely_experiments_" + r;
|
|
402
|
+
}
|
|
403
|
+
getAndSetWebOptimizelyExperiments() {
|
|
404
|
+
var r;
|
|
405
|
+
try {
|
|
406
|
+
if (window && window.optimizely && typeof window.optimizely.get == "function") {
|
|
407
|
+
const e = (r = window.optimizely.get("state")) == null ? void 0 : r.getExperimentStates({ isActive: !0 });
|
|
408
|
+
if (e) {
|
|
409
|
+
const i = Object.keys(e).map((a) => {
|
|
410
|
+
var t, s;
|
|
411
|
+
return (t = e[a].variation) != null && t.name ? { id: a, variation: (s = e[a].variation) == null ? void 0 : s.name } : { id: a, variation: "Original" };
|
|
412
|
+
});
|
|
413
|
+
return this.setOptimizelyExperiment({ experiments: i }, !1), !0;
|
|
414
|
+
}
|
|
415
|
+
return !1;
|
|
416
|
+
}
|
|
417
|
+
return !1;
|
|
418
|
+
} catch (e) {
|
|
419
|
+
return e instanceof Error && window.UserLeap.reportError("getAndSetWebOptimizely", e), !1;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}();
|
|
423
|
+
Object.freeze(de);
|
|
424
|
+
class Jt {
|
|
425
|
+
constructor(e, i) {
|
|
426
|
+
B(this, "paused");
|
|
427
|
+
B(this, "queue");
|
|
428
|
+
B(this, "ul");
|
|
429
|
+
this.ul = e, this.paused = !1, this.queue = [], this.flush(i);
|
|
430
|
+
}
|
|
431
|
+
flush(e) {
|
|
432
|
+
const i = e.length;
|
|
433
|
+
if (i) for (let a = 0; a < i; a++) this.push(e[a]);
|
|
434
|
+
}
|
|
435
|
+
isPaused() {
|
|
436
|
+
return this.paused;
|
|
437
|
+
}
|
|
438
|
+
pause() {
|
|
439
|
+
this.paused = !0;
|
|
440
|
+
}
|
|
441
|
+
unpause() {
|
|
442
|
+
this.paused = !1;
|
|
443
|
+
const e = this.queue.slice();
|
|
444
|
+
this.empty(), this.flush(e);
|
|
445
|
+
}
|
|
446
|
+
push(e) {
|
|
447
|
+
if (this.paused) this.queue.push(e);
|
|
448
|
+
else if (e instanceof Function) e();
|
|
449
|
+
else {
|
|
450
|
+
const i = Array.prototype.slice.call(e, 1), a = e[0], t = this.ul[a];
|
|
451
|
+
t instanceof Function ? t.apply(this.ul, i) : a && console.warn("[Sprig] (ERR-100) No valid UserLeap action called", a);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
perform(e) {
|
|
455
|
+
if (this.paused) {
|
|
456
|
+
let i = () => {
|
|
457
|
+
};
|
|
458
|
+
const a = new Promise(function(t) {
|
|
459
|
+
i = function() {
|
|
460
|
+
t(e());
|
|
461
|
+
};
|
|
462
|
+
});
|
|
463
|
+
return this.queue.push(i), a;
|
|
464
|
+
}
|
|
465
|
+
return e();
|
|
466
|
+
}
|
|
467
|
+
empty() {
|
|
468
|
+
this.queue.length = 0;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
let St, Ut;
|
|
472
|
+
const De = (r) => {
|
|
473
|
+
let e = 0, i = r.firstElementChild;
|
|
474
|
+
for (; i; ) e += De(i), i.shadowRoot && (e += De(i.shadowRoot)), i = i.nextElementSibling, e++;
|
|
475
|
+
return e;
|
|
476
|
+
}, it = () => {
|
|
477
|
+
St.report(De(document.body)), Ut.report(document.documentElement.innerHTML.toString().length);
|
|
478
|
+
}, Ae = (r, e) => {
|
|
479
|
+
const i = performance.now();
|
|
480
|
+
document.hidden ? setTimeout(() => Ae(r, e), r) : setTimeout(() => {
|
|
481
|
+
const a = performance.now() - i;
|
|
482
|
+
e.report(a / 1e3), setTimeout(() => Ae(r, e), r);
|
|
483
|
+
}, 0);
|
|
484
|
+
};
|
|
485
|
+
let ge, he, ye, be, st, G = {};
|
|
486
|
+
const le = (r, e = 1) => {
|
|
487
|
+
const { name: i } = r;
|
|
488
|
+
G[i] = (G[i] || 0) + e;
|
|
489
|
+
}, Tt = (r) => {
|
|
490
|
+
let e = 1;
|
|
491
|
+
return r.childNodes.forEach((i) => {
|
|
492
|
+
e += Tt(i);
|
|
493
|
+
}), e;
|
|
494
|
+
}, at = (r) => {
|
|
495
|
+
let e = 0;
|
|
496
|
+
return r.forEach((i) => {
|
|
497
|
+
e += Tt(i);
|
|
498
|
+
}), e;
|
|
499
|
+
}, Qt = (r) => {
|
|
500
|
+
switch (r.type) {
|
|
501
|
+
case "childList":
|
|
502
|
+
return le(ge, at(r.addedNodes)), void le(he, at(r.removedNodes));
|
|
503
|
+
case "attributes":
|
|
504
|
+
return void le(ye);
|
|
505
|
+
case "characterData":
|
|
506
|
+
return void le(be);
|
|
507
|
+
}
|
|
508
|
+
}, Yt = (r) => r.forEach(Qt), Xt = () => {
|
|
509
|
+
ge.report(G[ge.name] || 0), he.report(G[he.name] || 0), ye.report(G[ye.name] || 0), be.report(G[be.name] || 0), G = {};
|
|
510
|
+
}, Zt = (r = 1e3) => {
|
|
511
|
+
ge = K("sdk_mutations_nodes_added"), he = K("sdk_mutations_nodes_removed"), ye = K("sdk_mutations_attributes_changed"), be = K("sdk_mutations_character_data"), st = new MutationObserver(Yt), st.observe(document, { attributes: !0, attributeOldValue: !0, characterData: !0, characterDataOldValue: !0, childList: !0, subtree: !0 }), setInterval(Xt, r);
|
|
512
|
+
}, er = ({ isWeb: r, reportingIntervalSeconds: e, thresholds: i, postMetrics: a }) => {
|
|
513
|
+
Pt(i, (t, s) => {
|
|
514
|
+
var n, o;
|
|
515
|
+
if ((n = T.replay) != null && n.isReplayRecording()) {
|
|
516
|
+
const l = `Value: ${t} on ${s.metric} violated threshold of ${s.type} ${s.value}`;
|
|
517
|
+
(o = T.replay) == null || o.disableRecording("Threshold violated", new Error(l), { reportError: !1 }), window.UserLeap.reportError("Sdk Performance Metric threshold violated", new Error("Sdk Performance Metric threshold violated"), { metricName: s.metric, type: s.type, value: s.value }, { metricName: s.metric }), jt();
|
|
518
|
+
}
|
|
519
|
+
}), Mt({ reportingIntervalSeconds: e, postMetrics: a }), r && (((t = 1e3) => {
|
|
520
|
+
const s = K("sdk_event_queue_latency_seconds");
|
|
521
|
+
Ae(t, s);
|
|
522
|
+
})(), ((t = 1e4) => {
|
|
523
|
+
St = K("sdk_dom_nodes_count"), Ut = K("sdk_page_html_characters"), it(), setInterval(it, t);
|
|
524
|
+
})(), Zt());
|
|
525
|
+
}, tr = "test", rr = ["popState", "pushState", "replaceState"];
|
|
526
|
+
let je, re;
|
|
527
|
+
const me = {}, X = "!email", It = "pageUrl";
|
|
528
|
+
var nt;
|
|
529
|
+
let ke = ((nt = globalThis.location) == null ? void 0 : nt.href) || "";
|
|
530
|
+
function ie(r) {
|
|
531
|
+
var o, l;
|
|
532
|
+
const { pageUrlEvents: e, interactiveEvents: i, dismissOnPageChange: a, platform: t } = globalThis.UserLeap._config;
|
|
533
|
+
if (t && t !== "web") return;
|
|
534
|
+
ke !== globalThis.location.href && P.navigation("LocationChange", { from: ke, to: globalThis.location.href }), ke = globalThis.location.href;
|
|
535
|
+
const s = _t().trackStartUrl, n = s ? String(s) : null;
|
|
536
|
+
e && xt(globalThis.location.href), i && (Et(), ir()), mt() && (() => {
|
|
537
|
+
if (pe()) return;
|
|
538
|
+
const c = Y();
|
|
539
|
+
c && (Ct(te) || (c.remove(), te = null, L = null));
|
|
540
|
+
})(), Q.getItem("sprig.isCapturingHeatmap") && ((l = (o = T.replay) == null ? void 0 : o.checkPendingHeatmapsUrl()) == null || l.then((c) => {
|
|
541
|
+
var d;
|
|
542
|
+
c && ((d = T.replay) == null || d.uploadReadyPendingCaptures(!0));
|
|
543
|
+
})), !pe() && a && n && n !== globalThis.location.href && r && rr.includes(r.type) && globalThis.UserLeap("dismissActiveSurvey", C.PageChange);
|
|
544
|
+
}
|
|
545
|
+
const kt = { capture: !0 }, ir = () => {
|
|
546
|
+
const r = globalThis.UserLeap._config.interactiveEvents.filter((i) => pt(i, globalThis.location.href)).map((i) => {
|
|
547
|
+
const { name: a, properties: t } = i, { selector: s, innerText: n } = t;
|
|
548
|
+
return s ? (o) => {
|
|
549
|
+
if (Ze(o.target)) try {
|
|
550
|
+
o.target.closest(s) && globalThis.UserLeap("track", a);
|
|
551
|
+
} catch {
|
|
552
|
+
}
|
|
553
|
+
return !1;
|
|
554
|
+
} : (o) => (Ze(o.target) && o.target.innerText === n && globalThis.UserLeap("track", a), !1);
|
|
555
|
+
}), e = (i) => r.forEach((a) => a(i));
|
|
556
|
+
globalThis.UserLeap._config.interactiveEventsHandler = e, globalThis.addEventListener("click", e, kt);
|
|
557
|
+
}, Et = () => {
|
|
558
|
+
globalThis.UserLeap._config.interactiveEventsHandler && globalThis.removeEventListener("click", globalThis.UserLeap._config.interactiveEventsHandler, kt), delete globalThis.UserLeap._config.interactiveEventsHandler;
|
|
559
|
+
};
|
|
560
|
+
function _t() {
|
|
561
|
+
const r = H.getItemObject("userleap.ids");
|
|
562
|
+
return (r == null ? void 0 : r[globalThis.UserLeap.envId]) || {};
|
|
563
|
+
}
|
|
564
|
+
function Rt() {
|
|
565
|
+
if (globalThis.previewMode) return;
|
|
566
|
+
const r = H.getItemObject("sprig.anon.env.vid.map") || {}, e = r[globalThis.UserLeap.envId];
|
|
567
|
+
globalThis.UserLeap.visitorId = e || dt(), P.info("NewVid", { vid: globalThis.UserLeap.visitorId }), E("vid", globalThis.UserLeap.visitorId), e || (r[globalThis.UserLeap.envId] = globalThis.UserLeap.visitorId, H.setItemObject("sprig.anon.env.vid.map", r)), g.emit(u.VisitorIDUpdated, { visitorId: globalThis.UserLeap.visitorId });
|
|
568
|
+
}
|
|
569
|
+
function xt(r, e, i, a) {
|
|
570
|
+
var t, s;
|
|
571
|
+
try {
|
|
572
|
+
if (r.endsWith("mock_snippet.html")) return;
|
|
573
|
+
P.info("PageView", { url: r });
|
|
574
|
+
const n = (t = document == null ? void 0 : document.querySelector('meta[name="description"]')) == null ? void 0 : t.getAttribute("content");
|
|
575
|
+
(s = T.replay) == null || s.RecordPageView({ ...n && { description: n }, url: r, referrer: document.referrer, pageTitle: document.title });
|
|
576
|
+
const o = globalThis.UserLeap._config.pageUrlEvents;
|
|
577
|
+
let l = !1;
|
|
578
|
+
if (o && o.length) for (let d = 0; d < o.length && (l = pt(o[d], r), !l); d++) ;
|
|
579
|
+
if (!l) return;
|
|
580
|
+
globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig trackPageView", r);
|
|
581
|
+
const c = { url: r };
|
|
582
|
+
a && (c.trackPageView = !0), globalThis.UserLeap._queue.push(["track", It, e, c, i]);
|
|
583
|
+
} catch (n) {
|
|
584
|
+
n instanceof Error && (n.stack = r, globalThis.UserLeap.reportError("trackPageView", n)), console.warn("[Sprig] (ERR-428) Failed to track page view", n);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function sr() {
|
|
588
|
+
var e;
|
|
589
|
+
const r = ((e = globalThis.Backbone) == null ? void 0 : e.history) || globalThis.history;
|
|
590
|
+
"pushState" in r && (r.pushState = /* @__PURE__ */ ((i) => function(...a) {
|
|
591
|
+
const t = i.apply(this, a), s = new Event("pushState");
|
|
592
|
+
return globalThis.dispatchEvent(s), ie(s), t;
|
|
593
|
+
})(r.pushState)), "replaceState" in r && (r.replaceState = /* @__PURE__ */ ((i) => function(...a) {
|
|
594
|
+
const t = i.apply(this, a), s = new Event("replaceState");
|
|
595
|
+
return globalThis.dispatchEvent(s), ie(s), t;
|
|
596
|
+
})(r.replaceState)), ["hashchange", "popstate"].forEach((i) => globalThis.addEventListener(i, ie, !0));
|
|
597
|
+
}
|
|
598
|
+
async function Ee(r, e) {
|
|
599
|
+
const i = Oe();
|
|
600
|
+
r && !e && (globalThis.UserLeap._config.mode = tr);
|
|
601
|
+
const a = ve(O(globalThis.UserLeap)), t = await D(function(s) {
|
|
602
|
+
const n = new URL(R("1", [q], "questions"));
|
|
603
|
+
return Object.entries(s || {}).forEach(([o, l]) => {
|
|
604
|
+
l && n.searchParams.append(o, String(l));
|
|
605
|
+
}), n.toString();
|
|
606
|
+
}({ desktopDisplay: globalThis.UserLeap._config.desktopDisplay, isMobile: a, previewLanguage: globalThis.UserLeap._config.previewLanguage, surveyid: r == null ? void 0 : r.surveyId, surveytemplateid: r == null ? void 0 : r.surveyTemplateId, vid: i }), { shouldDropOnRateLimit: !0 });
|
|
607
|
+
if (!t.ok) return t.reportError && t.error && (console.warn("[Sprig] (ERR-414) Failed to request questions from the server", t.error), globalThis.UserLeap.reportError("getQuestions", t.error)), { success: !1, surveyState: "no survey" };
|
|
608
|
+
if (t.json.delay && await ut(t.json.delay), !t.json.isFeedback) return ee(t.json, re, je);
|
|
609
|
+
{
|
|
610
|
+
const { feedbackLabel: s, productConfig: n, surveyUuid: o, feedbackCustomStyles: l } = t.json, { buttonTheme: c, placement: d, desktopDisplay: p } = n;
|
|
611
|
+
Lt({ customStyles: l, buttonTheme: c, desktopDisplay: p, eventId: 0, feedbackLabel: s, placement: d, surveyUuid: o, surveyId: r == null ? void 0 : r.surveyId }, t.json);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
function ar(r) {
|
|
615
|
+
if (!r) return;
|
|
616
|
+
globalThis.UserLeap._config = r, r.mute && globalThis.UserLeap._queue.pause();
|
|
617
|
+
const { interactiveEvents: e, pageUrlEvents: i, dismissOnPageChange: a } = r;
|
|
618
|
+
e && function(t) {
|
|
619
|
+
let s = t.length;
|
|
620
|
+
for (; s; ) {
|
|
621
|
+
const n = Math.floor(Math.random() * s);
|
|
622
|
+
s -= 1;
|
|
623
|
+
const o = t[s];
|
|
624
|
+
t[s] = t[n], t[n] = o;
|
|
625
|
+
}
|
|
626
|
+
}(e), (e || i || a) && (sr(), ie());
|
|
627
|
+
}
|
|
628
|
+
const or = function(r) {
|
|
629
|
+
if (!globalThis.UserLeap) return;
|
|
630
|
+
const e = async (t = {}) => {
|
|
631
|
+
var v, I, S, k, z;
|
|
632
|
+
const { userId: s, anonymousId: n, metadata: o = {}, properties: l, showSurveyCallback: c } = t;
|
|
633
|
+
let { eventName: d } = t;
|
|
634
|
+
if (globalThis.UserLeap.debugMode && d !== It && console.info("[DEBUG] Sprig track", t), r.mode === "test") return;
|
|
635
|
+
const p = Q.getItem("sprig.previewKey") ?? void 0;
|
|
636
|
+
if (r.requireUserIdForTracking && !globalThis.UserLeap.userId && !s) {
|
|
637
|
+
const w = "[Sprig] - Skipping tracking without userId";
|
|
638
|
+
return console.warn(w), { success: !1, message: w, surveyState: "no survey" };
|
|
639
|
+
}
|
|
640
|
+
if (!d || d.trim().length === 0) {
|
|
641
|
+
d = d ? String(d) : "";
|
|
642
|
+
const w = "[Sprig] - Invalid event name " + d;
|
|
643
|
+
return console.warn(w), { success: !1, message: w, surveyState: "no survey" };
|
|
644
|
+
}
|
|
645
|
+
const m = re ?? globalThis.location.href;
|
|
646
|
+
o.url || (o.url = m), E("trackStartUrl", m), (I = (v = globalThis.UserLeap) == null ? void 0 : v._config) != null && I.optimizelyEnabled && (ae(O(globalThis.UserLeap)) || de.getAndSetWebOptimizelyExperiments(), o.optimizelyExperiments = Object.assign({}, de.getAllOptimizelyExperiments())), (k = (S = globalThis.UserLeap) == null ? void 0 : S._config) != null && k.launchDarklyEnabled && (o.launchDarklyFlags = xe.getAllLaunchDarklyVariations()), s && (globalThis.UserLeap.userId = s), n && (globalThis.UserLeap.partnerAnonymousId = n), l && (o.eventProperties = l), (z = T.replay) == null || z.RecordEvent({ name: d, url: o.url }), P.info("TrackEvent", { eventName: d });
|
|
647
|
+
const h = globalThis.UserLeap.delayingSurvey || ft() ? await D(R("1", [F], "events/batch"), { body: JSON.stringify({ events: [{ event: d, metadata: o }], previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 }) : await D(R("1", [F], "events"), { body: JSON.stringify({ event: d, metadata: o, previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 });
|
|
648
|
+
if (!h.ok) {
|
|
649
|
+
const w = "[Sprig] (ERR-421) Failed to track event";
|
|
650
|
+
return h.reportError && (console.warn(w, h.error), h.error && globalThis.UserLeap.reportError("track", h.error)), { success: !1, message: w, error: h.error, surveyState: "no survey" };
|
|
651
|
+
}
|
|
652
|
+
s && E("uid", s), n && E("aid", n);
|
|
653
|
+
const y = h.json;
|
|
654
|
+
y.invalidPreviewKey && Q.removeItem("sprig.previewKey");
|
|
655
|
+
const f = o.trackPageView ? o.url : void 0;
|
|
656
|
+
return y != null && y.feedbackButton && Lt(y.feedbackButton, void 0, f), await async function(w, V) {
|
|
657
|
+
var W, M;
|
|
658
|
+
let x = !0;
|
|
659
|
+
return !(V && ((W = w == null ? void 0 : w.json) != null && W.surveyId) && (globalThis.UserLeap.delayingSurvey = !0, x = await V(w.json.surveyId), globalThis.UserLeap.delayingSurvey = !1, !x)) && ((M = w == null ? void 0 : w.json) != null && M.delay && !globalThis.UserLeap.isMobileSDK && (globalThis.UserLeap.delayingSurvey = !0, await ut(w.json.delay), globalThis.UserLeap.delayingSurvey = !1), x);
|
|
660
|
+
}(h, c) ? function(w) {
|
|
661
|
+
if (!globalThis.UserLeap._config.dismissOnPageChange) return !0;
|
|
662
|
+
const V = new URL(w), x = new URL(re ?? globalThis.location.href);
|
|
663
|
+
return V.hostname === x.hostname && V.pathname === x.pathname;
|
|
664
|
+
}(m) ? ee(y, f, je) : { success: !1, message: "Study should not be displayed after page navigation", surveyState: "no survey" } : { success: !1, message: "[Sprig] Callback returned false, aborting rendering of survey", surveyState: "no survey" };
|
|
665
|
+
}, i = (t, s) => {
|
|
666
|
+
var o;
|
|
667
|
+
const n = (o = t == null ? void 0 : t.querySelector(`[id="${Pe}"]`)) == null ? void 0 : o.contentDocument;
|
|
668
|
+
n && ce({ document: n, elementId: "ul-custom-style", styleString: s });
|
|
669
|
+
}, a = { displaySurvey: async (t) => (console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."), globalThis.UserLeap("dismissActiveSurvey", C.Override), Ee({ surveyId: t }, !0)), _previewSurvey(t) {
|
|
670
|
+
globalThis.UserLeap("dismissActiveSurvey", C.Override), Ee({ surveyTemplateId: t }, !1);
|
|
671
|
+
}, _reviewSurvey(t) {
|
|
672
|
+
globalThis.UserLeap("dismissActiveSurvey", C.Override), Ee({ surveyId: t }, !1);
|
|
673
|
+
}, previewSurvey(t) {
|
|
674
|
+
a._previewSurvey(t);
|
|
675
|
+
}, reviewSurvey(t) {
|
|
676
|
+
a._reviewSurvey(t);
|
|
677
|
+
}, mute() {
|
|
678
|
+
globalThis.UserLeap._queue.pause();
|
|
679
|
+
}, unmute() {
|
|
680
|
+
globalThis.UserLeap._queue.unpause();
|
|
681
|
+
}, setVisitorToken() {
|
|
682
|
+
console.warn("[Sprig] setVisitorToken is deprecated.");
|
|
683
|
+
}, dismissActiveSurvey(t = C.API) {
|
|
684
|
+
globalThis.UserLeap.container && (t === C.Closed && globalThis.Sprig.trackHistory && globalThis.Sprig.trackHistory({ event: "closed" }), g.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: t, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) }), g.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: t, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) }));
|
|
685
|
+
}, async setAttribute(t, s) {
|
|
686
|
+
if (!t || !s && s !== 0 && s !== !1) {
|
|
687
|
+
const n = "[Sprig] - Disregarding empty attribute / value provided";
|
|
688
|
+
return console.warn(n), { success: !1, message: n };
|
|
689
|
+
}
|
|
690
|
+
return this.setAttributes({ [t]: s });
|
|
691
|
+
}, async setAttributes(t) {
|
|
692
|
+
if (t == null || Object.keys(t).length === 0) {
|
|
693
|
+
const s = "[Sprig] - Disregarding empty attributes provided";
|
|
694
|
+
return console.warn(s), { success: !1, message: s };
|
|
695
|
+
}
|
|
696
|
+
return this.identifyAndSetAttributes({ attributes: t });
|
|
697
|
+
}, async identifyAndSetAttributes(t) {
|
|
698
|
+
if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig identifyAndSetAttributes", t), r.mode === "test") return;
|
|
699
|
+
if (t === null || typeof t != "object" || !(t.userId || t.anonymousId || t.attributes)) {
|
|
700
|
+
const d = "[Sprig] - Disregarding empty payload provided";
|
|
701
|
+
return console.warn(d), { success: !1, message: d };
|
|
702
|
+
}
|
|
703
|
+
const { userId: s, anonymousId: n, attributes: o } = t;
|
|
704
|
+
if (r.requireUserIdForTracking && !globalThis.UserLeap.userId && !s) {
|
|
705
|
+
const d = "[Sprig] - Skipping tracking without userId";
|
|
706
|
+
return console.warn(d), { success: !1, message: d };
|
|
707
|
+
}
|
|
708
|
+
if (o) {
|
|
709
|
+
o.email && !o[X] && (o[X] = o.email, delete o.email);
|
|
710
|
+
const d = Object.keys(o);
|
|
711
|
+
for (const p of d) o[p] === me[p] && delete o[p];
|
|
712
|
+
}
|
|
713
|
+
if (!(o && Object.keys(o).length !== 0 || s && globalThis.UserLeap.userId !== s || n && globalThis.UserLeap.partnerAnonymousId !== n)) return { success: !0 };
|
|
714
|
+
const l = {};
|
|
715
|
+
let c;
|
|
716
|
+
return s && (l.userId = globalThis.UserLeap.userId = s), n && (l.partnerAnonymousId = globalThis.UserLeap.partnerAnonymousId = n), o && Object.keys(o).length > 0 ? (c = await D(R("1", [q, F], "attributes"), { body: JSON.stringify(o), method: "PUT" }), c.ok ? Object.assign(me, o) : c.reportError && (console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed", c.error), c.error && globalThis.UserLeap.reportError("identifyAndSetAttributes", c.error))) : c = await D(R("1", [q, F]), { body: JSON.stringify(l), method: "PUT" }), o && o[X] && (globalThis.UserLeap.email = o[X]), c.ok && (s && E("uid", s), n && E("aid", n)), { success: !!c.ok };
|
|
717
|
+
}, async removeAttributes(t) {
|
|
718
|
+
if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig removeAttributes", t), r.mode === "test") return;
|
|
719
|
+
if (t == null || t.length === 0) {
|
|
720
|
+
const n = "[Sprig] - Disregarding empty attributes provided";
|
|
721
|
+
return console.warn(n), { success: !1, message: n };
|
|
722
|
+
}
|
|
723
|
+
if (r.requireUserIdForTracking && !globalThis.UserLeap.userId) {
|
|
724
|
+
const n = "[Sprig] - Skipping tracking without userId";
|
|
725
|
+
return console.warn(n), { success: !1, message: n };
|
|
726
|
+
}
|
|
727
|
+
const s = await D(R("1", [q, F], "attributes"), { body: JSON.stringify({ delete: t }), method: "DELETE" });
|
|
728
|
+
return !s.ok && s.reportError && (console.warn("[Sprig] (ERR-433) Remove attributes failed", s.error), s.error && globalThis.UserLeap.reportError("removeAttributes", s.error)), { success: !!s.ok };
|
|
729
|
+
}, async addSurveyListener(t) {
|
|
730
|
+
g.on(u.SurveyLifeCycle, t);
|
|
731
|
+
}, async removeSurveyListener(t) {
|
|
732
|
+
g.removeListener(u.SurveyLifeCycle, t);
|
|
733
|
+
}, async addListener(t, s) {
|
|
734
|
+
g.on(t, s);
|
|
735
|
+
}, async removeListener(t, s) {
|
|
736
|
+
g.removeListener(t, s);
|
|
737
|
+
}, async removeAllListeners() {
|
|
738
|
+
g.removeAllListeners();
|
|
739
|
+
}, setPreviewKey(t) {
|
|
740
|
+
t && typeof t == "string" && Q.isStorageAvailable && t && Q.setItem("sprig.previewKey", t);
|
|
741
|
+
}, async setUserId(t) {
|
|
742
|
+
var o;
|
|
743
|
+
if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig setUserId", t), t == null) {
|
|
744
|
+
const l = `[Sprig] - Invalid userId ${t}`;
|
|
745
|
+
return console.warn(l), { success: !1, message: l };
|
|
746
|
+
}
|
|
747
|
+
if (r.mode === "test" || t === globalThis.UserLeap.userId) return;
|
|
748
|
+
globalThis.UserLeap.userId = t;
|
|
749
|
+
const s = globalThis.UserLeap.visitorId, n = await D(R("1", [q, F]), { body: JSON.stringify({ userId: t }), method: "PUT" });
|
|
750
|
+
n.ok ? (s !== globalThis.UserLeap.visitorId && ((o = T.replay) == null || o.clearUserReplayData()), E("uid", t)) : n.reportError && (console.warn("[Sprig] (ERR-420) Failed to set user id", n.error), n.error && globalThis.UserLeap.reportError("setUserId", n.error));
|
|
751
|
+
}, async setPartnerAnonymousId(t) {
|
|
752
|
+
if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig setPartnerAnonymousId", t), t == null) {
|
|
753
|
+
const s = `[Sprig] - Invalid partnerAnonymousId ${t}`;
|
|
754
|
+
return console.warn(s), { success: !1, message: s };
|
|
755
|
+
}
|
|
756
|
+
return globalThis.UserLeap.partnerAnonymousId = t, E("aid", t), { success: !0 };
|
|
757
|
+
}, track: async (t, s, n = {}, o = void 0) => e({ eventName: t, properties: s, metadata: n, showSurveyCallback: o }), identifyAndTrack: async (t) => await e(t), trackPageView(t, s = void 0, n = void 0, o = !0) {
|
|
758
|
+
re = t, xt(t, s, n, o);
|
|
759
|
+
}, applyFeedbackStyles({ button: t = "", view: s = "" }) {
|
|
760
|
+
globalThis.UserLeap.feedbackCustomStyles = s, document.getElementById("sprig-feedback-style") && ce({ document, elementId: "ul-custom-style", styleString: t, nonce: globalThis.UserLeap.styleNonce }), i(document.querySelector(".ul-container-feedback"), s);
|
|
761
|
+
}, applyStyles(t) {
|
|
762
|
+
globalThis.UserLeap.customStyles = t, i(globalThis.UserLeap.container, t);
|
|
763
|
+
}, setWindowDimensions(t, s) {
|
|
764
|
+
var m, h;
|
|
765
|
+
const n = typeof t == "string" ? parseInt(t, 10) : t, o = typeof s == "string" ? parseInt(s, 10) : s;
|
|
766
|
+
isNaN(n) || isNaN(o) || (globalThis.UserLeap.windowDimensions = { width: n, height: o });
|
|
767
|
+
const l = O(globalThis.UserLeap), c = ve(l), d = l["userleap-platform"] === "web";
|
|
768
|
+
if (!globalThis.UserLeap.frameId) return;
|
|
769
|
+
const p = document.getElementById(globalThis.UserLeap.frameId);
|
|
770
|
+
p && (globalThis.UserLeap.useMobileStyling && ((m = globalThis.UserLeap.windowDimensions) != null && m.width && (p.style.width = `${globalThis.UserLeap.windowDimensions.width}px`), (h = globalThis.UserLeap.windowDimensions) != null && h.height && (p.style.maxHeight = globalThis.UserLeap.windowDimensions.height - 20 + "px"), p.contentDocument && (p.style.height = String($t(p.contentDocument, d && !c, ct(l))[0]) + "px")), g.emit(u.SurveyDimensions, { name: u.SurveyDimensions, contentFrameWidth: p.clientWidth, contentFrameHeight: p.clientHeight, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) }));
|
|
771
|
+
}, logoutUser() {
|
|
772
|
+
var t;
|
|
773
|
+
globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), P.info("LogOut", { vid: globalThis.UserLeap.visitorId, userId: globalThis.UserLeap.userId }), globalThis.UserLeap.visitorId = null, globalThis.UserLeap.userId = null, globalThis.UserLeap.partnerAnonymousId = null, globalThis.UserLeap.token = null, globalThis.UserLeap.email = null, H.removeItem("userleap.ids"), globalThis.UserLeap._queue.isPaused() && globalThis.UserLeap._queue.empty(), Rt(), (t = T.replay) == null || t.clearUserReplayData(), globalThis.UserLeap._queue.unpause();
|
|
774
|
+
}, teardown() {
|
|
775
|
+
["hashchange", "popstate"].forEach((t) => globalThis.removeEventListener(t, ie, !0)), globalThis.UserLeap._config.interactiveEvents && Et(), globalThis.UserLeap("dismissActiveSurvey", C.API), delete globalThis.UserLeap, delete globalThis.Sprig, delete globalThis._Sprig;
|
|
776
|
+
}, integrateOptimizely(t, s = !0) {
|
|
777
|
+
var n, o;
|
|
778
|
+
if ((o = (n = globalThis.UserLeap) == null ? void 0 : n._config) != null && o.optimizelyEnabled) try {
|
|
779
|
+
const l = typeof t == "string" ? JSON.parse(t) : t;
|
|
780
|
+
de.setOptimizelyExperiment(l, s);
|
|
781
|
+
} catch (l) {
|
|
782
|
+
console.warn("[Sprig] Error with integrating Optimizely data"), l instanceof Error && globalThis.UserLeap.reportError("integrateOptimizely", l);
|
|
783
|
+
}
|
|
784
|
+
else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
|
|
785
|
+
}, integrateOptimizelyClient(t) {
|
|
786
|
+
var s, n;
|
|
787
|
+
if (!((n = (s = globalThis.UserLeap) == null ? void 0 : s._config) != null && n.optimizelyEnabled)) return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
|
|
788
|
+
t.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event", ({ experiment: o, variation: l }) => {
|
|
789
|
+
const c = { experiments: [{ id: o.id, variation: l.key }] };
|
|
790
|
+
globalThis.UserLeap("integrateOptimizely", c, !1);
|
|
791
|
+
});
|
|
792
|
+
}, importLaunchDarklyData(t) {
|
|
793
|
+
var s, n;
|
|
794
|
+
(n = (s = globalThis.UserLeap) == null ? void 0 : s._config) != null && n.launchDarklyEnabled ? xe.setLDFlagsVariations(t) : console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");
|
|
795
|
+
}, setVisitorAttribute: (t, s) => (console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"), a.setAttribute(t, s)), setEmail: async (t) => a.setAttribute(X, t), setVisitorEmail: async (t) => (console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"), a.setEmail(t)), _generateVideoUploadUrl: async (t) => async function(s) {
|
|
796
|
+
var o;
|
|
797
|
+
if (!s) return;
|
|
798
|
+
const n = `${globalThis.UserLeap._API_URL}/2/environments/integrations/upload`;
|
|
799
|
+
try {
|
|
800
|
+
const l = await fetch(n, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(s) });
|
|
801
|
+
if (l.ok) {
|
|
802
|
+
const c = await l.json();
|
|
803
|
+
return (o = c == null ? void 0 : c.upload) == null ? void 0 : o.url;
|
|
804
|
+
}
|
|
805
|
+
return null;
|
|
806
|
+
} catch (l) {
|
|
807
|
+
console.warn("[Sprig] Error with generating video upload url"), l instanceof Error && globalThis.UserLeap.reportError("generateVideoUploadUrl", l);
|
|
808
|
+
}
|
|
809
|
+
}(t), _reportMetric(t, s) {
|
|
810
|
+
Ft(t, s);
|
|
811
|
+
}, _completeSessionReplay: async ({ surveyId: t, responseGroupUuid: s, eventDigest: n }) => {
|
|
812
|
+
var o;
|
|
813
|
+
return T.replay ? (o = T.replay) == null ? void 0 : o._completeSessionReplay({ surveyId: t, responseGroupUuid: s, eventDigest: n, headers: O(globalThis.UserLeap) }) : (globalThis.UserLeap.reportError("_completeSessionReplay", new Error("Replay module not registered")), !1);
|
|
814
|
+
}, pauseReplayRecording() {
|
|
815
|
+
var t, s, n, o;
|
|
816
|
+
(s = (t = T.replay) == null ? void 0 : t.isReplayPaused) != null && s.call(t) || ((o = (n = T.replay) == null ? void 0 : n.recordReplayPaused) == null || o.call(n));
|
|
817
|
+
}, resumeReplayRecording() {
|
|
818
|
+
var t, s, n, o, l, c;
|
|
819
|
+
(s = (t = T.replay) == null ? void 0 : t.isReplayPaused) != null && s.call(t) && ((o = (n = T.replay) == null ? void 0 : n.recordReplayResumed) == null || o.call(n), (c = (l = T.replay) == null ? void 0 : l.recordFullSnapshot) == null || c.call(l));
|
|
820
|
+
} };
|
|
821
|
+
Object.assign(globalThis.UserLeap, a);
|
|
822
|
+
};
|
|
823
|
+
async function nr(r, e, i = {}, a = {}) {
|
|
824
|
+
var d;
|
|
825
|
+
const t = (d = globalThis.__cfg) == null ? void 0 : d.mode, s = Oe(), n = globalThis.UserLeap.envId, o = globalThis.document.documentElement, l = { mode: t, screenWidth: globalThis.screen.width, screenHeight: globalThis.screen.height, clientWidth: o.clientWidth, clientHeight: o.clientHeight, location: re ?? globalThis.location.href, language: globalThis.navigator.language, ...i }, c = { action: r, breadcrumbs: P.breadcrumbs, err: { message: `${e == null ? void 0 : e.name} - ${e == null ? void 0 : e.message}`, stack: e == null ? void 0 : e.stack }, meta: l, vid: s, envId: n, ...a };
|
|
826
|
+
(await D(R("1", null, "errors"), { method: "POST", headers: { "x-ul-error": globalThis.btoa(`userleap-${Date.now()}-error`) }, body: JSON.stringify(c), shouldDropOnRateLimit: !0 })).ok || console.warn("[Sprig] (ERR-444) Failed to report error to API", e);
|
|
827
|
+
}
|
|
828
|
+
function lr(r = {}) {
|
|
829
|
+
var a;
|
|
830
|
+
(a = globalThis.SprigLoggerCallback) == null || a.call(globalThis, "Initializing Sprig");
|
|
831
|
+
const e = new URLSearchParams(globalThis.location.search).get("sprigPreviewKey") ?? "";
|
|
832
|
+
async function i() {
|
|
833
|
+
var p, m, h, y, f;
|
|
834
|
+
if (globalThis.UserLeap.loaded) return;
|
|
835
|
+
if ((p = globalThis.SprigLoggerCallback) == null || p.call(globalThis, "Loading Sprig"), globalThis.UserLeap.reportError = nr, globalThis.UserLeap.loaded = !0, globalThis.UserLeap._config = Object.assign({}, r, globalThis.UserLeap.config), globalThis.UserLeap.delayingSurvey = !1, globalThis.UserLeap._config && typeof globalThis.UserLeap._config == "object") for (const b in globalThis.UserLeap._config) globalThis.UserLeap[b] = globalThis.UserLeap._config[b];
|
|
836
|
+
if (globalThis.Sprig.outstandingTransactionLimit !== void 0 && (r.outstandingTransactionLimit = globalThis.Sprig.outstandingTransactionLimit), !globalThis.UserLeap.envId) {
|
|
837
|
+
if (!globalThis.UserLeap.appId) throw new Error("Missing Environment id");
|
|
838
|
+
globalThis.UserLeap.envId = globalThis.UserLeap.appId;
|
|
839
|
+
}
|
|
840
|
+
globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig debug mode enabled");
|
|
841
|
+
const t = _t(), s = globalThis.UserLeap.sampleRate;
|
|
842
|
+
let n = t.sampled;
|
|
843
|
+
if (s) {
|
|
844
|
+
if (n === null && (n = Math.random() < s, E("sampled", n)), !n) return;
|
|
845
|
+
} else n !== null && E("sampled", null);
|
|
846
|
+
globalThis.UserLeap._API_URL || (globalThis.UserLeap._API_URL = "https://api.sprig.com");
|
|
847
|
+
const o = [...globalThis.UserLeap._queue];
|
|
848
|
+
globalThis.UserLeap._queue = new Jt(globalThis.UserLeap, []), globalThis.UserLeap._queue.pause();
|
|
849
|
+
for (let b = 0; b < o.length; b++) globalThis.UserLeap._queue.push(o[b]);
|
|
850
|
+
const l = t.token;
|
|
851
|
+
l ? (globalThis.UserLeap.token = l, globalThis.UserLeap.visitorId = t.vid ?? null, globalThis.UserLeap.userId = t.uid ?? null, globalThis.UserLeap.partnerAnonymousId = t.aid ?? null) : Rt();
|
|
852
|
+
const c = ae(O(globalThis.UserLeap));
|
|
853
|
+
(m = globalThis.SprigLoggerCallback) == null || m.call(globalThis, "Sprig fetching config");
|
|
854
|
+
const d = await async function(b) {
|
|
855
|
+
var k, z;
|
|
856
|
+
const v = O(globalThis.UserLeap);
|
|
857
|
+
document.addEventListener("securitypolicyviolation", Ge);
|
|
858
|
+
const I = await lt(R("1", [q], "config"), { headers: v });
|
|
859
|
+
if (document.removeEventListener("securitypolicyviolation", Ge), !I.ok) return (k = globalThis.SprigLoggerCallback) == null || k.call(globalThis, "Sprig config fetch failed"), I.reportError && (console.warn("[Sprig] (ERR-422) Failed to load configuration", I.error), I.error && globalThis.UserLeap.reportError("applyRemoteConfig", I.error)), Ke("Disabled: failed to fetch configuration"), b;
|
|
860
|
+
const S = I.json;
|
|
861
|
+
return S != null && S.disabled ? ((z = globalThis.SprigLoggerCallback) == null || z.call(globalThis, "Sprig config fetch disabled"), Ke(`Disabled: ${S.disabled}`), { disabled: S.disabled }) : Object.assign({}, S, b);
|
|
862
|
+
}(r);
|
|
863
|
+
if ((h = globalThis.SprigLoggerCallback) == null || h.call(globalThis, "Sprig fetched config"), er({ isWeb: !c, reportingIntervalSeconds: d.metricsReportingEnabled || d.mobileMetricsReportingEnabled ? d.metricsReportingIntervalSeconds : 0, thresholds: d.metricThresholds, postMetrics: async (b) => {
|
|
864
|
+
var v;
|
|
865
|
+
await D(R("1", [q], "metrics"), { body: b, method: "POST", headers: { "x-ul-replay-enabled": `${!!((v = T.replay) != null && v.isReplayRecording())}` }, shouldDropOnRateLimit: !0 });
|
|
866
|
+
} }), !c) {
|
|
867
|
+
const b = d.alwaysOnReplay ? { userAgent: globalThis.navigator.userAgent, surveyId: d.alwaysOnReplay.surveyId, responseGroupUuid: d.alwaysOnReplay.responseGroupUuid, sdkVersion: "2.42.1", maxDurationSeconds: d.alwaysOnReplay.maxDurationSeconds } : void 0;
|
|
868
|
+
await ((y = T.replay) == null ? void 0 : y.initializeReplay({ maxReplayDurationSeconds: d.maxReplayDurationSeconds, maxInflightRequests: globalThis.UserLeap.maxInflightReplayRequests ?? 2, replaySettings: d.replaySettings, apiUrl: globalThis.UserLeap._API_URL, alwaysOnConfig: b })), je = d.replaySettings;
|
|
869
|
+
}
|
|
870
|
+
or(d), await ar(d), globalThis.UserLeap._queue.unpause(), (f = globalThis.SprigLoggerCallback) == null || f.call(globalThis, "SdkReady"), g.emit(u.SDKReady, { mobileMetricsReportingEnabled: !!d.mobileMetricsReportingEnabled, metricsReportingInterval: d.metricsReportingIntervalSeconds || 0, metricsThresholds: d.metricThresholds || [], maxMobileReplayDurationSeconds: d.maxMobileReplayDurationSeconds, mobileReplaySettings: d.mobileReplaySettings }), g.emit(u.VisitorIDUpdated, { visitorId: globalThis.UserLeap.visitorId }), g.on(u.VisitorIDUpdated, () => {
|
|
871
|
+
for (const b in me) delete me[b];
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
globalThis.UserLeap.UPDATES = se, globalThis.UserLeap("setPreviewKey", e), document.readyState === "complete" ? i() : globalThis.attachEvent ? globalThis.attachEvent("onload", i) : globalThis.addEventListener("load", () => {
|
|
875
|
+
i();
|
|
876
|
+
}, !1);
|
|
877
|
+
}
|
|
878
|
+
class fe {
|
|
879
|
+
constructor() {
|
|
880
|
+
B(this, "UPDATES", se);
|
|
881
|
+
}
|
|
882
|
+
displaySurvey(e) {
|
|
883
|
+
var i;
|
|
884
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "displaySurvey", e);
|
|
885
|
+
}
|
|
886
|
+
mute() {
|
|
887
|
+
var e;
|
|
888
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "mute");
|
|
889
|
+
}
|
|
890
|
+
unmute() {
|
|
891
|
+
var e;
|
|
892
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "unmute");
|
|
893
|
+
}
|
|
894
|
+
dismissActiveSurvey() {
|
|
895
|
+
var e;
|
|
896
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "dismissActiveSurvey");
|
|
897
|
+
}
|
|
898
|
+
setAttribute(e, i) {
|
|
899
|
+
var a;
|
|
900
|
+
(a = globalThis.Sprig) == null || a.call(globalThis, "setAttribute", e, i);
|
|
901
|
+
}
|
|
902
|
+
setAttributes(e) {
|
|
903
|
+
var i;
|
|
904
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "setAttributes", e);
|
|
905
|
+
}
|
|
906
|
+
identifyAndSetAttributes(e) {
|
|
907
|
+
var i;
|
|
908
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "identifyAndSetAttributes", e);
|
|
909
|
+
}
|
|
910
|
+
removeAttributes(e) {
|
|
911
|
+
var i;
|
|
912
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "removeAttributes", e);
|
|
913
|
+
}
|
|
914
|
+
addListener(e, i) {
|
|
915
|
+
var a;
|
|
916
|
+
(a = globalThis.Sprig) == null || a.call(globalThis, "addListener", e, i);
|
|
917
|
+
}
|
|
918
|
+
removeListener(e, i) {
|
|
919
|
+
var a;
|
|
920
|
+
(a = globalThis.Sprig) == null || a.call(globalThis, "removeListener", e, i);
|
|
921
|
+
}
|
|
922
|
+
removeAllListeners() {
|
|
923
|
+
var e;
|
|
924
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "removeAllListeners");
|
|
925
|
+
}
|
|
926
|
+
setEmail(e) {
|
|
927
|
+
var i;
|
|
928
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "setAttribute", "!email", e);
|
|
929
|
+
}
|
|
930
|
+
setUserId(e) {
|
|
931
|
+
var i;
|
|
932
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "setUserId", e);
|
|
933
|
+
}
|
|
934
|
+
setPartnerAnonymousId(e) {
|
|
935
|
+
var i;
|
|
936
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "setPartnerAnonymousId", e);
|
|
937
|
+
}
|
|
938
|
+
track(e, i = {}, a = {}) {
|
|
939
|
+
var t;
|
|
940
|
+
(t = globalThis.Sprig) == null || t.call(globalThis, "track", e, i, a);
|
|
941
|
+
}
|
|
942
|
+
identifyAndTrack(e) {
|
|
943
|
+
var i;
|
|
944
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "identifyAndTrack", e);
|
|
945
|
+
}
|
|
946
|
+
trackPageView(e, i, a) {
|
|
947
|
+
var t;
|
|
948
|
+
(t = globalThis.Sprig) == null || t.call(globalThis, "trackPageView", e, i, a);
|
|
949
|
+
}
|
|
950
|
+
applyStyles(e) {
|
|
951
|
+
var i;
|
|
952
|
+
(i = globalThis.Sprig) == null || i.call(globalThis, "applyStyles", e);
|
|
953
|
+
}
|
|
954
|
+
setWindowDimensions(e, i) {
|
|
955
|
+
var a;
|
|
956
|
+
(a = globalThis.Sprig) == null || a.call(globalThis, "setWindowDimensions", e, i);
|
|
957
|
+
}
|
|
958
|
+
logoutUser() {
|
|
959
|
+
var e;
|
|
960
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "logoutUser");
|
|
961
|
+
}
|
|
962
|
+
teardown() {
|
|
963
|
+
var e;
|
|
964
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "teardown");
|
|
965
|
+
}
|
|
966
|
+
pauseReplayRecording() {
|
|
967
|
+
var e;
|
|
968
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "pauseReplayRecording");
|
|
969
|
+
}
|
|
970
|
+
resumeReplayRecording() {
|
|
971
|
+
var e;
|
|
972
|
+
(e = globalThis.Sprig) == null || e.call(globalThis, "resumeReplayRecording");
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
const ot = { configure: (r) => {
|
|
976
|
+
if (!r.envId && !r.environmentId) throw new Error("Initialization Error: Sprig configure requires an environmentId");
|
|
977
|
+
if (r.envId || (r.envId = r.environmentId ?? ""), r.installationMethod = "web-npm", globalThis.Sprig) return globalThis.Sprig;
|
|
978
|
+
globalThis.Sprig = function() {
|
|
979
|
+
var i;
|
|
980
|
+
(i = globalThis.Sprig) == null || i._queue.push(arguments);
|
|
981
|
+
}, Object.getOwnPropertyNames(fe.prototype).map((i) => {
|
|
982
|
+
i !== "constructor" && (globalThis.Sprig[i] = fe.prototype[i]);
|
|
983
|
+
});
|
|
984
|
+
const e = globalThis.Sprig;
|
|
985
|
+
return e.appId = r.envId, e._queue = [], globalThis.UserLeap = e, lr(r), globalThis.Sprig;
|
|
986
|
+
} }, dr = new fe(), fr = { sprig: ot, SprigAPI: fe, configure: ot.configure, Sprig: dr };
|
|
987
|
+
export {
|
|
988
|
+
gr as A,
|
|
989
|
+
qt as C,
|
|
990
|
+
hr as D,
|
|
991
|
+
br as E,
|
|
992
|
+
dr as S,
|
|
993
|
+
fe as a,
|
|
994
|
+
yr as b,
|
|
995
|
+
fr as c,
|
|
996
|
+
ur as d,
|
|
997
|
+
$t as e,
|
|
998
|
+
ce as f,
|
|
999
|
+
Ce as g,
|
|
1000
|
+
j as i,
|
|
1001
|
+
mr as r,
|
|
1002
|
+
ot as s
|
|
1003
|
+
};
|