@sprig-technologies/sprig-browser 2.34.0 → 2.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{core-DE6rbUl1.js → core-9nFfVPj6.js} +105 -103
- package/dist/{core-i4jnjCfb.cjs → core-B84vH8bq.cjs} +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +52 -15
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +52 -15
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-CEzz54S2.js → metricsReporter-BzXI6BiM.js} +25 -20
- package/dist/{metricsReporter-Cc-ZSIZD.cjs → metricsReporter-Dy3EDEs8.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +281 -261
- package/dist/view-CDp4O3a5.js +2979 -0
- package/dist/view-DJLfkjCB.cjs +669 -0
- package/package.json +1 -1
- package/dist/view-Bze4Vd-1.cjs +0 -669
- package/dist/view-C3KUMRoa.js +0 -2752
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var It = Object.defineProperty;
|
|
2
2
|
var kt = (r, t, n) => t in r ? It(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
|
|
3
3
|
var W = (r, t, n) => kt(r, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { l as x, g as P, s as et, e as y, S as w, v as tt, m as
|
|
4
|
+
import { l as x, g as P, s as et, e as y, S as w, v as tt, m as S, b as q, h as rt, E as re, D as M, c as Et, r as $, i as _t, j as Rt, k as xt, n as He, o as Ve, d as Dt, a as At, p as it, q as nt } from "./metricsReporter-BzXI6BiM.js";
|
|
5
5
|
const nr = 360, or = "ul-app", sr = "#e6e6e6", ar = "#bd282a", dr = 1030, We = () => {
|
|
6
6
|
try {
|
|
7
7
|
return window.parent.Intercom;
|
|
@@ -55,64 +55,64 @@ function A(r, t, n) {
|
|
|
55
55
|
}
|
|
56
56
|
const X = async (r, t, n) => {
|
|
57
57
|
var Me, qe, Fe;
|
|
58
|
-
const { context: s, delay: e, forceBrandedLogo: i, endCard: o, isFeedback: a = !1, heatmap: l, locale: p, previewMode: d, productConfig: c, questions: g, responseGroupUid:
|
|
59
|
-
if (
|
|
58
|
+
const { context: s, delay: e, forceBrandedLogo: i, endCard: o, isFeedback: a = !1, heatmap: l, locale: p, previewMode: d, productConfig: c, questions: g, responseGroupUid: m, surveyId: u, uuid: E, vid: f, sessionReplay: v, studyType: L } = r, b = P(window.UserLeap), _ = ie(b), T = ge(b);
|
|
59
|
+
if (v) if (_) y.emit(w.ReplayCapture, { responseGroupUid: m, hasQuestions: !!(g != null && g.length), surveyId: u, uploadId: v.uploadId, replayType: v.replayDurationType ?? "before", seconds: v.replayDurationSeconds, generateVideoUploadUrlPayload: { mediaRecordingUid: tt(), mediaType: "screen", questionId: 1, responseGroupUid: m, surveyId: u, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), visitorId: window.UserLeap.visitorId, isReplay: !0 } });
|
|
60
60
|
else {
|
|
61
|
-
if (!
|
|
62
|
-
|
|
61
|
+
if (!S.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
|
|
62
|
+
S.replay.scheduleOrCaptureReplay({ responseGroupId: m, surveyId: u, visitorId: f, replayParams: v, completeUploadHeaders: b, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: g.length === 0 });
|
|
63
63
|
}
|
|
64
64
|
if (l) {
|
|
65
|
-
if (!
|
|
66
|
-
const { eventId:
|
|
67
|
-
await
|
|
65
|
+
if (!S.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: I, replayParams: J, responseGroupUid: fe, surveyId: ve } = l;
|
|
67
|
+
await S.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0, apiUrl: window.UserLeap._API_URL, replaySettings: n }), S.replay.tryReplayAction(() => {
|
|
68
68
|
var ze;
|
|
69
|
-
return (ze =
|
|
69
|
+
return (ze = S.replay) == null ? void 0 : ze.scheduleCapture({ apiUrl: window.UserLeap._API_URL, completeUploadHeaders: b, eventId: I, isHeatmap: !0, replayParams: J, responseGroupId: fe, surveyId: ve, triggerTimestamp: Date.now(), visitorId: f });
|
|
70
70
|
}, "Error in scheduling/capturing replay");
|
|
71
71
|
}
|
|
72
|
-
if (
|
|
72
|
+
if (f == null || !(g != null && g.length)) return q.info("CannotDisplaySurvey", { vid: f }), { success: !1, message: "[Sprig] no survey found", surveyState: "no survey" };
|
|
73
73
|
if (window.UserLeap.container) {
|
|
74
74
|
q.info("AlreadyDisplayingSurvey");
|
|
75
|
-
const
|
|
76
|
-
return console.warn(
|
|
75
|
+
const I = "[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";
|
|
76
|
+
return console.warn(I), { success: !1, message: I, surveyState: "no survey" };
|
|
77
77
|
}
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
return window.UserLeap.reportError("DisplaySurvey", new Error(
|
|
78
|
+
if (f !== window.UserLeap.visitorId && E !== window.UserLeap.visitorId && !window.previewMode) {
|
|
79
|
+
const I = "Attempted to display survey to a different visitor";
|
|
80
|
+
return window.UserLeap.reportError("DisplaySurvey", new Error(I)), { success: !1, message: I, surveyState: "no survey" };
|
|
81
81
|
}
|
|
82
|
-
q.info("ShowingSurvey", { surveyId: u }), (Me =
|
|
83
|
-
let
|
|
84
|
-
const Ce = (
|
|
85
|
-
const { "view.version": J } =
|
|
82
|
+
q.info("ShowingSurvey", { surveyId: u }), (Me = S.replay) == null || Me.RecordSurveyShown({ id: u, userAgent: window.navigator.userAgent }), Ot.disable(), y.emit(w.SurveyWillPresent, { name: w.SurveyWillPresent, "survey.id": u });
|
|
83
|
+
let U, D, k, H, V = document.createElement("div");
|
|
84
|
+
const Ce = (I) => {
|
|
85
|
+
const { "view.version": J } = I;
|
|
86
86
|
J !== b["x-ul-sdk-version"] && st(), y.removeListener("verify.view.version", Ce);
|
|
87
87
|
};
|
|
88
|
-
y.on("verify.view.version", Ce), window.UserLeap.useMobileStyling = T, rt(b) ? (
|
|
89
|
-
const
|
|
88
|
+
y.on("verify.view.version", Ce), window.UserLeap.useMobileStyling = T, rt(b) ? (U = "ul-direct-embeded-frame", D = document.head, k = window, H = !1, (() => {
|
|
89
|
+
const I = P(window.UserLeap), J = ie(I), fe = window.UserLeap.forceDirectEmbed, ve = I["userleap-platform"] === "web";
|
|
90
90
|
return J || fe && ve;
|
|
91
|
-
})() && (ot(u, a), V.id =
|
|
92
|
-
const G = { apiURL: window.UserLeap._API_URL, cards: g, configureExitOnOverlayClick: (
|
|
93
|
-
y.once(w.CloseSurveyOnOverlayClick,
|
|
94
|
-
}, context: s, endCard: o, envId: window.UserLeap.envId, eventEmitFn: y.emit.bind(y), fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: i, frame: V, headers: b, locale: p, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: x.getItem("sprig.previewKey"), previewMode: d, productConfig: { framePosition: c == null ? void 0 : c.framePosition, desktopDisplay: c == null ? void 0 : c.desktopDisplay, placement: c == null ? void 0 : c.placement }, responseGroupUid:
|
|
91
|
+
})() && (ot(u, a), V.id = U, window.UserLeap.container.appendChild(V), at(), y.emit(w.SurveyLifeCycle, { state: "presented" }), y.emit(w.SurveyPresented, { name: w.SurveyPresented, "survey.id": u }))) : { frameId: U, contentWinDocHead: D, contentWindow: k, hasOverlay: H, iframe: V } = Tt({ productConfig: c, useMobileStyling: T, surveyId: u, isFeedback: a }), window.UserLeap.frameId = U;
|
|
92
|
+
const G = { apiURL: window.UserLeap._API_URL, cards: g, configureExitOnOverlayClick: (I) => {
|
|
93
|
+
y.once(w.CloseSurveyOnOverlayClick, I);
|
|
94
|
+
}, context: s, endCard: o, envId: window.UserLeap.envId, eventEmitFn: y.emit.bind(y), fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: i, frame: V, headers: b, locale: p, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: x.getItem("sprig.previewKey"), previewMode: d, productConfig: { framePosition: c == null ? void 0 : c.framePosition, desktopDisplay: c == null ? void 0 : c.desktopDisplay, placement: c == null ? void 0 : c.placement }, responseGroupUid: m, startingQuestionIdx: (qe = window.UserLeap.config) == null ? void 0 : qe.startingQuestionIdx, studyType: L, styleNonce: window.UserLeap.styleNonce, surveyId: u, tabTitle: document.title, trackPageViewUrl: t, ulEvents: re, upchunkLibraryURL: window.UserLeap.upchunkLibraryURL, useMobileStyling: T, userId: E, viewDocument: k == null ? void 0 : k.document, viewWindow: k, visitorAttributes: { externalUserId: window.UserLeap.userId, email: window.UserLeap.email }, ...window.UserLeap._config };
|
|
95
95
|
(Fe = window.UserLeap._config) != null && Fe.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null });
|
|
96
96
|
const St = (a ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? c.customStyles;
|
|
97
97
|
G.customStyles = St, k && (k.__cfg = G);
|
|
98
98
|
const ye = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : G.path, Pe = document.getElementById(Ne);
|
|
99
99
|
Pe && Pe.remove();
|
|
100
100
|
const me = function() {
|
|
101
|
-
const
|
|
102
|
-
return window.UserLeap.nonce &&
|
|
101
|
+
const I = document.createElement("script");
|
|
102
|
+
return window.UserLeap.nonce && I.setAttribute("nonce", window.UserLeap.nonce), I.id = Ne, I;
|
|
103
103
|
}(), Te = () => {
|
|
104
104
|
window.UserLeap.container && Object.assign(window.UserLeap.container.style, { display: "flex" });
|
|
105
105
|
};
|
|
106
106
|
if (G.installationMethod === "web-npm" || G.installationMethod === "web-npm-bundled") {
|
|
107
|
-
const { default:
|
|
108
|
-
|
|
107
|
+
const { default: I } = await import("./view-CDp4O3a5.js");
|
|
108
|
+
I.configure(G), H && window.UserLeap.container && Te();
|
|
109
109
|
} else ye && (me.src = ye, H && me.addEventListener("load", () => {
|
|
110
110
|
window.UserLeap.container && Te();
|
|
111
|
-
}), k == null || k.addEventListener("error", (
|
|
112
|
-
|
|
111
|
+
}), k == null || k.addEventListener("error", (I) => {
|
|
112
|
+
I.target instanceof HTMLScriptElement && I.target.src === ye && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load"));
|
|
113
113
|
}, { capture: !0, once: !0 }));
|
|
114
114
|
D == null || D.appendChild(me);
|
|
115
|
-
const je = { success: !0, surveyState: "ready", surveyId: u, responseGroupUid:
|
|
115
|
+
const je = { success: !0, surveyState: "ready", surveyId: u, responseGroupUid: m };
|
|
116
116
|
return window.UserLeap.isMobileSDK && e && (je.delay = e), je;
|
|
117
117
|
};
|
|
118
118
|
function ge(r) {
|
|
@@ -170,12 +170,12 @@ const he = "0px", ot = (r, t, n) => {
|
|
|
170
170
|
g();
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
return p && ((g,
|
|
174
|
-
const u = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, E =
|
|
175
|
-
u["background-color"] = E === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)",
|
|
173
|
+
return p && ((g, m) => {
|
|
174
|
+
const u = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, E = m ? g.overlayStyleMobile : g.overlayStyle;
|
|
175
|
+
u["background-color"] = E === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)", m || (u.margin = "auto"), window.UserLeap.container && Object.assign(window.UserLeap.container.style, u);
|
|
176
176
|
})(i, n), Object.assign(r.style, e, l), p;
|
|
177
177
|
}, Tt = ({ productConfig: r, useMobileStyling: t, surveyId: n, isFeedback: s }) => {
|
|
178
|
-
var g,
|
|
178
|
+
var g, m;
|
|
179
179
|
const e = De, i = s && r.desktopDisplay === "slider";
|
|
180
180
|
ot(n, s, i), jt();
|
|
181
181
|
const o = document.createElement("iframe");
|
|
@@ -192,7 +192,7 @@ const he = "0px", ot = (r, t, n) => {
|
|
|
192
192
|
}, (g = window.UserLeap.container) == null || g.appendChild(o), r && (t ? r.exitOnOverlayClickMobile : r.exitOnOverlayClick) && window.UserLeap.container && (window.UserLeap.container.onclick = () => {
|
|
193
193
|
y.emit(w.CloseSurveyOnOverlayClick);
|
|
194
194
|
}), y.emit(w.SurveyLifeCycle, { state: "presented" }), y.emit(w.SurveyPresented, { name: w.SurveyPresented, "survey.id": n });
|
|
195
|
-
const d = (
|
|
195
|
+
const d = (m = o.contentWindow) == null ? void 0 : m.document;
|
|
196
196
|
if (d && (d.open("text/html", "replace"), d.write("<!doctype html><head></head><body></body></html>"), d.close(), !t)) {
|
|
197
197
|
const u = d.body;
|
|
198
198
|
u.style.display = "flex", u.style.alignItems = "center";
|
|
@@ -231,9 +231,9 @@ const he = "0px", ot = (r, t, n) => {
|
|
|
231
231
|
const l = s.querySelector(".ul-card--matrix_grid"), p = !l && t && n;
|
|
232
232
|
try {
|
|
233
233
|
p && (e.style.width = "360px"), i = s.clientHeight, i += ((g) => {
|
|
234
|
-
const
|
|
235
|
-
let
|
|
236
|
-
return j(u) && (
|
|
234
|
+
const m = g.querySelector(".sprig-question-body"), u = g.querySelector(".ul-card"), E = g.querySelector(".ul-card-main-content"), f = g.querySelector(".ul-footer"), v = g.querySelector(".sprig-container");
|
|
235
|
+
let L = 0;
|
|
236
|
+
return j(u) && (L += u.scrollHeight - u.clientHeight), j(E) && (L += E.scrollHeight - E.clientHeight), j(m) && (L += m.scrollHeight - m.clientHeight), j(f) && j(v) && v.clientHeight === 0 && (L += f.clientHeight), L;
|
|
237
237
|
})(r);
|
|
238
238
|
const d = getComputedStyle(s);
|
|
239
239
|
a = i;
|
|
@@ -298,41 +298,41 @@ const zt = ["bottom-left", "bottom-right", "center-left", "center-right"], ae =
|
|
|
298
298
|
c.remove(), y.off(re.SURVEY_FADING_OUT, be);
|
|
299
299
|
}
|
|
300
300
|
Z = i, se({ 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 }), se({ document, elementId: "ul-custom-style", styleString: e ?? "", nonce: window.UserLeap.styleNonce }), Ke = a === "center-modal", B = o;
|
|
301
|
-
const [g,
|
|
302
|
-
((
|
|
303
|
-
if (K() || !zt.includes(
|
|
304
|
-
const [
|
|
305
|
-
|
|
301
|
+
const [g, m] = o.split("-");
|
|
302
|
+
((v) => {
|
|
303
|
+
if (K() || !zt.includes(v)) return;
|
|
304
|
+
const [L, b] = v.split("-"), _ = document.createElement("div");
|
|
305
|
+
_.id = "sprig-feedback-container", _.classList.add(`sprig-feedback-container-${b}`, `sprig-feedback-container-${L}`), document.body.appendChild(_);
|
|
306
306
|
})(o), c = K(), C = document.createElement("button");
|
|
307
307
|
const u = document.createElement("div");
|
|
308
|
-
u.className = "sprig-feedback-button-label", u.innerText = l, C.appendChild(u), C.id = "sprig-feedback-button", C.classList.add(`sprig-feedback-button-${
|
|
309
|
-
const
|
|
308
|
+
u.className = "sprig-feedback-button-label", u.innerText = l, C.appendChild(u), C.id = "sprig-feedback-button", C.classList.add(`sprig-feedback-button-${m}`, `sprig-feedback-button-${g}`, `sprig-feedback-button-${s}`, "fade-in-transition"), y.on(re.SURVEY_FADING_OUT, be), C.addEventListener("click", async () => {
|
|
309
|
+
const v = document.getElementById("sprig-feedback-error-container");
|
|
310
310
|
if (ct() || pt()) {
|
|
311
311
|
if (be()) {
|
|
312
312
|
y.emit(w.SurveyCloseRequested, { name: w.SurveyCloseRequested, initiator: M.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }), y.emit(w.SurveyWillClose, { name: w.SurveyWillClose, initiator: M.FeedbackClosed, studyType: "feedbackButton", "survey.id": d });
|
|
313
313
|
const b = K();
|
|
314
|
-
|
|
314
|
+
v && b && (b.remove(), Z = null, h = null);
|
|
315
315
|
}
|
|
316
316
|
return;
|
|
317
317
|
}
|
|
318
318
|
if (ge(P(window.UserLeap)) || Ae || Je(), t) return h && h.classList.add("sprig-feedback-loading-container-previews"), await X(t), void Y();
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
return
|
|
319
|
+
const L = await (async (b) => {
|
|
320
|
+
const _ = await O(A("1", [F], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: b }), method: "POST" });
|
|
321
|
+
return _.ok ? _.json : null;
|
|
322
322
|
})(p);
|
|
323
|
-
if (
|
|
323
|
+
if (L) y.once(w.SurveyAppeared, Y), X({ ...L, studyType: "feedbackButton" }, n);
|
|
324
324
|
else if (h) {
|
|
325
325
|
const b = Ht();
|
|
326
326
|
h.appendChild(b), Y(), h.style.height = "300px", h.style.width = "360px";
|
|
327
327
|
}
|
|
328
328
|
}), c == null || c.appendChild(C), y.emit(w.FeedbackButtonLoaded, { name: w.FeedbackButtonLoaded, "survey.id": d });
|
|
329
|
-
const { useMobileStyling: E, _config: { border:
|
|
329
|
+
const { useMobileStyling: E, _config: { border: f } } = window.UserLeap;
|
|
330
330
|
if (Ke || E) de(0);
|
|
331
331
|
else {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
de(-
|
|
332
|
+
const v = document.createElement("div");
|
|
333
|
+
v.id = "sprig-feedback-loading-container", v.className = `sprig-feedback-loading-container sprig-feedback-loading-container-${m}`, v.style.setProperty("--feedback-border", f), h = v, Ie(), c == null || c.appendChild(v);
|
|
334
|
+
const L = ut();
|
|
335
|
+
de(-L);
|
|
336
336
|
}
|
|
337
337
|
window.UserLeap._config.isOnQuestionsTab && t && !ae() && h && (Je(), Ie(), h && h.classList.add("sprig-feedback-loading-container-previews"), X(t), Y());
|
|
338
338
|
}, Ht = () => {
|
|
@@ -501,9 +501,9 @@ const ne = (r, t = 1) => {
|
|
|
501
501
|
}, Gt = ({ isWeb: r, reportingIntervalSeconds: t, thresholds: n, postMetrics: s }) => {
|
|
502
502
|
_t(n, (e, i) => {
|
|
503
503
|
var o, a;
|
|
504
|
-
if ((o =
|
|
504
|
+
if ((o = S.replay) != null && o.isReplayRecording()) {
|
|
505
505
|
const l = `Value: ${e} on ${i.metric} violated threshold of ${i.type} ${i.value}`;
|
|
506
|
-
(a =
|
|
506
|
+
(a = S.replay) == null || a.disableRecording("Threshold violated", new Error(l), { reportError: !1 }), window.UserLeap.reportError("Sdk Performance Metric threshold violated", new Error("Sdk Performance Metric threshold violated"), { metricName: i.metric, type: i.type, value: i.value }, { metricName: i.metric }), xt();
|
|
507
507
|
}
|
|
508
508
|
}), Rt({ reportingIntervalSeconds: t, postMetrics: s }), r && (((e = 1e3) => {
|
|
509
509
|
const i = $("sdk_event_queue_latency_seconds");
|
|
@@ -525,9 +525,9 @@ function te(r) {
|
|
|
525
525
|
if (ae()) return;
|
|
526
526
|
const p = K();
|
|
527
527
|
p && (Et(Z) || (p.remove(), Z = null, h = null));
|
|
528
|
-
})(), At.getItem("sprig.isCapturingHeatmap") && ((l = (a =
|
|
528
|
+
})(), At.getItem("sprig.isCapturingHeatmap") && ((l = (a = S.replay) == null ? void 0 : a.checkPendingHeatmapsUrl()) == null || l.then((p) => {
|
|
529
529
|
var d;
|
|
530
|
-
p && ((d =
|
|
530
|
+
p && ((d = S.replay) == null || d.uploadReadyPendingCaptures(!0));
|
|
531
531
|
})), !ae() && s && o && o !== window.location.href && r && Jt.includes(r.type) && window.UserLeap("dismissActiveSurvey", M.PageChange);
|
|
532
532
|
}
|
|
533
533
|
const vt = { capture: !0 }, Qt = () => {
|
|
@@ -560,7 +560,7 @@ function Ut(r, t, n, s) {
|
|
|
560
560
|
if (r.endsWith("mock_snippet.html")) return;
|
|
561
561
|
q.info("PageView", { url: r });
|
|
562
562
|
const o = (e = document == null ? void 0 : document.querySelector('meta[name="description"]')) == null ? void 0 : e.getAttribute("content");
|
|
563
|
-
(i =
|
|
563
|
+
(i = S.replay) == null || i.RecordPageView({ ...o && { description: o }, url: r, referrer: document.referrer, pageTitle: document.title });
|
|
564
564
|
const a = window.UserLeap._config.pageUrlEvents;
|
|
565
565
|
let l = !1;
|
|
566
566
|
if (a && a.length) for (let d = 0; d < a.length && (l = it(a[d], r), !l); d++) ;
|
|
@@ -615,38 +615,38 @@ function Xt(r) {
|
|
|
615
615
|
const Zt = function(r) {
|
|
616
616
|
if (!window.UserLeap) return;
|
|
617
617
|
const t = async (e = {}) => {
|
|
618
|
-
var
|
|
618
|
+
var v, L, b, _, T;
|
|
619
619
|
const { userId: i, anonymousId: o, metadata: a = {}, properties: l, showSurveyCallback: p } = e;
|
|
620
620
|
let { eventName: d } = e;
|
|
621
621
|
if (window.UserLeap.debugMode && d !== ft && console.info("[DEBUG] Sprig track", e), r.mode === "test") return;
|
|
622
622
|
const c = x.getItem("sprig.previewKey") ?? void 0;
|
|
623
623
|
if (r.requireUserIdForTracking && !window.UserLeap.userId && !i) {
|
|
624
|
-
const
|
|
625
|
-
return console.warn(
|
|
624
|
+
const U = "[Sprig] - Skipping tracking without userId";
|
|
625
|
+
return console.warn(U), { success: !1, message: U, surveyState: "no survey" };
|
|
626
626
|
}
|
|
627
627
|
if (!d || d.trim().length === 0) {
|
|
628
628
|
d = d ? String(d) : "";
|
|
629
|
-
const
|
|
630
|
-
return console.warn(
|
|
629
|
+
const U = "[Sprig] - Invalid event name " + d;
|
|
630
|
+
return console.warn(U), { success: !1, message: U, surveyState: "no survey" };
|
|
631
631
|
}
|
|
632
632
|
const g = ee ?? window.location.href;
|
|
633
|
-
a.url || (a.url = g), R("trackStartUrl", g), (
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
636
|
-
const
|
|
637
|
-
return
|
|
633
|
+
a.url || (a.url = g), R("trackStartUrl", g), (L = (v = window.UserLeap) == null ? void 0 : v._config) != null && L.optimizelyEnabled && (ie(P(window.UserLeap)) || oe.getAndSetWebOptimizelyExperiments(), a.optimizelyExperiments = Object.assign({}, oe.getAllOptimizelyExperiments())), (_ = (b = window.UserLeap) == null ? void 0 : b._config) != null && _.launchDarklyEnabled && (a.launchDarklyFlags = ke.getAllLaunchDarklyVariations()), i && (window.UserLeap.userId = i), o && (window.UserLeap.partnerAnonymousId = o), l && (a.eventProperties = l), (T = S.replay) == null || T.RecordEvent({ name: d, url: a.url }), q.info("TrackEvent", { eventName: d });
|
|
634
|
+
const m = window.UserLeap.delayingSurvey || ct() ? await O(A("1", [F], "events/batch"), { body: JSON.stringify({ events: [{ event: d, metadata: a }], previewKey: c }), method: "POST", shouldDropOnRateLimit: !0 }) : await O(A("1", [F], "events"), { body: JSON.stringify({ event: d, metadata: a, previewKey: c }), method: "POST", shouldDropOnRateLimit: !0 });
|
|
635
|
+
if (!m.ok) {
|
|
636
|
+
const U = "[Sprig] (ERR-421) Failed to track event";
|
|
637
|
+
return m.reportError && (console.warn(U, m.error), m.error && window.UserLeap.reportError("track", m.error)), { success: !1, message: U, error: m.error, surveyState: "no survey" };
|
|
638
638
|
}
|
|
639
639
|
i && R("uid", i), o && R("aid", o);
|
|
640
|
-
const u =
|
|
640
|
+
const u = m.json;
|
|
641
641
|
u.invalidPreviewKey && x.removeItem("sprig.previewKey");
|
|
642
642
|
const E = a.trackPageView ? a.url : void 0;
|
|
643
|
-
return u != null && u.feedbackButton && wt(u.feedbackButton, void 0, E), await async function(
|
|
643
|
+
return u != null && u.feedbackButton && wt(u.feedbackButton, void 0, E), await async function(U, D) {
|
|
644
644
|
var H, V;
|
|
645
645
|
let k = !0;
|
|
646
|
-
return !(D && ((H =
|
|
647
|
-
}(
|
|
646
|
+
return !(D && ((H = U == null ? void 0 : U.json) != null && H.surveyId) && (window.UserLeap.delayingSurvey = !0, k = await D(U.json.surveyId), window.UserLeap.delayingSurvey = !1, !k)) && ((V = U == null ? void 0 : U.json) != null && V.delay && !window.UserLeap.isMobileSDK && (window.UserLeap.delayingSurvey = !0, await nt(U.json.delay), window.UserLeap.delayingSurvey = !1), k);
|
|
647
|
+
}(m, p) ? function(U) {
|
|
648
648
|
if (!window.UserLeap._config.dismissOnPageChange) return !0;
|
|
649
|
-
const D = new URL(
|
|
649
|
+
const D = new URL(U), k = new URL(ee ?? window.location.href);
|
|
650
650
|
return D.hostname === k.hostname && D.pathname === k.pathname;
|
|
651
651
|
}(g) ? X(u, E, Oe) : { 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" };
|
|
652
652
|
}, n = (e, i) => {
|
|
@@ -734,7 +734,7 @@ const Zt = function(r) {
|
|
|
734
734
|
if (r.mode === "test" || e === window.UserLeap.userId) return;
|
|
735
735
|
window.UserLeap.userId = e;
|
|
736
736
|
const i = window.UserLeap.visitorId, o = await O(A("1", [z, F]), { body: JSON.stringify({ userId: e }), method: "PUT" });
|
|
737
|
-
o.ok ? (i !== window.UserLeap.visitorId && ((a =
|
|
737
|
+
o.ok ? (i !== window.UserLeap.visitorId && ((a = S.replay) == null || a.clearUserReplayData()), R("uid", e)) : o.reportError && (console.warn("[Sprig] (ERR-420) Failed to set user id", o.error), o.error && window.UserLeap.reportError("setUserId", o.error));
|
|
738
738
|
}, async setPartnerAnonymousId(e) {
|
|
739
739
|
if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig setPartnerAnonymousId", e), e == null) {
|
|
740
740
|
const i = `[Sprig] - Invalid partnerAnonymousId ${e}`;
|
|
@@ -748,16 +748,16 @@ const Zt = function(r) {
|
|
|
748
748
|
}, applyStyles(e) {
|
|
749
749
|
window.UserLeap.customStyles = e, n(window.UserLeap.container, e);
|
|
750
750
|
}, setWindowDimensions(e, i) {
|
|
751
|
-
var g,
|
|
751
|
+
var g, m;
|
|
752
752
|
const o = typeof e == "string" ? parseInt(e, 10) : e, a = typeof i == "string" ? parseInt(i, 10) : i;
|
|
753
753
|
isNaN(o) || isNaN(a) || (window.UserLeap.windowDimensions = { width: o, height: a });
|
|
754
754
|
const l = P(window.UserLeap), p = ge(l), d = l["userleap-platform"] === "web";
|
|
755
755
|
if (!window.UserLeap.frameId) return;
|
|
756
756
|
const c = document.getElementById(window.UserLeap.frameId);
|
|
757
|
-
c && (window.UserLeap.useMobileStyling && ((g = window.UserLeap.windowDimensions) != null && g.width && (c.style.width = `${window.UserLeap.windowDimensions.width}px`), (
|
|
757
|
+
c && (window.UserLeap.useMobileStyling && ((g = window.UserLeap.windowDimensions) != null && g.width && (c.style.width = `${window.UserLeap.windowDimensions.width}px`), (m = window.UserLeap.windowDimensions) != null && m.height && (c.style.maxHeight = window.UserLeap.windowDimensions.height - 20 + "px"), c.contentDocument && (c.style.height = String(Ft(c.contentDocument, d && !p, rt(l))[0]) + "px")), y.emit(w.SurveyDimensions, { name: w.SurveyDimensions, contentFrameWidth: c.clientWidth, contentFrameHeight: c.clientHeight, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }));
|
|
758
758
|
}, logoutUser() {
|
|
759
759
|
var e;
|
|
760
|
-
window.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), q.info("LogOut", { vid: window.UserLeap.visitorId, userId: window.UserLeap.userId }), window.UserLeap.visitorId = null, window.UserLeap.userId = null, window.UserLeap.partnerAnonymousId = null, window.UserLeap.token = null, window.UserLeap.email = null, x.removeItem("userleap.ids"), window.UserLeap._queue.isPaused() && window.UserLeap._queue.empty(), Lt(), (e =
|
|
760
|
+
window.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), q.info("LogOut", { vid: window.UserLeap.visitorId, userId: window.UserLeap.userId }), window.UserLeap.visitorId = null, window.UserLeap.userId = null, window.UserLeap.partnerAnonymousId = null, window.UserLeap.token = null, window.UserLeap.email = null, x.removeItem("userleap.ids"), window.UserLeap._queue.isPaused() && window.UserLeap._queue.empty(), Lt(), (e = S.replay) == null || e.clearUserReplayData(), window.UserLeap._queue.unpause();
|
|
761
761
|
}, teardown() {
|
|
762
762
|
["hashchange", "popstate"].forEach((e) => window.removeEventListener(e, te, !0)), window.UserLeap._config.interactiveEvents && ht(), window.UserLeap("dismissActiveSurvey", M.API), delete window.UserLeap, delete window.Sprig, delete window._Sprig;
|
|
763
763
|
}, integrateOptimizely(e, i = !0) {
|
|
@@ -797,13 +797,13 @@ const Zt = function(r) {
|
|
|
797
797
|
Dt(e, i);
|
|
798
798
|
}, _completeSessionReplay: async ({ surveyId: e, responseGroupUuid: i, eventDigest: o }) => {
|
|
799
799
|
var a;
|
|
800
|
-
return
|
|
800
|
+
return S.replay ? (a = S.replay) == null ? void 0 : a._completeSessionReplay({ surveyId: e, responseGroupUuid: i, eventDigest: o, headers: P(window.UserLeap) }) : (window.UserLeap.reportError("_completeSessionReplay", new Error("Replay module not registered")), !1);
|
|
801
801
|
}, pauseReplayRecording() {
|
|
802
802
|
var e, i, o, a;
|
|
803
|
-
(i = (e =
|
|
803
|
+
(i = (e = S.replay) == null ? void 0 : e.isReplayPaused) != null && i.call(e) || ((a = (o = S.replay) == null ? void 0 : o.recordReplayPaused) == null || a.call(o));
|
|
804
804
|
}, resumeReplayRecording() {
|
|
805
805
|
var e, i, o, a, l, p;
|
|
806
|
-
(i = (e =
|
|
806
|
+
(i = (e = S.replay) == null ? void 0 : e.isReplayPaused) != null && i.call(e) && ((a = (o = S.replay) == null ? void 0 : o.recordReplayResumed) == null || a.call(o), (p = (l = S.replay) == null ? void 0 : l.recordFullSnapshot) == null || p.call(l));
|
|
807
807
|
} };
|
|
808
808
|
Object.assign(window.UserLeap, s);
|
|
809
809
|
};
|
|
@@ -816,10 +816,10 @@ function tr(r = {}) {
|
|
|
816
816
|
(s = window.SprigLoggerCallback) == null || s.call(window, "Initializing Sprig");
|
|
817
817
|
const t = new URLSearchParams(window.location.search).get("sprigPreviewKey") ?? "";
|
|
818
818
|
async function n() {
|
|
819
|
-
var g,
|
|
819
|
+
var c, g, m, u, E;
|
|
820
820
|
if (window.UserLeap.loaded) return;
|
|
821
|
-
if ((
|
|
822
|
-
if (!window.UserLeap.envId) {
|
|
821
|
+
if ((c = window.SprigLoggerCallback) == null || c.call(window, "Loading Sprig"), window.UserLeap.reportError = er, window.UserLeap.loaded = !0, window.UserLeap._config = Object.assign({}, r, window.UserLeap.config), window.UserLeap.delayingSurvey = !1, window.UserLeap._config && typeof window.UserLeap._config == "object") for (const f in window.UserLeap._config) window.UserLeap[f] = window.UserLeap._config[f];
|
|
822
|
+
if (window.Sprig.outstandingTransactionLimit !== void 0 && (r.outstandingTransactionLimit = window.Sprig.outstandingTransactionLimit), !window.UserLeap.envId) {
|
|
823
823
|
if (!window.UserLeap.appId) throw new Error("Missing Environment id");
|
|
824
824
|
window.UserLeap.envId = window.UserLeap.appId;
|
|
825
825
|
}
|
|
@@ -832,27 +832,29 @@ function tr(r = {}) {
|
|
|
832
832
|
window.UserLeap._API_URL || (window.UserLeap._API_URL = "https://api.sprig.com");
|
|
833
833
|
const a = [...window.UserLeap._queue];
|
|
834
834
|
window.UserLeap._queue = new Vt(window.UserLeap, []), window.UserLeap._queue.pause();
|
|
835
|
-
for (let
|
|
835
|
+
for (let f = 0; f < a.length; f++) window.UserLeap._queue.push(a[f]);
|
|
836
836
|
const l = e.token;
|
|
837
837
|
l ? (window.UserLeap.token = l, window.UserLeap.visitorId = e.vid ?? null, window.UserLeap.userId = e.uid ?? null, window.UserLeap.partnerAnonymousId = e.aid ?? null) : Lt();
|
|
838
838
|
const p = ie(P(window.UserLeap));
|
|
839
|
-
(
|
|
840
|
-
const d = await async function(
|
|
841
|
-
var
|
|
842
|
-
const
|
|
839
|
+
(g = window.SprigLoggerCallback) == null || g.call(window, "Sprig fetching config");
|
|
840
|
+
const d = await async function(f) {
|
|
841
|
+
var _, T;
|
|
842
|
+
const v = P(window.UserLeap);
|
|
843
843
|
document.addEventListener("securitypolicyviolation", He);
|
|
844
|
-
const
|
|
845
|
-
if (document.removeEventListener("securitypolicyviolation", He), !
|
|
846
|
-
const
|
|
847
|
-
return
|
|
844
|
+
const L = await et(A("1", [z], "config"), { headers: v });
|
|
845
|
+
if (document.removeEventListener("securitypolicyviolation", He), !L.ok) return (_ = window.SprigLoggerCallback) == null || _.call(window, "Sprig config fetch failed"), L.reportError && (console.warn("[Sprig] (ERR-422) Failed to load configuration", L.error), L.error && window.UserLeap.reportError("applyRemoteConfig", L.error)), Ve("Disabled: failed to fetch configuration"), f;
|
|
846
|
+
const b = L.json;
|
|
847
|
+
return b != null && b.disabled ? ((T = window.SprigLoggerCallback) == null || T.call(window, "Sprig config fetch disabled"), Ve(`Disabled: ${b.disabled}`), { disabled: b.disabled }) : Object.assign({}, b, f);
|
|
848
848
|
}(r);
|
|
849
|
-
(
|
|
850
|
-
var
|
|
851
|
-
await O(A("1", [z], "metrics"), { body:
|
|
852
|
-
} })
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
849
|
+
if ((m = window.SprigLoggerCallback) == null || m.call(window, "Sprig fetched config"), Gt({ isWeb: !p, reportingIntervalSeconds: d.metricsReportingEnabled || d.mobileMetricsReportingEnabled ? d.metricsReportingIntervalSeconds : 0, thresholds: d.metricThresholds, postMetrics: async (f) => {
|
|
850
|
+
var v;
|
|
851
|
+
await O(A("1", [z], "metrics"), { body: f, method: "POST", headers: { "x-ul-replay-enabled": `${!!((v = S.replay) != null && v.isReplayRecording())}` }, shouldDropOnRateLimit: !0 });
|
|
852
|
+
} }), !p) {
|
|
853
|
+
const f = d.alwaysOnReplay ? { userAgent: window.navigator.userAgent, surveyId: d.alwaysOnReplay.surveyId, responseGroupUuid: d.alwaysOnReplay.responseGroupUuid, sdkVersion: "2.34.2", maxDurationSeconds: d.alwaysOnReplay.maxDurationSeconds } : void 0;
|
|
854
|
+
await ((u = S.replay) == null ? void 0 : u.initializeReplay({ maxReplayDurationSeconds: d.maxReplayDurationSeconds, maxInflightRequests: window.UserLeap.maxInflightReplayRequests ?? 2, replaySettings: d.replaySettings, apiUrl: window.UserLeap._API_URL, alwaysOnConfig: f })), Oe = d.replaySettings;
|
|
855
|
+
}
|
|
856
|
+
Zt(d), await Xt(d), window.UserLeap._queue.unpause(), (E = window.SprigLoggerCallback) == null || E.call(window, "SdkReady"), y.emit(w.SDKReady, { mobileMetricsReportingEnabled: !!d.mobileMetricsReportingEnabled, metricsReportingInterval: d.metricsReportingIntervalSeconds || 0, metricsThresholds: d.metricThresholds || [], maxMobileReplayDurationSeconds: d.maxMobileReplayDurationSeconds, mobileReplaySettings: d.mobileReplaySettings }), y.emit(w.VisitorIDUpdated, { visitorId: window.UserLeap.visitorId }), y.on(w.VisitorIDUpdated, () => {
|
|
857
|
+
for (const f in we) delete we[f];
|
|
856
858
|
});
|
|
857
859
|
}
|
|
858
860
|
window.UserLeap.UPDATES = re, window.UserLeap("setPreviewKey", t), document.readyState === "complete" ? n() : window.attachEvent ? window.attachEvent("onload", n) : window.addEventListener("load", () => {
|