@usermaven/react 1.5.8 → 1.5.9-rc.106

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 +308 -272
  2. package/package.json +2 -2
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 p = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(p || {});
12
- class G {
11
+ var k = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(k || {});
12
+ class ie {
13
13
  constructor(e) {
14
14
  this.level = e;
15
15
  }
@@ -26,11 +26,11 @@ class G {
26
26
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
27
27
  }
28
28
  }
29
- function d(n = 0) {
30
- return new G(n);
29
+ function f(n = 0) {
30
+ return new ie(n);
31
31
  }
32
- const q = {
33
- logLevel: p.ERROR,
32
+ const X = {
33
+ logLevel: k.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
36
36
  trackingHost: "t.usermaven.com",
@@ -55,15 +55,15 @@ const q = {
55
55
  maskAllText: !1,
56
56
  maskAllElementAttributes: !1
57
57
  };
58
- class j {
58
+ class ne {
59
59
  constructor(e) {
60
60
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
61
  }
62
62
  set(e, t, i = 365, s = !0, r = !1) {
63
63
  const o = /* @__PURE__ */ new Date();
64
64
  o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
65
- const c = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", a = r ? "; HttpOnly" : "";
66
- document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
65
+ const a = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", c = r ? "; HttpOnly" : "";
66
+ document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
67
67
  }
68
68
  get(e) {
69
69
  const t = e + "=", i = document.cookie.split(";");
@@ -104,76 +104,76 @@ class j {
104
104
  return i ? i[0] : "";
105
105
  }
106
106
  }
107
- const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, P = ie.forEach, N = {};
108
- function ne(n, e, t) {
107
+ const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, T = oe.forEach, U = {};
108
+ function ae(n, e, t) {
109
109
  if (Array.isArray(n)) {
110
- if (P && n.forEach === P)
110
+ if (T && n.forEach === T)
111
111
  n.forEach(e, t);
112
112
  else if ("length" in n && n.length === +n.length) {
113
113
  for (let i = 0, s = n.length; i < s; i++)
114
- if (i in n && e.call(t, n[i], i) === N)
114
+ if (i in n && e.call(t, n[i], i) === U)
115
115
  return;
116
116
  }
117
117
  }
118
118
  }
119
- const R = function(n) {
119
+ const D = function(n) {
120
120
  return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, se = function(n) {
121
+ }, ce = function(n) {
122
122
  for (const e in n)
123
123
  typeof n[e] == "function" && (n[e] = n[e].bind(n));
124
124
  };
125
- function g(n, e, t) {
125
+ function w(n, e, t) {
126
126
  if (n != null) {
127
- if (P && Array.isArray(n) && n.forEach === P)
127
+ if (T && Array.isArray(n) && n.forEach === T)
128
128
  n.forEach(e, t);
129
129
  else if ("length" in n && n.length === +n.length) {
130
130
  for (let i = 0, s = n.length; i < s; i++)
131
- if (i in n && e.call(t, n[i], i) === N)
131
+ if (i in n && e.call(t, n[i], i) === U)
132
132
  return;
133
133
  } else
134
134
  for (const i in n)
135
- if (te.call(n, i) && e.call(t, n[i], i) === N)
135
+ if (re.call(n, i) && e.call(t, n[i], i) === U)
136
136
  return;
137
137
  }
138
138
  }
139
- const re = function(n, ...e) {
140
- return ne(e, function(t) {
139
+ const le = function(n, ...e) {
140
+ return ae(e, function(t) {
141
141
  for (const i in t)
142
142
  t[i] !== void 0 && (n[i] = t[i]);
143
143
  }), n;
144
144
  };
145
- function _(n, e) {
145
+ function S(n, e) {
146
146
  return n.indexOf(e) !== -1;
147
147
  }
148
- const oe = function(n) {
148
+ const ue = function(n) {
149
149
  try {
150
150
  return /^\s*\bfunction\b/.test(n);
151
151
  } catch {
152
152
  return !1;
153
153
  }
154
- }, ae = function(n) {
154
+ }, he = function(n) {
155
155
  return n === void 0;
156
- }, y = function() {
157
- const n = function(i, s, r, o, c) {
156
+ }, E = function() {
157
+ const n = function(i, s, r, o, a) {
158
158
  if (!i) {
159
- d().error("No valid element provided to register_event");
159
+ f().error("No valid element provided to register_event");
160
160
  return;
161
161
  }
162
162
  if (i.addEventListener && !o)
163
- i.addEventListener(s, r, !!c);
163
+ i.addEventListener(s, r, !!a);
164
164
  else {
165
- const l = "on" + s, a = i[l];
166
- i[l] = e(i, r, a);
165
+ const l = "on" + s, c = i[l];
166
+ i[l] = e(i, r, c);
167
167
  }
168
168
  };
169
169
  function e(i, s, r) {
170
170
  return function(o) {
171
171
  if (o = o || t(window.event), !o)
172
172
  return;
173
- let c = !0, l;
174
- oe(r) && (l = r(o));
175
- const a = s.call(i, o);
176
- return (l === !1 || a === !1) && (c = !1), c;
173
+ let a = !0, l;
174
+ ue(r) && (l = r(o));
175
+ const c = s.call(i, o);
176
+ return (l === !1 || c === !1) && (a = !1), a;
177
177
  };
178
178
  }
179
179
  function t(i) {
@@ -184,47 +184,47 @@ const oe = function(n) {
184
184
  }, t.stopPropagation = function() {
185
185
  this.cancelBubble = !0;
186
186
  }, n;
187
- }(), ce = function(n) {
187
+ }(), de = function(n) {
188
188
  return function(...e) {
189
189
  try {
190
190
  return n.apply(this, e);
191
191
  } catch (t) {
192
- d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
192
+ f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
193
193
  }
194
194
  };
195
- }, V = function(n) {
195
+ }, Z = function(n) {
196
196
  for (const e in n)
197
- typeof n[e] == "function" && (n[e] = ce(n[e]));
197
+ typeof n[e] == "function" && (n[e] = de(n[e]));
198
198
  };
199
- function U(n) {
199
+ function q(n) {
200
200
  for (let e in n)
201
201
  (n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
202
202
  return n;
203
203
  }
204
- function u() {
204
+ function h() {
205
205
  try {
206
206
  return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
207
207
  } catch {
208
- return d().warn("window is not available"), !1;
208
+ return f().warn("window is not available"), !1;
209
209
  }
210
210
  }
211
- function m(n = 5) {
211
+ function v(n = 5) {
212
212
  const e = new Uint8Array(n);
213
213
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
214
214
  }
215
- function le(n) {
215
+ function fe(n) {
216
216
  return n.replace(
217
217
  /([-_][a-z])/g,
218
218
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
219
  );
220
220
  }
221
- function I(n) {
222
- return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(I) : Object.keys(n).reduce((e, t) => {
223
- const i = le(t);
224
- return e[i] = I(n[t]), e;
221
+ function F(n) {
222
+ return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(F) : Object.keys(n).reduce((e, t) => {
223
+ const i = fe(t);
224
+ return e[i] = F(n[t]), e;
225
225
  }, {});
226
226
  }
227
- function A(n) {
227
+ function x(n) {
228
228
  switch (typeof n.className) {
229
229
  case "string":
230
230
  return n.className;
@@ -234,47 +234,47 @@ function A(n) {
234
234
  return "";
235
235
  }
236
236
  }
237
- function D(n) {
237
+ function V(n) {
238
238
  let e = "";
239
- return L(n) && !W(n) && n.childNodes && n.childNodes.length && g(n.childNodes, function(t) {
240
- Q(t) && t.textContent && (e += R(t.textContent).split(/(\s+)/).filter(E).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
- }), R(e);
239
+ return M(n) && !j(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
240
+ G(t) && t.textContent && (e += D(t.textContent).split(/(\s+)/).filter(C).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
+ }), D(e);
242
242
  }
243
- function J(n) {
243
+ function Y(n) {
244
244
  return !!n && n.nodeType === 1;
245
245
  }
246
- function f(n, e) {
246
+ function y(n, e) {
247
247
  return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
248
248
  }
249
- function Q(n) {
249
+ function G(n) {
250
250
  return !!n && n.nodeType === 3;
251
251
  }
252
- function O(n) {
252
+ function z(n) {
253
253
  return !!n && n.nodeType === 11;
254
254
  }
255
- const b = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function ue(n, e) {
257
- if (!n || f(n, "html") || !J(n))
255
+ const $ = ["a", "button", "form", "input", "select", "textarea", "label"];
256
+ function ge(n, e) {
257
+ if (!n || y(n, "html") || !Y(n))
258
258
  return !1;
259
259
  let t = n;
260
- for (; t && !f(t, "body"); ) {
260
+ for (; t && !y(t, "body"); ) {
261
261
  if (t.classList && t.classList.contains("um-no-capture"))
262
262
  return !1;
263
- t.parentNode && O(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
263
+ t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
264
  }
265
265
  let i = !1;
266
- for (t = n; t && !f(t, "body"); ) {
267
- if (t.parentNode && O(t.parentNode)) {
268
- t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
266
+ for (t = n; t && !y(t, "body"); ) {
267
+ if (t.parentNode && z(t.parentNode)) {
268
+ t = t.parentNode.host, t && $.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
269
269
  continue;
270
270
  }
271
271
  const o = t.parentNode;
272
272
  if (!o) break;
273
- if (b.indexOf(o.tagName.toLowerCase()) > -1)
273
+ if ($.indexOf(o.tagName.toLowerCase()) > -1)
274
274
  i = !0;
275
275
  else {
276
- const c = window.getComputedStyle(o);
277
- c && c.getPropertyValue("cursor") === "pointer" && (i = !0);
276
+ const a = window.getComputedStyle(o);
277
+ a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
278
278
  }
279
279
  t = o;
280
280
  }
@@ -293,16 +293,16 @@ function ue(n, e) {
293
293
  case "textarea":
294
294
  return e.type === "change" || e.type === "click";
295
295
  default:
296
- return i ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
296
+ return i ? e.type === "click" : e.type === "click" && ($.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
297
297
  }
298
298
  }
299
- function L(n) {
300
- for (let i = n; i.parentNode && !f(i, "body"); i = i.parentNode) {
301
- const s = A(i).split(" ");
302
- if (_(s, "ph-sensitive") || _(s, "ph-no-capture"))
299
+ function M(n) {
300
+ for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
301
+ const s = x(i).split(" ");
302
+ if (S(s, "ph-sensitive") || S(s, "ph-no-capture"))
303
303
  return !1;
304
304
  }
305
- if (_(A(n).split(" "), "ph-include"))
305
+ if (S(x(n).split(" "), "ph-include"))
306
306
  return !0;
307
307
  const e = n.type || "";
308
308
  if (typeof e == "string")
@@ -315,23 +315,23 @@ function L(n) {
315
315
  const t = n.name || n.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 W(n) {
318
+ function j(n) {
319
319
  const e = ["button", "checkbox", "submit", "reset"];
320
- return !!(f(n, "input") && !e.includes(n.type) || f(n, "select") || f(n, "textarea") || n.getAttribute("contenteditable") === "true");
320
+ return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
321
321
  }
322
- function E(n) {
323
- return !(n === null || ae(n) || typeof n == "string" && (n = R(n), /^(?:(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((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
322
+ function C(n) {
323
+ return !(n === null || he(n) || typeof n == "string" && (n = D(n), /^(?:(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((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
324
324
  }
325
- function he(n) {
325
+ function pe(n) {
326
326
  return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
327
327
  }
328
- function x() {
329
- return m(10);
328
+ function O() {
329
+ return v(10);
330
330
  }
331
- function de(n) {
331
+ function me(n) {
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(n).toLowerCase());
333
333
  }
334
- function fe(n, e) {
334
+ function ye(n, e) {
335
335
  let t;
336
336
  return function(...i) {
337
337
  const s = () => {
@@ -340,7 +340,7 @@ function fe(n, e) {
340
340
  clearTimeout(t), t = setTimeout(s, e);
341
341
  };
342
342
  }
343
- function ge(n) {
343
+ function we(n) {
344
344
  const e = {}, t = n.replace(/^\?/, "").split("&");
345
345
  for (let i = 0; i < t.length; i++) {
346
346
  const s = t[i].split("=");
@@ -348,25 +348,25 @@ function ge(n) {
348
348
  }
349
349
  return e;
350
350
  }
351
- function F(n) {
351
+ function J(n) {
352
352
  return typeof n == "string" || n instanceof String;
353
353
  }
354
- function v(n) {
354
+ function A(n) {
355
355
  return n !== null && typeof n == "object" && n.constructor === Object;
356
356
  }
357
- function pe(n) {
357
+ function ke(n) {
358
358
  if (n === null)
359
- return p.ERROR;
360
- const e = n.toUpperCase(), t = p[e];
361
- return t || t === 0 ? t : p.ERROR;
359
+ return k.ERROR;
360
+ const e = n.toUpperCase(), t = k[e];
361
+ return t || t === 0 ? t : k.ERROR;
362
362
  }
363
- const me = () => {
363
+ const ve = () => {
364
364
  let n = "false";
365
365
  return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
366
366
  };
367
- class ye {
367
+ class _e {
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 = fe(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 = ye(this.handleScroll.bind(this), 250), this.initializeEventListener();
370
370
  }
371
371
  initializeEventListener() {
372
372
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -414,10 +414,13 @@ class ye {
414
414
  this.send(), this.milestones = this.milestones.filter((s) => s !== i);
415
415
  });
416
416
  }
417
+ destroy() {
418
+ window.removeEventListener("scroll", this.debouncedHandleScroll);
419
+ }
417
420
  }
418
- const T = class T {
419
- constructor(e, t, i = d()) {
420
- this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new ye(e), se(this), V(this);
421
+ const R = class R {
422
+ constructor(e, t, i = f()) {
423
+ this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), ce(this), Z(this);
421
424
  }
422
425
  isBrowserSupported() {
423
426
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -441,7 +444,7 @@ const T = class T {
441
444
  const e = (t) => {
442
445
  t = t || window.event, this.captureEvent(t);
443
446
  };
444
- 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);
447
+ E(document, "submit", e, !1, !0), E(document, "change", e, !1, !0), E(document, "click", e, !1, !0), E(document, "visibilitychange", e, !1, !0), E(document, "scroll", e, !1, !0), E(window, "popstate", e, !1, !0);
445
448
  }
446
449
  isPageRefresh() {
447
450
  if ("PerformanceNavigationTiming" in window) {
@@ -454,61 +457,61 @@ const T = class T {
454
457
  captureEvent(e) {
455
458
  var i, s;
456
459
  let t = this.getEventTarget(e);
457
- if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
460
+ if (G(t) && (t = t.parentNode || null), e.type === "scroll")
458
461
  return (i = this.scrollDepth) == null || i.track(), !0;
459
462
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
460
463
  return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
461
- if (t && ue(t, e)) {
464
+ if (t && ge(t, e)) {
462
465
  const r = [t];
463
466
  let o = t;
464
- for (; o.parentNode && !f(o, "body"); ) {
465
- if (O(o.parentNode)) {
467
+ for (; o.parentNode && !y(o, "body"); ) {
468
+ if (z(o.parentNode)) {
466
469
  r.push(o.parentNode.host), o = o.parentNode.host;
467
470
  continue;
468
471
  }
469
472
  r.push(o.parentNode), o = o.parentNode;
470
473
  }
471
- const c = [];
472
- let l, a = !1;
473
- if (g(r, (k) => {
474
- const Z = L(k);
475
- k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = Z && E(l) && l);
476
- const Y = A(k).split(" ");
477
- _(Y, "ph-no-capture") && (a = !0), c.push(
474
+ const a = [];
475
+ let l, c = !1;
476
+ if (w(r, (p) => {
477
+ const _ = M(p);
478
+ p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && C(l) && l);
479
+ const u = x(p).split(" ");
480
+ S(u, "ph-no-capture") && (c = !0), a.push(
478
481
  this.getPropertiesFromElement(
479
- k,
482
+ p,
480
483
  this.options.maskAllElementAttributes ?? !1,
481
484
  this.options.maskAllText ?? !1
482
485
  )
483
486
  );
484
- }), this.options.maskAllText || (c[0].$el_text = D(t)), l && (c[0].attr__href = l), a)
487
+ }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
485
488
  return !1;
486
- const h = re(
489
+ const d = le(
487
490
  this.getDefaultProperties(e.type),
488
491
  {
489
- $elements: c
492
+ $elements: a
490
493
  },
491
494
  this.getCustomProperties(r)
492
495
  );
493
- return this.client.track("$autocapture", h), !0;
496
+ return this.client.track("$autocapture", d), !0;
494
497
  }
495
498
  }
496
499
  getCustomProperties(e) {
497
500
  const t = {};
498
- return g(this.customProperties, (i) => {
499
- g(i.event_selectors, (s) => {
501
+ return w(this.customProperties, (i) => {
502
+ w(i.event_selectors, (s) => {
500
503
  const r = document.querySelectorAll(s);
501
- g(r, (o) => {
502
- _(e, o) && L(o) && (t[i.name] = this.extractCustomPropertyValue(i));
504
+ w(r, (o) => {
505
+ S(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
503
506
  });
504
507
  });
505
508
  }), t;
506
509
  }
507
510
  extractCustomPropertyValue(e) {
508
511
  const t = [];
509
- return g(document.querySelectorAll(e.css_selector), function(i) {
512
+ return w(document.querySelectorAll(e.css_selector), function(i) {
510
513
  let s;
511
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), E(s) && t.push(s);
514
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), C(s) && t.push(s);
512
515
  }), t.join(", ");
513
516
  }
514
517
  getEventTarget(e) {
@@ -519,17 +522,17 @@ const T = class T {
519
522
  const s = e.tagName.toLowerCase(), r = {
520
523
  tag_name: s
521
524
  };
522
- b.indexOf(s) > -1 && !i && (r.$el_text = D(e));
523
- const o = A(e);
524
- o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
525
- return h !== "";
526
- })), g(e.attributes, function(h) {
527
- W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && E(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
525
+ $.indexOf(s) > -1 && !i && (r.$el_text = V(e));
526
+ const o = x(e);
527
+ o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
528
+ return d !== "";
529
+ })), w(e.attributes, function(d) {
530
+ j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && C(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
528
531
  });
529
- let c = 1, l = 1, a = e;
530
- for (; a = this.previousElementSibling(a); )
531
- c++, a.tagName === e.tagName && l++;
532
- return r.nth_child = c, r.nth_of_type = l, r;
532
+ let a = 1, l = 1, c = e;
533
+ for (; c = this.previousElementSibling(c); )
534
+ a++, c.tagName === e.tagName && l++;
535
+ return r.nth_child = a, r.nth_of_type = l, r;
533
536
  }
534
537
  previousElementSibling(e) {
535
538
  if (e.previousElementSibling)
@@ -538,7 +541,7 @@ const T = class T {
538
541
  let t = e;
539
542
  do
540
543
  t = t.previousSibling;
541
- while (t && !J(t));
544
+ while (t && !Y(t));
542
545
  return t;
543
546
  }
544
547
  }
@@ -560,9 +563,9 @@ const T = class T {
560
563
  return s % t < i;
561
564
  }
562
565
  };
563
- T.FORCE_CAPTURE_ATTR = "data-um-force-capture", T.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
564
- let $ = T;
565
- class we {
566
+ R.FORCE_CAPTURE_ATTR = "data-um-force-capture", R.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
567
+ let H = R;
568
+ class be {
566
569
  constructor(e) {
567
570
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
568
571
  }
@@ -591,8 +594,8 @@ class we {
591
594
  }));
592
595
  }
593
596
  }
594
- class ke {
595
- constructor(e, t, i = d()) {
597
+ class Ee {
598
+ constructor(e, t, i = f()) {
596
599
  this.trackingHost = e, this.logger = i, this.config = t;
597
600
  }
598
601
  async send(e) {
@@ -603,14 +606,14 @@ class ke {
603
606
  throw new Error("Failed to queue events via Beacon API");
604
607
  }
605
608
  constructUrl(e) {
606
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
607
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
609
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
610
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
608
611
  }
609
612
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
610
613
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
611
614
  }
612
- class z {
613
- constructor(e, t, i = d()) {
615
+ class Q {
616
+ constructor(e, t, i = f()) {
614
617
  this.trackingHost = e, this.logger = i, this.config = t;
615
618
  }
616
619
  async send(e) {
@@ -627,8 +630,8 @@ class z {
627
630
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
628
631
  }
629
632
  constructUrl(e) {
630
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
631
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
633
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
634
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
632
635
  }
633
636
  getCustomHeaders() {
634
637
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -637,17 +640,17 @@ class z {
637
640
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
638
641
  }
639
642
  }
640
- class ve {
641
- constructor(e, t, i = d()) {
643
+ class Pe {
644
+ constructor(e, t, i = f()) {
642
645
  this.trackingHost = e, this.logger = i, this.config = t;
643
646
  }
644
647
  send(e) {
645
648
  return new Promise((t, i) => {
646
649
  const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
647
650
  s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
648
- const c = this.getCustomHeaders();
649
- Object.keys(c).forEach((l) => {
650
- s.setRequestHeader(l, c[l]);
651
+ const a = this.getCustomHeaders();
652
+ Object.keys(a).forEach((l) => {
653
+ s.setRequestHeader(l, a[l]);
651
654
  }), s.onload = () => {
652
655
  s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
653
656
  }, s.onerror = () => {
@@ -656,8 +659,8 @@ class ve {
656
659
  });
657
660
  }
658
661
  constructUrl(e) {
659
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
660
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
662
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
663
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
661
664
  }
662
665
  getCustomHeaders() {
663
666
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -666,9 +669,9 @@ class ve {
666
669
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
667
670
  }
668
671
  }
669
- class K {
672
+ class ee {
670
673
  constructor(e, t) {
671
- this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
674
+ this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
672
675
  }
673
676
  set(e, t) {
674
677
  this.storage[e] = t, this.save();
@@ -683,7 +686,7 @@ class K {
683
686
  this.storage = {}, this.save();
684
687
  }
685
688
  save() {
686
- if (!u()) {
689
+ if (!h()) {
687
690
  this.logger.warn("localStorage is not available in this environment");
688
691
  return;
689
692
  }
@@ -694,7 +697,7 @@ class K {
694
697
  }
695
698
  }
696
699
  load() {
697
- if (!u()) {
700
+ if (!h()) {
698
701
  this.logger.warn("localStorage is not available in this environment");
699
702
  return;
700
703
  }
@@ -706,7 +709,7 @@ class K {
706
709
  }
707
710
  }
708
711
  }
709
- class _e {
712
+ class Ae {
710
713
  constructor() {
711
714
  this.storage = {};
712
715
  }
@@ -725,56 +728,56 @@ class _e {
725
728
  this.storage = {};
726
729
  }
727
730
  }
728
- class B {
731
+ class W {
729
732
  // Default to true for server-side
730
- constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = d(), c = "default") {
731
- this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new K(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
733
+ constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
734
+ this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new ee(`offline_queue_${a}`), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
732
735
  }
733
736
  add(e) {
734
737
  const t = { payload: e, retries: 0, timestamp: Date.now() };
735
- this.queue.push(t), u() ? this.saveQueueToStorage() : this.processBatch();
738
+ this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
736
739
  }
737
740
  initNetworkListeners() {
738
- u() && (window.addEventListener("online", () => {
741
+ h() && (window.addEventListener("online", () => {
739
742
  this.isOnline = !0, this.processBatch();
740
743
  }), window.addEventListener("offline", () => {
741
744
  this.isOnline = !1;
742
745
  }));
743
746
  }
744
747
  scheduleBatch() {
745
- u() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
748
+ h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
746
749
  }
747
750
  async processBatch() {
748
- if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
751
+ if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
749
752
  this.processing = !0;
750
753
  const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
751
754
  try {
752
- await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
755
+ await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
753
756
  } catch (i) {
754
757
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
755
758
  }
756
759
  this.processing = !1;
757
760
  }
758
- u() && this.scheduleBatch();
761
+ h() && this.scheduleBatch();
759
762
  }
760
763
  async handleBatchFailure(e) {
761
764
  for (const t of e)
762
765
  t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error("Max retries reached, discarding payload", t.payload);
763
- u() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
766
+ h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
764
767
  }
765
768
  loadQueueFromStorage() {
766
- if (u()) {
769
+ if (h()) {
767
770
  const e = this.persistence.get("queue");
768
771
  e && (this.queue = JSON.parse(e));
769
772
  }
770
773
  }
771
774
  saveQueueToStorage() {
772
- u() && this.persistence.set("queue", JSON.stringify(this.queue));
775
+ h() && this.persistence.set("queue", JSON.stringify(this.queue));
773
776
  }
774
777
  }
775
- class be {
778
+ class Se {
776
779
  constructor(e) {
777
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
780
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
778
781
  }
779
782
  initializeEventListener() {
780
783
  document.addEventListener("click", this.handleClick.bind(this));
@@ -794,8 +797,8 @@ class be {
794
797
  const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
795
798
  this.clicks.every((r, o) => {
796
799
  if (o === 0) return !0;
797
- const c = this.clicks[o - 1];
798
- return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
800
+ const a = this.clicks[o - 1];
801
+ return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
799
802
  }) && this.sendRageClickEvent(i);
800
803
  }
801
804
  sendRageClickEvent(e) {
@@ -806,8 +809,8 @@ class be {
806
809
  }), this.clicks = [];
807
810
  }
808
811
  }
809
- class Ee {
810
- constructor(e, t, i = d()) {
812
+ class $e {
813
+ constructor(e, t, i = f()) {
811
814
  this.trackingHost = e, this.logger = i, this.config = t;
812
815
  }
813
816
  async send(e) {
@@ -822,16 +825,16 @@ class Ee {
822
825
  }
823
826
  };
824
827
  return new Promise((r, o) => {
825
- const c = (void 0)(s, (l) => {
826
- l.on("data", (a) => {
828
+ const a = (void 0)(s, (l) => {
829
+ l.on("data", (c) => {
827
830
  }), l.on("end", () => {
828
- const a = l.statusCode || 0;
829
- a >= 200 && a < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${a}`));
831
+ const c = l.statusCode || 0;
832
+ c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
830
833
  });
831
834
  });
832
- c.on("error", (l) => {
835
+ a.on("error", (l) => {
833
836
  o(l);
834
- }), c.write(JSON.stringify(e)), c.end();
837
+ }), a.write(JSON.stringify(e)), a.end();
835
838
  });
836
839
  }
837
840
  constructUrl(e) {
@@ -842,7 +845,7 @@ class Ee {
842
845
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
843
846
  }
844
847
  }
845
- class w {
848
+ class P {
846
849
  constructor(e, t = "all", i = {}) {
847
850
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
848
851
  }
@@ -857,18 +860,18 @@ class w {
857
860
  }
858
861
  handleFormSubmit(e) {
859
862
  const t = e.target, i = this._getFormDetails(t);
860
- this.instance.track("$form", U(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
863
+ this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
861
864
  }
862
865
  trackFieldChanges(e) {
863
866
  e.querySelectorAll("input, select, textarea").forEach((i) => {
864
867
  i.addEventListener("change", (s) => {
865
868
  const r = this._getFieldProps(s.target, 0);
866
- this.instance.track("$form_field_change", U(r));
869
+ this.instance.track("$form_field_change", q(r));
867
870
  });
868
871
  });
869
872
  }
870
873
  static getInstance(e, t = "all", i = {}) {
871
- return w.instance || (w.instance = new w(e, t, i)), w.instance;
874
+ return P.instance || (P.instance = new P(e, t, i)), P.instance;
872
875
  }
873
876
  _getFormDetails(e) {
874
877
  const t = {
@@ -880,8 +883,8 @@ class w {
880
883
  form_attributes: this._getElementAttributes(e)
881
884
  }, i = e.querySelectorAll("input, select, textarea");
882
885
  return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
883
- const c = this._getFieldProps(r, o);
884
- Object.assign(t, c);
886
+ const a = this._getFieldProps(r, o);
887
+ Object.assign(t, a);
885
888
  }), t;
886
889
  }
887
890
  _getFieldProps(e, t) {
@@ -956,9 +959,9 @@ class w {
956
959
  return e.slice(t, i + 1);
957
960
  }
958
961
  }
959
- class S {
962
+ class N {
960
963
  constructor(e) {
961
- 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 B(
964
+ this.config = this.mergeConfig(e, X), this.logger = f(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new W(
962
965
  this.transport,
963
966
  this.config.maxSendAttempts || 3,
964
967
  this.config.minSendTimeout || 1e3,
@@ -967,16 +970,16 @@ class S {
967
970
  // Reduced interval to .2 second
968
971
  this.logger,
969
972
  this.namespace
970
- ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
973
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
971
974
  }
972
975
  initializeBrowserFeatures() {
973
- if (this.cookieManager = new j(this.config.cookieDomain), this.config.autocapture && $.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new $(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
976
+ if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && H.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new H(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
974
977
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
975
- this.formTracking = w.getInstance(this, e || "none", {
978
+ this.formTracking = P.getInstance(this, e || "none", {
976
979
  trackFieldChanges: !1
977
980
  });
978
981
  }
979
- this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
982
+ this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Se(this)), this.setupPageLeaveTracking();
980
983
  }
981
984
  /**
982
985
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -987,11 +990,11 @@ class S {
987
990
  const i = JSON.parse(JSON.stringify(e));
988
991
  let s = { ...t, ...i };
989
992
  return Object.keys(t).forEach((r) => {
990
- v(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
993
+ A(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
991
994
  }), s;
992
995
  }
993
996
  init(e) {
994
- 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 B(
997
+ this.config = { ...this.config, ...e }, this.logger = f(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new W(
995
998
  this.transport,
996
999
  this.config.maxSendAttempts || 3,
997
1000
  this.config.minSendTimeout || 1e3,
@@ -1000,21 +1003,21 @@ class S {
1000
1003
  // Reduced interval to .25 second
1001
1004
  this.logger,
1002
1005
  this.namespace
1003
- ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
1006
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
1004
1007
  }
1005
1008
  manageCrossDomainLinking() {
1006
1009
  if (!this.config.crossDomainLinking || !this.config.domains)
1007
1010
  return;
1008
1011
  const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1009
1012
  document.addEventListener("click", (i) => {
1010
- var c;
1013
+ var a;
1011
1014
  const s = this.findClosestLink(i.target);
1012
1015
  if (!s) return;
1013
1016
  const r = s.getAttribute("href");
1014
1017
  if (!r || !r.startsWith("http")) return;
1015
1018
  const o = new URL(r);
1016
1019
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1017
- const l = (c = this.cookieManager) == null ? void 0 : c.get(t);
1020
+ const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
1018
1021
  l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
1019
1022
  }
1020
1023
  }), this.logger.debug("Cross-domain linking initialized");
@@ -1026,47 +1029,47 @@ class S {
1026
1029
  }
1027
1030
  initializeTransport(e) {
1028
1031
  const t = "https://events.usermaven.com";
1029
- if (!u())
1030
- return new Ee(e.trackingHost || t, e);
1032
+ if (!h())
1033
+ return new $e(e.trackingHost || t, e);
1031
1034
  const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1032
1035
  if (e.useBeaconApi && r)
1033
- return new ke(e.trackingHost || t, e, this.logger);
1036
+ return new Ee(e.trackingHost || t, e, this.logger);
1034
1037
  if (e.forceUseFetch && s)
1035
- return new z(e.trackingHost || t, e, this.logger);
1038
+ return new Q(e.trackingHost || t, e, this.logger);
1036
1039
  if (i)
1037
- return new ve(e.trackingHost || t, e, this.logger);
1040
+ return new Pe(e.trackingHost || t, e, this.logger);
1038
1041
  if (s)
1039
- return new z(e.trackingHost || t, e, this.logger);
1042
+ return new Q(e.trackingHost || t, e, this.logger);
1040
1043
  throw new Error("No suitable transport method available");
1041
1044
  }
1042
1045
  initializePersistence() {
1043
- return this.config.disableEventPersistence || !u() ? new _e() : new K(`${this.namespace}_${this.config.key}`, this.logger);
1046
+ return this.config.disableEventPersistence || !h() ? new Ae() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
1044
1047
  }
1045
1048
  getOrCreateAnonymousId() {
1046
1049
  var i, s;
1047
- if (!u())
1048
- return x();
1050
+ if (!h())
1051
+ return O();
1049
1052
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1050
1053
  return "";
1051
1054
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1052
1055
  let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1053
1056
  if (!t) {
1054
1057
  if (this.config.crossDomainLinking) {
1055
- const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
1056
- t = c || h || x();
1058
+ const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
1059
+ t = a || d || O();
1057
1060
  }
1058
- t || (t = x());
1061
+ t || (t = O());
1059
1062
  const r = 365 * 10;
1060
1063
  (s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
1061
1064
  }
1062
1065
  return t;
1063
1066
  }
1064
1067
  async id(e, t = !1) {
1065
- if (!v(e))
1068
+ if (!A(e))
1066
1069
  throw new Error("User data must be an object");
1067
- if (e.email && !de(e.email))
1070
+ if (e.email && !me(e.email))
1068
1071
  throw new Error("Invalid email provided");
1069
- if (!e.id || !F(e.id))
1072
+ if (!e.id || !J(e.id))
1070
1073
  throw new Error("User ID must be a string");
1071
1074
  const i = e.id;
1072
1075
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1082,11 +1085,11 @@ class S {
1082
1085
  this.trackInternal(e, t, i);
1083
1086
  }
1084
1087
  trackInternal(e, t, i = !1) {
1085
- if (me()) {
1088
+ if (ve()) {
1086
1089
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1087
1090
  return;
1088
1091
  }
1089
- if (!F(e))
1092
+ if (!J(e))
1090
1093
  throw new Error("Event name must be a string");
1091
1094
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1092
1095
  throw new Error("Event payload must be a non-null object and not an array");
@@ -1102,21 +1105,21 @@ class S {
1102
1105
  }
1103
1106
  }
1104
1107
  rawTrack(e) {
1105
- if (!v(e))
1108
+ if (!A(e))
1106
1109
  throw new Error("Event payload must be an object");
1107
1110
  this.track("raw", e);
1108
1111
  }
1109
1112
  async group(e, t = !1) {
1110
- if (!v(e))
1113
+ if (!A(e))
1111
1114
  throw new Error("Company properties must be an object");
1112
1115
  if (!e.id || !e.name || !e.created_at)
1113
1116
  throw new Error("Company properties must include id, name, and created_at");
1114
1117
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1115
1118
  }
1116
1119
  createEventPayload(e, t) {
1117
- const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1120
+ const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, a = this.persistence.get(`props_${e}`) || {};
1118
1121
  let l = t || {};
1119
- const a = {
1122
+ const c = {
1120
1123
  event_id: "",
1121
1124
  user: {
1122
1125
  anonymous_id: this.anonymousId,
@@ -1132,15 +1135,15 @@ class S {
1132
1135
  event_type: e,
1133
1136
  namespace: this.namespace,
1134
1137
  ...o,
1135
- ...c
1138
+ ...a
1136
1139
  };
1137
1140
  if (e === "$autocapture") {
1138
- const h = this.processAutocaptureAttributes(t || {});
1139
- a.autocapture_attributes = h;
1140
- } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((h) => {
1141
- delete l[h];
1142
- }), a.event_attributes = l);
1143
- return u() && (a.referer = document.referrer, a.url = window.location.href, a.page_title = document.title, a.doc_path = window.location.pathname, a.doc_host = window.location.hostname, a.doc_search = window.location.search, a.screen_resolution = `${window.screen.width}x${window.screen.height}`, a.vp_size = `${window.innerWidth}x${window.innerHeight}`, a.user_agent = navigator.userAgent, a.user_language = navigator.language, a.doc_encoding = document.characterSet, a.utm = this.getUtmParams()), a;
1141
+ const d = this.processAutocaptureAttributes(t || {});
1142
+ c.autocapture_attributes = d;
1143
+ } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1144
+ delete l[d];
1145
+ }), c.event_attributes = l);
1146
+ return h() && (c.referer = document.referrer, c.url = window.location.href, c.page_title = document.title, c.doc_path = window.location.pathname, c.doc_host = window.location.hostname, c.doc_search = window.location.search, c.screen_resolution = `${window.screen.width}x${window.screen.height}`, c.vp_size = `${window.innerWidth}x${window.innerHeight}`, c.user_agent = navigator.userAgent, c.user_language = navigator.language, c.doc_encoding = document.characterSet, c.utm = this.getUtmParams()), c;
1144
1147
  }
1145
1148
  processAutocaptureAttributes(e) {
1146
1149
  let t = {};
@@ -1155,27 +1158,27 @@ class S {
1155
1158
  }
1156
1159
  getThirdPartyIds() {
1157
1160
  const e = {};
1158
- if (u()) {
1161
+ if (h()) {
1159
1162
  const t = this.getCookie("_fbp");
1160
1163
  t && (e.fbp = t);
1161
1164
  }
1162
1165
  return e;
1163
1166
  }
1164
1167
  getUtmParams() {
1165
- const e = {}, t = ge(window.location.search);
1168
+ const e = {}, t = we(window.location.search);
1166
1169
  return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
1167
1170
  t[s] && (e[s.replace("utm_", "")] = t[s]);
1168
1171
  }), e;
1169
1172
  }
1170
1173
  pageview() {
1171
- u() ? this.track("pageview", {
1174
+ h() ? this.track("pageview", {
1172
1175
  url: window.location.href,
1173
1176
  referrer: document.referrer,
1174
1177
  title: document.title
1175
1178
  }, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
1176
1179
  }
1177
1180
  setupPageLeaveTracking() {
1178
- if (!u()) return;
1181
+ if (!h()) return;
1179
1182
  let e = !1, t = !1;
1180
1183
  const i = () => {
1181
1184
  !e && !t && (e = !0, this.track("$pageleave", {
@@ -1210,7 +1213,7 @@ class S {
1210
1213
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1211
1214
  }
1212
1215
  set(e, t) {
1213
- if (!v(e))
1216
+ if (!A(e))
1214
1217
  throw new Error("Properties must be an object");
1215
1218
  const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1216
1219
  if (i) {
@@ -1243,28 +1246,28 @@ class S {
1243
1246
  s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1244
1247
  }
1245
1248
  }
1246
- function X() {
1249
+ function te() {
1247
1250
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1248
1251
  }
1249
- function Pe() {
1250
- return X() ? window.define : void 0;
1252
+ function Ce() {
1253
+ return te() ? window.define : void 0;
1251
1254
  }
1252
- const Ae = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1253
- function C(n) {
1254
- const e = JSON.parse(JSON.stringify(n)), t = I(e), i = { ...q, ...t };
1255
+ const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1256
+ function I(n) {
1257
+ const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
1255
1258
  if (!i.key)
1256
1259
  throw new Error("API key is required!");
1257
1260
  if (!i.trackingHost)
1258
1261
  throw new Error("Tracking host is required!");
1259
- const s = i.key || "", r = `${Ae}${s}`;
1260
- return u() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), u() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new S(i);
1262
+ const s = i.key || "", r = `${Te}${s}`;
1263
+ return h() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
1261
1264
  }
1262
- function $e(n) {
1265
+ function xe(n) {
1263
1266
  var s;
1264
1267
  const e = {
1265
1268
  key: n.getAttribute("data-key") || void 0,
1266
1269
  trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1267
- logLevel: pe(n.getAttribute("data-log-level")),
1270
+ logLevel: ke(n.getAttribute("data-log-level")),
1268
1271
  autocapture: n.getAttribute("data-autocapture") === "true",
1269
1272
  formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
1270
1273
  autoPageview: n.getAttribute("data-auto-pageview") === "true",
@@ -1291,79 +1294,112 @@ function $e(n) {
1291
1294
  maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
1292
1295
  };
1293
1296
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1294
- const t = C(e), i = e.namespace || "usermaven";
1295
- return u() && t.pageview(), Se(i, t), t;
1297
+ const t = I(e), i = e.namespace || "usermaven";
1298
+ return h() && t.pageview(), He(i, t), t;
1296
1299
  }
1297
- function Se(n, e) {
1300
+ function He(n, e) {
1298
1301
  let t = !1;
1299
1302
  const i = [], s = [];
1300
1303
  function r() {
1301
1304
  for (; i.length > 0; ) {
1302
- const a = i.shift();
1303
- a && window[n].apply(null, a);
1305
+ const u = i.shift();
1306
+ if (u) {
1307
+ const g = u[u.length - 1];
1308
+ if (g && typeof g.resolve == "function") {
1309
+ const m = u.pop();
1310
+ try {
1311
+ const b = a.apply(null, u);
1312
+ b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
1313
+ } catch (b) {
1314
+ m.reject(b);
1315
+ }
1316
+ } else
1317
+ try {
1318
+ a.apply(null, u);
1319
+ } catch (m) {
1320
+ console.error("Usermaven: Error processing queued command:", m);
1321
+ }
1322
+ }
1304
1323
  }
1305
1324
  }
1306
1325
  function o() {
1307
- s.forEach((a) => a()), s.length = 0;
1326
+ s.forEach((u) => u()), s.length = 0;
1308
1327
  }
1309
- window[n] = function(...a) {
1310
- const h = a[0];
1311
- if (h === "onLoad") {
1312
- typeof a[1] == "function" && (t ? a[1]() : s.push(a[1]));
1328
+ function a(...u) {
1329
+ const g = u[0];
1330
+ if (g === "onLoad") {
1331
+ typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
1313
1332
  return;
1314
1333
  }
1315
1334
  if (!t) {
1316
- i.push(a);
1335
+ i.push(u);
1317
1336
  return;
1318
1337
  }
1319
- if (typeof e[h] == "function")
1320
- return e[h].apply(e, a.slice(1));
1321
- console.error(`Method ${h} not found on UsermavenClient`);
1322
- };
1323
- const c = `${n}Q`, l = window[c] || [];
1324
- for (window[c] = l, l.push = function(...a) {
1325
- return window[n].apply(null, a), Array.prototype.push.apply(this, a);
1338
+ if (typeof e[g] == "function")
1339
+ return e[g].apply(e, u.slice(1));
1340
+ console.error(`Method ${g} not found on UsermavenClient`);
1341
+ }
1342
+ const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
1343
+ [...l, ...c].forEach((u) => {
1344
+ a[u] = function(...g) {
1345
+ if (!t) {
1346
+ if (l.includes(u))
1347
+ return new Promise((B, m) => {
1348
+ i.push([u, ...g, { resolve: B, reject: m }]);
1349
+ });
1350
+ i.push([u, ...g]);
1351
+ return;
1352
+ }
1353
+ if (typeof e[u] == "function")
1354
+ return e[u].apply(e, g);
1355
+ };
1356
+ }), a.getConfig = function() {
1357
+ return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
1358
+ }, window[n] = a;
1359
+ const p = `${n}Q`, _ = window[p] || [];
1360
+ for (window[p] = _, _.push = function(...u) {
1361
+ return a.apply(null, u), Array.prototype.push.apply(this, u);
1326
1362
  }, setTimeout(() => {
1327
1363
  t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
1328
- }, 0); l.length > 0; ) {
1329
- const a = l.shift();
1330
- a && i.push(a);
1364
+ }, 0); _.length > 0; ) {
1365
+ const u = _.shift();
1366
+ u && i.push(u);
1331
1367
  }
1332
1368
  }
1333
- let M = !1, H = null;
1334
- if (u()) {
1335
- const n = Pe();
1369
+ let K = !1, L = null;
1370
+ if (h()) {
1371
+ const n = Ce();
1336
1372
  n && n("usermaven", [], function() {
1337
1373
  return {
1338
- usermavenClient: C,
1339
- UsermavenClient: S,
1340
- LogLevel: p,
1374
+ usermavenClient: I,
1375
+ UsermavenClient: N,
1376
+ LogLevel: k,
1341
1377
  // Expose the script tag client if it exists
1342
- getScriptTagClient: () => H
1378
+ getScriptTagClient: () => L
1343
1379
  };
1344
- }), typeof window < "u" && (window.usermavenClient = C, window.UsermavenClient = S, window.usermavenScriptTagClient = () => H), function(e, t) {
1380
+ }), typeof window < "u" && (window.usermavenClient = I, window.UsermavenClient = N, window.usermavenScriptTagClient = () => L), function(e, t) {
1345
1381
  const i = e.currentScript;
1346
1382
  function s() {
1347
- return M || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1383
+ return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1348
1384
  }
1349
1385
  function r() {
1350
- s() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(i), M = !0);
1386
+ s() && (console.log("[Usermaven] Auto-initializing from script tag"), L = xe(i), K = !0);
1351
1387
  }
1352
1388
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1353
1389
  }(document, window);
1354
1390
  }
1355
- typeof module < "u" && module.exports && !X() && (module.exports = {
1356
- usermavenClient: C,
1357
- UsermavenClient: S,
1391
+ typeof module < "u" && module.exports && !te() && (module.exports = {
1392
+ usermavenClient: I,
1393
+ UsermavenClient: N,
1358
1394
  Config: void 0,
1359
1395
  UserProps: void 0,
1360
1396
  EventPayload: void 0,
1361
- LogLevel: p,
1397
+ LogLevel: k,
1362
1398
  ClientProperties: void 0
1363
1399
  });
1364
1400
 
1365
1401
  function createClient(params) {
1366
- return C(params);
1402
+ return I(params);
1367
1403
  }
1368
1404
 
1369
1405
  function useUsermaven() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/react",
3
- "version": "1.5.8",
3
+ "version": "1.5.9-rc.106",
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.8"
21
+ "@usermaven/sdk-js": "1.5.9-rc.106"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "15.x || 16.x || 17.x || 18.x || 19.x",