@usermaven/react 1.5.10 → 1.5.12

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.
package/lib/index.es.js CHANGED
@@ -8,8 +8,8 @@ const UsermavenProvider = ({ children, client }) => {
8
8
  return React.createElement(Context.Provider, { value: client }, children);
9
9
  };
10
10
 
11
- var k = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(k || {});
12
- class ie {
11
+ var _ = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(_ || {});
12
+ class se {
13
13
  constructor(e) {
14
14
  this.level = e;
15
15
  }
@@ -26,11 +26,11 @@ class ie {
26
26
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
27
27
  }
28
28
  }
29
- function f(n = 0) {
30
- return new ie(n);
29
+ function p(s = 0) {
30
+ return new se(s);
31
31
  }
32
- const X = {
33
- logLevel: k.ERROR,
32
+ const Y = {
33
+ logLevel: _.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
36
36
  trackingHost: "t.usermaven.com",
@@ -42,7 +42,13 @@ const X = {
42
42
  gaHook: !1,
43
43
  segmentHook: !1,
44
44
  randomizeUrl: !1,
45
- capture3rdPartyCookies: ["_ga", "_fbp", "_ym_uid", "ajs_user_id", "ajs_anonymous_id"],
45
+ capture3rdPartyCookies: [
46
+ "_ga",
47
+ "_fbp",
48
+ "_ym_uid",
49
+ "ajs_user_id",
50
+ "ajs_anonymous_id"
51
+ ],
46
52
  idMethod: "cookie",
47
53
  ipPolicy: "keep",
48
54
  cookiePolicy: "keep",
@@ -59,16 +65,16 @@ class ne {
59
65
  constructor(e) {
60
66
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
67
  }
62
- set(e, t, i = 365, s = !0, r = !1) {
68
+ set(e, t, i = 365, n = !0, r = !1) {
63
69
  const o = /* @__PURE__ */ new Date();
64
70
  o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
65
- const a = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", c = r ? "; HttpOnly" : "";
66
- document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
71
+ const a = `expires=${o.toUTCString()}`, c = n ? "; Secure" : "", h = r ? "; HttpOnly" : "";
72
+ document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${c}${h}`;
67
73
  }
68
74
  get(e) {
69
75
  const t = e + "=", i = document.cookie.split(";");
70
- for (let s = 0; s < i.length; s++) {
71
- let r = i[s].trim();
76
+ for (let n = 0; n < i.length; n++) {
77
+ let r = i[n].trim();
72
78
  if (r.indexOf(t) === 0)
73
79
  return decodeURIComponent(r.substring(t.length));
74
80
  }
@@ -96,84 +102,84 @@ class ne {
96
102
  }
97
103
  extractRootDomain(e) {
98
104
  let t = this.extractHostname(e);
99
- const i = t.split("."), s = i.length;
100
- 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;
105
+ const i = t.split("."), n = i.length;
106
+ 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;
101
107
  }
102
108
  extractTopLevelDomain(e) {
103
109
  const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
104
110
  return i ? i[0] : "";
105
111
  }
106
112
  }
107
- const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, T = oe.forEach, U = {};
108
- function ae(n, e, t) {
109
- if (Array.isArray(n)) {
110
- if (T && n.forEach === T)
111
- n.forEach(e, t);
112
- else if ("length" in n && n.length === +n.length) {
113
- for (let i = 0, s = n.length; i < s; i++)
114
- if (i in n && e.call(t, n[i], i) === U)
113
+ const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, I = ae.forEach, F = {};
114
+ function ce(s, e, t) {
115
+ if (Array.isArray(s)) {
116
+ if (I && s.forEach === I)
117
+ s.forEach(e, t);
118
+ else if ("length" in s && s.length === +s.length) {
119
+ for (let i = 0, n = s.length; i < n; i++)
120
+ if (i in s && e.call(t, s[i], i) === F)
115
121
  return;
116
122
  }
117
123
  }
118
124
  }
119
- const D = function(n) {
120
- return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, ce = function(n) {
122
- for (const e in n)
123
- typeof n[e] == "function" && (n[e] = n[e].bind(n));
125
+ const v = function(s) {
126
+ return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
127
+ }, le = function(s) {
128
+ for (const e in s)
129
+ typeof s[e] == "function" && (s[e] = s[e].bind(s));
124
130
  };
125
- function w(n, e, t) {
126
- if (n != null) {
127
- if (T && Array.isArray(n) && n.forEach === T)
128
- n.forEach(e, t);
129
- else if ("length" in n && n.length === +n.length) {
130
- for (let i = 0, s = n.length; i < s; i++)
131
- if (i in n && e.call(t, n[i], i) === U)
131
+ function k(s, e, t) {
132
+ if (s != null) {
133
+ if (I && Array.isArray(s) && s.forEach === I)
134
+ s.forEach(e, t);
135
+ else if ("length" in s && s.length === +s.length) {
136
+ for (let i = 0, n = s.length; i < n; i++)
137
+ if (i in s && e.call(t, s[i], i) === F)
132
138
  return;
133
139
  } else
134
- for (const i in n)
135
- if (re.call(n, i) && e.call(t, n[i], i) === U)
140
+ for (const i in s)
141
+ if (oe.call(s, i) && e.call(t, s[i], i) === F)
136
142
  return;
137
143
  }
138
144
  }
139
- const le = function(n, ...e) {
140
- return ae(e, function(t) {
145
+ const ue = function(s, ...e) {
146
+ return ce(e, function(t) {
141
147
  for (const i in t)
142
- t[i] !== void 0 && (n[i] = t[i]);
143
- }), n;
148
+ t[i] !== void 0 && (s[i] = t[i]);
149
+ }), s;
144
150
  };
145
- function S(n, e) {
146
- return n.indexOf(e) !== -1;
151
+ function $(s, e) {
152
+ return s.indexOf(e) !== -1;
147
153
  }
148
- const ue = function(n) {
154
+ const he = function(s) {
149
155
  try {
150
- return /^\s*\bfunction\b/.test(n);
156
+ return /^\s*\bfunction\b/.test(s);
151
157
  } catch {
152
158
  return !1;
153
159
  }
154
- }, he = function(n) {
155
- return n === void 0;
156
- }, E = function() {
157
- const n = function(i, s, r, o, a) {
160
+ }, de = function(s) {
161
+ return s === void 0;
162
+ }, A = function() {
163
+ const s = function(i, n, r, o, a) {
158
164
  if (!i) {
159
- f().error("No valid element provided to register_event");
165
+ p().error("No valid element provided to register_event");
160
166
  return;
161
167
  }
162
168
  if (i.addEventListener && !o)
163
- i.addEventListener(s, r, !!a);
169
+ i.addEventListener(n, r, !!a);
164
170
  else {
165
- const l = "on" + s, c = i[l];
166
- i[l] = e(i, r, c);
171
+ const c = "on" + n, h = i[c];
172
+ i[c] = e(i, r, h);
167
173
  }
168
174
  };
169
- function e(i, s, r) {
175
+ function e(i, n, r) {
170
176
  return function(o) {
171
177
  if (o = o || t(window.event), !o)
172
178
  return;
173
- let a = !0, l;
174
- ue(r) && (l = r(o));
175
- const c = s.call(i, o);
176
- return (l === !1 || c === !1) && (a = !1), a;
179
+ let a = !0, c;
180
+ he(r) && (c = r(o));
181
+ const h = n.call(i, o);
182
+ return (c === !1 || h === !1) && (a = !1), a;
177
183
  };
178
184
  }
179
185
  function t(i) {
@@ -183,105 +189,121 @@ const ue = function(n) {
183
189
  this.returnValue = !1;
184
190
  }, t.stopPropagation = function() {
185
191
  this.cancelBubble = !0;
186
- }, n;
187
- }(), de = function(n) {
192
+ }, s;
193
+ }(), fe = function(s) {
188
194
  return function(...e) {
189
195
  try {
190
- return n.apply(this, e);
196
+ return s.apply(this, e);
191
197
  } catch (t) {
192
- f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
198
+ p().error(
199
+ "Implementation error. Please turn on debug and contact support@usermaven.com.",
200
+ t
201
+ );
193
202
  }
194
203
  };
195
- }, Z = function(n) {
196
- for (const e in n)
197
- typeof n[e] == "function" && (n[e] = de(n[e]));
204
+ }, G = function(s) {
205
+ for (const e in s)
206
+ typeof s[e] == "function" && (s[e] = fe(s[e]));
198
207
  };
199
- function q(n) {
200
- for (let e in n)
201
- (n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
202
- return n;
208
+ function V(s) {
209
+ for (let e in s)
210
+ (s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
211
+ return s;
203
212
  }
204
- function h() {
213
+ function d() {
205
214
  try {
206
215
  return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
207
216
  } catch {
208
- return f().warn("window is not available"), !1;
217
+ return p().warn("window is not available"), !1;
209
218
  }
210
219
  }
211
- function v(n = 5) {
212
- const e = new Uint8Array(n);
213
- return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
220
+ function E(s = 5) {
221
+ const e = new Uint8Array(s);
222
+ return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, s);
214
223
  }
215
- function fe(n) {
216
- return n.replace(
224
+ function ge(s) {
225
+ return s.replace(
217
226
  /([-_][a-z])/g,
218
227
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
228
  );
220
229
  }
221
- function F(n) {
222
- return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(F) : Object.keys(n).reduce((e, t) => {
223
- const i = fe(t);
224
- return e[i] = F(n[t]), e;
225
- }, {});
230
+ function Q(s) {
231
+ return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(Q) : Object.keys(s).reduce(
232
+ (e, t) => {
233
+ const i = ge(t);
234
+ return e[i] = Q(s[t]), e;
235
+ },
236
+ {}
237
+ );
226
238
  }
227
- function x(n) {
228
- switch (typeof n.className) {
239
+ function O(s) {
240
+ switch (typeof s.className) {
229
241
  case "string":
230
- return n.className;
242
+ return s.className;
231
243
  case "object":
232
- return ("baseVal" in n.className ? n.className.baseVal : null) || n.getAttribute("class") || "";
244
+ return ("baseVal" in s.className ? s.className.baseVal : null) || s.getAttribute("class") || "";
233
245
  default:
234
246
  return "";
235
247
  }
236
248
  }
237
- function V(n) {
249
+ function J(s) {
238
250
  let e = "";
239
- return M(n) && !j(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
240
- G(t) && t.textContent && (e += D(t.textContent).split(/(\s+)/).filter(C).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
- }), D(e);
251
+ return z(s) && !ee(s) && s.childNodes && s.childNodes.length && k(s.childNodes, function(t) {
252
+ j(t) && t.textContent && (e += v(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
253
+ }), v(e);
242
254
  }
243
- function Y(n) {
244
- return !!n && n.nodeType === 1;
255
+ function b(s) {
256
+ return !!s && s.nodeType === 1;
245
257
  }
246
- function y(n, e) {
247
- return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
258
+ function w(s, e) {
259
+ return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
248
260
  }
249
- function G(n) {
250
- return !!n && n.nodeType === 3;
261
+ function j(s) {
262
+ return !!s && s.nodeType === 3;
251
263
  }
252
- function z(n) {
253
- return !!n && n.nodeType === 11;
264
+ function q(s) {
265
+ return !!s && s.nodeType === 11;
254
266
  }
255
- const $ = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function ge(n, e) {
257
- if (!n || y(n, "html") || !Y(n))
267
+ const T = [
268
+ "a",
269
+ "button",
270
+ "form",
271
+ "input",
272
+ "select",
273
+ "textarea",
274
+ "label"
275
+ ];
276
+ function pe(s, e) {
277
+ var o, a;
278
+ if (!s || w(s, "html") || !b(s))
258
279
  return !1;
259
- let t = n;
260
- for (; t && !y(t, "body"); ) {
280
+ let t = s;
281
+ for (; t && !w(t, "body"); ) {
261
282
  if (t.classList && t.classList.contains("um-no-capture"))
262
283
  return !1;
263
- t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
284
+ t.parentNode && q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
285
  }
265
286
  let i = !1;
266
- for (t = n; t && !y(t, "body"); ) {
267
- if (t.parentNode && z(t.parentNode)) {
268
- t = t.parentNode.host, t && $.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
287
+ for (t = s; t && !w(t, "body"); ) {
288
+ if (t.parentNode && q(t.parentNode)) {
289
+ t = t.parentNode.host, t && b(t) && T.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
269
290
  continue;
270
291
  }
271
- const o = t.parentNode;
272
- if (!o) break;
273
- if ($.indexOf(o.tagName.toLowerCase()) > -1)
292
+ const c = t.parentNode;
293
+ if (!c || !b(c)) break;
294
+ if (T.indexOf(c.tagName.toLowerCase()) > -1)
274
295
  i = !0;
275
296
  else {
276
- const a = window.getComputedStyle(o);
277
- a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
297
+ const h = window.getComputedStyle(c);
298
+ h && h.getPropertyValue("cursor") === "pointer" && (i = !0);
278
299
  }
279
- t = o;
300
+ t = c;
280
301
  }
281
- const s = window.getComputedStyle(n);
282
- if (s && s.getPropertyValue("cursor") === "pointer" && e.type === "click")
302
+ const n = window.getComputedStyle(s);
303
+ if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
283
304
  return !0;
284
- const r = n.tagName.toLowerCase();
305
+ const r = (a = (o = s.tagName) == null ? void 0 : o.toLowerCase) == null ? void 0 : a.call(o);
306
+ if (!r) return !1;
285
307
  switch (r) {
286
308
  case "html":
287
309
  return !1;
@@ -293,18 +315,18 @@ function ge(n, e) {
293
315
  case "textarea":
294
316
  return e.type === "change" || e.type === "click";
295
317
  default:
296
- return i ? e.type === "click" : e.type === "click" && ($.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
318
+ return i ? e.type === "click" : e.type === "click" && (T.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
297
319
  }
298
320
  }
299
- function M(n) {
300
- for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
301
- const s = x(i).split(" ");
302
- if (S(s, "ph-sensitive") || S(s, "ph-no-capture"))
321
+ function z(s) {
322
+ for (let i = s; i.parentNode && !w(i, "body"); i = i.parentNode) {
323
+ const n = O(i).split(" ");
324
+ if ($(n, "ph-sensitive") || $(n, "ph-no-capture"))
303
325
  return !1;
304
326
  }
305
- if (S(x(n).split(" "), "ph-include"))
327
+ if ($(O(s).split(" "), "ph-include"))
306
328
  return !0;
307
- const e = n.type || "";
329
+ const e = s.type || "";
308
330
  if (typeof e == "string")
309
331
  switch (e.toLowerCase()) {
310
332
  case "hidden":
@@ -312,61 +334,89 @@ function M(n) {
312
334
  case "password":
313
335
  return !1;
314
336
  }
315
- const t = n.name || n.id || "";
337
+ const t = s.name || s.id || "";
316
338
  return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
317
339
  }
318
- function j(n) {
340
+ function ee(s) {
319
341
  const e = ["button", "checkbox", "submit", "reset"];
320
- return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
342
+ return !!(w(s, "input") && !e.includes(s.type) || w(s, "select") || w(s, "textarea") || s.getAttribute("contenteditable") === "true");
343
+ }
344
+ function H(s) {
345
+ return !(s === null || de(s) || typeof s == "string" && (s = v(s), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
321
346
  }
322
- function C(n) {
323
- return !(n === null || he(n) || typeof n == "string" && (n = D(n), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
347
+ function me(s) {
348
+ return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
324
349
  }
325
- function pe(n) {
326
- return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
350
+ function ye(s) {
351
+ if (!s)
352
+ return !1;
353
+ const e = s.$el_text;
354
+ if (typeof e == "string" && v(e).length > 0)
355
+ return !0;
356
+ const t = s.classes;
357
+ if (Array.isArray(t) && t.some((n) => v(n).length > 0))
358
+ return !0;
359
+ const i = [
360
+ "attr__id",
361
+ "attr__name",
362
+ "attr__class",
363
+ "attr__aria-label",
364
+ "attr__aria-labelledby",
365
+ "attr__label",
366
+ "attr__href"
367
+ ];
368
+ for (const n of i) {
369
+ const r = s[n];
370
+ if (typeof r == "string" && v(r).length > 0)
371
+ return !0;
372
+ }
373
+ for (const [n, r] of Object.entries(s))
374
+ if (n.startsWith("attr__data-") && typeof r == "string" && v(r).length > 0)
375
+ return !0;
376
+ return !1;
327
377
  }
328
- function O() {
329
- return v(10);
378
+ function x() {
379
+ return E(10);
330
380
  }
331
- function me(n) {
332
- return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(n).toLowerCase());
381
+ function W(s) {
382
+ return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(s).toLowerCase());
333
383
  }
334
- function ye(n, e) {
384
+ function we(s, e) {
335
385
  let t;
336
386
  return function(...i) {
337
- const s = () => {
338
- clearTimeout(t), n(...i);
387
+ const n = () => {
388
+ clearTimeout(t), s(...i);
339
389
  };
340
- clearTimeout(t), t = setTimeout(s, e);
390
+ clearTimeout(t), t = setTimeout(n, e);
341
391
  };
342
392
  }
343
- function we(n) {
344
- const e = {}, t = n.replace(/^\?/, "").split("&");
393
+ function ke(s) {
394
+ const e = {}, t = s.replace(/^\?/, "").split("&");
345
395
  for (let i = 0; i < t.length; i++) {
346
- const s = t[i].split("=");
347
- s[0] !== "" && (e[decodeURIComponent(s[0])] = decodeURIComponent(s[1] || ""));
396
+ const n = t[i].split("=");
397
+ n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
348
398
  }
349
399
  return e;
350
400
  }
351
- function J(n) {
352
- return typeof n == "string" || n instanceof String;
401
+ function U(s) {
402
+ return typeof s == "string" || s instanceof String;
353
403
  }
354
- function A(n) {
355
- return n !== null && typeof n == "object" && n.constructor === Object;
404
+ function S(s) {
405
+ return s !== null && typeof s == "object" && s.constructor === Object;
356
406
  }
357
- function ke(n) {
358
- if (n === null)
359
- return k.ERROR;
360
- const e = n.toUpperCase(), t = k[e];
361
- return t || t === 0 ? t : k.ERROR;
407
+ function ve(s) {
408
+ if (s === null)
409
+ return _.ERROR;
410
+ const e = s.toUpperCase(), t = _[e];
411
+ return t || t === 0 ? t : _.ERROR;
362
412
  }
363
- const ve = () => {
364
- let n = "false";
365
- return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
413
+ const be = () => {
414
+ let s = "false";
415
+ return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
366
416
  };
367
417
  class _e {
368
418
  constructor(e) {
369
- this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ye(this.handleScroll.bind(this), 250), this.initializeEventListener();
419
+ this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = we(this.handleScroll.bind(this), 250), this.initializeEventListener();
370
420
  }
371
421
  initializeEventListener() {
372
422
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -390,8 +440,8 @@ class _e {
390
440
  this.track();
391
441
  }
392
442
  getScrollDepth() {
393
- const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), s = t - e;
394
- return Math.min(100, Math.floor(i / s * 100));
443
+ const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
444
+ return Math.min(100, Math.floor(i / n * 100));
395
445
  }
396
446
  getWindowHeight() {
397
447
  return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
@@ -410,17 +460,19 @@ class _e {
410
460
  return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
411
461
  }
412
462
  checkMilestones(e) {
413
- this.milestones.filter((i) => e >= i).forEach((i) => {
414
- this.send(), this.milestones = this.milestones.filter((s) => s !== i);
463
+ this.milestones.filter(
464
+ (i) => e >= i
465
+ ).forEach((i) => {
466
+ this.send(), this.milestones = this.milestones.filter((n) => n !== i);
415
467
  });
416
468
  }
417
469
  destroy() {
418
470
  window.removeEventListener("scroll", this.debouncedHandleScroll);
419
471
  }
420
472
  }
421
- const R = class R {
422
- constructor(e, t, i = f()) {
423
- 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);
473
+ const D = class D {
474
+ constructor(e, t, i = p()) {
475
+ this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), le(this), G(this);
424
476
  }
425
477
  isBrowserSupported() {
426
478
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -435,7 +487,9 @@ const R = class R {
435
487
  return;
436
488
  }
437
489
  if (!(document && document.body)) {
438
- this.logger.debug("Document not ready yet, trying again in 500 milliseconds..."), setTimeout(() => this.init(), 500);
490
+ this.logger.debug(
491
+ "Document not ready yet, trying again in 500 milliseconds..."
492
+ ), setTimeout(() => this.init(), 500);
439
493
  return;
440
494
  }
441
495
  this.addDomEventHandlers(), this.domHandlersAttached = !0;
@@ -444,7 +498,7 @@ const R = class R {
444
498
  const e = (t) => {
445
499
  t = t || window.event, this.captureEvent(t);
446
500
  };
447
- E(document, "submit", e, !1, !0), E(document, "change", e, !1, !0), E(document, "click", e, !1, !0), E(document, "visibilitychange", e, !1, !0), E(document, "scroll", e, !1, !0), E(window, "popstate", e, !1, !0);
501
+ A(document, "submit", e, !1, !0), A(document, "change", e, !1, !0), A(document, "click", e, !1, !0), A(document, "visibilitychange", e, !1, !0), A(document, "scroll", e, !1, !0), A(window, "popstate", e, !1, !0);
448
502
  }
449
503
  isPageRefresh() {
450
504
  if ("PerformanceNavigationTiming" in window) {
@@ -455,84 +509,94 @@ const R = class R {
455
509
  return performance.navigation && performance.navigation.type === 1;
456
510
  }
457
511
  captureEvent(e) {
458
- var i, s;
512
+ var i, n;
459
513
  let t = this.getEventTarget(e);
460
- if (G(t) && (t = t.parentNode || null), e.type === "scroll")
514
+ if (j(t) && (t = t.parentNode || null), e.type === "scroll")
461
515
  return (i = this.scrollDepth) == null || i.track(), !0;
462
516
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
463
- return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
464
- if (t && ge(t, e)) {
517
+ return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
518
+ if (!(!t || !b(t)) && t && pe(t, e)) {
465
519
  const r = [t];
466
520
  let o = t;
467
- for (; o.parentNode && !y(o, "body"); ) {
468
- if (z(o.parentNode)) {
469
- r.push(o.parentNode.host), o = o.parentNode.host;
521
+ for (; o != null && o.parentNode && !w(o, "body"); ) {
522
+ if (q(o == null ? void 0 : o.parentNode)) {
523
+ const g = (o == null ? void 0 : o.parentNode).host;
524
+ g && b(g) && r.push(g), o = g;
470
525
  continue;
471
526
  }
472
- r.push(o.parentNode), o = o.parentNode;
527
+ const l = o == null ? void 0 : o.parentNode;
528
+ if (!l || !b(l)) break;
529
+ r.push(l), o = l;
473
530
  }
474
531
  const a = [];
475
- let l, c = !1;
476
- if (w(r, (p) => {
477
- const _ = M(p);
478
- p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && C(l) && l);
479
- const u = x(p).split(" ");
480
- S(u, "ph-no-capture") && (c = !0), a.push(
532
+ let c, h = !1;
533
+ if (k(r, (l) => {
534
+ if (!l.tagName)
535
+ return;
536
+ const g = z(l);
537
+ l.tagName.toLowerCase() === "a" && (c = l.getAttribute("href"), c = g && H(c) && c);
538
+ const u = O(l).split(" ");
539
+ $(u, "ph-no-capture") && (h = !0), a.push(
481
540
  this.getPropertiesFromElement(
482
- p,
541
+ l,
483
542
  this.options.maskAllElementAttributes ?? !1,
484
543
  this.options.maskAllText ?? !1
485
544
  )
486
545
  );
487
- }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
546
+ }), this.options.maskAllText || (a[0].$el_text = J(t)), c && (a[0].attr__href = c), h)
488
547
  return !1;
489
- const d = le(
548
+ if (!ye(a[0]))
549
+ return this.logger.debug("Dropping autocapture event without identifiers."), !1;
550
+ const f = ue(
490
551
  this.getDefaultProperties(e.type),
491
552
  {
492
553
  $elements: a
493
554
  },
494
555
  this.getCustomProperties(r)
495
556
  );
496
- return this.client.track("$autocapture", d), !0;
557
+ return this.client.track("$autocapture", f), !0;
497
558
  }
498
559
  }
499
560
  getCustomProperties(e) {
500
561
  const t = {};
501
- return w(this.customProperties, (i) => {
502
- w(i.event_selectors, (s) => {
503
- const r = document.querySelectorAll(s);
504
- w(r, (o) => {
505
- S(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
562
+ return k(this.customProperties, (i) => {
563
+ k(i.event_selectors, (n) => {
564
+ const r = document.querySelectorAll(n);
565
+ k(r, (o) => {
566
+ $(e, o) && z(o) && (t[i.name] = this.extractCustomPropertyValue(i));
506
567
  });
507
568
  });
508
569
  }), t;
509
570
  }
510
571
  extractCustomPropertyValue(e) {
511
572
  const t = [];
512
- return w(document.querySelectorAll(e.css_selector), function(i) {
513
- let s;
514
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), C(s) && t.push(s);
515
- }), t.join(", ");
573
+ return k(
574
+ document.querySelectorAll(e.css_selector),
575
+ function(i) {
576
+ let n;
577
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), H(n) && t.push(n);
578
+ }
579
+ ), t.join(", ");
516
580
  }
517
581
  getEventTarget(e) {
518
582
  var t;
519
583
  return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
520
584
  }
521
585
  getPropertiesFromElement(e, t, i) {
522
- const s = e.tagName.toLowerCase(), r = {
523
- tag_name: s
586
+ const n = e.tagName.toLowerCase(), r = {
587
+ tag_name: n
524
588
  };
525
- $.indexOf(s) > -1 && !i && (r.$el_text = V(e));
526
- const o = x(e);
527
- o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
528
- return d !== "";
529
- })), w(e.attributes, function(d) {
530
- j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && C(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
589
+ T.indexOf(n) > -1 && !i && (r.$el_text = J(e));
590
+ const o = O(e);
591
+ o.length > 0 && (r.classes = o.split(" ").filter(function(f) {
592
+ return f !== "";
593
+ })), k(e.attributes, function(f) {
594
+ ee(e) && ["name", "id", "class"].indexOf(f.name) === -1 || !t && H(f.value) && !me(f.name) && (r["attr__" + f.name] = f.value);
531
595
  });
532
- let a = 1, l = 1, c = e;
533
- for (; c = this.previousElementSibling(c); )
534
- a++, c.tagName === e.tagName && l++;
535
- return r.nth_child = a, r.nth_of_type = l, r;
596
+ let a = 1, c = 1, h = e;
597
+ for (; h = this.previousElementSibling(h); )
598
+ a++, h.tagName === e.tagName && c++;
599
+ return r.nth_child = a, r.nth_of_type = c, r;
536
600
  }
537
601
  previousElementSibling(e) {
538
602
  if (e.previousElementSibling)
@@ -541,7 +605,7 @@ const R = class R {
541
605
  let t = e;
542
606
  do
543
607
  t = t.previousSibling;
544
- while (t && !Y(t));
608
+ while (t && !b(t));
545
609
  return t;
546
610
  }
547
611
  }
@@ -557,15 +621,15 @@ const R = class R {
557
621
  static enabledForProject(e, t = 10, i = 10) {
558
622
  if (!e)
559
623
  return !1;
560
- let s = 0;
624
+ let n = 0;
561
625
  for (let r = 0; r < e.length; r++)
562
- s += e.charCodeAt(r);
563
- return s % t < i;
626
+ n += e.charCodeAt(r);
627
+ return n % t < i;
564
628
  }
565
629
  };
566
- R.FORCE_CAPTURE_ATTR = "data-um-force-capture", R.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
567
- let H = R;
568
- class be {
630
+ D.FORCE_CAPTURE_ATTR = "data-um-force-capture", D.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
631
+ let N = D;
632
+ class Ee {
569
633
  constructor(e) {
570
634
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
571
635
  }
@@ -594,44 +658,48 @@ class be {
594
658
  }));
595
659
  }
596
660
  }
597
- class Ee {
598
- constructor(e, t, i = f()) {
661
+ class Pe {
662
+ constructor(e, t, i = p()) {
599
663
  this.trackingHost = e, this.logger = i, this.config = t;
600
664
  }
601
665
  async send(e) {
602
- const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], { type: "application/json" });
603
- if (navigator.sendBeacon(i, s))
604
- this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
666
+ const t = this.config.key, i = this.constructUrl(t), n = new Blob([JSON.stringify(e)], {
667
+ type: "application/json"
668
+ });
669
+ if (navigator.sendBeacon(i, n))
670
+ this.logger.debug(
671
+ `Successfully queued ${e.length} event(s) via Beacon API`
672
+ );
605
673
  else
606
674
  throw new Error("Failed to queue events via Beacon API");
607
675
  }
608
676
  constructUrl(e) {
609
- 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";
610
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
677
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
678
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
611
679
  }
612
680
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
613
681
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
614
682
  }
615
- class Q {
616
- constructor(e, t, i = f()) {
683
+ class K {
684
+ constructor(e, t, i = p()) {
617
685
  this.trackingHost = e, this.logger = i, this.config = t;
618
686
  }
619
687
  async send(e) {
620
- const t = this.config.key, i = this.constructUrl(t), s = JSON.stringify(e), r = {
688
+ const t = this.config.key, i = this.constructUrl(t), n = JSON.stringify(e), r = {
621
689
  "Content-Type": "application/json",
622
690
  ...this.getCustomHeaders()
623
691
  }, o = await fetch(i, {
624
692
  method: "POST",
625
693
  headers: r,
626
- body: s
694
+ body: n
627
695
  });
628
696
  if (!o.ok)
629
697
  throw new Error(`HTTP error! status: ${o.status}`);
630
698
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
631
699
  }
632
700
  constructUrl(e) {
633
- 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";
634
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
701
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
702
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
635
703
  }
636
704
  getCustomHeaders() {
637
705
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -640,27 +708,27 @@ class Q {
640
708
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
641
709
  }
642
710
  }
643
- class Pe {
644
- constructor(e, t, i = f()) {
711
+ class Ae {
712
+ constructor(e, t, i = p()) {
645
713
  this.trackingHost = e, this.logger = i, this.config = t;
646
714
  }
647
715
  send(e) {
648
716
  return new Promise((t, i) => {
649
- const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
650
- s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
717
+ const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
718
+ n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
651
719
  const a = this.getCustomHeaders();
652
- Object.keys(a).forEach((l) => {
653
- s.setRequestHeader(l, a[l]);
654
- }), s.onload = () => {
655
- s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
656
- }, s.onerror = () => {
720
+ Object.keys(a).forEach((c) => {
721
+ n.setRequestHeader(c, a[c]);
722
+ }), n.onload = () => {
723
+ n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${n.status}`));
724
+ }, n.onerror = () => {
657
725
  i(new Error("Network error"));
658
- }, s.send(JSON.stringify(e));
726
+ }, n.send(JSON.stringify(e));
659
727
  });
660
728
  }
661
729
  constructUrl(e) {
662
- 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";
663
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
730
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
731
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
664
732
  }
665
733
  getCustomHeaders() {
666
734
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -669,9 +737,9 @@ class Pe {
669
737
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
670
738
  }
671
739
  }
672
- class ee {
740
+ class te {
673
741
  constructor(e, t) {
674
- this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
742
+ this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || p(), this.load();
675
743
  }
676
744
  set(e, t) {
677
745
  this.storage[e] = t, this.save();
@@ -685,19 +753,11 @@ class ee {
685
753
  clear() {
686
754
  this.storage = {}, this.save();
687
755
  }
688
- save() {
689
- if (!h()) {
690
- this.logger.warn("localStorage is not available in this environment");
691
- return;
692
- }
693
- try {
694
- localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage));
695
- } catch (e) {
696
- this.logger.error("Error saving to localStorage:", e);
697
- }
756
+ isStorageEnabled() {
757
+ return !this.storageDisabled;
698
758
  }
699
759
  load() {
700
- if (!h()) {
760
+ if (!d()) {
701
761
  this.logger.warn("localStorage is not available in this environment");
702
762
  return;
703
763
  }
@@ -705,11 +765,32 @@ class ee {
705
765
  const e = localStorage.getItem(this.prefix + "data");
706
766
  e && (this.storage = JSON.parse(e));
707
767
  } catch (e) {
708
- this.logger.error("Error loading from localStorage:", e);
768
+ this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error loading from localStorage:", e);
709
769
  }
710
770
  }
771
+ save() {
772
+ if (!d())
773
+ return this.logger.warn("localStorage is not available in this environment"), !1;
774
+ if (this.storageDisabled)
775
+ return !1;
776
+ try {
777
+ return localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage)), !0;
778
+ } catch (e) {
779
+ return this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error saving to localStorage:", e), !1;
780
+ }
781
+ }
782
+ isQuotaError(e) {
783
+ const t = e == null ? void 0 : e.name;
784
+ return t === "QuotaExceededError" || t === "NS_ERROR_DOM_QUOTA_REACHED" || (e == null ? void 0 : e.code) === 22 || (e == null ? void 0 : e.code) === 1014;
785
+ }
786
+ logQuotaOnce(e) {
787
+ this.quotaErrorLogged || (this.quotaErrorLogged = !0, this.logger.error(
788
+ "localStorage quota exceeded; persisting disabled. Continuing with in-memory storage only.",
789
+ e
790
+ ));
791
+ }
711
792
  }
712
- class Ae {
793
+ class Se {
713
794
  constructor() {
714
795
  this.storage = {};
715
796
  }
@@ -728,56 +809,119 @@ class Ae {
728
809
  this.storage = {};
729
810
  }
730
811
  }
731
- class W {
732
- // Default to true for server-side
733
- constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
734
- 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());
812
+ class X {
813
+ constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = p(), a = "default", c = 1e3, h = 25e5) {
814
+ this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.totalQueueBytes = 0, this.persistence = new te(
815
+ `offline_queue_${a}`
816
+ ), this.maxQueueItems = c, this.maxQueueBytes = h, d() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
735
817
  }
736
818
  add(e) {
737
- const t = { payload: e, retries: 0, timestamp: Date.now() };
738
- this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
819
+ const t = {
820
+ payload: e,
821
+ retries: 0,
822
+ timestamp: Date.now()
823
+ };
824
+ t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), d() ? this.saveQueueToStorage() : this.processBatch();
739
825
  }
740
826
  initNetworkListeners() {
741
- h() && (window.addEventListener("online", () => {
827
+ d() && (window.addEventListener("online", () => {
742
828
  this.isOnline = !0, this.processBatch();
743
829
  }), window.addEventListener("offline", () => {
744
830
  this.isOnline = !1;
745
831
  }));
746
832
  }
747
833
  scheduleBatch() {
748
- h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
834
+ d() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
835
+ () => this.processBatch(),
836
+ this.batchInterval
837
+ ));
749
838
  }
750
839
  async processBatch() {
751
- if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
840
+ if ((!d() || this.isOnline) && !this.processing && this.queue.length > 0) {
752
841
  this.processing = !0;
753
- const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
842
+ const e = this.queue.splice(0, this.batchSize);
843
+ this.totalQueueBytes = Math.max(
844
+ 0,
845
+ this.totalQueueBytes - e.reduce((i, n) => i + (n.bytes || 0), 0)
846
+ );
847
+ const t = e.map((i) => i.payload);
754
848
  try {
755
- await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
849
+ await this.transport.send(t), this.logger.debug(
850
+ `Successfully sent batch of ${e.length} payloads`
851
+ ), d() && this.saveQueueToStorage();
756
852
  } catch (i) {
757
853
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
758
854
  }
759
855
  this.processing = !1;
760
856
  }
761
- h() && this.scheduleBatch();
857
+ d() && this.scheduleBatch();
762
858
  }
763
859
  async handleBatchFailure(e) {
764
860
  for (const t of e)
765
- 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);
766
- h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
861
+ 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(
862
+ "Max retries reached, discarding payload",
863
+ t.payload
864
+ );
865
+ d() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
866
+ }
867
+ enforceQueueLimits() {
868
+ if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
869
+ const e = this.queue.length - this.maxQueueItems, t = this.queue.splice(0, e);
870
+ this.totalQueueBytes = Math.max(
871
+ 0,
872
+ this.totalQueueBytes - t.reduce((i, n) => i + (n.bytes || 0), 0)
873
+ ), this.logger.warn(
874
+ `Retry queue exceeded ${this.maxQueueItems} items; dropped ${t.length} oldest payload(s)`
875
+ );
876
+ }
877
+ if (this.maxQueueBytes > 0 && this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 0) {
878
+ let e = 0;
879
+ for (; this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 1; ) {
880
+ const t = this.queue.shift();
881
+ t && (this.totalQueueBytes -= t.bytes || this.estimateItemBytes(t), e++);
882
+ }
883
+ this.totalQueueBytes = Math.max(0, this.totalQueueBytes), e > 0 && this.logger.warn(
884
+ `Retry queue exceeded ${this.maxQueueBytes} bytes; dropped ${e} oldest payload(s)`
885
+ );
886
+ }
887
+ }
888
+ estimateItemBytes(e) {
889
+ const t = { ...e };
890
+ delete t.bytes;
891
+ try {
892
+ return JSON.stringify(t).length;
893
+ } catch {
894
+ return 0;
895
+ }
767
896
  }
768
897
  loadQueueFromStorage() {
769
- if (h()) {
898
+ if (d()) {
770
899
  const e = this.persistence.get("queue");
771
- e && (this.queue = JSON.parse(e));
900
+ if (!e) return;
901
+ try {
902
+ const t = JSON.parse(e);
903
+ this.queue = t.map((i) => ({
904
+ ...i,
905
+ bytes: i.bytes || this.estimateItemBytes(i)
906
+ })), this.totalQueueBytes = this.queue.reduce(
907
+ (i, n) => i + (n.bytes || 0),
908
+ 0
909
+ ), this.enforceQueueLimits();
910
+ } catch (t) {
911
+ this.logger.error("Failed to parse stored queue", t), this.queue = [], this.totalQueueBytes = 0;
912
+ }
772
913
  }
773
914
  }
774
915
  saveQueueToStorage() {
775
- h() && this.persistence.set("queue", JSON.stringify(this.queue));
916
+ if (d()) {
917
+ const e = this.queue.map(({ bytes: t, ...i }) => i);
918
+ this.persistence.set("queue", JSON.stringify(e));
919
+ }
776
920
  }
777
921
  }
778
- class Se {
922
+ class Ce {
779
923
  constructor(e) {
780
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
924
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), G(this);
781
925
  }
782
926
  initializeEventListener() {
783
927
  document.addEventListener("click", this.handleClick.bind(this));
@@ -790,15 +934,19 @@ class Se {
790
934
  return !e.closest(".um-no-capture");
791
935
  }
792
936
  click(e, t, i) {
793
- const s = { x: e, y: t, timestamp: i };
794
- this.clicks.push(s), this.clicks = this.clicks.filter((r) => i - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
937
+ const n = { x: e, y: t, timestamp: i };
938
+ this.clicks.push(n), this.clicks = this.clicks.filter(
939
+ (r) => i - r.timestamp < this.timeWindow
940
+ ), this.clicks.length >= this.threshold && this.checkRageClick();
795
941
  }
796
942
  checkRageClick() {
797
943
  const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
798
944
  this.clicks.every((r, o) => {
799
945
  if (o === 0) return !0;
800
946
  const a = this.clicks[o - 1];
801
- return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
947
+ return Math.sqrt(
948
+ Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)
949
+ ) < this.distanceThreshold;
802
950
  }) && this.sendRageClickEvent(i);
803
951
  }
804
952
  sendRageClickEvent(e) {
@@ -810,11 +958,11 @@ class Se {
810
958
  }
811
959
  }
812
960
  class $e {
813
- constructor(e, t, i = f()) {
961
+ constructor(e, t, i = p()) {
814
962
  this.trackingHost = e, this.logger = i, this.config = t;
815
963
  }
816
964
  async send(e) {
817
- const t = this.config.key, i = new (void 0)(this.constructUrl(t)), s = {
965
+ const t = this.config.key, i = new (void 0)(this.constructUrl(t)), n = {
818
966
  hostname: i.hostname,
819
967
  port: 443,
820
968
  path: `${i.pathname}${i.search}`,
@@ -825,15 +973,15 @@ class $e {
825
973
  }
826
974
  };
827
975
  return new Promise((r, o) => {
828
- const a = (void 0)(s, (l) => {
829
- l.on("data", (c) => {
830
- }), l.on("end", () => {
831
- const c = l.statusCode || 0;
832
- c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
976
+ const a = (void 0)(n, (c) => {
977
+ c.on("data", (h) => {
978
+ }), c.on("end", () => {
979
+ const h = c.statusCode || 0;
980
+ h >= 200 && h < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${h}`));
833
981
  });
834
982
  });
835
- a.on("error", (l) => {
836
- o(l);
983
+ a.on("error", (c) => {
984
+ o(c);
837
985
  }), a.write(JSON.stringify(e)), a.end();
838
986
  });
839
987
  }
@@ -845,7 +993,7 @@ class $e {
845
993
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
846
994
  }
847
995
  }
848
- class P {
996
+ class C {
849
997
  constructor(e, t = "all", i = {}) {
850
998
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
851
999
  }
@@ -860,18 +1008,27 @@ class P {
860
1008
  }
861
1009
  handleFormSubmit(e) {
862
1010
  const t = e.target, i = this._getFormDetails(t);
863
- this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
1011
+ this.instance.track("$form", V(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
864
1012
  }
865
1013
  trackFieldChanges(e) {
866
1014
  e.querySelectorAll("input, select, textarea").forEach((i) => {
867
- i.addEventListener("change", (s) => {
868
- const r = this._getFieldProps(s.target, 0);
869
- this.instance.track("$form_field_change", q(r));
1015
+ i.addEventListener("change", (n) => {
1016
+ const r = this._getFieldProps(
1017
+ n.target
1018
+ );
1019
+ this.instance.track(
1020
+ "$form_field_change",
1021
+ V({
1022
+ form_id: e.id,
1023
+ form_name: e.name || "",
1024
+ field: r
1025
+ })
1026
+ );
870
1027
  });
871
1028
  });
872
1029
  }
873
1030
  static getInstance(e, t = "all", i = {}) {
874
- return P.instance || (P.instance = new P(e, t, i)), P.instance;
1031
+ return C.instance || (C.instance = new C(e, t, i)), C.instance;
875
1032
  }
876
1033
  _getFormDetails(e) {
877
1034
  const t = {
@@ -880,34 +1037,47 @@ class P {
880
1037
  form_action: e.action,
881
1038
  form_method: e.method,
882
1039
  form_class: e.className,
883
- form_attributes: this._getElementAttributes(e)
884
- }, i = e.querySelectorAll("input, select, textarea");
885
- return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
886
- const a = this._getFieldProps(r, o);
887
- Object.assign(t, a);
888
- }), t;
1040
+ form_attributes: this._getElementAttributes(e),
1041
+ fields: []
1042
+ }, i = e.querySelectorAll(
1043
+ "input, select, textarea"
1044
+ );
1045
+ return Array.from(i).filter(
1046
+ (r) => !r.classList.contains("um-no-capture")
1047
+ ).forEach(
1048
+ (r) => {
1049
+ const o = this._getFieldProps(r);
1050
+ t.fields.push(o);
1051
+ }
1052
+ ), t;
889
1053
  }
890
- _getFieldProps(e, t) {
891
- const i = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, s = this.getSafeText(e);
1054
+ _getFieldProps(e) {
1055
+ const t = Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : void 0, i = this.getSafeText(e);
892
1056
  return {
893
- [`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
894
- [`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
895
- [`field_${t + 1}_data_attributes`]: i,
896
- [`field_${t + 1}_id`]: e.id,
897
- [`field_${t + 1}_value`]: s,
898
- [`field_${t + 1}_class`]: e.className,
899
- [`field_${t + 1}_name`]: e.name,
900
- [`field_${t + 1}_attributes`]: this._getElementAttributes(e)
1057
+ tag: e.tagName.toLowerCase(),
1058
+ type: e instanceof HTMLInputElement ? e.type : void 0,
1059
+ data_attributes: t,
1060
+ id: e.id,
1061
+ value: i,
1062
+ class: e.className,
1063
+ name: e.name,
1064
+ attributes: this._getElementAttributes(e)
901
1065
  };
902
1066
  }
903
1067
  _getElementAttributes(e) {
904
- return Object.keys(e.dataset).length ? JSON.parse(JSON.stringify(e.dataset)) : {};
1068
+ return Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : {};
1069
+ }
1070
+ _convertDOMStringMapToObject(e) {
1071
+ const t = {};
1072
+ for (const i in e)
1073
+ e.hasOwnProperty(i) && e[i] !== void 0 && (t[i] = e[i]);
1074
+ return t;
905
1075
  }
906
1076
  getSafeText(e) {
907
1077
  let t = "";
908
1078
  return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
909
- (s) => s.nodeType === Node.TEXT_NODE
910
- ).map((s) => s.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
1079
+ (n) => n.nodeType === Node.TEXT_NODE
1080
+ ).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
911
1081
  }
912
1082
  _scrubPotentiallySensitiveValues(e) {
913
1083
  return this._shouldCaptureValue(e) ? e : "<redacted>";
@@ -925,7 +1095,7 @@ class P {
925
1095
  if (typeof String.prototype.trim == "function")
926
1096
  return e.trim();
927
1097
  let t = 0, i = e.length - 1;
928
- const s = [
1098
+ const n = [
929
1099
  " ",
930
1100
  `
931
1101
  `,
@@ -952,16 +1122,16 @@ class P {
952
1122
  " ",
953
1123
  " "
954
1124
  ].join("");
955
- for (; t <= i && s.indexOf(e[t]) > -1; )
1125
+ for (; t <= i && n.indexOf(e[t]) > -1; )
956
1126
  t++;
957
- for (; i >= t && s.indexOf(e[i]) > -1; )
1127
+ for (; i >= t && n.indexOf(e[i]) > -1; )
958
1128
  i--;
959
1129
  return e.slice(t, i + 1);
960
1130
  }
961
1131
  }
962
- class N {
1132
+ class R {
963
1133
  constructor(e) {
964
- 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(
1134
+ this.config = this.mergeConfig(e, Y), this.logger = p(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new X(
965
1135
  this.transport,
966
1136
  this.config.maxSendAttempts || 3,
967
1137
  this.config.minSendTimeout || 1e3,
@@ -970,16 +1140,22 @@ class N {
970
1140
  // Reduced interval to .2 second
971
1141
  this.logger,
972
1142
  this.namespace
973
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
1143
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1144
+ `Usermaven client initialized for namespace: ${this.namespace}`
1145
+ );
974
1146
  }
975
1147
  initializeBrowserFeatures() {
976
- if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && H.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new H(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
1148
+ if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && N.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new N(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
977
1149
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
978
- this.formTracking = P.getInstance(this, e || "none", {
979
- trackFieldChanges: !1
980
- });
1150
+ this.formTracking = C.getInstance(
1151
+ this,
1152
+ e || "none",
1153
+ {
1154
+ trackFieldChanges: !1
1155
+ }
1156
+ );
981
1157
  }
982
- this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Se(this)), this.setupPageLeaveTracking();
1158
+ this.config.autoPageview && (this.pageviewTracking = new Ee(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ce(this)), this.setupPageLeaveTracking();
983
1159
  }
984
1160
  /**
985
1161
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -988,13 +1164,13 @@ class N {
988
1164
  */
989
1165
  mergeConfig(e, t) {
990
1166
  const i = JSON.parse(JSON.stringify(e));
991
- let s = { ...t, ...i };
1167
+ let n = { ...t, ...i };
992
1168
  return Object.keys(t).forEach((r) => {
993
- A(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
994
- }), s;
1169
+ S(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
1170
+ }), n;
995
1171
  }
996
1172
  init(e) {
997
- 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(
1173
+ this.config = { ...this.config, ...e }, this.logger = p(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new X(
998
1174
  this.transport,
999
1175
  this.config.maxSendAttempts || 3,
1000
1176
  this.config.minSendTimeout || 1e3,
@@ -1003,7 +1179,9 @@ class N {
1003
1179
  // Reduced interval to .25 second
1004
1180
  this.logger,
1005
1181
  this.namespace
1006
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
1182
+ ), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1183
+ `Usermaven client reinitialized for namespace: ${this.namespace}`
1184
+ );
1007
1185
  }
1008
1186
  manageCrossDomainLinking() {
1009
1187
  if (!this.config.crossDomainLinking || !this.config.domains)
@@ -1011,14 +1189,14 @@ class N {
1011
1189
  const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1012
1190
  document.addEventListener("click", (i) => {
1013
1191
  var a;
1014
- const s = this.findClosestLink(i.target);
1015
- if (!s) return;
1016
- const r = s.getAttribute("href");
1192
+ const n = this.findClosestLink(i.target);
1193
+ if (!n) return;
1194
+ const r = n.getAttribute("href");
1017
1195
  if (!r || !r.startsWith("http")) return;
1018
1196
  const o = new URL(r);
1019
1197
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1020
- const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
1021
- l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
1198
+ const c = (a = this.cookieManager) == null ? void 0 : a.get(t);
1199
+ c && (o.searchParams.append("_um", c), n.setAttribute("href", o.toString()));
1022
1200
  }
1023
1201
  }), this.logger.debug("Cross-domain linking initialized");
1024
1202
  }
@@ -1029,70 +1207,114 @@ class N {
1029
1207
  }
1030
1208
  initializeTransport(e) {
1031
1209
  const t = "https://events.usermaven.com";
1032
- if (!h())
1210
+ if (!d())
1033
1211
  return new $e(e.trackingHost || t, e);
1034
- const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1212
+ const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1035
1213
  if (e.useBeaconApi && r)
1036
- return new Ee(e.trackingHost || t, e, this.logger);
1037
- if (e.forceUseFetch && s)
1038
- return new Q(e.trackingHost || t, e, this.logger);
1214
+ return new Pe(
1215
+ e.trackingHost || t,
1216
+ e,
1217
+ this.logger
1218
+ );
1219
+ if (e.forceUseFetch && n)
1220
+ return new K(
1221
+ e.trackingHost || t,
1222
+ e,
1223
+ this.logger
1224
+ );
1039
1225
  if (i)
1040
- return new Pe(e.trackingHost || t, e, this.logger);
1041
- if (s)
1042
- return new Q(e.trackingHost || t, e, this.logger);
1226
+ return new Ae(
1227
+ e.trackingHost || t,
1228
+ e,
1229
+ this.logger
1230
+ );
1231
+ if (n)
1232
+ return new K(
1233
+ e.trackingHost || t,
1234
+ e,
1235
+ this.logger
1236
+ );
1043
1237
  throw new Error("No suitable transport method available");
1044
1238
  }
1045
1239
  initializePersistence() {
1046
- return this.config.disableEventPersistence || !h() ? new Ae() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
1240
+ return this.config.disableEventPersistence || !d() ? new Se() : new te(
1241
+ `${this.namespace}_${this.config.key}`,
1242
+ this.logger
1243
+ );
1047
1244
  }
1048
1245
  getOrCreateAnonymousId() {
1049
- var i, s;
1050
- if (!h())
1051
- return O();
1246
+ var i, n;
1247
+ if (!d())
1248
+ return x();
1052
1249
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1053
1250
  return "";
1054
1251
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1055
1252
  let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1056
1253
  if (!t) {
1057
1254
  if (this.config.crossDomainLinking) {
1058
- const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
1059
- t = a || d || O();
1255
+ const a = new URLSearchParams(window.location.search).get("_um"), h = window.location.hash.substring(1).split("~"), f = h.length > 1 ? h[1] : void 0;
1256
+ t = a || f || x();
1060
1257
  }
1061
- t || (t = O());
1258
+ t || (t = x());
1062
1259
  const r = 365 * 10;
1063
- (s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
1260
+ (n = this.cookieManager) == null || n.set(
1261
+ e,
1262
+ t,
1263
+ r,
1264
+ document.location.protocol !== "http:",
1265
+ !1
1266
+ );
1064
1267
  }
1065
1268
  return t;
1066
1269
  }
1067
1270
  async id(e, t = !1) {
1068
- if (!A(e))
1271
+ if (!S(e))
1069
1272
  throw new Error("User data must be an object");
1070
- if (e.email && !me(e.email))
1273
+ if (e.email && !W(e.email))
1071
1274
  throw new Error("Invalid email provided");
1072
- if (!e.id || !J(e.id))
1275
+ if (!e.id || !U(e.id))
1073
1276
  throw new Error("User ID must be a string");
1074
1277
  const i = e.id;
1075
1278
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
1076
- const s = {
1279
+ const n = {
1077
1280
  ...e,
1078
1281
  anonymous_id: this.anonymousId
1079
1282
  };
1080
- await this.track("user_identify", s);
1283
+ await this.track("user_identify", n);
1081
1284
  }
1082
1285
  this.logger.info("User identified:", e);
1083
1286
  }
1084
1287
  track(e, t, i = !1) {
1085
1288
  this.trackInternal(e, t, i);
1086
1289
  }
1290
+ lead(e, t = !1) {
1291
+ if (!S(e))
1292
+ throw new Error(
1293
+ "Lead payload must be a non-null object and not an array"
1294
+ );
1295
+ const i = e.email;
1296
+ if (!U(i)) {
1297
+ this.logger.error("Lead event requires a valid email attribute");
1298
+ return;
1299
+ }
1300
+ const n = i.trim();
1301
+ if (!n || !W(n)) {
1302
+ this.logger.error("Lead event requires a valid email attribute");
1303
+ return;
1304
+ }
1305
+ e.email = n, this.track("lead", e, t);
1306
+ }
1087
1307
  trackInternal(e, t, i = !1) {
1088
- if (ve()) {
1308
+ if (be()) {
1089
1309
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1090
1310
  return;
1091
1311
  }
1092
- if (!J(e))
1312
+ if (!U(e))
1093
1313
  throw new Error("Event name must be a string");
1094
1314
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1095
- throw new Error("Event payload must be a non-null object and not an array");
1315
+ throw new Error(
1316
+ "Event payload must be a non-null object and not an array"
1317
+ );
1096
1318
  const r = this.createEventPayload(e, t);
1097
1319
  try {
1098
1320
  if (i) {
@@ -1105,28 +1327,30 @@ class N {
1105
1327
  }
1106
1328
  }
1107
1329
  rawTrack(e) {
1108
- if (!A(e))
1330
+ if (!S(e))
1109
1331
  throw new Error("Event payload must be an object");
1110
1332
  this.track("raw", e);
1111
1333
  }
1112
1334
  async group(e, t = !1) {
1113
- if (!A(e))
1335
+ if (!S(e))
1114
1336
  throw new Error("Company properties must be an object");
1115
1337
  if (!e.id || !e.name || !e.created_at)
1116
- throw new Error("Company properties must include id, name, and created_at");
1338
+ throw new Error(
1339
+ "Company properties must include id, name, and created_at"
1340
+ );
1117
1341
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1118
1342
  }
1119
1343
  createEventPayload(e, t) {
1120
- 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}`) || {};
1121
- let l = t || {};
1122
- const c = {
1123
- event_id: "",
1344
+ const { event_id: i, ...n } = t || {}, r = this.persistence.get("userProps") || {}, o = this.persistence.get("companyProps") || (r == null ? void 0 : r.company) || {}, a = this.persistence.get("userId"), c = this.persistence.get("global_props") || {}, h = this.persistence.get(`props_${e}`) || {};
1345
+ let f = n;
1346
+ const l = {
1347
+ event_id: i || x(),
1124
1348
  user: {
1125
1349
  anonymous_id: this.anonymousId,
1126
- id: r,
1127
- ...i
1350
+ id: a,
1351
+ ...r
1128
1352
  },
1129
- ...s && { company: s },
1353
+ ...o && { company: o },
1130
1354
  ids: this.getThirdPartyIds(),
1131
1355
  utc_time: (/* @__PURE__ */ new Date()).toISOString(),
1132
1356
  local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
@@ -1134,22 +1358,32 @@ class N {
1134
1358
  src: "usermaven",
1135
1359
  event_type: e,
1136
1360
  namespace: this.namespace,
1137
- ...o,
1138
- ...a
1361
+ ...c,
1362
+ ...h
1139
1363
  };
1140
1364
  if (e === "$autocapture") {
1141
- const d = this.processAutocaptureAttributes(t || {});
1142
- c.autocapture_attributes = d;
1143
- } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1144
- delete l[d];
1145
- }), c.event_attributes = l);
1146
- 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;
1365
+ const g = this.processAutocaptureAttributes(
1366
+ t || {}
1367
+ );
1368
+ l.autocapture_attributes = g;
1369
+ } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((g) => {
1370
+ delete f[g];
1371
+ }), l.event_attributes = f);
1372
+ return d() && (l.referer = document.referrer, l.url = window.location.href, l.page_title = document.title, l.doc_path = window.location.pathname, l.doc_host = window.location.hostname, l.doc_search = window.location.search, l.screen_resolution = `${window.screen.width}x${window.screen.height}`, l.vp_size = `${window.innerWidth}x${window.innerHeight}`, l.user_agent = navigator.userAgent, l.user_language = navigator.language, l.doc_encoding = document.characterSet, l.utm = this.getUtmParams()), l;
1147
1373
  }
1148
1374
  processAutocaptureAttributes(e) {
1149
1375
  let t = {};
1150
1376
  const i = e.$elements || [];
1151
- return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", ["$ce_version", "$event_type", "$initial_referrer", "$initial_referring_domain", "$referrer", "$referring_domain", "$elements"].forEach((s) => {
1152
- delete t[s];
1377
+ return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
1378
+ "$ce_version",
1379
+ "$event_type",
1380
+ "$initial_referrer",
1381
+ "$initial_referring_domain",
1382
+ "$referrer",
1383
+ "$referring_domain",
1384
+ "$elements"
1385
+ ].forEach((n) => {
1386
+ delete t[n];
1153
1387
  }), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
1154
1388
  }
1155
1389
  getCookie(e) {
@@ -1158,27 +1392,39 @@ class N {
1158
1392
  }
1159
1393
  getThirdPartyIds() {
1160
1394
  const e = {};
1161
- if (h()) {
1395
+ if (d()) {
1162
1396
  const t = this.getCookie("_fbp");
1163
1397
  t && (e.fbp = t);
1164
1398
  }
1165
1399
  return e;
1166
1400
  }
1167
1401
  getUtmParams() {
1168
- const e = {}, t = we(window.location.search);
1169
- return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
1170
- t[s] && (e[s.replace("utm_", "")] = t[s]);
1402
+ const e = {}, t = ke(window.location.search);
1403
+ return [
1404
+ "utm_source",
1405
+ "utm_medium",
1406
+ "utm_campaign",
1407
+ "utm_term",
1408
+ "utm_content"
1409
+ ].forEach((n) => {
1410
+ t[n] && (e[n.replace("utm_", "")] = t[n]);
1171
1411
  }), e;
1172
1412
  }
1173
1413
  pageview() {
1174
- h() ? this.track("pageview", {
1175
- url: window.location.href,
1176
- referrer: document.referrer,
1177
- title: document.title
1178
- }, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
1414
+ d() ? this.track(
1415
+ "pageview",
1416
+ {
1417
+ url: window.location.href,
1418
+ referrer: document.referrer,
1419
+ title: document.title
1420
+ },
1421
+ !0
1422
+ ) : this.logger.warn(
1423
+ "Pageview tracking is not available in server-side environments"
1424
+ );
1179
1425
  }
1180
1426
  setupPageLeaveTracking() {
1181
- if (!h()) return;
1427
+ if (!d()) return;
1182
1428
  let e = !1, t = !1;
1183
1429
  const i = () => {
1184
1430
  !e && !t && (e = !0, this.track("$pageleave", {
@@ -1194,9 +1440,9 @@ class N {
1194
1440
  }), document.addEventListener("visibilitychange", () => {
1195
1441
  document.visibilityState === "hidden" && !t && i();
1196
1442
  });
1197
- const s = history.pushState;
1443
+ const n = history.pushState;
1198
1444
  history.pushState = function() {
1199
- return i(), s.apply(this, arguments);
1445
+ return i(), n.apply(this, arguments);
1200
1446
  }, window.addEventListener("popstate", i);
1201
1447
  }
1202
1448
  getConfig() {
@@ -1210,12 +1456,15 @@ class N {
1210
1456
  const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1211
1457
  this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
1212
1458
  }
1213
- this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1459
+ this.logger.info("core state reset", {
1460
+ resetAnonId: e,
1461
+ namespace: this.namespace
1462
+ });
1214
1463
  }
1215
1464
  set(e, t) {
1216
- if (!A(e))
1465
+ if (!S(e))
1217
1466
  throw new Error("Properties must be an object");
1218
- const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1467
+ const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1219
1468
  if (i) {
1220
1469
  let r = this.persistence.get(`props_${i}`) || {};
1221
1470
  r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
@@ -1223,10 +1472,10 @@ class N {
1223
1472
  let r = this.persistence.get("global_props") || {};
1224
1473
  r = { ...r, ...e }, this.persistence.set("global_props", r);
1225
1474
  }
1226
- s && this.persistence.save(), this.logger.debug("Properties set", {
1475
+ n && this.persistence.save(), this.logger.debug("Properties set", {
1227
1476
  properties: e,
1228
1477
  eventType: i || "global",
1229
- persist: s
1478
+ persist: n
1230
1479
  });
1231
1480
  }
1232
1481
  setUserId(e) {
@@ -1235,7 +1484,7 @@ class N {
1235
1484
  t.id = e, this.persistence.set("userProps", t), this.persistence.save();
1236
1485
  }
1237
1486
  unset(e, t) {
1238
- const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1487
+ const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1239
1488
  if (i) {
1240
1489
  let r = this.persistence.get(`props_${i}`) || {};
1241
1490
  delete r[e], this.persistence.set(`props_${i}`, r);
@@ -1243,178 +1492,199 @@ class N {
1243
1492
  let r = this.persistence.get("global_props") || {};
1244
1493
  delete r[e], this.persistence.set("global_props", r);
1245
1494
  }
1246
- s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1495
+ n && this.persistence.save(), this.logger.debug(
1496
+ `Property unset: ${e}`,
1497
+ `Event type: ${i || "global"}`
1498
+ );
1247
1499
  }
1248
1500
  }
1249
- function te() {
1501
+ function ie() {
1250
1502
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1251
1503
  }
1252
- function Ce() {
1253
- return te() ? window.define : void 0;
1504
+ function xe() {
1505
+ return ie() ? window.define : void 0;
1254
1506
  }
1255
1507
  const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1256
- function I(n) {
1257
- const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
1508
+ function L(s) {
1509
+ const e = JSON.parse(JSON.stringify(s)), t = Q(e), i = {
1510
+ ...Y,
1511
+ ...t
1512
+ };
1258
1513
  if (!i.key)
1259
1514
  throw new Error("API key is required!");
1260
1515
  if (!i.trackingHost)
1261
1516
  throw new Error("Tracking host is required!");
1262
- const s = i.key || "", r = `${Te}${s}`;
1263
- 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);
1517
+ const n = i.key || "", r = `${Te}${n}`;
1518
+ return d() && i.autocapture && window[r] && (console.warn(
1519
+ "Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
1520
+ ), i.disableAutocaptureListenerRegistration = !0), d() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new R(i);
1264
1521
  }
1265
- function xe(n) {
1266
- var s;
1522
+ function He(s) {
1523
+ var n;
1267
1524
  const e = {
1268
- key: n.getAttribute("data-key") || void 0,
1269
- trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1270
- logLevel: ke(n.getAttribute("data-log-level")),
1271
- autocapture: n.getAttribute("data-autocapture") === "true",
1272
- formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
1273
- autoPageview: n.getAttribute("data-auto-pageview") === "true",
1274
- useBeaconApi: n.getAttribute("data-use-beacon-api") === "true",
1275
- forceUseFetch: n.getAttribute("data-force-use-fetch") === "true",
1276
- gaHook: n.getAttribute("data-ga-hook") === "true",
1277
- segmentHook: n.getAttribute("data-segment-hook") === "true",
1278
- randomizeUrl: n.getAttribute("data-randomize-url") === "true",
1279
- capture3rdPartyCookies: n.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1280
- idMethod: n.getAttribute("data-id-method") || void 0,
1281
- privacyPolicy: n.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1282
- ipPolicy: n.getAttribute("data-ip-policy") || void 0,
1283
- cookiePolicy: n.getAttribute("data-cookie-policy") || void 0,
1284
- minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1285
- maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1286
- maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1287
- propertiesStringMaxLength: parseInt(n.getAttribute("data-properties-string-max-length") || "", 10) || null,
1288
- propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
1289
- exclude: n.getAttribute("data-exclude") || void 0,
1290
- namespace: n.getAttribute("data-namespace") || void 0,
1291
- crossDomainLinking: n.getAttribute("data-cross-domain-linking") !== "false",
1292
- domains: n.getAttribute("data-domains") || void 0,
1293
- maskAllText: n.getAttribute("data-mask-all-text") === "true",
1294
- maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
1525
+ key: s.getAttribute("data-key") || void 0,
1526
+ trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1527
+ logLevel: ve(s.getAttribute("data-log-level")),
1528
+ autocapture: s.getAttribute("data-autocapture") === "true",
1529
+ formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
1530
+ autoPageview: s.getAttribute("data-auto-pageview") === "true",
1531
+ useBeaconApi: s.getAttribute("data-use-beacon-api") === "true",
1532
+ forceUseFetch: s.getAttribute("data-force-use-fetch") === "true",
1533
+ gaHook: s.getAttribute("data-ga-hook") === "true",
1534
+ segmentHook: s.getAttribute("data-segment-hook") === "true",
1535
+ randomizeUrl: s.getAttribute("data-randomize-url") === "true",
1536
+ capture3rdPartyCookies: s.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1537
+ idMethod: s.getAttribute("data-id-method") || void 0,
1538
+ privacyPolicy: s.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1539
+ ipPolicy: s.getAttribute("data-ip-policy") || void 0,
1540
+ cookiePolicy: s.getAttribute("data-cookie-policy") || void 0,
1541
+ minSendTimeout: parseInt(s.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1542
+ maxSendTimeout: parseInt(s.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1543
+ maxSendAttempts: parseInt(s.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1544
+ propertiesStringMaxLength: parseInt(
1545
+ s.getAttribute("data-properties-string-max-length") || "",
1546
+ 10
1547
+ ) || null,
1548
+ propertyBlacklist: ((n = s.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
1549
+ exclude: s.getAttribute("data-exclude") || void 0,
1550
+ namespace: s.getAttribute("data-namespace") || void 0,
1551
+ crossDomainLinking: s.getAttribute("data-cross-domain-linking") !== "false",
1552
+ domains: s.getAttribute("data-domains") || void 0,
1553
+ maskAllText: s.getAttribute("data-mask-all-text") === "true",
1554
+ maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
1295
1555
  };
1296
1556
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1297
- const t = I(e), i = e.namespace || "usermaven";
1298
- return h() && t.pageview(), He(i, t), t;
1557
+ const t = L(e), i = e.namespace || "usermaven";
1558
+ return d() && t.pageview(), Ie(i, t), t;
1299
1559
  }
1300
- function He(n, e) {
1560
+ function Ie(s, e) {
1301
1561
  let t = !1;
1302
- const i = [], s = [];
1562
+ const i = [], n = [];
1303
1563
  function r() {
1304
1564
  for (; i.length > 0; ) {
1305
1565
  const u = i.shift();
1306
1566
  if (u) {
1307
- const g = u[u.length - 1];
1308
- if (g && typeof g.resolve == "function") {
1309
- const m = u.pop();
1567
+ const m = u[u.length - 1];
1568
+ if (m && typeof m.resolve == "function") {
1569
+ const y = u.pop();
1310
1570
  try {
1311
- const b = a.apply(null, u);
1312
- b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
1313
- } catch (b) {
1314
- m.reject(b);
1571
+ const P = a.apply(null, u);
1572
+ P && typeof P.then == "function" ? P.then(y.resolve).catch(y.reject) : y.resolve(P);
1573
+ } catch (P) {
1574
+ y.reject(P);
1315
1575
  }
1316
1576
  } else
1317
1577
  try {
1318
1578
  a.apply(null, u);
1319
- } catch (m) {
1320
- console.error("Usermaven: Error processing queued command:", m);
1579
+ } catch (y) {
1580
+ console.error("Usermaven: Error processing queued command:", y);
1321
1581
  }
1322
1582
  }
1323
1583
  }
1324
1584
  }
1325
1585
  function o() {
1326
- s.forEach((u) => u()), s.length = 0;
1586
+ n.forEach((u) => u()), n.length = 0;
1327
1587
  }
1328
1588
  function a(...u) {
1329
- const g = u[0];
1330
- if (g === "onLoad") {
1331
- typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
1589
+ const m = u[0];
1590
+ if (m === "onLoad") {
1591
+ typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
1332
1592
  return;
1333
1593
  }
1334
1594
  if (!t) {
1335
1595
  i.push(u);
1336
1596
  return;
1337
1597
  }
1338
- if (typeof e[g] == "function")
1339
- return e[g].apply(e, u.slice(1));
1340
- console.error(`Method ${g} not found on UsermavenClient`);
1341
- }
1342
- const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
1343
- [...l, ...c].forEach((u) => {
1344
- a[u] = function(...g) {
1598
+ if (typeof e[m] == "function")
1599
+ return e[m].apply(e, u.slice(1));
1600
+ console.error(`Method ${m} not found on UsermavenClient`);
1601
+ }
1602
+ const c = ["id", "group", "reset"], h = [
1603
+ "track",
1604
+ "lead",
1605
+ "pageview",
1606
+ "set",
1607
+ "unset",
1608
+ "rawTrack",
1609
+ "setUserId"
1610
+ ];
1611
+ [...c, ...h].forEach((u) => {
1612
+ a[u] = function(...m) {
1345
1613
  if (!t) {
1346
- if (l.includes(u))
1347
- return new Promise((B, m) => {
1348
- i.push([u, ...g, { resolve: B, reject: m }]);
1614
+ if (c.includes(u))
1615
+ return new Promise((M, y) => {
1616
+ i.push([u, ...m, { resolve: M, reject: y }]);
1349
1617
  });
1350
- i.push([u, ...g]);
1618
+ i.push([u, ...m]);
1351
1619
  return;
1352
1620
  }
1353
1621
  if (typeof e[u] == "function")
1354
- return e[u].apply(e, g);
1622
+ return e[u].apply(e, m);
1355
1623
  };
1356
1624
  }), a.getConfig = function() {
1357
1625
  return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
1358
- }, window[n] = a;
1359
- const p = `${n}Q`, _ = window[p] || [];
1360
- for (window[p] = _, _.push = function(...u) {
1626
+ }, window[s] = a;
1627
+ const l = `${s}Q`, g = window[l] || [];
1628
+ for (window[l] = g, g.push = function(...u) {
1361
1629
  return a.apply(null, u), Array.prototype.push.apply(this, u);
1362
1630
  }, setTimeout(() => {
1363
- t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
1364
- }, 0); _.length > 0; ) {
1365
- const u = _.shift();
1631
+ t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
1632
+ }, 0); g.length > 0; ) {
1633
+ const u = g.shift();
1366
1634
  u && i.push(u);
1367
1635
  }
1368
1636
  }
1369
- let K = !1, L = null;
1370
- if (h()) {
1371
- const n = Ce();
1372
- n && n("usermaven", [], function() {
1637
+ let Z = !1, B = null;
1638
+ if (d()) {
1639
+ const s = xe();
1640
+ s && s("usermaven", [], function() {
1373
1641
  return {
1374
- usermavenClient: I,
1375
- UsermavenClient: N,
1376
- LogLevel: k,
1642
+ usermavenClient: L,
1643
+ UsermavenClient: R,
1644
+ LogLevel: _,
1377
1645
  // Expose the script tag client if it exists
1378
- getScriptTagClient: () => L
1646
+ getScriptTagClient: () => B
1379
1647
  };
1380
- }), typeof window < "u" && (window.usermavenClient = I, window.UsermavenClient = N, window.usermavenScriptTagClient = () => L), function(e, t) {
1648
+ }), typeof window < "u" && (window.usermavenClient = L, window.UsermavenClient = R, window.usermavenScriptTagClient = () => B), function(e, t) {
1381
1649
  const i = e.currentScript;
1382
- function s() {
1383
- return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1650
+ function n() {
1651
+ return Z || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1384
1652
  }
1385
1653
  function r() {
1386
- s() && (console.log("[Usermaven] Auto-initializing from script tag"), L = xe(i), K = !0);
1654
+ n() && (console.log("[Usermaven] Auto-initializing from script tag"), B = He(i), Z = !0);
1387
1655
  }
1388
1656
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1389
1657
  }(document, window);
1390
1658
  }
1391
- typeof module < "u" && module.exports && !te() && (module.exports = {
1392
- usermavenClient: I,
1393
- UsermavenClient: N,
1659
+ typeof module < "u" && module.exports && !ie() && (module.exports = {
1660
+ usermavenClient: L,
1661
+ UsermavenClient: R,
1394
1662
  Config: void 0,
1395
1663
  UserProps: void 0,
1396
1664
  EventPayload: void 0,
1397
- LogLevel: k,
1665
+ LogLevel: _,
1398
1666
  ClientProperties: void 0
1399
1667
  });
1400
1668
 
1401
1669
  function createClient(params) {
1402
- return I(params);
1670
+ return L(params);
1403
1671
  }
1404
1672
 
1405
1673
  function useUsermaven() {
1406
1674
  const client = useContext(UsermavenContext);
1407
1675
  if (!client) {
1408
- throw new Error("Before calling useUsermaven() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react");
1676
+ throw new Error('Before calling useUsermaven() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react');
1409
1677
  }
1410
1678
  const id = useCallback((userData, doNotSendEvent) => client === null || client === void 0 ? void 0 : client.id(userData, doNotSendEvent), [client]);
1411
1679
  const trackPageView = useCallback(() => client === null || client === void 0 ? void 0 : client.track('pageview'), [client]);
1412
1680
  const track = useCallback((typeName, payload) => client === null || client === void 0 ? void 0 : client.track(typeName, payload), [client]);
1681
+ const lead = useCallback((payload, directSend) => client === null || client === void 0 ? void 0 : client.lead(payload, directSend), [client]);
1413
1682
  const rawTrack = useCallback((payload) => client === null || client === void 0 ? void 0 : client.rawTrack(payload), [client]);
1414
1683
  const set = useCallback((properties, opts) => client === null || client === void 0 ? void 0 : client.set(properties, opts), [client]);
1415
1684
  const unset = useCallback((propertyName, opts) => client === null || client === void 0 ? void 0 : client.unset(propertyName, opts), [client]);
1416
1685
  return Object.assign(Object.assign({}, client), { id,
1417
1686
  track,
1687
+ lead,
1418
1688
  trackPageView,
1419
1689
  rawTrack,
1420
1690
  set,