@usermaven/sdk-js 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.
@@ -1,4 +1,4 @@
1
- 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 || {});
1
+ var _ = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(_ || {});
2
2
  class se {
3
3
  constructor(e) {
4
4
  this.level = e;
@@ -16,11 +16,11 @@ class se {
16
16
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
17
17
  }
18
18
  }
19
- function g(s = 0) {
19
+ function p(s = 0) {
20
20
  return new se(s);
21
21
  }
22
- const Z = {
23
- logLevel: k.ERROR,
22
+ const Y = {
23
+ logLevel: _.ERROR,
24
24
  useBeaconApi: !1,
25
25
  forceUseFetch: !1,
26
26
  trackingHost: "t.usermaven.com",
@@ -58,8 +58,8 @@ class ne {
58
58
  set(e, t, i = 365, n = !0, r = !1) {
59
59
  const o = /* @__PURE__ */ new Date();
60
60
  o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
61
- const a = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", c = r ? "; HttpOnly" : "";
62
- document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
61
+ const a = `expires=${o.toUTCString()}`, c = n ? "; Secure" : "", h = r ? "; HttpOnly" : "";
62
+ document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${c}${h}`;
63
63
  }
64
64
  get(e) {
65
65
  const t = e + "=", i = document.cookie.split(";");
@@ -100,35 +100,35 @@ class ne {
100
100
  return i ? i[0] : "";
101
101
  }
102
102
  }
103
- const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, T = ae.forEach, U = {};
103
+ const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, I = ae.forEach, F = {};
104
104
  function ce(s, e, t) {
105
105
  if (Array.isArray(s)) {
106
- if (T && s.forEach === T)
106
+ if (I && s.forEach === I)
107
107
  s.forEach(e, t);
108
108
  else if ("length" in s && s.length === +s.length) {
109
109
  for (let i = 0, n = s.length; i < n; i++)
110
- if (i in s && e.call(t, s[i], i) === U)
110
+ if (i in s && e.call(t, s[i], i) === F)
111
111
  return;
112
112
  }
113
113
  }
114
114
  }
115
- const B = function(s) {
115
+ const v = function(s) {
116
116
  return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
117
117
  }, le = function(s) {
118
118
  for (const e in s)
119
119
  typeof s[e] == "function" && (s[e] = s[e].bind(s));
120
120
  };
121
- function w(s, e, t) {
121
+ function k(s, e, t) {
122
122
  if (s != null) {
123
- if (T && Array.isArray(s) && s.forEach === T)
123
+ if (I && Array.isArray(s) && s.forEach === I)
124
124
  s.forEach(e, t);
125
125
  else if ("length" in s && s.length === +s.length) {
126
126
  for (let i = 0, n = s.length; i < n; i++)
127
- if (i in s && e.call(t, s[i], i) === U)
127
+ if (i in s && e.call(t, s[i], i) === F)
128
128
  return;
129
129
  } else
130
130
  for (const i in s)
131
- if (oe.call(s, i) && e.call(t, s[i], i) === U)
131
+ if (oe.call(s, i) && e.call(t, s[i], i) === F)
132
132
  return;
133
133
  }
134
134
  }
@@ -138,7 +138,7 @@ const ue = function(s, ...e) {
138
138
  t[i] !== void 0 && (s[i] = t[i]);
139
139
  }), s;
140
140
  };
141
- function A(s, e) {
141
+ function $(s, e) {
142
142
  return s.indexOf(e) !== -1;
143
143
  }
144
144
  const he = function(s) {
@@ -149,27 +149,27 @@ const he = function(s) {
149
149
  }
150
150
  }, de = function(s) {
151
151
  return s === void 0;
152
- }, E = function() {
152
+ }, A = function() {
153
153
  const s = function(i, n, r, o, a) {
154
154
  if (!i) {
155
- g().error("No valid element provided to register_event");
155
+ p().error("No valid element provided to register_event");
156
156
  return;
157
157
  }
158
158
  if (i.addEventListener && !o)
159
159
  i.addEventListener(n, r, !!a);
160
160
  else {
161
- const l = "on" + n, c = i[l];
162
- i[l] = e(i, r, c);
161
+ const c = "on" + n, h = i[c];
162
+ i[c] = e(i, r, h);
163
163
  }
164
164
  };
165
165
  function e(i, n, r) {
166
166
  return function(o) {
167
167
  if (o = o || t(window.event), !o)
168
168
  return;
169
- let a = !0, l;
170
- he(r) && (l = r(o));
171
- const c = n.call(i, o);
172
- return (l === !1 || c === !1) && (a = !1), a;
169
+ let a = !0, c;
170
+ he(r) && (c = r(o));
171
+ const h = n.call(i, o);
172
+ return (c === !1 || h === !1) && (a = !1), a;
173
173
  };
174
174
  }
175
175
  function t(i) {
@@ -180,53 +180,53 @@ const he = function(s) {
180
180
  }, t.stopPropagation = function() {
181
181
  this.cancelBubble = !0;
182
182
  }, s;
183
- }(), ge = function(s) {
183
+ }(), fe = function(s) {
184
184
  return function(...e) {
185
185
  try {
186
186
  return s.apply(this, e);
187
187
  } catch (t) {
188
- g().error(
188
+ p().error(
189
189
  "Implementation error. Please turn on debug and contact support@usermaven.com.",
190
190
  t
191
191
  );
192
192
  }
193
193
  };
194
- }, Y = function(s) {
194
+ }, G = function(s) {
195
195
  for (const e in s)
196
- typeof s[e] == "function" && (s[e] = ge(s[e]));
196
+ typeof s[e] == "function" && (s[e] = fe(s[e]));
197
197
  };
198
- function M(s) {
198
+ function V(s) {
199
199
  for (let e in s)
200
200
  (s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
201
201
  return s;
202
202
  }
203
- function h() {
203
+ function d() {
204
204
  try {
205
205
  return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
206
206
  } catch {
207
- return g().warn("window is not available"), !1;
207
+ return p().warn("window is not available"), !1;
208
208
  }
209
209
  }
210
- function v(s = 5) {
210
+ function E(s = 5) {
211
211
  const e = new Uint8Array(s);
212
212
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, s);
213
213
  }
214
- function fe(s) {
214
+ function ge(s) {
215
215
  return s.replace(
216
216
  /([-_][a-z])/g,
217
217
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
218
218
  );
219
219
  }
220
- function F(s) {
221
- return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(F) : Object.keys(s).reduce(
220
+ function Q(s) {
221
+ return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(Q) : Object.keys(s).reduce(
222
222
  (e, t) => {
223
- const i = fe(t);
224
- return e[i] = F(s[t]), e;
223
+ const i = ge(t);
224
+ return e[i] = Q(s[t]), e;
225
225
  },
226
226
  {}
227
227
  );
228
228
  }
229
- function x(s) {
229
+ function O(s) {
230
230
  switch (typeof s.className) {
231
231
  case "string":
232
232
  return s.className;
@@ -236,25 +236,25 @@ function x(s) {
236
236
  return "";
237
237
  }
238
238
  }
239
- function V(s) {
239
+ function J(s) {
240
240
  let e = "";
241
- return q(s) && !ee(s) && s.childNodes && s.childNodes.length && w(s.childNodes, function(t) {
242
- j(t) && t.textContent && (e += B(t.textContent).split(/(\s+)/).filter($).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
243
- }), B(e);
241
+ return z(s) && !ee(s) && s.childNodes && s.childNodes.length && k(s.childNodes, function(t) {
242
+ j(t) && t.textContent && (e += v(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
243
+ }), v(e);
244
244
  }
245
- function G(s) {
245
+ function b(s) {
246
246
  return !!s && s.nodeType === 1;
247
247
  }
248
- function y(s, e) {
248
+ function w(s, e) {
249
249
  return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
250
250
  }
251
251
  function j(s) {
252
252
  return !!s && s.nodeType === 3;
253
253
  }
254
- function Q(s) {
254
+ function q(s) {
255
255
  return !!s && s.nodeType === 11;
256
256
  }
257
- const C = [
257
+ const T = [
258
258
  "a",
259
259
  "button",
260
260
  "form",
@@ -264,34 +264,36 @@ const C = [
264
264
  "label"
265
265
  ];
266
266
  function pe(s, e) {
267
- if (!s || y(s, "html") || !G(s))
267
+ var o, a;
268
+ if (!s || w(s, "html") || !b(s))
268
269
  return !1;
269
270
  let t = s;
270
- for (; t && !y(t, "body"); ) {
271
+ for (; t && !w(t, "body"); ) {
271
272
  if (t.classList && t.classList.contains("um-no-capture"))
272
273
  return !1;
273
- t.parentNode && Q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
274
+ t.parentNode && q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
274
275
  }
275
276
  let i = !1;
276
- for (t = s; t && !y(t, "body"); ) {
277
- if (t.parentNode && Q(t.parentNode)) {
278
- t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
277
+ for (t = s; t && !w(t, "body"); ) {
278
+ if (t.parentNode && q(t.parentNode)) {
279
+ t = t.parentNode.host, t && b(t) && T.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
279
280
  continue;
280
281
  }
281
- const o = t.parentNode;
282
- if (!o) break;
283
- if (C.indexOf(o.tagName.toLowerCase()) > -1)
282
+ const c = t.parentNode;
283
+ if (!c || !b(c)) break;
284
+ if (T.indexOf(c.tagName.toLowerCase()) > -1)
284
285
  i = !0;
285
286
  else {
286
- const a = window.getComputedStyle(o);
287
- a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
287
+ const h = window.getComputedStyle(c);
288
+ h && h.getPropertyValue("cursor") === "pointer" && (i = !0);
288
289
  }
289
- t = o;
290
+ t = c;
290
291
  }
291
292
  const n = window.getComputedStyle(s);
292
293
  if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
293
294
  return !0;
294
- const r = s.tagName.toLowerCase();
295
+ const r = (a = (o = s.tagName) == null ? void 0 : o.toLowerCase) == null ? void 0 : a.call(o);
296
+ if (!r) return !1;
295
297
  switch (r) {
296
298
  case "html":
297
299
  return !1;
@@ -303,16 +305,16 @@ function pe(s, e) {
303
305
  case "textarea":
304
306
  return e.type === "change" || e.type === "click";
305
307
  default:
306
- return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
308
+ return i ? e.type === "click" : e.type === "click" && (T.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
307
309
  }
308
310
  }
309
- function q(s) {
310
- for (let i = s; i.parentNode && !y(i, "body"); i = i.parentNode) {
311
- const n = x(i).split(" ");
312
- if (A(n, "ph-sensitive") || A(n, "ph-no-capture"))
311
+ function z(s) {
312
+ for (let i = s; i.parentNode && !w(i, "body"); i = i.parentNode) {
313
+ const n = O(i).split(" ");
314
+ if ($(n, "ph-sensitive") || $(n, "ph-no-capture"))
313
315
  return !1;
314
316
  }
315
- if (A(x(s).split(" "), "ph-include"))
317
+ if ($(O(s).split(" "), "ph-include"))
316
318
  return !0;
317
319
  const e = s.type || "";
318
320
  if (typeof e == "string")
@@ -327,21 +329,49 @@ function q(s) {
327
329
  }
328
330
  function ee(s) {
329
331
  const e = ["button", "checkbox", "submit", "reset"];
330
- return !!(y(s, "input") && !e.includes(s.type) || y(s, "select") || y(s, "textarea") || s.getAttribute("contenteditable") === "true");
332
+ return !!(w(s, "input") && !e.includes(s.type) || w(s, "select") || w(s, "textarea") || s.getAttribute("contenteditable") === "true");
331
333
  }
332
- function $(s) {
333
- 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)));
334
+ function H(s) {
335
+ 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)));
334
336
  }
335
337
  function me(s) {
336
338
  return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
337
339
  }
338
- function R() {
339
- return v(10);
340
+ function ye(s) {
341
+ if (!s)
342
+ return !1;
343
+ const e = s.$el_text;
344
+ if (typeof e == "string" && v(e).length > 0)
345
+ return !0;
346
+ const t = s.classes;
347
+ if (Array.isArray(t) && t.some((n) => v(n).length > 0))
348
+ return !0;
349
+ const i = [
350
+ "attr__id",
351
+ "attr__name",
352
+ "attr__class",
353
+ "attr__aria-label",
354
+ "attr__aria-labelledby",
355
+ "attr__label",
356
+ "attr__href"
357
+ ];
358
+ for (const n of i) {
359
+ const r = s[n];
360
+ if (typeof r == "string" && v(r).length > 0)
361
+ return !0;
362
+ }
363
+ for (const [n, r] of Object.entries(s))
364
+ if (n.startsWith("attr__data-") && typeof r == "string" && v(r).length > 0)
365
+ return !0;
366
+ return !1;
340
367
  }
341
- function J(s) {
368
+ function x() {
369
+ return E(10);
370
+ }
371
+ function W(s) {
342
372
  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());
343
373
  }
344
- function ye(s, e) {
374
+ function we(s, e) {
345
375
  let t;
346
376
  return function(...i) {
347
377
  const n = () => {
@@ -350,7 +380,7 @@ function ye(s, e) {
350
380
  clearTimeout(t), t = setTimeout(n, e);
351
381
  };
352
382
  }
353
- function we(s) {
383
+ function ke(s) {
354
384
  const e = {}, t = s.replace(/^\?/, "").split("&");
355
385
  for (let i = 0; i < t.length; i++) {
356
386
  const n = t[i].split("=");
@@ -358,25 +388,25 @@ function we(s) {
358
388
  }
359
389
  return e;
360
390
  }
361
- function L(s) {
391
+ function U(s) {
362
392
  return typeof s == "string" || s instanceof String;
363
393
  }
364
- function P(s) {
394
+ function S(s) {
365
395
  return s !== null && typeof s == "object" && s.constructor === Object;
366
396
  }
367
- function ke(s) {
397
+ function ve(s) {
368
398
  if (s === null)
369
- return k.ERROR;
370
- const e = s.toUpperCase(), t = k[e];
371
- return t || t === 0 ? t : k.ERROR;
399
+ return _.ERROR;
400
+ const e = s.toUpperCase(), t = _[e];
401
+ return t || t === 0 ? t : _.ERROR;
372
402
  }
373
- const ve = () => {
403
+ const be = () => {
374
404
  let s = "false";
375
405
  return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
376
406
  };
377
- class be {
407
+ class _e {
378
408
  constructor(e) {
379
- 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();
409
+ 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();
380
410
  }
381
411
  initializeEventListener() {
382
412
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -430,9 +460,9 @@ class be {
430
460
  window.removeEventListener("scroll", this.debouncedHandleScroll);
431
461
  }
432
462
  }
433
- const N = class N {
434
- constructor(e, t, i = g()) {
435
- 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);
463
+ const D = class D {
464
+ constructor(e, t, i = p()) {
465
+ 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);
436
466
  }
437
467
  isBrowserSupported() {
438
468
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -458,7 +488,7 @@ const N = class N {
458
488
  const e = (t) => {
459
489
  t = t || window.event, this.captureEvent(t);
460
490
  };
461
- 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);
491
+ 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);
462
492
  }
463
493
  isPageRefresh() {
464
494
  if ("PerformanceNavigationTiming" in window) {
@@ -475,59 +505,66 @@ const N = class N {
475
505
  return (i = this.scrollDepth) == null || i.track(), !0;
476
506
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
477
507
  return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
478
- if (t && pe(t, e)) {
508
+ if (!(!t || !b(t)) && t && pe(t, e)) {
479
509
  const r = [t];
480
510
  let o = t;
481
- for (; o.parentNode && !y(o, "body"); ) {
482
- if (Q(o.parentNode)) {
483
- r.push(o.parentNode.host), o = o.parentNode.host;
511
+ for (; o != null && o.parentNode && !w(o, "body"); ) {
512
+ if (q(o == null ? void 0 : o.parentNode)) {
513
+ const g = (o == null ? void 0 : o.parentNode).host;
514
+ g && b(g) && r.push(g), o = g;
484
515
  continue;
485
516
  }
486
- r.push(o.parentNode), o = o.parentNode;
517
+ const l = o == null ? void 0 : o.parentNode;
518
+ if (!l || !b(l)) break;
519
+ r.push(l), o = l;
487
520
  }
488
521
  const a = [];
489
- let l, c = !1;
490
- if (w(r, (p) => {
491
- const b = q(p);
492
- p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = b && $(l) && l);
493
- const u = x(p).split(" ");
494
- A(u, "ph-no-capture") && (c = !0), a.push(
522
+ let c, h = !1;
523
+ if (k(r, (l) => {
524
+ if (!l.tagName)
525
+ return;
526
+ const g = z(l);
527
+ l.tagName.toLowerCase() === "a" && (c = l.getAttribute("href"), c = g && H(c) && c);
528
+ const u = O(l).split(" ");
529
+ $(u, "ph-no-capture") && (h = !0), a.push(
495
530
  this.getPropertiesFromElement(
496
- p,
531
+ l,
497
532
  this.options.maskAllElementAttributes ?? !1,
498
533
  this.options.maskAllText ?? !1
499
534
  )
500
535
  );
501
- }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
536
+ }), this.options.maskAllText || (a[0].$el_text = J(t)), c && (a[0].attr__href = c), h)
502
537
  return !1;
503
- const d = ue(
538
+ if (!ye(a[0]))
539
+ return this.logger.debug("Dropping autocapture event without identifiers."), !1;
540
+ const f = ue(
504
541
  this.getDefaultProperties(e.type),
505
542
  {
506
543
  $elements: a
507
544
  },
508
545
  this.getCustomProperties(r)
509
546
  );
510
- return this.client.track("$autocapture", d), !0;
547
+ return this.client.track("$autocapture", f), !0;
511
548
  }
512
549
  }
513
550
  getCustomProperties(e) {
514
551
  const t = {};
515
- return w(this.customProperties, (i) => {
516
- w(i.event_selectors, (n) => {
552
+ return k(this.customProperties, (i) => {
553
+ k(i.event_selectors, (n) => {
517
554
  const r = document.querySelectorAll(n);
518
- w(r, (o) => {
519
- A(e, o) && q(o) && (t[i.name] = this.extractCustomPropertyValue(i));
555
+ k(r, (o) => {
556
+ $(e, o) && z(o) && (t[i.name] = this.extractCustomPropertyValue(i));
520
557
  });
521
558
  });
522
559
  }), t;
523
560
  }
524
561
  extractCustomPropertyValue(e) {
525
562
  const t = [];
526
- return w(
563
+ return k(
527
564
  document.querySelectorAll(e.css_selector),
528
565
  function(i) {
529
566
  let n;
530
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), $(n) && t.push(n);
567
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), H(n) && t.push(n);
531
568
  }
532
569
  ), t.join(", ");
533
570
  }
@@ -539,17 +576,17 @@ const N = class N {
539
576
  const n = e.tagName.toLowerCase(), r = {
540
577
  tag_name: n
541
578
  };
542
- C.indexOf(n) > -1 && !i && (r.$el_text = V(e));
543
- const o = x(e);
544
- o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
545
- return d !== "";
546
- })), w(e.attributes, function(d) {
547
- ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && $(d.value) && !me(d.name) && (r["attr__" + d.name] = d.value);
579
+ T.indexOf(n) > -1 && !i && (r.$el_text = J(e));
580
+ const o = O(e);
581
+ o.length > 0 && (r.classes = o.split(" ").filter(function(f) {
582
+ return f !== "";
583
+ })), k(e.attributes, function(f) {
584
+ ee(e) && ["name", "id", "class"].indexOf(f.name) === -1 || !t && H(f.value) && !me(f.name) && (r["attr__" + f.name] = f.value);
548
585
  });
549
- let a = 1, l = 1, c = e;
550
- for (; c = this.previousElementSibling(c); )
551
- a++, c.tagName === e.tagName && l++;
552
- return r.nth_child = a, r.nth_of_type = l, r;
586
+ let a = 1, c = 1, h = e;
587
+ for (; h = this.previousElementSibling(h); )
588
+ a++, h.tagName === e.tagName && c++;
589
+ return r.nth_child = a, r.nth_of_type = c, r;
553
590
  }
554
591
  previousElementSibling(e) {
555
592
  if (e.previousElementSibling)
@@ -558,7 +595,7 @@ const N = class N {
558
595
  let t = e;
559
596
  do
560
597
  t = t.previousSibling;
561
- while (t && !G(t));
598
+ while (t && !b(t));
562
599
  return t;
563
600
  }
564
601
  }
@@ -580,9 +617,9 @@ const N = class N {
580
617
  return n % t < i;
581
618
  }
582
619
  };
583
- N.FORCE_CAPTURE_ATTR = "data-um-force-capture", N.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
584
- let H = N;
585
- class _e {
620
+ D.FORCE_CAPTURE_ATTR = "data-um-force-capture", D.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
621
+ let N = D;
622
+ class Ee {
586
623
  constructor(e) {
587
624
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
588
625
  }
@@ -611,8 +648,8 @@ class _e {
611
648
  }));
612
649
  }
613
650
  }
614
- class Ee {
615
- constructor(e, t, i = g()) {
651
+ class Pe {
652
+ constructor(e, t, i = p()) {
616
653
  this.trackingHost = e, this.logger = i, this.config = t;
617
654
  }
618
655
  async send(e) {
@@ -627,14 +664,14 @@ class Ee {
627
664
  throw new Error("Failed to queue events via Beacon API");
628
665
  }
629
666
  constructUrl(e) {
630
- 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";
631
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
667
+ 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";
668
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
632
669
  }
633
670
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
634
671
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
635
672
  }
636
- class W {
637
- constructor(e, t, i = g()) {
673
+ class K {
674
+ constructor(e, t, i = p()) {
638
675
  this.trackingHost = e, this.logger = i, this.config = t;
639
676
  }
640
677
  async send(e) {
@@ -651,8 +688,8 @@ class W {
651
688
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
652
689
  }
653
690
  constructUrl(e) {
654
- 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";
655
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
691
+ 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";
692
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
656
693
  }
657
694
  getCustomHeaders() {
658
695
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -661,8 +698,8 @@ class W {
661
698
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
662
699
  }
663
700
  }
664
- class Pe {
665
- constructor(e, t, i = g()) {
701
+ class Ae {
702
+ constructor(e, t, i = p()) {
666
703
  this.trackingHost = e, this.logger = i, this.config = t;
667
704
  }
668
705
  send(e) {
@@ -670,8 +707,8 @@ class Pe {
670
707
  const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
671
708
  n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
672
709
  const a = this.getCustomHeaders();
673
- Object.keys(a).forEach((l) => {
674
- n.setRequestHeader(l, a[l]);
710
+ Object.keys(a).forEach((c) => {
711
+ n.setRequestHeader(c, a[c]);
675
712
  }), n.onload = () => {
676
713
  n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${n.status}`));
677
714
  }, n.onerror = () => {
@@ -680,8 +717,8 @@ class Pe {
680
717
  });
681
718
  }
682
719
  constructUrl(e) {
683
- 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";
684
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
720
+ 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";
721
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
685
722
  }
686
723
  getCustomHeaders() {
687
724
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -692,7 +729,7 @@ class Pe {
692
729
  }
693
730
  class te {
694
731
  constructor(e, t) {
695
- this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || g(), this.load();
732
+ this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || p(), this.load();
696
733
  }
697
734
  set(e, t) {
698
735
  this.storage[e] = t, this.save();
@@ -710,7 +747,7 @@ class te {
710
747
  return !this.storageDisabled;
711
748
  }
712
749
  load() {
713
- if (!h()) {
750
+ if (!d()) {
714
751
  this.logger.warn("localStorage is not available in this environment");
715
752
  return;
716
753
  }
@@ -722,7 +759,7 @@ class te {
722
759
  }
723
760
  }
724
761
  save() {
725
- if (!h())
762
+ if (!d())
726
763
  return this.logger.warn("localStorage is not available in this environment"), !1;
727
764
  if (this.storageDisabled)
728
765
  return !1;
@@ -762,11 +799,11 @@ class Se {
762
799
  this.storage = {};
763
800
  }
764
801
  }
765
- class K {
766
- constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = g(), a = "default", l = 1e3, c = 25e5) {
802
+ class X {
803
+ constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = p(), a = "default", c = 1e3, h = 25e5) {
767
804
  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(
768
805
  `offline_queue_${a}`
769
- ), this.maxQueueItems = l, this.maxQueueBytes = c, h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
806
+ ), this.maxQueueItems = c, this.maxQueueBytes = h, d() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
770
807
  }
771
808
  add(e) {
772
809
  const t = {
@@ -774,23 +811,23 @@ class K {
774
811
  retries: 0,
775
812
  timestamp: Date.now()
776
813
  };
777
- t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), h() ? this.saveQueueToStorage() : this.processBatch();
814
+ t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), d() ? this.saveQueueToStorage() : this.processBatch();
778
815
  }
779
816
  initNetworkListeners() {
780
- h() && (window.addEventListener("online", () => {
817
+ d() && (window.addEventListener("online", () => {
781
818
  this.isOnline = !0, this.processBatch();
782
819
  }), window.addEventListener("offline", () => {
783
820
  this.isOnline = !1;
784
821
  }));
785
822
  }
786
823
  scheduleBatch() {
787
- h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
824
+ d() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
788
825
  () => this.processBatch(),
789
826
  this.batchInterval
790
827
  ));
791
828
  }
792
829
  async processBatch() {
793
- if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
830
+ if ((!d() || this.isOnline) && !this.processing && this.queue.length > 0) {
794
831
  this.processing = !0;
795
832
  const e = this.queue.splice(0, this.batchSize);
796
833
  this.totalQueueBytes = Math.max(
@@ -801,13 +838,13 @@ class K {
801
838
  try {
802
839
  await this.transport.send(t), this.logger.debug(
803
840
  `Successfully sent batch of ${e.length} payloads`
804
- ), h() && this.saveQueueToStorage();
841
+ ), d() && this.saveQueueToStorage();
805
842
  } catch (i) {
806
843
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
807
844
  }
808
845
  this.processing = !1;
809
846
  }
810
- h() && this.scheduleBatch();
847
+ d() && this.scheduleBatch();
811
848
  }
812
849
  async handleBatchFailure(e) {
813
850
  for (const t of e)
@@ -815,7 +852,7 @@ class K {
815
852
  "Max retries reached, discarding payload",
816
853
  t.payload
817
854
  );
818
- h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
855
+ d() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
819
856
  }
820
857
  enforceQueueLimits() {
821
858
  if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
@@ -848,7 +885,7 @@ class K {
848
885
  }
849
886
  }
850
887
  loadQueueFromStorage() {
851
- if (h()) {
888
+ if (d()) {
852
889
  const e = this.persistence.get("queue");
853
890
  if (!e) return;
854
891
  try {
@@ -866,15 +903,15 @@ class K {
866
903
  }
867
904
  }
868
905
  saveQueueToStorage() {
869
- if (h()) {
906
+ if (d()) {
870
907
  const e = this.queue.map(({ bytes: t, ...i }) => i);
871
908
  this.persistence.set("queue", JSON.stringify(e));
872
909
  }
873
910
  }
874
911
  }
875
- class Ae {
912
+ class Ce {
876
913
  constructor(e) {
877
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
914
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), G(this);
878
915
  }
879
916
  initializeEventListener() {
880
917
  document.addEventListener("click", this.handleClick.bind(this));
@@ -910,8 +947,8 @@ class Ae {
910
947
  }), this.clicks = [];
911
948
  }
912
949
  }
913
- class Ce {
914
- constructor(e, t, i = g()) {
950
+ class $e {
951
+ constructor(e, t, i = p()) {
915
952
  this.trackingHost = e, this.logger = i, this.config = t;
916
953
  }
917
954
  async send(e) {
@@ -926,15 +963,15 @@ class Ce {
926
963
  }
927
964
  };
928
965
  return new Promise((r, o) => {
929
- const a = (void 0)(n, (l) => {
930
- l.on("data", (c) => {
931
- }), l.on("end", () => {
932
- const c = l.statusCode || 0;
933
- c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
966
+ const a = (void 0)(n, (c) => {
967
+ c.on("data", (h) => {
968
+ }), c.on("end", () => {
969
+ const h = c.statusCode || 0;
970
+ h >= 200 && h < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${h}`));
934
971
  });
935
972
  });
936
- a.on("error", (l) => {
937
- o(l);
973
+ a.on("error", (c) => {
974
+ o(c);
938
975
  }), a.write(JSON.stringify(e)), a.end();
939
976
  });
940
977
  }
@@ -946,7 +983,7 @@ class Ce {
946
983
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
947
984
  }
948
985
  }
949
- class S {
986
+ class C {
950
987
  constructor(e, t = "all", i = {}) {
951
988
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
952
989
  }
@@ -961,7 +998,7 @@ class S {
961
998
  }
962
999
  handleFormSubmit(e) {
963
1000
  const t = e.target, i = this._getFormDetails(t);
964
- this.instance.track("$form", M(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
1001
+ this.instance.track("$form", V(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
965
1002
  }
966
1003
  trackFieldChanges(e) {
967
1004
  e.querySelectorAll("input, select, textarea").forEach((i) => {
@@ -971,7 +1008,7 @@ class S {
971
1008
  );
972
1009
  this.instance.track(
973
1010
  "$form_field_change",
974
- M({
1011
+ V({
975
1012
  form_id: e.id,
976
1013
  form_name: e.name || "",
977
1014
  field: r
@@ -981,7 +1018,7 @@ class S {
981
1018
  });
982
1019
  }
983
1020
  static getInstance(e, t = "all", i = {}) {
984
- return S.instance || (S.instance = new S(e, t, i)), S.instance;
1021
+ return C.instance || (C.instance = new C(e, t, i)), C.instance;
985
1022
  }
986
1023
  _getFormDetails(e) {
987
1024
  const t = {
@@ -1082,9 +1119,9 @@ class S {
1082
1119
  return e.slice(t, i + 1);
1083
1120
  }
1084
1121
  }
1085
- class I {
1122
+ class R {
1086
1123
  constructor(e) {
1087
- 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(
1124
+ 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(
1088
1125
  this.transport,
1089
1126
  this.config.maxSendAttempts || 3,
1090
1127
  this.config.minSendTimeout || 1e3,
@@ -1093,14 +1130,14 @@ class I {
1093
1130
  // Reduced interval to .2 second
1094
1131
  this.logger,
1095
1132
  this.namespace
1096
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1133
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1097
1134
  `Usermaven client initialized for namespace: ${this.namespace}`
1098
1135
  );
1099
1136
  }
1100
1137
  initializeBrowserFeatures() {
1101
- 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) {
1138
+ 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) {
1102
1139
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
1103
- this.formTracking = S.getInstance(
1140
+ this.formTracking = C.getInstance(
1104
1141
  this,
1105
1142
  e || "none",
1106
1143
  {
@@ -1108,7 +1145,7 @@ class I {
1108
1145
  }
1109
1146
  );
1110
1147
  }
1111
- this.config.autoPageview && (this.pageviewTracking = new _e(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ae(this)), this.setupPageLeaveTracking();
1148
+ this.config.autoPageview && (this.pageviewTracking = new Ee(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ce(this)), this.setupPageLeaveTracking();
1112
1149
  }
1113
1150
  /**
1114
1151
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -1119,11 +1156,11 @@ class I {
1119
1156
  const i = JSON.parse(JSON.stringify(e));
1120
1157
  let n = { ...t, ...i };
1121
1158
  return Object.keys(t).forEach((r) => {
1122
- P(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
1159
+ S(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
1123
1160
  }), n;
1124
1161
  }
1125
1162
  init(e) {
1126
- 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(
1163
+ 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(
1127
1164
  this.transport,
1128
1165
  this.config.maxSendAttempts || 3,
1129
1166
  this.config.minSendTimeout || 1e3,
@@ -1132,7 +1169,7 @@ class I {
1132
1169
  // Reduced interval to .25 second
1133
1170
  this.logger,
1134
1171
  this.namespace
1135
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1172
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1136
1173
  `Usermaven client reinitialized for namespace: ${this.namespace}`
1137
1174
  );
1138
1175
  }
@@ -1148,8 +1185,8 @@ class I {
1148
1185
  if (!r || !r.startsWith("http")) return;
1149
1186
  const o = new URL(r);
1150
1187
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1151
- const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
1152
- l && (o.searchParams.append("_um", l), n.setAttribute("href", o.toString()));
1188
+ const c = (a = this.cookieManager) == null ? void 0 : a.get(t);
1189
+ c && (o.searchParams.append("_um", c), n.setAttribute("href", o.toString()));
1153
1190
  }
1154
1191
  }), this.logger.debug("Cross-domain linking initialized");
1155
1192
  }
@@ -1160,29 +1197,29 @@ class I {
1160
1197
  }
1161
1198
  initializeTransport(e) {
1162
1199
  const t = "https://events.usermaven.com";
1163
- if (!h())
1164
- return new Ce(e.trackingHost || t, e);
1200
+ if (!d())
1201
+ return new $e(e.trackingHost || t, e);
1165
1202
  const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1166
1203
  if (e.useBeaconApi && r)
1167
- return new Ee(
1204
+ return new Pe(
1168
1205
  e.trackingHost || t,
1169
1206
  e,
1170
1207
  this.logger
1171
1208
  );
1172
1209
  if (e.forceUseFetch && n)
1173
- return new W(
1210
+ return new K(
1174
1211
  e.trackingHost || t,
1175
1212
  e,
1176
1213
  this.logger
1177
1214
  );
1178
1215
  if (i)
1179
- return new Pe(
1216
+ return new Ae(
1180
1217
  e.trackingHost || t,
1181
1218
  e,
1182
1219
  this.logger
1183
1220
  );
1184
1221
  if (n)
1185
- return new W(
1222
+ return new K(
1186
1223
  e.trackingHost || t,
1187
1224
  e,
1188
1225
  this.logger
@@ -1190,25 +1227,25 @@ class I {
1190
1227
  throw new Error("No suitable transport method available");
1191
1228
  }
1192
1229
  initializePersistence() {
1193
- return this.config.disableEventPersistence || !h() ? new Se() : new te(
1230
+ return this.config.disableEventPersistence || !d() ? new Se() : new te(
1194
1231
  `${this.namespace}_${this.config.key}`,
1195
1232
  this.logger
1196
1233
  );
1197
1234
  }
1198
1235
  getOrCreateAnonymousId() {
1199
1236
  var i, n;
1200
- if (!h())
1201
- return R();
1237
+ if (!d())
1238
+ return x();
1202
1239
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1203
1240
  return "";
1204
1241
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1205
1242
  let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1206
1243
  if (!t) {
1207
1244
  if (this.config.crossDomainLinking) {
1208
- const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
1209
- t = a || d || R();
1245
+ const a = new URLSearchParams(window.location.search).get("_um"), h = window.location.hash.substring(1).split("~"), f = h.length > 1 ? h[1] : void 0;
1246
+ t = a || f || x();
1210
1247
  }
1211
- t || (t = R());
1248
+ t || (t = x());
1212
1249
  const r = 365 * 10;
1213
1250
  (n = this.cookieManager) == null || n.set(
1214
1251
  e,
@@ -1221,11 +1258,11 @@ class I {
1221
1258
  return t;
1222
1259
  }
1223
1260
  async id(e, t = !1) {
1224
- if (!P(e))
1261
+ if (!S(e))
1225
1262
  throw new Error("User data must be an object");
1226
- if (e.email && !J(e.email))
1263
+ if (e.email && !W(e.email))
1227
1264
  throw new Error("Invalid email provided");
1228
- if (!e.id || !L(e.id))
1265
+ if (!e.id || !U(e.id))
1229
1266
  throw new Error("User ID must be a string");
1230
1267
  const i = e.id;
1231
1268
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1241,28 +1278,28 @@ class I {
1241
1278
  this.trackInternal(e, t, i);
1242
1279
  }
1243
1280
  lead(e, t = !1) {
1244
- if (!P(e))
1281
+ if (!S(e))
1245
1282
  throw new Error(
1246
1283
  "Lead payload must be a non-null object and not an array"
1247
1284
  );
1248
1285
  const i = e.email;
1249
- if (!L(i)) {
1286
+ if (!U(i)) {
1250
1287
  this.logger.error("Lead event requires a valid email attribute");
1251
1288
  return;
1252
1289
  }
1253
1290
  const n = i.trim();
1254
- if (!n || !J(n)) {
1291
+ if (!n || !W(n)) {
1255
1292
  this.logger.error("Lead event requires a valid email attribute");
1256
1293
  return;
1257
1294
  }
1258
1295
  e.email = n, this.track("lead", e, t);
1259
1296
  }
1260
1297
  trackInternal(e, t, i = !1) {
1261
- if (ve()) {
1298
+ if (be()) {
1262
1299
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1263
1300
  return;
1264
1301
  }
1265
- if (!L(e))
1302
+ if (!U(e))
1266
1303
  throw new Error("Event name must be a string");
1267
1304
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1268
1305
  throw new Error(
@@ -1280,12 +1317,12 @@ class I {
1280
1317
  }
1281
1318
  }
1282
1319
  rawTrack(e) {
1283
- if (!P(e))
1320
+ if (!S(e))
1284
1321
  throw new Error("Event payload must be an object");
1285
1322
  this.track("raw", e);
1286
1323
  }
1287
1324
  async group(e, t = !1) {
1288
- if (!P(e))
1325
+ if (!S(e))
1289
1326
  throw new Error("Company properties must be an object");
1290
1327
  if (!e.id || !e.name || !e.created_at)
1291
1328
  throw new Error(
@@ -1294,16 +1331,16 @@ class I {
1294
1331
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1295
1332
  }
1296
1333
  createEventPayload(e, t) {
1297
- 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}`) || {};
1298
- let l = t || {};
1299
- const c = {
1300
- event_id: "",
1334
+ 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}`) || {};
1335
+ let f = n;
1336
+ const l = {
1337
+ event_id: i || x(),
1301
1338
  user: {
1302
1339
  anonymous_id: this.anonymousId,
1303
- id: r,
1304
- ...i
1340
+ id: a,
1341
+ ...r
1305
1342
  },
1306
- ...n && { company: n },
1343
+ ...o && { company: o },
1307
1344
  ids: this.getThirdPartyIds(),
1308
1345
  utc_time: (/* @__PURE__ */ new Date()).toISOString(),
1309
1346
  local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
@@ -1311,18 +1348,18 @@ class I {
1311
1348
  src: "usermaven",
1312
1349
  event_type: e,
1313
1350
  namespace: this.namespace,
1314
- ...o,
1315
- ...a
1351
+ ...c,
1352
+ ...h
1316
1353
  };
1317
1354
  if (e === "$autocapture") {
1318
- const d = this.processAutocaptureAttributes(
1355
+ const g = this.processAutocaptureAttributes(
1319
1356
  t || {}
1320
1357
  );
1321
- c.autocapture_attributes = d;
1322
- } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1323
- delete l[d];
1324
- }), c.event_attributes = l);
1325
- 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;
1358
+ l.autocapture_attributes = g;
1359
+ } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((g) => {
1360
+ delete f[g];
1361
+ }), l.event_attributes = f);
1362
+ 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;
1326
1363
  }
1327
1364
  processAutocaptureAttributes(e) {
1328
1365
  let t = {};
@@ -1345,14 +1382,14 @@ class I {
1345
1382
  }
1346
1383
  getThirdPartyIds() {
1347
1384
  const e = {};
1348
- if (h()) {
1385
+ if (d()) {
1349
1386
  const t = this.getCookie("_fbp");
1350
1387
  t && (e.fbp = t);
1351
1388
  }
1352
1389
  return e;
1353
1390
  }
1354
1391
  getUtmParams() {
1355
- const e = {}, t = we(window.location.search);
1392
+ const e = {}, t = ke(window.location.search);
1356
1393
  return [
1357
1394
  "utm_source",
1358
1395
  "utm_medium",
@@ -1364,7 +1401,7 @@ class I {
1364
1401
  }), e;
1365
1402
  }
1366
1403
  pageview() {
1367
- h() ? this.track(
1404
+ d() ? this.track(
1368
1405
  "pageview",
1369
1406
  {
1370
1407
  url: window.location.href,
@@ -1377,7 +1414,7 @@ class I {
1377
1414
  );
1378
1415
  }
1379
1416
  setupPageLeaveTracking() {
1380
- if (!h()) return;
1417
+ if (!d()) return;
1381
1418
  let e = !1, t = !1;
1382
1419
  const i = () => {
1383
1420
  !e && !t && (e = !0, this.track("$pageleave", {
@@ -1415,7 +1452,7 @@ class I {
1415
1452
  });
1416
1453
  }
1417
1454
  set(e, t) {
1418
- if (!P(e))
1455
+ if (!S(e))
1419
1456
  throw new Error("Properties must be an object");
1420
1457
  const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1421
1458
  if (i) {
@@ -1454,13 +1491,13 @@ class I {
1454
1491
  function ie() {
1455
1492
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1456
1493
  }
1457
- function $e() {
1494
+ function xe() {
1458
1495
  return ie() ? window.define : void 0;
1459
1496
  }
1460
1497
  const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1461
- function O(s) {
1462
- const e = JSON.parse(JSON.stringify(s)), t = F(e), i = {
1463
- ...Z,
1498
+ function L(s) {
1499
+ const e = JSON.parse(JSON.stringify(s)), t = Q(e), i = {
1500
+ ...Y,
1464
1501
  ...t
1465
1502
  };
1466
1503
  if (!i.key)
@@ -1468,16 +1505,16 @@ function O(s) {
1468
1505
  if (!i.trackingHost)
1469
1506
  throw new Error("Tracking host is required!");
1470
1507
  const n = i.key || "", r = `${Te}${n}`;
1471
- return h() && i.autocapture && window[r] && (console.warn(
1508
+ return d() && i.autocapture && window[r] && (console.warn(
1472
1509
  "Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
1473
- ), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new I(i);
1510
+ ), i.disableAutocaptureListenerRegistration = !0), d() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new R(i);
1474
1511
  }
1475
- function xe(s) {
1512
+ function He(s) {
1476
1513
  var n;
1477
1514
  const e = {
1478
1515
  key: s.getAttribute("data-key") || void 0,
1479
1516
  trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1480
- logLevel: ke(s.getAttribute("data-log-level")),
1517
+ logLevel: ve(s.getAttribute("data-log-level")),
1481
1518
  autocapture: s.getAttribute("data-autocapture") === "true",
1482
1519
  formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
1483
1520
  autoPageview: s.getAttribute("data-auto-pageview") === "true",
@@ -1507,30 +1544,30 @@ function xe(s) {
1507
1544
  maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
1508
1545
  };
1509
1546
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1510
- const t = O(e), i = e.namespace || "usermaven";
1511
- return h() && t.pageview(), He(i, t), t;
1547
+ const t = L(e), i = e.namespace || "usermaven";
1548
+ return d() && t.pageview(), Ie(i, t), t;
1512
1549
  }
1513
- function He(s, e) {
1550
+ function Ie(s, e) {
1514
1551
  let t = !1;
1515
1552
  const i = [], n = [];
1516
1553
  function r() {
1517
1554
  for (; i.length > 0; ) {
1518
1555
  const u = i.shift();
1519
1556
  if (u) {
1520
- const f = u[u.length - 1];
1521
- if (f && typeof f.resolve == "function") {
1522
- const m = u.pop();
1557
+ const m = u[u.length - 1];
1558
+ if (m && typeof m.resolve == "function") {
1559
+ const y = u.pop();
1523
1560
  try {
1524
- const _ = a.apply(null, u);
1525
- _ && typeof _.then == "function" ? _.then(m.resolve).catch(m.reject) : m.resolve(_);
1526
- } catch (_) {
1527
- m.reject(_);
1561
+ const P = a.apply(null, u);
1562
+ P && typeof P.then == "function" ? P.then(y.resolve).catch(y.reject) : y.resolve(P);
1563
+ } catch (P) {
1564
+ y.reject(P);
1528
1565
  }
1529
1566
  } else
1530
1567
  try {
1531
1568
  a.apply(null, u);
1532
- } catch (m) {
1533
- console.error("Usermaven: Error processing queued command:", m);
1569
+ } catch (y) {
1570
+ console.error("Usermaven: Error processing queued command:", y);
1534
1571
  }
1535
1572
  }
1536
1573
  }
@@ -1539,8 +1576,8 @@ function He(s, e) {
1539
1576
  n.forEach((u) => u()), n.length = 0;
1540
1577
  }
1541
1578
  function a(...u) {
1542
- const f = u[0];
1543
- if (f === "onLoad") {
1579
+ const m = u[0];
1580
+ if (m === "onLoad") {
1544
1581
  typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
1545
1582
  return;
1546
1583
  }
@@ -1548,11 +1585,11 @@ function He(s, e) {
1548
1585
  i.push(u);
1549
1586
  return;
1550
1587
  }
1551
- if (typeof e[f] == "function")
1552
- return e[f].apply(e, u.slice(1));
1553
- console.error(`Method ${f} not found on UsermavenClient`);
1588
+ if (typeof e[m] == "function")
1589
+ return e[m].apply(e, u.slice(1));
1590
+ console.error(`Method ${m} not found on UsermavenClient`);
1554
1591
  }
1555
- const l = ["id", "group", "reset"], c = [
1592
+ const c = ["id", "group", "reset"], h = [
1556
1593
  "track",
1557
1594
  "lead",
1558
1595
  "pageview",
@@ -1561,65 +1598,65 @@ function He(s, e) {
1561
1598
  "rawTrack",
1562
1599
  "setUserId"
1563
1600
  ];
1564
- [...l, ...c].forEach((u) => {
1565
- a[u] = function(...f) {
1601
+ [...c, ...h].forEach((u) => {
1602
+ a[u] = function(...m) {
1566
1603
  if (!t) {
1567
- if (l.includes(u))
1568
- return new Promise((z, m) => {
1569
- i.push([u, ...f, { resolve: z, reject: m }]);
1604
+ if (c.includes(u))
1605
+ return new Promise((M, y) => {
1606
+ i.push([u, ...m, { resolve: M, reject: y }]);
1570
1607
  });
1571
- i.push([u, ...f]);
1608
+ i.push([u, ...m]);
1572
1609
  return;
1573
1610
  }
1574
1611
  if (typeof e[u] == "function")
1575
- return e[u].apply(e, f);
1612
+ return e[u].apply(e, m);
1576
1613
  };
1577
1614
  }), a.getConfig = function() {
1578
1615
  return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
1579
1616
  }, window[s] = a;
1580
- const p = `${s}Q`, b = window[p] || [];
1581
- for (window[p] = b, b.push = function(...u) {
1617
+ const l = `${s}Q`, g = window[l] || [];
1618
+ for (window[l] = g, g.push = function(...u) {
1582
1619
  return a.apply(null, u), Array.prototype.push.apply(this, u);
1583
1620
  }, setTimeout(() => {
1584
1621
  t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
1585
- }, 0); b.length > 0; ) {
1586
- const u = b.shift();
1622
+ }, 0); g.length > 0; ) {
1623
+ const u = g.shift();
1587
1624
  u && i.push(u);
1588
1625
  }
1589
1626
  }
1590
- let X = !1, D = null;
1591
- if (h()) {
1592
- const s = $e();
1627
+ let Z = !1, B = null;
1628
+ if (d()) {
1629
+ const s = xe();
1593
1630
  s && s("usermaven", [], function() {
1594
1631
  return {
1595
- usermavenClient: O,
1596
- UsermavenClient: I,
1597
- LogLevel: k,
1632
+ usermavenClient: L,
1633
+ UsermavenClient: R,
1634
+ LogLevel: _,
1598
1635
  // Expose the script tag client if it exists
1599
- getScriptTagClient: () => D
1636
+ getScriptTagClient: () => B
1600
1637
  };
1601
- }), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = I, window.usermavenScriptTagClient = () => D), function(e, t) {
1638
+ }), typeof window < "u" && (window.usermavenClient = L, window.UsermavenClient = R, window.usermavenScriptTagClient = () => B), function(e, t) {
1602
1639
  const i = e.currentScript;
1603
1640
  function n() {
1604
- return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1641
+ return Z || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1605
1642
  }
1606
1643
  function r() {
1607
- n() && (console.log("[Usermaven] Auto-initializing from script tag"), D = xe(i), X = !0);
1644
+ n() && (console.log("[Usermaven] Auto-initializing from script tag"), B = He(i), Z = !0);
1608
1645
  }
1609
1646
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1610
1647
  }(document, window);
1611
1648
  }
1612
1649
  typeof module < "u" && module.exports && !ie() && (module.exports = {
1613
- usermavenClient: O,
1614
- UsermavenClient: I,
1650
+ usermavenClient: L,
1651
+ UsermavenClient: R,
1615
1652
  Config: void 0,
1616
1653
  UserProps: void 0,
1617
1654
  EventPayload: void 0,
1618
- LogLevel: k,
1655
+ LogLevel: _,
1619
1656
  ClientProperties: void 0
1620
1657
  });
1621
1658
  export {
1622
- k as LogLevel,
1623
- I as UsermavenClient,
1624
- O as usermavenClient
1659
+ _ as LogLevel,
1660
+ R as UsermavenClient,
1661
+ L as usermavenClient
1625
1662
  };