@usermaven/sdk-js 1.4.1-rc.61 → 1.4.1-rc.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/client.d.ts +0 -2
- package/dist/core/types.d.ts +7 -0
- package/dist/lib.js +2 -2
- package/dist/tracking/autocapture.d.ts +3 -7
- package/dist/usermaven.cjs.js +2 -2
- package/dist/usermaven.es.js +202 -224
- package/dist/utils/autocapture-utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/usermaven.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var v = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(v || {});
|
|
2
|
-
class
|
|
2
|
+
class W {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.level = e;
|
|
5
5
|
}
|
|
@@ -16,10 +16,10 @@ class V {
|
|
|
16
16
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return new
|
|
19
|
+
function g(i = 0) {
|
|
20
|
+
return new W(i);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const U = {
|
|
23
23
|
logLevel: v.ERROR,
|
|
24
24
|
useBeaconApi: !1,
|
|
25
25
|
forceUseFetch: !1,
|
|
@@ -45,7 +45,7 @@ const I = {
|
|
|
45
45
|
maskAllText: !1,
|
|
46
46
|
maskAllElementAttributes: !1
|
|
47
47
|
};
|
|
48
|
-
class
|
|
48
|
+
class X {
|
|
49
49
|
constructor(e) {
|
|
50
50
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
51
51
|
}
|
|
@@ -94,39 +94,39 @@ class Q {
|
|
|
94
94
|
return s ? s[0] : "";
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
const
|
|
97
|
+
const K = Object.prototype, G = K.hasOwnProperty, Y = Array.prototype, $ = Y.forEach, A = {};
|
|
98
98
|
function Z(i, e, t) {
|
|
99
99
|
if (Array.isArray(i)) {
|
|
100
|
-
if (
|
|
100
|
+
if ($ && i.forEach === $)
|
|
101
101
|
i.forEach(e, t);
|
|
102
102
|
else if ("length" in i && i.length === +i.length) {
|
|
103
103
|
for (let s = 0, n = i.length; s < n; s++)
|
|
104
|
-
if (s in i && e.call(t, i[s], s) ===
|
|
104
|
+
if (s in i && e.call(t, i[s], s) === A)
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const x = function(i) {
|
|
110
110
|
return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
111
|
-
},
|
|
111
|
+
}, j = function(i) {
|
|
112
112
|
for (const e in i)
|
|
113
113
|
typeof i[e] == "function" && (i[e] = i[e].bind(i));
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function f(i, e, t) {
|
|
116
116
|
if (i != null) {
|
|
117
|
-
if (
|
|
117
|
+
if ($ && Array.isArray(i) && i.forEach === $)
|
|
118
118
|
i.forEach(e, t);
|
|
119
119
|
else if ("length" in i && i.length === +i.length) {
|
|
120
120
|
for (let s = 0, n = i.length; s < n; s++)
|
|
121
|
-
if (s in i && e.call(t, i[s], s) ===
|
|
121
|
+
if (s in i && e.call(t, i[s], s) === A)
|
|
122
122
|
return;
|
|
123
123
|
} else
|
|
124
124
|
for (const s in i)
|
|
125
|
-
if (
|
|
125
|
+
if (G.call(i, s) && e.call(t, i[s], s) === A)
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const
|
|
129
|
+
const ee = function(i, ...e) {
|
|
130
130
|
return Z(e, function(t) {
|
|
131
131
|
for (const s in t)
|
|
132
132
|
t[s] !== void 0 && (i[s] = t[s]);
|
|
@@ -135,18 +135,18 @@ const Y = function(i, ...e) {
|
|
|
135
135
|
function _(i, e) {
|
|
136
136
|
return i.indexOf(e) !== -1;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const te = function(i) {
|
|
139
139
|
try {
|
|
140
140
|
return /^\s*\bfunction\b/.test(i);
|
|
141
141
|
} catch {
|
|
142
142
|
return !1;
|
|
143
143
|
}
|
|
144
|
-
},
|
|
144
|
+
}, ie = function(i) {
|
|
145
145
|
return i === void 0;
|
|
146
|
-
},
|
|
146
|
+
}, m = function() {
|
|
147
147
|
const i = function(s, n, r, o, c) {
|
|
148
148
|
if (!s) {
|
|
149
|
-
|
|
149
|
+
g().error("No valid element provided to register_event");
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
if (s.addEventListener && !o)
|
|
@@ -161,7 +161,7 @@ const F = function(i) {
|
|
|
161
161
|
if (o = o || t(window.event), !o)
|
|
162
162
|
return;
|
|
163
163
|
let c = !0, l;
|
|
164
|
-
|
|
164
|
+
te(r) && (l = r(o));
|
|
165
165
|
const a = n.call(s, o);
|
|
166
166
|
return (l === !1 || a === !1) && (c = !1), c;
|
|
167
167
|
};
|
|
@@ -174,19 +174,19 @@ const F = function(i) {
|
|
|
174
174
|
}, t.stopPropagation = function() {
|
|
175
175
|
this.cancelBubble = !0;
|
|
176
176
|
}, i;
|
|
177
|
-
}(),
|
|
177
|
+
}(), se = function(i) {
|
|
178
178
|
return function(...e) {
|
|
179
179
|
try {
|
|
180
180
|
return i.apply(this, e);
|
|
181
181
|
} catch (t) {
|
|
182
|
-
|
|
182
|
+
g().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
}, z = function(i) {
|
|
186
186
|
for (const e in i)
|
|
187
|
-
typeof i[e] == "function" && (i[e] =
|
|
187
|
+
typeof i[e] == "function" && (i[e] = se(i[e]));
|
|
188
188
|
};
|
|
189
|
-
function
|
|
189
|
+
function R(i) {
|
|
190
190
|
for (let e in i)
|
|
191
191
|
(i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
|
|
192
192
|
return i;
|
|
@@ -195,26 +195,26 @@ function u() {
|
|
|
195
195
|
try {
|
|
196
196
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
197
197
|
} catch {
|
|
198
|
-
return
|
|
198
|
+
return g().warn("window is not available"), !1;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function p(i = 5) {
|
|
202
202
|
const e = new Uint8Array(i);
|
|
203
203
|
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function ne(i) {
|
|
206
206
|
return i.replace(
|
|
207
207
|
/([-_][a-z])/g,
|
|
208
208
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function
|
|
212
|
-
return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(
|
|
213
|
-
const s =
|
|
214
|
-
return e[s] =
|
|
211
|
+
function H(i) {
|
|
212
|
+
return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(H) : Object.keys(i).reduce((e, t) => {
|
|
213
|
+
const s = ne(t);
|
|
214
|
+
return e[s] = H(i[t]), e;
|
|
215
215
|
}, {});
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function E(i) {
|
|
218
218
|
switch (typeof i.className) {
|
|
219
219
|
case "string":
|
|
220
220
|
return i.className;
|
|
@@ -224,13 +224,13 @@ function P(i) {
|
|
|
224
224
|
return "";
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function L(i) {
|
|
228
228
|
let e = "";
|
|
229
|
-
return
|
|
230
|
-
B(t) && t.textContent && (e +=
|
|
231
|
-
}),
|
|
229
|
+
return O(i) && !M(i) && i.childNodes && i.childNodes.length && f(i.childNodes, function(t) {
|
|
230
|
+
B(t) && t.textContent && (e += x(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
231
|
+
}), x(e);
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function q(i) {
|
|
234
234
|
return !!i && i.nodeType === 1;
|
|
235
235
|
}
|
|
236
236
|
function d(i, e) {
|
|
@@ -239,22 +239,22 @@ function d(i, e) {
|
|
|
239
239
|
function B(i) {
|
|
240
240
|
return !!i && i.nodeType === 3;
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function N(i) {
|
|
243
243
|
return !!i && i.nodeType === 11;
|
|
244
244
|
}
|
|
245
245
|
const b = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
246
|
-
function
|
|
247
|
-
if (!i || d(i, "html") || !
|
|
246
|
+
function re(i, e) {
|
|
247
|
+
if (!i || d(i, "html") || !q(i))
|
|
248
248
|
return !1;
|
|
249
249
|
let t = i;
|
|
250
250
|
for (; t && !d(t, "body"); ) {
|
|
251
251
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
252
252
|
return !1;
|
|
253
|
-
t.parentNode &&
|
|
253
|
+
t.parentNode && N(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
254
254
|
}
|
|
255
255
|
let s = !1;
|
|
256
256
|
for (t = i; t && !d(t, "body"); ) {
|
|
257
|
-
if (t.parentNode &&
|
|
257
|
+
if (t.parentNode && N(t.parentNode)) {
|
|
258
258
|
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
|
|
259
259
|
continue;
|
|
260
260
|
}
|
|
@@ -286,51 +286,42 @@ function ie(i, e) {
|
|
|
286
286
|
return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (typeof i.hasAttribute == "function") {
|
|
293
|
-
if (i.hasAttribute(w.FORCE_CAPTURE_ATTR))
|
|
294
|
-
return !0;
|
|
295
|
-
if (i.hasAttribute(w.PREVENT_CAPTURE_ATTR))
|
|
296
|
-
return !1;
|
|
297
|
-
}
|
|
298
|
-
let e = i;
|
|
299
|
-
for (; e && e.parentElement && !d(e, "body"); ) {
|
|
300
|
-
const n = P(e).split(" ");
|
|
289
|
+
function O(i) {
|
|
290
|
+
for (let s = i; s.parentNode && !d(s, "body"); s = s.parentNode) {
|
|
291
|
+
const n = E(s).split(" ");
|
|
301
292
|
if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
|
|
302
293
|
return !1;
|
|
303
|
-
e = e.parentElement;
|
|
304
294
|
}
|
|
305
|
-
if (_(
|
|
295
|
+
if (_(E(i).split(" "), "ph-include"))
|
|
306
296
|
return !0;
|
|
307
|
-
const
|
|
308
|
-
if (typeof
|
|
309
|
-
switch (
|
|
297
|
+
const e = i.type || "";
|
|
298
|
+
if (typeof e == "string")
|
|
299
|
+
switch (e.toLowerCase()) {
|
|
310
300
|
case "hidden":
|
|
301
|
+
return !1;
|
|
311
302
|
case "password":
|
|
312
303
|
return !1;
|
|
313
304
|
}
|
|
314
|
-
const
|
|
315
|
-
return !(typeof
|
|
305
|
+
const t = i.name || i.id || "";
|
|
306
|
+
return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
|
|
316
307
|
}
|
|
317
|
-
function
|
|
308
|
+
function M(i) {
|
|
318
309
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
319
310
|
return !!(d(i, "input") && !e.includes(i.type) || d(i, "select") || d(i, "textarea") || i.getAttribute("contenteditable") === "true");
|
|
320
311
|
}
|
|
321
|
-
function
|
|
322
|
-
return !(i === null ||
|
|
312
|
+
function P(i) {
|
|
313
|
+
return !(i === null || ie(i) || typeof i == "string" && (i = x(i), /^(?:(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((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
|
|
323
314
|
}
|
|
324
|
-
function
|
|
315
|
+
function oe(i) {
|
|
325
316
|
return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
|
|
326
317
|
}
|
|
327
|
-
function
|
|
328
|
-
return
|
|
318
|
+
function T() {
|
|
319
|
+
return p(10);
|
|
329
320
|
}
|
|
330
|
-
function
|
|
321
|
+
function ae(i) {
|
|
331
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(i).toLowerCase());
|
|
332
323
|
}
|
|
333
|
-
function
|
|
324
|
+
function ce(i, e) {
|
|
334
325
|
let t;
|
|
335
326
|
return function(...s) {
|
|
336
327
|
const n = () => {
|
|
@@ -339,7 +330,7 @@ function re(i, e) {
|
|
|
339
330
|
clearTimeout(t), t = setTimeout(n, e);
|
|
340
331
|
};
|
|
341
332
|
}
|
|
342
|
-
function
|
|
333
|
+
function le(i) {
|
|
343
334
|
const e = {}, t = i.replace(/^\?/, "").split("&");
|
|
344
335
|
for (let s = 0; s < t.length; s++) {
|
|
345
336
|
const n = t[s].split("=");
|
|
@@ -347,21 +338,21 @@ function oe(i) {
|
|
|
347
338
|
}
|
|
348
339
|
return e;
|
|
349
340
|
}
|
|
350
|
-
function
|
|
341
|
+
function I(i) {
|
|
351
342
|
return typeof i == "string" || i instanceof String;
|
|
352
343
|
}
|
|
353
344
|
function k(i) {
|
|
354
345
|
return i !== null && typeof i == "object" && i.constructor === Object;
|
|
355
346
|
}
|
|
356
|
-
function
|
|
347
|
+
function ue(i) {
|
|
357
348
|
if (i === null)
|
|
358
349
|
return v.ERROR;
|
|
359
350
|
const e = i.toUpperCase(), t = v[e];
|
|
360
351
|
return t || t === 0 ? t : v.ERROR;
|
|
361
352
|
}
|
|
362
|
-
class
|
|
353
|
+
class he {
|
|
363
354
|
constructor(e) {
|
|
364
|
-
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll =
|
|
355
|
+
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ce(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
365
356
|
}
|
|
366
357
|
initializeEventListener() {
|
|
367
358
|
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
@@ -410,9 +401,9 @@ class ce {
|
|
|
410
401
|
});
|
|
411
402
|
}
|
|
412
403
|
}
|
|
413
|
-
const
|
|
414
|
-
constructor(e, t, s =
|
|
415
|
-
this.logger = s, this.scrollDepth = null, this.client = e, this.options = t, this.scrollDepth = new
|
|
404
|
+
const C = class C {
|
|
405
|
+
constructor(e, t, s = g()) {
|
|
406
|
+
this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new he(e), j(this), z(this);
|
|
416
407
|
}
|
|
417
408
|
init() {
|
|
418
409
|
if (!(document && document.body)) {
|
|
@@ -425,7 +416,7 @@ const y = class y {
|
|
|
425
416
|
const e = (t) => {
|
|
426
417
|
t = t || window.event, this.captureEvent(t);
|
|
427
418
|
};
|
|
428
|
-
|
|
419
|
+
m(document, "submit", e, !1, !0), m(document, "change", e, !1, !0), m(document, "click", e, !1, !0), m(document, "visibilitychange", e, !1, !0), m(document, "scroll", e, !1, !0), m(window, "popstate", e, !1, !0);
|
|
429
420
|
}
|
|
430
421
|
isPageRefresh() {
|
|
431
422
|
if ("PerformanceNavigationTiming" in window) {
|
|
@@ -442,63 +433,89 @@ const y = class y {
|
|
|
442
433
|
return (s = this.scrollDepth) == null || s.track(), !0;
|
|
443
434
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
444
435
|
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
445
|
-
if (t &&
|
|
446
|
-
const r =
|
|
436
|
+
if (t && re(t, e)) {
|
|
437
|
+
const r = [t];
|
|
438
|
+
let o = t;
|
|
439
|
+
for (; o.parentNode && !d(o, "body"); ) {
|
|
440
|
+
if (N(o.parentNode)) {
|
|
441
|
+
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
r.push(o.parentNode), o = o.parentNode;
|
|
445
|
+
}
|
|
446
|
+
const c = [];
|
|
447
|
+
let l, a = !1;
|
|
448
|
+
if (f(r, (w) => {
|
|
449
|
+
const J = O(w);
|
|
450
|
+
w.tagName.toLowerCase() === "a" && (l = w.getAttribute("href"), l = J && P(l) && l);
|
|
451
|
+
const Q = E(w).split(" ");
|
|
452
|
+
_(Q, "ph-no-capture") && (a = !0), c.push(
|
|
453
|
+
this.getPropertiesFromElement(
|
|
454
|
+
w,
|
|
455
|
+
this.options.maskAllElementAttributes ?? !1,
|
|
456
|
+
this.options.maskAllText ?? !1
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}), this.options.maskAllText || (c[0].$el_text = L(t)), l && (c[0].attr__href = l), a)
|
|
460
|
+
return !1;
|
|
461
|
+
const h = ee(
|
|
447
462
|
this.getDefaultProperties(e.type),
|
|
448
463
|
{
|
|
449
|
-
$elements:
|
|
450
|
-
}
|
|
464
|
+
$elements: c
|
|
465
|
+
},
|
|
466
|
+
this.getCustomProperties(r)
|
|
451
467
|
);
|
|
452
|
-
return this.client.track("$autocapture",
|
|
468
|
+
return this.client.track("$autocapture", h), !0;
|
|
453
469
|
}
|
|
454
470
|
}
|
|
455
|
-
|
|
456
|
-
|
|
471
|
+
getCustomProperties(e) {
|
|
472
|
+
const t = {};
|
|
473
|
+
return f(this.customProperties, (s) => {
|
|
474
|
+
f(s.event_selectors, (n) => {
|
|
475
|
+
const r = document.querySelectorAll(n);
|
|
476
|
+
f(r, (o) => {
|
|
477
|
+
_(e, o) && O(o) && (t[s.name] = this.extractCustomPropertyValue(s));
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
}), t;
|
|
481
|
+
}
|
|
482
|
+
extractCustomPropertyValue(e) {
|
|
483
|
+
const t = [];
|
|
484
|
+
return f(document.querySelectorAll(e.css_selector), function(s) {
|
|
485
|
+
let n;
|
|
486
|
+
["input", "select"].indexOf(s.tagName.toLowerCase()) > -1 ? n = s.value : s.textContent && (n = s.textContent), P(n) && t.push(n);
|
|
487
|
+
}), t.join(", ");
|
|
457
488
|
}
|
|
458
489
|
getEventTarget(e) {
|
|
459
490
|
var t;
|
|
460
491
|
return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
461
492
|
}
|
|
462
|
-
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
for (; s.parentNode && !d(s, "body"); )
|
|
466
|
-
x(s.parentNode) ? (t.push(s.parentNode.host), s = s.parentNode.host) : (t.push(s.parentNode), s = s.parentNode);
|
|
467
|
-
return t;
|
|
468
|
-
}
|
|
469
|
-
getElementsJson(e, t) {
|
|
470
|
-
const s = [];
|
|
471
|
-
let n = null, r = !1;
|
|
472
|
-
return S(e, (o) => {
|
|
473
|
-
if (d(o, "a")) {
|
|
474
|
-
const l = o.getAttribute("href");
|
|
475
|
-
l !== null && M(o) && H(l) && (n = l);
|
|
476
|
-
}
|
|
477
|
-
const c = P(o).split(" ");
|
|
478
|
-
_(c, "ph-no-capture") && (r = !0), s.push(this.getPropertiesFromElement(o));
|
|
479
|
-
}), this.options.maskAllText || (s[0].$el_text = this.sanitizeText(O(e[0]))), n !== null && (s[0].attr__href = n), r ? [] : s;
|
|
480
|
-
}
|
|
481
|
-
getPropertiesFromElement(e) {
|
|
482
|
-
const t = {
|
|
483
|
-
tag_name: e.tagName.toLowerCase()
|
|
493
|
+
getPropertiesFromElement(e, t, s) {
|
|
494
|
+
const n = e.tagName.toLowerCase(), r = {
|
|
495
|
+
tag_name: n
|
|
484
496
|
};
|
|
485
|
-
b.indexOf(
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
497
|
+
b.indexOf(n) > -1 && !s && (r.$el_text = L(e));
|
|
498
|
+
const o = E(e);
|
|
499
|
+
o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
|
|
500
|
+
return h !== "";
|
|
501
|
+
})), f(e.attributes, function(h) {
|
|
502
|
+
M(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !oe(h.name) && (r["attr__" + h.name] = h.value);
|
|
489
503
|
});
|
|
490
|
-
let
|
|
491
|
-
for (;
|
|
492
|
-
|
|
493
|
-
return
|
|
504
|
+
let c = 1, l = 1, a = e;
|
|
505
|
+
for (; a = this.previousElementSibling(a); )
|
|
506
|
+
c++, a.tagName === e.tagName && l++;
|
|
507
|
+
return r.nth_child = c, r.nth_of_type = l, r;
|
|
494
508
|
}
|
|
495
509
|
previousElementSibling(e) {
|
|
496
510
|
if (e.previousElementSibling)
|
|
497
511
|
return e.previousElementSibling;
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
512
|
+
{
|
|
513
|
+
let t = e;
|
|
514
|
+
do
|
|
515
|
+
t = t.previousSibling;
|
|
516
|
+
while (t && !q(t));
|
|
517
|
+
return t;
|
|
518
|
+
}
|
|
502
519
|
}
|
|
503
520
|
getDefaultProperties(e) {
|
|
504
521
|
return {
|
|
@@ -506,30 +523,6 @@ const y = class y {
|
|
|
506
523
|
$ce_version: 1
|
|
507
524
|
};
|
|
508
525
|
}
|
|
509
|
-
// Input sanitization and XSS prevention methods
|
|
510
|
-
sanitizeText(e) {
|
|
511
|
-
e = e.replace(/<[^>]*?>/g, ""), e = this.encodeHtml(e);
|
|
512
|
-
const t = this.options.propertiesStringMaxLength || 255;
|
|
513
|
-
return e.length > t && (e = e.substring(0, t) + "..."), e;
|
|
514
|
-
}
|
|
515
|
-
sanitizeUrl(e) {
|
|
516
|
-
if (!e) return "";
|
|
517
|
-
try {
|
|
518
|
-
const t = new URL(e, window.location.href);
|
|
519
|
-
return t.protocol !== "http:" && t.protocol !== "https:" ? "" : encodeURI(t.toString());
|
|
520
|
-
} catch {
|
|
521
|
-
return this.encodeHtml(e);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
sanitizeAttributeValue(e, t) {
|
|
525
|
-
switch (e.toLowerCase()) {
|
|
526
|
-
case "href":
|
|
527
|
-
case "src":
|
|
528
|
-
return this.sanitizeUrl(t);
|
|
529
|
-
default:
|
|
530
|
-
return this.encodeHtml(t);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
526
|
encodeHtml(e) {
|
|
534
527
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
535
528
|
}
|
|
@@ -541,13 +534,10 @@ const y = class y {
|
|
|
541
534
|
n += e.charCodeAt(r);
|
|
542
535
|
return n % t < s;
|
|
543
536
|
}
|
|
544
|
-
static isBrowserSupported() {
|
|
545
|
-
return F(document.querySelectorAll);
|
|
546
|
-
}
|
|
547
537
|
};
|
|
548
|
-
|
|
549
|
-
let
|
|
550
|
-
class
|
|
538
|
+
C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
539
|
+
let S = C;
|
|
540
|
+
class ge {
|
|
551
541
|
constructor(e) {
|
|
552
542
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
553
543
|
}
|
|
@@ -576,8 +566,8 @@ class le {
|
|
|
576
566
|
}));
|
|
577
567
|
}
|
|
578
568
|
}
|
|
579
|
-
class
|
|
580
|
-
constructor(e, t, s =
|
|
569
|
+
class de {
|
|
570
|
+
constructor(e, t, s = g()) {
|
|
581
571
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
582
572
|
}
|
|
583
573
|
async send(e) {
|
|
@@ -589,13 +579,13 @@ class ue {
|
|
|
589
579
|
}
|
|
590
580
|
constructUrl(e) {
|
|
591
581
|
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
592
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
582
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
593
583
|
}
|
|
594
584
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
595
585
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
596
586
|
}
|
|
597
|
-
class
|
|
598
|
-
constructor(e, t, s =
|
|
587
|
+
class D {
|
|
588
|
+
constructor(e, t, s = g()) {
|
|
599
589
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
600
590
|
}
|
|
601
591
|
async send(e) {
|
|
@@ -613,7 +603,7 @@ class U {
|
|
|
613
603
|
}
|
|
614
604
|
constructUrl(e) {
|
|
615
605
|
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
616
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
606
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
617
607
|
}
|
|
618
608
|
getCustomHeaders() {
|
|
619
609
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -622,8 +612,8 @@ class U {
|
|
|
622
612
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
623
613
|
}
|
|
624
614
|
}
|
|
625
|
-
class
|
|
626
|
-
constructor(e, t, s =
|
|
615
|
+
class fe {
|
|
616
|
+
constructor(e, t, s = g()) {
|
|
627
617
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
628
618
|
}
|
|
629
619
|
send(e) {
|
|
@@ -642,7 +632,7 @@ class he {
|
|
|
642
632
|
}
|
|
643
633
|
constructUrl(e) {
|
|
644
634
|
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
645
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
635
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
646
636
|
}
|
|
647
637
|
getCustomHeaders() {
|
|
648
638
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -651,9 +641,9 @@ class he {
|
|
|
651
641
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
652
642
|
}
|
|
653
643
|
}
|
|
654
|
-
class
|
|
644
|
+
class V {
|
|
655
645
|
constructor(e, t) {
|
|
656
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t ||
|
|
646
|
+
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || g();
|
|
657
647
|
}
|
|
658
648
|
set(e, t) {
|
|
659
649
|
this.storage[e] = t, this.save();
|
|
@@ -691,7 +681,7 @@ class J {
|
|
|
691
681
|
}
|
|
692
682
|
}
|
|
693
683
|
}
|
|
694
|
-
class
|
|
684
|
+
class pe {
|
|
695
685
|
constructor() {
|
|
696
686
|
this.storage = {};
|
|
697
687
|
}
|
|
@@ -710,10 +700,10 @@ class ge {
|
|
|
710
700
|
this.storage = {};
|
|
711
701
|
}
|
|
712
702
|
}
|
|
713
|
-
class
|
|
703
|
+
class F {
|
|
714
704
|
// Default to true for server-side
|
|
715
|
-
constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o =
|
|
716
|
-
this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new
|
|
705
|
+
constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = g()) {
|
|
706
|
+
this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new V("offline_queue"), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
717
707
|
}
|
|
718
708
|
add(e) {
|
|
719
709
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -757,7 +747,7 @@ class D {
|
|
|
757
747
|
u() && this.persistence.set("queue", JSON.stringify(this.queue));
|
|
758
748
|
}
|
|
759
749
|
}
|
|
760
|
-
class
|
|
750
|
+
class me {
|
|
761
751
|
constructor(e) {
|
|
762
752
|
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
|
|
763
753
|
}
|
|
@@ -791,8 +781,8 @@ class de {
|
|
|
791
781
|
}), this.clicks = [];
|
|
792
782
|
}
|
|
793
783
|
}
|
|
794
|
-
class
|
|
795
|
-
constructor(e, t, s =
|
|
784
|
+
class ye {
|
|
785
|
+
constructor(e, t, s = g()) {
|
|
796
786
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
797
787
|
}
|
|
798
788
|
async send(e) {
|
|
@@ -827,7 +817,7 @@ class fe {
|
|
|
827
817
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
828
818
|
}
|
|
829
819
|
}
|
|
830
|
-
class
|
|
820
|
+
class y {
|
|
831
821
|
constructor(e, t = "all", s = {}) {
|
|
832
822
|
this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
833
823
|
}
|
|
@@ -842,18 +832,18 @@ class m {
|
|
|
842
832
|
}
|
|
843
833
|
handleFormSubmit(e) {
|
|
844
834
|
const t = e.target, s = this._getFormDetails(t);
|
|
845
|
-
this.instance.track("$form",
|
|
835
|
+
this.instance.track("$form", R(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
846
836
|
}
|
|
847
837
|
trackFieldChanges(e) {
|
|
848
838
|
e.querySelectorAll("input, select, textarea").forEach((s) => {
|
|
849
839
|
s.addEventListener("change", (n) => {
|
|
850
840
|
const r = this._getFieldProps(n.target, 0);
|
|
851
|
-
this.instance.track("$form_field_change",
|
|
841
|
+
this.instance.track("$form_field_change", R(r));
|
|
852
842
|
});
|
|
853
843
|
});
|
|
854
844
|
}
|
|
855
845
|
static getInstance(e, t = "all", s = {}) {
|
|
856
|
-
return
|
|
846
|
+
return y.instance || (y.instance = new y(e, t, s)), y.instance;
|
|
857
847
|
}
|
|
858
848
|
_getFormDetails(e) {
|
|
859
849
|
const t = {
|
|
@@ -941,9 +931,9 @@ class m {
|
|
|
941
931
|
return e.slice(t, s + 1);
|
|
942
932
|
}
|
|
943
933
|
}
|
|
944
|
-
class
|
|
934
|
+
class we {
|
|
945
935
|
constructor(e) {
|
|
946
|
-
this.config = this.mergeConfig(e,
|
|
936
|
+
this.config = this.mergeConfig(e, U), this.logger = g(this.config.logLevel), this.namespace = e.namespace || "usermaven", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new F(
|
|
947
937
|
this.transport,
|
|
948
938
|
this.config.maxSendAttempts || 3,
|
|
949
939
|
this.config.minSendTimeout || 1e3,
|
|
@@ -954,13 +944,13 @@ class pe {
|
|
|
954
944
|
), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
|
|
955
945
|
}
|
|
956
946
|
initializeBrowserFeatures() {
|
|
957
|
-
if (this.cookieManager = new
|
|
947
|
+
if (this.cookieManager = new X(this.config.cookieDomain), this.config.autocapture && S.enabledForProject(this.config.key) && (this.autoCapture = new S(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
958
948
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
959
|
-
this.formTracking =
|
|
949
|
+
this.formTracking = y.getInstance(this, e || "none", {
|
|
960
950
|
trackFieldChanges: !1
|
|
961
951
|
});
|
|
962
952
|
}
|
|
963
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
953
|
+
this.config.autoPageview && (this.pageviewTracking = new ge(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new me(this)), this.setupPageLeaveTracking();
|
|
964
954
|
}
|
|
965
955
|
/**
|
|
966
956
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -975,7 +965,7 @@ class pe {
|
|
|
975
965
|
}), n;
|
|
976
966
|
}
|
|
977
967
|
init(e) {
|
|
978
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
968
|
+
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 F(
|
|
979
969
|
this.transport,
|
|
980
970
|
this.config.maxSendAttempts || 3,
|
|
981
971
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1009,58 +999,46 @@ class pe {
|
|
|
1009
999
|
}
|
|
1010
1000
|
initializeTransport(e) {
|
|
1011
1001
|
if (!u())
|
|
1012
|
-
return new
|
|
1002
|
+
return new ye(e.trackingHost, e);
|
|
1013
1003
|
const t = "XMLHttpRequest" in window, s = typeof fetch < "u", n = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1014
1004
|
if (e.useBeaconApi && n)
|
|
1015
|
-
return new
|
|
1005
|
+
return new de(e.trackingHost, e, this.logger);
|
|
1016
1006
|
if (e.forceUseFetch && s)
|
|
1017
|
-
return new
|
|
1007
|
+
return new D(e.trackingHost, e, this.logger);
|
|
1018
1008
|
if (t)
|
|
1019
|
-
return new
|
|
1009
|
+
return new fe(e.trackingHost, e, this.logger);
|
|
1020
1010
|
if (s)
|
|
1021
|
-
return new
|
|
1011
|
+
return new D(e.trackingHost, e, this.logger);
|
|
1022
1012
|
throw new Error("No suitable transport method available");
|
|
1023
1013
|
}
|
|
1024
1014
|
initializePersistence() {
|
|
1025
|
-
return this.config.disableEventPersistence || !u() ? new
|
|
1015
|
+
return this.config.disableEventPersistence || !u() ? new pe() : new V(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1026
1016
|
}
|
|
1027
1017
|
getOrCreateAnonymousId() {
|
|
1028
1018
|
var s, n;
|
|
1029
1019
|
if (!u())
|
|
1030
|
-
return
|
|
1020
|
+
return T();
|
|
1031
1021
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1032
|
-
return
|
|
1022
|
+
return "";
|
|
1033
1023
|
const e = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
|
|
1034
1024
|
let t = (s = this.cookieManager) == null ? void 0 : s.get(e);
|
|
1035
1025
|
if (!t) {
|
|
1036
1026
|
if (this.config.crossDomainLinking) {
|
|
1037
|
-
const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"),
|
|
1038
|
-
t = c ||
|
|
1027
|
+
const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
|
|
1028
|
+
t = c || h || T();
|
|
1039
1029
|
}
|
|
1040
|
-
t || (t =
|
|
1030
|
+
t || (t = T());
|
|
1041
1031
|
const r = 365 * 10;
|
|
1042
1032
|
(n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
|
|
1043
1033
|
}
|
|
1044
1034
|
return t;
|
|
1045
1035
|
}
|
|
1046
|
-
generateFingerprint() {
|
|
1047
|
-
const e = navigator.userAgent, t = `${screen.width}x${screen.height}`, s = screen.colorDepth, n = Intl.DateTimeFormat().resolvedOptions().timeZone, r = `${e}|${t}|${s}|${n}`;
|
|
1048
|
-
return this.hashString(r);
|
|
1049
|
-
}
|
|
1050
|
-
hashString(e) {
|
|
1051
|
-
let t = 0;
|
|
1052
|
-
for (let s = 0; s < e.length; s++) {
|
|
1053
|
-
const n = e.charCodeAt(s);
|
|
1054
|
-
t = (t << 5) - t + n, t = t & t;
|
|
1055
|
-
}
|
|
1056
|
-
return t.toString(36);
|
|
1057
|
-
}
|
|
1058
1036
|
async id(e, t = !1) {
|
|
1059
1037
|
if (!k(e))
|
|
1060
1038
|
throw new Error("User data must be an object");
|
|
1061
|
-
if (e.email && !
|
|
1039
|
+
if (e.email && !ae(e.email))
|
|
1062
1040
|
throw new Error("Invalid email provided");
|
|
1063
|
-
if (!e.id || !
|
|
1041
|
+
if (!e.id || !I(e.id))
|
|
1064
1042
|
throw new Error("User ID must be a string");
|
|
1065
1043
|
const s = e.id;
|
|
1066
1044
|
if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
|
|
@@ -1076,7 +1054,7 @@ class pe {
|
|
|
1076
1054
|
this.trackInternal(e, t, s);
|
|
1077
1055
|
}
|
|
1078
1056
|
trackInternal(e, t, s = !1) {
|
|
1079
|
-
if (!
|
|
1057
|
+
if (!I(e))
|
|
1080
1058
|
throw new Error("Event name must be a string");
|
|
1081
1059
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1082
1060
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
@@ -1125,11 +1103,11 @@ class pe {
|
|
|
1125
1103
|
...c
|
|
1126
1104
|
};
|
|
1127
1105
|
if (e === "$autocapture") {
|
|
1128
|
-
const
|
|
1129
|
-
a.autocapture_attributes =
|
|
1106
|
+
const h = this.processAutocaptureAttributes(t || {});
|
|
1107
|
+
a.autocapture_attributes = h;
|
|
1130
1108
|
} else
|
|
1131
|
-
Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((
|
|
1132
|
-
delete l[
|
|
1109
|
+
Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((h) => {
|
|
1110
|
+
delete l[h];
|
|
1133
1111
|
}), a.event_attributes = l;
|
|
1134
1112
|
return u() && (a.referer = document.referrer, a.url = window.location.href, a.page_title = document.title, a.doc_path = window.location.pathname, a.doc_host = window.location.hostname, a.doc_search = window.location.search, a.screen_resolution = `${window.screen.width}x${window.screen.height}`, a.vp_size = `${window.innerWidth}x${window.innerHeight}`, a.user_agent = navigator.userAgent, a.user_language = navigator.language, a.doc_encoding = document.characterSet, a.utm = this.getUtmParams()), a;
|
|
1135
1113
|
}
|
|
@@ -1153,7 +1131,7 @@ class pe {
|
|
|
1153
1131
|
return e;
|
|
1154
1132
|
}
|
|
1155
1133
|
getUtmParams() {
|
|
1156
|
-
const e = {}, t =
|
|
1134
|
+
const e = {}, t = le(window.location.search);
|
|
1157
1135
|
return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((n) => {
|
|
1158
1136
|
t[n] && (e[n.replace("utm_", "")] = t[n]);
|
|
1159
1137
|
}), e;
|
|
@@ -1234,20 +1212,20 @@ class pe {
|
|
|
1234
1212
|
n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
|
|
1235
1213
|
}
|
|
1236
1214
|
}
|
|
1237
|
-
function
|
|
1238
|
-
const e = JSON.parse(JSON.stringify(i)), t =
|
|
1215
|
+
function ke(i) {
|
|
1216
|
+
const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...U, ...t };
|
|
1239
1217
|
if (!s.key)
|
|
1240
1218
|
throw new Error("API key is required!");
|
|
1241
1219
|
if (!s.trackingHost)
|
|
1242
1220
|
throw new Error("Tracking host is required!");
|
|
1243
|
-
return new
|
|
1221
|
+
return new we(s);
|
|
1244
1222
|
}
|
|
1245
|
-
function
|
|
1223
|
+
function ve(i) {
|
|
1246
1224
|
var n;
|
|
1247
1225
|
const e = {
|
|
1248
1226
|
key: i.getAttribute("data-key") || void 0,
|
|
1249
1227
|
trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1250
|
-
logLevel:
|
|
1228
|
+
logLevel: ue(i.getAttribute("data-log-level")),
|
|
1251
1229
|
autocapture: i.getAttribute("data-autocapture") === "true",
|
|
1252
1230
|
formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
|
|
1253
1231
|
autoPageview: i.getAttribute("data-auto-pageview") === "true",
|
|
@@ -1272,10 +1250,10 @@ function ye(i) {
|
|
|
1272
1250
|
domains: i.getAttribute("data-domains") || void 0,
|
|
1273
1251
|
maskAllText: i.getAttribute("data-mask-all-text") === "true",
|
|
1274
1252
|
maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1275
|
-
}, t =
|
|
1276
|
-
u() && t.pageview(),
|
|
1253
|
+
}, t = ke(e), s = e.namespace || "usermaven";
|
|
1254
|
+
u() && t.pageview(), _e(s, t);
|
|
1277
1255
|
}
|
|
1278
|
-
function
|
|
1256
|
+
function _e(i, e) {
|
|
1279
1257
|
let t = !1;
|
|
1280
1258
|
const s = [], n = [];
|
|
1281
1259
|
function r() {
|
|
@@ -1288,8 +1266,8 @@ function we(i, e) {
|
|
|
1288
1266
|
n.forEach((a) => a()), n.length = 0;
|
|
1289
1267
|
}
|
|
1290
1268
|
window[i] = function(...a) {
|
|
1291
|
-
const
|
|
1292
|
-
if (
|
|
1269
|
+
const h = a[0];
|
|
1270
|
+
if (h === "onLoad") {
|
|
1293
1271
|
typeof a[1] == "function" && (t ? a[1]() : n.push(a[1]));
|
|
1294
1272
|
return;
|
|
1295
1273
|
}
|
|
@@ -1297,9 +1275,9 @@ function we(i, e) {
|
|
|
1297
1275
|
s.push(a);
|
|
1298
1276
|
return;
|
|
1299
1277
|
}
|
|
1300
|
-
if (typeof e[
|
|
1301
|
-
return e[
|
|
1302
|
-
console.error(`Method ${
|
|
1278
|
+
if (typeof e[h] == "function")
|
|
1279
|
+
return e[h].apply(e, a.slice(1));
|
|
1280
|
+
console.error(`Method ${h} not found on UsermavenClient`);
|
|
1303
1281
|
};
|
|
1304
1282
|
const c = `${i}Q`, l = window[c] || [];
|
|
1305
1283
|
for (window[c] = l, l.push = function(...a) {
|
|
@@ -1314,12 +1292,12 @@ function we(i, e) {
|
|
|
1314
1292
|
u() && function(i, e) {
|
|
1315
1293
|
const t = i.currentScript;
|
|
1316
1294
|
function s() {
|
|
1317
|
-
t && t.src.includes("lib.js") &&
|
|
1295
|
+
t && t.src.includes("lib.js") && ve(t);
|
|
1318
1296
|
}
|
|
1319
1297
|
typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
|
|
1320
1298
|
}(document, window);
|
|
1321
1299
|
export {
|
|
1322
1300
|
v as LogLevel,
|
|
1323
|
-
|
|
1324
|
-
|
|
1301
|
+
we as UsermavenClient,
|
|
1302
|
+
ke as usermavenClient
|
|
1325
1303
|
};
|