@usermaven/sdk-js 1.5.10-rc.110 → 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/index.d.ts +1 -1
- 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 +568 -363
- package/dist/utils/queue.d.ts +6 -1
- package/package.json +2 -3
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,
|
|
@@ -32,7 +32,13 @@ const Z = {
|
|
|
32
32
|
gaHook: !1,
|
|
33
33
|
segmentHook: !1,
|
|
34
34
|
randomizeUrl: !1,
|
|
35
|
-
capture3rdPartyCookies: [
|
|
35
|
+
capture3rdPartyCookies: [
|
|
36
|
+
"_ga",
|
|
37
|
+
"_fbp",
|
|
38
|
+
"_ym_uid",
|
|
39
|
+
"ajs_user_id",
|
|
40
|
+
"ajs_anonymous_id"
|
|
41
|
+
],
|
|
36
42
|
idMethod: "cookie",
|
|
37
43
|
ipPolicy: "keep",
|
|
38
44
|
cookiePolicy: "keep",
|
|
@@ -45,20 +51,20 @@ const Z = {
|
|
|
45
51
|
maskAllText: !1,
|
|
46
52
|
maskAllElementAttributes: !1
|
|
47
53
|
};
|
|
48
|
-
class
|
|
54
|
+
class ne {
|
|
49
55
|
constructor(e) {
|
|
50
56
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
51
57
|
}
|
|
52
|
-
set(e, t, i = 365,
|
|
58
|
+
set(e, t, i = 365, n = !0, r = !1) {
|
|
53
59
|
const o = /* @__PURE__ */ new Date();
|
|
54
60
|
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
55
|
-
const a = `expires=${o.toUTCString()}`, l =
|
|
61
|
+
const a = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", c = r ? "; HttpOnly" : "";
|
|
56
62
|
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
|
|
57
63
|
}
|
|
58
64
|
get(e) {
|
|
59
65
|
const t = e + "=", i = document.cookie.split(";");
|
|
60
|
-
for (let
|
|
61
|
-
let r = i[
|
|
66
|
+
for (let n = 0; n < i.length; n++) {
|
|
67
|
+
let r = i[n].trim();
|
|
62
68
|
if (r.indexOf(t) === 0)
|
|
63
69
|
return decodeURIComponent(r.substring(t.length));
|
|
64
70
|
}
|
|
@@ -86,83 +92,83 @@ class se {
|
|
|
86
92
|
}
|
|
87
93
|
extractRootDomain(e) {
|
|
88
94
|
let t = this.extractHostname(e);
|
|
89
|
-
const i = t.split("."),
|
|
90
|
-
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;
|
|
91
97
|
}
|
|
92
98
|
extractTopLevelDomain(e) {
|
|
93
99
|
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
|
|
94
100
|
return i ? i[0] : "";
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype,
|
|
98
|
-
function ce(
|
|
99
|
-
if (Array.isArray(
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
else if ("length" in
|
|
103
|
-
for (let i = 0,
|
|
104
|
-
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)
|
|
105
111
|
return;
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
|
-
const
|
|
110
|
-
return
|
|
111
|
-
}, le = function(
|
|
112
|
-
for (const e in
|
|
113
|
-
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));
|
|
114
120
|
};
|
|
115
|
-
function w(
|
|
116
|
-
if (
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
else if ("length" in
|
|
120
|
-
for (let i = 0,
|
|
121
|
-
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)
|
|
122
128
|
return;
|
|
123
129
|
} else
|
|
124
|
-
for (const i in
|
|
125
|
-
if (oe.call(
|
|
130
|
+
for (const i in s)
|
|
131
|
+
if (oe.call(s, i) && e.call(t, s[i], i) === U)
|
|
126
132
|
return;
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
|
-
const ue = function(
|
|
135
|
+
const ue = function(s, ...e) {
|
|
130
136
|
return ce(e, function(t) {
|
|
131
137
|
for (const i in t)
|
|
132
|
-
t[i] !== void 0 && (
|
|
133
|
-
}),
|
|
138
|
+
t[i] !== void 0 && (s[i] = t[i]);
|
|
139
|
+
}), s;
|
|
134
140
|
};
|
|
135
|
-
function
|
|
136
|
-
return
|
|
141
|
+
function A(s, e) {
|
|
142
|
+
return s.indexOf(e) !== -1;
|
|
137
143
|
}
|
|
138
|
-
const he = function(
|
|
144
|
+
const he = function(s) {
|
|
139
145
|
try {
|
|
140
|
-
return /^\s*\bfunction\b/.test(
|
|
146
|
+
return /^\s*\bfunction\b/.test(s);
|
|
141
147
|
} catch {
|
|
142
148
|
return !1;
|
|
143
149
|
}
|
|
144
|
-
}, de = function(
|
|
145
|
-
return
|
|
150
|
+
}, de = function(s) {
|
|
151
|
+
return s === void 0;
|
|
146
152
|
}, E = function() {
|
|
147
|
-
const
|
|
153
|
+
const s = function(i, n, r, o, a) {
|
|
148
154
|
if (!i) {
|
|
149
|
-
|
|
155
|
+
g().error("No valid element provided to register_event");
|
|
150
156
|
return;
|
|
151
157
|
}
|
|
152
158
|
if (i.addEventListener && !o)
|
|
153
|
-
i.addEventListener(
|
|
159
|
+
i.addEventListener(n, r, !!a);
|
|
154
160
|
else {
|
|
155
|
-
const l = "on" +
|
|
161
|
+
const l = "on" + n, c = i[l];
|
|
156
162
|
i[l] = e(i, r, c);
|
|
157
163
|
}
|
|
158
164
|
};
|
|
159
|
-
function e(i,
|
|
165
|
+
function e(i, n, r) {
|
|
160
166
|
return function(o) {
|
|
161
167
|
if (o = o || t(window.event), !o)
|
|
162
168
|
return;
|
|
163
169
|
let a = !0, l;
|
|
164
170
|
he(r) && (l = r(o));
|
|
165
|
-
const c =
|
|
171
|
+
const c = n.call(i, o);
|
|
166
172
|
return (l === !1 || c === !1) && (a = !1), a;
|
|
167
173
|
};
|
|
168
174
|
}
|
|
@@ -173,88 +179,102 @@ const he = function(n) {
|
|
|
173
179
|
this.returnValue = !1;
|
|
174
180
|
}, t.stopPropagation = function() {
|
|
175
181
|
this.cancelBubble = !0;
|
|
176
|
-
},
|
|
177
|
-
}(),
|
|
182
|
+
}, s;
|
|
183
|
+
}(), ge = function(s) {
|
|
178
184
|
return function(...e) {
|
|
179
185
|
try {
|
|
180
|
-
return
|
|
186
|
+
return s.apply(this, e);
|
|
181
187
|
} catch (t) {
|
|
182
|
-
|
|
188
|
+
g().error(
|
|
189
|
+
"Implementation error. Please turn on debug and contact support@usermaven.com.",
|
|
190
|
+
t
|
|
191
|
+
);
|
|
183
192
|
}
|
|
184
193
|
};
|
|
185
|
-
}, Y = function(
|
|
186
|
-
for (const e in
|
|
187
|
-
typeof
|
|
194
|
+
}, Y = function(s) {
|
|
195
|
+
for (const e in s)
|
|
196
|
+
typeof s[e] == "function" && (s[e] = ge(s[e]));
|
|
188
197
|
};
|
|
189
|
-
function
|
|
190
|
-
for (let e in
|
|
191
|
-
(
|
|
192
|
-
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;
|
|
193
202
|
}
|
|
194
203
|
function h() {
|
|
195
204
|
try {
|
|
196
205
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
197
206
|
} catch {
|
|
198
|
-
return
|
|
207
|
+
return g().warn("window is not available"), !1;
|
|
199
208
|
}
|
|
200
209
|
}
|
|
201
|
-
function v(
|
|
202
|
-
const e = new Uint8Array(
|
|
203
|
-
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);
|
|
204
213
|
}
|
|
205
|
-
function
|
|
206
|
-
return
|
|
214
|
+
function fe(s) {
|
|
215
|
+
return s.replace(
|
|
207
216
|
/([-_][a-z])/g,
|
|
208
217
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
209
218
|
);
|
|
210
219
|
}
|
|
211
|
-
function
|
|
212
|
-
return typeof
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
function F(s) {
|
|
221
|
+
return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(F) : Object.keys(s).reduce(
|
|
222
|
+
(e, t) => {
|
|
223
|
+
const i = fe(t);
|
|
224
|
+
return e[i] = F(s[t]), e;
|
|
225
|
+
},
|
|
226
|
+
{}
|
|
227
|
+
);
|
|
216
228
|
}
|
|
217
|
-
function x(
|
|
218
|
-
switch (typeof
|
|
229
|
+
function x(s) {
|
|
230
|
+
switch (typeof s.className) {
|
|
219
231
|
case "string":
|
|
220
|
-
return
|
|
232
|
+
return s.className;
|
|
221
233
|
case "object":
|
|
222
|
-
return ("baseVal" in
|
|
234
|
+
return ("baseVal" in s.className ? s.className.baseVal : null) || s.getAttribute("class") || "";
|
|
223
235
|
default:
|
|
224
236
|
return "";
|
|
225
237
|
}
|
|
226
238
|
}
|
|
227
|
-
function
|
|
239
|
+
function V(s) {
|
|
228
240
|
let e = "";
|
|
229
|
-
return
|
|
230
|
-
j(t) && t.textContent && (e +=
|
|
231
|
-
}),
|
|
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);
|
|
232
244
|
}
|
|
233
|
-
function G(
|
|
234
|
-
return !!
|
|
245
|
+
function G(s) {
|
|
246
|
+
return !!s && s.nodeType === 1;
|
|
235
247
|
}
|
|
236
|
-
function y(
|
|
237
|
-
return !!
|
|
248
|
+
function y(s, e) {
|
|
249
|
+
return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
|
|
238
250
|
}
|
|
239
|
-
function j(
|
|
240
|
-
return !!
|
|
251
|
+
function j(s) {
|
|
252
|
+
return !!s && s.nodeType === 3;
|
|
241
253
|
}
|
|
242
|
-
function
|
|
243
|
-
return !!
|
|
254
|
+
function Q(s) {
|
|
255
|
+
return !!s && s.nodeType === 11;
|
|
244
256
|
}
|
|
245
|
-
const C = [
|
|
246
|
-
|
|
247
|
-
|
|
257
|
+
const C = [
|
|
258
|
+
"a",
|
|
259
|
+
"button",
|
|
260
|
+
"form",
|
|
261
|
+
"input",
|
|
262
|
+
"select",
|
|
263
|
+
"textarea",
|
|
264
|
+
"label"
|
|
265
|
+
];
|
|
266
|
+
function pe(s, e) {
|
|
267
|
+
if (!s || y(s, "html") || !G(s))
|
|
248
268
|
return !1;
|
|
249
|
-
let t =
|
|
269
|
+
let t = s;
|
|
250
270
|
for (; t && !y(t, "body"); ) {
|
|
251
271
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
252
272
|
return !1;
|
|
253
|
-
t.parentNode &&
|
|
273
|
+
t.parentNode && Q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
254
274
|
}
|
|
255
275
|
let i = !1;
|
|
256
|
-
for (t =
|
|
257
|
-
if (t.parentNode &&
|
|
276
|
+
for (t = s; t && !y(t, "body"); ) {
|
|
277
|
+
if (t.parentNode && Q(t.parentNode)) {
|
|
258
278
|
t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
259
279
|
continue;
|
|
260
280
|
}
|
|
@@ -268,10 +288,10 @@ function pe(n, e) {
|
|
|
268
288
|
}
|
|
269
289
|
t = o;
|
|
270
290
|
}
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
291
|
+
const n = window.getComputedStyle(s);
|
|
292
|
+
if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
|
|
273
293
|
return !0;
|
|
274
|
-
const r =
|
|
294
|
+
const r = s.tagName.toLowerCase();
|
|
275
295
|
switch (r) {
|
|
276
296
|
case "html":
|
|
277
297
|
return !1;
|
|
@@ -283,18 +303,18 @@ function pe(n, e) {
|
|
|
283
303
|
case "textarea":
|
|
284
304
|
return e.type === "change" || e.type === "click";
|
|
285
305
|
default:
|
|
286
|
-
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");
|
|
287
307
|
}
|
|
288
308
|
}
|
|
289
|
-
function
|
|
290
|
-
for (let i =
|
|
291
|
-
const
|
|
292
|
-
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"))
|
|
293
313
|
return !1;
|
|
294
314
|
}
|
|
295
|
-
if (
|
|
315
|
+
if (A(x(s).split(" "), "ph-include"))
|
|
296
316
|
return !0;
|
|
297
|
-
const e =
|
|
317
|
+
const e = s.type || "";
|
|
298
318
|
if (typeof e == "string")
|
|
299
319
|
switch (e.toLowerCase()) {
|
|
300
320
|
case "hidden":
|
|
@@ -302,59 +322,59 @@ function B(n) {
|
|
|
302
322
|
case "password":
|
|
303
323
|
return !1;
|
|
304
324
|
}
|
|
305
|
-
const t =
|
|
325
|
+
const t = s.name || s.id || "";
|
|
306
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, "")));
|
|
307
327
|
}
|
|
308
|
-
function ee(
|
|
328
|
+
function ee(s) {
|
|
309
329
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
310
|
-
return !!(y(
|
|
330
|
+
return !!(y(s, "input") && !e.includes(s.type) || y(s, "select") || y(s, "textarea") || s.getAttribute("contenteditable") === "true");
|
|
311
331
|
}
|
|
312
|
-
function
|
|
313
|
-
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)));
|
|
314
334
|
}
|
|
315
|
-
function me(
|
|
316
|
-
return typeof
|
|
335
|
+
function me(s) {
|
|
336
|
+
return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
|
|
317
337
|
}
|
|
318
338
|
function R() {
|
|
319
339
|
return v(10);
|
|
320
340
|
}
|
|
321
|
-
function J(
|
|
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(
|
|
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());
|
|
323
343
|
}
|
|
324
|
-
function ye(
|
|
344
|
+
function ye(s, e) {
|
|
325
345
|
let t;
|
|
326
346
|
return function(...i) {
|
|
327
|
-
const
|
|
328
|
-
clearTimeout(t),
|
|
347
|
+
const n = () => {
|
|
348
|
+
clearTimeout(t), s(...i);
|
|
329
349
|
};
|
|
330
|
-
clearTimeout(t), t = setTimeout(
|
|
350
|
+
clearTimeout(t), t = setTimeout(n, e);
|
|
331
351
|
};
|
|
332
352
|
}
|
|
333
|
-
function we(
|
|
334
|
-
const e = {}, t =
|
|
353
|
+
function we(s) {
|
|
354
|
+
const e = {}, t = s.replace(/^\?/, "").split("&");
|
|
335
355
|
for (let i = 0; i < t.length; i++) {
|
|
336
|
-
const
|
|
337
|
-
|
|
356
|
+
const n = t[i].split("=");
|
|
357
|
+
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
338
358
|
}
|
|
339
359
|
return e;
|
|
340
360
|
}
|
|
341
|
-
function L(
|
|
342
|
-
return typeof
|
|
361
|
+
function L(s) {
|
|
362
|
+
return typeof s == "string" || s instanceof String;
|
|
343
363
|
}
|
|
344
|
-
function P(
|
|
345
|
-
return
|
|
364
|
+
function P(s) {
|
|
365
|
+
return s !== null && typeof s == "object" && s.constructor === Object;
|
|
346
366
|
}
|
|
347
|
-
function ke(
|
|
348
|
-
if (
|
|
367
|
+
function ke(s) {
|
|
368
|
+
if (s === null)
|
|
349
369
|
return k.ERROR;
|
|
350
|
-
const e =
|
|
370
|
+
const e = s.toUpperCase(), t = k[e];
|
|
351
371
|
return t || t === 0 ? t : k.ERROR;
|
|
352
372
|
}
|
|
353
373
|
const ve = () => {
|
|
354
|
-
let
|
|
355
|
-
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");
|
|
356
376
|
};
|
|
357
|
-
class
|
|
377
|
+
class be {
|
|
358
378
|
constructor(e) {
|
|
359
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();
|
|
360
380
|
}
|
|
@@ -380,8 +400,8 @@ class _e {
|
|
|
380
400
|
this.track();
|
|
381
401
|
}
|
|
382
402
|
getScrollDepth() {
|
|
383
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(),
|
|
384
|
-
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));
|
|
385
405
|
}
|
|
386
406
|
getWindowHeight() {
|
|
387
407
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -400,17 +420,19 @@ class _e {
|
|
|
400
420
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
401
421
|
}
|
|
402
422
|
checkMilestones(e) {
|
|
403
|
-
this.milestones.filter(
|
|
404
|
-
|
|
423
|
+
this.milestones.filter(
|
|
424
|
+
(i) => e >= i
|
|
425
|
+
).forEach((i) => {
|
|
426
|
+
this.send(), this.milestones = this.milestones.filter((n) => n !== i);
|
|
405
427
|
});
|
|
406
428
|
}
|
|
407
429
|
destroy() {
|
|
408
430
|
window.removeEventListener("scroll", this.debouncedHandleScroll);
|
|
409
431
|
}
|
|
410
432
|
}
|
|
411
|
-
const
|
|
412
|
-
constructor(e, t, i =
|
|
413
|
-
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);
|
|
414
436
|
}
|
|
415
437
|
isBrowserSupported() {
|
|
416
438
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -425,7 +447,9 @@ const I = class I {
|
|
|
425
447
|
return;
|
|
426
448
|
}
|
|
427
449
|
if (!(document && document.body)) {
|
|
428
|
-
this.logger.debug(
|
|
450
|
+
this.logger.debug(
|
|
451
|
+
"Document not ready yet, trying again in 500 milliseconds..."
|
|
452
|
+
), setTimeout(() => this.init(), 500);
|
|
429
453
|
return;
|
|
430
454
|
}
|
|
431
455
|
this.addDomEventHandlers(), this.domHandlersAttached = !0;
|
|
@@ -445,17 +469,17 @@ const I = class I {
|
|
|
445
469
|
return performance.navigation && performance.navigation.type === 1;
|
|
446
470
|
}
|
|
447
471
|
captureEvent(e) {
|
|
448
|
-
var i,
|
|
472
|
+
var i, n;
|
|
449
473
|
let t = this.getEventTarget(e);
|
|
450
474
|
if (j(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
451
475
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
452
476
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
453
|
-
return this.isPageRefresh() || (
|
|
477
|
+
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
454
478
|
if (t && pe(t, e)) {
|
|
455
479
|
const r = [t];
|
|
456
480
|
let o = t;
|
|
457
481
|
for (; o.parentNode && !y(o, "body"); ) {
|
|
458
|
-
if (
|
|
482
|
+
if (Q(o.parentNode)) {
|
|
459
483
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
460
484
|
continue;
|
|
461
485
|
}
|
|
@@ -464,17 +488,17 @@ const I = class I {
|
|
|
464
488
|
const a = [];
|
|
465
489
|
let l, c = !1;
|
|
466
490
|
if (w(r, (p) => {
|
|
467
|
-
const
|
|
468
|
-
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);
|
|
469
493
|
const u = x(p).split(" ");
|
|
470
|
-
|
|
494
|
+
A(u, "ph-no-capture") && (c = !0), a.push(
|
|
471
495
|
this.getPropertiesFromElement(
|
|
472
496
|
p,
|
|
473
497
|
this.options.maskAllElementAttributes ?? !1,
|
|
474
498
|
this.options.maskAllText ?? !1
|
|
475
499
|
)
|
|
476
500
|
);
|
|
477
|
-
}), this.options.maskAllText || (a[0].$el_text =
|
|
501
|
+
}), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
|
|
478
502
|
return !1;
|
|
479
503
|
const d = ue(
|
|
480
504
|
this.getDefaultProperties(e.type),
|
|
@@ -489,35 +513,38 @@ const I = class I {
|
|
|
489
513
|
getCustomProperties(e) {
|
|
490
514
|
const t = {};
|
|
491
515
|
return w(this.customProperties, (i) => {
|
|
492
|
-
w(i.event_selectors, (
|
|
493
|
-
const r = document.querySelectorAll(
|
|
516
|
+
w(i.event_selectors, (n) => {
|
|
517
|
+
const r = document.querySelectorAll(n);
|
|
494
518
|
w(r, (o) => {
|
|
495
|
-
|
|
519
|
+
A(e, o) && q(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
496
520
|
});
|
|
497
521
|
});
|
|
498
522
|
}), t;
|
|
499
523
|
}
|
|
500
524
|
extractCustomPropertyValue(e) {
|
|
501
525
|
const t = [];
|
|
502
|
-
return w(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
526
|
+
return w(
|
|
527
|
+
document.querySelectorAll(e.css_selector),
|
|
528
|
+
function(i) {
|
|
529
|
+
let n;
|
|
530
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), $(n) && t.push(n);
|
|
531
|
+
}
|
|
532
|
+
), t.join(", ");
|
|
506
533
|
}
|
|
507
534
|
getEventTarget(e) {
|
|
508
535
|
var t;
|
|
509
536
|
return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
510
537
|
}
|
|
511
538
|
getPropertiesFromElement(e, t, i) {
|
|
512
|
-
const
|
|
513
|
-
tag_name:
|
|
539
|
+
const n = e.tagName.toLowerCase(), r = {
|
|
540
|
+
tag_name: n
|
|
514
541
|
};
|
|
515
|
-
C.indexOf(
|
|
542
|
+
C.indexOf(n) > -1 && !i && (r.$el_text = V(e));
|
|
516
543
|
const o = x(e);
|
|
517
544
|
o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
|
|
518
545
|
return d !== "";
|
|
519
546
|
})), w(e.attributes, function(d) {
|
|
520
|
-
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);
|
|
521
548
|
});
|
|
522
549
|
let a = 1, l = 1, c = e;
|
|
523
550
|
for (; c = this.previousElementSibling(c); )
|
|
@@ -547,15 +574,15 @@ const I = class I {
|
|
|
547
574
|
static enabledForProject(e, t = 10, i = 10) {
|
|
548
575
|
if (!e)
|
|
549
576
|
return !1;
|
|
550
|
-
let
|
|
577
|
+
let n = 0;
|
|
551
578
|
for (let r = 0; r < e.length; r++)
|
|
552
|
-
|
|
553
|
-
return
|
|
579
|
+
n += e.charCodeAt(r);
|
|
580
|
+
return n % t < i;
|
|
554
581
|
}
|
|
555
582
|
};
|
|
556
|
-
|
|
557
|
-
let H =
|
|
558
|
-
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 {
|
|
559
586
|
constructor(e) {
|
|
560
587
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
561
588
|
}
|
|
@@ -585,43 +612,47 @@ class be {
|
|
|
585
612
|
}
|
|
586
613
|
}
|
|
587
614
|
class Ee {
|
|
588
|
-
constructor(e, t, i =
|
|
615
|
+
constructor(e, t, i = g()) {
|
|
589
616
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
590
617
|
}
|
|
591
618
|
async send(e) {
|
|
592
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
593
|
-
|
|
594
|
-
|
|
619
|
+
const t = this.config.key, i = this.constructUrl(t), n = new Blob([JSON.stringify(e)], {
|
|
620
|
+
type: "application/json"
|
|
621
|
+
});
|
|
622
|
+
if (navigator.sendBeacon(i, n))
|
|
623
|
+
this.logger.debug(
|
|
624
|
+
`Successfully queued ${e.length} event(s) via Beacon API`
|
|
625
|
+
);
|
|
595
626
|
else
|
|
596
627
|
throw new Error("Failed to queue events via Beacon API");
|
|
597
628
|
}
|
|
598
629
|
constructUrl(e) {
|
|
599
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
600
|
-
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}`;
|
|
601
632
|
}
|
|
602
633
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
603
634
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
604
635
|
}
|
|
605
636
|
class W {
|
|
606
|
-
constructor(e, t, i =
|
|
637
|
+
constructor(e, t, i = g()) {
|
|
607
638
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
608
639
|
}
|
|
609
640
|
async send(e) {
|
|
610
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
641
|
+
const t = this.config.key, i = this.constructUrl(t), n = JSON.stringify(e), r = {
|
|
611
642
|
"Content-Type": "application/json",
|
|
612
643
|
...this.getCustomHeaders()
|
|
613
644
|
}, o = await fetch(i, {
|
|
614
645
|
method: "POST",
|
|
615
646
|
headers: r,
|
|
616
|
-
body:
|
|
647
|
+
body: n
|
|
617
648
|
});
|
|
618
649
|
if (!o.ok)
|
|
619
650
|
throw new Error(`HTTP error! status: ${o.status}`);
|
|
620
651
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
621
652
|
}
|
|
622
653
|
constructUrl(e) {
|
|
623
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
624
|
-
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}`;
|
|
625
656
|
}
|
|
626
657
|
getCustomHeaders() {
|
|
627
658
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -631,26 +662,26 @@ class W {
|
|
|
631
662
|
}
|
|
632
663
|
}
|
|
633
664
|
class Pe {
|
|
634
|
-
constructor(e, t, i =
|
|
665
|
+
constructor(e, t, i = g()) {
|
|
635
666
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
636
667
|
}
|
|
637
668
|
send(e) {
|
|
638
669
|
return new Promise((t, i) => {
|
|
639
|
-
const
|
|
640
|
-
|
|
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");
|
|
641
672
|
const a = this.getCustomHeaders();
|
|
642
673
|
Object.keys(a).forEach((l) => {
|
|
643
|
-
|
|
644
|
-
}),
|
|
645
|
-
|
|
646
|
-
},
|
|
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 = () => {
|
|
647
678
|
i(new Error("Network error"));
|
|
648
|
-
},
|
|
679
|
+
}, n.send(JSON.stringify(e));
|
|
649
680
|
});
|
|
650
681
|
}
|
|
651
682
|
constructUrl(e) {
|
|
652
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
653
|
-
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}`;
|
|
654
685
|
}
|
|
655
686
|
getCustomHeaders() {
|
|
656
687
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -661,7 +692,7 @@ class Pe {
|
|
|
661
692
|
}
|
|
662
693
|
class te {
|
|
663
694
|
constructor(e, t) {
|
|
664
|
-
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();
|
|
665
696
|
}
|
|
666
697
|
set(e, t) {
|
|
667
698
|
this.storage[e] = t, this.save();
|
|
@@ -675,16 +706,8 @@ class te {
|
|
|
675
706
|
clear() {
|
|
676
707
|
this.storage = {}, this.save();
|
|
677
708
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
this.logger.warn("localStorage is not available in this environment");
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
try {
|
|
684
|
-
localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage));
|
|
685
|
-
} catch (e) {
|
|
686
|
-
this.logger.error("Error saving to localStorage:", e);
|
|
687
|
-
}
|
|
709
|
+
isStorageEnabled() {
|
|
710
|
+
return !this.storageDisabled;
|
|
688
711
|
}
|
|
689
712
|
load() {
|
|
690
713
|
if (!h()) {
|
|
@@ -695,11 +718,32 @@ class te {
|
|
|
695
718
|
const e = localStorage.getItem(this.prefix + "data");
|
|
696
719
|
e && (this.storage = JSON.parse(e));
|
|
697
720
|
} catch (e) {
|
|
698
|
-
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);
|
|
699
722
|
}
|
|
700
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;
|
|
733
|
+
}
|
|
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
|
+
}
|
|
701
745
|
}
|
|
702
|
-
class
|
|
746
|
+
class Se {
|
|
703
747
|
constructor() {
|
|
704
748
|
this.storage = {};
|
|
705
749
|
}
|
|
@@ -719,13 +763,18 @@ class Ae {
|
|
|
719
763
|
}
|
|
720
764
|
}
|
|
721
765
|
class K {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
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(
|
|
768
|
+
`offline_queue_${a}`
|
|
769
|
+
), this.maxQueueItems = l, this.maxQueueBytes = c, h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
725
770
|
}
|
|
726
771
|
add(e) {
|
|
727
|
-
const t = {
|
|
728
|
-
|
|
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();
|
|
729
778
|
}
|
|
730
779
|
initNetworkListeners() {
|
|
731
780
|
h() && (window.addEventListener("online", () => {
|
|
@@ -735,14 +784,24 @@ class K {
|
|
|
735
784
|
}));
|
|
736
785
|
}
|
|
737
786
|
scheduleBatch() {
|
|
738
|
-
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
787
|
+
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
788
|
+
() => this.processBatch(),
|
|
789
|
+
this.batchInterval
|
|
790
|
+
));
|
|
739
791
|
}
|
|
740
792
|
async processBatch() {
|
|
741
793
|
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
742
794
|
this.processing = !0;
|
|
743
|
-
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);
|
|
744
801
|
try {
|
|
745
|
-
await this.transport.send(t), this.logger.debug(
|
|
802
|
+
await this.transport.send(t), this.logger.debug(
|
|
803
|
+
`Successfully sent batch of ${e.length} payloads`
|
|
804
|
+
), h() && this.saveQueueToStorage();
|
|
746
805
|
} catch (i) {
|
|
747
806
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
748
807
|
}
|
|
@@ -752,20 +811,68 @@ class K {
|
|
|
752
811
|
}
|
|
753
812
|
async handleBatchFailure(e) {
|
|
754
813
|
for (const t of e)
|
|
755
|
-
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(
|
|
815
|
+
"Max retries reached, discarding payload",
|
|
816
|
+
t.payload
|
|
817
|
+
);
|
|
756
818
|
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
757
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
|
+
}
|
|
758
850
|
loadQueueFromStorage() {
|
|
759
851
|
if (h()) {
|
|
760
852
|
const e = this.persistence.get("queue");
|
|
761
|
-
|
|
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
|
+
}
|
|
762
866
|
}
|
|
763
867
|
}
|
|
764
868
|
saveQueueToStorage() {
|
|
765
|
-
|
|
869
|
+
if (h()) {
|
|
870
|
+
const e = this.queue.map(({ bytes: t, ...i }) => i);
|
|
871
|
+
this.persistence.set("queue", JSON.stringify(e));
|
|
872
|
+
}
|
|
766
873
|
}
|
|
767
874
|
}
|
|
768
|
-
class
|
|
875
|
+
class Ae {
|
|
769
876
|
constructor(e) {
|
|
770
877
|
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
|
|
771
878
|
}
|
|
@@ -780,15 +887,19 @@ class Se {
|
|
|
780
887
|
return !e.closest(".um-no-capture");
|
|
781
888
|
}
|
|
782
889
|
click(e, t, i) {
|
|
783
|
-
const
|
|
784
|
-
this.clicks.push(
|
|
890
|
+
const n = { x: e, y: t, timestamp: i };
|
|
891
|
+
this.clicks.push(n), this.clicks = this.clicks.filter(
|
|
892
|
+
(r) => i - r.timestamp < this.timeWindow
|
|
893
|
+
), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
785
894
|
}
|
|
786
895
|
checkRageClick() {
|
|
787
896
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
788
897
|
this.clicks.every((r, o) => {
|
|
789
898
|
if (o === 0) return !0;
|
|
790
899
|
const a = this.clicks[o - 1];
|
|
791
|
-
return Math.sqrt(
|
|
900
|
+
return Math.sqrt(
|
|
901
|
+
Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)
|
|
902
|
+
) < this.distanceThreshold;
|
|
792
903
|
}) && this.sendRageClickEvent(i);
|
|
793
904
|
}
|
|
794
905
|
sendRageClickEvent(e) {
|
|
@@ -800,11 +911,11 @@ class Se {
|
|
|
800
911
|
}
|
|
801
912
|
}
|
|
802
913
|
class Ce {
|
|
803
|
-
constructor(e, t, i =
|
|
914
|
+
constructor(e, t, i = g()) {
|
|
804
915
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
805
916
|
}
|
|
806
917
|
async send(e) {
|
|
807
|
-
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 = {
|
|
808
919
|
hostname: i.hostname,
|
|
809
920
|
port: 443,
|
|
810
921
|
path: `${i.pathname}${i.search}`,
|
|
@@ -815,7 +926,7 @@ class Ce {
|
|
|
815
926
|
}
|
|
816
927
|
};
|
|
817
928
|
return new Promise((r, o) => {
|
|
818
|
-
const a = (void 0)(
|
|
929
|
+
const a = (void 0)(n, (l) => {
|
|
819
930
|
l.on("data", (c) => {
|
|
820
931
|
}), l.on("end", () => {
|
|
821
932
|
const c = l.statusCode || 0;
|
|
@@ -835,7 +946,7 @@ class Ce {
|
|
|
835
946
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
836
947
|
}
|
|
837
948
|
}
|
|
838
|
-
class
|
|
949
|
+
class S {
|
|
839
950
|
constructor(e, t = "all", i = {}) {
|
|
840
951
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
841
952
|
}
|
|
@@ -850,22 +961,27 @@ class A {
|
|
|
850
961
|
}
|
|
851
962
|
handleFormSubmit(e) {
|
|
852
963
|
const t = e.target, i = this._getFormDetails(t);
|
|
853
|
-
this.instance.track("$form",
|
|
964
|
+
this.instance.track("$form", M(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
854
965
|
}
|
|
855
966
|
trackFieldChanges(e) {
|
|
856
967
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
857
|
-
i.addEventListener("change", (
|
|
858
|
-
const r = this._getFieldProps(
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
968
|
+
i.addEventListener("change", (n) => {
|
|
969
|
+
const r = this._getFieldProps(
|
|
970
|
+
n.target
|
|
971
|
+
);
|
|
972
|
+
this.instance.track(
|
|
973
|
+
"$form_field_change",
|
|
974
|
+
M({
|
|
975
|
+
form_id: e.id,
|
|
976
|
+
form_name: e.name || "",
|
|
977
|
+
field: r
|
|
978
|
+
})
|
|
979
|
+
);
|
|
864
980
|
});
|
|
865
981
|
});
|
|
866
982
|
}
|
|
867
983
|
static getInstance(e, t = "all", i = {}) {
|
|
868
|
-
return
|
|
984
|
+
return S.instance || (S.instance = new S(e, t, i)), S.instance;
|
|
869
985
|
}
|
|
870
986
|
_getFormDetails(e) {
|
|
871
987
|
const t = {
|
|
@@ -876,11 +992,17 @@ class A {
|
|
|
876
992
|
form_class: e.className,
|
|
877
993
|
form_attributes: this._getElementAttributes(e),
|
|
878
994
|
fields: []
|
|
879
|
-
}, i = e.querySelectorAll(
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
995
|
+
}, i = e.querySelectorAll(
|
|
996
|
+
"input, select, textarea"
|
|
997
|
+
);
|
|
998
|
+
return Array.from(i).filter(
|
|
999
|
+
(r) => !r.classList.contains("um-no-capture")
|
|
1000
|
+
).forEach(
|
|
1001
|
+
(r) => {
|
|
1002
|
+
const o = this._getFieldProps(r);
|
|
1003
|
+
t.fields.push(o);
|
|
1004
|
+
}
|
|
1005
|
+
), t;
|
|
884
1006
|
}
|
|
885
1007
|
_getFieldProps(e) {
|
|
886
1008
|
const t = Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : void 0, i = this.getSafeText(e);
|
|
@@ -907,8 +1029,8 @@ class A {
|
|
|
907
1029
|
getSafeText(e) {
|
|
908
1030
|
let t = "";
|
|
909
1031
|
return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
|
|
910
|
-
(
|
|
911
|
-
).map((
|
|
1032
|
+
(n) => n.nodeType === Node.TEXT_NODE
|
|
1033
|
+
).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
|
|
912
1034
|
}
|
|
913
1035
|
_scrubPotentiallySensitiveValues(e) {
|
|
914
1036
|
return this._shouldCaptureValue(e) ? e : "<redacted>";
|
|
@@ -926,7 +1048,7 @@ class A {
|
|
|
926
1048
|
if (typeof String.prototype.trim == "function")
|
|
927
1049
|
return e.trim();
|
|
928
1050
|
let t = 0, i = e.length - 1;
|
|
929
|
-
const
|
|
1051
|
+
const n = [
|
|
930
1052
|
" ",
|
|
931
1053
|
`
|
|
932
1054
|
`,
|
|
@@ -953,16 +1075,16 @@ class A {
|
|
|
953
1075
|
" ",
|
|
954
1076
|
" "
|
|
955
1077
|
].join("");
|
|
956
|
-
for (; t <= i &&
|
|
1078
|
+
for (; t <= i && n.indexOf(e[t]) > -1; )
|
|
957
1079
|
t++;
|
|
958
|
-
for (; i >= t &&
|
|
1080
|
+
for (; i >= t && n.indexOf(e[i]) > -1; )
|
|
959
1081
|
i--;
|
|
960
1082
|
return e.slice(t, i + 1);
|
|
961
1083
|
}
|
|
962
1084
|
}
|
|
963
|
-
class
|
|
1085
|
+
class I {
|
|
964
1086
|
constructor(e) {
|
|
965
|
-
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(
|
|
966
1088
|
this.transport,
|
|
967
1089
|
this.config.maxSendAttempts || 3,
|
|
968
1090
|
this.config.minSendTimeout || 1e3,
|
|
@@ -971,16 +1093,22 @@ class N {
|
|
|
971
1093
|
// Reduced interval to .2 second
|
|
972
1094
|
this.logger,
|
|
973
1095
|
this.namespace
|
|
974
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1096
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1097
|
+
`Usermaven client initialized for namespace: ${this.namespace}`
|
|
1098
|
+
);
|
|
975
1099
|
}
|
|
976
1100
|
initializeBrowserFeatures() {
|
|
977
|
-
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) {
|
|
978
1102
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
979
|
-
this.formTracking =
|
|
980
|
-
|
|
981
|
-
|
|
1103
|
+
this.formTracking = S.getInstance(
|
|
1104
|
+
this,
|
|
1105
|
+
e || "none",
|
|
1106
|
+
{
|
|
1107
|
+
trackFieldChanges: !1
|
|
1108
|
+
}
|
|
1109
|
+
);
|
|
982
1110
|
}
|
|
983
|
-
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();
|
|
984
1112
|
}
|
|
985
1113
|
/**
|
|
986
1114
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -989,13 +1117,13 @@ class N {
|
|
|
989
1117
|
*/
|
|
990
1118
|
mergeConfig(e, t) {
|
|
991
1119
|
const i = JSON.parse(JSON.stringify(e));
|
|
992
|
-
let
|
|
1120
|
+
let n = { ...t, ...i };
|
|
993
1121
|
return Object.keys(t).forEach((r) => {
|
|
994
|
-
P(t[r]) && (
|
|
995
|
-
}),
|
|
1122
|
+
P(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
|
|
1123
|
+
}), n;
|
|
996
1124
|
}
|
|
997
1125
|
init(e) {
|
|
998
|
-
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(
|
|
999
1127
|
this.transport,
|
|
1000
1128
|
this.config.maxSendAttempts || 3,
|
|
1001
1129
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1004,7 +1132,9 @@ class N {
|
|
|
1004
1132
|
// Reduced interval to .25 second
|
|
1005
1133
|
this.logger,
|
|
1006
1134
|
this.namespace
|
|
1007
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1135
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1136
|
+
`Usermaven client reinitialized for namespace: ${this.namespace}`
|
|
1137
|
+
);
|
|
1008
1138
|
}
|
|
1009
1139
|
manageCrossDomainLinking() {
|
|
1010
1140
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
@@ -1012,14 +1142,14 @@ class N {
|
|
|
1012
1142
|
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1013
1143
|
document.addEventListener("click", (i) => {
|
|
1014
1144
|
var a;
|
|
1015
|
-
const
|
|
1016
|
-
if (!
|
|
1017
|
-
const r =
|
|
1145
|
+
const n = this.findClosestLink(i.target);
|
|
1146
|
+
if (!n) return;
|
|
1147
|
+
const r = n.getAttribute("href");
|
|
1018
1148
|
if (!r || !r.startsWith("http")) return;
|
|
1019
1149
|
const o = new URL(r);
|
|
1020
1150
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1021
1151
|
const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
|
|
1022
|
-
l && (o.searchParams.append("_um", l),
|
|
1152
|
+
l && (o.searchParams.append("_um", l), n.setAttribute("href", o.toString()));
|
|
1023
1153
|
}
|
|
1024
1154
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
1025
1155
|
}
|
|
@@ -1032,22 +1162,41 @@ class N {
|
|
|
1032
1162
|
const t = "https://events.usermaven.com";
|
|
1033
1163
|
if (!h())
|
|
1034
1164
|
return new Ce(e.trackingHost || t, e);
|
|
1035
|
-
const i = "XMLHttpRequest" in window,
|
|
1165
|
+
const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1036
1166
|
if (e.useBeaconApi && r)
|
|
1037
|
-
return new Ee(
|
|
1038
|
-
|
|
1039
|
-
|
|
1167
|
+
return new Ee(
|
|
1168
|
+
e.trackingHost || t,
|
|
1169
|
+
e,
|
|
1170
|
+
this.logger
|
|
1171
|
+
);
|
|
1172
|
+
if (e.forceUseFetch && n)
|
|
1173
|
+
return new W(
|
|
1174
|
+
e.trackingHost || t,
|
|
1175
|
+
e,
|
|
1176
|
+
this.logger
|
|
1177
|
+
);
|
|
1040
1178
|
if (i)
|
|
1041
|
-
return new Pe(
|
|
1042
|
-
|
|
1043
|
-
|
|
1179
|
+
return new Pe(
|
|
1180
|
+
e.trackingHost || t,
|
|
1181
|
+
e,
|
|
1182
|
+
this.logger
|
|
1183
|
+
);
|
|
1184
|
+
if (n)
|
|
1185
|
+
return new W(
|
|
1186
|
+
e.trackingHost || t,
|
|
1187
|
+
e,
|
|
1188
|
+
this.logger
|
|
1189
|
+
);
|
|
1044
1190
|
throw new Error("No suitable transport method available");
|
|
1045
1191
|
}
|
|
1046
1192
|
initializePersistence() {
|
|
1047
|
-
return this.config.disableEventPersistence || !h() ? new
|
|
1193
|
+
return this.config.disableEventPersistence || !h() ? new Se() : new te(
|
|
1194
|
+
`${this.namespace}_${this.config.key}`,
|
|
1195
|
+
this.logger
|
|
1196
|
+
);
|
|
1048
1197
|
}
|
|
1049
1198
|
getOrCreateAnonymousId() {
|
|
1050
|
-
var i,
|
|
1199
|
+
var i, n;
|
|
1051
1200
|
if (!h())
|
|
1052
1201
|
return R();
|
|
1053
1202
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
@@ -1061,7 +1210,13 @@ class N {
|
|
|
1061
1210
|
}
|
|
1062
1211
|
t || (t = R());
|
|
1063
1212
|
const r = 365 * 10;
|
|
1064
|
-
(
|
|
1213
|
+
(n = this.cookieManager) == null || n.set(
|
|
1214
|
+
e,
|
|
1215
|
+
t,
|
|
1216
|
+
r,
|
|
1217
|
+
document.location.protocol !== "http:",
|
|
1218
|
+
!1
|
|
1219
|
+
);
|
|
1065
1220
|
}
|
|
1066
1221
|
return t;
|
|
1067
1222
|
}
|
|
@@ -1074,11 +1229,11 @@ class N {
|
|
|
1074
1229
|
throw new Error("User ID must be a string");
|
|
1075
1230
|
const i = e.id;
|
|
1076
1231
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
1077
|
-
const
|
|
1232
|
+
const n = {
|
|
1078
1233
|
...e,
|
|
1079
1234
|
anonymous_id: this.anonymousId
|
|
1080
1235
|
};
|
|
1081
|
-
await this.track("user_identify",
|
|
1236
|
+
await this.track("user_identify", n);
|
|
1082
1237
|
}
|
|
1083
1238
|
this.logger.info("User identified:", e);
|
|
1084
1239
|
}
|
|
@@ -1087,18 +1242,20 @@ class N {
|
|
|
1087
1242
|
}
|
|
1088
1243
|
lead(e, t = !1) {
|
|
1089
1244
|
if (!P(e))
|
|
1090
|
-
throw new Error(
|
|
1245
|
+
throw new Error(
|
|
1246
|
+
"Lead payload must be a non-null object and not an array"
|
|
1247
|
+
);
|
|
1091
1248
|
const i = e.email;
|
|
1092
1249
|
if (!L(i)) {
|
|
1093
1250
|
this.logger.error("Lead event requires a valid email attribute");
|
|
1094
1251
|
return;
|
|
1095
1252
|
}
|
|
1096
|
-
const
|
|
1097
|
-
if (!
|
|
1253
|
+
const n = i.trim();
|
|
1254
|
+
if (!n || !J(n)) {
|
|
1098
1255
|
this.logger.error("Lead event requires a valid email attribute");
|
|
1099
1256
|
return;
|
|
1100
1257
|
}
|
|
1101
|
-
e.email =
|
|
1258
|
+
e.email = n, this.track("lead", e, t);
|
|
1102
1259
|
}
|
|
1103
1260
|
trackInternal(e, t, i = !1) {
|
|
1104
1261
|
if (ve()) {
|
|
@@ -1108,7 +1265,9 @@ class N {
|
|
|
1108
1265
|
if (!L(e))
|
|
1109
1266
|
throw new Error("Event name must be a string");
|
|
1110
1267
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1111
|
-
throw new Error(
|
|
1268
|
+
throw new Error(
|
|
1269
|
+
"Event payload must be a non-null object and not an array"
|
|
1270
|
+
);
|
|
1112
1271
|
const r = this.createEventPayload(e, t);
|
|
1113
1272
|
try {
|
|
1114
1273
|
if (i) {
|
|
@@ -1129,11 +1288,13 @@ class N {
|
|
|
1129
1288
|
if (!P(e))
|
|
1130
1289
|
throw new Error("Company properties must be an object");
|
|
1131
1290
|
if (!e.id || !e.name || !e.created_at)
|
|
1132
|
-
throw new Error(
|
|
1291
|
+
throw new Error(
|
|
1292
|
+
"Company properties must include id, name, and created_at"
|
|
1293
|
+
);
|
|
1133
1294
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1134
1295
|
}
|
|
1135
1296
|
createEventPayload(e, t) {
|
|
1136
|
-
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}`) || {};
|
|
1137
1298
|
let l = t || {};
|
|
1138
1299
|
const c = {
|
|
1139
1300
|
event_id: "",
|
|
@@ -1142,7 +1303,7 @@ class N {
|
|
|
1142
1303
|
id: r,
|
|
1143
1304
|
...i
|
|
1144
1305
|
},
|
|
1145
|
-
...
|
|
1306
|
+
...n && { company: n },
|
|
1146
1307
|
ids: this.getThirdPartyIds(),
|
|
1147
1308
|
utc_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1148
1309
|
local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
@@ -1154,7 +1315,9 @@ class N {
|
|
|
1154
1315
|
...a
|
|
1155
1316
|
};
|
|
1156
1317
|
if (e === "$autocapture") {
|
|
1157
|
-
const d = this.processAutocaptureAttributes(
|
|
1318
|
+
const d = this.processAutocaptureAttributes(
|
|
1319
|
+
t || {}
|
|
1320
|
+
);
|
|
1158
1321
|
c.autocapture_attributes = d;
|
|
1159
1322
|
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
|
|
1160
1323
|
delete l[d];
|
|
@@ -1164,8 +1327,16 @@ class N {
|
|
|
1164
1327
|
processAutocaptureAttributes(e) {
|
|
1165
1328
|
let t = {};
|
|
1166
1329
|
const i = e.$elements || [];
|
|
1167
|
-
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1168
|
-
|
|
1330
|
+
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1331
|
+
"$ce_version",
|
|
1332
|
+
"$event_type",
|
|
1333
|
+
"$initial_referrer",
|
|
1334
|
+
"$initial_referring_domain",
|
|
1335
|
+
"$referrer",
|
|
1336
|
+
"$referring_domain",
|
|
1337
|
+
"$elements"
|
|
1338
|
+
].forEach((n) => {
|
|
1339
|
+
delete t[n];
|
|
1169
1340
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1170
1341
|
}
|
|
1171
1342
|
getCookie(e) {
|
|
@@ -1182,16 +1353,28 @@ class N {
|
|
|
1182
1353
|
}
|
|
1183
1354
|
getUtmParams() {
|
|
1184
1355
|
const e = {}, t = we(window.location.search);
|
|
1185
|
-
return [
|
|
1186
|
-
|
|
1356
|
+
return [
|
|
1357
|
+
"utm_source",
|
|
1358
|
+
"utm_medium",
|
|
1359
|
+
"utm_campaign",
|
|
1360
|
+
"utm_term",
|
|
1361
|
+
"utm_content"
|
|
1362
|
+
].forEach((n) => {
|
|
1363
|
+
t[n] && (e[n.replace("utm_", "")] = t[n]);
|
|
1187
1364
|
}), e;
|
|
1188
1365
|
}
|
|
1189
1366
|
pageview() {
|
|
1190
|
-
h() ? this.track(
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1367
|
+
h() ? this.track(
|
|
1368
|
+
"pageview",
|
|
1369
|
+
{
|
|
1370
|
+
url: window.location.href,
|
|
1371
|
+
referrer: document.referrer,
|
|
1372
|
+
title: document.title
|
|
1373
|
+
},
|
|
1374
|
+
!0
|
|
1375
|
+
) : this.logger.warn(
|
|
1376
|
+
"Pageview tracking is not available in server-side environments"
|
|
1377
|
+
);
|
|
1195
1378
|
}
|
|
1196
1379
|
setupPageLeaveTracking() {
|
|
1197
1380
|
if (!h()) return;
|
|
@@ -1210,9 +1393,9 @@ class N {
|
|
|
1210
1393
|
}), document.addEventListener("visibilitychange", () => {
|
|
1211
1394
|
document.visibilityState === "hidden" && !t && i();
|
|
1212
1395
|
});
|
|
1213
|
-
const
|
|
1396
|
+
const n = history.pushState;
|
|
1214
1397
|
history.pushState = function() {
|
|
1215
|
-
return i(),
|
|
1398
|
+
return i(), n.apply(this, arguments);
|
|
1216
1399
|
}, window.addEventListener("popstate", i);
|
|
1217
1400
|
}
|
|
1218
1401
|
getConfig() {
|
|
@@ -1226,12 +1409,15 @@ class N {
|
|
|
1226
1409
|
const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1227
1410
|
this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
|
|
1228
1411
|
}
|
|
1229
|
-
this.logger.info("core state reset", {
|
|
1412
|
+
this.logger.info("core state reset", {
|
|
1413
|
+
resetAnonId: e,
|
|
1414
|
+
namespace: this.namespace
|
|
1415
|
+
});
|
|
1230
1416
|
}
|
|
1231
1417
|
set(e, t) {
|
|
1232
1418
|
if (!P(e))
|
|
1233
1419
|
throw new Error("Properties must be an object");
|
|
1234
|
-
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;
|
|
1235
1421
|
if (i) {
|
|
1236
1422
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1237
1423
|
r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
|
|
@@ -1239,10 +1425,10 @@ class N {
|
|
|
1239
1425
|
let r = this.persistence.get("global_props") || {};
|
|
1240
1426
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1241
1427
|
}
|
|
1242
|
-
|
|
1428
|
+
n && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1243
1429
|
properties: e,
|
|
1244
1430
|
eventType: i || "global",
|
|
1245
|
-
persist:
|
|
1431
|
+
persist: n
|
|
1246
1432
|
});
|
|
1247
1433
|
}
|
|
1248
1434
|
setUserId(e) {
|
|
@@ -1251,7 +1437,7 @@ class N {
|
|
|
1251
1437
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1252
1438
|
}
|
|
1253
1439
|
unset(e, t) {
|
|
1254
|
-
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;
|
|
1255
1441
|
if (i) {
|
|
1256
1442
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1257
1443
|
delete r[e], this.persistence.set(`props_${i}`, r);
|
|
@@ -1259,75 +1445,86 @@ class N {
|
|
|
1259
1445
|
let r = this.persistence.get("global_props") || {};
|
|
1260
1446
|
delete r[e], this.persistence.set("global_props", r);
|
|
1261
1447
|
}
|
|
1262
|
-
|
|
1448
|
+
n && this.persistence.save(), this.logger.debug(
|
|
1449
|
+
`Property unset: ${e}`,
|
|
1450
|
+
`Event type: ${i || "global"}`
|
|
1451
|
+
);
|
|
1263
1452
|
}
|
|
1264
1453
|
}
|
|
1265
1454
|
function ie() {
|
|
1266
1455
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1267
1456
|
}
|
|
1268
|
-
function
|
|
1457
|
+
function $e() {
|
|
1269
1458
|
return ie() ? window.define : void 0;
|
|
1270
1459
|
}
|
|
1271
|
-
const
|
|
1272
|
-
function O(
|
|
1273
|
-
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 = {
|
|
1463
|
+
...Z,
|
|
1464
|
+
...t
|
|
1465
|
+
};
|
|
1274
1466
|
if (!i.key)
|
|
1275
1467
|
throw new Error("API key is required!");
|
|
1276
1468
|
if (!i.trackingHost)
|
|
1277
1469
|
throw new Error("Tracking host is required!");
|
|
1278
|
-
const
|
|
1279
|
-
return h() && i.autocapture && window[r] && (console.warn(
|
|
1470
|
+
const n = i.key || "", r = `${Te}${n}`;
|
|
1471
|
+
return h() && i.autocapture && window[r] && (console.warn(
|
|
1472
|
+
"Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
|
|
1473
|
+
), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new I(i);
|
|
1280
1474
|
}
|
|
1281
|
-
function xe(
|
|
1282
|
-
var
|
|
1475
|
+
function xe(s) {
|
|
1476
|
+
var n;
|
|
1283
1477
|
const e = {
|
|
1284
|
-
key:
|
|
1285
|
-
trackingHost:
|
|
1286
|
-
logLevel: ke(
|
|
1287
|
-
autocapture:
|
|
1288
|
-
formTracking:
|
|
1289
|
-
autoPageview:
|
|
1290
|
-
useBeaconApi:
|
|
1291
|
-
forceUseFetch:
|
|
1292
|
-
gaHook:
|
|
1293
|
-
segmentHook:
|
|
1294
|
-
randomizeUrl:
|
|
1295
|
-
capture3rdPartyCookies:
|
|
1296
|
-
idMethod:
|
|
1297
|
-
privacyPolicy:
|
|
1298
|
-
ipPolicy:
|
|
1299
|
-
cookiePolicy:
|
|
1300
|
-
minSendTimeout: parseInt(
|
|
1301
|
-
maxSendTimeout: parseInt(
|
|
1302
|
-
maxSendAttempts: parseInt(
|
|
1303
|
-
propertiesStringMaxLength: parseInt(
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
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,
|
|
1497
|
+
propertiesStringMaxLength: parseInt(
|
|
1498
|
+
s.getAttribute("data-properties-string-max-length") || "",
|
|
1499
|
+
10
|
|
1500
|
+
) || null,
|
|
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"
|
|
1311
1508
|
};
|
|
1312
1509
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1313
1510
|
const t = O(e), i = e.namespace || "usermaven";
|
|
1314
1511
|
return h() && t.pageview(), He(i, t), t;
|
|
1315
1512
|
}
|
|
1316
|
-
function He(
|
|
1513
|
+
function He(s, e) {
|
|
1317
1514
|
let t = !1;
|
|
1318
|
-
const i = [],
|
|
1515
|
+
const i = [], n = [];
|
|
1319
1516
|
function r() {
|
|
1320
1517
|
for (; i.length > 0; ) {
|
|
1321
1518
|
const u = i.shift();
|
|
1322
1519
|
if (u) {
|
|
1323
|
-
const
|
|
1324
|
-
if (
|
|
1520
|
+
const f = u[u.length - 1];
|
|
1521
|
+
if (f && typeof f.resolve == "function") {
|
|
1325
1522
|
const m = u.pop();
|
|
1326
1523
|
try {
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
} catch (
|
|
1330
|
-
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(_);
|
|
1331
1528
|
}
|
|
1332
1529
|
} else
|
|
1333
1530
|
try {
|
|
@@ -1339,74 +1536,82 @@ function He(n, e) {
|
|
|
1339
1536
|
}
|
|
1340
1537
|
}
|
|
1341
1538
|
function o() {
|
|
1342
|
-
|
|
1539
|
+
n.forEach((u) => u()), n.length = 0;
|
|
1343
1540
|
}
|
|
1344
1541
|
function a(...u) {
|
|
1345
|
-
const
|
|
1346
|
-
if (
|
|
1347
|
-
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]));
|
|
1348
1545
|
return;
|
|
1349
1546
|
}
|
|
1350
1547
|
if (!t) {
|
|
1351
1548
|
i.push(u);
|
|
1352
1549
|
return;
|
|
1353
1550
|
}
|
|
1354
|
-
if (typeof e[
|
|
1355
|
-
return e[
|
|
1356
|
-
console.error(`Method ${
|
|
1357
|
-
}
|
|
1358
|
-
const l = ["id", "group", "reset"], c = [
|
|
1551
|
+
if (typeof e[f] == "function")
|
|
1552
|
+
return e[f].apply(e, u.slice(1));
|
|
1553
|
+
console.error(`Method ${f} not found on UsermavenClient`);
|
|
1554
|
+
}
|
|
1555
|
+
const l = ["id", "group", "reset"], c = [
|
|
1556
|
+
"track",
|
|
1557
|
+
"lead",
|
|
1558
|
+
"pageview",
|
|
1559
|
+
"set",
|
|
1560
|
+
"unset",
|
|
1561
|
+
"rawTrack",
|
|
1562
|
+
"setUserId"
|
|
1563
|
+
];
|
|
1359
1564
|
[...l, ...c].forEach((u) => {
|
|
1360
|
-
a[u] = function(...
|
|
1565
|
+
a[u] = function(...f) {
|
|
1361
1566
|
if (!t) {
|
|
1362
1567
|
if (l.includes(u))
|
|
1363
|
-
return new Promise((
|
|
1364
|
-
i.push([u, ...
|
|
1568
|
+
return new Promise((z, m) => {
|
|
1569
|
+
i.push([u, ...f, { resolve: z, reject: m }]);
|
|
1365
1570
|
});
|
|
1366
|
-
i.push([u, ...
|
|
1571
|
+
i.push([u, ...f]);
|
|
1367
1572
|
return;
|
|
1368
1573
|
}
|
|
1369
1574
|
if (typeof e[u] == "function")
|
|
1370
|
-
return e[u].apply(e,
|
|
1575
|
+
return e[u].apply(e, f);
|
|
1371
1576
|
};
|
|
1372
1577
|
}), a.getConfig = function() {
|
|
1373
1578
|
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1374
|
-
}, window[
|
|
1375
|
-
const p = `${
|
|
1376
|
-
for (window[p] =
|
|
1579
|
+
}, window[s] = a;
|
|
1580
|
+
const p = `${s}Q`, b = window[p] || [];
|
|
1581
|
+
for (window[p] = b, b.push = function(...u) {
|
|
1377
1582
|
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1378
1583
|
}, setTimeout(() => {
|
|
1379
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1380
|
-
}, 0);
|
|
1381
|
-
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();
|
|
1382
1587
|
u && i.push(u);
|
|
1383
1588
|
}
|
|
1384
1589
|
}
|
|
1385
|
-
let X = !1,
|
|
1590
|
+
let X = !1, D = null;
|
|
1386
1591
|
if (h()) {
|
|
1387
|
-
const
|
|
1388
|
-
|
|
1592
|
+
const s = $e();
|
|
1593
|
+
s && s("usermaven", [], function() {
|
|
1389
1594
|
return {
|
|
1390
1595
|
usermavenClient: O,
|
|
1391
|
-
UsermavenClient:
|
|
1596
|
+
UsermavenClient: I,
|
|
1392
1597
|
LogLevel: k,
|
|
1393
1598
|
// Expose the script tag client if it exists
|
|
1394
|
-
getScriptTagClient: () =>
|
|
1599
|
+
getScriptTagClient: () => D
|
|
1395
1600
|
};
|
|
1396
|
-
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient =
|
|
1601
|
+
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = I, window.usermavenScriptTagClient = () => D), function(e, t) {
|
|
1397
1602
|
const i = e.currentScript;
|
|
1398
|
-
function
|
|
1603
|
+
function n() {
|
|
1399
1604
|
return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1400
1605
|
}
|
|
1401
1606
|
function r() {
|
|
1402
|
-
|
|
1607
|
+
n() && (console.log("[Usermaven] Auto-initializing from script tag"), D = xe(i), X = !0);
|
|
1403
1608
|
}
|
|
1404
1609
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1405
1610
|
}(document, window);
|
|
1406
1611
|
}
|
|
1407
1612
|
typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
1408
1613
|
usermavenClient: O,
|
|
1409
|
-
UsermavenClient:
|
|
1614
|
+
UsermavenClient: I,
|
|
1410
1615
|
Config: void 0,
|
|
1411
1616
|
UserProps: void 0,
|
|
1412
1617
|
EventPayload: void 0,
|
|
@@ -1415,6 +1620,6 @@ typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
|
1415
1620
|
});
|
|
1416
1621
|
export {
|
|
1417
1622
|
k as LogLevel,
|
|
1418
|
-
|
|
1623
|
+
I as UsermavenClient,
|
|
1419
1624
|
O as usermavenClient
|
|
1420
1625
|
};
|