@usermaven/react 1.5.10-rc.112 → 1.5.10-rc.116

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 -268
  2. package/package.json +2 -2
package/lib/index.es.js CHANGED
@@ -8,7 +8,7 @@ const UsermavenProvider = ({ children, client }) => {
8
8
  return React.createElement(Context.Provider, { value: client }, children);
9
9
  };
10
10
 
11
- var k = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(k || {});
11
+ var _ = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(_ || {});
12
12
  class se {
13
13
  constructor(e) {
14
14
  this.level = e;
@@ -26,11 +26,11 @@ class se {
26
26
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
27
27
  }
28
28
  }
29
- function g(s = 0) {
29
+ function p(s = 0) {
30
30
  return new se(s);
31
31
  }
32
- const Z = {
33
- logLevel: k.ERROR,
32
+ const Y = {
33
+ logLevel: _.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
36
36
  trackingHost: "t.usermaven.com",
@@ -68,8 +68,8 @@ class ne {
68
68
  set(e, t, i = 365, n = !0, r = !1) {
69
69
  const o = /* @__PURE__ */ new Date();
70
70
  o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
71
- const a = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", c = r ? "; HttpOnly" : "";
72
- document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
71
+ const a = `expires=${o.toUTCString()}`, c = n ? "; Secure" : "", h = r ? "; HttpOnly" : "";
72
+ document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${c}${h}`;
73
73
  }
74
74
  get(e) {
75
75
  const t = e + "=", i = document.cookie.split(";");
@@ -110,35 +110,35 @@ class ne {
110
110
  return i ? i[0] : "";
111
111
  }
112
112
  }
113
- const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, T = ae.forEach, U = {};
113
+ const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, I = ae.forEach, F = {};
114
114
  function ce(s, e, t) {
115
115
  if (Array.isArray(s)) {
116
- if (T && s.forEach === T)
116
+ if (I && s.forEach === I)
117
117
  s.forEach(e, t);
118
118
  else if ("length" in s && s.length === +s.length) {
119
119
  for (let i = 0, n = s.length; i < n; i++)
120
- if (i in s && e.call(t, s[i], i) === U)
120
+ if (i in s && e.call(t, s[i], i) === F)
121
121
  return;
122
122
  }
123
123
  }
124
124
  }
125
- const B = function(s) {
125
+ const v = function(s) {
126
126
  return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
127
127
  }, le = function(s) {
128
128
  for (const e in s)
129
129
  typeof s[e] == "function" && (s[e] = s[e].bind(s));
130
130
  };
131
- function w(s, e, t) {
131
+ function k(s, e, t) {
132
132
  if (s != null) {
133
- if (T && Array.isArray(s) && s.forEach === T)
133
+ if (I && Array.isArray(s) && s.forEach === I)
134
134
  s.forEach(e, t);
135
135
  else if ("length" in s && s.length === +s.length) {
136
136
  for (let i = 0, n = s.length; i < n; i++)
137
- if (i in s && e.call(t, s[i], i) === U)
137
+ if (i in s && e.call(t, s[i], i) === F)
138
138
  return;
139
139
  } else
140
140
  for (const i in s)
141
- if (oe.call(s, i) && e.call(t, s[i], i) === U)
141
+ if (oe.call(s, i) && e.call(t, s[i], i) === F)
142
142
  return;
143
143
  }
144
144
  }
@@ -148,7 +148,7 @@ const ue = function(s, ...e) {
148
148
  t[i] !== void 0 && (s[i] = t[i]);
149
149
  }), s;
150
150
  };
151
- function A(s, e) {
151
+ function $(s, e) {
152
152
  return s.indexOf(e) !== -1;
153
153
  }
154
154
  const he = function(s) {
@@ -159,27 +159,27 @@ const he = function(s) {
159
159
  }
160
160
  }, de = function(s) {
161
161
  return s === void 0;
162
- }, E = function() {
162
+ }, A = function() {
163
163
  const s = function(i, n, r, o, a) {
164
164
  if (!i) {
165
- g().error("No valid element provided to register_event");
165
+ p().error("No valid element provided to register_event");
166
166
  return;
167
167
  }
168
168
  if (i.addEventListener && !o)
169
169
  i.addEventListener(n, r, !!a);
170
170
  else {
171
- const l = "on" + n, c = i[l];
172
- i[l] = e(i, r, c);
171
+ const c = "on" + n, h = i[c];
172
+ i[c] = e(i, r, h);
173
173
  }
174
174
  };
175
175
  function e(i, n, r) {
176
176
  return function(o) {
177
177
  if (o = o || t(window.event), !o)
178
178
  return;
179
- let a = !0, l;
180
- he(r) && (l = r(o));
181
- const c = n.call(i, o);
182
- return (l === !1 || c === !1) && (a = !1), a;
179
+ let a = !0, c;
180
+ he(r) && (c = r(o));
181
+ const h = n.call(i, o);
182
+ return (c === !1 || h === !1) && (a = !1), a;
183
183
  };
184
184
  }
185
185
  function t(i) {
@@ -190,53 +190,53 @@ const he = function(s) {
190
190
  }, t.stopPropagation = function() {
191
191
  this.cancelBubble = !0;
192
192
  }, s;
193
- }(), ge = function(s) {
193
+ }(), fe = function(s) {
194
194
  return function(...e) {
195
195
  try {
196
196
  return s.apply(this, e);
197
197
  } catch (t) {
198
- g().error(
198
+ p().error(
199
199
  "Implementation error. Please turn on debug and contact support@usermaven.com.",
200
200
  t
201
201
  );
202
202
  }
203
203
  };
204
- }, Y = function(s) {
204
+ }, G = function(s) {
205
205
  for (const e in s)
206
- typeof s[e] == "function" && (s[e] = ge(s[e]));
206
+ typeof s[e] == "function" && (s[e] = fe(s[e]));
207
207
  };
208
- function M(s) {
208
+ function V(s) {
209
209
  for (let e in s)
210
210
  (s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
211
211
  return s;
212
212
  }
213
- function h() {
213
+ function d() {
214
214
  try {
215
215
  return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
216
216
  } catch {
217
- return g().warn("window is not available"), !1;
217
+ return p().warn("window is not available"), !1;
218
218
  }
219
219
  }
220
- function v(s = 5) {
220
+ function E(s = 5) {
221
221
  const e = new Uint8Array(s);
222
222
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, s);
223
223
  }
224
- function fe(s) {
224
+ function ge(s) {
225
225
  return s.replace(
226
226
  /([-_][a-z])/g,
227
227
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
228
228
  );
229
229
  }
230
- function F(s) {
231
- return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(F) : Object.keys(s).reduce(
230
+ function Q(s) {
231
+ return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(Q) : Object.keys(s).reduce(
232
232
  (e, t) => {
233
- const i = fe(t);
234
- return e[i] = F(s[t]), e;
233
+ const i = ge(t);
234
+ return e[i] = Q(s[t]), e;
235
235
  },
236
236
  {}
237
237
  );
238
238
  }
239
- function x(s) {
239
+ function O(s) {
240
240
  switch (typeof s.className) {
241
241
  case "string":
242
242
  return s.className;
@@ -246,25 +246,25 @@ function x(s) {
246
246
  return "";
247
247
  }
248
248
  }
249
- function V(s) {
249
+ function J(s) {
250
250
  let e = "";
251
- return q(s) && !ee(s) && s.childNodes && s.childNodes.length && w(s.childNodes, function(t) {
252
- j(t) && t.textContent && (e += B(t.textContent).split(/(\s+)/).filter($).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
253
- }), B(e);
251
+ return z(s) && !ee(s) && s.childNodes && s.childNodes.length && k(s.childNodes, function(t) {
252
+ j(t) && t.textContent && (e += v(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
253
+ }), v(e);
254
254
  }
255
- function G(s) {
255
+ function b(s) {
256
256
  return !!s && s.nodeType === 1;
257
257
  }
258
- function y(s, e) {
258
+ function w(s, e) {
259
259
  return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
260
260
  }
261
261
  function j(s) {
262
262
  return !!s && s.nodeType === 3;
263
263
  }
264
- function Q(s) {
264
+ function q(s) {
265
265
  return !!s && s.nodeType === 11;
266
266
  }
267
- const C = [
267
+ const T = [
268
268
  "a",
269
269
  "button",
270
270
  "form",
@@ -274,34 +274,36 @@ const C = [
274
274
  "label"
275
275
  ];
276
276
  function pe(s, e) {
277
- if (!s || y(s, "html") || !G(s))
277
+ var o, a;
278
+ if (!s || w(s, "html") || !b(s))
278
279
  return !1;
279
280
  let t = s;
280
- for (; t && !y(t, "body"); ) {
281
+ for (; t && !w(t, "body"); ) {
281
282
  if (t.classList && t.classList.contains("um-no-capture"))
282
283
  return !1;
283
- t.parentNode && Q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
284
+ t.parentNode && q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
284
285
  }
285
286
  let i = !1;
286
- for (t = s; t && !y(t, "body"); ) {
287
- if (t.parentNode && Q(t.parentNode)) {
288
- t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
287
+ for (t = s; t && !w(t, "body"); ) {
288
+ if (t.parentNode && q(t.parentNode)) {
289
+ t = t.parentNode.host, t && b(t) && T.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
289
290
  continue;
290
291
  }
291
- const o = t.parentNode;
292
- if (!o) break;
293
- if (C.indexOf(o.tagName.toLowerCase()) > -1)
292
+ const c = t.parentNode;
293
+ if (!c || !b(c)) break;
294
+ if (T.indexOf(c.tagName.toLowerCase()) > -1)
294
295
  i = !0;
295
296
  else {
296
- const a = window.getComputedStyle(o);
297
- a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
297
+ const h = window.getComputedStyle(c);
298
+ h && h.getPropertyValue("cursor") === "pointer" && (i = !0);
298
299
  }
299
- t = o;
300
+ t = c;
300
301
  }
301
302
  const n = window.getComputedStyle(s);
302
303
  if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
303
304
  return !0;
304
- const r = s.tagName.toLowerCase();
305
+ const r = (a = (o = s.tagName) == null ? void 0 : o.toLowerCase) == null ? void 0 : a.call(o);
306
+ if (!r) return !1;
305
307
  switch (r) {
306
308
  case "html":
307
309
  return !1;
@@ -313,16 +315,16 @@ function pe(s, e) {
313
315
  case "textarea":
314
316
  return e.type === "change" || e.type === "click";
315
317
  default:
316
- return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
318
+ return i ? e.type === "click" : e.type === "click" && (T.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
317
319
  }
318
320
  }
319
- function q(s) {
320
- for (let i = s; i.parentNode && !y(i, "body"); i = i.parentNode) {
321
- const n = x(i).split(" ");
322
- if (A(n, "ph-sensitive") || A(n, "ph-no-capture"))
321
+ function z(s) {
322
+ for (let i = s; i.parentNode && !w(i, "body"); i = i.parentNode) {
323
+ const n = O(i).split(" ");
324
+ if ($(n, "ph-sensitive") || $(n, "ph-no-capture"))
323
325
  return !1;
324
326
  }
325
- if (A(x(s).split(" "), "ph-include"))
327
+ if ($(O(s).split(" "), "ph-include"))
326
328
  return !0;
327
329
  const e = s.type || "";
328
330
  if (typeof e == "string")
@@ -337,21 +339,49 @@ function q(s) {
337
339
  }
338
340
  function ee(s) {
339
341
  const e = ["button", "checkbox", "submit", "reset"];
340
- return !!(y(s, "input") && !e.includes(s.type) || y(s, "select") || y(s, "textarea") || s.getAttribute("contenteditable") === "true");
342
+ return !!(w(s, "input") && !e.includes(s.type) || w(s, "select") || w(s, "textarea") || s.getAttribute("contenteditable") === "true");
341
343
  }
342
- function $(s) {
343
- return !(s === null || de(s) || typeof s == "string" && (s = B(s), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
344
+ function H(s) {
345
+ return !(s === null || de(s) || typeof s == "string" && (s = v(s), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
344
346
  }
345
347
  function me(s) {
346
348
  return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
347
349
  }
348
- function R() {
349
- return v(10);
350
+ function ye(s) {
351
+ if (!s)
352
+ return !1;
353
+ const e = s.$el_text;
354
+ if (typeof e == "string" && v(e).length > 0)
355
+ return !0;
356
+ const t = s.classes;
357
+ if (Array.isArray(t) && t.some((n) => v(n).length > 0))
358
+ return !0;
359
+ const i = [
360
+ "attr__id",
361
+ "attr__name",
362
+ "attr__class",
363
+ "attr__aria-label",
364
+ "attr__aria-labelledby",
365
+ "attr__label",
366
+ "attr__href"
367
+ ];
368
+ for (const n of i) {
369
+ const r = s[n];
370
+ if (typeof r == "string" && v(r).length > 0)
371
+ return !0;
372
+ }
373
+ for (const [n, r] of Object.entries(s))
374
+ if (n.startsWith("attr__data-") && typeof r == "string" && v(r).length > 0)
375
+ return !0;
376
+ return !1;
350
377
  }
351
- function J(s) {
378
+ function x() {
379
+ return E(10);
380
+ }
381
+ function W(s) {
352
382
  return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(s).toLowerCase());
353
383
  }
354
- function ye(s, e) {
384
+ function we(s, e) {
355
385
  let t;
356
386
  return function(...i) {
357
387
  const n = () => {
@@ -360,7 +390,7 @@ function ye(s, e) {
360
390
  clearTimeout(t), t = setTimeout(n, e);
361
391
  };
362
392
  }
363
- function we(s) {
393
+ function ke(s) {
364
394
  const e = {}, t = s.replace(/^\?/, "").split("&");
365
395
  for (let i = 0; i < t.length; i++) {
366
396
  const n = t[i].split("=");
@@ -368,25 +398,25 @@ function we(s) {
368
398
  }
369
399
  return e;
370
400
  }
371
- function L(s) {
401
+ function U(s) {
372
402
  return typeof s == "string" || s instanceof String;
373
403
  }
374
- function P(s) {
404
+ function S(s) {
375
405
  return s !== null && typeof s == "object" && s.constructor === Object;
376
406
  }
377
- function ke(s) {
407
+ function ve(s) {
378
408
  if (s === null)
379
- return k.ERROR;
380
- const e = s.toUpperCase(), t = k[e];
381
- return t || t === 0 ? t : k.ERROR;
409
+ return _.ERROR;
410
+ const e = s.toUpperCase(), t = _[e];
411
+ return t || t === 0 ? t : _.ERROR;
382
412
  }
383
- const ve = () => {
413
+ const be = () => {
384
414
  let s = "false";
385
415
  return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
386
416
  };
387
- class be {
417
+ class _e {
388
418
  constructor(e) {
389
- 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();
419
+ this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = we(this.handleScroll.bind(this), 250), this.initializeEventListener();
390
420
  }
391
421
  initializeEventListener() {
392
422
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -440,9 +470,9 @@ class be {
440
470
  window.removeEventListener("scroll", this.debouncedHandleScroll);
441
471
  }
442
472
  }
443
- const N = class N {
444
- constructor(e, t, i = g()) {
445
- this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new be(e), le(this), Y(this);
473
+ const D = class D {
474
+ constructor(e, t, i = p()) {
475
+ this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), le(this), G(this);
446
476
  }
447
477
  isBrowserSupported() {
448
478
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -468,7 +498,7 @@ const N = class N {
468
498
  const e = (t) => {
469
499
  t = t || window.event, this.captureEvent(t);
470
500
  };
471
- 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);
501
+ A(document, "submit", e, !1, !0), A(document, "change", e, !1, !0), A(document, "click", e, !1, !0), A(document, "visibilitychange", e, !1, !0), A(document, "scroll", e, !1, !0), A(window, "popstate", e, !1, !0);
472
502
  }
473
503
  isPageRefresh() {
474
504
  if ("PerformanceNavigationTiming" in window) {
@@ -485,59 +515,66 @@ const N = class N {
485
515
  return (i = this.scrollDepth) == null || i.track(), !0;
486
516
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
487
517
  return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
488
- if (t && pe(t, e)) {
518
+ if (!(!t || !b(t)) && t && pe(t, e)) {
489
519
  const r = [t];
490
520
  let o = t;
491
- for (; o.parentNode && !y(o, "body"); ) {
492
- if (Q(o.parentNode)) {
493
- r.push(o.parentNode.host), o = o.parentNode.host;
521
+ for (; o != null && o.parentNode && !w(o, "body"); ) {
522
+ if (q(o == null ? void 0 : o.parentNode)) {
523
+ const g = (o == null ? void 0 : o.parentNode).host;
524
+ g && b(g) && r.push(g), o = g;
494
525
  continue;
495
526
  }
496
- r.push(o.parentNode), o = o.parentNode;
527
+ const l = o == null ? void 0 : o.parentNode;
528
+ if (!l || !b(l)) break;
529
+ r.push(l), o = l;
497
530
  }
498
531
  const a = [];
499
- let l, c = !1;
500
- if (w(r, (p) => {
501
- const b = q(p);
502
- p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = b && $(l) && l);
503
- const u = x(p).split(" ");
504
- A(u, "ph-no-capture") && (c = !0), a.push(
532
+ let c, h = !1;
533
+ if (k(r, (l) => {
534
+ if (!l.tagName)
535
+ return;
536
+ const g = z(l);
537
+ l.tagName.toLowerCase() === "a" && (c = l.getAttribute("href"), c = g && H(c) && c);
538
+ const u = O(l).split(" ");
539
+ $(u, "ph-no-capture") && (h = !0), a.push(
505
540
  this.getPropertiesFromElement(
506
- p,
541
+ l,
507
542
  this.options.maskAllElementAttributes ?? !1,
508
543
  this.options.maskAllText ?? !1
509
544
  )
510
545
  );
511
- }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
546
+ }), this.options.maskAllText || (a[0].$el_text = J(t)), c && (a[0].attr__href = c), h)
512
547
  return !1;
513
- const d = ue(
548
+ if (!ye(a[0]))
549
+ return this.logger.debug("Dropping autocapture event without identifiers."), !1;
550
+ const f = ue(
514
551
  this.getDefaultProperties(e.type),
515
552
  {
516
553
  $elements: a
517
554
  },
518
555
  this.getCustomProperties(r)
519
556
  );
520
- return this.client.track("$autocapture", d), !0;
557
+ return this.client.track("$autocapture", f), !0;
521
558
  }
522
559
  }
523
560
  getCustomProperties(e) {
524
561
  const t = {};
525
- return w(this.customProperties, (i) => {
526
- w(i.event_selectors, (n) => {
562
+ return k(this.customProperties, (i) => {
563
+ k(i.event_selectors, (n) => {
527
564
  const r = document.querySelectorAll(n);
528
- w(r, (o) => {
529
- A(e, o) && q(o) && (t[i.name] = this.extractCustomPropertyValue(i));
565
+ k(r, (o) => {
566
+ $(e, o) && z(o) && (t[i.name] = this.extractCustomPropertyValue(i));
530
567
  });
531
568
  });
532
569
  }), t;
533
570
  }
534
571
  extractCustomPropertyValue(e) {
535
572
  const t = [];
536
- return w(
573
+ return k(
537
574
  document.querySelectorAll(e.css_selector),
538
575
  function(i) {
539
576
  let n;
540
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), $(n) && t.push(n);
577
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), H(n) && t.push(n);
541
578
  }
542
579
  ), t.join(", ");
543
580
  }
@@ -549,17 +586,17 @@ const N = class N {
549
586
  const n = e.tagName.toLowerCase(), r = {
550
587
  tag_name: n
551
588
  };
552
- C.indexOf(n) > -1 && !i && (r.$el_text = V(e));
553
- const o = x(e);
554
- o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
555
- return d !== "";
556
- })), w(e.attributes, function(d) {
557
- ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && $(d.value) && !me(d.name) && (r["attr__" + d.name] = d.value);
589
+ T.indexOf(n) > -1 && !i && (r.$el_text = J(e));
590
+ const o = O(e);
591
+ o.length > 0 && (r.classes = o.split(" ").filter(function(f) {
592
+ return f !== "";
593
+ })), k(e.attributes, function(f) {
594
+ ee(e) && ["name", "id", "class"].indexOf(f.name) === -1 || !t && H(f.value) && !me(f.name) && (r["attr__" + f.name] = f.value);
558
595
  });
559
- let a = 1, l = 1, c = e;
560
- for (; c = this.previousElementSibling(c); )
561
- a++, c.tagName === e.tagName && l++;
562
- return r.nth_child = a, r.nth_of_type = l, r;
596
+ let a = 1, c = 1, h = e;
597
+ for (; h = this.previousElementSibling(h); )
598
+ a++, h.tagName === e.tagName && c++;
599
+ return r.nth_child = a, r.nth_of_type = c, r;
563
600
  }
564
601
  previousElementSibling(e) {
565
602
  if (e.previousElementSibling)
@@ -568,7 +605,7 @@ const N = class N {
568
605
  let t = e;
569
606
  do
570
607
  t = t.previousSibling;
571
- while (t && !G(t));
608
+ while (t && !b(t));
572
609
  return t;
573
610
  }
574
611
  }
@@ -590,9 +627,9 @@ const N = class N {
590
627
  return n % t < i;
591
628
  }
592
629
  };
593
- N.FORCE_CAPTURE_ATTR = "data-um-force-capture", N.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
594
- let H = N;
595
- class _e {
630
+ D.FORCE_CAPTURE_ATTR = "data-um-force-capture", D.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
631
+ let N = D;
632
+ class Ee {
596
633
  constructor(e) {
597
634
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
598
635
  }
@@ -621,8 +658,8 @@ class _e {
621
658
  }));
622
659
  }
623
660
  }
624
- class Ee {
625
- constructor(e, t, i = g()) {
661
+ class Pe {
662
+ constructor(e, t, i = p()) {
626
663
  this.trackingHost = e, this.logger = i, this.config = t;
627
664
  }
628
665
  async send(e) {
@@ -637,14 +674,14 @@ class Ee {
637
674
  throw new Error("Failed to queue events via Beacon API");
638
675
  }
639
676
  constructUrl(e) {
640
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
641
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
677
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
678
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
642
679
  }
643
680
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
644
681
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
645
682
  }
646
- class W {
647
- constructor(e, t, i = g()) {
683
+ class K {
684
+ constructor(e, t, i = p()) {
648
685
  this.trackingHost = e, this.logger = i, this.config = t;
649
686
  }
650
687
  async send(e) {
@@ -661,8 +698,8 @@ class W {
661
698
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
662
699
  }
663
700
  constructUrl(e) {
664
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
665
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
701
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
702
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
666
703
  }
667
704
  getCustomHeaders() {
668
705
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -671,8 +708,8 @@ class W {
671
708
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
672
709
  }
673
710
  }
674
- class Pe {
675
- constructor(e, t, i = g()) {
711
+ class Ae {
712
+ constructor(e, t, i = p()) {
676
713
  this.trackingHost = e, this.logger = i, this.config = t;
677
714
  }
678
715
  send(e) {
@@ -680,8 +717,8 @@ class Pe {
680
717
  const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
681
718
  n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
682
719
  const a = this.getCustomHeaders();
683
- Object.keys(a).forEach((l) => {
684
- n.setRequestHeader(l, a[l]);
720
+ Object.keys(a).forEach((c) => {
721
+ n.setRequestHeader(c, a[c]);
685
722
  }), n.onload = () => {
686
723
  n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${n.status}`));
687
724
  }, n.onerror = () => {
@@ -690,8 +727,8 @@ class Pe {
690
727
  });
691
728
  }
692
729
  constructUrl(e) {
693
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
694
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
730
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
731
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
695
732
  }
696
733
  getCustomHeaders() {
697
734
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -702,7 +739,7 @@ class Pe {
702
739
  }
703
740
  class te {
704
741
  constructor(e, t) {
705
- this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || g(), this.load();
742
+ this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || p(), this.load();
706
743
  }
707
744
  set(e, t) {
708
745
  this.storage[e] = t, this.save();
@@ -720,7 +757,7 @@ class te {
720
757
  return !this.storageDisabled;
721
758
  }
722
759
  load() {
723
- if (!h()) {
760
+ if (!d()) {
724
761
  this.logger.warn("localStorage is not available in this environment");
725
762
  return;
726
763
  }
@@ -732,7 +769,7 @@ class te {
732
769
  }
733
770
  }
734
771
  save() {
735
- if (!h())
772
+ if (!d())
736
773
  return this.logger.warn("localStorage is not available in this environment"), !1;
737
774
  if (this.storageDisabled)
738
775
  return !1;
@@ -772,11 +809,11 @@ class Se {
772
809
  this.storage = {};
773
810
  }
774
811
  }
775
- class K {
776
- constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = g(), a = "default", l = 1e3, c = 25e5) {
812
+ class X {
813
+ constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = p(), a = "default", c = 1e3, h = 25e5) {
777
814
  this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.totalQueueBytes = 0, this.persistence = new te(
778
815
  `offline_queue_${a}`
779
- ), this.maxQueueItems = l, this.maxQueueBytes = c, h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
816
+ ), this.maxQueueItems = c, this.maxQueueBytes = h, d() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
780
817
  }
781
818
  add(e) {
782
819
  const t = {
@@ -784,23 +821,23 @@ class K {
784
821
  retries: 0,
785
822
  timestamp: Date.now()
786
823
  };
787
- t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), h() ? this.saveQueueToStorage() : this.processBatch();
824
+ t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), d() ? this.saveQueueToStorage() : this.processBatch();
788
825
  }
789
826
  initNetworkListeners() {
790
- h() && (window.addEventListener("online", () => {
827
+ d() && (window.addEventListener("online", () => {
791
828
  this.isOnline = !0, this.processBatch();
792
829
  }), window.addEventListener("offline", () => {
793
830
  this.isOnline = !1;
794
831
  }));
795
832
  }
796
833
  scheduleBatch() {
797
- h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
834
+ d() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
798
835
  () => this.processBatch(),
799
836
  this.batchInterval
800
837
  ));
801
838
  }
802
839
  async processBatch() {
803
- if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
840
+ if ((!d() || this.isOnline) && !this.processing && this.queue.length > 0) {
804
841
  this.processing = !0;
805
842
  const e = this.queue.splice(0, this.batchSize);
806
843
  this.totalQueueBytes = Math.max(
@@ -811,13 +848,13 @@ class K {
811
848
  try {
812
849
  await this.transport.send(t), this.logger.debug(
813
850
  `Successfully sent batch of ${e.length} payloads`
814
- ), h() && this.saveQueueToStorage();
851
+ ), d() && this.saveQueueToStorage();
815
852
  } catch (i) {
816
853
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
817
854
  }
818
855
  this.processing = !1;
819
856
  }
820
- h() && this.scheduleBatch();
857
+ d() && this.scheduleBatch();
821
858
  }
822
859
  async handleBatchFailure(e) {
823
860
  for (const t of e)
@@ -825,7 +862,7 @@ class K {
825
862
  "Max retries reached, discarding payload",
826
863
  t.payload
827
864
  );
828
- h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
865
+ d() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
829
866
  }
830
867
  enforceQueueLimits() {
831
868
  if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
@@ -858,7 +895,7 @@ class K {
858
895
  }
859
896
  }
860
897
  loadQueueFromStorage() {
861
- if (h()) {
898
+ if (d()) {
862
899
  const e = this.persistence.get("queue");
863
900
  if (!e) return;
864
901
  try {
@@ -876,15 +913,15 @@ class K {
876
913
  }
877
914
  }
878
915
  saveQueueToStorage() {
879
- if (h()) {
916
+ if (d()) {
880
917
  const e = this.queue.map(({ bytes: t, ...i }) => i);
881
918
  this.persistence.set("queue", JSON.stringify(e));
882
919
  }
883
920
  }
884
921
  }
885
- class Ae {
922
+ class Ce {
886
923
  constructor(e) {
887
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
924
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), G(this);
888
925
  }
889
926
  initializeEventListener() {
890
927
  document.addEventListener("click", this.handleClick.bind(this));
@@ -920,8 +957,8 @@ class Ae {
920
957
  }), this.clicks = [];
921
958
  }
922
959
  }
923
- class Ce {
924
- constructor(e, t, i = g()) {
960
+ class $e {
961
+ constructor(e, t, i = p()) {
925
962
  this.trackingHost = e, this.logger = i, this.config = t;
926
963
  }
927
964
  async send(e) {
@@ -936,15 +973,15 @@ class Ce {
936
973
  }
937
974
  };
938
975
  return new Promise((r, o) => {
939
- const a = (void 0)(n, (l) => {
940
- l.on("data", (c) => {
941
- }), l.on("end", () => {
942
- const c = l.statusCode || 0;
943
- c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
976
+ const a = (void 0)(n, (c) => {
977
+ c.on("data", (h) => {
978
+ }), c.on("end", () => {
979
+ const h = c.statusCode || 0;
980
+ h >= 200 && h < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${h}`));
944
981
  });
945
982
  });
946
- a.on("error", (l) => {
947
- o(l);
983
+ a.on("error", (c) => {
984
+ o(c);
948
985
  }), a.write(JSON.stringify(e)), a.end();
949
986
  });
950
987
  }
@@ -956,7 +993,7 @@ class Ce {
956
993
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
957
994
  }
958
995
  }
959
- class S {
996
+ class C {
960
997
  constructor(e, t = "all", i = {}) {
961
998
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
962
999
  }
@@ -971,7 +1008,7 @@ class S {
971
1008
  }
972
1009
  handleFormSubmit(e) {
973
1010
  const t = e.target, i = this._getFormDetails(t);
974
- this.instance.track("$form", M(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
1011
+ this.instance.track("$form", V(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
975
1012
  }
976
1013
  trackFieldChanges(e) {
977
1014
  e.querySelectorAll("input, select, textarea").forEach((i) => {
@@ -981,7 +1018,7 @@ class S {
981
1018
  );
982
1019
  this.instance.track(
983
1020
  "$form_field_change",
984
- M({
1021
+ V({
985
1022
  form_id: e.id,
986
1023
  form_name: e.name || "",
987
1024
  field: r
@@ -991,7 +1028,7 @@ class S {
991
1028
  });
992
1029
  }
993
1030
  static getInstance(e, t = "all", i = {}) {
994
- return S.instance || (S.instance = new S(e, t, i)), S.instance;
1031
+ return C.instance || (C.instance = new C(e, t, i)), C.instance;
995
1032
  }
996
1033
  _getFormDetails(e) {
997
1034
  const t = {
@@ -1092,9 +1129,9 @@ class S {
1092
1129
  return e.slice(t, i + 1);
1093
1130
  }
1094
1131
  }
1095
- class I {
1132
+ class R {
1096
1133
  constructor(e) {
1097
- this.config = this.mergeConfig(e, Z), this.logger = g(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new K(
1134
+ this.config = this.mergeConfig(e, Y), this.logger = p(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new X(
1098
1135
  this.transport,
1099
1136
  this.config.maxSendAttempts || 3,
1100
1137
  this.config.minSendTimeout || 1e3,
@@ -1103,14 +1140,14 @@ class I {
1103
1140
  // Reduced interval to .2 second
1104
1141
  this.logger,
1105
1142
  this.namespace
1106
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1143
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1107
1144
  `Usermaven client initialized for namespace: ${this.namespace}`
1108
1145
  );
1109
1146
  }
1110
1147
  initializeBrowserFeatures() {
1111
- 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) {
1148
+ if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && N.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new N(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
1112
1149
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
1113
- this.formTracking = S.getInstance(
1150
+ this.formTracking = C.getInstance(
1114
1151
  this,
1115
1152
  e || "none",
1116
1153
  {
@@ -1118,7 +1155,7 @@ class I {
1118
1155
  }
1119
1156
  );
1120
1157
  }
1121
- this.config.autoPageview && (this.pageviewTracking = new _e(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ae(this)), this.setupPageLeaveTracking();
1158
+ this.config.autoPageview && (this.pageviewTracking = new Ee(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ce(this)), this.setupPageLeaveTracking();
1122
1159
  }
1123
1160
  /**
1124
1161
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -1129,11 +1166,11 @@ class I {
1129
1166
  const i = JSON.parse(JSON.stringify(e));
1130
1167
  let n = { ...t, ...i };
1131
1168
  return Object.keys(t).forEach((r) => {
1132
- P(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
1169
+ S(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
1133
1170
  }), n;
1134
1171
  }
1135
1172
  init(e) {
1136
- this.config = { ...this.config, ...e }, this.logger = g(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new K(
1173
+ this.config = { ...this.config, ...e }, this.logger = p(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new X(
1137
1174
  this.transport,
1138
1175
  this.config.maxSendAttempts || 3,
1139
1176
  this.config.minSendTimeout || 1e3,
@@ -1142,7 +1179,7 @@ class I {
1142
1179
  // Reduced interval to .25 second
1143
1180
  this.logger,
1144
1181
  this.namespace
1145
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1182
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1146
1183
  `Usermaven client reinitialized for namespace: ${this.namespace}`
1147
1184
  );
1148
1185
  }
@@ -1158,8 +1195,8 @@ class I {
1158
1195
  if (!r || !r.startsWith("http")) return;
1159
1196
  const o = new URL(r);
1160
1197
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1161
- const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
1162
- l && (o.searchParams.append("_um", l), n.setAttribute("href", o.toString()));
1198
+ const c = (a = this.cookieManager) == null ? void 0 : a.get(t);
1199
+ c && (o.searchParams.append("_um", c), n.setAttribute("href", o.toString()));
1163
1200
  }
1164
1201
  }), this.logger.debug("Cross-domain linking initialized");
1165
1202
  }
@@ -1170,29 +1207,29 @@ class I {
1170
1207
  }
1171
1208
  initializeTransport(e) {
1172
1209
  const t = "https://events.usermaven.com";
1173
- if (!h())
1174
- return new Ce(e.trackingHost || t, e);
1210
+ if (!d())
1211
+ return new $e(e.trackingHost || t, e);
1175
1212
  const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1176
1213
  if (e.useBeaconApi && r)
1177
- return new Ee(
1214
+ return new Pe(
1178
1215
  e.trackingHost || t,
1179
1216
  e,
1180
1217
  this.logger
1181
1218
  );
1182
1219
  if (e.forceUseFetch && n)
1183
- return new W(
1220
+ return new K(
1184
1221
  e.trackingHost || t,
1185
1222
  e,
1186
1223
  this.logger
1187
1224
  );
1188
1225
  if (i)
1189
- return new Pe(
1226
+ return new Ae(
1190
1227
  e.trackingHost || t,
1191
1228
  e,
1192
1229
  this.logger
1193
1230
  );
1194
1231
  if (n)
1195
- return new W(
1232
+ return new K(
1196
1233
  e.trackingHost || t,
1197
1234
  e,
1198
1235
  this.logger
@@ -1200,25 +1237,25 @@ class I {
1200
1237
  throw new Error("No suitable transport method available");
1201
1238
  }
1202
1239
  initializePersistence() {
1203
- return this.config.disableEventPersistence || !h() ? new Se() : new te(
1240
+ return this.config.disableEventPersistence || !d() ? new Se() : new te(
1204
1241
  `${this.namespace}_${this.config.key}`,
1205
1242
  this.logger
1206
1243
  );
1207
1244
  }
1208
1245
  getOrCreateAnonymousId() {
1209
1246
  var i, n;
1210
- if (!h())
1211
- return R();
1247
+ if (!d())
1248
+ return x();
1212
1249
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1213
1250
  return "";
1214
1251
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1215
1252
  let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1216
1253
  if (!t) {
1217
1254
  if (this.config.crossDomainLinking) {
1218
- const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
1219
- t = a || d || R();
1255
+ const a = new URLSearchParams(window.location.search).get("_um"), h = window.location.hash.substring(1).split("~"), f = h.length > 1 ? h[1] : void 0;
1256
+ t = a || f || x();
1220
1257
  }
1221
- t || (t = R());
1258
+ t || (t = x());
1222
1259
  const r = 365 * 10;
1223
1260
  (n = this.cookieManager) == null || n.set(
1224
1261
  e,
@@ -1231,11 +1268,11 @@ class I {
1231
1268
  return t;
1232
1269
  }
1233
1270
  async id(e, t = !1) {
1234
- if (!P(e))
1271
+ if (!S(e))
1235
1272
  throw new Error("User data must be an object");
1236
- if (e.email && !J(e.email))
1273
+ if (e.email && !W(e.email))
1237
1274
  throw new Error("Invalid email provided");
1238
- if (!e.id || !L(e.id))
1275
+ if (!e.id || !U(e.id))
1239
1276
  throw new Error("User ID must be a string");
1240
1277
  const i = e.id;
1241
1278
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1251,28 +1288,28 @@ class I {
1251
1288
  this.trackInternal(e, t, i);
1252
1289
  }
1253
1290
  lead(e, t = !1) {
1254
- if (!P(e))
1291
+ if (!S(e))
1255
1292
  throw new Error(
1256
1293
  "Lead payload must be a non-null object and not an array"
1257
1294
  );
1258
1295
  const i = e.email;
1259
- if (!L(i)) {
1296
+ if (!U(i)) {
1260
1297
  this.logger.error("Lead event requires a valid email attribute");
1261
1298
  return;
1262
1299
  }
1263
1300
  const n = i.trim();
1264
- if (!n || !J(n)) {
1301
+ if (!n || !W(n)) {
1265
1302
  this.logger.error("Lead event requires a valid email attribute");
1266
1303
  return;
1267
1304
  }
1268
1305
  e.email = n, this.track("lead", e, t);
1269
1306
  }
1270
1307
  trackInternal(e, t, i = !1) {
1271
- if (ve()) {
1308
+ if (be()) {
1272
1309
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1273
1310
  return;
1274
1311
  }
1275
- if (!L(e))
1312
+ if (!U(e))
1276
1313
  throw new Error("Event name must be a string");
1277
1314
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1278
1315
  throw new Error(
@@ -1290,12 +1327,12 @@ class I {
1290
1327
  }
1291
1328
  }
1292
1329
  rawTrack(e) {
1293
- if (!P(e))
1330
+ if (!S(e))
1294
1331
  throw new Error("Event payload must be an object");
1295
1332
  this.track("raw", e);
1296
1333
  }
1297
1334
  async group(e, t = !1) {
1298
- if (!P(e))
1335
+ if (!S(e))
1299
1336
  throw new Error("Company properties must be an object");
1300
1337
  if (!e.id || !e.name || !e.created_at)
1301
1338
  throw new Error(
@@ -1304,16 +1341,16 @@ class I {
1304
1341
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1305
1342
  }
1306
1343
  createEventPayload(e, t) {
1307
- const i = this.persistence.get("userProps") || {}, n = 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}`) || {};
1308
- let l = t || {};
1309
- const c = {
1310
- event_id: "",
1344
+ const { event_id: i, ...n } = t || {}, r = this.persistence.get("userProps") || {}, o = this.persistence.get("companyProps") || (r == null ? void 0 : r.company) || {}, a = this.persistence.get("userId"), c = this.persistence.get("global_props") || {}, h = this.persistence.get(`props_${e}`) || {};
1345
+ let f = n;
1346
+ const l = {
1347
+ event_id: i || x(),
1311
1348
  user: {
1312
1349
  anonymous_id: this.anonymousId,
1313
- id: r,
1314
- ...i
1350
+ id: a,
1351
+ ...r
1315
1352
  },
1316
- ...n && { company: n },
1353
+ ...o && { company: o },
1317
1354
  ids: this.getThirdPartyIds(),
1318
1355
  utc_time: (/* @__PURE__ */ new Date()).toISOString(),
1319
1356
  local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
@@ -1321,18 +1358,18 @@ class I {
1321
1358
  src: "usermaven",
1322
1359
  event_type: e,
1323
1360
  namespace: this.namespace,
1324
- ...o,
1325
- ...a
1361
+ ...c,
1362
+ ...h
1326
1363
  };
1327
1364
  if (e === "$autocapture") {
1328
- const d = this.processAutocaptureAttributes(
1365
+ const g = this.processAutocaptureAttributes(
1329
1366
  t || {}
1330
1367
  );
1331
- c.autocapture_attributes = d;
1332
- } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1333
- delete l[d];
1334
- }), c.event_attributes = l);
1335
- 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;
1368
+ l.autocapture_attributes = g;
1369
+ } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((g) => {
1370
+ delete f[g];
1371
+ }), l.event_attributes = f);
1372
+ return d() && (l.referer = document.referrer, l.url = window.location.href, l.page_title = document.title, l.doc_path = window.location.pathname, l.doc_host = window.location.hostname, l.doc_search = window.location.search, l.screen_resolution = `${window.screen.width}x${window.screen.height}`, l.vp_size = `${window.innerWidth}x${window.innerHeight}`, l.user_agent = navigator.userAgent, l.user_language = navigator.language, l.doc_encoding = document.characterSet, l.utm = this.getUtmParams()), l;
1336
1373
  }
1337
1374
  processAutocaptureAttributes(e) {
1338
1375
  let t = {};
@@ -1355,14 +1392,14 @@ class I {
1355
1392
  }
1356
1393
  getThirdPartyIds() {
1357
1394
  const e = {};
1358
- if (h()) {
1395
+ if (d()) {
1359
1396
  const t = this.getCookie("_fbp");
1360
1397
  t && (e.fbp = t);
1361
1398
  }
1362
1399
  return e;
1363
1400
  }
1364
1401
  getUtmParams() {
1365
- const e = {}, t = we(window.location.search);
1402
+ const e = {}, t = ke(window.location.search);
1366
1403
  return [
1367
1404
  "utm_source",
1368
1405
  "utm_medium",
@@ -1374,7 +1411,7 @@ class I {
1374
1411
  }), e;
1375
1412
  }
1376
1413
  pageview() {
1377
- h() ? this.track(
1414
+ d() ? this.track(
1378
1415
  "pageview",
1379
1416
  {
1380
1417
  url: window.location.href,
@@ -1387,7 +1424,7 @@ class I {
1387
1424
  );
1388
1425
  }
1389
1426
  setupPageLeaveTracking() {
1390
- if (!h()) return;
1427
+ if (!d()) return;
1391
1428
  let e = !1, t = !1;
1392
1429
  const i = () => {
1393
1430
  !e && !t && (e = !0, this.track("$pageleave", {
@@ -1425,7 +1462,7 @@ class I {
1425
1462
  });
1426
1463
  }
1427
1464
  set(e, t) {
1428
- if (!P(e))
1465
+ if (!S(e))
1429
1466
  throw new Error("Properties must be an object");
1430
1467
  const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1431
1468
  if (i) {
@@ -1464,13 +1501,13 @@ class I {
1464
1501
  function ie() {
1465
1502
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1466
1503
  }
1467
- function $e() {
1504
+ function xe() {
1468
1505
  return ie() ? window.define : void 0;
1469
1506
  }
1470
1507
  const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1471
- function O(s) {
1472
- const e = JSON.parse(JSON.stringify(s)), t = F(e), i = {
1473
- ...Z,
1508
+ function L(s) {
1509
+ const e = JSON.parse(JSON.stringify(s)), t = Q(e), i = {
1510
+ ...Y,
1474
1511
  ...t
1475
1512
  };
1476
1513
  if (!i.key)
@@ -1478,16 +1515,16 @@ function O(s) {
1478
1515
  if (!i.trackingHost)
1479
1516
  throw new Error("Tracking host is required!");
1480
1517
  const n = i.key || "", r = `${Te}${n}`;
1481
- return h() && i.autocapture && window[r] && (console.warn(
1518
+ return d() && i.autocapture && window[r] && (console.warn(
1482
1519
  "Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
1483
- ), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new I(i);
1520
+ ), i.disableAutocaptureListenerRegistration = !0), d() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new R(i);
1484
1521
  }
1485
- function xe(s) {
1522
+ function He(s) {
1486
1523
  var n;
1487
1524
  const e = {
1488
1525
  key: s.getAttribute("data-key") || void 0,
1489
1526
  trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1490
- logLevel: ke(s.getAttribute("data-log-level")),
1527
+ logLevel: ve(s.getAttribute("data-log-level")),
1491
1528
  autocapture: s.getAttribute("data-autocapture") === "true",
1492
1529
  formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
1493
1530
  autoPageview: s.getAttribute("data-auto-pageview") === "true",
@@ -1517,30 +1554,30 @@ function xe(s) {
1517
1554
  maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
1518
1555
  };
1519
1556
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1520
- const t = O(e), i = e.namespace || "usermaven";
1521
- return h() && t.pageview(), He(i, t), t;
1557
+ const t = L(e), i = e.namespace || "usermaven";
1558
+ return d() && t.pageview(), Ie(i, t), t;
1522
1559
  }
1523
- function He(s, e) {
1560
+ function Ie(s, e) {
1524
1561
  let t = !1;
1525
1562
  const i = [], n = [];
1526
1563
  function r() {
1527
1564
  for (; i.length > 0; ) {
1528
1565
  const u = i.shift();
1529
1566
  if (u) {
1530
- const f = u[u.length - 1];
1531
- if (f && typeof f.resolve == "function") {
1532
- const m = u.pop();
1567
+ const m = u[u.length - 1];
1568
+ if (m && typeof m.resolve == "function") {
1569
+ const y = u.pop();
1533
1570
  try {
1534
- const _ = a.apply(null, u);
1535
- _ && typeof _.then == "function" ? _.then(m.resolve).catch(m.reject) : m.resolve(_);
1536
- } catch (_) {
1537
- m.reject(_);
1571
+ const P = a.apply(null, u);
1572
+ P && typeof P.then == "function" ? P.then(y.resolve).catch(y.reject) : y.resolve(P);
1573
+ } catch (P) {
1574
+ y.reject(P);
1538
1575
  }
1539
1576
  } else
1540
1577
  try {
1541
1578
  a.apply(null, u);
1542
- } catch (m) {
1543
- console.error("Usermaven: Error processing queued command:", m);
1579
+ } catch (y) {
1580
+ console.error("Usermaven: Error processing queued command:", y);
1544
1581
  }
1545
1582
  }
1546
1583
  }
@@ -1549,8 +1586,8 @@ function He(s, e) {
1549
1586
  n.forEach((u) => u()), n.length = 0;
1550
1587
  }
1551
1588
  function a(...u) {
1552
- const f = u[0];
1553
- if (f === "onLoad") {
1589
+ const m = u[0];
1590
+ if (m === "onLoad") {
1554
1591
  typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
1555
1592
  return;
1556
1593
  }
@@ -1558,11 +1595,11 @@ function He(s, e) {
1558
1595
  i.push(u);
1559
1596
  return;
1560
1597
  }
1561
- if (typeof e[f] == "function")
1562
- return e[f].apply(e, u.slice(1));
1563
- console.error(`Method ${f} not found on UsermavenClient`);
1598
+ if (typeof e[m] == "function")
1599
+ return e[m].apply(e, u.slice(1));
1600
+ console.error(`Method ${m} not found on UsermavenClient`);
1564
1601
  }
1565
- const l = ["id", "group", "reset"], c = [
1602
+ const c = ["id", "group", "reset"], h = [
1566
1603
  "track",
1567
1604
  "lead",
1568
1605
  "pageview",
@@ -1571,66 +1608,66 @@ function He(s, e) {
1571
1608
  "rawTrack",
1572
1609
  "setUserId"
1573
1610
  ];
1574
- [...l, ...c].forEach((u) => {
1575
- a[u] = function(...f) {
1611
+ [...c, ...h].forEach((u) => {
1612
+ a[u] = function(...m) {
1576
1613
  if (!t) {
1577
- if (l.includes(u))
1578
- return new Promise((z, m) => {
1579
- i.push([u, ...f, { resolve: z, reject: m }]);
1614
+ if (c.includes(u))
1615
+ return new Promise((M, y) => {
1616
+ i.push([u, ...m, { resolve: M, reject: y }]);
1580
1617
  });
1581
- i.push([u, ...f]);
1618
+ i.push([u, ...m]);
1582
1619
  return;
1583
1620
  }
1584
1621
  if (typeof e[u] == "function")
1585
- return e[u].apply(e, f);
1622
+ return e[u].apply(e, m);
1586
1623
  };
1587
1624
  }), a.getConfig = function() {
1588
1625
  return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
1589
1626
  }, window[s] = a;
1590
- const p = `${s}Q`, b = window[p] || [];
1591
- for (window[p] = b, b.push = function(...u) {
1627
+ const l = `${s}Q`, g = window[l] || [];
1628
+ for (window[l] = g, g.push = function(...u) {
1592
1629
  return a.apply(null, u), Array.prototype.push.apply(this, u);
1593
1630
  }, setTimeout(() => {
1594
1631
  t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
1595
- }, 0); b.length > 0; ) {
1596
- const u = b.shift();
1632
+ }, 0); g.length > 0; ) {
1633
+ const u = g.shift();
1597
1634
  u && i.push(u);
1598
1635
  }
1599
1636
  }
1600
- let X = !1, D = null;
1601
- if (h()) {
1602
- const s = $e();
1637
+ let Z = !1, B = null;
1638
+ if (d()) {
1639
+ const s = xe();
1603
1640
  s && s("usermaven", [], function() {
1604
1641
  return {
1605
- usermavenClient: O,
1606
- UsermavenClient: I,
1607
- LogLevel: k,
1642
+ usermavenClient: L,
1643
+ UsermavenClient: R,
1644
+ LogLevel: _,
1608
1645
  // Expose the script tag client if it exists
1609
- getScriptTagClient: () => D
1646
+ getScriptTagClient: () => B
1610
1647
  };
1611
- }), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = I, window.usermavenScriptTagClient = () => D), function(e, t) {
1648
+ }), typeof window < "u" && (window.usermavenClient = L, window.UsermavenClient = R, window.usermavenScriptTagClient = () => B), function(e, t) {
1612
1649
  const i = e.currentScript;
1613
1650
  function n() {
1614
- return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1651
+ return Z || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1615
1652
  }
1616
1653
  function r() {
1617
- n() && (console.log("[Usermaven] Auto-initializing from script tag"), D = xe(i), X = !0);
1654
+ n() && (console.log("[Usermaven] Auto-initializing from script tag"), B = He(i), Z = !0);
1618
1655
  }
1619
1656
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1620
1657
  }(document, window);
1621
1658
  }
1622
1659
  typeof module < "u" && module.exports && !ie() && (module.exports = {
1623
- usermavenClient: O,
1624
- UsermavenClient: I,
1660
+ usermavenClient: L,
1661
+ UsermavenClient: R,
1625
1662
  Config: void 0,
1626
1663
  UserProps: void 0,
1627
1664
  EventPayload: void 0,
1628
- LogLevel: k,
1665
+ LogLevel: _,
1629
1666
  ClientProperties: void 0
1630
1667
  });
1631
1668
 
1632
1669
  function createClient(params) {
1633
- return O(params);
1670
+ return L(params);
1634
1671
  }
1635
1672
 
1636
1673
  function useUsermaven() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/react",
3
- "version": "1.5.10-rc.112",
3
+ "version": "1.5.10-rc.116",
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.10-rc.112"
21
+ "@usermaven/sdk-js": "1.5.10-rc.116"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "15.x || 16.x || 17.x || 18.x || 19.x",