@usermaven/sdk-js 1.5.8 → 1.5.9-rc.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- var p = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(p || {});
2
- class G {
1
+ var k = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(k || {});
2
+ class ie {
3
3
  constructor(e) {
4
4
  this.level = e;
5
5
  }
@@ -16,11 +16,11 @@ class G {
16
16
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
17
17
  }
18
18
  }
19
- function d(n = 0) {
20
- return new G(n);
19
+ function f(n = 0) {
20
+ return new ie(n);
21
21
  }
22
- const q = {
23
- logLevel: p.ERROR,
22
+ const X = {
23
+ logLevel: k.ERROR,
24
24
  useBeaconApi: !1,
25
25
  forceUseFetch: !1,
26
26
  trackingHost: "t.usermaven.com",
@@ -45,15 +45,15 @@ const q = {
45
45
  maskAllText: !1,
46
46
  maskAllElementAttributes: !1
47
47
  };
48
- class j {
48
+ class ne {
49
49
  constructor(e) {
50
50
  this.domain = e, this.cookieDomain = this.getCookieDomain();
51
51
  }
52
52
  set(e, t, i = 365, s = !0, r = !1) {
53
53
  const o = /* @__PURE__ */ new Date();
54
54
  o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
55
- const c = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", a = r ? "; HttpOnly" : "";
56
- document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
55
+ const a = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", c = r ? "; HttpOnly" : "";
56
+ document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
57
57
  }
58
58
  get(e) {
59
59
  const t = e + "=", i = document.cookie.split(";");
@@ -94,76 +94,76 @@ class j {
94
94
  return i ? i[0] : "";
95
95
  }
96
96
  }
97
- const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, P = ie.forEach, N = {};
98
- function ne(n, e, t) {
97
+ const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, T = oe.forEach, U = {};
98
+ function ae(n, e, t) {
99
99
  if (Array.isArray(n)) {
100
- if (P && n.forEach === P)
100
+ if (T && n.forEach === T)
101
101
  n.forEach(e, t);
102
102
  else if ("length" in n && n.length === +n.length) {
103
103
  for (let i = 0, s = n.length; i < s; i++)
104
- if (i in n && e.call(t, n[i], i) === N)
104
+ if (i in n && e.call(t, n[i], i) === U)
105
105
  return;
106
106
  }
107
107
  }
108
108
  }
109
- const R = function(n) {
109
+ const D = function(n) {
110
110
  return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
111
- }, se = function(n) {
111
+ }, ce = function(n) {
112
112
  for (const e in n)
113
113
  typeof n[e] == "function" && (n[e] = n[e].bind(n));
114
114
  };
115
- function g(n, e, t) {
115
+ function w(n, e, t) {
116
116
  if (n != null) {
117
- if (P && Array.isArray(n) && n.forEach === P)
117
+ if (T && Array.isArray(n) && n.forEach === T)
118
118
  n.forEach(e, t);
119
119
  else if ("length" in n && n.length === +n.length) {
120
120
  for (let i = 0, s = n.length; i < s; i++)
121
- if (i in n && e.call(t, n[i], i) === N)
121
+ if (i in n && e.call(t, n[i], i) === U)
122
122
  return;
123
123
  } else
124
124
  for (const i in n)
125
- if (te.call(n, i) && e.call(t, n[i], i) === N)
125
+ if (re.call(n, i) && e.call(t, n[i], i) === U)
126
126
  return;
127
127
  }
128
128
  }
129
- const re = function(n, ...e) {
130
- return ne(e, function(t) {
129
+ const le = function(n, ...e) {
130
+ return ae(e, function(t) {
131
131
  for (const i in t)
132
132
  t[i] !== void 0 && (n[i] = t[i]);
133
133
  }), n;
134
134
  };
135
- function _(n, e) {
135
+ function S(n, e) {
136
136
  return n.indexOf(e) !== -1;
137
137
  }
138
- const oe = function(n) {
138
+ const ue = function(n) {
139
139
  try {
140
140
  return /^\s*\bfunction\b/.test(n);
141
141
  } catch {
142
142
  return !1;
143
143
  }
144
- }, ae = function(n) {
144
+ }, he = function(n) {
145
145
  return n === void 0;
146
- }, y = function() {
147
- const n = function(i, s, r, o, c) {
146
+ }, E = function() {
147
+ const n = function(i, s, r, o, a) {
148
148
  if (!i) {
149
- d().error("No valid element provided to register_event");
149
+ f().error("No valid element provided to register_event");
150
150
  return;
151
151
  }
152
152
  if (i.addEventListener && !o)
153
- i.addEventListener(s, r, !!c);
153
+ i.addEventListener(s, r, !!a);
154
154
  else {
155
- const l = "on" + s, a = i[l];
156
- i[l] = e(i, r, a);
155
+ const l = "on" + s, c = i[l];
156
+ i[l] = e(i, r, c);
157
157
  }
158
158
  };
159
159
  function e(i, s, r) {
160
160
  return function(o) {
161
161
  if (o = o || t(window.event), !o)
162
162
  return;
163
- let c = !0, l;
164
- oe(r) && (l = r(o));
165
- const a = s.call(i, o);
166
- return (l === !1 || a === !1) && (c = !1), c;
163
+ let a = !0, l;
164
+ ue(r) && (l = r(o));
165
+ const c = s.call(i, o);
166
+ return (l === !1 || c === !1) && (a = !1), a;
167
167
  };
168
168
  }
169
169
  function t(i) {
@@ -174,47 +174,47 @@ const oe = function(n) {
174
174
  }, t.stopPropagation = function() {
175
175
  this.cancelBubble = !0;
176
176
  }, n;
177
- }(), ce = function(n) {
177
+ }(), de = function(n) {
178
178
  return function(...e) {
179
179
  try {
180
180
  return n.apply(this, e);
181
181
  } catch (t) {
182
- d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
182
+ f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
183
183
  }
184
184
  };
185
- }, V = function(n) {
185
+ }, Z = function(n) {
186
186
  for (const e in n)
187
- typeof n[e] == "function" && (n[e] = ce(n[e]));
187
+ typeof n[e] == "function" && (n[e] = de(n[e]));
188
188
  };
189
- function U(n) {
189
+ function q(n) {
190
190
  for (let e in n)
191
191
  (n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
192
192
  return n;
193
193
  }
194
- function u() {
194
+ function h() {
195
195
  try {
196
196
  return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
197
197
  } catch {
198
- return d().warn("window is not available"), !1;
198
+ return f().warn("window is not available"), !1;
199
199
  }
200
200
  }
201
- function m(n = 5) {
201
+ function v(n = 5) {
202
202
  const e = new Uint8Array(n);
203
203
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
204
204
  }
205
- function le(n) {
205
+ function fe(n) {
206
206
  return n.replace(
207
207
  /([-_][a-z])/g,
208
208
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
209
209
  );
210
210
  }
211
- function I(n) {
212
- return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(I) : Object.keys(n).reduce((e, t) => {
213
- const i = le(t);
214
- return e[i] = I(n[t]), e;
211
+ function F(n) {
212
+ return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(F) : Object.keys(n).reduce((e, t) => {
213
+ const i = fe(t);
214
+ return e[i] = F(n[t]), e;
215
215
  }, {});
216
216
  }
217
- function A(n) {
217
+ function x(n) {
218
218
  switch (typeof n.className) {
219
219
  case "string":
220
220
  return n.className;
@@ -224,47 +224,47 @@ function A(n) {
224
224
  return "";
225
225
  }
226
226
  }
227
- function D(n) {
227
+ function V(n) {
228
228
  let e = "";
229
- return L(n) && !W(n) && n.childNodes && n.childNodes.length && g(n.childNodes, function(t) {
230
- Q(t) && t.textContent && (e += R(t.textContent).split(/(\s+)/).filter(E).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
231
- }), R(e);
229
+ return M(n) && !j(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
230
+ G(t) && t.textContent && (e += D(t.textContent).split(/(\s+)/).filter(C).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
231
+ }), D(e);
232
232
  }
233
- function J(n) {
233
+ function Y(n) {
234
234
  return !!n && n.nodeType === 1;
235
235
  }
236
- function f(n, e) {
236
+ function y(n, e) {
237
237
  return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
238
238
  }
239
- function Q(n) {
239
+ function G(n) {
240
240
  return !!n && n.nodeType === 3;
241
241
  }
242
- function O(n) {
242
+ function z(n) {
243
243
  return !!n && n.nodeType === 11;
244
244
  }
245
- const b = ["a", "button", "form", "input", "select", "textarea", "label"];
246
- function ue(n, e) {
247
- if (!n || f(n, "html") || !J(n))
245
+ const $ = ["a", "button", "form", "input", "select", "textarea", "label"];
246
+ function ge(n, e) {
247
+ if (!n || y(n, "html") || !Y(n))
248
248
  return !1;
249
249
  let t = n;
250
- for (; t && !f(t, "body"); ) {
250
+ for (; t && !y(t, "body"); ) {
251
251
  if (t.classList && t.classList.contains("um-no-capture"))
252
252
  return !1;
253
- t.parentNode && O(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
253
+ t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
254
254
  }
255
255
  let i = !1;
256
- for (t = n; t && !f(t, "body"); ) {
257
- if (t.parentNode && O(t.parentNode)) {
258
- t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
256
+ for (t = n; t && !y(t, "body"); ) {
257
+ if (t.parentNode && z(t.parentNode)) {
258
+ t = t.parentNode.host, t && $.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
259
259
  continue;
260
260
  }
261
261
  const o = t.parentNode;
262
262
  if (!o) break;
263
- if (b.indexOf(o.tagName.toLowerCase()) > -1)
263
+ if ($.indexOf(o.tagName.toLowerCase()) > -1)
264
264
  i = !0;
265
265
  else {
266
- const c = window.getComputedStyle(o);
267
- c && c.getPropertyValue("cursor") === "pointer" && (i = !0);
266
+ const a = window.getComputedStyle(o);
267
+ a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
268
268
  }
269
269
  t = o;
270
270
  }
@@ -283,16 +283,16 @@ function ue(n, e) {
283
283
  case "textarea":
284
284
  return e.type === "change" || e.type === "click";
285
285
  default:
286
- return i ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
286
+ return i ? e.type === "click" : e.type === "click" && ($.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
287
287
  }
288
288
  }
289
- function L(n) {
290
- for (let i = n; i.parentNode && !f(i, "body"); i = i.parentNode) {
291
- const s = A(i).split(" ");
292
- if (_(s, "ph-sensitive") || _(s, "ph-no-capture"))
289
+ function M(n) {
290
+ for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
291
+ const s = x(i).split(" ");
292
+ if (S(s, "ph-sensitive") || S(s, "ph-no-capture"))
293
293
  return !1;
294
294
  }
295
- if (_(A(n).split(" "), "ph-include"))
295
+ if (S(x(n).split(" "), "ph-include"))
296
296
  return !0;
297
297
  const e = n.type || "";
298
298
  if (typeof e == "string")
@@ -305,23 +305,23 @@ function L(n) {
305
305
  const t = n.name || n.id || "";
306
306
  return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
307
307
  }
308
- function W(n) {
308
+ function j(n) {
309
309
  const e = ["button", "checkbox", "submit", "reset"];
310
- return !!(f(n, "input") && !e.includes(n.type) || f(n, "select") || f(n, "textarea") || n.getAttribute("contenteditable") === "true");
310
+ return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
311
311
  }
312
- function E(n) {
313
- return !(n === null || ae(n) || typeof n == "string" && (n = R(n), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
312
+ function C(n) {
313
+ return !(n === null || he(n) || typeof n == "string" && (n = D(n), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
314
314
  }
315
- function he(n) {
315
+ function pe(n) {
316
316
  return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
317
317
  }
318
- function x() {
319
- return m(10);
318
+ function O() {
319
+ return v(10);
320
320
  }
321
- function de(n) {
321
+ function me(n) {
322
322
  return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(n).toLowerCase());
323
323
  }
324
- function fe(n, e) {
324
+ function ye(n, e) {
325
325
  let t;
326
326
  return function(...i) {
327
327
  const s = () => {
@@ -330,7 +330,7 @@ function fe(n, e) {
330
330
  clearTimeout(t), t = setTimeout(s, e);
331
331
  };
332
332
  }
333
- function ge(n) {
333
+ function we(n) {
334
334
  const e = {}, t = n.replace(/^\?/, "").split("&");
335
335
  for (let i = 0; i < t.length; i++) {
336
336
  const s = t[i].split("=");
@@ -338,25 +338,25 @@ function ge(n) {
338
338
  }
339
339
  return e;
340
340
  }
341
- function F(n) {
341
+ function J(n) {
342
342
  return typeof n == "string" || n instanceof String;
343
343
  }
344
- function v(n) {
344
+ function A(n) {
345
345
  return n !== null && typeof n == "object" && n.constructor === Object;
346
346
  }
347
- function pe(n) {
347
+ function ke(n) {
348
348
  if (n === null)
349
- return p.ERROR;
350
- const e = n.toUpperCase(), t = p[e];
351
- return t || t === 0 ? t : p.ERROR;
349
+ return k.ERROR;
350
+ const e = n.toUpperCase(), t = k[e];
351
+ return t || t === 0 ? t : k.ERROR;
352
352
  }
353
- const me = () => {
353
+ const ve = () => {
354
354
  let n = "false";
355
355
  return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
356
356
  };
357
- class ye {
357
+ class _e {
358
358
  constructor(e) {
359
- this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = fe(this.handleScroll.bind(this), 250), this.initializeEventListener();
359
+ 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();
360
360
  }
361
361
  initializeEventListener() {
362
362
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -404,10 +404,13 @@ class ye {
404
404
  this.send(), this.milestones = this.milestones.filter((s) => s !== i);
405
405
  });
406
406
  }
407
+ destroy() {
408
+ window.removeEventListener("scroll", this.debouncedHandleScroll);
409
+ }
407
410
  }
408
- const T = class T {
409
- constructor(e, t, i = d()) {
410
- this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new ye(e), se(this), V(this);
411
+ const R = class R {
412
+ constructor(e, t, i = f()) {
413
+ this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), ce(this), Z(this);
411
414
  }
412
415
  isBrowserSupported() {
413
416
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -431,7 +434,7 @@ const T = class T {
431
434
  const e = (t) => {
432
435
  t = t || window.event, this.captureEvent(t);
433
436
  };
434
- y(document, "submit", e, !1, !0), y(document, "change", e, !1, !0), y(document, "click", e, !1, !0), y(document, "visibilitychange", e, !1, !0), y(document, "scroll", e, !1, !0), y(window, "popstate", e, !1, !0);
437
+ 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);
435
438
  }
436
439
  isPageRefresh() {
437
440
  if ("PerformanceNavigationTiming" in window) {
@@ -444,61 +447,61 @@ const T = class T {
444
447
  captureEvent(e) {
445
448
  var i, s;
446
449
  let t = this.getEventTarget(e);
447
- if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
450
+ if (G(t) && (t = t.parentNode || null), e.type === "scroll")
448
451
  return (i = this.scrollDepth) == null || i.track(), !0;
449
452
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
450
453
  return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
451
- if (t && ue(t, e)) {
454
+ if (t && ge(t, e)) {
452
455
  const r = [t];
453
456
  let o = t;
454
- for (; o.parentNode && !f(o, "body"); ) {
455
- if (O(o.parentNode)) {
457
+ for (; o.parentNode && !y(o, "body"); ) {
458
+ if (z(o.parentNode)) {
456
459
  r.push(o.parentNode.host), o = o.parentNode.host;
457
460
  continue;
458
461
  }
459
462
  r.push(o.parentNode), o = o.parentNode;
460
463
  }
461
- const c = [];
462
- let l, a = !1;
463
- if (g(r, (k) => {
464
- const Z = L(k);
465
- k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = Z && E(l) && l);
466
- const Y = A(k).split(" ");
467
- _(Y, "ph-no-capture") && (a = !0), c.push(
464
+ const a = [];
465
+ let l, c = !1;
466
+ if (w(r, (p) => {
467
+ const _ = M(p);
468
+ p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && C(l) && l);
469
+ const u = x(p).split(" ");
470
+ S(u, "ph-no-capture") && (c = !0), a.push(
468
471
  this.getPropertiesFromElement(
469
- k,
472
+ p,
470
473
  this.options.maskAllElementAttributes ?? !1,
471
474
  this.options.maskAllText ?? !1
472
475
  )
473
476
  );
474
- }), this.options.maskAllText || (c[0].$el_text = D(t)), l && (c[0].attr__href = l), a)
477
+ }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
475
478
  return !1;
476
- const h = re(
479
+ const d = le(
477
480
  this.getDefaultProperties(e.type),
478
481
  {
479
- $elements: c
482
+ $elements: a
480
483
  },
481
484
  this.getCustomProperties(r)
482
485
  );
483
- return this.client.track("$autocapture", h), !0;
486
+ return this.client.track("$autocapture", d), !0;
484
487
  }
485
488
  }
486
489
  getCustomProperties(e) {
487
490
  const t = {};
488
- return g(this.customProperties, (i) => {
489
- g(i.event_selectors, (s) => {
491
+ return w(this.customProperties, (i) => {
492
+ w(i.event_selectors, (s) => {
490
493
  const r = document.querySelectorAll(s);
491
- g(r, (o) => {
492
- _(e, o) && L(o) && (t[i.name] = this.extractCustomPropertyValue(i));
494
+ w(r, (o) => {
495
+ S(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
493
496
  });
494
497
  });
495
498
  }), t;
496
499
  }
497
500
  extractCustomPropertyValue(e) {
498
501
  const t = [];
499
- return g(document.querySelectorAll(e.css_selector), function(i) {
502
+ return w(document.querySelectorAll(e.css_selector), function(i) {
500
503
  let s;
501
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), E(s) && t.push(s);
504
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), C(s) && t.push(s);
502
505
  }), t.join(", ");
503
506
  }
504
507
  getEventTarget(e) {
@@ -509,17 +512,17 @@ const T = class T {
509
512
  const s = e.tagName.toLowerCase(), r = {
510
513
  tag_name: s
511
514
  };
512
- b.indexOf(s) > -1 && !i && (r.$el_text = D(e));
513
- const o = A(e);
514
- o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
515
- return h !== "";
516
- })), g(e.attributes, function(h) {
517
- W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && E(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
515
+ $.indexOf(s) > -1 && !i && (r.$el_text = V(e));
516
+ const o = x(e);
517
+ o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
518
+ return d !== "";
519
+ })), w(e.attributes, function(d) {
520
+ j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && C(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
518
521
  });
519
- let c = 1, l = 1, a = e;
520
- for (; a = this.previousElementSibling(a); )
521
- c++, a.tagName === e.tagName && l++;
522
- return r.nth_child = c, r.nth_of_type = l, r;
522
+ let a = 1, l = 1, c = e;
523
+ for (; c = this.previousElementSibling(c); )
524
+ a++, c.tagName === e.tagName && l++;
525
+ return r.nth_child = a, r.nth_of_type = l, r;
523
526
  }
524
527
  previousElementSibling(e) {
525
528
  if (e.previousElementSibling)
@@ -528,7 +531,7 @@ const T = class T {
528
531
  let t = e;
529
532
  do
530
533
  t = t.previousSibling;
531
- while (t && !J(t));
534
+ while (t && !Y(t));
532
535
  return t;
533
536
  }
534
537
  }
@@ -550,9 +553,9 @@ const T = class T {
550
553
  return s % t < i;
551
554
  }
552
555
  };
553
- T.FORCE_CAPTURE_ATTR = "data-um-force-capture", T.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
554
- let $ = T;
555
- class we {
556
+ R.FORCE_CAPTURE_ATTR = "data-um-force-capture", R.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
557
+ let H = R;
558
+ class be {
556
559
  constructor(e) {
557
560
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
558
561
  }
@@ -581,8 +584,8 @@ class we {
581
584
  }));
582
585
  }
583
586
  }
584
- class ke {
585
- constructor(e, t, i = d()) {
587
+ class Ee {
588
+ constructor(e, t, i = f()) {
586
589
  this.trackingHost = e, this.logger = i, this.config = t;
587
590
  }
588
591
  async send(e) {
@@ -593,14 +596,14 @@ class ke {
593
596
  throw new Error("Failed to queue events via Beacon API");
594
597
  }
595
598
  constructUrl(e) {
596
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
597
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
599
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
600
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
598
601
  }
599
602
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
600
603
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
601
604
  }
602
- class z {
603
- constructor(e, t, i = d()) {
605
+ class Q {
606
+ constructor(e, t, i = f()) {
604
607
  this.trackingHost = e, this.logger = i, this.config = t;
605
608
  }
606
609
  async send(e) {
@@ -617,8 +620,8 @@ class z {
617
620
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
618
621
  }
619
622
  constructUrl(e) {
620
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
621
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
623
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
624
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
622
625
  }
623
626
  getCustomHeaders() {
624
627
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -627,17 +630,17 @@ class z {
627
630
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
628
631
  }
629
632
  }
630
- class ve {
631
- constructor(e, t, i = d()) {
633
+ class Pe {
634
+ constructor(e, t, i = f()) {
632
635
  this.trackingHost = e, this.logger = i, this.config = t;
633
636
  }
634
637
  send(e) {
635
638
  return new Promise((t, i) => {
636
639
  const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
637
640
  s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
638
- const c = this.getCustomHeaders();
639
- Object.keys(c).forEach((l) => {
640
- s.setRequestHeader(l, c[l]);
641
+ const a = this.getCustomHeaders();
642
+ Object.keys(a).forEach((l) => {
643
+ s.setRequestHeader(l, a[l]);
641
644
  }), s.onload = () => {
642
645
  s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
643
646
  }, s.onerror = () => {
@@ -646,8 +649,8 @@ class ve {
646
649
  });
647
650
  }
648
651
  constructUrl(e) {
649
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
650
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
652
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
653
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
651
654
  }
652
655
  getCustomHeaders() {
653
656
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -656,9 +659,9 @@ class ve {
656
659
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
657
660
  }
658
661
  }
659
- class K {
662
+ class ee {
660
663
  constructor(e, t) {
661
- this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
664
+ this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
662
665
  }
663
666
  set(e, t) {
664
667
  this.storage[e] = t, this.save();
@@ -673,7 +676,7 @@ class K {
673
676
  this.storage = {}, this.save();
674
677
  }
675
678
  save() {
676
- if (!u()) {
679
+ if (!h()) {
677
680
  this.logger.warn("localStorage is not available in this environment");
678
681
  return;
679
682
  }
@@ -684,7 +687,7 @@ class K {
684
687
  }
685
688
  }
686
689
  load() {
687
- if (!u()) {
690
+ if (!h()) {
688
691
  this.logger.warn("localStorage is not available in this environment");
689
692
  return;
690
693
  }
@@ -696,7 +699,7 @@ class K {
696
699
  }
697
700
  }
698
701
  }
699
- class _e {
702
+ class Ae {
700
703
  constructor() {
701
704
  this.storage = {};
702
705
  }
@@ -715,56 +718,56 @@ class _e {
715
718
  this.storage = {};
716
719
  }
717
720
  }
718
- class B {
721
+ class W {
719
722
  // Default to true for server-side
720
- constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = d(), c = "default") {
721
- this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new K(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
723
+ constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
724
+ this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new ee(`offline_queue_${a}`), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
722
725
  }
723
726
  add(e) {
724
727
  const t = { payload: e, retries: 0, timestamp: Date.now() };
725
- this.queue.push(t), u() ? this.saveQueueToStorage() : this.processBatch();
728
+ this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
726
729
  }
727
730
  initNetworkListeners() {
728
- u() && (window.addEventListener("online", () => {
731
+ h() && (window.addEventListener("online", () => {
729
732
  this.isOnline = !0, this.processBatch();
730
733
  }), window.addEventListener("offline", () => {
731
734
  this.isOnline = !1;
732
735
  }));
733
736
  }
734
737
  scheduleBatch() {
735
- u() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
738
+ h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
736
739
  }
737
740
  async processBatch() {
738
- if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
741
+ if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
739
742
  this.processing = !0;
740
743
  const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
741
744
  try {
742
- await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
745
+ await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
743
746
  } catch (i) {
744
747
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
745
748
  }
746
749
  this.processing = !1;
747
750
  }
748
- u() && this.scheduleBatch();
751
+ h() && this.scheduleBatch();
749
752
  }
750
753
  async handleBatchFailure(e) {
751
754
  for (const t of e)
752
755
  t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error("Max retries reached, discarding payload", t.payload);
753
- u() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
756
+ h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
754
757
  }
755
758
  loadQueueFromStorage() {
756
- if (u()) {
759
+ if (h()) {
757
760
  const e = this.persistence.get("queue");
758
761
  e && (this.queue = JSON.parse(e));
759
762
  }
760
763
  }
761
764
  saveQueueToStorage() {
762
- u() && this.persistence.set("queue", JSON.stringify(this.queue));
765
+ h() && this.persistence.set("queue", JSON.stringify(this.queue));
763
766
  }
764
767
  }
765
- class be {
768
+ class Se {
766
769
  constructor(e) {
767
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
770
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
768
771
  }
769
772
  initializeEventListener() {
770
773
  document.addEventListener("click", this.handleClick.bind(this));
@@ -784,8 +787,8 @@ class be {
784
787
  const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
785
788
  this.clicks.every((r, o) => {
786
789
  if (o === 0) return !0;
787
- const c = this.clicks[o - 1];
788
- return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
790
+ const a = this.clicks[o - 1];
791
+ return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
789
792
  }) && this.sendRageClickEvent(i);
790
793
  }
791
794
  sendRageClickEvent(e) {
@@ -796,8 +799,8 @@ class be {
796
799
  }), this.clicks = [];
797
800
  }
798
801
  }
799
- class Ee {
800
- constructor(e, t, i = d()) {
802
+ class $e {
803
+ constructor(e, t, i = f()) {
801
804
  this.trackingHost = e, this.logger = i, this.config = t;
802
805
  }
803
806
  async send(e) {
@@ -812,16 +815,16 @@ class Ee {
812
815
  }
813
816
  };
814
817
  return new Promise((r, o) => {
815
- const c = (void 0)(s, (l) => {
816
- l.on("data", (a) => {
818
+ const a = (void 0)(s, (l) => {
819
+ l.on("data", (c) => {
817
820
  }), l.on("end", () => {
818
- const a = l.statusCode || 0;
819
- a >= 200 && a < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${a}`));
821
+ const c = l.statusCode || 0;
822
+ c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
820
823
  });
821
824
  });
822
- c.on("error", (l) => {
825
+ a.on("error", (l) => {
823
826
  o(l);
824
- }), c.write(JSON.stringify(e)), c.end();
827
+ }), a.write(JSON.stringify(e)), a.end();
825
828
  });
826
829
  }
827
830
  constructUrl(e) {
@@ -832,7 +835,7 @@ class Ee {
832
835
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
833
836
  }
834
837
  }
835
- class w {
838
+ class P {
836
839
  constructor(e, t = "all", i = {}) {
837
840
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
838
841
  }
@@ -847,18 +850,18 @@ class w {
847
850
  }
848
851
  handleFormSubmit(e) {
849
852
  const t = e.target, i = this._getFormDetails(t);
850
- this.instance.track("$form", U(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
853
+ this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
851
854
  }
852
855
  trackFieldChanges(e) {
853
856
  e.querySelectorAll("input, select, textarea").forEach((i) => {
854
857
  i.addEventListener("change", (s) => {
855
858
  const r = this._getFieldProps(s.target, 0);
856
- this.instance.track("$form_field_change", U(r));
859
+ this.instance.track("$form_field_change", q(r));
857
860
  });
858
861
  });
859
862
  }
860
863
  static getInstance(e, t = "all", i = {}) {
861
- return w.instance || (w.instance = new w(e, t, i)), w.instance;
864
+ return P.instance || (P.instance = new P(e, t, i)), P.instance;
862
865
  }
863
866
  _getFormDetails(e) {
864
867
  const t = {
@@ -870,8 +873,8 @@ class w {
870
873
  form_attributes: this._getElementAttributes(e)
871
874
  }, i = e.querySelectorAll("input, select, textarea");
872
875
  return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
873
- const c = this._getFieldProps(r, o);
874
- Object.assign(t, c);
876
+ const a = this._getFieldProps(r, o);
877
+ Object.assign(t, a);
875
878
  }), t;
876
879
  }
877
880
  _getFieldProps(e, t) {
@@ -946,9 +949,9 @@ class w {
946
949
  return e.slice(t, i + 1);
947
950
  }
948
951
  }
949
- class S {
952
+ class N {
950
953
  constructor(e) {
951
- this.config = this.mergeConfig(e, q), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new B(
954
+ this.config = this.mergeConfig(e, X), this.logger = f(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new W(
952
955
  this.transport,
953
956
  this.config.maxSendAttempts || 3,
954
957
  this.config.minSendTimeout || 1e3,
@@ -957,16 +960,16 @@ class S {
957
960
  // Reduced interval to .2 second
958
961
  this.logger,
959
962
  this.namespace
960
- ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
963
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
961
964
  }
962
965
  initializeBrowserFeatures() {
963
- if (this.cookieManager = new j(this.config.cookieDomain), this.config.autocapture && $.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new $(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
966
+ 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) {
964
967
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
965
- this.formTracking = w.getInstance(this, e || "none", {
968
+ this.formTracking = P.getInstance(this, e || "none", {
966
969
  trackFieldChanges: !1
967
970
  });
968
971
  }
969
- this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
972
+ this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Se(this)), this.setupPageLeaveTracking();
970
973
  }
971
974
  /**
972
975
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -977,11 +980,11 @@ class S {
977
980
  const i = JSON.parse(JSON.stringify(e));
978
981
  let s = { ...t, ...i };
979
982
  return Object.keys(t).forEach((r) => {
980
- v(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
983
+ A(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
981
984
  }), s;
982
985
  }
983
986
  init(e) {
984
- this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new B(
987
+ this.config = { ...this.config, ...e }, this.logger = f(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new W(
985
988
  this.transport,
986
989
  this.config.maxSendAttempts || 3,
987
990
  this.config.minSendTimeout || 1e3,
@@ -990,21 +993,21 @@ class S {
990
993
  // Reduced interval to .25 second
991
994
  this.logger,
992
995
  this.namespace
993
- ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
996
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
994
997
  }
995
998
  manageCrossDomainLinking() {
996
999
  if (!this.config.crossDomainLinking || !this.config.domains)
997
1000
  return;
998
1001
  const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
999
1002
  document.addEventListener("click", (i) => {
1000
- var c;
1003
+ var a;
1001
1004
  const s = this.findClosestLink(i.target);
1002
1005
  if (!s) return;
1003
1006
  const r = s.getAttribute("href");
1004
1007
  if (!r || !r.startsWith("http")) return;
1005
1008
  const o = new URL(r);
1006
1009
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1007
- const l = (c = this.cookieManager) == null ? void 0 : c.get(t);
1010
+ const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
1008
1011
  l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
1009
1012
  }
1010
1013
  }), this.logger.debug("Cross-domain linking initialized");
@@ -1016,47 +1019,47 @@ class S {
1016
1019
  }
1017
1020
  initializeTransport(e) {
1018
1021
  const t = "https://events.usermaven.com";
1019
- if (!u())
1020
- return new Ee(e.trackingHost || t, e);
1022
+ if (!h())
1023
+ return new $e(e.trackingHost || t, e);
1021
1024
  const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1022
1025
  if (e.useBeaconApi && r)
1023
- return new ke(e.trackingHost || t, e, this.logger);
1026
+ return new Ee(e.trackingHost || t, e, this.logger);
1024
1027
  if (e.forceUseFetch && s)
1025
- return new z(e.trackingHost || t, e, this.logger);
1028
+ return new Q(e.trackingHost || t, e, this.logger);
1026
1029
  if (i)
1027
- return new ve(e.trackingHost || t, e, this.logger);
1030
+ return new Pe(e.trackingHost || t, e, this.logger);
1028
1031
  if (s)
1029
- return new z(e.trackingHost || t, e, this.logger);
1032
+ return new Q(e.trackingHost || t, e, this.logger);
1030
1033
  throw new Error("No suitable transport method available");
1031
1034
  }
1032
1035
  initializePersistence() {
1033
- return this.config.disableEventPersistence || !u() ? new _e() : new K(`${this.namespace}_${this.config.key}`, this.logger);
1036
+ return this.config.disableEventPersistence || !h() ? new Ae() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
1034
1037
  }
1035
1038
  getOrCreateAnonymousId() {
1036
1039
  var i, s;
1037
- if (!u())
1038
- return x();
1040
+ if (!h())
1041
+ return O();
1039
1042
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1040
1043
  return "";
1041
1044
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1042
1045
  let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1043
1046
  if (!t) {
1044
1047
  if (this.config.crossDomainLinking) {
1045
- const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
1046
- t = c || h || x();
1048
+ const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
1049
+ t = a || d || O();
1047
1050
  }
1048
- t || (t = x());
1051
+ t || (t = O());
1049
1052
  const r = 365 * 10;
1050
1053
  (s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
1051
1054
  }
1052
1055
  return t;
1053
1056
  }
1054
1057
  async id(e, t = !1) {
1055
- if (!v(e))
1058
+ if (!A(e))
1056
1059
  throw new Error("User data must be an object");
1057
- if (e.email && !de(e.email))
1060
+ if (e.email && !me(e.email))
1058
1061
  throw new Error("Invalid email provided");
1059
- if (!e.id || !F(e.id))
1062
+ if (!e.id || !J(e.id))
1060
1063
  throw new Error("User ID must be a string");
1061
1064
  const i = e.id;
1062
1065
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1072,11 +1075,11 @@ class S {
1072
1075
  this.trackInternal(e, t, i);
1073
1076
  }
1074
1077
  trackInternal(e, t, i = !1) {
1075
- if (me()) {
1078
+ if (ve()) {
1076
1079
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1077
1080
  return;
1078
1081
  }
1079
- if (!F(e))
1082
+ if (!J(e))
1080
1083
  throw new Error("Event name must be a string");
1081
1084
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1082
1085
  throw new Error("Event payload must be a non-null object and not an array");
@@ -1092,21 +1095,21 @@ class S {
1092
1095
  }
1093
1096
  }
1094
1097
  rawTrack(e) {
1095
- if (!v(e))
1098
+ if (!A(e))
1096
1099
  throw new Error("Event payload must be an object");
1097
1100
  this.track("raw", e);
1098
1101
  }
1099
1102
  async group(e, t = !1) {
1100
- if (!v(e))
1103
+ if (!A(e))
1101
1104
  throw new Error("Company properties must be an object");
1102
1105
  if (!e.id || !e.name || !e.created_at)
1103
1106
  throw new Error("Company properties must include id, name, and created_at");
1104
1107
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1105
1108
  }
1106
1109
  createEventPayload(e, t) {
1107
- const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1110
+ const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, a = this.persistence.get(`props_${e}`) || {};
1108
1111
  let l = t || {};
1109
- const a = {
1112
+ const c = {
1110
1113
  event_id: "",
1111
1114
  user: {
1112
1115
  anonymous_id: this.anonymousId,
@@ -1122,15 +1125,15 @@ class S {
1122
1125
  event_type: e,
1123
1126
  namespace: this.namespace,
1124
1127
  ...o,
1125
- ...c
1128
+ ...a
1126
1129
  };
1127
1130
  if (e === "$autocapture") {
1128
- const h = this.processAutocaptureAttributes(t || {});
1129
- a.autocapture_attributes = h;
1130
- } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((h) => {
1131
- delete l[h];
1132
- }), a.event_attributes = l);
1133
- return u() && (a.referer = document.referrer, a.url = window.location.href, a.page_title = document.title, a.doc_path = window.location.pathname, a.doc_host = window.location.hostname, a.doc_search = window.location.search, a.screen_resolution = `${window.screen.width}x${window.screen.height}`, a.vp_size = `${window.innerWidth}x${window.innerHeight}`, a.user_agent = navigator.userAgent, a.user_language = navigator.language, a.doc_encoding = document.characterSet, a.utm = this.getUtmParams()), a;
1131
+ const d = this.processAutocaptureAttributes(t || {});
1132
+ c.autocapture_attributes = d;
1133
+ } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1134
+ delete l[d];
1135
+ }), c.event_attributes = l);
1136
+ 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;
1134
1137
  }
1135
1138
  processAutocaptureAttributes(e) {
1136
1139
  let t = {};
@@ -1145,27 +1148,27 @@ class S {
1145
1148
  }
1146
1149
  getThirdPartyIds() {
1147
1150
  const e = {};
1148
- if (u()) {
1151
+ if (h()) {
1149
1152
  const t = this.getCookie("_fbp");
1150
1153
  t && (e.fbp = t);
1151
1154
  }
1152
1155
  return e;
1153
1156
  }
1154
1157
  getUtmParams() {
1155
- const e = {}, t = ge(window.location.search);
1158
+ const e = {}, t = we(window.location.search);
1156
1159
  return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
1157
1160
  t[s] && (e[s.replace("utm_", "")] = t[s]);
1158
1161
  }), e;
1159
1162
  }
1160
1163
  pageview() {
1161
- u() ? this.track("pageview", {
1164
+ h() ? this.track("pageview", {
1162
1165
  url: window.location.href,
1163
1166
  referrer: document.referrer,
1164
1167
  title: document.title
1165
1168
  }, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
1166
1169
  }
1167
1170
  setupPageLeaveTracking() {
1168
- if (!u()) return;
1171
+ if (!h()) return;
1169
1172
  let e = !1, t = !1;
1170
1173
  const i = () => {
1171
1174
  !e && !t && (e = !0, this.track("$pageleave", {
@@ -1200,7 +1203,7 @@ class S {
1200
1203
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1201
1204
  }
1202
1205
  set(e, t) {
1203
- if (!v(e))
1206
+ if (!A(e))
1204
1207
  throw new Error("Properties must be an object");
1205
1208
  const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1206
1209
  if (i) {
@@ -1233,28 +1236,28 @@ class S {
1233
1236
  s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1234
1237
  }
1235
1238
  }
1236
- function X() {
1239
+ function te() {
1237
1240
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1238
1241
  }
1239
- function Pe() {
1240
- return X() ? window.define : void 0;
1242
+ function Ce() {
1243
+ return te() ? window.define : void 0;
1241
1244
  }
1242
- const Ae = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1243
- function C(n) {
1244
- const e = JSON.parse(JSON.stringify(n)), t = I(e), i = { ...q, ...t };
1245
+ const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1246
+ function I(n) {
1247
+ const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
1245
1248
  if (!i.key)
1246
1249
  throw new Error("API key is required!");
1247
1250
  if (!i.trackingHost)
1248
1251
  throw new Error("Tracking host is required!");
1249
- const s = i.key || "", r = `${Ae}${s}`;
1250
- return u() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), u() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new S(i);
1252
+ const s = i.key || "", r = `${Te}${s}`;
1253
+ return h() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
1251
1254
  }
1252
- function $e(n) {
1255
+ function xe(n) {
1253
1256
  var s;
1254
1257
  const e = {
1255
1258
  key: n.getAttribute("data-key") || void 0,
1256
1259
  trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1257
- logLevel: pe(n.getAttribute("data-log-level")),
1260
+ logLevel: ke(n.getAttribute("data-log-level")),
1258
1261
  autocapture: n.getAttribute("data-autocapture") === "true",
1259
1262
  formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
1260
1263
  autoPageview: n.getAttribute("data-auto-pageview") === "true",
@@ -1281,78 +1284,111 @@ function $e(n) {
1281
1284
  maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
1282
1285
  };
1283
1286
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1284
- const t = C(e), i = e.namespace || "usermaven";
1285
- return u() && t.pageview(), Se(i, t), t;
1287
+ const t = I(e), i = e.namespace || "usermaven";
1288
+ return h() && t.pageview(), He(i, t), t;
1286
1289
  }
1287
- function Se(n, e) {
1290
+ function He(n, e) {
1288
1291
  let t = !1;
1289
1292
  const i = [], s = [];
1290
1293
  function r() {
1291
1294
  for (; i.length > 0; ) {
1292
- const a = i.shift();
1293
- a && window[n].apply(null, a);
1295
+ const u = i.shift();
1296
+ if (u) {
1297
+ const g = u[u.length - 1];
1298
+ if (g && typeof g.resolve == "function") {
1299
+ const m = u.pop();
1300
+ try {
1301
+ const b = a.apply(null, u);
1302
+ b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
1303
+ } catch (b) {
1304
+ m.reject(b);
1305
+ }
1306
+ } else
1307
+ try {
1308
+ a.apply(null, u);
1309
+ } catch (m) {
1310
+ console.error("Usermaven: Error processing queued command:", m);
1311
+ }
1312
+ }
1294
1313
  }
1295
1314
  }
1296
1315
  function o() {
1297
- s.forEach((a) => a()), s.length = 0;
1316
+ s.forEach((u) => u()), s.length = 0;
1298
1317
  }
1299
- window[n] = function(...a) {
1300
- const h = a[0];
1301
- if (h === "onLoad") {
1302
- typeof a[1] == "function" && (t ? a[1]() : s.push(a[1]));
1318
+ function a(...u) {
1319
+ const g = u[0];
1320
+ if (g === "onLoad") {
1321
+ typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
1303
1322
  return;
1304
1323
  }
1305
1324
  if (!t) {
1306
- i.push(a);
1325
+ i.push(u);
1307
1326
  return;
1308
1327
  }
1309
- if (typeof e[h] == "function")
1310
- return e[h].apply(e, a.slice(1));
1311
- console.error(`Method ${h} not found on UsermavenClient`);
1312
- };
1313
- const c = `${n}Q`, l = window[c] || [];
1314
- for (window[c] = l, l.push = function(...a) {
1315
- return window[n].apply(null, a), Array.prototype.push.apply(this, a);
1328
+ if (typeof e[g] == "function")
1329
+ return e[g].apply(e, u.slice(1));
1330
+ console.error(`Method ${g} not found on UsermavenClient`);
1331
+ }
1332
+ const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
1333
+ [...l, ...c].forEach((u) => {
1334
+ a[u] = function(...g) {
1335
+ if (!t) {
1336
+ if (l.includes(u))
1337
+ return new Promise((B, m) => {
1338
+ i.push([u, ...g, { resolve: B, reject: m }]);
1339
+ });
1340
+ i.push([u, ...g]);
1341
+ return;
1342
+ }
1343
+ if (typeof e[u] == "function")
1344
+ return e[u].apply(e, g);
1345
+ };
1346
+ }), a.getConfig = function() {
1347
+ return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
1348
+ }, window[n] = a;
1349
+ const p = `${n}Q`, _ = window[p] || [];
1350
+ for (window[p] = _, _.push = function(...u) {
1351
+ return a.apply(null, u), Array.prototype.push.apply(this, u);
1316
1352
  }, setTimeout(() => {
1317
1353
  t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
1318
- }, 0); l.length > 0; ) {
1319
- const a = l.shift();
1320
- a && i.push(a);
1354
+ }, 0); _.length > 0; ) {
1355
+ const u = _.shift();
1356
+ u && i.push(u);
1321
1357
  }
1322
1358
  }
1323
- let M = !1, H = null;
1324
- if (u()) {
1325
- const n = Pe();
1359
+ let K = !1, L = null;
1360
+ if (h()) {
1361
+ const n = Ce();
1326
1362
  n && n("usermaven", [], function() {
1327
1363
  return {
1328
- usermavenClient: C,
1329
- UsermavenClient: S,
1330
- LogLevel: p,
1364
+ usermavenClient: I,
1365
+ UsermavenClient: N,
1366
+ LogLevel: k,
1331
1367
  // Expose the script tag client if it exists
1332
- getScriptTagClient: () => H
1368
+ getScriptTagClient: () => L
1333
1369
  };
1334
- }), typeof window < "u" && (window.usermavenClient = C, window.UsermavenClient = S, window.usermavenScriptTagClient = () => H), function(e, t) {
1370
+ }), typeof window < "u" && (window.usermavenClient = I, window.UsermavenClient = N, window.usermavenScriptTagClient = () => L), function(e, t) {
1335
1371
  const i = e.currentScript;
1336
1372
  function s() {
1337
- return M || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1373
+ return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1338
1374
  }
1339
1375
  function r() {
1340
- s() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(i), M = !0);
1376
+ s() && (console.log("[Usermaven] Auto-initializing from script tag"), L = xe(i), K = !0);
1341
1377
  }
1342
1378
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1343
1379
  }(document, window);
1344
1380
  }
1345
- typeof module < "u" && module.exports && !X() && (module.exports = {
1346
- usermavenClient: C,
1347
- UsermavenClient: S,
1381
+ typeof module < "u" && module.exports && !te() && (module.exports = {
1382
+ usermavenClient: I,
1383
+ UsermavenClient: N,
1348
1384
  Config: void 0,
1349
1385
  UserProps: void 0,
1350
1386
  EventPayload: void 0,
1351
- LogLevel: p,
1387
+ LogLevel: k,
1352
1388
  ClientProperties: void 0
1353
1389
  });
1354
1390
  export {
1355
- p as LogLevel,
1356
- S as UsermavenClient,
1357
- C as usermavenClient
1391
+ k as LogLevel,
1392
+ N as UsermavenClient,
1393
+ I as usermavenClient
1358
1394
  };