@usermaven/react 1.5.4-rc.96 → 1.5.5-rc.97

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 +179 -149
  2. package/package.json +3 -3
package/lib/index.es.js CHANGED
@@ -8,8 +8,8 @@ const UsermavenProvider = ({ children, client }) => {
8
8
  return React.createElement(Context.Provider, { value: client }, children);
9
9
  };
10
10
 
11
- var v = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(v || {});
12
- class W {
11
+ var p = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(p || {});
12
+ class Z {
13
13
  constructor(e) {
14
14
  this.level = e;
15
15
  }
@@ -27,10 +27,10 @@ class W {
27
27
  }
28
28
  }
29
29
  function d(i = 0) {
30
- return new W(i);
30
+ return new Z(i);
31
31
  }
32
- const F = {
33
- logLevel: v.ERROR,
32
+ const q = {
33
+ logLevel: p.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
36
36
  trackingHost: "t.usermaven.com",
@@ -55,7 +55,7 @@ const F = {
55
55
  maskAllText: !1,
56
56
  maskAllElementAttributes: !1
57
57
  };
58
- class X {
58
+ class j {
59
59
  constructor(e) {
60
60
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
61
  }
@@ -104,40 +104,40 @@ class X {
104
104
  return s ? s[0] : "";
105
105
  }
106
106
  }
107
- const K = Object.prototype, G = K.hasOwnProperty, Y = Array.prototype, E = Y.forEach, A = {};
108
- function Z(i, e, t) {
107
+ const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, E = ie.forEach, N = {};
108
+ function se(i, e, t) {
109
109
  if (Array.isArray(i)) {
110
110
  if (E && i.forEach === E)
111
111
  i.forEach(e, t);
112
112
  else if ("length" in i && i.length === +i.length) {
113
113
  for (let s = 0, n = i.length; s < n; s++)
114
- if (s in i && e.call(t, i[s], s) === A)
114
+ if (s in i && e.call(t, i[s], s) === N)
115
115
  return;
116
116
  }
117
117
  }
118
118
  }
119
- const x = function(i) {
119
+ const O = function(i) {
120
120
  return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, j = function(i) {
121
+ }, ne = function(i) {
122
122
  for (const e in i)
123
123
  typeof i[e] == "function" && (i[e] = i[e].bind(i));
124
124
  };
125
- function f(i, e, t) {
125
+ function g(i, e, t) {
126
126
  if (i != null) {
127
127
  if (E && Array.isArray(i) && i.forEach === E)
128
128
  i.forEach(e, t);
129
129
  else if ("length" in i && i.length === +i.length) {
130
130
  for (let s = 0, n = i.length; s < n; s++)
131
- if (s in i && e.call(t, i[s], s) === A)
131
+ if (s in i && e.call(t, i[s], s) === N)
132
132
  return;
133
133
  } else
134
134
  for (const s in i)
135
- if (G.call(i, s) && e.call(t, i[s], s) === A)
135
+ if (te.call(i, s) && e.call(t, i[s], s) === N)
136
136
  return;
137
137
  }
138
138
  }
139
- const ee = function(i, ...e) {
140
- return Z(e, function(t) {
139
+ const re = function(i, ...e) {
140
+ return se(e, function(t) {
141
141
  for (const s in t)
142
142
  t[s] !== void 0 && (i[s] = t[s]);
143
143
  }), i;
@@ -145,15 +145,15 @@ const ee = function(i, ...e) {
145
145
  function _(i, e) {
146
146
  return i.indexOf(e) !== -1;
147
147
  }
148
- const te = function(i) {
148
+ const oe = function(i) {
149
149
  try {
150
150
  return /^\s*\bfunction\b/.test(i);
151
151
  } catch {
152
152
  return !1;
153
153
  }
154
- }, ie = function(i) {
154
+ }, ae = function(i) {
155
155
  return i === void 0;
156
- }, m = function() {
156
+ }, y = function() {
157
157
  const i = function(s, n, r, o, c) {
158
158
  if (!s) {
159
159
  d().error("No valid element provided to register_event");
@@ -171,7 +171,7 @@ const te = function(i) {
171
171
  if (o = o || t(window.event), !o)
172
172
  return;
173
173
  let c = !0, l;
174
- te(r) && (l = r(o));
174
+ oe(r) && (l = r(o));
175
175
  const a = n.call(s, o);
176
176
  return (l === !1 || a === !1) && (c = !1), c;
177
177
  };
@@ -184,7 +184,7 @@ const te = function(i) {
184
184
  }, t.stopPropagation = function() {
185
185
  this.cancelBubble = !0;
186
186
  }, i;
187
- }(), se = function(i) {
187
+ }(), ce = function(i) {
188
188
  return function(...e) {
189
189
  try {
190
190
  return i.apply(this, e);
@@ -192,11 +192,11 @@ const te = function(i) {
192
192
  d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
193
193
  }
194
194
  };
195
- }, z = function(i) {
195
+ }, V = function(i) {
196
196
  for (const e in i)
197
- typeof i[e] == "function" && (i[e] = se(i[e]));
197
+ typeof i[e] == "function" && (i[e] = ce(i[e]));
198
198
  };
199
- function R(i) {
199
+ function D(i) {
200
200
  for (let e in i)
201
201
  (i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
202
202
  return i;
@@ -208,20 +208,20 @@ function u() {
208
208
  return d().warn("window is not available"), !1;
209
209
  }
210
210
  }
211
- function p(i = 5) {
211
+ function m(i = 5) {
212
212
  const e = new Uint8Array(i);
213
213
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
214
214
  }
215
- function ne(i) {
215
+ function le(i) {
216
216
  return i.replace(
217
217
  /([-_][a-z])/g,
218
218
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
219
  );
220
220
  }
221
- function H(i) {
222
- return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(H) : Object.keys(i).reduce((e, t) => {
223
- const s = ne(t);
224
- return e[s] = H(i[t]), e;
221
+ function R(i) {
222
+ return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(R) : Object.keys(i).reduce((e, t) => {
223
+ const s = le(t);
224
+ return e[s] = R(i[t]), e;
225
225
  }, {});
226
226
  }
227
227
  function $(i) {
@@ -234,37 +234,37 @@ function $(i) {
234
234
  return "";
235
235
  }
236
236
  }
237
- function L(i) {
237
+ function U(i) {
238
238
  let e = "";
239
- return O(i) && !M(i) && i.childNodes && i.childNodes.length && f(i.childNodes, function(t) {
240
- q(t) && t.textContent && (e += x(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
- }), x(e);
239
+ return L(i) && !W(i) && i.childNodes && i.childNodes.length && g(i.childNodes, function(t) {
240
+ Q(t) && t.textContent && (e += O(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
+ }), O(e);
242
242
  }
243
- function B(i) {
243
+ function J(i) {
244
244
  return !!i && i.nodeType === 1;
245
245
  }
246
- function g(i, e) {
246
+ function f(i, e) {
247
247
  return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
248
248
  }
249
- function q(i) {
249
+ function Q(i) {
250
250
  return !!i && i.nodeType === 3;
251
251
  }
252
- function N(i) {
252
+ function I(i) {
253
253
  return !!i && i.nodeType === 11;
254
254
  }
255
255
  const b = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function re(i, e) {
257
- if (!i || g(i, "html") || !B(i))
256
+ function ue(i, e) {
257
+ if (!i || f(i, "html") || !J(i))
258
258
  return !1;
259
259
  let t = i;
260
- for (; t && !g(t, "body"); ) {
260
+ for (; t && !f(t, "body"); ) {
261
261
  if (t.classList && t.classList.contains("um-no-capture"))
262
262
  return !1;
263
- t.parentNode && N(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
263
+ t.parentNode && I(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
264
  }
265
265
  let s = !1;
266
- for (t = i; t && !g(t, "body"); ) {
267
- if (t.parentNode && N(t.parentNode)) {
266
+ for (t = i; t && !f(t, "body"); ) {
267
+ if (t.parentNode && I(t.parentNode)) {
268
268
  t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
269
269
  continue;
270
270
  }
@@ -296,8 +296,8 @@ function re(i, e) {
296
296
  return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
297
297
  }
298
298
  }
299
- function O(i) {
300
- for (let s = i; s.parentNode && !g(s, "body"); s = s.parentNode) {
299
+ function L(i) {
300
+ for (let s = i; s.parentNode && !f(s, "body"); s = s.parentNode) {
301
301
  const n = $(s).split(" ");
302
302
  if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
303
303
  return !1;
@@ -315,23 +315,23 @@ function O(i) {
315
315
  const t = i.name || i.id || "";
316
316
  return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
317
317
  }
318
- function M(i) {
318
+ function W(i) {
319
319
  const e = ["button", "checkbox", "submit", "reset"];
320
- return !!(g(i, "input") && !e.includes(i.type) || g(i, "select") || g(i, "textarea") || i.getAttribute("contenteditable") === "true");
320
+ return !!(f(i, "input") && !e.includes(i.type) || f(i, "select") || f(i, "textarea") || i.getAttribute("contenteditable") === "true");
321
321
  }
322
322
  function P(i) {
323
- return !(i === null || ie(i) || typeof i == "string" && (i = x(i), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
323
+ return !(i === null || ae(i) || typeof i == "string" && (i = O(i), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
324
324
  }
325
- function oe(i) {
325
+ function he(i) {
326
326
  return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
327
327
  }
328
- function T() {
329
- return p(10);
328
+ function x() {
329
+ return m(10);
330
330
  }
331
- function ae(i) {
331
+ function de(i) {
332
332
  return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(i).toLowerCase());
333
333
  }
334
- function ce(i, e) {
334
+ function fe(i, e) {
335
335
  let t;
336
336
  return function(...s) {
337
337
  const n = () => {
@@ -340,7 +340,7 @@ function ce(i, e) {
340
340
  clearTimeout(t), t = setTimeout(n, e);
341
341
  };
342
342
  }
343
- function le(i) {
343
+ function ge(i) {
344
344
  const e = {}, t = i.replace(/^\?/, "").split("&");
345
345
  for (let s = 0; s < t.length; s++) {
346
346
  const n = t[s].split("=");
@@ -348,25 +348,25 @@ function le(i) {
348
348
  }
349
349
  return e;
350
350
  }
351
- function I(i) {
351
+ function F(i) {
352
352
  return typeof i == "string" || i instanceof String;
353
353
  }
354
- function k(i) {
354
+ function v(i) {
355
355
  return i !== null && typeof i == "object" && i.constructor === Object;
356
356
  }
357
- function ue(i) {
357
+ function pe(i) {
358
358
  if (i === null)
359
- return v.ERROR;
360
- const e = i.toUpperCase(), t = v[e];
361
- return t || t === 0 ? t : v.ERROR;
359
+ return p.ERROR;
360
+ const e = i.toUpperCase(), t = p[e];
361
+ return t || t === 0 ? t : p.ERROR;
362
362
  }
363
- const he = () => {
363
+ const me = () => {
364
364
  let i = "false";
365
365
  return typeof window < "u" && window.localStorage && (i = localStorage.getItem("um_exclusion")), !(i == null || i === "false");
366
366
  };
367
- class de {
367
+ class ye {
368
368
  constructor(e) {
369
- this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ce(this.handleScroll.bind(this), 250), this.initializeEventListener();
369
+ this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = fe(this.handleScroll.bind(this), 250), this.initializeEventListener();
370
370
  }
371
371
  initializeEventListener() {
372
372
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -415,9 +415,9 @@ class de {
415
415
  });
416
416
  }
417
417
  }
418
- const C = class C {
418
+ const A = class A {
419
419
  constructor(e, t, s = d()) {
420
- this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new de(e), j(this), z(this);
420
+ this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new ye(e), ne(this), V(this);
421
421
  }
422
422
  init() {
423
423
  if (!(document && document.body)) {
@@ -430,7 +430,7 @@ const C = class C {
430
430
  const e = (t) => {
431
431
  t = t || window.event, this.captureEvent(t);
432
432
  };
433
- m(document, "submit", e, !1, !0), m(document, "change", e, !1, !0), m(document, "click", e, !1, !0), m(document, "visibilitychange", e, !1, !0), m(document, "scroll", e, !1, !0), m(window, "popstate", e, !1, !0);
433
+ y(document, "submit", e, !1, !0), y(document, "change", e, !1, !0), y(document, "click", e, !1, !0), y(document, "visibilitychange", e, !1, !0), y(document, "scroll", e, !1, !0), y(window, "popstate", e, !1, !0);
434
434
  }
435
435
  isPageRefresh() {
436
436
  if ("PerformanceNavigationTiming" in window) {
@@ -443,15 +443,15 @@ const C = class C {
443
443
  captureEvent(e) {
444
444
  var s, n;
445
445
  let t = this.getEventTarget(e);
446
- if (q(t) && (t = t.parentNode || null), e.type === "scroll")
446
+ if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
447
447
  return (s = this.scrollDepth) == null || s.track(), !0;
448
448
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
449
449
  return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
450
- if (t && re(t, e)) {
450
+ if (t && ue(t, e)) {
451
451
  const r = [t];
452
452
  let o = t;
453
- for (; o.parentNode && !g(o, "body"); ) {
454
- if (N(o.parentNode)) {
453
+ for (; o.parentNode && !f(o, "body"); ) {
454
+ if (I(o.parentNode)) {
455
455
  r.push(o.parentNode.host), o = o.parentNode.host;
456
456
  continue;
457
457
  }
@@ -459,20 +459,20 @@ const C = class C {
459
459
  }
460
460
  const c = [];
461
461
  let l, a = !1;
462
- if (f(r, (w) => {
463
- const J = O(w);
464
- w.tagName.toLowerCase() === "a" && (l = w.getAttribute("href"), l = J && P(l) && l);
465
- const Q = $(w).split(" ");
466
- _(Q, "ph-no-capture") && (a = !0), c.push(
462
+ if (g(r, (k) => {
463
+ const G = L(k);
464
+ k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = G && P(l) && l);
465
+ const Y = $(k).split(" ");
466
+ _(Y, "ph-no-capture") && (a = !0), c.push(
467
467
  this.getPropertiesFromElement(
468
- w,
468
+ k,
469
469
  this.options.maskAllElementAttributes ?? !1,
470
470
  this.options.maskAllText ?? !1
471
471
  )
472
472
  );
473
- }), this.options.maskAllText || (c[0].$el_text = L(t)), l && (c[0].attr__href = l), a)
473
+ }), this.options.maskAllText || (c[0].$el_text = U(t)), l && (c[0].attr__href = l), a)
474
474
  return !1;
475
- const h = ee(
475
+ const h = re(
476
476
  this.getDefaultProperties(e.type),
477
477
  {
478
478
  $elements: c
@@ -484,18 +484,18 @@ const C = class C {
484
484
  }
485
485
  getCustomProperties(e) {
486
486
  const t = {};
487
- return f(this.customProperties, (s) => {
488
- f(s.event_selectors, (n) => {
487
+ return g(this.customProperties, (s) => {
488
+ g(s.event_selectors, (n) => {
489
489
  const r = document.querySelectorAll(n);
490
- f(r, (o) => {
491
- _(e, o) && O(o) && (t[s.name] = this.extractCustomPropertyValue(s));
490
+ g(r, (o) => {
491
+ _(e, o) && L(o) && (t[s.name] = this.extractCustomPropertyValue(s));
492
492
  });
493
493
  });
494
494
  }), t;
495
495
  }
496
496
  extractCustomPropertyValue(e) {
497
497
  const t = [];
498
- return f(document.querySelectorAll(e.css_selector), function(s) {
498
+ return g(document.querySelectorAll(e.css_selector), function(s) {
499
499
  let n;
500
500
  ["input", "select"].indexOf(s.tagName.toLowerCase()) > -1 ? n = s.value : s.textContent && (n = s.textContent), P(n) && t.push(n);
501
501
  }), t.join(", ");
@@ -508,12 +508,12 @@ const C = class C {
508
508
  const n = e.tagName.toLowerCase(), r = {
509
509
  tag_name: n
510
510
  };
511
- b.indexOf(n) > -1 && !s && (r.$el_text = L(e));
511
+ b.indexOf(n) > -1 && !s && (r.$el_text = U(e));
512
512
  const o = $(e);
513
513
  o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
514
514
  return h !== "";
515
- })), f(e.attributes, function(h) {
516
- M(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !oe(h.name) && (r["attr__" + h.name] = h.value);
515
+ })), g(e.attributes, function(h) {
516
+ W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
517
517
  });
518
518
  let c = 1, l = 1, a = e;
519
519
  for (; a = this.previousElementSibling(a); )
@@ -527,7 +527,7 @@ const C = class C {
527
527
  let t = e;
528
528
  do
529
529
  t = t.previousSibling;
530
- while (t && !B(t));
530
+ while (t && !J(t));
531
531
  return t;
532
532
  }
533
533
  }
@@ -549,9 +549,9 @@ const C = class C {
549
549
  return n % t < s;
550
550
  }
551
551
  };
552
- C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
553
- let S = C;
554
- class ge {
552
+ A.FORCE_CAPTURE_ATTR = "data-um-force-capture", A.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
553
+ let S = A;
554
+ class we {
555
555
  constructor(e) {
556
556
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
557
557
  }
@@ -580,7 +580,7 @@ class ge {
580
580
  }));
581
581
  }
582
582
  }
583
- class fe {
583
+ class ke {
584
584
  constructor(e, t, s = d()) {
585
585
  this.trackingHost = e, this.logger = s, this.config = t;
586
586
  }
@@ -593,12 +593,12 @@ class fe {
593
593
  }
594
594
  constructUrl(e) {
595
595
  const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
596
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
596
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
597
597
  }
598
598
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
599
599
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
600
600
  }
601
- class D {
601
+ class z {
602
602
  constructor(e, t, s = d()) {
603
603
  this.trackingHost = e, this.logger = s, this.config = t;
604
604
  }
@@ -617,7 +617,7 @@ class D {
617
617
  }
618
618
  constructUrl(e) {
619
619
  const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
620
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
620
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
621
621
  }
622
622
  getCustomHeaders() {
623
623
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -626,7 +626,7 @@ class D {
626
626
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
627
627
  }
628
628
  }
629
- class pe {
629
+ class ve {
630
630
  constructor(e, t, s = d()) {
631
631
  this.trackingHost = e, this.logger = s, this.config = t;
632
632
  }
@@ -646,7 +646,7 @@ class pe {
646
646
  }
647
647
  constructUrl(e) {
648
648
  const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
649
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
649
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
650
650
  }
651
651
  getCustomHeaders() {
652
652
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -655,7 +655,7 @@ class pe {
655
655
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
656
656
  }
657
657
  }
658
- class V {
658
+ class X {
659
659
  constructor(e, t) {
660
660
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
661
661
  }
@@ -695,7 +695,7 @@ class V {
695
695
  }
696
696
  }
697
697
  }
698
- class me {
698
+ class _e {
699
699
  constructor() {
700
700
  this.storage = {};
701
701
  }
@@ -714,10 +714,10 @@ class me {
714
714
  this.storage = {};
715
715
  }
716
716
  }
717
- class U {
717
+ class M {
718
718
  // Default to true for server-side
719
719
  constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = d(), c = "default") {
720
- this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new V(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
720
+ this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new X(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
721
721
  }
722
722
  add(e) {
723
723
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -761,9 +761,9 @@ class U {
761
761
  u() && this.persistence.set("queue", JSON.stringify(this.queue));
762
762
  }
763
763
  }
764
- class ye {
764
+ class be {
765
765
  constructor(e) {
766
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
766
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
767
767
  }
768
768
  initializeEventListener() {
769
769
  document.addEventListener("click", this.handleClick.bind(this));
@@ -795,7 +795,7 @@ class ye {
795
795
  }), this.clicks = [];
796
796
  }
797
797
  }
798
- class we {
798
+ class Pe {
799
799
  constructor(e, t, s = d()) {
800
800
  this.trackingHost = e, this.logger = s, this.config = t;
801
801
  }
@@ -831,7 +831,7 @@ class we {
831
831
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
832
832
  }
833
833
  }
834
- class y {
834
+ class w {
835
835
  constructor(e, t = "all", s = {}) {
836
836
  this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
837
837
  }
@@ -846,18 +846,18 @@ class y {
846
846
  }
847
847
  handleFormSubmit(e) {
848
848
  const t = e.target, s = this._getFormDetails(t);
849
- this.instance.track("$form", R(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
849
+ this.instance.track("$form", D(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
850
850
  }
851
851
  trackFieldChanges(e) {
852
852
  e.querySelectorAll("input, select, textarea").forEach((s) => {
853
853
  s.addEventListener("change", (n) => {
854
854
  const r = this._getFieldProps(n.target, 0);
855
- this.instance.track("$form_field_change", R(r));
855
+ this.instance.track("$form_field_change", D(r));
856
856
  });
857
857
  });
858
858
  }
859
859
  static getInstance(e, t = "all", s = {}) {
860
- return y.instance || (y.instance = new y(e, t, s)), y.instance;
860
+ return w.instance || (w.instance = new w(e, t, s)), w.instance;
861
861
  }
862
862
  _getFormDetails(e) {
863
863
  const t = {
@@ -945,9 +945,9 @@ class y {
945
945
  return e.slice(t, s + 1);
946
946
  }
947
947
  }
948
- class ke {
948
+ class C {
949
949
  constructor(e) {
950
- this.config = this.mergeConfig(e, F), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new U(
950
+ this.config = this.mergeConfig(e, q), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new M(
951
951
  this.transport,
952
952
  this.config.maxSendAttempts || 3,
953
953
  this.config.minSendTimeout || 1e3,
@@ -959,13 +959,13 @@ class ke {
959
959
  ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
960
960
  }
961
961
  initializeBrowserFeatures() {
962
- if (this.cookieManager = new X(this.config.cookieDomain), this.config.autocapture && S.enabledForProject(this.config.key) && (this.autoCapture = new S(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
962
+ if (this.cookieManager = new j(this.config.cookieDomain), this.config.autocapture && S.enabledForProject(this.config.key) && (this.autoCapture = new S(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
963
963
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
964
- this.formTracking = y.getInstance(this, e || "none", {
964
+ this.formTracking = w.getInstance(this, e || "none", {
965
965
  trackFieldChanges: !1
966
966
  });
967
967
  }
968
- this.config.autoPageview && (this.pageviewTracking = new ge(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new ye(this)), this.setupPageLeaveTracking();
968
+ this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
969
969
  }
970
970
  /**
971
971
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -976,11 +976,11 @@ class ke {
976
976
  const s = JSON.parse(JSON.stringify(e));
977
977
  let n = { ...t, ...s };
978
978
  return Object.keys(t).forEach((r) => {
979
- k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
979
+ v(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
980
980
  }), n;
981
981
  }
982
982
  init(e) {
983
- this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new U(
983
+ this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new M(
984
984
  this.transport,
985
985
  this.config.maxSendAttempts || 3,
986
986
  this.config.minSendTimeout || 1e3,
@@ -1016,25 +1016,25 @@ class ke {
1016
1016
  initializeTransport(e) {
1017
1017
  const t = "https://events.usermaven.com";
1018
1018
  if (!u())
1019
- return new we(e.trackingHost || t, e);
1019
+ return new Pe(e.trackingHost || t, e);
1020
1020
  const s = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1021
1021
  if (e.useBeaconApi && r)
1022
- return new fe(e.trackingHost || t, e, this.logger);
1022
+ return new ke(e.trackingHost || t, e, this.logger);
1023
1023
  if (e.forceUseFetch && n)
1024
- return new D(e.trackingHost || t, e, this.logger);
1024
+ return new z(e.trackingHost || t, e, this.logger);
1025
1025
  if (s)
1026
- return new pe(e.trackingHost || t, e, this.logger);
1026
+ return new ve(e.trackingHost || t, e, this.logger);
1027
1027
  if (n)
1028
- return new D(e.trackingHost || t, e, this.logger);
1028
+ return new z(e.trackingHost || t, e, this.logger);
1029
1029
  throw new Error("No suitable transport method available");
1030
1030
  }
1031
1031
  initializePersistence() {
1032
- return this.config.disableEventPersistence || !u() ? new me() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1032
+ return this.config.disableEventPersistence || !u() ? new _e() : new X(`${this.namespace}_${this.config.key}`, this.logger);
1033
1033
  }
1034
1034
  getOrCreateAnonymousId() {
1035
1035
  var s, n;
1036
1036
  if (!u())
1037
- return T();
1037
+ return x();
1038
1038
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1039
1039
  return "";
1040
1040
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
@@ -1042,20 +1042,20 @@ class ke {
1042
1042
  if (!t) {
1043
1043
  if (this.config.crossDomainLinking) {
1044
1044
  const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
1045
- t = c || h || T();
1045
+ t = c || h || x();
1046
1046
  }
1047
- t || (t = T());
1047
+ t || (t = x());
1048
1048
  const r = 365 * 10;
1049
1049
  (n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
1050
1050
  }
1051
1051
  return t;
1052
1052
  }
1053
1053
  async id(e, t = !1) {
1054
- if (!k(e))
1054
+ if (!v(e))
1055
1055
  throw new Error("User data must be an object");
1056
- if (e.email && !ae(e.email))
1056
+ if (e.email && !de(e.email))
1057
1057
  throw new Error("Invalid email provided");
1058
- if (!e.id || !I(e.id))
1058
+ if (!e.id || !F(e.id))
1059
1059
  throw new Error("User ID must be a string");
1060
1060
  const s = e.id;
1061
1061
  if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
@@ -1071,11 +1071,11 @@ class ke {
1071
1071
  this.trackInternal(e, t, s);
1072
1072
  }
1073
1073
  trackInternal(e, t, s = !1) {
1074
- if (he()) {
1074
+ if (me()) {
1075
1075
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1076
1076
  return;
1077
1077
  }
1078
- if (!I(e))
1078
+ if (!F(e))
1079
1079
  throw new Error("Event name must be a string");
1080
1080
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1081
1081
  throw new Error("Event payload must be a non-null object and not an array");
@@ -1091,12 +1091,12 @@ class ke {
1091
1091
  }
1092
1092
  }
1093
1093
  rawTrack(e) {
1094
- if (!k(e))
1094
+ if (!v(e))
1095
1095
  throw new Error("Event payload must be an object");
1096
1096
  this.track("raw", e);
1097
1097
  }
1098
1098
  async group(e, t = !1) {
1099
- if (!k(e))
1099
+ if (!v(e))
1100
1100
  throw new Error("Company properties must be an object");
1101
1101
  if (!e.id || !e.name || !e.created_at)
1102
1102
  throw new Error("Company properties must include id, name, and created_at");
@@ -1151,7 +1151,7 @@ class ke {
1151
1151
  return e;
1152
1152
  }
1153
1153
  getUtmParams() {
1154
- const e = {}, t = le(window.location.search);
1154
+ const e = {}, t = ge(window.location.search);
1155
1155
  return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((n) => {
1156
1156
  t[n] && (e[n.replace("utm_", "")] = t[n]);
1157
1157
  }), e;
@@ -1199,7 +1199,7 @@ class ke {
1199
1199
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1200
1200
  }
1201
1201
  set(e, t) {
1202
- if (!k(e))
1202
+ if (!v(e))
1203
1203
  throw new Error("Properties must be an object");
1204
1204
  const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1205
1205
  if (s) {
@@ -1232,20 +1232,26 @@ class ke {
1232
1232
  n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
1233
1233
  }
1234
1234
  }
1235
- function ve(i) {
1236
- const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...F, ...t };
1235
+ function K() {
1236
+ return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1237
+ }
1238
+ function Ee() {
1239
+ return K() ? window.define : void 0;
1240
+ }
1241
+ function T(i) {
1242
+ const e = JSON.parse(JSON.stringify(i)), t = R(e), s = { ...q, ...t };
1237
1243
  if (!s.key)
1238
1244
  throw new Error("API key is required!");
1239
1245
  if (!s.trackingHost)
1240
1246
  throw new Error("Tracking host is required!");
1241
- return new ke(s);
1247
+ return new C(s);
1242
1248
  }
1243
- function _e(i) {
1249
+ function $e(i) {
1244
1250
  var n;
1245
1251
  const e = {
1246
1252
  key: i.getAttribute("data-key") || void 0,
1247
1253
  trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1248
- logLevel: ue(i.getAttribute("data-log-level")),
1254
+ logLevel: pe(i.getAttribute("data-log-level")),
1249
1255
  autocapture: i.getAttribute("data-autocapture") === "true",
1250
1256
  formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
1251
1257
  autoPageview: i.getAttribute("data-auto-pageview") === "true",
@@ -1272,10 +1278,10 @@ function _e(i) {
1272
1278
  maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
1273
1279
  };
1274
1280
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1275
- const t = ve(e), s = e.namespace || "usermaven";
1276
- u() && t.pageview(), be(s, t);
1281
+ const t = T(e), s = e.namespace || "usermaven";
1282
+ return u() && e.autoPageview !== !1 && t.pageview(), Se(s, t), t;
1277
1283
  }
1278
- function be(i, e) {
1284
+ function Se(i, e) {
1279
1285
  let t = !1;
1280
1286
  const s = [], n = [];
1281
1287
  function r() {
@@ -1311,16 +1317,40 @@ function be(i, e) {
1311
1317
  a && s.push(a);
1312
1318
  }
1313
1319
  }
1314
- u() && function(i, e) {
1315
- const t = i.currentScript;
1316
- function s() {
1317
- t && t.src.includes("lib.js") && _e(t);
1318
- }
1319
- typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
1320
- }(document, window);
1320
+ let B = !1, H = null;
1321
+ if (u()) {
1322
+ const i = Ee();
1323
+ i && i("usermaven", [], function() {
1324
+ return {
1325
+ usermavenClient: T,
1326
+ UsermavenClient: C,
1327
+ LogLevel: p,
1328
+ // Expose the script tag client if it exists
1329
+ getScriptTagClient: () => H
1330
+ };
1331
+ }), typeof window < "u" && (window.usermavenClient = T, window.UsermavenClient = C, window.usermavenScriptTagClient = () => H), function(e, t) {
1332
+ const s = e.currentScript;
1333
+ function n() {
1334
+ return B || !s || !s.hasAttribute("data-key") || s.getAttribute("data-no-auto-init") === "true" ? !1 : s.src.includes("lib.js");
1335
+ }
1336
+ function r() {
1337
+ n() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(s), B = !0);
1338
+ }
1339
+ typeof t < "u" && s && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1340
+ }(document, window);
1341
+ }
1342
+ typeof module < "u" && module.exports && !K() && (module.exports = {
1343
+ usermavenClient: T,
1344
+ UsermavenClient: C,
1345
+ Config: void 0,
1346
+ UserProps: void 0,
1347
+ EventPayload: void 0,
1348
+ LogLevel: p,
1349
+ ClientProperties: void 0
1350
+ });
1321
1351
 
1322
1352
  function createClient(params) {
1323
- return ve(params);
1353
+ return T(params);
1324
1354
  }
1325
1355
 
1326
1356
  function useUsermaven() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/react",
3
- "version": "1.5.4-rc.96",
3
+ "version": "1.5.5-rc.97",
4
4
  "description": "Usermaven JavaScript SDK for React",
5
5
  "author": "Usermaven <hello@usermaven.com>",
6
6
  "license": "MIT",
@@ -18,10 +18,10 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@usermaven/sdk-js": "1.5.4-rc.96"
21
+ "@usermaven/sdk-js": "1.5.5-rc.97"
22
22
  },
23
23
  "peerDependencies": {
24
- "react": "15.x || 16.x || 17.x || 18.x",
24
+ "react": "15.x || 16.x || 17.x || 18.x || 19.x",
25
25
  "react-router": "5.x || 6.x"
26
26
  },
27
27
  "devDependencies": {