@usermaven/sdk-js 1.5.10-rc.111 → 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,5 +1,5 @@
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 ne {
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
+ class se {
3
3
  constructor(e) {
4
4
  this.level = e;
5
5
  }
@@ -16,11 +16,11 @@ class ne {
16
16
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
17
17
  }
18
18
  }
19
- function f(n = 0) {
20
- return new ne(n);
19
+ function p(s = 0) {
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",
@@ -51,20 +51,20 @@ const Z = {
51
51
  maskAllText: !1,
52
52
  maskAllElementAttributes: !1
53
53
  };
54
- class se {
54
+ class ne {
55
55
  constructor(e) {
56
56
  this.domain = e, this.cookieDomain = this.getCookieDomain();
57
57
  }
58
- set(e, t, i = 365, s = !0, r = !1) {
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 = s ? "; 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(";");
66
- for (let s = 0; s < i.length; s++) {
67
- let r = i[s].trim();
66
+ for (let n = 0; n < i.length; n++) {
67
+ let r = i[n].trim();
68
68
  if (r.indexOf(t) === 0)
69
69
  return decodeURIComponent(r.substring(t.length));
70
70
  }
@@ -92,84 +92,84 @@ class se {
92
92
  }
93
93
  extractRootDomain(e) {
94
94
  let t = this.extractHostname(e);
95
- const i = t.split("."), s = i.length;
96
- return s > 2 && (i[s - 1].length == 2 ? (t = i[s - 2] + "." + i[s - 1], i[s - 2].length == 2 && (t = i[s - 3] + "." + t)) : t = i[s - 2] + "." + i[s - 1]), t;
95
+ const i = t.split("."), n = i.length;
96
+ return n > 2 && (i[n - 1].length == 2 ? (t = i[n - 2] + "." + i[n - 1], i[n - 2].length == 2 && (t = i[n - 3] + "." + t)) : t = i[n - 2] + "." + i[n - 1]), t;
97
97
  }
98
98
  extractTopLevelDomain(e) {
99
99
  const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
100
100
  return i ? i[0] : "";
101
101
  }
102
102
  }
103
- const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, $ = ae.forEach, D = {};
104
- function ce(n, e, t) {
105
- if (Array.isArray(n)) {
106
- if ($ && n.forEach === $)
107
- n.forEach(e, t);
108
- else if ("length" in n && n.length === +n.length) {
109
- for (let i = 0, s = n.length; i < s; i++)
110
- if (i in n && e.call(t, n[i], i) === D)
103
+ const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, I = ae.forEach, F = {};
104
+ function ce(s, e, t) {
105
+ if (Array.isArray(s)) {
106
+ if (I && s.forEach === I)
107
+ s.forEach(e, t);
108
+ else if ("length" in s && s.length === +s.length) {
109
+ for (let i = 0, n = s.length; i < n; i++)
110
+ if (i in s && e.call(t, s[i], i) === F)
111
111
  return;
112
112
  }
113
113
  }
114
114
  }
115
- const F = function(n) {
116
- return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
117
- }, le = function(n) {
118
- for (const e in n)
119
- typeof n[e] == "function" && (n[e] = n[e].bind(n));
115
+ const v = function(s) {
116
+ return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
117
+ }, le = function(s) {
118
+ for (const e in s)
119
+ typeof s[e] == "function" && (s[e] = s[e].bind(s));
120
120
  };
121
- function w(n, e, t) {
122
- if (n != null) {
123
- if ($ && Array.isArray(n) && n.forEach === $)
124
- n.forEach(e, t);
125
- else if ("length" in n && n.length === +n.length) {
126
- for (let i = 0, s = n.length; i < s; i++)
127
- if (i in n && e.call(t, n[i], i) === D)
121
+ function k(s, e, t) {
122
+ if (s != null) {
123
+ if (I && Array.isArray(s) && s.forEach === I)
124
+ s.forEach(e, t);
125
+ else if ("length" in s && s.length === +s.length) {
126
+ for (let i = 0, n = s.length; i < n; i++)
127
+ if (i in s && e.call(t, s[i], i) === F)
128
128
  return;
129
129
  } else
130
- for (const i in n)
131
- if (oe.call(n, i) && e.call(t, n[i], i) === D)
130
+ for (const i in s)
131
+ if (oe.call(s, i) && e.call(t, s[i], i) === F)
132
132
  return;
133
133
  }
134
134
  }
135
- const ue = function(n, ...e) {
135
+ const ue = function(s, ...e) {
136
136
  return ce(e, function(t) {
137
137
  for (const i in t)
138
- t[i] !== void 0 && (n[i] = t[i]);
139
- }), n;
138
+ t[i] !== void 0 && (s[i] = t[i]);
139
+ }), s;
140
140
  };
141
- function S(n, e) {
142
- return n.indexOf(e) !== -1;
141
+ function $(s, e) {
142
+ return s.indexOf(e) !== -1;
143
143
  }
144
- const he = function(n) {
144
+ const he = function(s) {
145
145
  try {
146
- return /^\s*\bfunction\b/.test(n);
146
+ return /^\s*\bfunction\b/.test(s);
147
147
  } catch {
148
148
  return !1;
149
149
  }
150
- }, de = function(n) {
151
- return n === void 0;
152
- }, E = function() {
153
- const n = function(i, s, r, o, a) {
150
+ }, de = function(s) {
151
+ return s === void 0;
152
+ }, A = function() {
153
+ const s = function(i, n, r, o, a) {
154
154
  if (!i) {
155
- f().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
- i.addEventListener(s, r, !!a);
159
+ i.addEventListener(n, r, !!a);
160
160
  else {
161
- const l = "on" + s, 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
- function e(i, s, r) {
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 = s.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) {
@@ -179,82 +179,82 @@ const he = function(n) {
179
179
  this.returnValue = !1;
180
180
  }, t.stopPropagation = function() {
181
181
  this.cancelBubble = !0;
182
- }, n;
183
- }(), fe = function(n) {
182
+ }, s;
183
+ }(), fe = function(s) {
184
184
  return function(...e) {
185
185
  try {
186
- return n.apply(this, e);
186
+ return s.apply(this, e);
187
187
  } catch (t) {
188
- f().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(n) {
195
- for (const e in n)
196
- typeof n[e] == "function" && (n[e] = fe(n[e]));
194
+ }, G = function(s) {
195
+ for (const e in s)
196
+ typeof s[e] == "function" && (s[e] = fe(s[e]));
197
197
  };
198
- function V(n) {
199
- for (let e in n)
200
- (n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
201
- return n;
198
+ function V(s) {
199
+ for (let e in s)
200
+ (s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
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 f().warn("window is not available"), !1;
207
+ return p().warn("window is not available"), !1;
208
208
  }
209
209
  }
210
- function v(n = 5) {
211
- const e = new Uint8Array(n);
212
- return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
210
+ function E(s = 5) {
211
+ const e = new Uint8Array(s);
212
+ return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, s);
213
213
  }
214
- function ge(n) {
215
- return n.replace(
214
+ function ge(s) {
215
+ return s.replace(
216
216
  /([-_][a-z])/g,
217
217
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
218
218
  );
219
219
  }
220
- function z(n) {
221
- return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(z) : Object.keys(n).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
223
  const i = ge(t);
224
- return e[i] = z(n[t]), e;
224
+ return e[i] = Q(s[t]), e;
225
225
  },
226
226
  {}
227
227
  );
228
228
  }
229
- function x(n) {
230
- switch (typeof n.className) {
229
+ function O(s) {
230
+ switch (typeof s.className) {
231
231
  case "string":
232
- return n.className;
232
+ return s.className;
233
233
  case "object":
234
- return ("baseVal" in n.className ? n.className.baseVal : null) || n.getAttribute("class") || "";
234
+ return ("baseVal" in s.className ? s.className.baseVal : null) || s.getAttribute("class") || "";
235
235
  default:
236
236
  return "";
237
237
  }
238
238
  }
239
- function Q(n) {
239
+ function J(s) {
240
240
  let e = "";
241
- return B(n) && !ee(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
242
- j(t) && t.textContent && (e += F(t.textContent).split(/(\s+)/).filter(T).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
243
- }), F(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(n) {
246
- return !!n && n.nodeType === 1;
245
+ function b(s) {
246
+ return !!s && s.nodeType === 1;
247
247
  }
248
- function y(n, e) {
249
- return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
248
+ function w(s, e) {
249
+ return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
250
250
  }
251
- function j(n) {
252
- return !!n && n.nodeType === 3;
251
+ function j(s) {
252
+ return !!s && s.nodeType === 3;
253
253
  }
254
- function M(n) {
255
- return !!n && n.nodeType === 11;
254
+ function q(s) {
255
+ return !!s && s.nodeType === 11;
256
256
  }
257
- const C = [
257
+ const T = [
258
258
  "a",
259
259
  "button",
260
260
  "form",
@@ -263,35 +263,37 @@ const C = [
263
263
  "textarea",
264
264
  "label"
265
265
  ];
266
- function pe(n, e) {
267
- if (!n || y(n, "html") || !G(n))
266
+ function pe(s, e) {
267
+ var o, a;
268
+ if (!s || w(s, "html") || !b(s))
268
269
  return !1;
269
- let t = n;
270
- for (; t && !y(t, "body"); ) {
270
+ let t = s;
271
+ for (; t && !w(t, "body"); ) {
271
272
  if (t.classList && t.classList.contains("um-no-capture"))
272
273
  return !1;
273
- t.parentNode && M(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 = n; t && !y(t, "body"); ) {
277
- if (t.parentNode && M(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
- const s = window.getComputedStyle(n);
292
- if (s && s.getPropertyValue("cursor") === "pointer" && e.type === "click")
292
+ const n = window.getComputedStyle(s);
293
+ if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
293
294
  return !0;
294
- const r = n.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,18 +305,18 @@ function pe(n, 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 || n.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 B(n) {
310
- for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
311
- const s = x(i).split(" ");
312
- if (S(s, "ph-sensitive") || S(s, "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 (S(x(n).split(" "), "ph-include"))
317
+ if ($(O(s).split(" "), "ph-include"))
316
318
  return !0;
317
- const e = n.type || "";
319
+ const e = s.type || "";
318
320
  if (typeof e == "string")
319
321
  switch (e.toLowerCase()) {
320
322
  case "hidden":
@@ -322,61 +324,89 @@ function B(n) {
322
324
  case "password":
323
325
  return !1;
324
326
  }
325
- const t = n.name || n.id || "";
327
+ const t = s.name || s.id || "";
326
328
  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, "")));
327
329
  }
328
- function ee(n) {
330
+ function ee(s) {
329
331
  const e = ["button", "checkbox", "submit", "reset"];
330
- return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.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 T(n) {
333
- return !(n === null || de(n) || typeof n == "string" && (n = F(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)));
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
- function me(n) {
336
- return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
337
+ function me(s) {
338
+ return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
339
+ }
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;
337
367
  }
338
- function R() {
339
- return v(10);
368
+ function x() {
369
+ return E(10);
340
370
  }
341
- function J(n) {
342
- 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());
371
+ function W(s) {
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(n, e) {
374
+ function we(s, e) {
345
375
  let t;
346
376
  return function(...i) {
347
- const s = () => {
348
- clearTimeout(t), n(...i);
377
+ const n = () => {
378
+ clearTimeout(t), s(...i);
349
379
  };
350
- clearTimeout(t), t = setTimeout(s, e);
380
+ clearTimeout(t), t = setTimeout(n, e);
351
381
  };
352
382
  }
353
- function we(n) {
354
- const e = {}, t = n.replace(/^\?/, "").split("&");
383
+ function ke(s) {
384
+ const e = {}, t = s.replace(/^\?/, "").split("&");
355
385
  for (let i = 0; i < t.length; i++) {
356
- const s = t[i].split("=");
357
- s[0] !== "" && (e[decodeURIComponent(s[0])] = decodeURIComponent(s[1] || ""));
386
+ const n = t[i].split("=");
387
+ n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
358
388
  }
359
389
  return e;
360
390
  }
361
- function L(n) {
362
- return typeof n == "string" || n instanceof String;
391
+ function U(s) {
392
+ return typeof s == "string" || s instanceof String;
363
393
  }
364
- function P(n) {
365
- return n !== null && typeof n == "object" && n.constructor === Object;
394
+ function S(s) {
395
+ return s !== null && typeof s == "object" && s.constructor === Object;
366
396
  }
367
- function ke(n) {
368
- if (n === null)
369
- return k.ERROR;
370
- const e = n.toUpperCase(), t = k[e];
371
- return t || t === 0 ? t : k.ERROR;
397
+ function ve(s) {
398
+ if (s === null)
399
+ return _.ERROR;
400
+ const e = s.toUpperCase(), t = _[e];
401
+ return t || t === 0 ? t : _.ERROR;
372
402
  }
373
- const ve = () => {
374
- let n = "false";
375
- return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
403
+ const be = () => {
404
+ let s = "false";
405
+ return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
376
406
  };
377
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);
@@ -400,8 +430,8 @@ class _e {
400
430
  this.track();
401
431
  }
402
432
  getScrollDepth() {
403
- const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), s = t - e;
404
- return Math.min(100, Math.floor(i / s * 100));
433
+ const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
434
+ return Math.min(100, Math.floor(i / n * 100));
405
435
  }
406
436
  getWindowHeight() {
407
437
  return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
@@ -423,16 +453,16 @@ class _e {
423
453
  this.milestones.filter(
424
454
  (i) => e >= i
425
455
  ).forEach((i) => {
426
- this.send(), this.milestones = this.milestones.filter((s) => s !== i);
456
+ this.send(), this.milestones = this.milestones.filter((n) => n !== i);
427
457
  });
428
458
  }
429
459
  destroy() {
430
460
  window.removeEventListener("scroll", this.debouncedHandleScroll);
431
461
  }
432
462
  }
433
- const I = class I {
434
- constructor(e, t, i = f()) {
435
- this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(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 I = class I {
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) {
@@ -469,65 +499,72 @@ const I = class I {
469
499
  return performance.navigation && performance.navigation.type === 1;
470
500
  }
471
501
  captureEvent(e) {
472
- var i, s;
502
+ var i, n;
473
503
  let t = this.getEventTarget(e);
474
504
  if (j(t) && (t = t.parentNode || null), e.type === "scroll")
475
505
  return (i = this.scrollDepth) == null || i.track(), !0;
476
506
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
477
- return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
478
- if (t && pe(t, e)) {
507
+ return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
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 (M(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(p);
492
- p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && T(l) && l);
493
- const u = x(p).split(" ");
494
- S(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 = Q(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, (s) => {
517
- const r = document.querySelectorAll(s);
518
- w(r, (o) => {
519
- S(e, o) && B(o) && (t[i.name] = this.extractCustomPropertyValue(i));
552
+ return k(this.customProperties, (i) => {
553
+ k(i.event_selectors, (n) => {
554
+ const r = document.querySelectorAll(n);
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
- let s;
530
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), T(s) && t.push(s);
566
+ let 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
  }
@@ -536,20 +573,20 @@ const I = class I {
536
573
  return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
537
574
  }
538
575
  getPropertiesFromElement(e, t, i) {
539
- const s = e.tagName.toLowerCase(), r = {
540
- tag_name: s
576
+ const n = e.tagName.toLowerCase(), r = {
577
+ tag_name: n
541
578
  };
542
- C.indexOf(s) > -1 && !i && (r.$el_text = Q(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 && 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 I = class I {
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
  }
@@ -574,15 +611,15 @@ const I = class I {
574
611
  static enabledForProject(e, t = 10, i = 10) {
575
612
  if (!e)
576
613
  return !1;
577
- let s = 0;
614
+ let n = 0;
578
615
  for (let r = 0; r < e.length; r++)
579
- s += e.charCodeAt(r);
580
- return s % t < i;
616
+ n += e.charCodeAt(r);
617
+ return n % t < i;
581
618
  }
582
619
  };
583
- I.FORCE_CAPTURE_ATTR = "data-um-force-capture", I.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
584
- let H = I;
585
- class be {
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,15 +648,15 @@ class be {
611
648
  }));
612
649
  }
613
650
  }
614
- class Ee {
615
- constructor(e, t, i = f()) {
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) {
619
- const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], {
656
+ const t = this.config.key, i = this.constructUrl(t), n = new Blob([JSON.stringify(e)], {
620
657
  type: "application/json"
621
658
  });
622
- if (navigator.sendBeacon(i, s))
659
+ if (navigator.sendBeacon(i, n))
623
660
  this.logger.debug(
624
661
  `Successfully queued ${e.length} event(s) via Beacon API`
625
662
  );
@@ -627,32 +664,32 @@ 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}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
631
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
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 = f()) {
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) {
641
- const t = this.config.key, i = this.constructUrl(t), s = JSON.stringify(e), r = {
678
+ const t = this.config.key, i = this.constructUrl(t), n = JSON.stringify(e), r = {
642
679
  "Content-Type": "application/json",
643
680
  ...this.getCustomHeaders()
644
681
  }, o = await fetch(i, {
645
682
  method: "POST",
646
683
  headers: r,
647
- body: s
684
+ body: n
648
685
  });
649
686
  if (!o.ok)
650
687
  throw new Error(`HTTP error! status: ${o.status}`);
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}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
655
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?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,27 +698,27 @@ 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 = f()) {
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) {
669
706
  return new Promise((t, i) => {
670
- const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
671
- s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
707
+ const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
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
- s.setRequestHeader(l, a[l]);
675
- }), s.onload = () => {
676
- s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
677
- }, s.onerror = () => {
710
+ Object.keys(a).forEach((c) => {
711
+ n.setRequestHeader(c, a[c]);
712
+ }), n.onload = () => {
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}`));
714
+ }, n.onerror = () => {
678
715
  i(new Error("Network error"));
679
- }, s.send(JSON.stringify(e));
716
+ }, n.send(JSON.stringify(e));
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}` : "", s = h() ? "/api/v1/event" : "/api/v1/s2s/event";
684
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?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.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
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();
@@ -706,19 +743,11 @@ class te {
706
743
  clear() {
707
744
  this.storage = {}, this.save();
708
745
  }
709
- save() {
710
- if (!h()) {
711
- this.logger.warn("localStorage is not available in this environment");
712
- return;
713
- }
714
- try {
715
- localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage));
716
- } catch (e) {
717
- this.logger.error("Error saving to localStorage:", e);
718
- }
746
+ isStorageEnabled() {
747
+ return !this.storageDisabled;
719
748
  }
720
749
  load() {
721
- if (!h()) {
750
+ if (!d()) {
722
751
  this.logger.warn("localStorage is not available in this environment");
723
752
  return;
724
753
  }
@@ -726,11 +755,32 @@ class te {
726
755
  const e = localStorage.getItem(this.prefix + "data");
727
756
  e && (this.storage = JSON.parse(e));
728
757
  } catch (e) {
729
- this.logger.error("Error loading from localStorage:", e);
758
+ this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error loading from localStorage:", e);
759
+ }
760
+ }
761
+ save() {
762
+ if (!d())
763
+ return this.logger.warn("localStorage is not available in this environment"), !1;
764
+ if (this.storageDisabled)
765
+ return !1;
766
+ try {
767
+ return localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage)), !0;
768
+ } catch (e) {
769
+ return this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error saving to localStorage:", e), !1;
730
770
  }
731
771
  }
772
+ isQuotaError(e) {
773
+ const t = e == null ? void 0 : e.name;
774
+ return t === "QuotaExceededError" || t === "NS_ERROR_DOM_QUOTA_REACHED" || (e == null ? void 0 : e.code) === 22 || (e == null ? void 0 : e.code) === 1014;
775
+ }
776
+ logQuotaOnce(e) {
777
+ this.quotaErrorLogged || (this.quotaErrorLogged = !0, this.logger.error(
778
+ "localStorage quota exceeded; persisting disabled. Continuing with in-memory storage only.",
779
+ e
780
+ ));
781
+ }
732
782
  }
733
- class Ae {
783
+ class Se {
734
784
  constructor() {
735
785
  this.storage = {};
736
786
  }
@@ -749,66 +799,119 @@ class Ae {
749
799
  this.storage = {};
750
800
  }
751
801
  }
752
- class K {
753
- // Default to true for server-side
754
- constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
755
- 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 te(
802
+ class X {
803
+ constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = p(), a = "default", c = 1e3, h = 25e5) {
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(
756
805
  `offline_queue_${a}`
757
- ), 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());
758
807
  }
759
808
  add(e) {
760
- const t = { payload: e, retries: 0, timestamp: Date.now() };
761
- this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
809
+ const t = {
810
+ payload: e,
811
+ retries: 0,
812
+ timestamp: Date.now()
813
+ };
814
+ t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), d() ? this.saveQueueToStorage() : this.processBatch();
762
815
  }
763
816
  initNetworkListeners() {
764
- h() && (window.addEventListener("online", () => {
817
+ d() && (window.addEventListener("online", () => {
765
818
  this.isOnline = !0, this.processBatch();
766
819
  }), window.addEventListener("offline", () => {
767
820
  this.isOnline = !1;
768
821
  }));
769
822
  }
770
823
  scheduleBatch() {
771
- h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
824
+ d() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
772
825
  () => this.processBatch(),
773
826
  this.batchInterval
774
827
  ));
775
828
  }
776
829
  async processBatch() {
777
- if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
830
+ if ((!d() || this.isOnline) && !this.processing && this.queue.length > 0) {
778
831
  this.processing = !0;
779
- const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
832
+ const e = this.queue.splice(0, this.batchSize);
833
+ this.totalQueueBytes = Math.max(
834
+ 0,
835
+ this.totalQueueBytes - e.reduce((i, n) => i + (n.bytes || 0), 0)
836
+ );
837
+ const t = e.map((i) => i.payload);
780
838
  try {
781
839
  await this.transport.send(t), this.logger.debug(
782
840
  `Successfully sent batch of ${e.length} payloads`
783
- ), h() && this.saveQueueToStorage();
841
+ ), d() && this.saveQueueToStorage();
784
842
  } catch (i) {
785
843
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
786
844
  }
787
845
  this.processing = !1;
788
846
  }
789
- h() && this.scheduleBatch();
847
+ d() && this.scheduleBatch();
790
848
  }
791
849
  async handleBatchFailure(e) {
792
850
  for (const t of e)
793
- t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
851
+ t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.totalQueueBytes += t.bytes || this.estimateItemBytes(t), this.enforceQueueLimits(), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
794
852
  "Max retries reached, discarding payload",
795
853
  t.payload
796
854
  );
797
- h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
855
+ d() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
856
+ }
857
+ enforceQueueLimits() {
858
+ if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
859
+ const e = this.queue.length - this.maxQueueItems, t = this.queue.splice(0, e);
860
+ this.totalQueueBytes = Math.max(
861
+ 0,
862
+ this.totalQueueBytes - t.reduce((i, n) => i + (n.bytes || 0), 0)
863
+ ), this.logger.warn(
864
+ `Retry queue exceeded ${this.maxQueueItems} items; dropped ${t.length} oldest payload(s)`
865
+ );
866
+ }
867
+ if (this.maxQueueBytes > 0 && this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 0) {
868
+ let e = 0;
869
+ for (; this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 1; ) {
870
+ const t = this.queue.shift();
871
+ t && (this.totalQueueBytes -= t.bytes || this.estimateItemBytes(t), e++);
872
+ }
873
+ this.totalQueueBytes = Math.max(0, this.totalQueueBytes), e > 0 && this.logger.warn(
874
+ `Retry queue exceeded ${this.maxQueueBytes} bytes; dropped ${e} oldest payload(s)`
875
+ );
876
+ }
877
+ }
878
+ estimateItemBytes(e) {
879
+ const t = { ...e };
880
+ delete t.bytes;
881
+ try {
882
+ return JSON.stringify(t).length;
883
+ } catch {
884
+ return 0;
885
+ }
798
886
  }
799
887
  loadQueueFromStorage() {
800
- if (h()) {
888
+ if (d()) {
801
889
  const e = this.persistence.get("queue");
802
- e && (this.queue = JSON.parse(e));
890
+ if (!e) return;
891
+ try {
892
+ const t = JSON.parse(e);
893
+ this.queue = t.map((i) => ({
894
+ ...i,
895
+ bytes: i.bytes || this.estimateItemBytes(i)
896
+ })), this.totalQueueBytes = this.queue.reduce(
897
+ (i, n) => i + (n.bytes || 0),
898
+ 0
899
+ ), this.enforceQueueLimits();
900
+ } catch (t) {
901
+ this.logger.error("Failed to parse stored queue", t), this.queue = [], this.totalQueueBytes = 0;
902
+ }
803
903
  }
804
904
  }
805
905
  saveQueueToStorage() {
806
- h() && this.persistence.set("queue", JSON.stringify(this.queue));
906
+ if (d()) {
907
+ const e = this.queue.map(({ bytes: t, ...i }) => i);
908
+ this.persistence.set("queue", JSON.stringify(e));
909
+ }
807
910
  }
808
911
  }
809
- class Se {
912
+ class Ce {
810
913
  constructor(e) {
811
- 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);
812
915
  }
813
916
  initializeEventListener() {
814
917
  document.addEventListener("click", this.handleClick.bind(this));
@@ -821,8 +924,8 @@ class Se {
821
924
  return !e.closest(".um-no-capture");
822
925
  }
823
926
  click(e, t, i) {
824
- const s = { x: e, y: t, timestamp: i };
825
- this.clicks.push(s), this.clicks = this.clicks.filter(
927
+ const n = { x: e, y: t, timestamp: i };
928
+ this.clicks.push(n), this.clicks = this.clicks.filter(
826
929
  (r) => i - r.timestamp < this.timeWindow
827
930
  ), this.clicks.length >= this.threshold && this.checkRageClick();
828
931
  }
@@ -844,12 +947,12 @@ class Se {
844
947
  }), this.clicks = [];
845
948
  }
846
949
  }
847
- class Ce {
848
- constructor(e, t, i = f()) {
950
+ class $e {
951
+ constructor(e, t, i = p()) {
849
952
  this.trackingHost = e, this.logger = i, this.config = t;
850
953
  }
851
954
  async send(e) {
852
- const t = this.config.key, i = new (void 0)(this.constructUrl(t)), s = {
955
+ const t = this.config.key, i = new (void 0)(this.constructUrl(t)), n = {
853
956
  hostname: i.hostname,
854
957
  port: 443,
855
958
  path: `${i.pathname}${i.search}`,
@@ -860,15 +963,15 @@ class Ce {
860
963
  }
861
964
  };
862
965
  return new Promise((r, o) => {
863
- const a = (void 0)(s, (l) => {
864
- l.on("data", (c) => {
865
- }), l.on("end", () => {
866
- const c = l.statusCode || 0;
867
- 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}`));
868
971
  });
869
972
  });
870
- a.on("error", (l) => {
871
- o(l);
973
+ a.on("error", (c) => {
974
+ o(c);
872
975
  }), a.write(JSON.stringify(e)), a.end();
873
976
  });
874
977
  }
@@ -880,7 +983,7 @@ class Ce {
880
983
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
881
984
  }
882
985
  }
883
- class A {
986
+ class C {
884
987
  constructor(e, t = "all", i = {}) {
885
988
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
886
989
  }
@@ -899,9 +1002,9 @@ class A {
899
1002
  }
900
1003
  trackFieldChanges(e) {
901
1004
  e.querySelectorAll("input, select, textarea").forEach((i) => {
902
- i.addEventListener("change", (s) => {
1005
+ i.addEventListener("change", (n) => {
903
1006
  const r = this._getFieldProps(
904
- s.target
1007
+ n.target
905
1008
  );
906
1009
  this.instance.track(
907
1010
  "$form_field_change",
@@ -915,7 +1018,7 @@ class A {
915
1018
  });
916
1019
  }
917
1020
  static getInstance(e, t = "all", i = {}) {
918
- return A.instance || (A.instance = new A(e, t, i)), A.instance;
1021
+ return C.instance || (C.instance = new C(e, t, i)), C.instance;
919
1022
  }
920
1023
  _getFormDetails(e) {
921
1024
  const t = {
@@ -963,8 +1066,8 @@ class A {
963
1066
  getSafeText(e) {
964
1067
  let t = "";
965
1068
  return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
966
- (s) => s.nodeType === Node.TEXT_NODE
967
- ).map((s) => s.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
1069
+ (n) => n.nodeType === Node.TEXT_NODE
1070
+ ).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
968
1071
  }
969
1072
  _scrubPotentiallySensitiveValues(e) {
970
1073
  return this._shouldCaptureValue(e) ? e : "<redacted>";
@@ -982,7 +1085,7 @@ class A {
982
1085
  if (typeof String.prototype.trim == "function")
983
1086
  return e.trim();
984
1087
  let t = 0, i = e.length - 1;
985
- const s = [
1088
+ const n = [
986
1089
  " ",
987
1090
  `
988
1091
  `,
@@ -1009,16 +1112,16 @@ class A {
1009
1112
  " ",
1010
1113
  " "
1011
1114
  ].join("");
1012
- for (; t <= i && s.indexOf(e[t]) > -1; )
1115
+ for (; t <= i && n.indexOf(e[t]) > -1; )
1013
1116
  t++;
1014
- for (; i >= t && s.indexOf(e[i]) > -1; )
1117
+ for (; i >= t && n.indexOf(e[i]) > -1; )
1015
1118
  i--;
1016
1119
  return e.slice(t, i + 1);
1017
1120
  }
1018
1121
  }
1019
- class N {
1122
+ class R {
1020
1123
  constructor(e) {
1021
- this.config = this.mergeConfig(e, Z), this.logger = f(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(
1022
1125
  this.transport,
1023
1126
  this.config.maxSendAttempts || 3,
1024
1127
  this.config.minSendTimeout || 1e3,
@@ -1027,14 +1130,14 @@ class N {
1027
1130
  // Reduced interval to .2 second
1028
1131
  this.logger,
1029
1132
  this.namespace
1030
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1133
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1031
1134
  `Usermaven client initialized for namespace: ${this.namespace}`
1032
1135
  );
1033
1136
  }
1034
1137
  initializeBrowserFeatures() {
1035
- if (this.cookieManager = new se(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) {
1036
1139
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
1037
- this.formTracking = A.getInstance(
1140
+ this.formTracking = C.getInstance(
1038
1141
  this,
1039
1142
  e || "none",
1040
1143
  {
@@ -1042,7 +1145,7 @@ class N {
1042
1145
  }
1043
1146
  );
1044
1147
  }
1045
- this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Se(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();
1046
1149
  }
1047
1150
  /**
1048
1151
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -1051,13 +1154,13 @@ class N {
1051
1154
  */
1052
1155
  mergeConfig(e, t) {
1053
1156
  const i = JSON.parse(JSON.stringify(e));
1054
- let s = { ...t, ...i };
1157
+ let n = { ...t, ...i };
1055
1158
  return Object.keys(t).forEach((r) => {
1056
- P(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
1057
- }), s;
1159
+ S(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
1160
+ }), n;
1058
1161
  }
1059
1162
  init(e) {
1060
- 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 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(
1061
1164
  this.transport,
1062
1165
  this.config.maxSendAttempts || 3,
1063
1166
  this.config.minSendTimeout || 1e3,
@@ -1066,7 +1169,7 @@ class N {
1066
1169
  // Reduced interval to .25 second
1067
1170
  this.logger,
1068
1171
  this.namespace
1069
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1172
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1070
1173
  `Usermaven client reinitialized for namespace: ${this.namespace}`
1071
1174
  );
1072
1175
  }
@@ -1076,14 +1179,14 @@ class N {
1076
1179
  const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1077
1180
  document.addEventListener("click", (i) => {
1078
1181
  var a;
1079
- const s = this.findClosestLink(i.target);
1080
- if (!s) return;
1081
- const r = s.getAttribute("href");
1182
+ const n = this.findClosestLink(i.target);
1183
+ if (!n) return;
1184
+ const r = n.getAttribute("href");
1082
1185
  if (!r || !r.startsWith("http")) return;
1083
1186
  const o = new URL(r);
1084
1187
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1085
- const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
1086
- l && (o.searchParams.append("_um", l), s.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()));
1087
1190
  }
1088
1191
  }), this.logger.debug("Cross-domain linking initialized");
1089
1192
  }
@@ -1094,29 +1197,29 @@ class N {
1094
1197
  }
1095
1198
  initializeTransport(e) {
1096
1199
  const t = "https://events.usermaven.com";
1097
- if (!h())
1098
- return new Ce(e.trackingHost || t, e);
1099
- const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1200
+ if (!d())
1201
+ return new $e(e.trackingHost || t, e);
1202
+ const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1100
1203
  if (e.useBeaconApi && r)
1101
- return new Ee(
1204
+ return new Pe(
1102
1205
  e.trackingHost || t,
1103
1206
  e,
1104
1207
  this.logger
1105
1208
  );
1106
- if (e.forceUseFetch && s)
1107
- return new W(
1209
+ if (e.forceUseFetch && n)
1210
+ return new K(
1108
1211
  e.trackingHost || t,
1109
1212
  e,
1110
1213
  this.logger
1111
1214
  );
1112
1215
  if (i)
1113
- return new Pe(
1216
+ return new Ae(
1114
1217
  e.trackingHost || t,
1115
1218
  e,
1116
1219
  this.logger
1117
1220
  );
1118
- if (s)
1119
- return new W(
1221
+ if (n)
1222
+ return new K(
1120
1223
  e.trackingHost || t,
1121
1224
  e,
1122
1225
  this.logger
@@ -1124,27 +1227,27 @@ class N {
1124
1227
  throw new Error("No suitable transport method available");
1125
1228
  }
1126
1229
  initializePersistence() {
1127
- return this.config.disableEventPersistence || !h() ? new Ae() : new te(
1230
+ return this.config.disableEventPersistence || !d() ? new Se() : new te(
1128
1231
  `${this.namespace}_${this.config.key}`,
1129
1232
  this.logger
1130
1233
  );
1131
1234
  }
1132
1235
  getOrCreateAnonymousId() {
1133
- var i, s;
1134
- if (!h())
1135
- return R();
1236
+ var i, n;
1237
+ if (!d())
1238
+ return x();
1136
1239
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1137
1240
  return "";
1138
1241
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1139
1242
  let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1140
1243
  if (!t) {
1141
1244
  if (this.config.crossDomainLinking) {
1142
- const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
1143
- 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();
1144
1247
  }
1145
- t || (t = R());
1248
+ t || (t = x());
1146
1249
  const r = 365 * 10;
1147
- (s = this.cookieManager) == null || s.set(
1250
+ (n = this.cookieManager) == null || n.set(
1148
1251
  e,
1149
1252
  t,
1150
1253
  r,
@@ -1155,19 +1258,19 @@ class N {
1155
1258
  return t;
1156
1259
  }
1157
1260
  async id(e, t = !1) {
1158
- if (!P(e))
1261
+ if (!S(e))
1159
1262
  throw new Error("User data must be an object");
1160
- if (e.email && !J(e.email))
1263
+ if (e.email && !W(e.email))
1161
1264
  throw new Error("Invalid email provided");
1162
- if (!e.id || !L(e.id))
1265
+ if (!e.id || !U(e.id))
1163
1266
  throw new Error("User ID must be a string");
1164
1267
  const i = e.id;
1165
1268
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
1166
- const s = {
1269
+ const n = {
1167
1270
  ...e,
1168
1271
  anonymous_id: this.anonymousId
1169
1272
  };
1170
- await this.track("user_identify", s);
1273
+ await this.track("user_identify", n);
1171
1274
  }
1172
1275
  this.logger.info("User identified:", e);
1173
1276
  }
@@ -1175,28 +1278,28 @@ class N {
1175
1278
  this.trackInternal(e, t, i);
1176
1279
  }
1177
1280
  lead(e, t = !1) {
1178
- if (!P(e))
1281
+ if (!S(e))
1179
1282
  throw new Error(
1180
1283
  "Lead payload must be a non-null object and not an array"
1181
1284
  );
1182
1285
  const i = e.email;
1183
- if (!L(i)) {
1286
+ if (!U(i)) {
1184
1287
  this.logger.error("Lead event requires a valid email attribute");
1185
1288
  return;
1186
1289
  }
1187
- const s = i.trim();
1188
- if (!s || !J(s)) {
1290
+ const n = i.trim();
1291
+ if (!n || !W(n)) {
1189
1292
  this.logger.error("Lead event requires a valid email attribute");
1190
1293
  return;
1191
1294
  }
1192
- e.email = s, this.track("lead", e, t);
1295
+ e.email = n, this.track("lead", e, t);
1193
1296
  }
1194
1297
  trackInternal(e, t, i = !1) {
1195
- if (ve()) {
1298
+ if (be()) {
1196
1299
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1197
1300
  return;
1198
1301
  }
1199
- if (!L(e))
1302
+ if (!U(e))
1200
1303
  throw new Error("Event name must be a string");
1201
1304
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1202
1305
  throw new Error(
@@ -1214,12 +1317,12 @@ class N {
1214
1317
  }
1215
1318
  }
1216
1319
  rawTrack(e) {
1217
- if (!P(e))
1320
+ if (!S(e))
1218
1321
  throw new Error("Event payload must be an object");
1219
1322
  this.track("raw", e);
1220
1323
  }
1221
1324
  async group(e, t = !1) {
1222
- if (!P(e))
1325
+ if (!S(e))
1223
1326
  throw new Error("Company properties must be an object");
1224
1327
  if (!e.id || !e.name || !e.created_at)
1225
1328
  throw new Error(
@@ -1228,16 +1331,16 @@ class N {
1228
1331
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1229
1332
  }
1230
1333
  createEventPayload(e, t) {
1231
- 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}`) || {};
1232
- let l = t || {};
1233
- const c = {
1234
- 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(),
1235
1338
  user: {
1236
1339
  anonymous_id: this.anonymousId,
1237
- id: r,
1238
- ...i
1340
+ id: a,
1341
+ ...r
1239
1342
  },
1240
- ...s && { company: s },
1343
+ ...o && { company: o },
1241
1344
  ids: this.getThirdPartyIds(),
1242
1345
  utc_time: (/* @__PURE__ */ new Date()).toISOString(),
1243
1346
  local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
@@ -1245,18 +1348,18 @@ class N {
1245
1348
  src: "usermaven",
1246
1349
  event_type: e,
1247
1350
  namespace: this.namespace,
1248
- ...o,
1249
- ...a
1351
+ ...c,
1352
+ ...h
1250
1353
  };
1251
1354
  if (e === "$autocapture") {
1252
- const d = this.processAutocaptureAttributes(
1355
+ const g = this.processAutocaptureAttributes(
1253
1356
  t || {}
1254
1357
  );
1255
- c.autocapture_attributes = d;
1256
- } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1257
- delete l[d];
1258
- }), c.event_attributes = l);
1259
- 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;
1260
1363
  }
1261
1364
  processAutocaptureAttributes(e) {
1262
1365
  let t = {};
@@ -1269,8 +1372,8 @@ class N {
1269
1372
  "$referrer",
1270
1373
  "$referring_domain",
1271
1374
  "$elements"
1272
- ].forEach((s) => {
1273
- delete t[s];
1375
+ ].forEach((n) => {
1376
+ delete t[n];
1274
1377
  }), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
1275
1378
  }
1276
1379
  getCookie(e) {
@@ -1279,26 +1382,26 @@ class N {
1279
1382
  }
1280
1383
  getThirdPartyIds() {
1281
1384
  const e = {};
1282
- if (h()) {
1385
+ if (d()) {
1283
1386
  const t = this.getCookie("_fbp");
1284
1387
  t && (e.fbp = t);
1285
1388
  }
1286
1389
  return e;
1287
1390
  }
1288
1391
  getUtmParams() {
1289
- const e = {}, t = we(window.location.search);
1392
+ const e = {}, t = ke(window.location.search);
1290
1393
  return [
1291
1394
  "utm_source",
1292
1395
  "utm_medium",
1293
1396
  "utm_campaign",
1294
1397
  "utm_term",
1295
1398
  "utm_content"
1296
- ].forEach((s) => {
1297
- t[s] && (e[s.replace("utm_", "")] = t[s]);
1399
+ ].forEach((n) => {
1400
+ t[n] && (e[n.replace("utm_", "")] = t[n]);
1298
1401
  }), e;
1299
1402
  }
1300
1403
  pageview() {
1301
- h() ? this.track(
1404
+ d() ? this.track(
1302
1405
  "pageview",
1303
1406
  {
1304
1407
  url: window.location.href,
@@ -1311,7 +1414,7 @@ class N {
1311
1414
  );
1312
1415
  }
1313
1416
  setupPageLeaveTracking() {
1314
- if (!h()) return;
1417
+ if (!d()) return;
1315
1418
  let e = !1, t = !1;
1316
1419
  const i = () => {
1317
1420
  !e && !t && (e = !0, this.track("$pageleave", {
@@ -1327,9 +1430,9 @@ class N {
1327
1430
  }), document.addEventListener("visibilitychange", () => {
1328
1431
  document.visibilityState === "hidden" && !t && i();
1329
1432
  });
1330
- const s = history.pushState;
1433
+ const n = history.pushState;
1331
1434
  history.pushState = function() {
1332
- return i(), s.apply(this, arguments);
1435
+ return i(), n.apply(this, arguments);
1333
1436
  }, window.addEventListener("popstate", i);
1334
1437
  }
1335
1438
  getConfig() {
@@ -1349,9 +1452,9 @@ class N {
1349
1452
  });
1350
1453
  }
1351
1454
  set(e, t) {
1352
- if (!P(e))
1455
+ if (!S(e))
1353
1456
  throw new Error("Properties must be an object");
1354
- const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1457
+ const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1355
1458
  if (i) {
1356
1459
  let r = this.persistence.get(`props_${i}`) || {};
1357
1460
  r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
@@ -1359,10 +1462,10 @@ class N {
1359
1462
  let r = this.persistence.get("global_props") || {};
1360
1463
  r = { ...r, ...e }, this.persistence.set("global_props", r);
1361
1464
  }
1362
- s && this.persistence.save(), this.logger.debug("Properties set", {
1465
+ n && this.persistence.save(), this.logger.debug("Properties set", {
1363
1466
  properties: e,
1364
1467
  eventType: i || "global",
1365
- persist: s
1468
+ persist: n
1366
1469
  });
1367
1470
  }
1368
1471
  setUserId(e) {
@@ -1371,7 +1474,7 @@ class N {
1371
1474
  t.id = e, this.persistence.set("userProps", t), this.persistence.save();
1372
1475
  }
1373
1476
  unset(e, t) {
1374
- const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1477
+ const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1375
1478
  if (i) {
1376
1479
  let r = this.persistence.get(`props_${i}`) || {};
1377
1480
  delete r[e], this.persistence.set(`props_${i}`, r);
@@ -1379,7 +1482,7 @@ class N {
1379
1482
  let r = this.persistence.get("global_props") || {};
1380
1483
  delete r[e], this.persistence.set("global_props", r);
1381
1484
  }
1382
- s && this.persistence.save(), this.logger.debug(
1485
+ n && this.persistence.save(), this.logger.debug(
1383
1486
  `Property unset: ${e}`,
1384
1487
  `Event type: ${i || "global"}`
1385
1488
  );
@@ -1388,105 +1491,105 @@ class N {
1388
1491
  function ie() {
1389
1492
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1390
1493
  }
1391
- function Te() {
1494
+ function xe() {
1392
1495
  return ie() ? window.define : void 0;
1393
1496
  }
1394
- const $e = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1395
- function O(n) {
1396
- const e = JSON.parse(JSON.stringify(n)), t = z(e), i = {
1397
- ...Z,
1497
+ const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1498
+ function L(s) {
1499
+ const e = JSON.parse(JSON.stringify(s)), t = Q(e), i = {
1500
+ ...Y,
1398
1501
  ...t
1399
1502
  };
1400
1503
  if (!i.key)
1401
1504
  throw new Error("API key is required!");
1402
1505
  if (!i.trackingHost)
1403
1506
  throw new Error("Tracking host is required!");
1404
- const s = i.key || "", r = `${$e}${s}`;
1405
- return h() && i.autocapture && window[r] && (console.warn(
1507
+ const n = i.key || "", r = `${Te}${n}`;
1508
+ return d() && i.autocapture && window[r] && (console.warn(
1406
1509
  "Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
1407
- ), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
1510
+ ), i.disableAutocaptureListenerRegistration = !0), d() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new R(i);
1408
1511
  }
1409
- function xe(n) {
1410
- var s;
1512
+ function He(s) {
1513
+ var n;
1411
1514
  const e = {
1412
- key: n.getAttribute("data-key") || void 0,
1413
- trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1414
- logLevel: ke(n.getAttribute("data-log-level")),
1415
- autocapture: n.getAttribute("data-autocapture") === "true",
1416
- formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
1417
- autoPageview: n.getAttribute("data-auto-pageview") === "true",
1418
- useBeaconApi: n.getAttribute("data-use-beacon-api") === "true",
1419
- forceUseFetch: n.getAttribute("data-force-use-fetch") === "true",
1420
- gaHook: n.getAttribute("data-ga-hook") === "true",
1421
- segmentHook: n.getAttribute("data-segment-hook") === "true",
1422
- randomizeUrl: n.getAttribute("data-randomize-url") === "true",
1423
- capture3rdPartyCookies: n.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1424
- idMethod: n.getAttribute("data-id-method") || void 0,
1425
- privacyPolicy: n.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1426
- ipPolicy: n.getAttribute("data-ip-policy") || void 0,
1427
- cookiePolicy: n.getAttribute("data-cookie-policy") || void 0,
1428
- minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1429
- maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1430
- maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1515
+ key: s.getAttribute("data-key") || void 0,
1516
+ trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1517
+ logLevel: ve(s.getAttribute("data-log-level")),
1518
+ autocapture: s.getAttribute("data-autocapture") === "true",
1519
+ formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
1520
+ autoPageview: s.getAttribute("data-auto-pageview") === "true",
1521
+ useBeaconApi: s.getAttribute("data-use-beacon-api") === "true",
1522
+ forceUseFetch: s.getAttribute("data-force-use-fetch") === "true",
1523
+ gaHook: s.getAttribute("data-ga-hook") === "true",
1524
+ segmentHook: s.getAttribute("data-segment-hook") === "true",
1525
+ randomizeUrl: s.getAttribute("data-randomize-url") === "true",
1526
+ capture3rdPartyCookies: s.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1527
+ idMethod: s.getAttribute("data-id-method") || void 0,
1528
+ privacyPolicy: s.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1529
+ ipPolicy: s.getAttribute("data-ip-policy") || void 0,
1530
+ cookiePolicy: s.getAttribute("data-cookie-policy") || void 0,
1531
+ minSendTimeout: parseInt(s.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1532
+ maxSendTimeout: parseInt(s.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1533
+ maxSendAttempts: parseInt(s.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1431
1534
  propertiesStringMaxLength: parseInt(
1432
- n.getAttribute("data-properties-string-max-length") || "",
1535
+ s.getAttribute("data-properties-string-max-length") || "",
1433
1536
  10
1434
1537
  ) || null,
1435
- propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
1436
- exclude: n.getAttribute("data-exclude") || void 0,
1437
- namespace: n.getAttribute("data-namespace") || void 0,
1438
- crossDomainLinking: n.getAttribute("data-cross-domain-linking") !== "false",
1439
- domains: n.getAttribute("data-domains") || void 0,
1440
- maskAllText: n.getAttribute("data-mask-all-text") === "true",
1441
- maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
1538
+ propertyBlacklist: ((n = s.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
1539
+ exclude: s.getAttribute("data-exclude") || void 0,
1540
+ namespace: s.getAttribute("data-namespace") || void 0,
1541
+ crossDomainLinking: s.getAttribute("data-cross-domain-linking") !== "false",
1542
+ domains: s.getAttribute("data-domains") || void 0,
1543
+ maskAllText: s.getAttribute("data-mask-all-text") === "true",
1544
+ maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
1442
1545
  };
1443
1546
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1444
- const t = O(e), i = e.namespace || "usermaven";
1445
- 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;
1446
1549
  }
1447
- function He(n, e) {
1550
+ function Ie(s, e) {
1448
1551
  let t = !1;
1449
- const i = [], s = [];
1552
+ const i = [], n = [];
1450
1553
  function r() {
1451
1554
  for (; i.length > 0; ) {
1452
1555
  const u = i.shift();
1453
1556
  if (u) {
1454
- const g = u[u.length - 1];
1455
- if (g && typeof g.resolve == "function") {
1456
- const m = u.pop();
1557
+ const m = u[u.length - 1];
1558
+ if (m && typeof m.resolve == "function") {
1559
+ const y = u.pop();
1457
1560
  try {
1458
- const b = a.apply(null, u);
1459
- b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
1460
- } catch (b) {
1461
- m.reject(b);
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);
1462
1565
  }
1463
1566
  } else
1464
1567
  try {
1465
1568
  a.apply(null, u);
1466
- } catch (m) {
1467
- console.error("Usermaven: Error processing queued command:", m);
1569
+ } catch (y) {
1570
+ console.error("Usermaven: Error processing queued command:", y);
1468
1571
  }
1469
1572
  }
1470
1573
  }
1471
1574
  }
1472
1575
  function o() {
1473
- s.forEach((u) => u()), s.length = 0;
1576
+ n.forEach((u) => u()), n.length = 0;
1474
1577
  }
1475
1578
  function a(...u) {
1476
- const g = u[0];
1477
- if (g === "onLoad") {
1478
- typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
1579
+ const m = u[0];
1580
+ if (m === "onLoad") {
1581
+ typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
1479
1582
  return;
1480
1583
  }
1481
1584
  if (!t) {
1482
1585
  i.push(u);
1483
1586
  return;
1484
1587
  }
1485
- if (typeof e[g] == "function")
1486
- return e[g].apply(e, u.slice(1));
1487
- console.error(`Method ${g} 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`);
1488
1591
  }
1489
- const l = ["id", "group", "reset"], c = [
1592
+ const c = ["id", "group", "reset"], h = [
1490
1593
  "track",
1491
1594
  "lead",
1492
1595
  "pageview",
@@ -1495,65 +1598,65 @@ function He(n, e) {
1495
1598
  "rawTrack",
1496
1599
  "setUserId"
1497
1600
  ];
1498
- [...l, ...c].forEach((u) => {
1499
- a[u] = function(...g) {
1601
+ [...c, ...h].forEach((u) => {
1602
+ a[u] = function(...m) {
1500
1603
  if (!t) {
1501
- if (l.includes(u))
1502
- return new Promise((q, m) => {
1503
- i.push([u, ...g, { resolve: q, reject: m }]);
1604
+ if (c.includes(u))
1605
+ return new Promise((M, y) => {
1606
+ i.push([u, ...m, { resolve: M, reject: y }]);
1504
1607
  });
1505
- i.push([u, ...g]);
1608
+ i.push([u, ...m]);
1506
1609
  return;
1507
1610
  }
1508
1611
  if (typeof e[u] == "function")
1509
- return e[u].apply(e, g);
1612
+ return e[u].apply(e, m);
1510
1613
  };
1511
1614
  }), a.getConfig = function() {
1512
1615
  return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
1513
- }, window[n] = a;
1514
- const p = `${n}Q`, _ = window[p] || [];
1515
- for (window[p] = _, _.push = function(...u) {
1616
+ }, window[s] = a;
1617
+ const l = `${s}Q`, g = window[l] || [];
1618
+ for (window[l] = g, g.push = function(...u) {
1516
1619
  return a.apply(null, u), Array.prototype.push.apply(this, u);
1517
1620
  }, setTimeout(() => {
1518
- t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
1519
- }, 0); _.length > 0; ) {
1520
- const u = _.shift();
1621
+ t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
1622
+ }, 0); g.length > 0; ) {
1623
+ const u = g.shift();
1521
1624
  u && i.push(u);
1522
1625
  }
1523
1626
  }
1524
- let X = !1, U = null;
1525
- if (h()) {
1526
- const n = Te();
1527
- n && n("usermaven", [], function() {
1627
+ let Z = !1, B = null;
1628
+ if (d()) {
1629
+ const s = xe();
1630
+ s && s("usermaven", [], function() {
1528
1631
  return {
1529
- usermavenClient: O,
1530
- UsermavenClient: N,
1531
- LogLevel: k,
1632
+ usermavenClient: L,
1633
+ UsermavenClient: R,
1634
+ LogLevel: _,
1532
1635
  // Expose the script tag client if it exists
1533
- getScriptTagClient: () => U
1636
+ getScriptTagClient: () => B
1534
1637
  };
1535
- }), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = N, window.usermavenScriptTagClient = () => U), function(e, t) {
1638
+ }), typeof window < "u" && (window.usermavenClient = L, window.UsermavenClient = R, window.usermavenScriptTagClient = () => B), function(e, t) {
1536
1639
  const i = e.currentScript;
1537
- function s() {
1538
- return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1640
+ function n() {
1641
+ return Z || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1539
1642
  }
1540
1643
  function r() {
1541
- s() && (console.log("[Usermaven] Auto-initializing from script tag"), U = xe(i), X = !0);
1644
+ n() && (console.log("[Usermaven] Auto-initializing from script tag"), B = He(i), Z = !0);
1542
1645
  }
1543
1646
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1544
1647
  }(document, window);
1545
1648
  }
1546
1649
  typeof module < "u" && module.exports && !ie() && (module.exports = {
1547
- usermavenClient: O,
1548
- UsermavenClient: N,
1650
+ usermavenClient: L,
1651
+ UsermavenClient: R,
1549
1652
  Config: void 0,
1550
1653
  UserProps: void 0,
1551
1654
  EventPayload: void 0,
1552
- LogLevel: k,
1655
+ LogLevel: _,
1553
1656
  ClientProperties: void 0
1554
1657
  });
1555
1658
  export {
1556
- k as LogLevel,
1557
- N as UsermavenClient,
1558
- O as usermavenClient
1659
+ _ as LogLevel,
1660
+ R as UsermavenClient,
1661
+ L as usermavenClient
1559
1662
  };