@usermaven/sdk-js 1.5.10-rc.111 → 1.5.10-rc.112
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/lib.js +2 -2
- package/dist/persistence/local-storage.d.ts +6 -1
- package/dist/usermaven.cjs.js +2 -2
- package/dist/usermaven.es.js +390 -324
- package/dist/utils/queue.d.ts +6 -1
- package/package.json +1 -1
package/dist/usermaven.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var k = /* @__PURE__ */ ((
|
|
2
|
-
class
|
|
1
|
+
var k = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(k || {});
|
|
2
|
+
class se {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.level = e;
|
|
5
5
|
}
|
|
@@ -16,8 +16,8 @@ class ne {
|
|
|
16
16
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return new
|
|
19
|
+
function g(s = 0) {
|
|
20
|
+
return new se(s);
|
|
21
21
|
}
|
|
22
22
|
const Z = {
|
|
23
23
|
logLevel: k.ERROR,
|
|
@@ -51,20 +51,20 @@ const Z = {
|
|
|
51
51
|
maskAllText: !1,
|
|
52
52
|
maskAllElementAttributes: !1
|
|
53
53
|
};
|
|
54
|
-
class
|
|
54
|
+
class ne {
|
|
55
55
|
constructor(e) {
|
|
56
56
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
57
57
|
}
|
|
58
|
-
set(e, t, i = 365,
|
|
58
|
+
set(e, t, i = 365, n = !0, r = !1) {
|
|
59
59
|
const o = /* @__PURE__ */ new Date();
|
|
60
60
|
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
61
|
-
const a = `expires=${o.toUTCString()}`, l =
|
|
61
|
+
const a = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", c = r ? "; HttpOnly" : "";
|
|
62
62
|
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
|
|
63
63
|
}
|
|
64
64
|
get(e) {
|
|
65
65
|
const t = e + "=", i = document.cookie.split(";");
|
|
66
|
-
for (let
|
|
67
|
-
let r = i[
|
|
66
|
+
for (let n = 0; n < i.length; n++) {
|
|
67
|
+
let r = i[n].trim();
|
|
68
68
|
if (r.indexOf(t) === 0)
|
|
69
69
|
return decodeURIComponent(r.substring(t.length));
|
|
70
70
|
}
|
|
@@ -92,83 +92,83 @@ class se {
|
|
|
92
92
|
}
|
|
93
93
|
extractRootDomain(e) {
|
|
94
94
|
let t = this.extractHostname(e);
|
|
95
|
-
const i = t.split("."),
|
|
96
|
-
return
|
|
95
|
+
const i = t.split("."), n = i.length;
|
|
96
|
+
return n > 2 && (i[n - 1].length == 2 ? (t = i[n - 2] + "." + i[n - 1], i[n - 2].length == 2 && (t = i[n - 3] + "." + t)) : t = i[n - 2] + "." + i[n - 1]), t;
|
|
97
97
|
}
|
|
98
98
|
extractTopLevelDomain(e) {
|
|
99
99
|
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
|
|
100
100
|
return i ? i[0] : "";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype,
|
|
104
|
-
function ce(
|
|
105
|
-
if (Array.isArray(
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
else if ("length" in
|
|
109
|
-
for (let i = 0,
|
|
110
|
-
if (i in
|
|
103
|
+
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, T = ae.forEach, U = {};
|
|
104
|
+
function ce(s, e, t) {
|
|
105
|
+
if (Array.isArray(s)) {
|
|
106
|
+
if (T && s.forEach === T)
|
|
107
|
+
s.forEach(e, t);
|
|
108
|
+
else if ("length" in s && s.length === +s.length) {
|
|
109
|
+
for (let i = 0, n = s.length; i < n; i++)
|
|
110
|
+
if (i in s && e.call(t, s[i], i) === U)
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
const
|
|
116
|
-
return
|
|
117
|
-
}, le = function(
|
|
118
|
-
for (const e in
|
|
119
|
-
typeof
|
|
115
|
+
const B = function(s) {
|
|
116
|
+
return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
117
|
+
}, le = function(s) {
|
|
118
|
+
for (const e in s)
|
|
119
|
+
typeof s[e] == "function" && (s[e] = s[e].bind(s));
|
|
120
120
|
};
|
|
121
|
-
function w(
|
|
122
|
-
if (
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
else if ("length" in
|
|
126
|
-
for (let i = 0,
|
|
127
|
-
if (i in
|
|
121
|
+
function w(s, e, t) {
|
|
122
|
+
if (s != null) {
|
|
123
|
+
if (T && Array.isArray(s) && s.forEach === T)
|
|
124
|
+
s.forEach(e, t);
|
|
125
|
+
else if ("length" in s && s.length === +s.length) {
|
|
126
|
+
for (let i = 0, n = s.length; i < n; i++)
|
|
127
|
+
if (i in s && e.call(t, s[i], i) === U)
|
|
128
128
|
return;
|
|
129
129
|
} else
|
|
130
|
-
for (const i in
|
|
131
|
-
if (oe.call(
|
|
130
|
+
for (const i in s)
|
|
131
|
+
if (oe.call(s, i) && e.call(t, s[i], i) === U)
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
const ue = function(
|
|
135
|
+
const ue = function(s, ...e) {
|
|
136
136
|
return ce(e, function(t) {
|
|
137
137
|
for (const i in t)
|
|
138
|
-
t[i] !== void 0 && (
|
|
139
|
-
}),
|
|
138
|
+
t[i] !== void 0 && (s[i] = t[i]);
|
|
139
|
+
}), s;
|
|
140
140
|
};
|
|
141
|
-
function
|
|
142
|
-
return
|
|
141
|
+
function A(s, e) {
|
|
142
|
+
return s.indexOf(e) !== -1;
|
|
143
143
|
}
|
|
144
|
-
const he = function(
|
|
144
|
+
const he = function(s) {
|
|
145
145
|
try {
|
|
146
|
-
return /^\s*\bfunction\b/.test(
|
|
146
|
+
return /^\s*\bfunction\b/.test(s);
|
|
147
147
|
} catch {
|
|
148
148
|
return !1;
|
|
149
149
|
}
|
|
150
|
-
}, de = function(
|
|
151
|
-
return
|
|
150
|
+
}, de = function(s) {
|
|
151
|
+
return s === void 0;
|
|
152
152
|
}, E = function() {
|
|
153
|
-
const
|
|
153
|
+
const s = function(i, n, r, o, a) {
|
|
154
154
|
if (!i) {
|
|
155
|
-
|
|
155
|
+
g().error("No valid element provided to register_event");
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
if (i.addEventListener && !o)
|
|
159
|
-
i.addEventListener(
|
|
159
|
+
i.addEventListener(n, r, !!a);
|
|
160
160
|
else {
|
|
161
|
-
const l = "on" +
|
|
161
|
+
const l = "on" + n, c = i[l];
|
|
162
162
|
i[l] = e(i, r, c);
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
|
-
function e(i,
|
|
165
|
+
function e(i, n, r) {
|
|
166
166
|
return function(o) {
|
|
167
167
|
if (o = o || t(window.event), !o)
|
|
168
168
|
return;
|
|
169
169
|
let a = !0, l;
|
|
170
170
|
he(r) && (l = r(o));
|
|
171
|
-
const c =
|
|
171
|
+
const c = n.call(i, o);
|
|
172
172
|
return (l === !1 || c === !1) && (a = !1), a;
|
|
173
173
|
};
|
|
174
174
|
}
|
|
@@ -179,80 +179,80 @@ const he = function(n) {
|
|
|
179
179
|
this.returnValue = !1;
|
|
180
180
|
}, t.stopPropagation = function() {
|
|
181
181
|
this.cancelBubble = !0;
|
|
182
|
-
},
|
|
183
|
-
}(),
|
|
182
|
+
}, s;
|
|
183
|
+
}(), ge = function(s) {
|
|
184
184
|
return function(...e) {
|
|
185
185
|
try {
|
|
186
|
-
return
|
|
186
|
+
return s.apply(this, e);
|
|
187
187
|
} catch (t) {
|
|
188
|
-
|
|
188
|
+
g().error(
|
|
189
189
|
"Implementation error. Please turn on debug and contact support@usermaven.com.",
|
|
190
190
|
t
|
|
191
191
|
);
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
|
-
}, Y = function(
|
|
195
|
-
for (const e in
|
|
196
|
-
typeof
|
|
194
|
+
}, Y = function(s) {
|
|
195
|
+
for (const e in s)
|
|
196
|
+
typeof s[e] == "function" && (s[e] = ge(s[e]));
|
|
197
197
|
};
|
|
198
|
-
function
|
|
199
|
-
for (let e in
|
|
200
|
-
(
|
|
201
|
-
return
|
|
198
|
+
function M(s) {
|
|
199
|
+
for (let e in s)
|
|
200
|
+
(s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
|
|
201
|
+
return s;
|
|
202
202
|
}
|
|
203
203
|
function h() {
|
|
204
204
|
try {
|
|
205
205
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
206
206
|
} catch {
|
|
207
|
-
return
|
|
207
|
+
return g().warn("window is not available"), !1;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
function v(
|
|
211
|
-
const e = new Uint8Array(
|
|
212
|
-
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0,
|
|
210
|
+
function v(s = 5) {
|
|
211
|
+
const e = new Uint8Array(s);
|
|
212
|
+
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, s);
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
return
|
|
214
|
+
function fe(s) {
|
|
215
|
+
return s.replace(
|
|
216
216
|
/([-_][a-z])/g,
|
|
217
217
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
|
-
function
|
|
221
|
-
return typeof
|
|
220
|
+
function F(s) {
|
|
221
|
+
return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(F) : Object.keys(s).reduce(
|
|
222
222
|
(e, t) => {
|
|
223
|
-
const i =
|
|
224
|
-
return e[i] =
|
|
223
|
+
const i = fe(t);
|
|
224
|
+
return e[i] = F(s[t]), e;
|
|
225
225
|
},
|
|
226
226
|
{}
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
|
-
function x(
|
|
230
|
-
switch (typeof
|
|
229
|
+
function x(s) {
|
|
230
|
+
switch (typeof s.className) {
|
|
231
231
|
case "string":
|
|
232
|
-
return
|
|
232
|
+
return s.className;
|
|
233
233
|
case "object":
|
|
234
|
-
return ("baseVal" in
|
|
234
|
+
return ("baseVal" in s.className ? s.className.baseVal : null) || s.getAttribute("class") || "";
|
|
235
235
|
default:
|
|
236
236
|
return "";
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function V(s) {
|
|
240
240
|
let e = "";
|
|
241
|
-
return
|
|
242
|
-
j(t) && t.textContent && (e +=
|
|
243
|
-
}),
|
|
241
|
+
return q(s) && !ee(s) && s.childNodes && s.childNodes.length && w(s.childNodes, function(t) {
|
|
242
|
+
j(t) && t.textContent && (e += B(t.textContent).split(/(\s+)/).filter($).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
243
|
+
}), B(e);
|
|
244
244
|
}
|
|
245
|
-
function G(
|
|
246
|
-
return !!
|
|
245
|
+
function G(s) {
|
|
246
|
+
return !!s && s.nodeType === 1;
|
|
247
247
|
}
|
|
248
|
-
function y(
|
|
249
|
-
return !!
|
|
248
|
+
function y(s, e) {
|
|
249
|
+
return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
|
|
250
250
|
}
|
|
251
|
-
function j(
|
|
252
|
-
return !!
|
|
251
|
+
function j(s) {
|
|
252
|
+
return !!s && s.nodeType === 3;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
255
|
-
return !!
|
|
254
|
+
function Q(s) {
|
|
255
|
+
return !!s && s.nodeType === 11;
|
|
256
256
|
}
|
|
257
257
|
const C = [
|
|
258
258
|
"a",
|
|
@@ -263,18 +263,18 @@ const C = [
|
|
|
263
263
|
"textarea",
|
|
264
264
|
"label"
|
|
265
265
|
];
|
|
266
|
-
function pe(
|
|
267
|
-
if (!
|
|
266
|
+
function pe(s, e) {
|
|
267
|
+
if (!s || y(s, "html") || !G(s))
|
|
268
268
|
return !1;
|
|
269
|
-
let t =
|
|
269
|
+
let t = s;
|
|
270
270
|
for (; t && !y(t, "body"); ) {
|
|
271
271
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
272
272
|
return !1;
|
|
273
|
-
t.parentNode &&
|
|
273
|
+
t.parentNode && Q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
274
274
|
}
|
|
275
275
|
let i = !1;
|
|
276
|
-
for (t =
|
|
277
|
-
if (t.parentNode &&
|
|
276
|
+
for (t = s; t && !y(t, "body"); ) {
|
|
277
|
+
if (t.parentNode && Q(t.parentNode)) {
|
|
278
278
|
t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
279
279
|
continue;
|
|
280
280
|
}
|
|
@@ -288,10 +288,10 @@ function pe(n, e) {
|
|
|
288
288
|
}
|
|
289
289
|
t = o;
|
|
290
290
|
}
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
291
|
+
const n = window.getComputedStyle(s);
|
|
292
|
+
if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
|
|
293
293
|
return !0;
|
|
294
|
-
const r =
|
|
294
|
+
const r = s.tagName.toLowerCase();
|
|
295
295
|
switch (r) {
|
|
296
296
|
case "html":
|
|
297
297
|
return !1;
|
|
@@ -303,18 +303,18 @@ function pe(n, e) {
|
|
|
303
303
|
case "textarea":
|
|
304
304
|
return e.type === "change" || e.type === "click";
|
|
305
305
|
default:
|
|
306
|
-
return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 ||
|
|
306
|
+
return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
function
|
|
310
|
-
for (let i =
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
309
|
+
function q(s) {
|
|
310
|
+
for (let i = s; i.parentNode && !y(i, "body"); i = i.parentNode) {
|
|
311
|
+
const n = x(i).split(" ");
|
|
312
|
+
if (A(n, "ph-sensitive") || A(n, "ph-no-capture"))
|
|
313
313
|
return !1;
|
|
314
314
|
}
|
|
315
|
-
if (
|
|
315
|
+
if (A(x(s).split(" "), "ph-include"))
|
|
316
316
|
return !0;
|
|
317
|
-
const e =
|
|
317
|
+
const e = s.type || "";
|
|
318
318
|
if (typeof e == "string")
|
|
319
319
|
switch (e.toLowerCase()) {
|
|
320
320
|
case "hidden":
|
|
@@ -322,59 +322,59 @@ function B(n) {
|
|
|
322
322
|
case "password":
|
|
323
323
|
return !1;
|
|
324
324
|
}
|
|
325
|
-
const t =
|
|
325
|
+
const t = s.name || s.id || "";
|
|
326
326
|
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, "")));
|
|
327
327
|
}
|
|
328
|
-
function ee(
|
|
328
|
+
function ee(s) {
|
|
329
329
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
330
|
-
return !!(y(
|
|
330
|
+
return !!(y(s, "input") && !e.includes(s.type) || y(s, "select") || y(s, "textarea") || s.getAttribute("contenteditable") === "true");
|
|
331
331
|
}
|
|
332
|
-
function
|
|
333
|
-
return !(
|
|
332
|
+
function $(s) {
|
|
333
|
+
return !(s === null || de(s) || typeof s == "string" && (s = B(s), /^(?:(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((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
|
|
334
334
|
}
|
|
335
|
-
function me(
|
|
336
|
-
return typeof
|
|
335
|
+
function me(s) {
|
|
336
|
+
return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
|
|
337
337
|
}
|
|
338
338
|
function R() {
|
|
339
339
|
return v(10);
|
|
340
340
|
}
|
|
341
|
-
function J(
|
|
342
|
-
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(
|
|
341
|
+
function J(s) {
|
|
342
|
+
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(s).toLowerCase());
|
|
343
343
|
}
|
|
344
|
-
function ye(
|
|
344
|
+
function ye(s, e) {
|
|
345
345
|
let t;
|
|
346
346
|
return function(...i) {
|
|
347
|
-
const
|
|
348
|
-
clearTimeout(t),
|
|
347
|
+
const n = () => {
|
|
348
|
+
clearTimeout(t), s(...i);
|
|
349
349
|
};
|
|
350
|
-
clearTimeout(t), t = setTimeout(
|
|
350
|
+
clearTimeout(t), t = setTimeout(n, e);
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
-
function we(
|
|
354
|
-
const e = {}, t =
|
|
353
|
+
function we(s) {
|
|
354
|
+
const e = {}, t = s.replace(/^\?/, "").split("&");
|
|
355
355
|
for (let i = 0; i < t.length; i++) {
|
|
356
|
-
const
|
|
357
|
-
|
|
356
|
+
const n = t[i].split("=");
|
|
357
|
+
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
358
358
|
}
|
|
359
359
|
return e;
|
|
360
360
|
}
|
|
361
|
-
function L(
|
|
362
|
-
return typeof
|
|
361
|
+
function L(s) {
|
|
362
|
+
return typeof s == "string" || s instanceof String;
|
|
363
363
|
}
|
|
364
|
-
function P(
|
|
365
|
-
return
|
|
364
|
+
function P(s) {
|
|
365
|
+
return s !== null && typeof s == "object" && s.constructor === Object;
|
|
366
366
|
}
|
|
367
|
-
function ke(
|
|
368
|
-
if (
|
|
367
|
+
function ke(s) {
|
|
368
|
+
if (s === null)
|
|
369
369
|
return k.ERROR;
|
|
370
|
-
const e =
|
|
370
|
+
const e = s.toUpperCase(), t = k[e];
|
|
371
371
|
return t || t === 0 ? t : k.ERROR;
|
|
372
372
|
}
|
|
373
373
|
const ve = () => {
|
|
374
|
-
let
|
|
375
|
-
return typeof window < "u" && window.localStorage && (
|
|
374
|
+
let s = "false";
|
|
375
|
+
return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
|
|
376
376
|
};
|
|
377
|
-
class
|
|
377
|
+
class be {
|
|
378
378
|
constructor(e) {
|
|
379
379
|
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ye(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
380
380
|
}
|
|
@@ -400,8 +400,8 @@ class _e {
|
|
|
400
400
|
this.track();
|
|
401
401
|
}
|
|
402
402
|
getScrollDepth() {
|
|
403
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(),
|
|
404
|
-
return Math.min(100, Math.floor(i /
|
|
403
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
|
|
404
|
+
return Math.min(100, Math.floor(i / n * 100));
|
|
405
405
|
}
|
|
406
406
|
getWindowHeight() {
|
|
407
407
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -423,16 +423,16 @@ class _e {
|
|
|
423
423
|
this.milestones.filter(
|
|
424
424
|
(i) => e >= i
|
|
425
425
|
).forEach((i) => {
|
|
426
|
-
this.send(), this.milestones = this.milestones.filter((
|
|
426
|
+
this.send(), this.milestones = this.milestones.filter((n) => n !== i);
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
429
|
destroy() {
|
|
430
430
|
window.removeEventListener("scroll", this.debouncedHandleScroll);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
const
|
|
434
|
-
constructor(e, t, i =
|
|
435
|
-
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new
|
|
433
|
+
const N = class N {
|
|
434
|
+
constructor(e, t, i = g()) {
|
|
435
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new be(e), le(this), Y(this);
|
|
436
436
|
}
|
|
437
437
|
isBrowserSupported() {
|
|
438
438
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -469,17 +469,17 @@ const I = class I {
|
|
|
469
469
|
return performance.navigation && performance.navigation.type === 1;
|
|
470
470
|
}
|
|
471
471
|
captureEvent(e) {
|
|
472
|
-
var i,
|
|
472
|
+
var i, n;
|
|
473
473
|
let t = this.getEventTarget(e);
|
|
474
474
|
if (j(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
475
475
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
476
476
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
477
|
-
return this.isPageRefresh() || (
|
|
477
|
+
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
478
478
|
if (t && pe(t, e)) {
|
|
479
479
|
const r = [t];
|
|
480
480
|
let o = t;
|
|
481
481
|
for (; o.parentNode && !y(o, "body"); ) {
|
|
482
|
-
if (
|
|
482
|
+
if (Q(o.parentNode)) {
|
|
483
483
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
484
484
|
continue;
|
|
485
485
|
}
|
|
@@ -488,17 +488,17 @@ const I = class I {
|
|
|
488
488
|
const a = [];
|
|
489
489
|
let l, c = !1;
|
|
490
490
|
if (w(r, (p) => {
|
|
491
|
-
const
|
|
492
|
-
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l =
|
|
491
|
+
const b = q(p);
|
|
492
|
+
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = b && $(l) && l);
|
|
493
493
|
const u = x(p).split(" ");
|
|
494
|
-
|
|
494
|
+
A(u, "ph-no-capture") && (c = !0), a.push(
|
|
495
495
|
this.getPropertiesFromElement(
|
|
496
496
|
p,
|
|
497
497
|
this.options.maskAllElementAttributes ?? !1,
|
|
498
498
|
this.options.maskAllText ?? !1
|
|
499
499
|
)
|
|
500
500
|
);
|
|
501
|
-
}), this.options.maskAllText || (a[0].$el_text =
|
|
501
|
+
}), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
|
|
502
502
|
return !1;
|
|
503
503
|
const d = ue(
|
|
504
504
|
this.getDefaultProperties(e.type),
|
|
@@ -513,10 +513,10 @@ const I = class I {
|
|
|
513
513
|
getCustomProperties(e) {
|
|
514
514
|
const t = {};
|
|
515
515
|
return w(this.customProperties, (i) => {
|
|
516
|
-
w(i.event_selectors, (
|
|
517
|
-
const r = document.querySelectorAll(
|
|
516
|
+
w(i.event_selectors, (n) => {
|
|
517
|
+
const r = document.querySelectorAll(n);
|
|
518
518
|
w(r, (o) => {
|
|
519
|
-
|
|
519
|
+
A(e, o) && q(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
520
520
|
});
|
|
521
521
|
});
|
|
522
522
|
}), t;
|
|
@@ -526,8 +526,8 @@ const I = class I {
|
|
|
526
526
|
return w(
|
|
527
527
|
document.querySelectorAll(e.css_selector),
|
|
528
528
|
function(i) {
|
|
529
|
-
let
|
|
530
|
-
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ?
|
|
529
|
+
let n;
|
|
530
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), $(n) && t.push(n);
|
|
531
531
|
}
|
|
532
532
|
), t.join(", ");
|
|
533
533
|
}
|
|
@@ -536,15 +536,15 @@ const I = class I {
|
|
|
536
536
|
return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
537
537
|
}
|
|
538
538
|
getPropertiesFromElement(e, t, i) {
|
|
539
|
-
const
|
|
540
|
-
tag_name:
|
|
539
|
+
const n = e.tagName.toLowerCase(), r = {
|
|
540
|
+
tag_name: n
|
|
541
541
|
};
|
|
542
|
-
C.indexOf(
|
|
542
|
+
C.indexOf(n) > -1 && !i && (r.$el_text = V(e));
|
|
543
543
|
const o = x(e);
|
|
544
544
|
o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
|
|
545
545
|
return d !== "";
|
|
546
546
|
})), w(e.attributes, function(d) {
|
|
547
|
-
ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t &&
|
|
547
|
+
ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && $(d.value) && !me(d.name) && (r["attr__" + d.name] = d.value);
|
|
548
548
|
});
|
|
549
549
|
let a = 1, l = 1, c = e;
|
|
550
550
|
for (; c = this.previousElementSibling(c); )
|
|
@@ -574,15 +574,15 @@ const I = class I {
|
|
|
574
574
|
static enabledForProject(e, t = 10, i = 10) {
|
|
575
575
|
if (!e)
|
|
576
576
|
return !1;
|
|
577
|
-
let
|
|
577
|
+
let n = 0;
|
|
578
578
|
for (let r = 0; r < e.length; r++)
|
|
579
|
-
|
|
580
|
-
return
|
|
579
|
+
n += e.charCodeAt(r);
|
|
580
|
+
return n % t < i;
|
|
581
581
|
}
|
|
582
582
|
};
|
|
583
|
-
|
|
584
|
-
let H =
|
|
585
|
-
class
|
|
583
|
+
N.FORCE_CAPTURE_ATTR = "data-um-force-capture", N.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
584
|
+
let H = N;
|
|
585
|
+
class _e {
|
|
586
586
|
constructor(e) {
|
|
587
587
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
588
588
|
}
|
|
@@ -612,14 +612,14 @@ class be {
|
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
class Ee {
|
|
615
|
-
constructor(e, t, i =
|
|
615
|
+
constructor(e, t, i = g()) {
|
|
616
616
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
617
617
|
}
|
|
618
618
|
async send(e) {
|
|
619
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
619
|
+
const t = this.config.key, i = this.constructUrl(t), n = new Blob([JSON.stringify(e)], {
|
|
620
620
|
type: "application/json"
|
|
621
621
|
});
|
|
622
|
-
if (navigator.sendBeacon(i,
|
|
622
|
+
if (navigator.sendBeacon(i, n))
|
|
623
623
|
this.logger.debug(
|
|
624
624
|
`Successfully queued ${e.length} event(s) via Beacon API`
|
|
625
625
|
);
|
|
@@ -627,32 +627,32 @@ class Ee {
|
|
|
627
627
|
throw new Error("Failed to queue events via Beacon API");
|
|
628
628
|
}
|
|
629
629
|
constructUrl(e) {
|
|
630
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
631
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${
|
|
630
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
631
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
632
632
|
}
|
|
633
633
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
634
634
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
635
635
|
}
|
|
636
636
|
class W {
|
|
637
|
-
constructor(e, t, i =
|
|
637
|
+
constructor(e, t, i = g()) {
|
|
638
638
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
639
639
|
}
|
|
640
640
|
async send(e) {
|
|
641
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
641
|
+
const t = this.config.key, i = this.constructUrl(t), n = JSON.stringify(e), r = {
|
|
642
642
|
"Content-Type": "application/json",
|
|
643
643
|
...this.getCustomHeaders()
|
|
644
644
|
}, o = await fetch(i, {
|
|
645
645
|
method: "POST",
|
|
646
646
|
headers: r,
|
|
647
|
-
body:
|
|
647
|
+
body: n
|
|
648
648
|
});
|
|
649
649
|
if (!o.ok)
|
|
650
650
|
throw new Error(`HTTP error! status: ${o.status}`);
|
|
651
651
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
652
652
|
}
|
|
653
653
|
constructUrl(e) {
|
|
654
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
655
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${
|
|
654
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
655
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
656
656
|
}
|
|
657
657
|
getCustomHeaders() {
|
|
658
658
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -662,26 +662,26 @@ class W {
|
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
664
|
class Pe {
|
|
665
|
-
constructor(e, t, i =
|
|
665
|
+
constructor(e, t, i = g()) {
|
|
666
666
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
667
667
|
}
|
|
668
668
|
send(e) {
|
|
669
669
|
return new Promise((t, i) => {
|
|
670
|
-
const
|
|
671
|
-
|
|
670
|
+
const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
671
|
+
n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
|
|
672
672
|
const a = this.getCustomHeaders();
|
|
673
673
|
Object.keys(a).forEach((l) => {
|
|
674
|
-
|
|
675
|
-
}),
|
|
676
|
-
|
|
677
|
-
},
|
|
674
|
+
n.setRequestHeader(l, a[l]);
|
|
675
|
+
}), n.onload = () => {
|
|
676
|
+
n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${n.status}`));
|
|
677
|
+
}, n.onerror = () => {
|
|
678
678
|
i(new Error("Network error"));
|
|
679
|
-
},
|
|
679
|
+
}, n.send(JSON.stringify(e));
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
constructUrl(e) {
|
|
683
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
684
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${
|
|
683
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
684
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
685
685
|
}
|
|
686
686
|
getCustomHeaders() {
|
|
687
687
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -692,7 +692,7 @@ class Pe {
|
|
|
692
692
|
}
|
|
693
693
|
class te {
|
|
694
694
|
constructor(e, t) {
|
|
695
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.
|
|
695
|
+
this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || g(), this.load();
|
|
696
696
|
}
|
|
697
697
|
set(e, t) {
|
|
698
698
|
this.storage[e] = t, this.save();
|
|
@@ -706,16 +706,8 @@ class te {
|
|
|
706
706
|
clear() {
|
|
707
707
|
this.storage = {}, this.save();
|
|
708
708
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
this.logger.warn("localStorage is not available in this environment");
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
try {
|
|
715
|
-
localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage));
|
|
716
|
-
} catch (e) {
|
|
717
|
-
this.logger.error("Error saving to localStorage:", e);
|
|
718
|
-
}
|
|
709
|
+
isStorageEnabled() {
|
|
710
|
+
return !this.storageDisabled;
|
|
719
711
|
}
|
|
720
712
|
load() {
|
|
721
713
|
if (!h()) {
|
|
@@ -726,11 +718,32 @@ class te {
|
|
|
726
718
|
const e = localStorage.getItem(this.prefix + "data");
|
|
727
719
|
e && (this.storage = JSON.parse(e));
|
|
728
720
|
} catch (e) {
|
|
729
|
-
this.logger.error("Error loading from localStorage:", e);
|
|
721
|
+
this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error loading from localStorage:", e);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
save() {
|
|
725
|
+
if (!h())
|
|
726
|
+
return this.logger.warn("localStorage is not available in this environment"), !1;
|
|
727
|
+
if (this.storageDisabled)
|
|
728
|
+
return !1;
|
|
729
|
+
try {
|
|
730
|
+
return localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage)), !0;
|
|
731
|
+
} catch (e) {
|
|
732
|
+
return this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error saving to localStorage:", e), !1;
|
|
730
733
|
}
|
|
731
734
|
}
|
|
735
|
+
isQuotaError(e) {
|
|
736
|
+
const t = e == null ? void 0 : e.name;
|
|
737
|
+
return t === "QuotaExceededError" || t === "NS_ERROR_DOM_QUOTA_REACHED" || (e == null ? void 0 : e.code) === 22 || (e == null ? void 0 : e.code) === 1014;
|
|
738
|
+
}
|
|
739
|
+
logQuotaOnce(e) {
|
|
740
|
+
this.quotaErrorLogged || (this.quotaErrorLogged = !0, this.logger.error(
|
|
741
|
+
"localStorage quota exceeded; persisting disabled. Continuing with in-memory storage only.",
|
|
742
|
+
e
|
|
743
|
+
));
|
|
744
|
+
}
|
|
732
745
|
}
|
|
733
|
-
class
|
|
746
|
+
class Se {
|
|
734
747
|
constructor() {
|
|
735
748
|
this.storage = {};
|
|
736
749
|
}
|
|
@@ -750,15 +763,18 @@ class Ae {
|
|
|
750
763
|
}
|
|
751
764
|
}
|
|
752
765
|
class K {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
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 te(
|
|
766
|
+
constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = g(), a = "default", l = 1e3, c = 25e5) {
|
|
767
|
+
this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.totalQueueBytes = 0, this.persistence = new te(
|
|
756
768
|
`offline_queue_${a}`
|
|
757
|
-
), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
769
|
+
), this.maxQueueItems = l, this.maxQueueBytes = c, h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
758
770
|
}
|
|
759
771
|
add(e) {
|
|
760
|
-
const t = {
|
|
761
|
-
|
|
772
|
+
const t = {
|
|
773
|
+
payload: e,
|
|
774
|
+
retries: 0,
|
|
775
|
+
timestamp: Date.now()
|
|
776
|
+
};
|
|
777
|
+
t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), h() ? this.saveQueueToStorage() : this.processBatch();
|
|
762
778
|
}
|
|
763
779
|
initNetworkListeners() {
|
|
764
780
|
h() && (window.addEventListener("online", () => {
|
|
@@ -776,7 +792,12 @@ class K {
|
|
|
776
792
|
async processBatch() {
|
|
777
793
|
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
778
794
|
this.processing = !0;
|
|
779
|
-
const e = this.queue.splice(0, this.batchSize)
|
|
795
|
+
const e = this.queue.splice(0, this.batchSize);
|
|
796
|
+
this.totalQueueBytes = Math.max(
|
|
797
|
+
0,
|
|
798
|
+
this.totalQueueBytes - e.reduce((i, n) => i + (n.bytes || 0), 0)
|
|
799
|
+
);
|
|
800
|
+
const t = e.map((i) => i.payload);
|
|
780
801
|
try {
|
|
781
802
|
await this.transport.send(t), this.logger.debug(
|
|
782
803
|
`Successfully sent batch of ${e.length} payloads`
|
|
@@ -790,23 +811,68 @@ class K {
|
|
|
790
811
|
}
|
|
791
812
|
async handleBatchFailure(e) {
|
|
792
813
|
for (const t of e)
|
|
793
|
-
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
814
|
+
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.totalQueueBytes += t.bytes || this.estimateItemBytes(t), this.enforceQueueLimits(), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
794
815
|
"Max retries reached, discarding payload",
|
|
795
816
|
t.payload
|
|
796
817
|
);
|
|
797
818
|
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
798
819
|
}
|
|
820
|
+
enforceQueueLimits() {
|
|
821
|
+
if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
|
|
822
|
+
const e = this.queue.length - this.maxQueueItems, t = this.queue.splice(0, e);
|
|
823
|
+
this.totalQueueBytes = Math.max(
|
|
824
|
+
0,
|
|
825
|
+
this.totalQueueBytes - t.reduce((i, n) => i + (n.bytes || 0), 0)
|
|
826
|
+
), this.logger.warn(
|
|
827
|
+
`Retry queue exceeded ${this.maxQueueItems} items; dropped ${t.length} oldest payload(s)`
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
if (this.maxQueueBytes > 0 && this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 0) {
|
|
831
|
+
let e = 0;
|
|
832
|
+
for (; this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 1; ) {
|
|
833
|
+
const t = this.queue.shift();
|
|
834
|
+
t && (this.totalQueueBytes -= t.bytes || this.estimateItemBytes(t), e++);
|
|
835
|
+
}
|
|
836
|
+
this.totalQueueBytes = Math.max(0, this.totalQueueBytes), e > 0 && this.logger.warn(
|
|
837
|
+
`Retry queue exceeded ${this.maxQueueBytes} bytes; dropped ${e} oldest payload(s)`
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
estimateItemBytes(e) {
|
|
842
|
+
const t = { ...e };
|
|
843
|
+
delete t.bytes;
|
|
844
|
+
try {
|
|
845
|
+
return JSON.stringify(t).length;
|
|
846
|
+
} catch {
|
|
847
|
+
return 0;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
799
850
|
loadQueueFromStorage() {
|
|
800
851
|
if (h()) {
|
|
801
852
|
const e = this.persistence.get("queue");
|
|
802
|
-
|
|
853
|
+
if (!e) return;
|
|
854
|
+
try {
|
|
855
|
+
const t = JSON.parse(e);
|
|
856
|
+
this.queue = t.map((i) => ({
|
|
857
|
+
...i,
|
|
858
|
+
bytes: i.bytes || this.estimateItemBytes(i)
|
|
859
|
+
})), this.totalQueueBytes = this.queue.reduce(
|
|
860
|
+
(i, n) => i + (n.bytes || 0),
|
|
861
|
+
0
|
|
862
|
+
), this.enforceQueueLimits();
|
|
863
|
+
} catch (t) {
|
|
864
|
+
this.logger.error("Failed to parse stored queue", t), this.queue = [], this.totalQueueBytes = 0;
|
|
865
|
+
}
|
|
803
866
|
}
|
|
804
867
|
}
|
|
805
868
|
saveQueueToStorage() {
|
|
806
|
-
|
|
869
|
+
if (h()) {
|
|
870
|
+
const e = this.queue.map(({ bytes: t, ...i }) => i);
|
|
871
|
+
this.persistence.set("queue", JSON.stringify(e));
|
|
872
|
+
}
|
|
807
873
|
}
|
|
808
874
|
}
|
|
809
|
-
class
|
|
875
|
+
class Ae {
|
|
810
876
|
constructor(e) {
|
|
811
877
|
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
|
|
812
878
|
}
|
|
@@ -821,8 +887,8 @@ class Se {
|
|
|
821
887
|
return !e.closest(".um-no-capture");
|
|
822
888
|
}
|
|
823
889
|
click(e, t, i) {
|
|
824
|
-
const
|
|
825
|
-
this.clicks.push(
|
|
890
|
+
const n = { x: e, y: t, timestamp: i };
|
|
891
|
+
this.clicks.push(n), this.clicks = this.clicks.filter(
|
|
826
892
|
(r) => i - r.timestamp < this.timeWindow
|
|
827
893
|
), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
828
894
|
}
|
|
@@ -845,11 +911,11 @@ class Se {
|
|
|
845
911
|
}
|
|
846
912
|
}
|
|
847
913
|
class Ce {
|
|
848
|
-
constructor(e, t, i =
|
|
914
|
+
constructor(e, t, i = g()) {
|
|
849
915
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
850
916
|
}
|
|
851
917
|
async send(e) {
|
|
852
|
-
const t = this.config.key, i = new (void 0)(this.constructUrl(t)),
|
|
918
|
+
const t = this.config.key, i = new (void 0)(this.constructUrl(t)), n = {
|
|
853
919
|
hostname: i.hostname,
|
|
854
920
|
port: 443,
|
|
855
921
|
path: `${i.pathname}${i.search}`,
|
|
@@ -860,7 +926,7 @@ class Ce {
|
|
|
860
926
|
}
|
|
861
927
|
};
|
|
862
928
|
return new Promise((r, o) => {
|
|
863
|
-
const a = (void 0)(
|
|
929
|
+
const a = (void 0)(n, (l) => {
|
|
864
930
|
l.on("data", (c) => {
|
|
865
931
|
}), l.on("end", () => {
|
|
866
932
|
const c = l.statusCode || 0;
|
|
@@ -880,7 +946,7 @@ class Ce {
|
|
|
880
946
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
881
947
|
}
|
|
882
948
|
}
|
|
883
|
-
class
|
|
949
|
+
class S {
|
|
884
950
|
constructor(e, t = "all", i = {}) {
|
|
885
951
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
886
952
|
}
|
|
@@ -895,17 +961,17 @@ class A {
|
|
|
895
961
|
}
|
|
896
962
|
handleFormSubmit(e) {
|
|
897
963
|
const t = e.target, i = this._getFormDetails(t);
|
|
898
|
-
this.instance.track("$form",
|
|
964
|
+
this.instance.track("$form", M(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
899
965
|
}
|
|
900
966
|
trackFieldChanges(e) {
|
|
901
967
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
902
|
-
i.addEventListener("change", (
|
|
968
|
+
i.addEventListener("change", (n) => {
|
|
903
969
|
const r = this._getFieldProps(
|
|
904
|
-
|
|
970
|
+
n.target
|
|
905
971
|
);
|
|
906
972
|
this.instance.track(
|
|
907
973
|
"$form_field_change",
|
|
908
|
-
|
|
974
|
+
M({
|
|
909
975
|
form_id: e.id,
|
|
910
976
|
form_name: e.name || "",
|
|
911
977
|
field: r
|
|
@@ -915,7 +981,7 @@ class A {
|
|
|
915
981
|
});
|
|
916
982
|
}
|
|
917
983
|
static getInstance(e, t = "all", i = {}) {
|
|
918
|
-
return
|
|
984
|
+
return S.instance || (S.instance = new S(e, t, i)), S.instance;
|
|
919
985
|
}
|
|
920
986
|
_getFormDetails(e) {
|
|
921
987
|
const t = {
|
|
@@ -963,8 +1029,8 @@ class A {
|
|
|
963
1029
|
getSafeText(e) {
|
|
964
1030
|
let t = "";
|
|
965
1031
|
return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
|
|
966
|
-
(
|
|
967
|
-
).map((
|
|
1032
|
+
(n) => n.nodeType === Node.TEXT_NODE
|
|
1033
|
+
).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
|
|
968
1034
|
}
|
|
969
1035
|
_scrubPotentiallySensitiveValues(e) {
|
|
970
1036
|
return this._shouldCaptureValue(e) ? e : "<redacted>";
|
|
@@ -982,7 +1048,7 @@ class A {
|
|
|
982
1048
|
if (typeof String.prototype.trim == "function")
|
|
983
1049
|
return e.trim();
|
|
984
1050
|
let t = 0, i = e.length - 1;
|
|
985
|
-
const
|
|
1051
|
+
const n = [
|
|
986
1052
|
" ",
|
|
987
1053
|
`
|
|
988
1054
|
`,
|
|
@@ -1009,16 +1075,16 @@ class A {
|
|
|
1009
1075
|
" ",
|
|
1010
1076
|
" "
|
|
1011
1077
|
].join("");
|
|
1012
|
-
for (; t <= i &&
|
|
1078
|
+
for (; t <= i && n.indexOf(e[t]) > -1; )
|
|
1013
1079
|
t++;
|
|
1014
|
-
for (; i >= t &&
|
|
1080
|
+
for (; i >= t && n.indexOf(e[i]) > -1; )
|
|
1015
1081
|
i--;
|
|
1016
1082
|
return e.slice(t, i + 1);
|
|
1017
1083
|
}
|
|
1018
1084
|
}
|
|
1019
|
-
class
|
|
1085
|
+
class I {
|
|
1020
1086
|
constructor(e) {
|
|
1021
|
-
this.config = this.mergeConfig(e, Z), this.logger =
|
|
1087
|
+
this.config = this.mergeConfig(e, Z), this.logger = g(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new K(
|
|
1022
1088
|
this.transport,
|
|
1023
1089
|
this.config.maxSendAttempts || 3,
|
|
1024
1090
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1032,9 +1098,9 @@ class N {
|
|
|
1032
1098
|
);
|
|
1033
1099
|
}
|
|
1034
1100
|
initializeBrowserFeatures() {
|
|
1035
|
-
if (this.cookieManager = new
|
|
1101
|
+
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) {
|
|
1036
1102
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
1037
|
-
this.formTracking =
|
|
1103
|
+
this.formTracking = S.getInstance(
|
|
1038
1104
|
this,
|
|
1039
1105
|
e || "none",
|
|
1040
1106
|
{
|
|
@@ -1042,7 +1108,7 @@ class N {
|
|
|
1042
1108
|
}
|
|
1043
1109
|
);
|
|
1044
1110
|
}
|
|
1045
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
1111
|
+
this.config.autoPageview && (this.pageviewTracking = new _e(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ae(this)), this.setupPageLeaveTracking();
|
|
1046
1112
|
}
|
|
1047
1113
|
/**
|
|
1048
1114
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -1051,13 +1117,13 @@ class N {
|
|
|
1051
1117
|
*/
|
|
1052
1118
|
mergeConfig(e, t) {
|
|
1053
1119
|
const i = JSON.parse(JSON.stringify(e));
|
|
1054
|
-
let
|
|
1120
|
+
let n = { ...t, ...i };
|
|
1055
1121
|
return Object.keys(t).forEach((r) => {
|
|
1056
|
-
P(t[r]) && (
|
|
1057
|
-
}),
|
|
1122
|
+
P(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
|
|
1123
|
+
}), n;
|
|
1058
1124
|
}
|
|
1059
1125
|
init(e) {
|
|
1060
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
1126
|
+
this.config = { ...this.config, ...e }, this.logger = g(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new K(
|
|
1061
1127
|
this.transport,
|
|
1062
1128
|
this.config.maxSendAttempts || 3,
|
|
1063
1129
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1076,14 +1142,14 @@ class N {
|
|
|
1076
1142
|
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1077
1143
|
document.addEventListener("click", (i) => {
|
|
1078
1144
|
var a;
|
|
1079
|
-
const
|
|
1080
|
-
if (!
|
|
1081
|
-
const r =
|
|
1145
|
+
const n = this.findClosestLink(i.target);
|
|
1146
|
+
if (!n) return;
|
|
1147
|
+
const r = n.getAttribute("href");
|
|
1082
1148
|
if (!r || !r.startsWith("http")) return;
|
|
1083
1149
|
const o = new URL(r);
|
|
1084
1150
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1085
1151
|
const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
|
|
1086
|
-
l && (o.searchParams.append("_um", l),
|
|
1152
|
+
l && (o.searchParams.append("_um", l), n.setAttribute("href", o.toString()));
|
|
1087
1153
|
}
|
|
1088
1154
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
1089
1155
|
}
|
|
@@ -1096,14 +1162,14 @@ class N {
|
|
|
1096
1162
|
const t = "https://events.usermaven.com";
|
|
1097
1163
|
if (!h())
|
|
1098
1164
|
return new Ce(e.trackingHost || t, e);
|
|
1099
|
-
const i = "XMLHttpRequest" in window,
|
|
1165
|
+
const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1100
1166
|
if (e.useBeaconApi && r)
|
|
1101
1167
|
return new Ee(
|
|
1102
1168
|
e.trackingHost || t,
|
|
1103
1169
|
e,
|
|
1104
1170
|
this.logger
|
|
1105
1171
|
);
|
|
1106
|
-
if (e.forceUseFetch &&
|
|
1172
|
+
if (e.forceUseFetch && n)
|
|
1107
1173
|
return new W(
|
|
1108
1174
|
e.trackingHost || t,
|
|
1109
1175
|
e,
|
|
@@ -1115,7 +1181,7 @@ class N {
|
|
|
1115
1181
|
e,
|
|
1116
1182
|
this.logger
|
|
1117
1183
|
);
|
|
1118
|
-
if (
|
|
1184
|
+
if (n)
|
|
1119
1185
|
return new W(
|
|
1120
1186
|
e.trackingHost || t,
|
|
1121
1187
|
e,
|
|
@@ -1124,13 +1190,13 @@ class N {
|
|
|
1124
1190
|
throw new Error("No suitable transport method available");
|
|
1125
1191
|
}
|
|
1126
1192
|
initializePersistence() {
|
|
1127
|
-
return this.config.disableEventPersistence || !h() ? new
|
|
1193
|
+
return this.config.disableEventPersistence || !h() ? new Se() : new te(
|
|
1128
1194
|
`${this.namespace}_${this.config.key}`,
|
|
1129
1195
|
this.logger
|
|
1130
1196
|
);
|
|
1131
1197
|
}
|
|
1132
1198
|
getOrCreateAnonymousId() {
|
|
1133
|
-
var i,
|
|
1199
|
+
var i, n;
|
|
1134
1200
|
if (!h())
|
|
1135
1201
|
return R();
|
|
1136
1202
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
@@ -1144,7 +1210,7 @@ class N {
|
|
|
1144
1210
|
}
|
|
1145
1211
|
t || (t = R());
|
|
1146
1212
|
const r = 365 * 10;
|
|
1147
|
-
(
|
|
1213
|
+
(n = this.cookieManager) == null || n.set(
|
|
1148
1214
|
e,
|
|
1149
1215
|
t,
|
|
1150
1216
|
r,
|
|
@@ -1163,11 +1229,11 @@ class N {
|
|
|
1163
1229
|
throw new Error("User ID must be a string");
|
|
1164
1230
|
const i = e.id;
|
|
1165
1231
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
1166
|
-
const
|
|
1232
|
+
const n = {
|
|
1167
1233
|
...e,
|
|
1168
1234
|
anonymous_id: this.anonymousId
|
|
1169
1235
|
};
|
|
1170
|
-
await this.track("user_identify",
|
|
1236
|
+
await this.track("user_identify", n);
|
|
1171
1237
|
}
|
|
1172
1238
|
this.logger.info("User identified:", e);
|
|
1173
1239
|
}
|
|
@@ -1184,12 +1250,12 @@ class N {
|
|
|
1184
1250
|
this.logger.error("Lead event requires a valid email attribute");
|
|
1185
1251
|
return;
|
|
1186
1252
|
}
|
|
1187
|
-
const
|
|
1188
|
-
if (!
|
|
1253
|
+
const n = i.trim();
|
|
1254
|
+
if (!n || !J(n)) {
|
|
1189
1255
|
this.logger.error("Lead event requires a valid email attribute");
|
|
1190
1256
|
return;
|
|
1191
1257
|
}
|
|
1192
|
-
e.email =
|
|
1258
|
+
e.email = n, this.track("lead", e, t);
|
|
1193
1259
|
}
|
|
1194
1260
|
trackInternal(e, t, i = !1) {
|
|
1195
1261
|
if (ve()) {
|
|
@@ -1228,7 +1294,7 @@ class N {
|
|
|
1228
1294
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1229
1295
|
}
|
|
1230
1296
|
createEventPayload(e, t) {
|
|
1231
|
-
const i = this.persistence.get("userProps") || {},
|
|
1297
|
+
const i = this.persistence.get("userProps") || {}, n = 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}`) || {};
|
|
1232
1298
|
let l = t || {};
|
|
1233
1299
|
const c = {
|
|
1234
1300
|
event_id: "",
|
|
@@ -1237,7 +1303,7 @@ class N {
|
|
|
1237
1303
|
id: r,
|
|
1238
1304
|
...i
|
|
1239
1305
|
},
|
|
1240
|
-
...
|
|
1306
|
+
...n && { company: n },
|
|
1241
1307
|
ids: this.getThirdPartyIds(),
|
|
1242
1308
|
utc_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1243
1309
|
local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
@@ -1269,8 +1335,8 @@ class N {
|
|
|
1269
1335
|
"$referrer",
|
|
1270
1336
|
"$referring_domain",
|
|
1271
1337
|
"$elements"
|
|
1272
|
-
].forEach((
|
|
1273
|
-
delete t[
|
|
1338
|
+
].forEach((n) => {
|
|
1339
|
+
delete t[n];
|
|
1274
1340
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1275
1341
|
}
|
|
1276
1342
|
getCookie(e) {
|
|
@@ -1293,8 +1359,8 @@ class N {
|
|
|
1293
1359
|
"utm_campaign",
|
|
1294
1360
|
"utm_term",
|
|
1295
1361
|
"utm_content"
|
|
1296
|
-
].forEach((
|
|
1297
|
-
t[
|
|
1362
|
+
].forEach((n) => {
|
|
1363
|
+
t[n] && (e[n.replace("utm_", "")] = t[n]);
|
|
1298
1364
|
}), e;
|
|
1299
1365
|
}
|
|
1300
1366
|
pageview() {
|
|
@@ -1327,9 +1393,9 @@ class N {
|
|
|
1327
1393
|
}), document.addEventListener("visibilitychange", () => {
|
|
1328
1394
|
document.visibilityState === "hidden" && !t && i();
|
|
1329
1395
|
});
|
|
1330
|
-
const
|
|
1396
|
+
const n = history.pushState;
|
|
1331
1397
|
history.pushState = function() {
|
|
1332
|
-
return i(),
|
|
1398
|
+
return i(), n.apply(this, arguments);
|
|
1333
1399
|
}, window.addEventListener("popstate", i);
|
|
1334
1400
|
}
|
|
1335
1401
|
getConfig() {
|
|
@@ -1351,7 +1417,7 @@ class N {
|
|
|
1351
1417
|
set(e, t) {
|
|
1352
1418
|
if (!P(e))
|
|
1353
1419
|
throw new Error("Properties must be an object");
|
|
1354
|
-
const i = t == null ? void 0 : t.eventType,
|
|
1420
|
+
const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1355
1421
|
if (i) {
|
|
1356
1422
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1357
1423
|
r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
|
|
@@ -1359,10 +1425,10 @@ class N {
|
|
|
1359
1425
|
let r = this.persistence.get("global_props") || {};
|
|
1360
1426
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1361
1427
|
}
|
|
1362
|
-
|
|
1428
|
+
n && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1363
1429
|
properties: e,
|
|
1364
1430
|
eventType: i || "global",
|
|
1365
|
-
persist:
|
|
1431
|
+
persist: n
|
|
1366
1432
|
});
|
|
1367
1433
|
}
|
|
1368
1434
|
setUserId(e) {
|
|
@@ -1371,7 +1437,7 @@ class N {
|
|
|
1371
1437
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1372
1438
|
}
|
|
1373
1439
|
unset(e, t) {
|
|
1374
|
-
const i = t == null ? void 0 : t.eventType,
|
|
1440
|
+
const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1375
1441
|
if (i) {
|
|
1376
1442
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1377
1443
|
delete r[e], this.persistence.set(`props_${i}`, r);
|
|
@@ -1379,7 +1445,7 @@ class N {
|
|
|
1379
1445
|
let r = this.persistence.get("global_props") || {};
|
|
1380
1446
|
delete r[e], this.persistence.set("global_props", r);
|
|
1381
1447
|
}
|
|
1382
|
-
|
|
1448
|
+
n && this.persistence.save(), this.logger.debug(
|
|
1383
1449
|
`Property unset: ${e}`,
|
|
1384
1450
|
`Event type: ${i || "global"}`
|
|
1385
1451
|
);
|
|
@@ -1388,12 +1454,12 @@ class N {
|
|
|
1388
1454
|
function ie() {
|
|
1389
1455
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1390
1456
|
}
|
|
1391
|
-
function
|
|
1457
|
+
function $e() {
|
|
1392
1458
|
return ie() ? window.define : void 0;
|
|
1393
1459
|
}
|
|
1394
|
-
const
|
|
1395
|
-
function O(
|
|
1396
|
-
const e = JSON.parse(JSON.stringify(
|
|
1460
|
+
const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1461
|
+
function O(s) {
|
|
1462
|
+
const e = JSON.parse(JSON.stringify(s)), t = F(e), i = {
|
|
1397
1463
|
...Z,
|
|
1398
1464
|
...t
|
|
1399
1465
|
};
|
|
@@ -1401,64 +1467,64 @@ function O(n) {
|
|
|
1401
1467
|
throw new Error("API key is required!");
|
|
1402
1468
|
if (!i.trackingHost)
|
|
1403
1469
|
throw new Error("Tracking host is required!");
|
|
1404
|
-
const
|
|
1470
|
+
const n = i.key || "", r = `${Te}${n}`;
|
|
1405
1471
|
return h() && i.autocapture && window[r] && (console.warn(
|
|
1406
1472
|
"Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
|
|
1407
|
-
), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new
|
|
1473
|
+
), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new I(i);
|
|
1408
1474
|
}
|
|
1409
|
-
function xe(
|
|
1410
|
-
var
|
|
1475
|
+
function xe(s) {
|
|
1476
|
+
var n;
|
|
1411
1477
|
const e = {
|
|
1412
|
-
key:
|
|
1413
|
-
trackingHost:
|
|
1414
|
-
logLevel: ke(
|
|
1415
|
-
autocapture:
|
|
1416
|
-
formTracking:
|
|
1417
|
-
autoPageview:
|
|
1418
|
-
useBeaconApi:
|
|
1419
|
-
forceUseFetch:
|
|
1420
|
-
gaHook:
|
|
1421
|
-
segmentHook:
|
|
1422
|
-
randomizeUrl:
|
|
1423
|
-
capture3rdPartyCookies:
|
|
1424
|
-
idMethod:
|
|
1425
|
-
privacyPolicy:
|
|
1426
|
-
ipPolicy:
|
|
1427
|
-
cookiePolicy:
|
|
1428
|
-
minSendTimeout: parseInt(
|
|
1429
|
-
maxSendTimeout: parseInt(
|
|
1430
|
-
maxSendAttempts: parseInt(
|
|
1478
|
+
key: s.getAttribute("data-key") || void 0,
|
|
1479
|
+
trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1480
|
+
logLevel: ke(s.getAttribute("data-log-level")),
|
|
1481
|
+
autocapture: s.getAttribute("data-autocapture") === "true",
|
|
1482
|
+
formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
|
|
1483
|
+
autoPageview: s.getAttribute("data-auto-pageview") === "true",
|
|
1484
|
+
useBeaconApi: s.getAttribute("data-use-beacon-api") === "true",
|
|
1485
|
+
forceUseFetch: s.getAttribute("data-force-use-fetch") === "true",
|
|
1486
|
+
gaHook: s.getAttribute("data-ga-hook") === "true",
|
|
1487
|
+
segmentHook: s.getAttribute("data-segment-hook") === "true",
|
|
1488
|
+
randomizeUrl: s.getAttribute("data-randomize-url") === "true",
|
|
1489
|
+
capture3rdPartyCookies: s.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
|
|
1490
|
+
idMethod: s.getAttribute("data-id-method") || void 0,
|
|
1491
|
+
privacyPolicy: s.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
|
|
1492
|
+
ipPolicy: s.getAttribute("data-ip-policy") || void 0,
|
|
1493
|
+
cookiePolicy: s.getAttribute("data-cookie-policy") || void 0,
|
|
1494
|
+
minSendTimeout: parseInt(s.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1495
|
+
maxSendTimeout: parseInt(s.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1496
|
+
maxSendAttempts: parseInt(s.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1431
1497
|
propertiesStringMaxLength: parseInt(
|
|
1432
|
-
|
|
1498
|
+
s.getAttribute("data-properties-string-max-length") || "",
|
|
1433
1499
|
10
|
|
1434
1500
|
) || null,
|
|
1435
|
-
propertyBlacklist: ((
|
|
1436
|
-
exclude:
|
|
1437
|
-
namespace:
|
|
1438
|
-
crossDomainLinking:
|
|
1439
|
-
domains:
|
|
1440
|
-
maskAllText:
|
|
1441
|
-
maskAllElementAttributes:
|
|
1501
|
+
propertyBlacklist: ((n = s.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
|
|
1502
|
+
exclude: s.getAttribute("data-exclude") || void 0,
|
|
1503
|
+
namespace: s.getAttribute("data-namespace") || void 0,
|
|
1504
|
+
crossDomainLinking: s.getAttribute("data-cross-domain-linking") !== "false",
|
|
1505
|
+
domains: s.getAttribute("data-domains") || void 0,
|
|
1506
|
+
maskAllText: s.getAttribute("data-mask-all-text") === "true",
|
|
1507
|
+
maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1442
1508
|
};
|
|
1443
1509
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1444
1510
|
const t = O(e), i = e.namespace || "usermaven";
|
|
1445
1511
|
return h() && t.pageview(), He(i, t), t;
|
|
1446
1512
|
}
|
|
1447
|
-
function He(
|
|
1513
|
+
function He(s, e) {
|
|
1448
1514
|
let t = !1;
|
|
1449
|
-
const i = [],
|
|
1515
|
+
const i = [], n = [];
|
|
1450
1516
|
function r() {
|
|
1451
1517
|
for (; i.length > 0; ) {
|
|
1452
1518
|
const u = i.shift();
|
|
1453
1519
|
if (u) {
|
|
1454
|
-
const
|
|
1455
|
-
if (
|
|
1520
|
+
const f = u[u.length - 1];
|
|
1521
|
+
if (f && typeof f.resolve == "function") {
|
|
1456
1522
|
const m = u.pop();
|
|
1457
1523
|
try {
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
} catch (
|
|
1461
|
-
m.reject(
|
|
1524
|
+
const _ = a.apply(null, u);
|
|
1525
|
+
_ && typeof _.then == "function" ? _.then(m.resolve).catch(m.reject) : m.resolve(_);
|
|
1526
|
+
} catch (_) {
|
|
1527
|
+
m.reject(_);
|
|
1462
1528
|
}
|
|
1463
1529
|
} else
|
|
1464
1530
|
try {
|
|
@@ -1470,21 +1536,21 @@ function He(n, e) {
|
|
|
1470
1536
|
}
|
|
1471
1537
|
}
|
|
1472
1538
|
function o() {
|
|
1473
|
-
|
|
1539
|
+
n.forEach((u) => u()), n.length = 0;
|
|
1474
1540
|
}
|
|
1475
1541
|
function a(...u) {
|
|
1476
|
-
const
|
|
1477
|
-
if (
|
|
1478
|
-
typeof u[1] == "function" && (t ? u[1]() :
|
|
1542
|
+
const f = u[0];
|
|
1543
|
+
if (f === "onLoad") {
|
|
1544
|
+
typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
|
|
1479
1545
|
return;
|
|
1480
1546
|
}
|
|
1481
1547
|
if (!t) {
|
|
1482
1548
|
i.push(u);
|
|
1483
1549
|
return;
|
|
1484
1550
|
}
|
|
1485
|
-
if (typeof e[
|
|
1486
|
-
return e[
|
|
1487
|
-
console.error(`Method ${
|
|
1551
|
+
if (typeof e[f] == "function")
|
|
1552
|
+
return e[f].apply(e, u.slice(1));
|
|
1553
|
+
console.error(`Method ${f} not found on UsermavenClient`);
|
|
1488
1554
|
}
|
|
1489
1555
|
const l = ["id", "group", "reset"], c = [
|
|
1490
1556
|
"track",
|
|
@@ -1496,56 +1562,56 @@ function He(n, e) {
|
|
|
1496
1562
|
"setUserId"
|
|
1497
1563
|
];
|
|
1498
1564
|
[...l, ...c].forEach((u) => {
|
|
1499
|
-
a[u] = function(...
|
|
1565
|
+
a[u] = function(...f) {
|
|
1500
1566
|
if (!t) {
|
|
1501
1567
|
if (l.includes(u))
|
|
1502
|
-
return new Promise((
|
|
1503
|
-
i.push([u, ...
|
|
1568
|
+
return new Promise((z, m) => {
|
|
1569
|
+
i.push([u, ...f, { resolve: z, reject: m }]);
|
|
1504
1570
|
});
|
|
1505
|
-
i.push([u, ...
|
|
1571
|
+
i.push([u, ...f]);
|
|
1506
1572
|
return;
|
|
1507
1573
|
}
|
|
1508
1574
|
if (typeof e[u] == "function")
|
|
1509
|
-
return e[u].apply(e,
|
|
1575
|
+
return e[u].apply(e, f);
|
|
1510
1576
|
};
|
|
1511
1577
|
}), a.getConfig = function() {
|
|
1512
1578
|
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1513
|
-
}, window[
|
|
1514
|
-
const p = `${
|
|
1515
|
-
for (window[p] =
|
|
1579
|
+
}, window[s] = a;
|
|
1580
|
+
const p = `${s}Q`, b = window[p] || [];
|
|
1581
|
+
for (window[p] = b, b.push = function(...u) {
|
|
1516
1582
|
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1517
1583
|
}, setTimeout(() => {
|
|
1518
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1519
|
-
}, 0);
|
|
1520
|
-
const u =
|
|
1584
|
+
t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
|
|
1585
|
+
}, 0); b.length > 0; ) {
|
|
1586
|
+
const u = b.shift();
|
|
1521
1587
|
u && i.push(u);
|
|
1522
1588
|
}
|
|
1523
1589
|
}
|
|
1524
|
-
let X = !1,
|
|
1590
|
+
let X = !1, D = null;
|
|
1525
1591
|
if (h()) {
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1592
|
+
const s = $e();
|
|
1593
|
+
s && s("usermaven", [], function() {
|
|
1528
1594
|
return {
|
|
1529
1595
|
usermavenClient: O,
|
|
1530
|
-
UsermavenClient:
|
|
1596
|
+
UsermavenClient: I,
|
|
1531
1597
|
LogLevel: k,
|
|
1532
1598
|
// Expose the script tag client if it exists
|
|
1533
|
-
getScriptTagClient: () =>
|
|
1599
|
+
getScriptTagClient: () => D
|
|
1534
1600
|
};
|
|
1535
|
-
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient =
|
|
1601
|
+
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = I, window.usermavenScriptTagClient = () => D), function(e, t) {
|
|
1536
1602
|
const i = e.currentScript;
|
|
1537
|
-
function
|
|
1603
|
+
function n() {
|
|
1538
1604
|
return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1539
1605
|
}
|
|
1540
1606
|
function r() {
|
|
1541
|
-
|
|
1607
|
+
n() && (console.log("[Usermaven] Auto-initializing from script tag"), D = xe(i), X = !0);
|
|
1542
1608
|
}
|
|
1543
1609
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1544
1610
|
}(document, window);
|
|
1545
1611
|
}
|
|
1546
1612
|
typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
1547
1613
|
usermavenClient: O,
|
|
1548
|
-
UsermavenClient:
|
|
1614
|
+
UsermavenClient: I,
|
|
1549
1615
|
Config: void 0,
|
|
1550
1616
|
UserProps: void 0,
|
|
1551
1617
|
EventPayload: void 0,
|
|
@@ -1554,6 +1620,6 @@ typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
|
1554
1620
|
});
|
|
1555
1621
|
export {
|
|
1556
1622
|
k as LogLevel,
|
|
1557
|
-
|
|
1623
|
+
I as UsermavenClient,
|
|
1558
1624
|
O as usermavenClient
|
|
1559
1625
|
};
|