@usermaven/sdk-js 1.5.8 → 1.5.9-rc.105
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/types.d.ts +37 -0
- package/dist/extensions/scroll-depth.d.ts +9 -3
- package/dist/lib.js +2 -2
- package/dist/usermaven.cjs.js +2 -2
- package/dist/usermaven.es.js +347 -289
- package/package.json +1 -1
package/dist/usermaven.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
class
|
|
1
|
+
var k = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(k || {});
|
|
2
|
+
class ie {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.level = e;
|
|
5
5
|
}
|
|
@@ -16,11 +16,11 @@ class G {
|
|
|
16
16
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return new
|
|
19
|
+
function f(n = 0) {
|
|
20
|
+
return new ie(n);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
logLevel:
|
|
22
|
+
const X = {
|
|
23
|
+
logLevel: k.ERROR,
|
|
24
24
|
useBeaconApi: !1,
|
|
25
25
|
forceUseFetch: !1,
|
|
26
26
|
trackingHost: "t.usermaven.com",
|
|
@@ -45,15 +45,15 @@ const q = {
|
|
|
45
45
|
maskAllText: !1,
|
|
46
46
|
maskAllElementAttributes: !1
|
|
47
47
|
};
|
|
48
|
-
class
|
|
48
|
+
class ne {
|
|
49
49
|
constructor(e) {
|
|
50
50
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
51
51
|
}
|
|
52
52
|
set(e, t, i = 365, s = !0, r = !1) {
|
|
53
53
|
const o = /* @__PURE__ */ new Date();
|
|
54
54
|
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
55
|
-
const
|
|
56
|
-
document.cookie = `${e}=${t};${
|
|
55
|
+
const a = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", c = r ? "; HttpOnly" : "";
|
|
56
|
+
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
|
|
57
57
|
}
|
|
58
58
|
get(e) {
|
|
59
59
|
const t = e + "=", i = document.cookie.split(";");
|
|
@@ -94,76 +94,76 @@ class j {
|
|
|
94
94
|
return i ? i[0] : "";
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
const
|
|
98
|
-
function
|
|
97
|
+
const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, C = oe.forEach, U = {};
|
|
98
|
+
function ae(n, e, t) {
|
|
99
99
|
if (Array.isArray(n)) {
|
|
100
|
-
if (
|
|
100
|
+
if (C && n.forEach === C)
|
|
101
101
|
n.forEach(e, t);
|
|
102
102
|
else if ("length" in n && n.length === +n.length) {
|
|
103
103
|
for (let i = 0, s = n.length; i < s; i++)
|
|
104
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
104
|
+
if (i in n && e.call(t, n[i], i) === U)
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const D = function(n) {
|
|
110
110
|
return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
111
|
-
},
|
|
111
|
+
}, ce = function(n) {
|
|
112
112
|
for (const e in n)
|
|
113
113
|
typeof n[e] == "function" && (n[e] = n[e].bind(n));
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function w(n, e, t) {
|
|
116
116
|
if (n != null) {
|
|
117
|
-
if (
|
|
117
|
+
if (C && Array.isArray(n) && n.forEach === C)
|
|
118
118
|
n.forEach(e, t);
|
|
119
119
|
else if ("length" in n && n.length === +n.length) {
|
|
120
120
|
for (let i = 0, s = n.length; i < s; i++)
|
|
121
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
121
|
+
if (i in n && e.call(t, n[i], i) === U)
|
|
122
122
|
return;
|
|
123
123
|
} else
|
|
124
124
|
for (const i in n)
|
|
125
|
-
if (
|
|
125
|
+
if (re.call(n, i) && e.call(t, n[i], i) === U)
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
return
|
|
129
|
+
const le = function(n, ...e) {
|
|
130
|
+
return ae(e, function(t) {
|
|
131
131
|
for (const i in t)
|
|
132
132
|
t[i] !== void 0 && (n[i] = t[i]);
|
|
133
133
|
}), n;
|
|
134
134
|
};
|
|
135
|
-
function
|
|
135
|
+
function $(n, e) {
|
|
136
136
|
return n.indexOf(e) !== -1;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const ue = function(n) {
|
|
139
139
|
try {
|
|
140
140
|
return /^\s*\bfunction\b/.test(n);
|
|
141
141
|
} catch {
|
|
142
142
|
return !1;
|
|
143
143
|
}
|
|
144
|
-
},
|
|
144
|
+
}, he = function(n) {
|
|
145
145
|
return n === void 0;
|
|
146
|
-
},
|
|
147
|
-
const n = function(i, s, r, o,
|
|
146
|
+
}, E = function() {
|
|
147
|
+
const n = function(i, s, r, o, a) {
|
|
148
148
|
if (!i) {
|
|
149
|
-
|
|
149
|
+
f().error("No valid element provided to register_event");
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
if (i.addEventListener && !o)
|
|
153
|
-
i.addEventListener(s, r, !!
|
|
153
|
+
i.addEventListener(s, r, !!a);
|
|
154
154
|
else {
|
|
155
|
-
const l = "on" + s,
|
|
156
|
-
i[l] = e(i, r,
|
|
155
|
+
const l = "on" + s, c = i[l];
|
|
156
|
+
i[l] = e(i, r, c);
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
159
|
function e(i, s, r) {
|
|
160
160
|
return function(o) {
|
|
161
161
|
if (o = o || t(window.event), !o)
|
|
162
162
|
return;
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
return (l === !1 ||
|
|
163
|
+
let a = !0, l;
|
|
164
|
+
ue(r) && (l = r(o));
|
|
165
|
+
const c = s.call(i, o);
|
|
166
|
+
return (l === !1 || c === !1) && (a = !1), a;
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
function t(i) {
|
|
@@ -174,47 +174,47 @@ const oe = function(n) {
|
|
|
174
174
|
}, t.stopPropagation = function() {
|
|
175
175
|
this.cancelBubble = !0;
|
|
176
176
|
}, n;
|
|
177
|
-
}(),
|
|
177
|
+
}(), de = function(n) {
|
|
178
178
|
return function(...e) {
|
|
179
179
|
try {
|
|
180
180
|
return n.apply(this, e);
|
|
181
181
|
} catch (t) {
|
|
182
|
-
|
|
182
|
+
f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
},
|
|
185
|
+
}, Z = function(n) {
|
|
186
186
|
for (const e in n)
|
|
187
|
-
typeof n[e] == "function" && (n[e] =
|
|
187
|
+
typeof n[e] == "function" && (n[e] = de(n[e]));
|
|
188
188
|
};
|
|
189
|
-
function
|
|
189
|
+
function q(n) {
|
|
190
190
|
for (let e in n)
|
|
191
191
|
(n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
|
|
192
192
|
return n;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function h() {
|
|
195
195
|
try {
|
|
196
196
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
197
197
|
} catch {
|
|
198
|
-
return
|
|
198
|
+
return f().warn("window is not available"), !1;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function v(n = 5) {
|
|
202
202
|
const e = new Uint8Array(n);
|
|
203
203
|
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function fe(n) {
|
|
206
206
|
return n.replace(
|
|
207
207
|
/([-_][a-z])/g,
|
|
208
208
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function
|
|
212
|
-
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(
|
|
213
|
-
const i =
|
|
214
|
-
return e[i] =
|
|
211
|
+
function F(n) {
|
|
212
|
+
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(F) : Object.keys(n).reduce((e, t) => {
|
|
213
|
+
const i = fe(t);
|
|
214
|
+
return e[i] = F(n[t]), e;
|
|
215
215
|
}, {});
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function x(n) {
|
|
218
218
|
switch (typeof n.className) {
|
|
219
219
|
case "string":
|
|
220
220
|
return n.className;
|
|
@@ -224,47 +224,47 @@ function A(n) {
|
|
|
224
224
|
return "";
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function V(n) {
|
|
228
228
|
let e = "";
|
|
229
|
-
return
|
|
230
|
-
|
|
231
|
-
}),
|
|
229
|
+
return M(n) && !j(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
|
|
230
|
+
G(t) && t.textContent && (e += D(t.textContent).split(/(\s+)/).filter(T).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
231
|
+
}), D(e);
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function Y(n) {
|
|
234
234
|
return !!n && n.nodeType === 1;
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function y(n, e) {
|
|
237
237
|
return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function G(n) {
|
|
240
240
|
return !!n && n.nodeType === 3;
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function z(n) {
|
|
243
243
|
return !!n && n.nodeType === 11;
|
|
244
244
|
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
247
|
-
if (!n ||
|
|
245
|
+
const A = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
246
|
+
function ge(n, e) {
|
|
247
|
+
if (!n || y(n, "html") || !Y(n))
|
|
248
248
|
return !1;
|
|
249
249
|
let t = n;
|
|
250
|
-
for (; t && !
|
|
250
|
+
for (; t && !y(t, "body"); ) {
|
|
251
251
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
252
252
|
return !1;
|
|
253
|
-
t.parentNode &&
|
|
253
|
+
t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
254
254
|
}
|
|
255
255
|
let i = !1;
|
|
256
|
-
for (t = n; t && !
|
|
257
|
-
if (t.parentNode &&
|
|
258
|
-
t = t.parentNode.host, t &&
|
|
256
|
+
for (t = n; t && !y(t, "body"); ) {
|
|
257
|
+
if (t.parentNode && z(t.parentNode)) {
|
|
258
|
+
t = t.parentNode.host, t && A.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
259
259
|
continue;
|
|
260
260
|
}
|
|
261
261
|
const o = t.parentNode;
|
|
262
262
|
if (!o) break;
|
|
263
|
-
if (
|
|
263
|
+
if (A.indexOf(o.tagName.toLowerCase()) > -1)
|
|
264
264
|
i = !0;
|
|
265
265
|
else {
|
|
266
|
-
const
|
|
267
|
-
|
|
266
|
+
const a = window.getComputedStyle(o);
|
|
267
|
+
a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
|
|
268
268
|
}
|
|
269
269
|
t = o;
|
|
270
270
|
}
|
|
@@ -283,16 +283,16 @@ function ue(n, e) {
|
|
|
283
283
|
case "textarea":
|
|
284
284
|
return e.type === "change" || e.type === "click";
|
|
285
285
|
default:
|
|
286
|
-
return i ? e.type === "click" : e.type === "click" && (
|
|
286
|
+
return i ? e.type === "click" : e.type === "click" && (A.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
for (let i = n; i.parentNode && !
|
|
291
|
-
const s =
|
|
292
|
-
if (
|
|
289
|
+
function M(n) {
|
|
290
|
+
for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
|
|
291
|
+
const s = x(i).split(" ");
|
|
292
|
+
if ($(s, "ph-sensitive") || $(s, "ph-no-capture"))
|
|
293
293
|
return !1;
|
|
294
294
|
}
|
|
295
|
-
if (
|
|
295
|
+
if ($(x(n).split(" "), "ph-include"))
|
|
296
296
|
return !0;
|
|
297
297
|
const e = n.type || "";
|
|
298
298
|
if (typeof e == "string")
|
|
@@ -305,23 +305,23 @@ function L(n) {
|
|
|
305
305
|
const t = n.name || n.id || "";
|
|
306
306
|
return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
|
|
307
307
|
}
|
|
308
|
-
function
|
|
308
|
+
function j(n) {
|
|
309
309
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
310
|
-
return !!(
|
|
310
|
+
return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
return !(n === null ||
|
|
312
|
+
function T(n) {
|
|
313
|
+
return !(n === null || he(n) || typeof n == "string" && (n = D(n), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function pe(n) {
|
|
316
316
|
return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
return
|
|
318
|
+
function R() {
|
|
319
|
+
return v(10);
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function me(n) {
|
|
322
322
|
return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(n).toLowerCase());
|
|
323
323
|
}
|
|
324
|
-
function
|
|
324
|
+
function ye(n, e) {
|
|
325
325
|
let t;
|
|
326
326
|
return function(...i) {
|
|
327
327
|
const s = () => {
|
|
@@ -330,7 +330,7 @@ function fe(n, e) {
|
|
|
330
330
|
clearTimeout(t), t = setTimeout(s, e);
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
|
-
function
|
|
333
|
+
function we(n) {
|
|
334
334
|
const e = {}, t = n.replace(/^\?/, "").split("&");
|
|
335
335
|
for (let i = 0; i < t.length; i++) {
|
|
336
336
|
const s = t[i].split("=");
|
|
@@ -338,50 +338,72 @@ function ge(n) {
|
|
|
338
338
|
}
|
|
339
339
|
return e;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function J(n) {
|
|
342
342
|
return typeof n == "string" || n instanceof String;
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function S(n) {
|
|
345
345
|
return n !== null && typeof n == "object" && n.constructor === Object;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function ke(n) {
|
|
348
348
|
if (n === null)
|
|
349
|
-
return
|
|
350
|
-
const e = n.toUpperCase(), t =
|
|
351
|
-
return t || t === 0 ? t :
|
|
349
|
+
return k.ERROR;
|
|
350
|
+
const e = n.toUpperCase(), t = k[e];
|
|
351
|
+
return t || t === 0 ? t : k.ERROR;
|
|
352
352
|
}
|
|
353
|
-
const
|
|
353
|
+
const ve = () => {
|
|
354
354
|
let n = "false";
|
|
355
355
|
return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
|
|
356
356
|
};
|
|
357
|
-
class
|
|
357
|
+
class _e {
|
|
358
358
|
constructor(e) {
|
|
359
|
-
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.
|
|
359
|
+
this.maxScrollDepth = 0, this.milestones = /* @__PURE__ */ new Set([25, 50, 75, 90]), this.reachedMilestones = /* @__PURE__ */ new Set(), this.hasSentFinalEvent = !1, this.scrollTimeout = null, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = this.createDebouncedScroll(250), this.initializeEventListeners();
|
|
360
|
+
}
|
|
361
|
+
createDebouncedScroll(e) {
|
|
362
|
+
ye(this.handleScroll.bind(this), e);
|
|
363
|
+
const t = () => {
|
|
364
|
+
this.scrollTimeout && clearTimeout(this.scrollTimeout), this.scrollTimeout = setTimeout(() => {
|
|
365
|
+
this.handleScroll(), this.scrollTimeout = null;
|
|
366
|
+
}, e);
|
|
367
|
+
};
|
|
368
|
+
return t.cancel = () => {
|
|
369
|
+
this.scrollTimeout && (clearTimeout(this.scrollTimeout), this.scrollTimeout = null);
|
|
370
|
+
}, t;
|
|
360
371
|
}
|
|
361
|
-
|
|
362
|
-
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
372
|
+
initializeEventListeners() {
|
|
373
|
+
window.addEventListener("scroll", this.debouncedHandleScroll, { passive: !0 }), window.addEventListener("pagehide", this.handlePageExit.bind(this)), window.addEventListener("beforeunload", this.handlePageExit.bind(this)), document.addEventListener("visibilitychange", this.handleVisibilityChange.bind(this));
|
|
363
374
|
}
|
|
364
375
|
track() {
|
|
365
376
|
const e = this.getScrollDepth();
|
|
366
|
-
e > this.
|
|
367
|
-
}
|
|
368
|
-
send(e = "$scroll") {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
percent: this.
|
|
377
|
+
e > this.maxScrollDepth && (this.maxScrollDepth = e, this.checkMilestones(e));
|
|
378
|
+
}
|
|
379
|
+
send(e = "$scroll", t) {
|
|
380
|
+
const i = this.getScrollDepth();
|
|
381
|
+
this.maxScrollDepth = Math.max(this.maxScrollDepth, i);
|
|
382
|
+
const s = {
|
|
383
|
+
percent: t ?? this.maxScrollDepth,
|
|
384
|
+
max_percent: this.maxScrollDepth,
|
|
373
385
|
window_height: this.getWindowHeight(),
|
|
374
386
|
document_height: this.getDocumentHeight(),
|
|
375
|
-
scroll_distance: this.getScrollDistance()
|
|
387
|
+
scroll_distance: this.getScrollDistance(),
|
|
388
|
+
is_final: e === "$scroll_exit"
|
|
376
389
|
};
|
|
377
|
-
this.client.track(e,
|
|
390
|
+
this.client.track(e, s);
|
|
378
391
|
}
|
|
379
392
|
handleScroll() {
|
|
380
393
|
this.track();
|
|
381
394
|
}
|
|
395
|
+
handlePageExit() {
|
|
396
|
+
this.hasSentFinalEvent || (this.debouncedHandleScroll.cancel && this.debouncedHandleScroll.cancel(), this.track(), this.send("$scroll_exit"), this.hasSentFinalEvent = !0);
|
|
397
|
+
}
|
|
398
|
+
handleVisibilityChange() {
|
|
399
|
+
document.hidden && (this.track(), this.send("$scroll_checkpoint"));
|
|
400
|
+
}
|
|
382
401
|
getScrollDepth() {
|
|
383
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance()
|
|
384
|
-
|
|
402
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance();
|
|
403
|
+
if (t <= e)
|
|
404
|
+
return 100;
|
|
405
|
+
const s = t - e, r = i / s * 100;
|
|
406
|
+
return Math.min(100, Math.max(0, Math.round(r)));
|
|
385
407
|
}
|
|
386
408
|
getWindowHeight() {
|
|
387
409
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -400,14 +422,17 @@ class ye {
|
|
|
400
422
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
401
423
|
}
|
|
402
424
|
checkMilestones(e) {
|
|
403
|
-
this.milestones.
|
|
404
|
-
this.
|
|
425
|
+
this.milestones.forEach((t) => {
|
|
426
|
+
e >= t && !this.reachedMilestones.has(t) && (this.reachedMilestones.add(t), this.send(`$scroll_milestone_${t}`, t));
|
|
405
427
|
});
|
|
406
428
|
}
|
|
429
|
+
destroy() {
|
|
430
|
+
window.removeEventListener("scroll", this.debouncedHandleScroll), window.removeEventListener("pagehide", this.handlePageExit.bind(this)), window.removeEventListener("beforeunload", this.handlePageExit.bind(this)), document.removeEventListener("visibilitychange", this.handleVisibilityChange.bind(this)), this.hasSentFinalEvent || this.handlePageExit();
|
|
431
|
+
}
|
|
407
432
|
}
|
|
408
|
-
const
|
|
409
|
-
constructor(e, t, i =
|
|
410
|
-
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new
|
|
433
|
+
const L = class L {
|
|
434
|
+
constructor(e, t, i = f()) {
|
|
435
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), ce(this), Z(this);
|
|
411
436
|
}
|
|
412
437
|
isBrowserSupported() {
|
|
413
438
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -431,7 +456,7 @@ const T = class T {
|
|
|
431
456
|
const e = (t) => {
|
|
432
457
|
t = t || window.event, this.captureEvent(t);
|
|
433
458
|
};
|
|
434
|
-
|
|
459
|
+
E(document, "submit", e, !1, !0), E(document, "change", e, !1, !0), E(document, "click", e, !1, !0), E(document, "visibilitychange", e, !1, !0), E(document, "scroll", e, !1, !0), E(window, "popstate", e, !1, !0);
|
|
435
460
|
}
|
|
436
461
|
isPageRefresh() {
|
|
437
462
|
if ("PerformanceNavigationTiming" in window) {
|
|
@@ -444,61 +469,61 @@ const T = class T {
|
|
|
444
469
|
captureEvent(e) {
|
|
445
470
|
var i, s;
|
|
446
471
|
let t = this.getEventTarget(e);
|
|
447
|
-
if (
|
|
472
|
+
if (G(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
448
473
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
449
474
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
450
475
|
return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
|
|
451
|
-
if (t &&
|
|
476
|
+
if (t && ge(t, e)) {
|
|
452
477
|
const r = [t];
|
|
453
478
|
let o = t;
|
|
454
|
-
for (; o.parentNode && !
|
|
455
|
-
if (
|
|
479
|
+
for (; o.parentNode && !y(o, "body"); ) {
|
|
480
|
+
if (z(o.parentNode)) {
|
|
456
481
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
457
482
|
continue;
|
|
458
483
|
}
|
|
459
484
|
r.push(o.parentNode), o = o.parentNode;
|
|
460
485
|
}
|
|
461
|
-
const
|
|
462
|
-
let l,
|
|
463
|
-
if (
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
const
|
|
467
|
-
|
|
486
|
+
const a = [];
|
|
487
|
+
let l, c = !1;
|
|
488
|
+
if (w(r, (p) => {
|
|
489
|
+
const _ = M(p);
|
|
490
|
+
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && T(l) && l);
|
|
491
|
+
const u = x(p).split(" ");
|
|
492
|
+
$(u, "ph-no-capture") && (c = !0), a.push(
|
|
468
493
|
this.getPropertiesFromElement(
|
|
469
|
-
|
|
494
|
+
p,
|
|
470
495
|
this.options.maskAllElementAttributes ?? !1,
|
|
471
496
|
this.options.maskAllText ?? !1
|
|
472
497
|
)
|
|
473
498
|
);
|
|
474
|
-
}), this.options.maskAllText || (
|
|
499
|
+
}), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
|
|
475
500
|
return !1;
|
|
476
|
-
const
|
|
501
|
+
const d = le(
|
|
477
502
|
this.getDefaultProperties(e.type),
|
|
478
503
|
{
|
|
479
|
-
$elements:
|
|
504
|
+
$elements: a
|
|
480
505
|
},
|
|
481
506
|
this.getCustomProperties(r)
|
|
482
507
|
);
|
|
483
|
-
return this.client.track("$autocapture",
|
|
508
|
+
return this.client.track("$autocapture", d), !0;
|
|
484
509
|
}
|
|
485
510
|
}
|
|
486
511
|
getCustomProperties(e) {
|
|
487
512
|
const t = {};
|
|
488
|
-
return
|
|
489
|
-
|
|
513
|
+
return w(this.customProperties, (i) => {
|
|
514
|
+
w(i.event_selectors, (s) => {
|
|
490
515
|
const r = document.querySelectorAll(s);
|
|
491
|
-
|
|
492
|
-
|
|
516
|
+
w(r, (o) => {
|
|
517
|
+
$(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
493
518
|
});
|
|
494
519
|
});
|
|
495
520
|
}), t;
|
|
496
521
|
}
|
|
497
522
|
extractCustomPropertyValue(e) {
|
|
498
523
|
const t = [];
|
|
499
|
-
return
|
|
524
|
+
return w(document.querySelectorAll(e.css_selector), function(i) {
|
|
500
525
|
let s;
|
|
501
|
-
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent),
|
|
526
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), T(s) && t.push(s);
|
|
502
527
|
}), t.join(", ");
|
|
503
528
|
}
|
|
504
529
|
getEventTarget(e) {
|
|
@@ -509,17 +534,17 @@ const T = class T {
|
|
|
509
534
|
const s = e.tagName.toLowerCase(), r = {
|
|
510
535
|
tag_name: s
|
|
511
536
|
};
|
|
512
|
-
|
|
513
|
-
const o =
|
|
514
|
-
o.length > 0 && (r.classes = o.split(" ").filter(function(
|
|
515
|
-
return
|
|
516
|
-
})),
|
|
517
|
-
|
|
537
|
+
A.indexOf(s) > -1 && !i && (r.$el_text = V(e));
|
|
538
|
+
const o = x(e);
|
|
539
|
+
o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
|
|
540
|
+
return d !== "";
|
|
541
|
+
})), w(e.attributes, function(d) {
|
|
542
|
+
j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && T(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
|
|
518
543
|
});
|
|
519
|
-
let
|
|
520
|
-
for (;
|
|
521
|
-
|
|
522
|
-
return r.nth_child =
|
|
544
|
+
let a = 1, l = 1, c = e;
|
|
545
|
+
for (; c = this.previousElementSibling(c); )
|
|
546
|
+
a++, c.tagName === e.tagName && l++;
|
|
547
|
+
return r.nth_child = a, r.nth_of_type = l, r;
|
|
523
548
|
}
|
|
524
549
|
previousElementSibling(e) {
|
|
525
550
|
if (e.previousElementSibling)
|
|
@@ -528,7 +553,7 @@ const T = class T {
|
|
|
528
553
|
let t = e;
|
|
529
554
|
do
|
|
530
555
|
t = t.previousSibling;
|
|
531
|
-
while (t && !
|
|
556
|
+
while (t && !Y(t));
|
|
532
557
|
return t;
|
|
533
558
|
}
|
|
534
559
|
}
|
|
@@ -550,9 +575,9 @@ const T = class T {
|
|
|
550
575
|
return s % t < i;
|
|
551
576
|
}
|
|
552
577
|
};
|
|
553
|
-
|
|
554
|
-
let
|
|
555
|
-
class
|
|
578
|
+
L.FORCE_CAPTURE_ATTR = "data-um-force-capture", L.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
579
|
+
let H = L;
|
|
580
|
+
class be {
|
|
556
581
|
constructor(e) {
|
|
557
582
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
558
583
|
}
|
|
@@ -581,8 +606,8 @@ class we {
|
|
|
581
606
|
}));
|
|
582
607
|
}
|
|
583
608
|
}
|
|
584
|
-
class
|
|
585
|
-
constructor(e, t, i =
|
|
609
|
+
class Ee {
|
|
610
|
+
constructor(e, t, i = f()) {
|
|
586
611
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
587
612
|
}
|
|
588
613
|
async send(e) {
|
|
@@ -593,14 +618,14 @@ class ke {
|
|
|
593
618
|
throw new Error("Failed to queue events via Beacon API");
|
|
594
619
|
}
|
|
595
620
|
constructUrl(e) {
|
|
596
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
597
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
621
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
622
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
598
623
|
}
|
|
599
624
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
600
625
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
601
626
|
}
|
|
602
|
-
class
|
|
603
|
-
constructor(e, t, i =
|
|
627
|
+
class Q {
|
|
628
|
+
constructor(e, t, i = f()) {
|
|
604
629
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
605
630
|
}
|
|
606
631
|
async send(e) {
|
|
@@ -617,8 +642,8 @@ class z {
|
|
|
617
642
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
618
643
|
}
|
|
619
644
|
constructUrl(e) {
|
|
620
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
621
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
645
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
646
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
622
647
|
}
|
|
623
648
|
getCustomHeaders() {
|
|
624
649
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -627,17 +652,17 @@ class z {
|
|
|
627
652
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
628
653
|
}
|
|
629
654
|
}
|
|
630
|
-
class
|
|
631
|
-
constructor(e, t, i =
|
|
655
|
+
class Pe {
|
|
656
|
+
constructor(e, t, i = f()) {
|
|
632
657
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
633
658
|
}
|
|
634
659
|
send(e) {
|
|
635
660
|
return new Promise((t, i) => {
|
|
636
661
|
const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
637
662
|
s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
|
|
638
|
-
const
|
|
639
|
-
Object.keys(
|
|
640
|
-
s.setRequestHeader(l,
|
|
663
|
+
const a = this.getCustomHeaders();
|
|
664
|
+
Object.keys(a).forEach((l) => {
|
|
665
|
+
s.setRequestHeader(l, a[l]);
|
|
641
666
|
}), s.onload = () => {
|
|
642
667
|
s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
|
|
643
668
|
}, s.onerror = () => {
|
|
@@ -646,8 +671,8 @@ class ve {
|
|
|
646
671
|
});
|
|
647
672
|
}
|
|
648
673
|
constructUrl(e) {
|
|
649
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
650
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
674
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
675
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
651
676
|
}
|
|
652
677
|
getCustomHeaders() {
|
|
653
678
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -656,9 +681,9 @@ class ve {
|
|
|
656
681
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
657
682
|
}
|
|
658
683
|
}
|
|
659
|
-
class
|
|
684
|
+
class ee {
|
|
660
685
|
constructor(e, t) {
|
|
661
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t ||
|
|
686
|
+
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
|
|
662
687
|
}
|
|
663
688
|
set(e, t) {
|
|
664
689
|
this.storage[e] = t, this.save();
|
|
@@ -673,7 +698,7 @@ class K {
|
|
|
673
698
|
this.storage = {}, this.save();
|
|
674
699
|
}
|
|
675
700
|
save() {
|
|
676
|
-
if (!
|
|
701
|
+
if (!h()) {
|
|
677
702
|
this.logger.warn("localStorage is not available in this environment");
|
|
678
703
|
return;
|
|
679
704
|
}
|
|
@@ -684,7 +709,7 @@ class K {
|
|
|
684
709
|
}
|
|
685
710
|
}
|
|
686
711
|
load() {
|
|
687
|
-
if (!
|
|
712
|
+
if (!h()) {
|
|
688
713
|
this.logger.warn("localStorage is not available in this environment");
|
|
689
714
|
return;
|
|
690
715
|
}
|
|
@@ -696,7 +721,7 @@ class K {
|
|
|
696
721
|
}
|
|
697
722
|
}
|
|
698
723
|
}
|
|
699
|
-
class
|
|
724
|
+
class Se {
|
|
700
725
|
constructor() {
|
|
701
726
|
this.storage = {};
|
|
702
727
|
}
|
|
@@ -715,56 +740,56 @@ class _e {
|
|
|
715
740
|
this.storage = {};
|
|
716
741
|
}
|
|
717
742
|
}
|
|
718
|
-
class
|
|
743
|
+
class W {
|
|
719
744
|
// Default to true for server-side
|
|
720
|
-
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o =
|
|
721
|
-
this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new
|
|
745
|
+
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
|
|
746
|
+
this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new ee(`offline_queue_${a}`), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
722
747
|
}
|
|
723
748
|
add(e) {
|
|
724
749
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
725
|
-
this.queue.push(t),
|
|
750
|
+
this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
|
|
726
751
|
}
|
|
727
752
|
initNetworkListeners() {
|
|
728
|
-
|
|
753
|
+
h() && (window.addEventListener("online", () => {
|
|
729
754
|
this.isOnline = !0, this.processBatch();
|
|
730
755
|
}), window.addEventListener("offline", () => {
|
|
731
756
|
this.isOnline = !1;
|
|
732
757
|
}));
|
|
733
758
|
}
|
|
734
759
|
scheduleBatch() {
|
|
735
|
-
|
|
760
|
+
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
|
|
736
761
|
}
|
|
737
762
|
async processBatch() {
|
|
738
|
-
if ((!
|
|
763
|
+
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
739
764
|
this.processing = !0;
|
|
740
765
|
const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
|
|
741
766
|
try {
|
|
742
|
-
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`),
|
|
767
|
+
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
|
|
743
768
|
} catch (i) {
|
|
744
769
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
745
770
|
}
|
|
746
771
|
this.processing = !1;
|
|
747
772
|
}
|
|
748
|
-
|
|
773
|
+
h() && this.scheduleBatch();
|
|
749
774
|
}
|
|
750
775
|
async handleBatchFailure(e) {
|
|
751
776
|
for (const t of e)
|
|
752
777
|
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error("Max retries reached, discarding payload", t.payload);
|
|
753
|
-
|
|
778
|
+
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
754
779
|
}
|
|
755
780
|
loadQueueFromStorage() {
|
|
756
|
-
if (
|
|
781
|
+
if (h()) {
|
|
757
782
|
const e = this.persistence.get("queue");
|
|
758
783
|
e && (this.queue = JSON.parse(e));
|
|
759
784
|
}
|
|
760
785
|
}
|
|
761
786
|
saveQueueToStorage() {
|
|
762
|
-
|
|
787
|
+
h() && this.persistence.set("queue", JSON.stringify(this.queue));
|
|
763
788
|
}
|
|
764
789
|
}
|
|
765
|
-
class
|
|
790
|
+
class $e {
|
|
766
791
|
constructor(e) {
|
|
767
|
-
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(),
|
|
792
|
+
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
|
|
768
793
|
}
|
|
769
794
|
initializeEventListener() {
|
|
770
795
|
document.addEventListener("click", this.handleClick.bind(this));
|
|
@@ -784,8 +809,8 @@ class be {
|
|
|
784
809
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
785
810
|
this.clicks.every((r, o) => {
|
|
786
811
|
if (o === 0) return !0;
|
|
787
|
-
const
|
|
788
|
-
return Math.sqrt(Math.pow(r.x -
|
|
812
|
+
const a = this.clicks[o - 1];
|
|
813
|
+
return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
|
|
789
814
|
}) && this.sendRageClickEvent(i);
|
|
790
815
|
}
|
|
791
816
|
sendRageClickEvent(e) {
|
|
@@ -796,8 +821,8 @@ class be {
|
|
|
796
821
|
}), this.clicks = [];
|
|
797
822
|
}
|
|
798
823
|
}
|
|
799
|
-
class
|
|
800
|
-
constructor(e, t, i =
|
|
824
|
+
class Ae {
|
|
825
|
+
constructor(e, t, i = f()) {
|
|
801
826
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
802
827
|
}
|
|
803
828
|
async send(e) {
|
|
@@ -812,16 +837,16 @@ class Ee {
|
|
|
812
837
|
}
|
|
813
838
|
};
|
|
814
839
|
return new Promise((r, o) => {
|
|
815
|
-
const
|
|
816
|
-
l.on("data", (
|
|
840
|
+
const a = (void 0)(s, (l) => {
|
|
841
|
+
l.on("data", (c) => {
|
|
817
842
|
}), l.on("end", () => {
|
|
818
|
-
const
|
|
819
|
-
|
|
843
|
+
const c = l.statusCode || 0;
|
|
844
|
+
c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
|
|
820
845
|
});
|
|
821
846
|
});
|
|
822
|
-
|
|
847
|
+
a.on("error", (l) => {
|
|
823
848
|
o(l);
|
|
824
|
-
}),
|
|
849
|
+
}), a.write(JSON.stringify(e)), a.end();
|
|
825
850
|
});
|
|
826
851
|
}
|
|
827
852
|
constructUrl(e) {
|
|
@@ -832,7 +857,7 @@ class Ee {
|
|
|
832
857
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
833
858
|
}
|
|
834
859
|
}
|
|
835
|
-
class
|
|
860
|
+
class P {
|
|
836
861
|
constructor(e, t = "all", i = {}) {
|
|
837
862
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
838
863
|
}
|
|
@@ -847,18 +872,18 @@ class w {
|
|
|
847
872
|
}
|
|
848
873
|
handleFormSubmit(e) {
|
|
849
874
|
const t = e.target, i = this._getFormDetails(t);
|
|
850
|
-
this.instance.track("$form",
|
|
875
|
+
this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
851
876
|
}
|
|
852
877
|
trackFieldChanges(e) {
|
|
853
878
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
854
879
|
i.addEventListener("change", (s) => {
|
|
855
880
|
const r = this._getFieldProps(s.target, 0);
|
|
856
|
-
this.instance.track("$form_field_change",
|
|
881
|
+
this.instance.track("$form_field_change", q(r));
|
|
857
882
|
});
|
|
858
883
|
});
|
|
859
884
|
}
|
|
860
885
|
static getInstance(e, t = "all", i = {}) {
|
|
861
|
-
return
|
|
886
|
+
return P.instance || (P.instance = new P(e, t, i)), P.instance;
|
|
862
887
|
}
|
|
863
888
|
_getFormDetails(e) {
|
|
864
889
|
const t = {
|
|
@@ -870,8 +895,8 @@ class w {
|
|
|
870
895
|
form_attributes: this._getElementAttributes(e)
|
|
871
896
|
}, i = e.querySelectorAll("input, select, textarea");
|
|
872
897
|
return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
|
|
873
|
-
const
|
|
874
|
-
Object.assign(t,
|
|
898
|
+
const a = this._getFieldProps(r, o);
|
|
899
|
+
Object.assign(t, a);
|
|
875
900
|
}), t;
|
|
876
901
|
}
|
|
877
902
|
_getFieldProps(e, t) {
|
|
@@ -946,9 +971,9 @@ class w {
|
|
|
946
971
|
return e.slice(t, i + 1);
|
|
947
972
|
}
|
|
948
973
|
}
|
|
949
|
-
class
|
|
974
|
+
class N {
|
|
950
975
|
constructor(e) {
|
|
951
|
-
this.config = this.mergeConfig(e,
|
|
976
|
+
this.config = this.mergeConfig(e, X), this.logger = f(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new W(
|
|
952
977
|
this.transport,
|
|
953
978
|
this.config.maxSendAttempts || 3,
|
|
954
979
|
this.config.minSendTimeout || 1e3,
|
|
@@ -957,16 +982,16 @@ class S {
|
|
|
957
982
|
// Reduced interval to .2 second
|
|
958
983
|
this.logger,
|
|
959
984
|
this.namespace
|
|
960
|
-
),
|
|
985
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
|
|
961
986
|
}
|
|
962
987
|
initializeBrowserFeatures() {
|
|
963
|
-
if (this.cookieManager = new
|
|
988
|
+
if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && H.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new H(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
964
989
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
965
|
-
this.formTracking =
|
|
990
|
+
this.formTracking = P.getInstance(this, e || "none", {
|
|
966
991
|
trackFieldChanges: !1
|
|
967
992
|
});
|
|
968
993
|
}
|
|
969
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
994
|
+
this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new $e(this)), this.setupPageLeaveTracking();
|
|
970
995
|
}
|
|
971
996
|
/**
|
|
972
997
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -977,11 +1002,11 @@ class S {
|
|
|
977
1002
|
const i = JSON.parse(JSON.stringify(e));
|
|
978
1003
|
let s = { ...t, ...i };
|
|
979
1004
|
return Object.keys(t).forEach((r) => {
|
|
980
|
-
|
|
1005
|
+
S(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
|
|
981
1006
|
}), s;
|
|
982
1007
|
}
|
|
983
1008
|
init(e) {
|
|
984
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
1009
|
+
this.config = { ...this.config, ...e }, this.logger = f(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new W(
|
|
985
1010
|
this.transport,
|
|
986
1011
|
this.config.maxSendAttempts || 3,
|
|
987
1012
|
this.config.minSendTimeout || 1e3,
|
|
@@ -990,21 +1015,21 @@ class S {
|
|
|
990
1015
|
// Reduced interval to .25 second
|
|
991
1016
|
this.logger,
|
|
992
1017
|
this.namespace
|
|
993
|
-
),
|
|
1018
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
|
|
994
1019
|
}
|
|
995
1020
|
manageCrossDomainLinking() {
|
|
996
1021
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
997
1022
|
return;
|
|
998
1023
|
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
999
1024
|
document.addEventListener("click", (i) => {
|
|
1000
|
-
var
|
|
1025
|
+
var a;
|
|
1001
1026
|
const s = this.findClosestLink(i.target);
|
|
1002
1027
|
if (!s) return;
|
|
1003
1028
|
const r = s.getAttribute("href");
|
|
1004
1029
|
if (!r || !r.startsWith("http")) return;
|
|
1005
1030
|
const o = new URL(r);
|
|
1006
1031
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1007
|
-
const l = (
|
|
1032
|
+
const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
|
|
1008
1033
|
l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
|
|
1009
1034
|
}
|
|
1010
1035
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
@@ -1016,47 +1041,47 @@ class S {
|
|
|
1016
1041
|
}
|
|
1017
1042
|
initializeTransport(e) {
|
|
1018
1043
|
const t = "https://events.usermaven.com";
|
|
1019
|
-
if (!
|
|
1020
|
-
return new
|
|
1044
|
+
if (!h())
|
|
1045
|
+
return new Ae(e.trackingHost || t, e);
|
|
1021
1046
|
const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1022
1047
|
if (e.useBeaconApi && r)
|
|
1023
|
-
return new
|
|
1048
|
+
return new Ee(e.trackingHost || t, e, this.logger);
|
|
1024
1049
|
if (e.forceUseFetch && s)
|
|
1025
|
-
return new
|
|
1050
|
+
return new Q(e.trackingHost || t, e, this.logger);
|
|
1026
1051
|
if (i)
|
|
1027
|
-
return new
|
|
1052
|
+
return new Pe(e.trackingHost || t, e, this.logger);
|
|
1028
1053
|
if (s)
|
|
1029
|
-
return new
|
|
1054
|
+
return new Q(e.trackingHost || t, e, this.logger);
|
|
1030
1055
|
throw new Error("No suitable transport method available");
|
|
1031
1056
|
}
|
|
1032
1057
|
initializePersistence() {
|
|
1033
|
-
return this.config.disableEventPersistence || !
|
|
1058
|
+
return this.config.disableEventPersistence || !h() ? new Se() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1034
1059
|
}
|
|
1035
1060
|
getOrCreateAnonymousId() {
|
|
1036
1061
|
var i, s;
|
|
1037
|
-
if (!
|
|
1038
|
-
return
|
|
1062
|
+
if (!h())
|
|
1063
|
+
return R();
|
|
1039
1064
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1040
1065
|
return "";
|
|
1041
1066
|
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1042
1067
|
let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
|
|
1043
1068
|
if (!t) {
|
|
1044
1069
|
if (this.config.crossDomainLinking) {
|
|
1045
|
-
const
|
|
1046
|
-
t =
|
|
1070
|
+
const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
|
|
1071
|
+
t = a || d || R();
|
|
1047
1072
|
}
|
|
1048
|
-
t || (t =
|
|
1073
|
+
t || (t = R());
|
|
1049
1074
|
const r = 365 * 10;
|
|
1050
1075
|
(s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
|
|
1051
1076
|
}
|
|
1052
1077
|
return t;
|
|
1053
1078
|
}
|
|
1054
1079
|
async id(e, t = !1) {
|
|
1055
|
-
if (!
|
|
1080
|
+
if (!S(e))
|
|
1056
1081
|
throw new Error("User data must be an object");
|
|
1057
|
-
if (e.email && !
|
|
1082
|
+
if (e.email && !me(e.email))
|
|
1058
1083
|
throw new Error("Invalid email provided");
|
|
1059
|
-
if (!e.id || !
|
|
1084
|
+
if (!e.id || !J(e.id))
|
|
1060
1085
|
throw new Error("User ID must be a string");
|
|
1061
1086
|
const i = e.id;
|
|
1062
1087
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
@@ -1072,11 +1097,11 @@ class S {
|
|
|
1072
1097
|
this.trackInternal(e, t, i);
|
|
1073
1098
|
}
|
|
1074
1099
|
trackInternal(e, t, i = !1) {
|
|
1075
|
-
if (
|
|
1100
|
+
if (ve()) {
|
|
1076
1101
|
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1077
1102
|
return;
|
|
1078
1103
|
}
|
|
1079
|
-
if (!
|
|
1104
|
+
if (!J(e))
|
|
1080
1105
|
throw new Error("Event name must be a string");
|
|
1081
1106
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1082
1107
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
@@ -1092,21 +1117,21 @@ class S {
|
|
|
1092
1117
|
}
|
|
1093
1118
|
}
|
|
1094
1119
|
rawTrack(e) {
|
|
1095
|
-
if (!
|
|
1120
|
+
if (!S(e))
|
|
1096
1121
|
throw new Error("Event payload must be an object");
|
|
1097
1122
|
this.track("raw", e);
|
|
1098
1123
|
}
|
|
1099
1124
|
async group(e, t = !1) {
|
|
1100
|
-
if (!
|
|
1125
|
+
if (!S(e))
|
|
1101
1126
|
throw new Error("Company properties must be an object");
|
|
1102
1127
|
if (!e.id || !e.name || !e.created_at)
|
|
1103
1128
|
throw new Error("Company properties must include id, name, and created_at");
|
|
1104
1129
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1105
1130
|
}
|
|
1106
1131
|
createEventPayload(e, t) {
|
|
1107
|
-
const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {},
|
|
1132
|
+
const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, a = this.persistence.get(`props_${e}`) || {};
|
|
1108
1133
|
let l = t || {};
|
|
1109
|
-
const
|
|
1134
|
+
const c = {
|
|
1110
1135
|
event_id: "",
|
|
1111
1136
|
user: {
|
|
1112
1137
|
anonymous_id: this.anonymousId,
|
|
@@ -1122,15 +1147,15 @@ class S {
|
|
|
1122
1147
|
event_type: e,
|
|
1123
1148
|
namespace: this.namespace,
|
|
1124
1149
|
...o,
|
|
1125
|
-
...
|
|
1150
|
+
...a
|
|
1126
1151
|
};
|
|
1127
1152
|
if (e === "$autocapture") {
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((
|
|
1131
|
-
delete l[
|
|
1132
|
-
}),
|
|
1133
|
-
return
|
|
1153
|
+
const d = this.processAutocaptureAttributes(t || {});
|
|
1154
|
+
c.autocapture_attributes = d;
|
|
1155
|
+
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
|
|
1156
|
+
delete l[d];
|
|
1157
|
+
}), c.event_attributes = l);
|
|
1158
|
+
return h() && (c.referer = document.referrer, c.url = window.location.href, c.page_title = document.title, c.doc_path = window.location.pathname, c.doc_host = window.location.hostname, c.doc_search = window.location.search, c.screen_resolution = `${window.screen.width}x${window.screen.height}`, c.vp_size = `${window.innerWidth}x${window.innerHeight}`, c.user_agent = navigator.userAgent, c.user_language = navigator.language, c.doc_encoding = document.characterSet, c.utm = this.getUtmParams()), c;
|
|
1134
1159
|
}
|
|
1135
1160
|
processAutocaptureAttributes(e) {
|
|
1136
1161
|
let t = {};
|
|
@@ -1145,27 +1170,27 @@ class S {
|
|
|
1145
1170
|
}
|
|
1146
1171
|
getThirdPartyIds() {
|
|
1147
1172
|
const e = {};
|
|
1148
|
-
if (
|
|
1173
|
+
if (h()) {
|
|
1149
1174
|
const t = this.getCookie("_fbp");
|
|
1150
1175
|
t && (e.fbp = t);
|
|
1151
1176
|
}
|
|
1152
1177
|
return e;
|
|
1153
1178
|
}
|
|
1154
1179
|
getUtmParams() {
|
|
1155
|
-
const e = {}, t =
|
|
1180
|
+
const e = {}, t = we(window.location.search);
|
|
1156
1181
|
return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
|
|
1157
1182
|
t[s] && (e[s.replace("utm_", "")] = t[s]);
|
|
1158
1183
|
}), e;
|
|
1159
1184
|
}
|
|
1160
1185
|
pageview() {
|
|
1161
|
-
|
|
1186
|
+
h() ? this.track("pageview", {
|
|
1162
1187
|
url: window.location.href,
|
|
1163
1188
|
referrer: document.referrer,
|
|
1164
1189
|
title: document.title
|
|
1165
1190
|
}, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
|
|
1166
1191
|
}
|
|
1167
1192
|
setupPageLeaveTracking() {
|
|
1168
|
-
if (!
|
|
1193
|
+
if (!h()) return;
|
|
1169
1194
|
let e = !1, t = !1;
|
|
1170
1195
|
const i = () => {
|
|
1171
1196
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
@@ -1200,7 +1225,7 @@ class S {
|
|
|
1200
1225
|
this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
|
|
1201
1226
|
}
|
|
1202
1227
|
set(e, t) {
|
|
1203
|
-
if (!
|
|
1228
|
+
if (!S(e))
|
|
1204
1229
|
throw new Error("Properties must be an object");
|
|
1205
1230
|
const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
|
|
1206
1231
|
if (i) {
|
|
@@ -1233,28 +1258,28 @@ class S {
|
|
|
1233
1258
|
s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
|
|
1234
1259
|
}
|
|
1235
1260
|
}
|
|
1236
|
-
function
|
|
1261
|
+
function te() {
|
|
1237
1262
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1238
1263
|
}
|
|
1239
|
-
function
|
|
1240
|
-
return
|
|
1264
|
+
function Te() {
|
|
1265
|
+
return te() ? window.define : void 0;
|
|
1241
1266
|
}
|
|
1242
|
-
const
|
|
1243
|
-
function
|
|
1244
|
-
const e = JSON.parse(JSON.stringify(n)), t =
|
|
1267
|
+
const Ce = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1268
|
+
function I(n) {
|
|
1269
|
+
const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
|
|
1245
1270
|
if (!i.key)
|
|
1246
1271
|
throw new Error("API key is required!");
|
|
1247
1272
|
if (!i.trackingHost)
|
|
1248
1273
|
throw new Error("Tracking host is required!");
|
|
1249
|
-
const s = i.key || "", r = `${
|
|
1250
|
-
return
|
|
1274
|
+
const s = i.key || "", r = `${Ce}${s}`;
|
|
1275
|
+
return h() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
|
|
1251
1276
|
}
|
|
1252
|
-
function
|
|
1277
|
+
function xe(n) {
|
|
1253
1278
|
var s;
|
|
1254
1279
|
const e = {
|
|
1255
1280
|
key: n.getAttribute("data-key") || void 0,
|
|
1256
1281
|
trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1257
|
-
logLevel:
|
|
1282
|
+
logLevel: ke(n.getAttribute("data-log-level")),
|
|
1258
1283
|
autocapture: n.getAttribute("data-autocapture") === "true",
|
|
1259
1284
|
formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
|
|
1260
1285
|
autoPageview: n.getAttribute("data-auto-pageview") === "true",
|
|
@@ -1281,78 +1306,111 @@ function $e(n) {
|
|
|
1281
1306
|
maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1282
1307
|
};
|
|
1283
1308
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1284
|
-
const t =
|
|
1285
|
-
return
|
|
1309
|
+
const t = I(e), i = e.namespace || "usermaven";
|
|
1310
|
+
return h() && t.pageview(), He(i, t), t;
|
|
1286
1311
|
}
|
|
1287
|
-
function
|
|
1312
|
+
function He(n, e) {
|
|
1288
1313
|
let t = !1;
|
|
1289
1314
|
const i = [], s = [];
|
|
1290
1315
|
function r() {
|
|
1291
1316
|
for (; i.length > 0; ) {
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1317
|
+
const u = i.shift();
|
|
1318
|
+
if (u) {
|
|
1319
|
+
const g = u[u.length - 1];
|
|
1320
|
+
if (g && typeof g.resolve == "function") {
|
|
1321
|
+
const m = u.pop();
|
|
1322
|
+
try {
|
|
1323
|
+
const b = a.apply(null, u);
|
|
1324
|
+
b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
|
|
1325
|
+
} catch (b) {
|
|
1326
|
+
m.reject(b);
|
|
1327
|
+
}
|
|
1328
|
+
} else
|
|
1329
|
+
try {
|
|
1330
|
+
a.apply(null, u);
|
|
1331
|
+
} catch (m) {
|
|
1332
|
+
console.error("Usermaven: Error processing queued command:", m);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1294
1335
|
}
|
|
1295
1336
|
}
|
|
1296
1337
|
function o() {
|
|
1297
|
-
s.forEach((
|
|
1338
|
+
s.forEach((u) => u()), s.length = 0;
|
|
1298
1339
|
}
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
if (
|
|
1302
|
-
typeof
|
|
1340
|
+
function a(...u) {
|
|
1341
|
+
const g = u[0];
|
|
1342
|
+
if (g === "onLoad") {
|
|
1343
|
+
typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
|
|
1303
1344
|
return;
|
|
1304
1345
|
}
|
|
1305
1346
|
if (!t) {
|
|
1306
|
-
i.push(
|
|
1347
|
+
i.push(u);
|
|
1307
1348
|
return;
|
|
1308
1349
|
}
|
|
1309
|
-
if (typeof e[
|
|
1310
|
-
return e[
|
|
1311
|
-
console.error(`Method ${
|
|
1312
|
-
}
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1350
|
+
if (typeof e[g] == "function")
|
|
1351
|
+
return e[g].apply(e, u.slice(1));
|
|
1352
|
+
console.error(`Method ${g} not found on UsermavenClient`);
|
|
1353
|
+
}
|
|
1354
|
+
const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
|
|
1355
|
+
[...l, ...c].forEach((u) => {
|
|
1356
|
+
a[u] = function(...g) {
|
|
1357
|
+
if (!t) {
|
|
1358
|
+
if (l.includes(u))
|
|
1359
|
+
return new Promise((B, m) => {
|
|
1360
|
+
i.push([u, ...g, { resolve: B, reject: m }]);
|
|
1361
|
+
});
|
|
1362
|
+
i.push([u, ...g]);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
if (typeof e[u] == "function")
|
|
1366
|
+
return e[u].apply(e, g);
|
|
1367
|
+
};
|
|
1368
|
+
}), a.getConfig = function() {
|
|
1369
|
+
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1370
|
+
}, window[n] = a;
|
|
1371
|
+
const p = `${n}Q`, _ = window[p] || [];
|
|
1372
|
+
for (window[p] = _, _.push = function(...u) {
|
|
1373
|
+
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1316
1374
|
}, setTimeout(() => {
|
|
1317
1375
|
t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
|
|
1318
|
-
}, 0);
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1376
|
+
}, 0); _.length > 0; ) {
|
|
1377
|
+
const u = _.shift();
|
|
1378
|
+
u && i.push(u);
|
|
1321
1379
|
}
|
|
1322
1380
|
}
|
|
1323
|
-
let
|
|
1324
|
-
if (
|
|
1325
|
-
const n =
|
|
1381
|
+
let K = !1, O = null;
|
|
1382
|
+
if (h()) {
|
|
1383
|
+
const n = Te();
|
|
1326
1384
|
n && n("usermaven", [], function() {
|
|
1327
1385
|
return {
|
|
1328
|
-
usermavenClient:
|
|
1329
|
-
UsermavenClient:
|
|
1330
|
-
LogLevel:
|
|
1386
|
+
usermavenClient: I,
|
|
1387
|
+
UsermavenClient: N,
|
|
1388
|
+
LogLevel: k,
|
|
1331
1389
|
// Expose the script tag client if it exists
|
|
1332
|
-
getScriptTagClient: () =>
|
|
1390
|
+
getScriptTagClient: () => O
|
|
1333
1391
|
};
|
|
1334
|
-
}), typeof window < "u" && (window.usermavenClient =
|
|
1392
|
+
}), typeof window < "u" && (window.usermavenClient = I, window.UsermavenClient = N, window.usermavenScriptTagClient = () => O), function(e, t) {
|
|
1335
1393
|
const i = e.currentScript;
|
|
1336
1394
|
function s() {
|
|
1337
|
-
return
|
|
1395
|
+
return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1338
1396
|
}
|
|
1339
1397
|
function r() {
|
|
1340
|
-
s() && (console.log("[Usermaven] Auto-initializing from script tag"),
|
|
1398
|
+
s() && (console.log("[Usermaven] Auto-initializing from script tag"), O = xe(i), K = !0);
|
|
1341
1399
|
}
|
|
1342
1400
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1343
1401
|
}(document, window);
|
|
1344
1402
|
}
|
|
1345
|
-
typeof module < "u" && module.exports && !
|
|
1346
|
-
usermavenClient:
|
|
1347
|
-
UsermavenClient:
|
|
1403
|
+
typeof module < "u" && module.exports && !te() && (module.exports = {
|
|
1404
|
+
usermavenClient: I,
|
|
1405
|
+
UsermavenClient: N,
|
|
1348
1406
|
Config: void 0,
|
|
1349
1407
|
UserProps: void 0,
|
|
1350
1408
|
EventPayload: void 0,
|
|
1351
|
-
LogLevel:
|
|
1409
|
+
LogLevel: k,
|
|
1352
1410
|
ClientProperties: void 0
|
|
1353
1411
|
});
|
|
1354
1412
|
export {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1413
|
+
k as LogLevel,
|
|
1414
|
+
N as UsermavenClient,
|
|
1415
|
+
I as usermavenClient
|
|
1358
1416
|
};
|