@usermaven/react 1.5.12 → 1.5.13-rc.120

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