@usermaven/react 1.5.8-rc.103 → 1.5.8-rc.104

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 +305 -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, L = {};
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) === L)
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) === L)
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) === L)
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 $(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 S = ["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 && S.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 (S.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" && (S.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, "ph-sensitive") || $(s, "ph-no-capture"))
303
303
  return !1;
304
304
  }
305
- if (_(A(n).split(" "), "ph-include"))
305
+ if ($(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);
@@ -415,9 +415,9 @@ class ye {
415
415
  });
416
416
  }
417
417
  }
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);
418
+ const R = class R {
419
+ constructor(e, t, i = f()) {
420
+ 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
421
  }
422
422
  isBrowserSupported() {
423
423
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -441,7 +441,7 @@ const T = class T {
441
441
  const e = (t) => {
442
442
  t = t || window.event, this.captureEvent(t);
443
443
  };
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);
444
+ 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
445
  }
446
446
  isPageRefresh() {
447
447
  if ("PerformanceNavigationTiming" in window) {
@@ -454,61 +454,61 @@ const T = class T {
454
454
  captureEvent(e) {
455
455
  var i, s;
456
456
  let t = this.getEventTarget(e);
457
- if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
457
+ if (G(t) && (t = t.parentNode || null), e.type === "scroll")
458
458
  return (i = this.scrollDepth) == null || i.track(), !0;
459
459
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
460
460
  return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
461
- if (t && ue(t, e)) {
461
+ if (t && ge(t, e)) {
462
462
  const r = [t];
463
463
  let o = t;
464
- for (; o.parentNode && !f(o, "body"); ) {
465
- if (O(o.parentNode)) {
464
+ for (; o.parentNode && !y(o, "body"); ) {
465
+ if (z(o.parentNode)) {
466
466
  r.push(o.parentNode.host), o = o.parentNode.host;
467
467
  continue;
468
468
  }
469
469
  r.push(o.parentNode), o = o.parentNode;
470
470
  }
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(
471
+ const a = [];
472
+ let l, c = !1;
473
+ if (w(r, (p) => {
474
+ const _ = M(p);
475
+ p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && C(l) && l);
476
+ const u = x(p).split(" ");
477
+ $(u, "ph-no-capture") && (c = !0), a.push(
478
478
  this.getPropertiesFromElement(
479
- k,
479
+ p,
480
480
  this.options.maskAllElementAttributes ?? !1,
481
481
  this.options.maskAllText ?? !1
482
482
  )
483
483
  );
484
- }), this.options.maskAllText || (c[0].$el_text = D(t)), l && (c[0].attr__href = l), a)
484
+ }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
485
485
  return !1;
486
- const h = re(
486
+ const d = le(
487
487
  this.getDefaultProperties(e.type),
488
488
  {
489
- $elements: c
489
+ $elements: a
490
490
  },
491
491
  this.getCustomProperties(r)
492
492
  );
493
- return this.client.track("$autocapture", h), !0;
493
+ return this.client.track("$autocapture", d), !0;
494
494
  }
495
495
  }
496
496
  getCustomProperties(e) {
497
497
  const t = {};
498
- return g(this.customProperties, (i) => {
499
- g(i.event_selectors, (s) => {
498
+ return w(this.customProperties, (i) => {
499
+ w(i.event_selectors, (s) => {
500
500
  const r = document.querySelectorAll(s);
501
- g(r, (o) => {
502
- _(e, o) && L(o) && (t[i.name] = this.extractCustomPropertyValue(i));
501
+ w(r, (o) => {
502
+ $(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
503
503
  });
504
504
  });
505
505
  }), t;
506
506
  }
507
507
  extractCustomPropertyValue(e) {
508
508
  const t = [];
509
- return g(document.querySelectorAll(e.css_selector), function(i) {
509
+ return w(document.querySelectorAll(e.css_selector), function(i) {
510
510
  let s;
511
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), E(s) && t.push(s);
511
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), C(s) && t.push(s);
512
512
  }), t.join(", ");
513
513
  }
514
514
  getEventTarget(e) {
@@ -519,17 +519,17 @@ const T = class T {
519
519
  const s = e.tagName.toLowerCase(), r = {
520
520
  tag_name: s
521
521
  };
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);
522
+ S.indexOf(s) > -1 && !i && (r.$el_text = V(e));
523
+ const o = x(e);
524
+ o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
525
+ return d !== "";
526
+ })), w(e.attributes, function(d) {
527
+ j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && C(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
528
528
  });
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;
529
+ let a = 1, l = 1, c = e;
530
+ for (; c = this.previousElementSibling(c); )
531
+ a++, c.tagName === e.tagName && l++;
532
+ return r.nth_child = a, r.nth_of_type = l, r;
533
533
  }
534
534
  previousElementSibling(e) {
535
535
  if (e.previousElementSibling)
@@ -538,7 +538,7 @@ const T = class T {
538
538
  let t = e;
539
539
  do
540
540
  t = t.previousSibling;
541
- while (t && !J(t));
541
+ while (t && !Y(t));
542
542
  return t;
543
543
  }
544
544
  }
@@ -560,9 +560,9 @@ const T = class T {
560
560
  return s % t < i;
561
561
  }
562
562
  };
563
- T.FORCE_CAPTURE_ATTR = "data-um-force-capture", T.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
564
- let $ = T;
565
- class we {
563
+ R.FORCE_CAPTURE_ATTR = "data-um-force-capture", R.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
564
+ let H = R;
565
+ class be {
566
566
  constructor(e) {
567
567
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
568
568
  }
@@ -591,8 +591,8 @@ class we {
591
591
  }));
592
592
  }
593
593
  }
594
- class ke {
595
- constructor(e, t, i = d()) {
594
+ class Ee {
595
+ constructor(e, t, i = f()) {
596
596
  this.trackingHost = e, this.logger = i, this.config = t;
597
597
  }
598
598
  async send(e) {
@@ -603,14 +603,14 @@ class ke {
603
603
  throw new Error("Failed to queue events via Beacon API");
604
604
  }
605
605
  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}`;
606
+ 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";
607
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
608
608
  }
609
609
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
610
610
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
611
611
  }
612
- class z {
613
- constructor(e, t, i = d()) {
612
+ class Q {
613
+ constructor(e, t, i = f()) {
614
614
  this.trackingHost = e, this.logger = i, this.config = t;
615
615
  }
616
616
  async send(e) {
@@ -627,8 +627,8 @@ class z {
627
627
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
628
628
  }
629
629
  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}`;
630
+ 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";
631
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
632
632
  }
633
633
  getCustomHeaders() {
634
634
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -637,17 +637,17 @@ class z {
637
637
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
638
638
  }
639
639
  }
640
- class ve {
641
- constructor(e, t, i = d()) {
640
+ class Pe {
641
+ constructor(e, t, i = f()) {
642
642
  this.trackingHost = e, this.logger = i, this.config = t;
643
643
  }
644
644
  send(e) {
645
645
  return new Promise((t, i) => {
646
646
  const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
647
647
  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]);
648
+ const a = this.getCustomHeaders();
649
+ Object.keys(a).forEach((l) => {
650
+ s.setRequestHeader(l, a[l]);
651
651
  }), s.onload = () => {
652
652
  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
653
  }, s.onerror = () => {
@@ -656,8 +656,8 @@ class ve {
656
656
  });
657
657
  }
658
658
  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}`;
659
+ 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";
660
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
661
661
  }
662
662
  getCustomHeaders() {
663
663
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -666,9 +666,9 @@ class ve {
666
666
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
667
667
  }
668
668
  }
669
- class K {
669
+ class ee {
670
670
  constructor(e, t) {
671
- this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
671
+ this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
672
672
  }
673
673
  set(e, t) {
674
674
  this.storage[e] = t, this.save();
@@ -683,7 +683,7 @@ class K {
683
683
  this.storage = {}, this.save();
684
684
  }
685
685
  save() {
686
- if (!u()) {
686
+ if (!h()) {
687
687
  this.logger.warn("localStorage is not available in this environment");
688
688
  return;
689
689
  }
@@ -694,7 +694,7 @@ class K {
694
694
  }
695
695
  }
696
696
  load() {
697
- if (!u()) {
697
+ if (!h()) {
698
698
  this.logger.warn("localStorage is not available in this environment");
699
699
  return;
700
700
  }
@@ -706,7 +706,7 @@ class K {
706
706
  }
707
707
  }
708
708
  }
709
- class _e {
709
+ class Ae {
710
710
  constructor() {
711
711
  this.storage = {};
712
712
  }
@@ -725,56 +725,56 @@ class _e {
725
725
  this.storage = {};
726
726
  }
727
727
  }
728
- class B {
728
+ class W {
729
729
  // 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());
730
+ constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "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 ee(`offline_queue_${a}`), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
732
732
  }
733
733
  add(e) {
734
734
  const t = { payload: e, retries: 0, timestamp: Date.now() };
735
- this.queue.push(t), u() ? this.saveQueueToStorage() : this.processBatch();
735
+ this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
736
736
  }
737
737
  initNetworkListeners() {
738
- u() && (window.addEventListener("online", () => {
738
+ h() && (window.addEventListener("online", () => {
739
739
  this.isOnline = !0, this.processBatch();
740
740
  }), window.addEventListener("offline", () => {
741
741
  this.isOnline = !1;
742
742
  }));
743
743
  }
744
744
  scheduleBatch() {
745
- u() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
745
+ h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
746
746
  }
747
747
  async processBatch() {
748
- if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
748
+ if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
749
749
  this.processing = !0;
750
750
  const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
751
751
  try {
752
- await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
752
+ await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
753
753
  } catch (i) {
754
754
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
755
755
  }
756
756
  this.processing = !1;
757
757
  }
758
- u() && this.scheduleBatch();
758
+ h() && this.scheduleBatch();
759
759
  }
760
760
  async handleBatchFailure(e) {
761
761
  for (const t of e)
762
762
  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)));
763
+ h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
764
764
  }
765
765
  loadQueueFromStorage() {
766
- if (u()) {
766
+ if (h()) {
767
767
  const e = this.persistence.get("queue");
768
768
  e && (this.queue = JSON.parse(e));
769
769
  }
770
770
  }
771
771
  saveQueueToStorage() {
772
- u() && this.persistence.set("queue", JSON.stringify(this.queue));
772
+ h() && this.persistence.set("queue", JSON.stringify(this.queue));
773
773
  }
774
774
  }
775
- class be {
775
+ class $e {
776
776
  constructor(e) {
777
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
777
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
778
778
  }
779
779
  initializeEventListener() {
780
780
  document.addEventListener("click", this.handleClick.bind(this));
@@ -794,8 +794,8 @@ class be {
794
794
  const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
795
795
  this.clicks.every((r, o) => {
796
796
  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;
797
+ const a = this.clicks[o - 1];
798
+ return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
799
799
  }) && this.sendRageClickEvent(i);
800
800
  }
801
801
  sendRageClickEvent(e) {
@@ -806,8 +806,8 @@ class be {
806
806
  }), this.clicks = [];
807
807
  }
808
808
  }
809
- class Ee {
810
- constructor(e, t, i = d()) {
809
+ class Se {
810
+ constructor(e, t, i = f()) {
811
811
  this.trackingHost = e, this.logger = i, this.config = t;
812
812
  }
813
813
  async send(e) {
@@ -822,16 +822,16 @@ class Ee {
822
822
  }
823
823
  };
824
824
  return new Promise((r, o) => {
825
- const c = (void 0)(s, (l) => {
826
- l.on("data", (a) => {
825
+ const a = (void 0)(s, (l) => {
826
+ l.on("data", (c) => {
827
827
  }), 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}`));
828
+ const c = l.statusCode || 0;
829
+ c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
830
830
  });
831
831
  });
832
- c.on("error", (l) => {
832
+ a.on("error", (l) => {
833
833
  o(l);
834
- }), c.write(JSON.stringify(e)), c.end();
834
+ }), a.write(JSON.stringify(e)), a.end();
835
835
  });
836
836
  }
837
837
  constructUrl(e) {
@@ -842,7 +842,7 @@ class Ee {
842
842
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
843
843
  }
844
844
  }
845
- class w {
845
+ class P {
846
846
  constructor(e, t = "all", i = {}) {
847
847
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
848
848
  }
@@ -857,18 +857,18 @@ class w {
857
857
  }
858
858
  handleFormSubmit(e) {
859
859
  const t = e.target, i = this._getFormDetails(t);
860
- this.instance.track("$form", U(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
860
+ this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
861
861
  }
862
862
  trackFieldChanges(e) {
863
863
  e.querySelectorAll("input, select, textarea").forEach((i) => {
864
864
  i.addEventListener("change", (s) => {
865
865
  const r = this._getFieldProps(s.target, 0);
866
- this.instance.track("$form_field_change", U(r));
866
+ this.instance.track("$form_field_change", q(r));
867
867
  });
868
868
  });
869
869
  }
870
870
  static getInstance(e, t = "all", i = {}) {
871
- return w.instance || (w.instance = new w(e, t, i)), w.instance;
871
+ return P.instance || (P.instance = new P(e, t, i)), P.instance;
872
872
  }
873
873
  _getFormDetails(e) {
874
874
  const t = {
@@ -880,8 +880,8 @@ class w {
880
880
  form_attributes: this._getElementAttributes(e)
881
881
  }, i = e.querySelectorAll("input, select, textarea");
882
882
  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);
883
+ const a = this._getFieldProps(r, o);
884
+ Object.assign(t, a);
885
885
  }), t;
886
886
  }
887
887
  _getFieldProps(e, t) {
@@ -956,9 +956,9 @@ class w {
956
956
  return e.slice(t, i + 1);
957
957
  }
958
958
  }
959
- class S {
959
+ class N {
960
960
  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(
961
+ 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
962
  this.transport,
963
963
  this.config.maxSendAttempts || 3,
964
964
  this.config.minSendTimeout || 1e3,
@@ -967,16 +967,16 @@ class S {
967
967
  // Reduced interval to .2 second
968
968
  this.logger,
969
969
  this.namespace
970
- ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
970
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
971
971
  }
972
972
  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) {
973
+ 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
974
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
975
- this.formTracking = w.getInstance(this, e || "none", {
975
+ this.formTracking = P.getInstance(this, e || "none", {
976
976
  trackFieldChanges: !1
977
977
  });
978
978
  }
979
- this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
979
+ this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new $e(this)), this.setupPageLeaveTracking();
980
980
  }
981
981
  /**
982
982
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -987,11 +987,11 @@ class S {
987
987
  const i = JSON.parse(JSON.stringify(e));
988
988
  let s = { ...t, ...i };
989
989
  return Object.keys(t).forEach((r) => {
990
- v(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
990
+ A(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
991
991
  }), s;
992
992
  }
993
993
  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(
994
+ 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
995
  this.transport,
996
996
  this.config.maxSendAttempts || 3,
997
997
  this.config.minSendTimeout || 1e3,
@@ -1000,21 +1000,21 @@ class S {
1000
1000
  // Reduced interval to .25 second
1001
1001
  this.logger,
1002
1002
  this.namespace
1003
- ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
1003
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
1004
1004
  }
1005
1005
  manageCrossDomainLinking() {
1006
1006
  if (!this.config.crossDomainLinking || !this.config.domains)
1007
1007
  return;
1008
1008
  const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1009
1009
  document.addEventListener("click", (i) => {
1010
- var c;
1010
+ var a;
1011
1011
  const s = this.findClosestLink(i.target);
1012
1012
  if (!s) return;
1013
1013
  const r = s.getAttribute("href");
1014
1014
  if (!r || !r.startsWith("http")) return;
1015
1015
  const o = new URL(r);
1016
1016
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1017
- const l = (c = this.cookieManager) == null ? void 0 : c.get(t);
1017
+ const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
1018
1018
  l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
1019
1019
  }
1020
1020
  }), this.logger.debug("Cross-domain linking initialized");
@@ -1026,47 +1026,47 @@ class S {
1026
1026
  }
1027
1027
  initializeTransport(e) {
1028
1028
  const t = "https://events.usermaven.com";
1029
- if (!u())
1030
- return new Ee(e.trackingHost || t, e);
1029
+ if (!h())
1030
+ return new Se(e.trackingHost || t, e);
1031
1031
  const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1032
1032
  if (e.useBeaconApi && r)
1033
- return new ke(e.trackingHost || t, e, this.logger);
1033
+ return new Ee(e.trackingHost || t, e, this.logger);
1034
1034
  if (e.forceUseFetch && s)
1035
- return new z(e.trackingHost || t, e, this.logger);
1035
+ return new Q(e.trackingHost || t, e, this.logger);
1036
1036
  if (i)
1037
- return new ve(e.trackingHost || t, e, this.logger);
1037
+ return new Pe(e.trackingHost || t, e, this.logger);
1038
1038
  if (s)
1039
- return new z(e.trackingHost || t, e, this.logger);
1039
+ return new Q(e.trackingHost || t, e, this.logger);
1040
1040
  throw new Error("No suitable transport method available");
1041
1041
  }
1042
1042
  initializePersistence() {
1043
- return this.config.disableEventPersistence || !u() ? new _e() : new K(`${this.namespace}_${this.config.key}`, this.logger);
1043
+ return this.config.disableEventPersistence || !h() ? new Ae() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
1044
1044
  }
1045
1045
  getOrCreateAnonymousId() {
1046
1046
  var i, s;
1047
- if (!u())
1048
- return x();
1047
+ if (!h())
1048
+ return O();
1049
1049
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1050
1050
  return "";
1051
1051
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1052
1052
  let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1053
1053
  if (!t) {
1054
1054
  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();
1055
+ const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
1056
+ t = a || d || O();
1057
1057
  }
1058
- t || (t = x());
1058
+ t || (t = O());
1059
1059
  const r = 365 * 10;
1060
1060
  (s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
1061
1061
  }
1062
1062
  return t;
1063
1063
  }
1064
1064
  async id(e, t = !1) {
1065
- if (!v(e))
1065
+ if (!A(e))
1066
1066
  throw new Error("User data must be an object");
1067
- if (e.email && !de(e.email))
1067
+ if (e.email && !me(e.email))
1068
1068
  throw new Error("Invalid email provided");
1069
- if (!e.id || !F(e.id))
1069
+ if (!e.id || !J(e.id))
1070
1070
  throw new Error("User ID must be a string");
1071
1071
  const i = e.id;
1072
1072
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1082,11 +1082,11 @@ class S {
1082
1082
  this.trackInternal(e, t, i);
1083
1083
  }
1084
1084
  trackInternal(e, t, i = !1) {
1085
- if (me()) {
1085
+ if (ve()) {
1086
1086
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1087
1087
  return;
1088
1088
  }
1089
- if (!F(e))
1089
+ if (!J(e))
1090
1090
  throw new Error("Event name must be a string");
1091
1091
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1092
1092
  throw new Error("Event payload must be a non-null object and not an array");
@@ -1102,21 +1102,21 @@ class S {
1102
1102
  }
1103
1103
  }
1104
1104
  rawTrack(e) {
1105
- if (!v(e))
1105
+ if (!A(e))
1106
1106
  throw new Error("Event payload must be an object");
1107
1107
  this.track("raw", e);
1108
1108
  }
1109
1109
  async group(e, t = !1) {
1110
- if (!v(e))
1110
+ if (!A(e))
1111
1111
  throw new Error("Company properties must be an object");
1112
1112
  if (!e.id || !e.name || !e.created_at)
1113
1113
  throw new Error("Company properties must include id, name, and created_at");
1114
1114
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1115
1115
  }
1116
1116
  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}`) || {};
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") || {}, a = this.persistence.get(`props_${e}`) || {};
1118
1118
  let l = t || {};
1119
- const a = {
1119
+ const c = {
1120
1120
  event_id: "",
1121
1121
  user: {
1122
1122
  anonymous_id: this.anonymousId,
@@ -1132,15 +1132,15 @@ class S {
1132
1132
  event_type: e,
1133
1133
  namespace: this.namespace,
1134
1134
  ...o,
1135
- ...c
1135
+ ...a
1136
1136
  };
1137
1137
  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;
1138
+ const d = this.processAutocaptureAttributes(t || {});
1139
+ c.autocapture_attributes = d;
1140
+ } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1141
+ delete l[d];
1142
+ }), c.event_attributes = l);
1143
+ 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
1144
  }
1145
1145
  processAutocaptureAttributes(e) {
1146
1146
  let t = {};
@@ -1155,27 +1155,27 @@ class S {
1155
1155
  }
1156
1156
  getThirdPartyIds() {
1157
1157
  const e = {};
1158
- if (u()) {
1158
+ if (h()) {
1159
1159
  const t = this.getCookie("_fbp");
1160
1160
  t && (e.fbp = t);
1161
1161
  }
1162
1162
  return e;
1163
1163
  }
1164
1164
  getUtmParams() {
1165
- const e = {}, t = ge(window.location.search);
1165
+ const e = {}, t = we(window.location.search);
1166
1166
  return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
1167
1167
  t[s] && (e[s.replace("utm_", "")] = t[s]);
1168
1168
  }), e;
1169
1169
  }
1170
1170
  pageview() {
1171
- u() ? this.track("pageview", {
1171
+ h() ? this.track("pageview", {
1172
1172
  url: window.location.href,
1173
1173
  referrer: document.referrer,
1174
1174
  title: document.title
1175
1175
  }, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
1176
1176
  }
1177
1177
  setupPageLeaveTracking() {
1178
- if (!u()) return;
1178
+ if (!h()) return;
1179
1179
  let e = !1, t = !1;
1180
1180
  const i = () => {
1181
1181
  !e && !t && (e = !0, this.track("$pageleave", {
@@ -1210,7 +1210,7 @@ class S {
1210
1210
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1211
1211
  }
1212
1212
  set(e, t) {
1213
- if (!v(e))
1213
+ if (!A(e))
1214
1214
  throw new Error("Properties must be an object");
1215
1215
  const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1216
1216
  if (i) {
@@ -1243,28 +1243,28 @@ class S {
1243
1243
  s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1244
1244
  }
1245
1245
  }
1246
- function X() {
1246
+ function te() {
1247
1247
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1248
1248
  }
1249
- function Pe() {
1250
- return X() ? window.define : void 0;
1249
+ function Ce() {
1250
+ return te() ? window.define : void 0;
1251
1251
  }
1252
- const Ae = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1253
- function C(n) {
1254
- const e = JSON.parse(JSON.stringify(n)), t = I(e), i = { ...q, ...t };
1252
+ const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1253
+ function I(n) {
1254
+ const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
1255
1255
  if (!i.key)
1256
1256
  throw new Error("API key is required!");
1257
1257
  if (!i.trackingHost)
1258
1258
  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);
1259
+ const s = i.key || "", r = `${Te}${s}`;
1260
+ 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
1261
  }
1262
- function $e(n) {
1262
+ function xe(n) {
1263
1263
  var s;
1264
1264
  const e = {
1265
1265
  key: n.getAttribute("data-key") || void 0,
1266
1266
  trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1267
- logLevel: pe(n.getAttribute("data-log-level")),
1267
+ logLevel: ke(n.getAttribute("data-log-level")),
1268
1268
  autocapture: n.getAttribute("data-autocapture") === "true",
1269
1269
  formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
1270
1270
  autoPageview: n.getAttribute("data-auto-pageview") === "true",
@@ -1291,79 +1291,112 @@ function $e(n) {
1291
1291
  maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
1292
1292
  };
1293
1293
  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;
1294
+ const t = I(e), i = e.namespace || "usermaven";
1295
+ return h() && t.pageview(), He(i, t), t;
1296
1296
  }
1297
- function Se(n, e) {
1297
+ function He(n, e) {
1298
1298
  let t = !1;
1299
1299
  const i = [], s = [];
1300
1300
  function r() {
1301
1301
  for (; i.length > 0; ) {
1302
- const a = i.shift();
1303
- a && window[n].apply(null, a);
1302
+ const u = i.shift();
1303
+ if (u) {
1304
+ const g = u[u.length - 1];
1305
+ if (g && typeof g.resolve == "function") {
1306
+ const m = u.pop();
1307
+ try {
1308
+ const b = a.apply(null, u);
1309
+ b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
1310
+ } catch (b) {
1311
+ m.reject(b);
1312
+ }
1313
+ } else
1314
+ try {
1315
+ a.apply(null, u);
1316
+ } catch (m) {
1317
+ console.error("Usermaven: Error processing queued command:", m);
1318
+ }
1319
+ }
1304
1320
  }
1305
1321
  }
1306
1322
  function o() {
1307
- s.forEach((a) => a()), s.length = 0;
1323
+ s.forEach((u) => u()), s.length = 0;
1308
1324
  }
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]));
1325
+ function a(...u) {
1326
+ const g = u[0];
1327
+ if (g === "onLoad") {
1328
+ typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
1313
1329
  return;
1314
1330
  }
1315
1331
  if (!t) {
1316
- i.push(a);
1332
+ i.push(u);
1317
1333
  return;
1318
1334
  }
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);
1335
+ if (typeof e[g] == "function")
1336
+ return e[g].apply(e, u.slice(1));
1337
+ console.error(`Method ${g} not found on UsermavenClient`);
1338
+ }
1339
+ const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
1340
+ [...l, ...c].forEach((u) => {
1341
+ a[u] = function(...g) {
1342
+ if (!t) {
1343
+ if (l.includes(u))
1344
+ return new Promise((B, m) => {
1345
+ i.push([u, ...g, { resolve: B, reject: m }]);
1346
+ });
1347
+ i.push([u, ...g]);
1348
+ return;
1349
+ }
1350
+ if (typeof e[u] == "function")
1351
+ return e[u].apply(e, g);
1352
+ };
1353
+ }), a.getConfig = function() {
1354
+ return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
1355
+ }, window[n] = a;
1356
+ const p = `${n}Q`, _ = window[p] || [];
1357
+ for (window[p] = _, _.push = function(...u) {
1358
+ return a.apply(null, u), Array.prototype.push.apply(this, u);
1326
1359
  }, setTimeout(() => {
1327
1360
  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);
1361
+ }, 0); _.length > 0; ) {
1362
+ const u = _.shift();
1363
+ u && i.push(u);
1331
1364
  }
1332
1365
  }
1333
- let M = !1, H = null;
1334
- if (u()) {
1335
- const n = Pe();
1366
+ let K = !1, U = null;
1367
+ if (h()) {
1368
+ const n = Ce();
1336
1369
  n && n("usermaven", [], function() {
1337
1370
  return {
1338
- usermavenClient: C,
1339
- UsermavenClient: S,
1340
- LogLevel: p,
1371
+ usermavenClient: I,
1372
+ UsermavenClient: N,
1373
+ LogLevel: k,
1341
1374
  // Expose the script tag client if it exists
1342
- getScriptTagClient: () => H
1375
+ getScriptTagClient: () => U
1343
1376
  };
1344
- }), typeof window < "u" && (window.usermavenClient = C, window.UsermavenClient = S, window.usermavenScriptTagClient = () => H), function(e, t) {
1377
+ }), typeof window < "u" && (window.usermavenClient = I, window.UsermavenClient = N, window.usermavenScriptTagClient = () => U), function(e, t) {
1345
1378
  const i = e.currentScript;
1346
1379
  function s() {
1347
- return M || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1380
+ return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1348
1381
  }
1349
1382
  function r() {
1350
- s() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(i), M = !0);
1383
+ s() && (console.log("[Usermaven] Auto-initializing from script tag"), U = xe(i), K = !0);
1351
1384
  }
1352
1385
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1353
1386
  }(document, window);
1354
1387
  }
1355
- typeof module < "u" && module.exports && !X() && (module.exports = {
1356
- usermavenClient: C,
1357
- UsermavenClient: S,
1388
+ typeof module < "u" && module.exports && !te() && (module.exports = {
1389
+ usermavenClient: I,
1390
+ UsermavenClient: N,
1358
1391
  Config: void 0,
1359
1392
  UserProps: void 0,
1360
1393
  EventPayload: void 0,
1361
- LogLevel: p,
1394
+ LogLevel: k,
1362
1395
  ClientProperties: void 0
1363
1396
  });
1364
1397
 
1365
1398
  function createClient(params) {
1366
- return C(params);
1399
+ return I(params);
1367
1400
  }
1368
1401
 
1369
1402
  function useUsermaven() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/react",
3
- "version": "1.5.8-rc.103",
3
+ "version": "1.5.8-rc.104",
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-rc.103"
21
+ "@usermaven/sdk-js": "1.5.8-rc.104"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "15.x || 16.x || 17.x || 18.x || 19.x",