@usermaven/react 1.5.13-rc.120 → 1.5.13
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/lib/index.es.js +292 -298
- package/package.json +2 -2
package/lib/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ class se {
|
|
|
26
26
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function p(s = 0) {
|
|
30
30
|
return new se(s);
|
|
31
31
|
}
|
|
32
32
|
const Y = {
|
|
@@ -68,8 +68,8 @@ class ne {
|
|
|
68
68
|
set(e, t, i = 365, n = !0, r = !1) {
|
|
69
69
|
const o = /* @__PURE__ */ new Date();
|
|
70
70
|
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
71
|
-
const a = `expires=${o.toUTCString()}`, c = n ? "; Secure" : "",
|
|
72
|
-
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${c}${
|
|
71
|
+
const a = `expires=${o.toUTCString()}`, c = n ? "; Secure" : "", h = r ? "; HttpOnly" : "";
|
|
72
|
+
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${c}${h}`;
|
|
73
73
|
}
|
|
74
74
|
get(e) {
|
|
75
75
|
const t = e + "=", i = document.cookie.split(";");
|
|
@@ -110,10 +110,10 @@ class ne {
|
|
|
110
110
|
return i ? i[0] : "";
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype,
|
|
113
|
+
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, I = ae.forEach, F = {};
|
|
114
114
|
function ce(s, e, t) {
|
|
115
115
|
if (Array.isArray(s)) {
|
|
116
|
-
if (
|
|
116
|
+
if (I && s.forEach === I)
|
|
117
117
|
s.forEach(e, t);
|
|
118
118
|
else if ("length" in s && s.length === +s.length) {
|
|
119
119
|
for (let i = 0, n = s.length; i < n; i++)
|
|
@@ -122,15 +122,15 @@ function ce(s, e, t) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
const
|
|
125
|
+
const v = function(s) {
|
|
126
126
|
return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
127
127
|
}, le = function(s) {
|
|
128
128
|
for (const e in s)
|
|
129
129
|
typeof s[e] == "function" && (s[e] = s[e].bind(s));
|
|
130
130
|
};
|
|
131
|
-
function
|
|
131
|
+
function k(s, e, t) {
|
|
132
132
|
if (s != null) {
|
|
133
|
-
if (
|
|
133
|
+
if (I && Array.isArray(s) && s.forEach === I)
|
|
134
134
|
s.forEach(e, t);
|
|
135
135
|
else if ("length" in s && s.length === +s.length) {
|
|
136
136
|
for (let i = 0, n = s.length; i < n; i++)
|
|
@@ -148,7 +148,7 @@ const ue = function(s, ...e) {
|
|
|
148
148
|
t[i] !== void 0 && (s[i] = t[i]);
|
|
149
149
|
}), s;
|
|
150
150
|
};
|
|
151
|
-
function
|
|
151
|
+
function $(s, e) {
|
|
152
152
|
return s.indexOf(e) !== -1;
|
|
153
153
|
}
|
|
154
154
|
const he = function(s) {
|
|
@@ -159,17 +159,17 @@ const he = function(s) {
|
|
|
159
159
|
}
|
|
160
160
|
}, de = function(s) {
|
|
161
161
|
return s === void 0;
|
|
162
|
-
},
|
|
162
|
+
}, A = function() {
|
|
163
163
|
const s = function(i, n, r, o, a) {
|
|
164
164
|
if (!i) {
|
|
165
|
-
|
|
165
|
+
p().error("No valid element provided to register_event");
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
if (i.addEventListener && !o)
|
|
169
169
|
i.addEventListener(n, r, !!a);
|
|
170
170
|
else {
|
|
171
|
-
const c = "on" + n,
|
|
172
|
-
i[c] = e(i, r,
|
|
171
|
+
const c = "on" + n, h = i[c];
|
|
172
|
+
i[c] = e(i, r, h);
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
175
|
function e(i, n, r) {
|
|
@@ -178,8 +178,8 @@ const he = function(s) {
|
|
|
178
178
|
return;
|
|
179
179
|
let a = !0, c;
|
|
180
180
|
he(r) && (c = r(o));
|
|
181
|
-
const
|
|
182
|
-
return (c === !1 ||
|
|
181
|
+
const h = n.call(i, o);
|
|
182
|
+
return (c === !1 || h === !1) && (a = !1), a;
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
function t(i) {
|
|
@@ -195,7 +195,7 @@ const he = function(s) {
|
|
|
195
195
|
try {
|
|
196
196
|
return s.apply(this, e);
|
|
197
197
|
} catch (t) {
|
|
198
|
-
|
|
198
|
+
p().error(
|
|
199
199
|
"Implementation error. Please turn on debug and contact support@usermaven.com.",
|
|
200
200
|
t
|
|
201
201
|
);
|
|
@@ -210,11 +210,11 @@ function V(s) {
|
|
|
210
210
|
(s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
|
|
211
211
|
return s;
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function d() {
|
|
214
214
|
try {
|
|
215
215
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
216
216
|
} catch {
|
|
217
|
-
return
|
|
217
|
+
return p().warn("window is not available"), !1;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
function E(s = 5) {
|
|
@@ -236,7 +236,7 @@ function Q(s) {
|
|
|
236
236
|
{}
|
|
237
237
|
);
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function O(s) {
|
|
240
240
|
switch (typeof s.className) {
|
|
241
241
|
case "string":
|
|
242
242
|
return s.className;
|
|
@@ -248,9 +248,9 @@ function D(s) {
|
|
|
248
248
|
}
|
|
249
249
|
function J(s) {
|
|
250
250
|
let e = "";
|
|
251
|
-
return
|
|
252
|
-
j(t) && t.textContent && (e +=
|
|
253
|
-
}),
|
|
251
|
+
return z(s) && !ee(s) && s.childNodes && s.childNodes.length && k(s.childNodes, function(t) {
|
|
252
|
+
j(t) && t.textContent && (e += v(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
253
|
+
}), v(e);
|
|
254
254
|
}
|
|
255
255
|
function b(s) {
|
|
256
256
|
return !!s && s.nodeType === 1;
|
|
@@ -261,10 +261,10 @@ function w(s, e) {
|
|
|
261
261
|
function j(s) {
|
|
262
262
|
return !!s && s.nodeType === 3;
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function q(s) {
|
|
265
265
|
return !!s && s.nodeType === 11;
|
|
266
266
|
}
|
|
267
|
-
const
|
|
267
|
+
const T = [
|
|
268
268
|
"a",
|
|
269
269
|
"button",
|
|
270
270
|
"form",
|
|
@@ -281,21 +281,21 @@ function pe(s, e) {
|
|
|
281
281
|
for (; t && !w(t, "body"); ) {
|
|
282
282
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
283
283
|
return !1;
|
|
284
|
-
t.parentNode &&
|
|
284
|
+
t.parentNode && q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
285
285
|
}
|
|
286
286
|
let i = !1;
|
|
287
287
|
for (t = s; t && !w(t, "body"); ) {
|
|
288
|
-
if (t.parentNode &&
|
|
289
|
-
t = t.parentNode.host, t && b(t) &&
|
|
288
|
+
if (t.parentNode && q(t.parentNode)) {
|
|
289
|
+
t = t.parentNode.host, t && b(t) && T.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
290
290
|
continue;
|
|
291
291
|
}
|
|
292
292
|
const c = t.parentNode;
|
|
293
293
|
if (!c || !b(c)) break;
|
|
294
|
-
if (
|
|
294
|
+
if (T.indexOf(c.tagName.toLowerCase()) > -1)
|
|
295
295
|
i = !0;
|
|
296
296
|
else {
|
|
297
|
-
const
|
|
298
|
-
|
|
297
|
+
const h = window.getComputedStyle(c);
|
|
298
|
+
h && h.getPropertyValue("cursor") === "pointer" && (i = !0);
|
|
299
299
|
}
|
|
300
300
|
t = c;
|
|
301
301
|
}
|
|
@@ -315,16 +315,16 @@ function pe(s, e) {
|
|
|
315
315
|
case "textarea":
|
|
316
316
|
return e.type === "change" || e.type === "click";
|
|
317
317
|
default:
|
|
318
|
-
return i ? e.type === "click" : e.type === "click" && (
|
|
318
|
+
return i ? e.type === "click" : e.type === "click" && (T.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function z(s) {
|
|
322
322
|
for (let i = s; i.parentNode && !w(i, "body"); i = i.parentNode) {
|
|
323
|
-
const n =
|
|
324
|
-
if (
|
|
323
|
+
const n = O(i).split(" ");
|
|
324
|
+
if ($(n, "ph-sensitive") || $(n, "ph-no-capture"))
|
|
325
325
|
return !1;
|
|
326
326
|
}
|
|
327
|
-
if (
|
|
327
|
+
if ($(O(s).split(" "), "ph-include"))
|
|
328
328
|
return !0;
|
|
329
329
|
const e = s.type || "";
|
|
330
330
|
if (typeof e == "string")
|
|
@@ -341,8 +341,8 @@ function ee(s) {
|
|
|
341
341
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
342
342
|
return !!(w(s, "input") && !e.includes(s.type) || w(s, "select") || w(s, "textarea") || s.getAttribute("contenteditable") === "true");
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
return !(s === null || de(s) || typeof s == "string" && (s =
|
|
344
|
+
function H(s) {
|
|
345
|
+
return !(s === null || de(s) || typeof s == "string" && (s = v(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)));
|
|
346
346
|
}
|
|
347
347
|
function me(s) {
|
|
348
348
|
return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
|
|
@@ -351,10 +351,10 @@ function ye(s) {
|
|
|
351
351
|
if (!s)
|
|
352
352
|
return !1;
|
|
353
353
|
const e = s.$el_text;
|
|
354
|
-
if (typeof e == "string" &&
|
|
354
|
+
if (typeof e == "string" && v(e).length > 0)
|
|
355
355
|
return !0;
|
|
356
356
|
const t = s.classes;
|
|
357
|
-
if (Array.isArray(t) && t.some((n) =>
|
|
357
|
+
if (Array.isArray(t) && t.some((n) => v(n).length > 0))
|
|
358
358
|
return !0;
|
|
359
359
|
const i = [
|
|
360
360
|
"attr__id",
|
|
@@ -367,17 +367,112 @@ function ye(s) {
|
|
|
367
367
|
];
|
|
368
368
|
for (const n of i) {
|
|
369
369
|
const r = s[n];
|
|
370
|
-
if (typeof r == "string" &&
|
|
370
|
+
if (typeof r == "string" && v(r).length > 0)
|
|
371
371
|
return !0;
|
|
372
372
|
}
|
|
373
373
|
for (const [n, r] of Object.entries(s))
|
|
374
|
-
if (n.startsWith("attr__data-") && typeof r == "string" &&
|
|
374
|
+
if (n.startsWith("attr__data-") && typeof r == "string" && v(r).length > 0)
|
|
375
375
|
return !0;
|
|
376
376
|
return !1;
|
|
377
377
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
function x() {
|
|
379
|
+
return E(10);
|
|
380
|
+
}
|
|
381
|
+
function W(s) {
|
|
382
|
+
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());
|
|
383
|
+
}
|
|
384
|
+
function we(s, e) {
|
|
385
|
+
let t;
|
|
386
|
+
return function(...i) {
|
|
387
|
+
const n = () => {
|
|
388
|
+
clearTimeout(t), s(...i);
|
|
389
|
+
};
|
|
390
|
+
clearTimeout(t), t = setTimeout(n, e);
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function ke(s) {
|
|
394
|
+
const e = {}, t = s.replace(/^\?/, "").split("&");
|
|
395
|
+
for (let i = 0; i < t.length; i++) {
|
|
396
|
+
const n = t[i].split("=");
|
|
397
|
+
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
398
|
+
}
|
|
399
|
+
return e;
|
|
400
|
+
}
|
|
401
|
+
function U(s) {
|
|
402
|
+
return typeof s == "string" || s instanceof String;
|
|
403
|
+
}
|
|
404
|
+
function S(s) {
|
|
405
|
+
return s !== null && typeof s == "object" && s.constructor === Object;
|
|
406
|
+
}
|
|
407
|
+
function ve(s) {
|
|
408
|
+
if (s === null)
|
|
409
|
+
return _.ERROR;
|
|
410
|
+
const e = s.toUpperCase(), t = _[e];
|
|
411
|
+
return t || t === 0 ? t : _.ERROR;
|
|
412
|
+
}
|
|
413
|
+
const be = () => {
|
|
414
|
+
let s = "false";
|
|
415
|
+
return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
|
|
416
|
+
};
|
|
417
|
+
class _e {
|
|
418
|
+
constructor(e) {
|
|
419
|
+
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = we(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
420
|
+
}
|
|
421
|
+
initializeEventListener() {
|
|
422
|
+
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
423
|
+
}
|
|
424
|
+
track() {
|
|
425
|
+
const e = this.getScrollDepth();
|
|
426
|
+
e > this.lastScrollDepth && (this.lastScrollDepth = e, this.checkMilestones(e));
|
|
427
|
+
}
|
|
428
|
+
send(e = "$scroll") {
|
|
429
|
+
if (!this.lastScrollDepth)
|
|
430
|
+
return;
|
|
431
|
+
const t = {
|
|
432
|
+
percent: this.lastScrollDepth,
|
|
433
|
+
window_height: this.getWindowHeight(),
|
|
434
|
+
document_height: this.getDocumentHeight(),
|
|
435
|
+
scroll_distance: this.getScrollDistance()
|
|
436
|
+
};
|
|
437
|
+
this.client.track(e, t);
|
|
438
|
+
}
|
|
439
|
+
handleScroll() {
|
|
440
|
+
this.track();
|
|
441
|
+
}
|
|
442
|
+
getScrollDepth() {
|
|
443
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
|
|
444
|
+
return Math.min(100, Math.floor(i / n * 100));
|
|
445
|
+
}
|
|
446
|
+
getWindowHeight() {
|
|
447
|
+
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
448
|
+
}
|
|
449
|
+
getDocumentHeight() {
|
|
450
|
+
return Math.max(
|
|
451
|
+
document.body.scrollHeight || 0,
|
|
452
|
+
this.documentElement.scrollHeight || 0,
|
|
453
|
+
document.body.offsetHeight || 0,
|
|
454
|
+
this.documentElement.offsetHeight || 0,
|
|
455
|
+
document.body.clientHeight || 0,
|
|
456
|
+
this.documentElement.clientHeight || 0
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
getScrollDistance() {
|
|
460
|
+
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
461
|
+
}
|
|
462
|
+
checkMilestones(e) {
|
|
463
|
+
this.milestones.filter(
|
|
464
|
+
(i) => e >= i
|
|
465
|
+
).forEach((i) => {
|
|
466
|
+
this.send(), this.milestones = this.milestones.filter((n) => n !== i);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
destroy() {
|
|
470
|
+
window.removeEventListener("scroll", this.debouncedHandleScroll);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const D = class D {
|
|
474
|
+
constructor(e, t, i = p()) {
|
|
475
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), le(this), G(this);
|
|
381
476
|
}
|
|
382
477
|
isBrowserSupported() {
|
|
383
478
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -403,70 +498,83 @@ const N = class N {
|
|
|
403
498
|
const e = (t) => {
|
|
404
499
|
t = t || window.event, this.captureEvent(t);
|
|
405
500
|
};
|
|
406
|
-
|
|
501
|
+
A(document, "submit", e, !1, !0), A(document, "change", e, !1, !0), A(document, "click", e, !1, !0), A(document, "visibilitychange", e, !1, !0), A(document, "scroll", e, !1, !0), A(window, "popstate", e, !1, !0);
|
|
502
|
+
}
|
|
503
|
+
isPageRefresh() {
|
|
504
|
+
if ("PerformanceNavigationTiming" in window) {
|
|
505
|
+
const e = performance.getEntriesByType("navigation");
|
|
506
|
+
if (e.length > 0)
|
|
507
|
+
return e[0].type === "reload";
|
|
508
|
+
}
|
|
509
|
+
return performance.navigation && performance.navigation.type === 1;
|
|
407
510
|
}
|
|
408
511
|
captureEvent(e) {
|
|
512
|
+
var i, n;
|
|
409
513
|
let t = this.getEventTarget(e);
|
|
410
|
-
if (j(t) && (t = t.parentNode || null),
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
514
|
+
if (j(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
515
|
+
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
516
|
+
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
517
|
+
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
518
|
+
if (!(!t || !b(t)) && t && pe(t, e)) {
|
|
519
|
+
const r = [t];
|
|
520
|
+
let o = t;
|
|
521
|
+
for (; o != null && o.parentNode && !w(o, "body"); ) {
|
|
522
|
+
if (q(o == null ? void 0 : o.parentNode)) {
|
|
523
|
+
const g = (o == null ? void 0 : o.parentNode).host;
|
|
524
|
+
g && b(g) && r.push(g), o = g;
|
|
417
525
|
continue;
|
|
418
526
|
}
|
|
419
|
-
const l =
|
|
527
|
+
const l = o == null ? void 0 : o.parentNode;
|
|
420
528
|
if (!l || !b(l)) break;
|
|
421
|
-
|
|
529
|
+
r.push(l), o = l;
|
|
422
530
|
}
|
|
423
|
-
const
|
|
424
|
-
let
|
|
425
|
-
if (
|
|
531
|
+
const a = [];
|
|
532
|
+
let c, h = !1;
|
|
533
|
+
if (k(r, (l) => {
|
|
426
534
|
if (!l.tagName)
|
|
427
535
|
return;
|
|
428
|
-
const
|
|
429
|
-
l.tagName.toLowerCase() === "a" && (
|
|
430
|
-
const
|
|
431
|
-
|
|
536
|
+
const g = z(l);
|
|
537
|
+
l.tagName.toLowerCase() === "a" && (c = l.getAttribute("href"), c = g && H(c) && c);
|
|
538
|
+
const u = O(l).split(" ");
|
|
539
|
+
$(u, "ph-no-capture") && (h = !0), a.push(
|
|
432
540
|
this.getPropertiesFromElement(
|
|
433
541
|
l,
|
|
434
542
|
this.options.maskAllElementAttributes ?? !1,
|
|
435
543
|
this.options.maskAllText ?? !1
|
|
436
544
|
)
|
|
437
545
|
);
|
|
438
|
-
}), this.options.maskAllText || (
|
|
546
|
+
}), this.options.maskAllText || (a[0].$el_text = J(t)), c && (a[0].attr__href = c), h)
|
|
439
547
|
return !1;
|
|
440
|
-
if (!ye(
|
|
548
|
+
if (!ye(a[0]))
|
|
441
549
|
return this.logger.debug("Dropping autocapture event without identifiers."), !1;
|
|
442
|
-
const
|
|
550
|
+
const f = ue(
|
|
443
551
|
this.getDefaultProperties(e.type),
|
|
444
552
|
{
|
|
445
|
-
$elements:
|
|
553
|
+
$elements: a
|
|
446
554
|
},
|
|
447
|
-
this.getCustomProperties(
|
|
555
|
+
this.getCustomProperties(r)
|
|
448
556
|
);
|
|
449
|
-
return this.client.track("$autocapture",
|
|
557
|
+
return this.client.track("$autocapture", f), !0;
|
|
450
558
|
}
|
|
451
559
|
}
|
|
452
560
|
getCustomProperties(e) {
|
|
453
561
|
const t = {};
|
|
454
|
-
return
|
|
455
|
-
|
|
562
|
+
return k(this.customProperties, (i) => {
|
|
563
|
+
k(i.event_selectors, (n) => {
|
|
456
564
|
const r = document.querySelectorAll(n);
|
|
457
|
-
|
|
458
|
-
|
|
565
|
+
k(r, (o) => {
|
|
566
|
+
$(e, o) && z(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
459
567
|
});
|
|
460
568
|
});
|
|
461
569
|
}), t;
|
|
462
570
|
}
|
|
463
571
|
extractCustomPropertyValue(e) {
|
|
464
572
|
const t = [];
|
|
465
|
-
return
|
|
573
|
+
return k(
|
|
466
574
|
document.querySelectorAll(e.css_selector),
|
|
467
575
|
function(i) {
|
|
468
576
|
let n;
|
|
469
|
-
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent),
|
|
577
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), H(n) && t.push(n);
|
|
470
578
|
}
|
|
471
579
|
), t.join(", ");
|
|
472
580
|
}
|
|
@@ -478,16 +586,16 @@ const N = class N {
|
|
|
478
586
|
const n = e.tagName.toLowerCase(), r = {
|
|
479
587
|
tag_name: n
|
|
480
588
|
};
|
|
481
|
-
|
|
482
|
-
const o =
|
|
483
|
-
o.length > 0 && (r.classes = o.split(" ").filter(function(
|
|
484
|
-
return
|
|
485
|
-
})),
|
|
486
|
-
ee(e) && ["name", "id", "class"].indexOf(
|
|
589
|
+
T.indexOf(n) > -1 && !i && (r.$el_text = J(e));
|
|
590
|
+
const o = O(e);
|
|
591
|
+
o.length > 0 && (r.classes = o.split(" ").filter(function(f) {
|
|
592
|
+
return f !== "";
|
|
593
|
+
})), k(e.attributes, function(f) {
|
|
594
|
+
ee(e) && ["name", "id", "class"].indexOf(f.name) === -1 || !t && H(f.value) && !me(f.name) && (r["attr__" + f.name] = f.value);
|
|
487
595
|
});
|
|
488
|
-
let a = 1, c = 1,
|
|
489
|
-
for (;
|
|
490
|
-
a++,
|
|
596
|
+
let a = 1, c = 1, h = e;
|
|
597
|
+
for (; h = this.previousElementSibling(h); )
|
|
598
|
+
a++, h.tagName === e.tagName && c++;
|
|
491
599
|
return r.nth_child = a, r.nth_of_type = c, r;
|
|
492
600
|
}
|
|
493
601
|
previousElementSibling(e) {
|
|
@@ -519,9 +627,9 @@ const N = class N {
|
|
|
519
627
|
return n % t < i;
|
|
520
628
|
}
|
|
521
629
|
};
|
|
522
|
-
|
|
523
|
-
let
|
|
524
|
-
class
|
|
630
|
+
D.FORCE_CAPTURE_ATTR = "data-um-force-capture", D.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
631
|
+
let N = D;
|
|
632
|
+
class Ee {
|
|
525
633
|
constructor(e) {
|
|
526
634
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
527
635
|
}
|
|
@@ -550,8 +658,8 @@ class we {
|
|
|
550
658
|
}));
|
|
551
659
|
}
|
|
552
660
|
}
|
|
553
|
-
class
|
|
554
|
-
constructor(e, t, i =
|
|
661
|
+
class Pe {
|
|
662
|
+
constructor(e, t, i = p()) {
|
|
555
663
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
556
664
|
}
|
|
557
665
|
async send(e) {
|
|
@@ -566,14 +674,14 @@ class ve {
|
|
|
566
674
|
throw new Error("Failed to queue events via Beacon API");
|
|
567
675
|
}
|
|
568
676
|
constructUrl(e) {
|
|
569
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n =
|
|
677
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
570
678
|
return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
571
679
|
}
|
|
572
680
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
573
681
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
574
682
|
}
|
|
575
|
-
class
|
|
576
|
-
constructor(e, t, i =
|
|
683
|
+
class K {
|
|
684
|
+
constructor(e, t, i = p()) {
|
|
577
685
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
578
686
|
}
|
|
579
687
|
async send(e) {
|
|
@@ -590,7 +698,7 @@ class W {
|
|
|
590
698
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
591
699
|
}
|
|
592
700
|
constructUrl(e) {
|
|
593
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n =
|
|
701
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
594
702
|
return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
595
703
|
}
|
|
596
704
|
getCustomHeaders() {
|
|
@@ -600,8 +708,8 @@ class W {
|
|
|
600
708
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
601
709
|
}
|
|
602
710
|
}
|
|
603
|
-
class
|
|
604
|
-
constructor(e, t, i =
|
|
711
|
+
class Ae {
|
|
712
|
+
constructor(e, t, i = p()) {
|
|
605
713
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
606
714
|
}
|
|
607
715
|
send(e) {
|
|
@@ -619,7 +727,7 @@ class ke {
|
|
|
619
727
|
});
|
|
620
728
|
}
|
|
621
729
|
constructUrl(e) {
|
|
622
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n =
|
|
730
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
623
731
|
return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
624
732
|
}
|
|
625
733
|
getCustomHeaders() {
|
|
@@ -631,7 +739,7 @@ class ke {
|
|
|
631
739
|
}
|
|
632
740
|
class te {
|
|
633
741
|
constructor(e, t) {
|
|
634
|
-
this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t ||
|
|
742
|
+
this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || p(), this.load();
|
|
635
743
|
}
|
|
636
744
|
set(e, t) {
|
|
637
745
|
this.storage[e] = t, this.save();
|
|
@@ -649,7 +757,7 @@ class te {
|
|
|
649
757
|
return !this.storageDisabled;
|
|
650
758
|
}
|
|
651
759
|
load() {
|
|
652
|
-
if (!
|
|
760
|
+
if (!d()) {
|
|
653
761
|
this.logger.warn("localStorage is not available in this environment");
|
|
654
762
|
return;
|
|
655
763
|
}
|
|
@@ -661,7 +769,7 @@ class te {
|
|
|
661
769
|
}
|
|
662
770
|
}
|
|
663
771
|
save() {
|
|
664
|
-
if (!
|
|
772
|
+
if (!d())
|
|
665
773
|
return this.logger.warn("localStorage is not available in this environment"), !1;
|
|
666
774
|
if (this.storageDisabled)
|
|
667
775
|
return !1;
|
|
@@ -682,7 +790,7 @@ class te {
|
|
|
682
790
|
));
|
|
683
791
|
}
|
|
684
792
|
}
|
|
685
|
-
class
|
|
793
|
+
class Se {
|
|
686
794
|
constructor() {
|
|
687
795
|
this.storage = {};
|
|
688
796
|
}
|
|
@@ -701,50 +809,11 @@ class be {
|
|
|
701
809
|
this.storage = {};
|
|
702
810
|
}
|
|
703
811
|
}
|
|
704
|
-
function $() {
|
|
705
|
-
return E(10);
|
|
706
|
-
}
|
|
707
|
-
function K(s) {
|
|
708
|
-
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());
|
|
709
|
-
}
|
|
710
|
-
function _e(s, e) {
|
|
711
|
-
let t;
|
|
712
|
-
return function(...i) {
|
|
713
|
-
const n = () => {
|
|
714
|
-
clearTimeout(t), s(...i);
|
|
715
|
-
};
|
|
716
|
-
clearTimeout(t), t = setTimeout(n, e);
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
function Ee(s) {
|
|
720
|
-
const e = {}, t = s.replace(/^\?/, "").split("&");
|
|
721
|
-
for (let i = 0; i < t.length; i++) {
|
|
722
|
-
const n = t[i].split("=");
|
|
723
|
-
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
724
|
-
}
|
|
725
|
-
return e;
|
|
726
|
-
}
|
|
727
|
-
function U(s) {
|
|
728
|
-
return typeof s == "string" || s instanceof String;
|
|
729
|
-
}
|
|
730
|
-
function S(s) {
|
|
731
|
-
return s !== null && typeof s == "object" && s.constructor === Object;
|
|
732
|
-
}
|
|
733
|
-
function Pe(s) {
|
|
734
|
-
if (s === null)
|
|
735
|
-
return _.ERROR;
|
|
736
|
-
const e = s.toUpperCase(), t = _[e];
|
|
737
|
-
return t || t === 0 ? t : _.ERROR;
|
|
738
|
-
}
|
|
739
|
-
const Se = () => {
|
|
740
|
-
let s = "false";
|
|
741
|
-
return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
|
|
742
|
-
};
|
|
743
812
|
class X {
|
|
744
|
-
constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o =
|
|
813
|
+
constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = p(), a = "default", c = 1e3, h = 25e5) {
|
|
745
814
|
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(
|
|
746
815
|
`offline_queue_${a}`
|
|
747
|
-
), this.maxQueueItems = c, this.maxQueueBytes =
|
|
816
|
+
), this.maxQueueItems = c, this.maxQueueBytes = h, d() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
748
817
|
}
|
|
749
818
|
add(e) {
|
|
750
819
|
const t = {
|
|
@@ -752,23 +821,23 @@ class X {
|
|
|
752
821
|
retries: 0,
|
|
753
822
|
timestamp: Date.now()
|
|
754
823
|
};
|
|
755
|
-
t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(),
|
|
824
|
+
t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), d() ? this.saveQueueToStorage() : this.processBatch();
|
|
756
825
|
}
|
|
757
826
|
initNetworkListeners() {
|
|
758
|
-
|
|
827
|
+
d() && (window.addEventListener("online", () => {
|
|
759
828
|
this.isOnline = !0, this.processBatch();
|
|
760
829
|
}), window.addEventListener("offline", () => {
|
|
761
830
|
this.isOnline = !1;
|
|
762
831
|
}));
|
|
763
832
|
}
|
|
764
833
|
scheduleBatch() {
|
|
765
|
-
|
|
834
|
+
d() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
766
835
|
() => this.processBatch(),
|
|
767
836
|
this.batchInterval
|
|
768
837
|
));
|
|
769
838
|
}
|
|
770
839
|
async processBatch() {
|
|
771
|
-
if ((!
|
|
840
|
+
if ((!d() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
772
841
|
this.processing = !0;
|
|
773
842
|
const e = this.queue.splice(0, this.batchSize);
|
|
774
843
|
this.totalQueueBytes = Math.max(
|
|
@@ -779,13 +848,13 @@ class X {
|
|
|
779
848
|
try {
|
|
780
849
|
await this.transport.send(t), this.logger.debug(
|
|
781
850
|
`Successfully sent batch of ${e.length} payloads`
|
|
782
|
-
),
|
|
851
|
+
), d() && this.saveQueueToStorage();
|
|
783
852
|
} catch (i) {
|
|
784
853
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
785
854
|
}
|
|
786
855
|
this.processing = !1;
|
|
787
856
|
}
|
|
788
|
-
|
|
857
|
+
d() && this.scheduleBatch();
|
|
789
858
|
}
|
|
790
859
|
async handleBatchFailure(e) {
|
|
791
860
|
for (const t of e)
|
|
@@ -793,7 +862,7 @@ class X {
|
|
|
793
862
|
"Max retries reached, discarding payload",
|
|
794
863
|
t.payload
|
|
795
864
|
);
|
|
796
|
-
|
|
865
|
+
d() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
797
866
|
}
|
|
798
867
|
enforceQueueLimits() {
|
|
799
868
|
if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
|
|
@@ -826,7 +895,7 @@ class X {
|
|
|
826
895
|
}
|
|
827
896
|
}
|
|
828
897
|
loadQueueFromStorage() {
|
|
829
|
-
if (
|
|
898
|
+
if (d()) {
|
|
830
899
|
const e = this.persistence.get("queue");
|
|
831
900
|
if (!e) return;
|
|
832
901
|
try {
|
|
@@ -844,13 +913,13 @@ class X {
|
|
|
844
913
|
}
|
|
845
914
|
}
|
|
846
915
|
saveQueueToStorage() {
|
|
847
|
-
if (
|
|
916
|
+
if (d()) {
|
|
848
917
|
const e = this.queue.map(({ bytes: t, ...i }) => i);
|
|
849
918
|
this.persistence.set("queue", JSON.stringify(e));
|
|
850
919
|
}
|
|
851
920
|
}
|
|
852
921
|
}
|
|
853
|
-
class
|
|
922
|
+
class Ce {
|
|
854
923
|
constructor(e) {
|
|
855
924
|
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), G(this);
|
|
856
925
|
}
|
|
@@ -888,64 +957,8 @@ class Ae {
|
|
|
888
957
|
}), this.clicks = [];
|
|
889
958
|
}
|
|
890
959
|
}
|
|
891
|
-
class Ce {
|
|
892
|
-
constructor(e) {
|
|
893
|
-
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = _e(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
894
|
-
}
|
|
895
|
-
initializeEventListener() {
|
|
896
|
-
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
897
|
-
}
|
|
898
|
-
track() {
|
|
899
|
-
const e = this.getScrollDepth();
|
|
900
|
-
e > this.lastScrollDepth && (this.lastScrollDepth = e, this.checkMilestones(e));
|
|
901
|
-
}
|
|
902
|
-
send(e = "$scroll") {
|
|
903
|
-
if (!this.lastScrollDepth)
|
|
904
|
-
return;
|
|
905
|
-
const t = {
|
|
906
|
-
percent: this.lastScrollDepth,
|
|
907
|
-
window_height: this.getWindowHeight(),
|
|
908
|
-
document_height: this.getDocumentHeight(),
|
|
909
|
-
scroll_distance: this.getScrollDistance()
|
|
910
|
-
};
|
|
911
|
-
this.client.track(e, t);
|
|
912
|
-
}
|
|
913
|
-
handleScroll() {
|
|
914
|
-
this.track();
|
|
915
|
-
}
|
|
916
|
-
getScrollDepth() {
|
|
917
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
|
|
918
|
-
return Math.min(100, Math.floor(i / n * 100));
|
|
919
|
-
}
|
|
920
|
-
getWindowHeight() {
|
|
921
|
-
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
922
|
-
}
|
|
923
|
-
getDocumentHeight() {
|
|
924
|
-
return Math.max(
|
|
925
|
-
document.body.scrollHeight || 0,
|
|
926
|
-
this.documentElement.scrollHeight || 0,
|
|
927
|
-
document.body.offsetHeight || 0,
|
|
928
|
-
this.documentElement.offsetHeight || 0,
|
|
929
|
-
document.body.clientHeight || 0,
|
|
930
|
-
this.documentElement.clientHeight || 0
|
|
931
|
-
);
|
|
932
|
-
}
|
|
933
|
-
getScrollDistance() {
|
|
934
|
-
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
935
|
-
}
|
|
936
|
-
checkMilestones(e) {
|
|
937
|
-
this.milestones.filter(
|
|
938
|
-
(i) => e >= i
|
|
939
|
-
).forEach((i) => {
|
|
940
|
-
this.send(), this.milestones = this.milestones.filter((n) => n !== i);
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
destroy() {
|
|
944
|
-
window.removeEventListener("scroll", this.debouncedHandleScroll);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
960
|
class $e {
|
|
948
|
-
constructor(e, t, i =
|
|
961
|
+
constructor(e, t, i = p()) {
|
|
949
962
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
950
963
|
}
|
|
951
964
|
async send(e) {
|
|
@@ -961,10 +974,10 @@ class $e {
|
|
|
961
974
|
};
|
|
962
975
|
return new Promise((r, o) => {
|
|
963
976
|
const a = (void 0)(n, (c) => {
|
|
964
|
-
c.on("data", (
|
|
977
|
+
c.on("data", (h) => {
|
|
965
978
|
}), c.on("end", () => {
|
|
966
|
-
const
|
|
967
|
-
|
|
979
|
+
const h = c.statusCode || 0;
|
|
980
|
+
h >= 200 && h < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${h}`));
|
|
968
981
|
});
|
|
969
982
|
});
|
|
970
983
|
a.on("error", (c) => {
|
|
@@ -980,7 +993,7 @@ class $e {
|
|
|
980
993
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
981
994
|
}
|
|
982
995
|
}
|
|
983
|
-
class
|
|
996
|
+
class C {
|
|
984
997
|
constructor(e, t = "all", i = {}) {
|
|
985
998
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
986
999
|
}
|
|
@@ -1015,7 +1028,7 @@ class A {
|
|
|
1015
1028
|
});
|
|
1016
1029
|
}
|
|
1017
1030
|
static getInstance(e, t = "all", i = {}) {
|
|
1018
|
-
return
|
|
1031
|
+
return C.instance || (C.instance = new C(e, t, i)), C.instance;
|
|
1019
1032
|
}
|
|
1020
1033
|
_getFormDetails(e) {
|
|
1021
1034
|
const t = {
|
|
@@ -1116,9 +1129,9 @@ class A {
|
|
|
1116
1129
|
return e.slice(t, i + 1);
|
|
1117
1130
|
}
|
|
1118
1131
|
}
|
|
1119
|
-
class
|
|
1132
|
+
class R {
|
|
1120
1133
|
constructor(e) {
|
|
1121
|
-
this.config = this.mergeConfig(e, Y), this.logger =
|
|
1134
|
+
this.config = this.mergeConfig(e, Y), this.logger = p(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new X(
|
|
1122
1135
|
this.transport,
|
|
1123
1136
|
this.config.maxSendAttempts || 3,
|
|
1124
1137
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1127,14 +1140,14 @@ class L {
|
|
|
1127
1140
|
// Reduced interval to .2 second
|
|
1128
1141
|
this.logger,
|
|
1129
1142
|
this.namespace
|
|
1130
|
-
),
|
|
1143
|
+
), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1131
1144
|
`Usermaven client initialized for namespace: ${this.namespace}`
|
|
1132
1145
|
);
|
|
1133
1146
|
}
|
|
1134
1147
|
initializeBrowserFeatures() {
|
|
1135
|
-
if (this.cookieManager = new ne(this.config.cookieDomain), this.
|
|
1148
|
+
if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && N.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new N(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
1136
1149
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
1137
|
-
this.formTracking =
|
|
1150
|
+
this.formTracking = C.getInstance(
|
|
1138
1151
|
this,
|
|
1139
1152
|
e || "none",
|
|
1140
1153
|
{
|
|
@@ -1142,26 +1155,7 @@ class L {
|
|
|
1142
1155
|
}
|
|
1143
1156
|
);
|
|
1144
1157
|
}
|
|
1145
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
1146
|
-
}
|
|
1147
|
-
initializeScrollDepthListeners() {
|
|
1148
|
-
if (!this.scrollDepth) return;
|
|
1149
|
-
const e = this.scrollDepth, t = () => {
|
|
1150
|
-
if ("PerformanceNavigationTiming" in window) {
|
|
1151
|
-
const n = performance.getEntriesByType("navigation");
|
|
1152
|
-
if (n.length > 0)
|
|
1153
|
-
return n[0].type === "reload";
|
|
1154
|
-
}
|
|
1155
|
-
return performance.navigation && performance.navigation.type === 1;
|
|
1156
|
-
}, i = () => {
|
|
1157
|
-
t() || e.send();
|
|
1158
|
-
};
|
|
1159
|
-
this.scrollDepthVisibilityHandler = () => {
|
|
1160
|
-
document.visibilityState === "hidden" && i();
|
|
1161
|
-
}, this.scrollDepthPopstateHandler = i, document.addEventListener("visibilitychange", this.scrollDepthVisibilityHandler), window.addEventListener("popstate", this.scrollDepthPopstateHandler);
|
|
1162
|
-
}
|
|
1163
|
-
destroyScrollDepth() {
|
|
1164
|
-
this.scrollDepth && this.scrollDepth.destroy(), this.scrollDepthVisibilityHandler && (document.removeEventListener("visibilitychange", this.scrollDepthVisibilityHandler), this.scrollDepthVisibilityHandler = void 0), this.scrollDepthPopstateHandler && (window.removeEventListener("popstate", this.scrollDepthPopstateHandler), this.scrollDepthPopstateHandler = void 0);
|
|
1158
|
+
this.config.autoPageview && (this.pageviewTracking = new Ee(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ce(this)), this.setupPageLeaveTracking();
|
|
1165
1159
|
}
|
|
1166
1160
|
/**
|
|
1167
1161
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -1176,7 +1170,7 @@ class L {
|
|
|
1176
1170
|
}), n;
|
|
1177
1171
|
}
|
|
1178
1172
|
init(e) {
|
|
1179
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
1173
|
+
this.config = { ...this.config, ...e }, this.logger = p(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new X(
|
|
1180
1174
|
this.transport,
|
|
1181
1175
|
this.config.maxSendAttempts || 3,
|
|
1182
1176
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1185,7 +1179,7 @@ class L {
|
|
|
1185
1179
|
// Reduced interval to .25 second
|
|
1186
1180
|
this.logger,
|
|
1187
1181
|
this.namespace
|
|
1188
|
-
),
|
|
1182
|
+
), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1189
1183
|
`Usermaven client reinitialized for namespace: ${this.namespace}`
|
|
1190
1184
|
);
|
|
1191
1185
|
}
|
|
@@ -1213,29 +1207,29 @@ class L {
|
|
|
1213
1207
|
}
|
|
1214
1208
|
initializeTransport(e) {
|
|
1215
1209
|
const t = "https://events.usermaven.com";
|
|
1216
|
-
if (!
|
|
1210
|
+
if (!d())
|
|
1217
1211
|
return new $e(e.trackingHost || t, e);
|
|
1218
1212
|
const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1219
1213
|
if (e.useBeaconApi && r)
|
|
1220
|
-
return new
|
|
1214
|
+
return new Pe(
|
|
1221
1215
|
e.trackingHost || t,
|
|
1222
1216
|
e,
|
|
1223
1217
|
this.logger
|
|
1224
1218
|
);
|
|
1225
1219
|
if (e.forceUseFetch && n)
|
|
1226
|
-
return new
|
|
1220
|
+
return new K(
|
|
1227
1221
|
e.trackingHost || t,
|
|
1228
1222
|
e,
|
|
1229
1223
|
this.logger
|
|
1230
1224
|
);
|
|
1231
1225
|
if (i)
|
|
1232
|
-
return new
|
|
1226
|
+
return new Ae(
|
|
1233
1227
|
e.trackingHost || t,
|
|
1234
1228
|
e,
|
|
1235
1229
|
this.logger
|
|
1236
1230
|
);
|
|
1237
1231
|
if (n)
|
|
1238
|
-
return new
|
|
1232
|
+
return new K(
|
|
1239
1233
|
e.trackingHost || t,
|
|
1240
1234
|
e,
|
|
1241
1235
|
this.logger
|
|
@@ -1243,25 +1237,25 @@ class L {
|
|
|
1243
1237
|
throw new Error("No suitable transport method available");
|
|
1244
1238
|
}
|
|
1245
1239
|
initializePersistence() {
|
|
1246
|
-
return this.config.disableEventPersistence || !
|
|
1240
|
+
return this.config.disableEventPersistence || !d() ? new Se() : new te(
|
|
1247
1241
|
`${this.namespace}_${this.config.key}`,
|
|
1248
1242
|
this.logger
|
|
1249
1243
|
);
|
|
1250
1244
|
}
|
|
1251
1245
|
getOrCreateAnonymousId() {
|
|
1252
1246
|
var i, n;
|
|
1253
|
-
if (!
|
|
1254
|
-
return
|
|
1247
|
+
if (!d())
|
|
1248
|
+
return x();
|
|
1255
1249
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1256
1250
|
return "";
|
|
1257
1251
|
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1258
1252
|
let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
|
|
1259
1253
|
if (!t) {
|
|
1260
1254
|
if (this.config.crossDomainLinking) {
|
|
1261
|
-
const a = new URLSearchParams(window.location.search).get("_um"),
|
|
1262
|
-
t = a ||
|
|
1255
|
+
const a = new URLSearchParams(window.location.search).get("_um"), h = window.location.hash.substring(1).split("~"), f = h.length > 1 ? h[1] : void 0;
|
|
1256
|
+
t = a || f || x();
|
|
1263
1257
|
}
|
|
1264
|
-
t || (t =
|
|
1258
|
+
t || (t = x());
|
|
1265
1259
|
const r = 365 * 10;
|
|
1266
1260
|
(n = this.cookieManager) == null || n.set(
|
|
1267
1261
|
e,
|
|
@@ -1276,7 +1270,7 @@ class L {
|
|
|
1276
1270
|
async id(e, t = !1) {
|
|
1277
1271
|
if (!S(e))
|
|
1278
1272
|
throw new Error("User data must be an object");
|
|
1279
|
-
if (e.email && !
|
|
1273
|
+
if (e.email && !W(e.email))
|
|
1280
1274
|
throw new Error("Invalid email provided");
|
|
1281
1275
|
if (!e.id || !U(e.id))
|
|
1282
1276
|
throw new Error("User ID must be a string");
|
|
@@ -1304,14 +1298,14 @@ class L {
|
|
|
1304
1298
|
return;
|
|
1305
1299
|
}
|
|
1306
1300
|
const n = i.trim();
|
|
1307
|
-
if (!n || !
|
|
1301
|
+
if (!n || !W(n)) {
|
|
1308
1302
|
this.logger.error("Lead event requires a valid email attribute");
|
|
1309
1303
|
return;
|
|
1310
1304
|
}
|
|
1311
1305
|
e.email = n, this.track("lead", e, t);
|
|
1312
1306
|
}
|
|
1313
1307
|
trackInternal(e, t, i = !1) {
|
|
1314
|
-
if (
|
|
1308
|
+
if (be()) {
|
|
1315
1309
|
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1316
1310
|
return;
|
|
1317
1311
|
}
|
|
@@ -1347,10 +1341,10 @@ class L {
|
|
|
1347
1341
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1348
1342
|
}
|
|
1349
1343
|
createEventPayload(e, t) {
|
|
1350
|
-
const { event_id: i, ...n } = t || {}, r = this.persistence.get("userProps") || {}, o = this.persistence.get("companyProps") || (r == null ? void 0 : r.company) || {}, a = this.persistence.get("userId"), c = this.persistence.get("global_props") || {},
|
|
1351
|
-
let
|
|
1352
|
-
const
|
|
1353
|
-
event_id: i ||
|
|
1344
|
+
const { event_id: i, ...n } = t || {}, r = this.persistence.get("userProps") || {}, o = this.persistence.get("companyProps") || (r == null ? void 0 : r.company) || {}, a = this.persistence.get("userId"), c = this.persistence.get("global_props") || {}, h = this.persistence.get(`props_${e}`) || {};
|
|
1345
|
+
let f = n;
|
|
1346
|
+
const l = {
|
|
1347
|
+
event_id: i || x(),
|
|
1354
1348
|
user: {
|
|
1355
1349
|
anonymous_id: this.anonymousId,
|
|
1356
1350
|
id: a,
|
|
@@ -1365,17 +1359,17 @@ class L {
|
|
|
1365
1359
|
event_type: e,
|
|
1366
1360
|
namespace: this.namespace,
|
|
1367
1361
|
...c,
|
|
1368
|
-
...
|
|
1362
|
+
...h
|
|
1369
1363
|
};
|
|
1370
1364
|
if (e === "$autocapture") {
|
|
1371
|
-
const
|
|
1365
|
+
const g = this.processAutocaptureAttributes(
|
|
1372
1366
|
t || {}
|
|
1373
1367
|
);
|
|
1374
|
-
|
|
1375
|
-
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((
|
|
1376
|
-
delete
|
|
1377
|
-
}),
|
|
1378
|
-
return
|
|
1368
|
+
l.autocapture_attributes = g;
|
|
1369
|
+
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((g) => {
|
|
1370
|
+
delete f[g];
|
|
1371
|
+
}), l.event_attributes = f);
|
|
1372
|
+
return d() && (l.referer = document.referrer, l.url = window.location.href, l.page_title = document.title, l.doc_path = window.location.pathname, l.doc_host = window.location.hostname, l.doc_search = window.location.search, l.screen_resolution = `${window.screen.width}x${window.screen.height}`, l.vp_size = `${window.innerWidth}x${window.innerHeight}`, l.user_agent = navigator.userAgent, l.user_language = navigator.language, l.doc_encoding = document.characterSet, l.utm = this.getUtmParams()), l;
|
|
1379
1373
|
}
|
|
1380
1374
|
processAutocaptureAttributes(e) {
|
|
1381
1375
|
let t = {};
|
|
@@ -1398,14 +1392,14 @@ class L {
|
|
|
1398
1392
|
}
|
|
1399
1393
|
getThirdPartyIds() {
|
|
1400
1394
|
const e = {};
|
|
1401
|
-
if (
|
|
1395
|
+
if (d()) {
|
|
1402
1396
|
const t = this.getCookie("_fbp");
|
|
1403
1397
|
t && (e.fbp = t);
|
|
1404
1398
|
}
|
|
1405
1399
|
return e;
|
|
1406
1400
|
}
|
|
1407
1401
|
getUtmParams() {
|
|
1408
|
-
const e = {}, t =
|
|
1402
|
+
const e = {}, t = ke(window.location.search);
|
|
1409
1403
|
return [
|
|
1410
1404
|
"utm_source",
|
|
1411
1405
|
"utm_medium",
|
|
@@ -1417,7 +1411,7 @@ class L {
|
|
|
1417
1411
|
}), e;
|
|
1418
1412
|
}
|
|
1419
1413
|
pageview() {
|
|
1420
|
-
|
|
1414
|
+
d() ? this.track(
|
|
1421
1415
|
"pageview",
|
|
1422
1416
|
{
|
|
1423
1417
|
url: window.location.href,
|
|
@@ -1430,7 +1424,7 @@ class L {
|
|
|
1430
1424
|
);
|
|
1431
1425
|
}
|
|
1432
1426
|
setupPageLeaveTracking() {
|
|
1433
|
-
if (!
|
|
1427
|
+
if (!d()) return;
|
|
1434
1428
|
let e = !1, t = !1;
|
|
1435
1429
|
const i = () => {
|
|
1436
1430
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
@@ -1511,7 +1505,7 @@ function xe() {
|
|
|
1511
1505
|
return ie() ? window.define : void 0;
|
|
1512
1506
|
}
|
|
1513
1507
|
const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1514
|
-
function
|
|
1508
|
+
function L(s) {
|
|
1515
1509
|
const e = JSON.parse(JSON.stringify(s)), t = Q(e), i = {
|
|
1516
1510
|
...Y,
|
|
1517
1511
|
...t
|
|
@@ -1521,16 +1515,16 @@ function O(s) {
|
|
|
1521
1515
|
if (!i.trackingHost)
|
|
1522
1516
|
throw new Error("Tracking host is required!");
|
|
1523
1517
|
const n = i.key || "", r = `${Te}${n}`;
|
|
1524
|
-
return
|
|
1518
|
+
return d() && i.autocapture && window[r] && (console.warn(
|
|
1525
1519
|
"Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
|
|
1526
|
-
), i.disableAutocaptureListenerRegistration = !0),
|
|
1520
|
+
), i.disableAutocaptureListenerRegistration = !0), d() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new R(i);
|
|
1527
1521
|
}
|
|
1528
1522
|
function He(s) {
|
|
1529
1523
|
var n;
|
|
1530
1524
|
const e = {
|
|
1531
1525
|
key: s.getAttribute("data-key") || void 0,
|
|
1532
1526
|
trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1533
|
-
logLevel:
|
|
1527
|
+
logLevel: ve(s.getAttribute("data-log-level")),
|
|
1534
1528
|
autocapture: s.getAttribute("data-autocapture") === "true",
|
|
1535
1529
|
formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
|
|
1536
1530
|
autoPageview: s.getAttribute("data-auto-pageview") === "false" ? !1 : s.getAttribute("data-auto-pageview") === "true" ? !0 : void 0,
|
|
@@ -1561,18 +1555,18 @@ function He(s) {
|
|
|
1561
1555
|
maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1562
1556
|
};
|
|
1563
1557
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1564
|
-
const t =
|
|
1565
|
-
return
|
|
1558
|
+
const t = L(e), i = e.namespace || "usermaven";
|
|
1559
|
+
return d() && t.pageview(), Ie(i, t), t;
|
|
1566
1560
|
}
|
|
1567
|
-
function
|
|
1561
|
+
function Ie(s, e) {
|
|
1568
1562
|
let t = !1;
|
|
1569
1563
|
const i = [], n = [];
|
|
1570
1564
|
function r() {
|
|
1571
1565
|
for (; i.length > 0; ) {
|
|
1572
1566
|
const u = i.shift();
|
|
1573
1567
|
if (u) {
|
|
1574
|
-
const
|
|
1575
|
-
if (
|
|
1568
|
+
const m = u[u.length - 1];
|
|
1569
|
+
if (m && typeof m.resolve == "function") {
|
|
1576
1570
|
const y = u.pop();
|
|
1577
1571
|
try {
|
|
1578
1572
|
const P = a.apply(null, u);
|
|
@@ -1593,8 +1587,8 @@ function De(s, e) {
|
|
|
1593
1587
|
n.forEach((u) => u()), n.length = 0;
|
|
1594
1588
|
}
|
|
1595
1589
|
function a(...u) {
|
|
1596
|
-
const
|
|
1597
|
-
if (
|
|
1590
|
+
const m = u[0];
|
|
1591
|
+
if (m === "onLoad") {
|
|
1598
1592
|
typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
|
|
1599
1593
|
return;
|
|
1600
1594
|
}
|
|
@@ -1602,11 +1596,11 @@ function De(s, e) {
|
|
|
1602
1596
|
i.push(u);
|
|
1603
1597
|
return;
|
|
1604
1598
|
}
|
|
1605
|
-
if (typeof e[
|
|
1606
|
-
return e[
|
|
1607
|
-
console.error(`Method ${
|
|
1599
|
+
if (typeof e[m] == "function")
|
|
1600
|
+
return e[m].apply(e, u.slice(1));
|
|
1601
|
+
console.error(`Method ${m} not found on UsermavenClient`);
|
|
1608
1602
|
}
|
|
1609
|
-
const c = ["id", "group", "reset"],
|
|
1603
|
+
const c = ["id", "group", "reset"], h = [
|
|
1610
1604
|
"track",
|
|
1611
1605
|
"lead",
|
|
1612
1606
|
"pageview",
|
|
@@ -1615,44 +1609,44 @@ function De(s, e) {
|
|
|
1615
1609
|
"rawTrack",
|
|
1616
1610
|
"setUserId"
|
|
1617
1611
|
];
|
|
1618
|
-
[...c, ...
|
|
1619
|
-
a[u] = function(...
|
|
1612
|
+
[...c, ...h].forEach((u) => {
|
|
1613
|
+
a[u] = function(...m) {
|
|
1620
1614
|
if (!t) {
|
|
1621
1615
|
if (c.includes(u))
|
|
1622
1616
|
return new Promise((M, y) => {
|
|
1623
|
-
i.push([u, ...
|
|
1617
|
+
i.push([u, ...m, { resolve: M, reject: y }]);
|
|
1624
1618
|
});
|
|
1625
|
-
i.push([u, ...
|
|
1619
|
+
i.push([u, ...m]);
|
|
1626
1620
|
return;
|
|
1627
1621
|
}
|
|
1628
1622
|
if (typeof e[u] == "function")
|
|
1629
|
-
return e[u].apply(e,
|
|
1623
|
+
return e[u].apply(e, m);
|
|
1630
1624
|
};
|
|
1631
1625
|
}), a.getConfig = function() {
|
|
1632
1626
|
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1633
1627
|
}, window[s] = a;
|
|
1634
|
-
const
|
|
1635
|
-
for (window[
|
|
1628
|
+
const l = `${s}Q`, g = window[l] || [];
|
|
1629
|
+
for (window[l] = g, g.push = function(...u) {
|
|
1636
1630
|
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1637
1631
|
}, setTimeout(() => {
|
|
1638
1632
|
t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
|
|
1639
|
-
}, 0);
|
|
1640
|
-
const u =
|
|
1633
|
+
}, 0); g.length > 0; ) {
|
|
1634
|
+
const u = g.shift();
|
|
1641
1635
|
u && i.push(u);
|
|
1642
1636
|
}
|
|
1643
1637
|
}
|
|
1644
1638
|
let Z = !1, B = null;
|
|
1645
|
-
if (
|
|
1639
|
+
if (d()) {
|
|
1646
1640
|
const s = xe();
|
|
1647
1641
|
s && s("usermaven", [], function() {
|
|
1648
1642
|
return {
|
|
1649
|
-
usermavenClient:
|
|
1650
|
-
UsermavenClient:
|
|
1643
|
+
usermavenClient: L,
|
|
1644
|
+
UsermavenClient: R,
|
|
1651
1645
|
LogLevel: _,
|
|
1652
1646
|
// Expose the script tag client if it exists
|
|
1653
1647
|
getScriptTagClient: () => B
|
|
1654
1648
|
};
|
|
1655
|
-
}), typeof window < "u" && (window.usermavenClient =
|
|
1649
|
+
}), typeof window < "u" && (window.usermavenClient = L, window.UsermavenClient = R, window.usermavenScriptTagClient = () => B), function(e, t) {
|
|
1656
1650
|
const i = e.currentScript;
|
|
1657
1651
|
function n() {
|
|
1658
1652
|
return Z || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
@@ -1664,8 +1658,8 @@ if (h()) {
|
|
|
1664
1658
|
}(document, window);
|
|
1665
1659
|
}
|
|
1666
1660
|
typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
1667
|
-
usermavenClient:
|
|
1668
|
-
UsermavenClient:
|
|
1661
|
+
usermavenClient: L,
|
|
1662
|
+
UsermavenClient: R,
|
|
1669
1663
|
Config: void 0,
|
|
1670
1664
|
UserProps: void 0,
|
|
1671
1665
|
EventPayload: void 0,
|
|
@@ -1674,7 +1668,7 @@ typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
|
1674
1668
|
});
|
|
1675
1669
|
|
|
1676
1670
|
function createClient(params) {
|
|
1677
|
-
return
|
|
1671
|
+
return L(params);
|
|
1678
1672
|
}
|
|
1679
1673
|
|
|
1680
1674
|
function useUsermaven() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/react",
|
|
3
|
-
"version": "1.5.13
|
|
3
|
+
"version": "1.5.13",
|
|
4
4
|
"description": "Usermaven JavaScript SDK for React",
|
|
5
5
|
"author": "Usermaven <hello@usermaven.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@usermaven/sdk-js": "1.5.13
|
|
21
|
+
"@usermaven/sdk-js": "1.5.13"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "15.x || 16.x || 17.x || 18.x || 19.x",
|