@usermaven/react 1.5.5 → 1.5.6-rc.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.es.js +452 -409
  2. package/package.json +4 -4
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 v = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(v || {});
12
- class W {
11
+ var p = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(p || {});
12
+ class G {
13
13
  constructor(e) {
14
14
  this.level = e;
15
15
  }
@@ -26,18 +26,18 @@ class W {
26
26
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
27
27
  }
28
28
  }
29
- function d(i = 0) {
30
- return new W(i);
29
+ function d(n = 0) {
30
+ return new G(n);
31
31
  }
32
- const F = {
33
- logLevel: v.ERROR,
32
+ const q = {
33
+ logLevel: p.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
36
36
  trackingHost: "t.usermaven.com",
37
37
  autocapture: !1,
38
38
  rageClick: !1,
39
39
  formTracking: !1,
40
- autoPageview: !1,
40
+ autoPageview: !0,
41
41
  disableEventPersistence: !1,
42
42
  gaHook: !1,
43
43
  segmentHook: !1,
@@ -55,20 +55,20 @@ const F = {
55
55
  maskAllText: !1,
56
56
  maskAllElementAttributes: !1
57
57
  };
58
- class X {
58
+ class j {
59
59
  constructor(e) {
60
60
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
61
  }
62
- set(e, t, s = 365, n = !0, r = !1) {
62
+ set(e, t, i = 365, s = !0, r = !1) {
63
63
  const o = /* @__PURE__ */ new Date();
64
- o.setTime(o.getTime() + s * 24 * 60 * 60 * 1e3);
65
- const c = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", a = r ? "; HttpOnly" : "";
64
+ o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
65
+ const c = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", a = r ? "; HttpOnly" : "";
66
66
  document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
67
67
  }
68
68
  get(e) {
69
- const t = e + "=", s = document.cookie.split(";");
70
- for (let n = 0; n < s.length; n++) {
71
- let r = s[n].trim();
69
+ const t = e + "=", i = document.cookie.split(";");
70
+ for (let s = 0; s < i.length; s++) {
71
+ let r = i[s].trim();
72
72
  if (r.indexOf(t) === 0)
73
73
  return decodeURIComponent(r.substring(t.length));
74
74
  }
@@ -88,7 +88,7 @@ class X {
88
88
  }
89
89
  isIpAddress(e) {
90
90
  const t = e.split(".");
91
- return t.length === 4 && t.every((s) => !isNaN(Number(s)));
91
+ return t.length === 4 && t.every((i) => !isNaN(Number(i)));
92
92
  }
93
93
  extractHostname(e) {
94
94
  let t;
@@ -96,110 +96,110 @@ class X {
96
96
  }
97
97
  extractRootDomain(e) {
98
98
  let t = this.extractHostname(e);
99
- const s = t.split("."), n = s.length;
100
- return n > 2 && (s[n - 1].length == 2 ? (t = s[n - 2] + "." + s[n - 1], s[n - 2].length == 2 && (t = s[n - 3] + "." + t)) : t = s[n - 2] + "." + s[n - 1]), t;
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;
101
101
  }
102
102
  extractTopLevelDomain(e) {
103
- const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, s = e.match(t);
104
- return s ? s[0] : "";
103
+ const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
104
+ return i ? i[0] : "";
105
105
  }
106
106
  }
107
- const K = Object.prototype, G = K.hasOwnProperty, Y = Array.prototype, E = Y.forEach, A = {};
108
- function Z(i, e, t) {
109
- if (Array.isArray(i)) {
110
- if (E && i.forEach === E)
111
- i.forEach(e, t);
112
- else if ("length" in i && i.length === +i.length) {
113
- for (let s = 0, n = i.length; s < n; s++)
114
- if (s in i && e.call(t, i[s], s) === A)
107
+ const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, P = ie.forEach, N = {};
108
+ function ne(n, e, t) {
109
+ if (Array.isArray(n)) {
110
+ if (P && n.forEach === P)
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) === N)
115
115
  return;
116
116
  }
117
117
  }
118
118
  }
119
- const x = function(i) {
120
- return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, j = function(i) {
122
- for (const e in i)
123
- typeof i[e] == "function" && (i[e] = i[e].bind(i));
119
+ const R = function(n) {
120
+ return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
+ }, se = function(n) {
122
+ for (const e in n)
123
+ typeof n[e] == "function" && (n[e] = n[e].bind(n));
124
124
  };
125
- function f(i, e, t) {
126
- if (i != null) {
127
- if (E && Array.isArray(i) && i.forEach === E)
128
- i.forEach(e, t);
129
- else if ("length" in i && i.length === +i.length) {
130
- for (let s = 0, n = i.length; s < n; s++)
131
- if (s in i && e.call(t, i[s], s) === A)
125
+ function g(n, e, t) {
126
+ if (n != null) {
127
+ if (P && Array.isArray(n) && n.forEach === P)
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) === N)
132
132
  return;
133
133
  } else
134
- for (const s in i)
135
- if (G.call(i, s) && e.call(t, i[s], s) === A)
134
+ for (const i in n)
135
+ if (te.call(n, i) && e.call(t, n[i], i) === N)
136
136
  return;
137
137
  }
138
138
  }
139
- const ee = function(i, ...e) {
140
- return Z(e, function(t) {
141
- for (const s in t)
142
- t[s] !== void 0 && (i[s] = t[s]);
143
- }), i;
139
+ const re = function(n, ...e) {
140
+ return ne(e, function(t) {
141
+ for (const i in t)
142
+ t[i] !== void 0 && (n[i] = t[i]);
143
+ }), n;
144
144
  };
145
- function _(i, e) {
146
- return i.indexOf(e) !== -1;
145
+ function _(n, e) {
146
+ return n.indexOf(e) !== -1;
147
147
  }
148
- const te = function(i) {
148
+ const oe = function(n) {
149
149
  try {
150
- return /^\s*\bfunction\b/.test(i);
150
+ return /^\s*\bfunction\b/.test(n);
151
151
  } catch {
152
152
  return !1;
153
153
  }
154
- }, ie = function(i) {
155
- return i === void 0;
156
- }, m = function() {
157
- const i = function(s, n, r, o, c) {
158
- if (!s) {
154
+ }, ae = function(n) {
155
+ return n === void 0;
156
+ }, y = function() {
157
+ const n = function(i, s, r, o, c) {
158
+ if (!i) {
159
159
  d().error("No valid element provided to register_event");
160
160
  return;
161
161
  }
162
- if (s.addEventListener && !o)
163
- s.addEventListener(n, r, !!c);
162
+ if (i.addEventListener && !o)
163
+ i.addEventListener(s, r, !!c);
164
164
  else {
165
- const l = "on" + n, a = s[l];
166
- s[l] = e(s, r, a);
165
+ const l = "on" + s, a = i[l];
166
+ i[l] = e(i, r, a);
167
167
  }
168
168
  };
169
- function e(s, n, r) {
169
+ function e(i, s, r) {
170
170
  return function(o) {
171
171
  if (o = o || t(window.event), !o)
172
172
  return;
173
173
  let c = !0, l;
174
- te(r) && (l = r(o));
175
- const a = n.call(s, o);
174
+ oe(r) && (l = r(o));
175
+ const a = s.call(i, o);
176
176
  return (l === !1 || a === !1) && (c = !1), c;
177
177
  };
178
178
  }
179
- function t(s) {
180
- return s && (s.preventDefault = t.preventDefault, s.stopPropagation = t.stopPropagation), s;
179
+ function t(i) {
180
+ return i && (i.preventDefault = t.preventDefault, i.stopPropagation = t.stopPropagation), i;
181
181
  }
182
182
  return t.preventDefault = function() {
183
183
  this.returnValue = !1;
184
184
  }, t.stopPropagation = function() {
185
185
  this.cancelBubble = !0;
186
- }, i;
187
- }(), se = function(i) {
186
+ }, n;
187
+ }(), ce = function(n) {
188
188
  return function(...e) {
189
189
  try {
190
- return i.apply(this, e);
190
+ return n.apply(this, e);
191
191
  } catch (t) {
192
192
  d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
193
193
  }
194
194
  };
195
- }, z = function(i) {
196
- for (const e in i)
197
- typeof i[e] == "function" && (i[e] = se(i[e]));
195
+ }, V = function(n) {
196
+ for (const e in n)
197
+ typeof n[e] == "function" && (n[e] = ce(n[e]));
198
198
  };
199
- function R(i) {
200
- for (let e in i)
201
- (i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
202
- return i;
199
+ function U(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;
203
203
  }
204
204
  function u() {
205
205
  try {
@@ -208,80 +208,80 @@ function u() {
208
208
  return d().warn("window is not available"), !1;
209
209
  }
210
210
  }
211
- function p(i = 5) {
212
- const e = new Uint8Array(i);
213
- return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
211
+ function m(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);
214
214
  }
215
- function ne(i) {
216
- return i.replace(
215
+ function le(n) {
216
+ return n.replace(
217
217
  /([-_][a-z])/g,
218
218
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
219
  );
220
220
  }
221
- function H(i) {
222
- return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(H) : Object.keys(i).reduce((e, t) => {
223
- const s = ne(t);
224
- return e[s] = H(i[t]), e;
221
+ function I(n) {
222
+ return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(I) : Object.keys(n).reduce((e, t) => {
223
+ const i = le(t);
224
+ return e[i] = I(n[t]), e;
225
225
  }, {});
226
226
  }
227
- function $(i) {
228
- switch (typeof i.className) {
227
+ function A(n) {
228
+ switch (typeof n.className) {
229
229
  case "string":
230
- return i.className;
230
+ return n.className;
231
231
  case "object":
232
- return ("baseVal" in i.className ? i.className.baseVal : null) || i.getAttribute("class") || "";
232
+ return ("baseVal" in n.className ? n.className.baseVal : null) || n.getAttribute("class") || "";
233
233
  default:
234
234
  return "";
235
235
  }
236
236
  }
237
- function L(i) {
237
+ function D(n) {
238
238
  let e = "";
239
- return O(i) && !M(i) && i.childNodes && i.childNodes.length && f(i.childNodes, function(t) {
240
- q(t) && t.textContent && (e += x(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
- }), x(e);
239
+ return L(n) && !W(n) && n.childNodes && n.childNodes.length && g(n.childNodes, function(t) {
240
+ Q(t) && t.textContent && (e += R(t.textContent).split(/(\s+)/).filter(E).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
+ }), R(e);
242
242
  }
243
- function B(i) {
244
- return !!i && i.nodeType === 1;
243
+ function J(n) {
244
+ return !!n && n.nodeType === 1;
245
245
  }
246
- function g(i, e) {
247
- return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
246
+ function f(n, e) {
247
+ return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
248
248
  }
249
- function q(i) {
250
- return !!i && i.nodeType === 3;
249
+ function Q(n) {
250
+ return !!n && n.nodeType === 3;
251
251
  }
252
- function N(i) {
253
- return !!i && i.nodeType === 11;
252
+ function O(n) {
253
+ return !!n && n.nodeType === 11;
254
254
  }
255
255
  const b = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function re(i, e) {
257
- if (!i || g(i, "html") || !B(i))
256
+ function ue(n, e) {
257
+ if (!n || f(n, "html") || !J(n))
258
258
  return !1;
259
- let t = i;
260
- for (; t && !g(t, "body"); ) {
259
+ let t = n;
260
+ for (; t && !f(t, "body"); ) {
261
261
  if (t.classList && t.classList.contains("um-no-capture"))
262
262
  return !1;
263
- t.parentNode && N(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
263
+ t.parentNode && O(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
264
  }
265
- let s = !1;
266
- for (t = i; t && !g(t, "body"); ) {
267
- if (t.parentNode && N(t.parentNode)) {
268
- t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
265
+ let i = !1;
266
+ for (t = n; t && !f(t, "body"); ) {
267
+ if (t.parentNode && O(t.parentNode)) {
268
+ t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
269
269
  continue;
270
270
  }
271
271
  const o = t.parentNode;
272
272
  if (!o) break;
273
273
  if (b.indexOf(o.tagName.toLowerCase()) > -1)
274
- s = !0;
274
+ i = !0;
275
275
  else {
276
276
  const c = window.getComputedStyle(o);
277
- c && c.getPropertyValue("cursor") === "pointer" && (s = !0);
277
+ c && c.getPropertyValue("cursor") === "pointer" && (i = !0);
278
278
  }
279
279
  t = o;
280
280
  }
281
- const n = window.getComputedStyle(i);
282
- if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
281
+ const s = window.getComputedStyle(n);
282
+ if (s && s.getPropertyValue("cursor") === "pointer" && e.type === "click")
283
283
  return !0;
284
- const r = i.tagName.toLowerCase();
284
+ const r = n.tagName.toLowerCase();
285
285
  switch (r) {
286
286
  case "html":
287
287
  return !1;
@@ -293,18 +293,18 @@ function re(i, e) {
293
293
  case "textarea":
294
294
  return e.type === "change" || e.type === "click";
295
295
  default:
296
- return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
296
+ return i ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
297
297
  }
298
298
  }
299
- function O(i) {
300
- for (let s = i; s.parentNode && !g(s, "body"); s = s.parentNode) {
301
- const n = $(s).split(" ");
302
- if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
299
+ function L(n) {
300
+ for (let i = n; i.parentNode && !f(i, "body"); i = i.parentNode) {
301
+ const s = A(i).split(" ");
302
+ if (_(s, "ph-sensitive") || _(s, "ph-no-capture"))
303
303
  return !1;
304
304
  }
305
- if (_($(i).split(" "), "ph-include"))
305
+ if (_(A(n).split(" "), "ph-include"))
306
306
  return !0;
307
- const e = i.type || "";
307
+ const e = n.type || "";
308
308
  if (typeof e == "string")
309
309
  switch (e.toLowerCase()) {
310
310
  case "hidden":
@@ -312,61 +312,61 @@ function O(i) {
312
312
  case "password":
313
313
  return !1;
314
314
  }
315
- const t = i.name || i.id || "";
315
+ const t = n.name || n.id || "";
316
316
  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
317
  }
318
- function M(i) {
318
+ function W(n) {
319
319
  const e = ["button", "checkbox", "submit", "reset"];
320
- return !!(g(i, "input") && !e.includes(i.type) || g(i, "select") || g(i, "textarea") || i.getAttribute("contenteditable") === "true");
320
+ return !!(f(n, "input") && !e.includes(n.type) || f(n, "select") || f(n, "textarea") || n.getAttribute("contenteditable") === "true");
321
321
  }
322
- function P(i) {
323
- return !(i === null || ie(i) || typeof i == "string" && (i = x(i), /^(?:(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((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
322
+ function E(n) {
323
+ return !(n === null || ae(n) || typeof n == "string" && (n = R(n), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
324
324
  }
325
- function oe(i) {
326
- return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
325
+ function he(n) {
326
+ return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
327
327
  }
328
- function T() {
329
- return p(10);
328
+ function x() {
329
+ return m(10);
330
330
  }
331
- function ae(i) {
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(i).toLowerCase());
331
+ function de(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());
333
333
  }
334
- function ce(i, e) {
334
+ function fe(n, e) {
335
335
  let t;
336
- return function(...s) {
337
- const n = () => {
338
- clearTimeout(t), i(...s);
336
+ return function(...i) {
337
+ const s = () => {
338
+ clearTimeout(t), n(...i);
339
339
  };
340
- clearTimeout(t), t = setTimeout(n, e);
340
+ clearTimeout(t), t = setTimeout(s, e);
341
341
  };
342
342
  }
343
- function le(i) {
344
- const e = {}, t = i.replace(/^\?/, "").split("&");
345
- for (let s = 0; s < t.length; s++) {
346
- const n = t[s].split("=");
347
- n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
343
+ function ge(n) {
344
+ const e = {}, t = n.replace(/^\?/, "").split("&");
345
+ for (let i = 0; i < t.length; i++) {
346
+ const s = t[i].split("=");
347
+ s[0] !== "" && (e[decodeURIComponent(s[0])] = decodeURIComponent(s[1] || ""));
348
348
  }
349
349
  return e;
350
350
  }
351
- function I(i) {
352
- return typeof i == "string" || i instanceof String;
351
+ function F(n) {
352
+ return typeof n == "string" || n instanceof String;
353
353
  }
354
- function k(i) {
355
- return i !== null && typeof i == "object" && i.constructor === Object;
354
+ function v(n) {
355
+ return n !== null && typeof n == "object" && n.constructor === Object;
356
356
  }
357
- function ue(i) {
358
- if (i === null)
359
- return v.ERROR;
360
- const e = i.toUpperCase(), t = v[e];
361
- return t || t === 0 ? t : v.ERROR;
357
+ function pe(n) {
358
+ if (n === null)
359
+ return p.ERROR;
360
+ const e = n.toUpperCase(), t = p[e];
361
+ return t || t === 0 ? t : p.ERROR;
362
362
  }
363
- const he = () => {
364
- let i = "false";
365
- return typeof window < "u" && window.localStorage && (i = localStorage.getItem("um_exclusion")), !(i == null || i === "false");
363
+ const me = () => {
364
+ let n = "false";
365
+ return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
366
366
  };
367
- class de {
367
+ class ye {
368
368
  constructor(e) {
369
- this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ce(this.handleScroll.bind(this), 250), this.initializeEventListener();
369
+ this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = fe(this.handleScroll.bind(this), 250), this.initializeEventListener();
370
370
  }
371
371
  initializeEventListener() {
372
372
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -390,8 +390,8 @@ class de {
390
390
  this.track();
391
391
  }
392
392
  getScrollDepth() {
393
- const e = this.getWindowHeight(), t = this.getDocumentHeight(), s = this.getScrollDistance(), n = t - e;
394
- return Math.min(100, Math.floor(s / n * 100));
393
+ const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), s = t - e;
394
+ return Math.min(100, Math.floor(i / s * 100));
395
395
  }
396
396
  getWindowHeight() {
397
397
  return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
@@ -410,27 +410,38 @@ class de {
410
410
  return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
411
411
  }
412
412
  checkMilestones(e) {
413
- this.milestones.filter((s) => e >= s).forEach((s) => {
414
- this.send(), this.milestones = this.milestones.filter((n) => n !== s);
413
+ this.milestones.filter((i) => e >= i).forEach((i) => {
414
+ this.send(), this.milestones = this.milestones.filter((s) => s !== i);
415
415
  });
416
416
  }
417
417
  }
418
- const C = class C {
419
- constructor(e, t, s = d()) {
420
- this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new de(e), j(this), z(this);
418
+ const T = class T {
419
+ constructor(e, t, i = d()) {
420
+ this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new ye(e), se(this), V(this);
421
+ }
422
+ isBrowserSupported() {
423
+ return typeof document < "u" && typeof document.addEventListener == "function";
421
424
  }
422
425
  init() {
426
+ if (!this.isBrowserSupported()) {
427
+ this.logger.debug("Browser not supported for autocapture");
428
+ return;
429
+ }
430
+ if (this.domHandlersAttached) {
431
+ this.logger.debug("Autocapture already initialized.");
432
+ return;
433
+ }
423
434
  if (!(document && document.body)) {
424
435
  this.logger.debug("Document not ready yet, trying again in 500 milliseconds..."), setTimeout(() => this.init(), 500);
425
436
  return;
426
437
  }
427
- this.addDomEventHandlers();
438
+ this.addDomEventHandlers(), this.domHandlersAttached = !0;
428
439
  }
429
440
  addDomEventHandlers() {
430
441
  const e = (t) => {
431
442
  t = t || window.event, this.captureEvent(t);
432
443
  };
433
- m(document, "submit", e, !1, !0), m(document, "change", e, !1, !0), m(document, "click", e, !1, !0), m(document, "visibilitychange", e, !1, !0), m(document, "scroll", e, !1, !0), m(window, "popstate", e, !1, !0);
444
+ y(document, "submit", e, !1, !0), y(document, "change", e, !1, !0), y(document, "click", e, !1, !0), y(document, "visibilitychange", e, !1, !0), y(document, "scroll", e, !1, !0), y(window, "popstate", e, !1, !0);
434
445
  }
435
446
  isPageRefresh() {
436
447
  if ("PerformanceNavigationTiming" in window) {
@@ -441,17 +452,17 @@ const C = class C {
441
452
  return performance.navigation && performance.navigation.type === 1;
442
453
  }
443
454
  captureEvent(e) {
444
- var s, n;
455
+ var i, s;
445
456
  let t = this.getEventTarget(e);
446
- if (q(t) && (t = t.parentNode || null), e.type === "scroll")
447
- return (s = this.scrollDepth) == null || s.track(), !0;
457
+ if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
458
+ return (i = this.scrollDepth) == null || i.track(), !0;
448
459
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
449
- return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
450
- if (t && re(t, e)) {
460
+ return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
461
+ if (t && ue(t, e)) {
451
462
  const r = [t];
452
463
  let o = t;
453
- for (; o.parentNode && !g(o, "body"); ) {
454
- if (N(o.parentNode)) {
464
+ for (; o.parentNode && !f(o, "body"); ) {
465
+ if (O(o.parentNode)) {
455
466
  r.push(o.parentNode.host), o = o.parentNode.host;
456
467
  continue;
457
468
  }
@@ -459,20 +470,20 @@ const C = class C {
459
470
  }
460
471
  const c = [];
461
472
  let l, a = !1;
462
- if (f(r, (w) => {
463
- const J = O(w);
464
- w.tagName.toLowerCase() === "a" && (l = w.getAttribute("href"), l = J && P(l) && l);
465
- const Q = $(w).split(" ");
466
- _(Q, "ph-no-capture") && (a = !0), c.push(
473
+ if (g(r, (k) => {
474
+ const Z = L(k);
475
+ k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = Z && E(l) && l);
476
+ const Y = A(k).split(" ");
477
+ _(Y, "ph-no-capture") && (a = !0), c.push(
467
478
  this.getPropertiesFromElement(
468
- w,
479
+ k,
469
480
  this.options.maskAllElementAttributes ?? !1,
470
481
  this.options.maskAllText ?? !1
471
482
  )
472
483
  );
473
- }), this.options.maskAllText || (c[0].$el_text = L(t)), l && (c[0].attr__href = l), a)
484
+ }), this.options.maskAllText || (c[0].$el_text = D(t)), l && (c[0].attr__href = l), a)
474
485
  return !1;
475
- const h = ee(
486
+ const h = re(
476
487
  this.getDefaultProperties(e.type),
477
488
  {
478
489
  $elements: c
@@ -484,36 +495,36 @@ const C = class C {
484
495
  }
485
496
  getCustomProperties(e) {
486
497
  const t = {};
487
- return f(this.customProperties, (s) => {
488
- f(s.event_selectors, (n) => {
489
- const r = document.querySelectorAll(n);
490
- f(r, (o) => {
491
- _(e, o) && O(o) && (t[s.name] = this.extractCustomPropertyValue(s));
498
+ return g(this.customProperties, (i) => {
499
+ g(i.event_selectors, (s) => {
500
+ const r = document.querySelectorAll(s);
501
+ g(r, (o) => {
502
+ _(e, o) && L(o) && (t[i.name] = this.extractCustomPropertyValue(i));
492
503
  });
493
504
  });
494
505
  }), t;
495
506
  }
496
507
  extractCustomPropertyValue(e) {
497
508
  const t = [];
498
- return f(document.querySelectorAll(e.css_selector), function(s) {
499
- let n;
500
- ["input", "select"].indexOf(s.tagName.toLowerCase()) > -1 ? n = s.value : s.textContent && (n = s.textContent), P(n) && t.push(n);
509
+ return g(document.querySelectorAll(e.css_selector), function(i) {
510
+ let s;
511
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), E(s) && t.push(s);
501
512
  }), t.join(", ");
502
513
  }
503
514
  getEventTarget(e) {
504
515
  var t;
505
516
  return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
506
517
  }
507
- getPropertiesFromElement(e, t, s) {
508
- const n = e.tagName.toLowerCase(), r = {
509
- tag_name: n
518
+ getPropertiesFromElement(e, t, i) {
519
+ const s = e.tagName.toLowerCase(), r = {
520
+ tag_name: s
510
521
  };
511
- b.indexOf(n) > -1 && !s && (r.$el_text = L(e));
512
- const o = $(e);
522
+ b.indexOf(s) > -1 && !i && (r.$el_text = D(e));
523
+ const o = A(e);
513
524
  o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
514
525
  return h !== "";
515
- })), f(e.attributes, function(h) {
516
- M(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !oe(h.name) && (r["attr__" + h.name] = h.value);
526
+ })), g(e.attributes, function(h) {
527
+ W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && E(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
517
528
  });
518
529
  let c = 1, l = 1, a = e;
519
530
  for (; a = this.previousElementSibling(a); )
@@ -527,7 +538,7 @@ const C = class C {
527
538
  let t = e;
528
539
  do
529
540
  t = t.previousSibling;
530
- while (t && !B(t));
541
+ while (t && !J(t));
531
542
  return t;
532
543
  }
533
544
  }
@@ -540,18 +551,18 @@ const C = class C {
540
551
  encodeHtml(e) {
541
552
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
542
553
  }
543
- static enabledForProject(e, t = 10, s = 10) {
554
+ static enabledForProject(e, t = 10, i = 10) {
544
555
  if (!e)
545
556
  return !1;
546
- let n = 0;
557
+ let s = 0;
547
558
  for (let r = 0; r < e.length; r++)
548
- n += e.charCodeAt(r);
549
- return n % t < s;
559
+ s += e.charCodeAt(r);
560
+ return s % t < i;
550
561
  }
551
562
  };
552
- C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
553
- let S = C;
554
- class ge {
563
+ T.FORCE_CAPTURE_ATTR = "data-um-force-capture", T.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
564
+ let $ = T;
565
+ class we {
555
566
  constructor(e) {
556
567
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
557
568
  }
@@ -580,44 +591,44 @@ class ge {
580
591
  }));
581
592
  }
582
593
  }
583
- class fe {
584
- constructor(e, t, s = d()) {
585
- this.trackingHost = e, this.logger = s, this.config = t;
594
+ class ke {
595
+ constructor(e, t, i = d()) {
596
+ this.trackingHost = e, this.logger = i, this.config = t;
586
597
  }
587
598
  async send(e) {
588
- const t = this.config.key, s = this.constructUrl(t), n = new Blob([JSON.stringify(e)], { type: "application/json" });
589
- if (navigator.sendBeacon(s, n))
599
+ const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], { type: "application/json" });
600
+ if (navigator.sendBeacon(i, s))
590
601
  this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
591
602
  else
592
603
  throw new Error("Failed to queue events via Beacon API");
593
604
  }
594
605
  constructUrl(e) {
595
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
596
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
606
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
607
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
597
608
  }
598
609
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
599
610
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
600
611
  }
601
- class D {
602
- constructor(e, t, s = d()) {
603
- this.trackingHost = e, this.logger = s, this.config = t;
612
+ class z {
613
+ constructor(e, t, i = d()) {
614
+ this.trackingHost = e, this.logger = i, this.config = t;
604
615
  }
605
616
  async send(e) {
606
- const t = this.config.key, s = this.constructUrl(t), n = JSON.stringify(e), r = {
617
+ const t = this.config.key, i = this.constructUrl(t), s = JSON.stringify(e), r = {
607
618
  "Content-Type": "application/json",
608
619
  ...this.getCustomHeaders()
609
- }, o = await fetch(s, {
620
+ }, o = await fetch(i, {
610
621
  method: "POST",
611
622
  headers: r,
612
- body: n
623
+ body: s
613
624
  });
614
625
  if (!o.ok)
615
626
  throw new Error(`HTTP error! status: ${o.status}`);
616
627
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
617
628
  }
618
629
  constructUrl(e) {
619
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
620
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
630
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
631
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
621
632
  }
622
633
  getCustomHeaders() {
623
634
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -626,27 +637,27 @@ class D {
626
637
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
627
638
  }
628
639
  }
629
- class pe {
630
- constructor(e, t, s = d()) {
631
- this.trackingHost = e, this.logger = s, this.config = t;
640
+ class ve {
641
+ constructor(e, t, i = d()) {
642
+ this.trackingHost = e, this.logger = i, this.config = t;
632
643
  }
633
644
  send(e) {
634
- return new Promise((t, s) => {
635
- const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
636
- n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
645
+ return new Promise((t, i) => {
646
+ const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
647
+ s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
637
648
  const c = this.getCustomHeaders();
638
649
  Object.keys(c).forEach((l) => {
639
- n.setRequestHeader(l, c[l]);
640
- }), n.onload = () => {
641
- n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : s(new Error(`HTTP error! status: ${n.status}`));
642
- }, n.onerror = () => {
643
- s(new Error("Network error"));
644
- }, n.send(JSON.stringify(e));
650
+ s.setRequestHeader(l, c[l]);
651
+ }), s.onload = () => {
652
+ s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
653
+ }, s.onerror = () => {
654
+ i(new Error("Network error"));
655
+ }, s.send(JSON.stringify(e));
645
656
  });
646
657
  }
647
658
  constructUrl(e) {
648
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
649
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
659
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
660
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
650
661
  }
651
662
  getCustomHeaders() {
652
663
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -655,7 +666,7 @@ class pe {
655
666
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
656
667
  }
657
668
  }
658
- class V {
669
+ class K {
659
670
  constructor(e, t) {
660
671
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
661
672
  }
@@ -695,7 +706,7 @@ class V {
695
706
  }
696
707
  }
697
708
  }
698
- class me {
709
+ class _e {
699
710
  constructor() {
700
711
  this.storage = {};
701
712
  }
@@ -714,10 +725,10 @@ class me {
714
725
  this.storage = {};
715
726
  }
716
727
  }
717
- class U {
728
+ class B {
718
729
  // Default to true for server-side
719
- constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = d(), c = "default") {
720
- this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new V(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
730
+ constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = d(), c = "default") {
731
+ this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new K(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
721
732
  }
722
733
  add(e) {
723
734
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -736,11 +747,11 @@ class U {
736
747
  async processBatch() {
737
748
  if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
738
749
  this.processing = !0;
739
- const e = this.queue.splice(0, this.batchSize), t = e.map((s) => s.payload);
750
+ const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
740
751
  try {
741
752
  await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
742
- } catch (s) {
743
- this.logger.error("Failed to send batch", s), await this.handleBatchFailure(e);
753
+ } catch (i) {
754
+ this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
744
755
  }
745
756
  this.processing = !1;
746
757
  }
@@ -761,9 +772,9 @@ class U {
761
772
  u() && this.persistence.set("queue", JSON.stringify(this.queue));
762
773
  }
763
774
  }
764
- class ye {
775
+ class be {
765
776
  constructor(e) {
766
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
777
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
767
778
  }
768
779
  initializeEventListener() {
769
780
  document.addEventListener("click", this.handleClick.bind(this));
@@ -775,17 +786,17 @@ class ye {
775
786
  shouldCaptureElement(e) {
776
787
  return !e.closest(".um-no-capture");
777
788
  }
778
- click(e, t, s) {
779
- const n = { x: e, y: t, timestamp: s };
780
- this.clicks.push(n), this.clicks = this.clicks.filter((r) => s - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
789
+ click(e, t, i) {
790
+ const s = { x: e, y: t, timestamp: i };
791
+ this.clicks.push(s), this.clicks = this.clicks.filter((r) => i - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
781
792
  }
782
793
  checkRageClick() {
783
- const e = this.clicks[0], s = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
794
+ const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
784
795
  this.clicks.every((r, o) => {
785
796
  if (o === 0) return !0;
786
797
  const c = this.clicks[o - 1];
787
798
  return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
788
- }) && this.sendRageClickEvent(s);
799
+ }) && this.sendRageClickEvent(i);
789
800
  }
790
801
  sendRageClickEvent(e) {
791
802
  const t = this.clicks[this.clicks.length - 1];
@@ -795,15 +806,15 @@ class ye {
795
806
  }), this.clicks = [];
796
807
  }
797
808
  }
798
- class we {
799
- constructor(e, t, s = d()) {
800
- this.trackingHost = e, this.logger = s, this.config = t;
809
+ class Ee {
810
+ constructor(e, t, i = d()) {
811
+ this.trackingHost = e, this.logger = i, this.config = t;
801
812
  }
802
813
  async send(e) {
803
- const t = this.config.key, s = new (void 0)(this.constructUrl(t)), n = {
804
- hostname: s.hostname,
814
+ const t = this.config.key, i = new (void 0)(this.constructUrl(t)), s = {
815
+ hostname: i.hostname,
805
816
  port: 443,
806
- path: `${s.pathname}${s.search}`,
817
+ path: `${i.pathname}${i.search}`,
807
818
  method: "POST",
808
819
  headers: {
809
820
  "Content-Type": "application/json",
@@ -811,7 +822,7 @@ class we {
811
822
  }
812
823
  };
813
824
  return new Promise((r, o) => {
814
- const c = (void 0)(n, (l) => {
825
+ const c = (void 0)(s, (l) => {
815
826
  l.on("data", (a) => {
816
827
  }), l.on("end", () => {
817
828
  const a = l.statusCode || 0;
@@ -824,16 +835,16 @@ class we {
824
835
  });
825
836
  }
826
837
  constructUrl(e) {
827
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
828
- return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${s}`;
838
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
839
+ return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${i}`;
829
840
  }
830
841
  getCustomHeaders() {
831
842
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
832
843
  }
833
844
  }
834
- class y {
835
- constructor(e, t = "all", s = {}) {
836
- this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
845
+ class w {
846
+ constructor(e, t = "all", i = {}) {
847
+ this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
837
848
  }
838
849
  initialize() {
839
850
  this.trackingType !== "none" && this.setupFormTracking();
@@ -845,19 +856,19 @@ class y {
845
856
  });
846
857
  }
847
858
  handleFormSubmit(e) {
848
- const t = e.target, s = this._getFormDetails(t);
849
- this.instance.track("$form", R(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
859
+ const t = e.target, i = this._getFormDetails(t);
860
+ this.instance.track("$form", U(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
850
861
  }
851
862
  trackFieldChanges(e) {
852
- e.querySelectorAll("input, select, textarea").forEach((s) => {
853
- s.addEventListener("change", (n) => {
854
- const r = this._getFieldProps(n.target, 0);
855
- this.instance.track("$form_field_change", R(r));
863
+ e.querySelectorAll("input, select, textarea").forEach((i) => {
864
+ i.addEventListener("change", (s) => {
865
+ const r = this._getFieldProps(s.target, 0);
866
+ this.instance.track("$form_field_change", U(r));
856
867
  });
857
868
  });
858
869
  }
859
- static getInstance(e, t = "all", s = {}) {
860
- return y.instance || (y.instance = new y(e, t, s)), y.instance;
870
+ static getInstance(e, t = "all", i = {}) {
871
+ return w.instance || (w.instance = new w(e, t, i)), w.instance;
861
872
  }
862
873
  _getFormDetails(e) {
863
874
  const t = {
@@ -867,20 +878,20 @@ class y {
867
878
  form_method: e.method,
868
879
  form_class: e.className,
869
880
  form_attributes: this._getElementAttributes(e)
870
- }, s = e.querySelectorAll("input, select, textarea");
871
- return Array.from(s).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
881
+ }, i = e.querySelectorAll("input, select, textarea");
882
+ return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
872
883
  const c = this._getFieldProps(r, o);
873
884
  Object.assign(t, c);
874
885
  }), t;
875
886
  }
876
887
  _getFieldProps(e, t) {
877
- const s = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, n = this.getSafeText(e);
888
+ const i = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, s = this.getSafeText(e);
878
889
  return {
879
890
  [`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
880
891
  [`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
881
- [`field_${t + 1}_data_attributes`]: s,
892
+ [`field_${t + 1}_data_attributes`]: i,
882
893
  [`field_${t + 1}_id`]: e.id,
883
- [`field_${t + 1}_value`]: n,
894
+ [`field_${t + 1}_value`]: s,
884
895
  [`field_${t + 1}_class`]: e.className,
885
896
  [`field_${t + 1}_name`]: e.name,
886
897
  [`field_${t + 1}_attributes`]: this._getElementAttributes(e)
@@ -892,8 +903,8 @@ class y {
892
903
  getSafeText(e) {
893
904
  let t = "";
894
905
  return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
895
- (n) => n.nodeType === Node.TEXT_NODE
896
- ).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
906
+ (s) => s.nodeType === Node.TEXT_NODE
907
+ ).map((s) => s.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
897
908
  }
898
909
  _scrubPotentiallySensitiveValues(e) {
899
910
  return this._shouldCaptureValue(e) ? e : "<redacted>";
@@ -910,8 +921,8 @@ class y {
910
921
  _trim(e) {
911
922
  if (typeof String.prototype.trim == "function")
912
923
  return e.trim();
913
- let t = 0, s = e.length - 1;
914
- const n = [
924
+ let t = 0, i = e.length - 1;
925
+ const s = [
915
926
  " ",
916
927
  `
917
928
  `,
@@ -938,16 +949,16 @@ class y {
938
949
  " ",
939
950
  " "
940
951
  ].join("");
941
- for (; t <= s && n.indexOf(e[t]) > -1; )
952
+ for (; t <= i && s.indexOf(e[t]) > -1; )
942
953
  t++;
943
- for (; s >= t && n.indexOf(e[s]) > -1; )
944
- s--;
945
- return e.slice(t, s + 1);
954
+ for (; i >= t && s.indexOf(e[i]) > -1; )
955
+ i--;
956
+ return e.slice(t, i + 1);
946
957
  }
947
958
  }
948
- class ke {
959
+ class S {
949
960
  constructor(e) {
950
- this.config = this.mergeConfig(e, F), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new U(
961
+ this.config = this.mergeConfig(e, q), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new B(
951
962
  this.transport,
952
963
  this.config.maxSendAttempts || 3,
953
964
  this.config.minSendTimeout || 1e3,
@@ -959,13 +970,13 @@ class ke {
959
970
  ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
960
971
  }
961
972
  initializeBrowserFeatures() {
962
- if (this.cookieManager = new X(this.config.cookieDomain), this.config.autocapture && S.enabledForProject(this.config.key) && (this.autoCapture = new S(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
973
+ if (this.cookieManager = new j(this.config.cookieDomain), this.config.autocapture && $.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new $(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
963
974
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
964
- this.formTracking = y.getInstance(this, e || "none", {
975
+ this.formTracking = w.getInstance(this, e || "none", {
965
976
  trackFieldChanges: !1
966
977
  });
967
978
  }
968
- this.config.autoPageview && (this.pageviewTracking = new ge(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new ye(this)), this.setupPageLeaveTracking();
979
+ this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
969
980
  }
970
981
  /**
971
982
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -973,14 +984,14 @@ class ke {
973
984
  * @param defaultConfig
974
985
  */
975
986
  mergeConfig(e, t) {
976
- const s = JSON.parse(JSON.stringify(e));
977
- let n = { ...t, ...s };
987
+ const i = JSON.parse(JSON.stringify(e));
988
+ let s = { ...t, ...i };
978
989
  return Object.keys(t).forEach((r) => {
979
- k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
980
- }), n;
990
+ v(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
991
+ }), s;
981
992
  }
982
993
  init(e) {
983
- this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new U(
994
+ this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new B(
984
995
  this.transport,
985
996
  this.config.maxSendAttempts || 3,
986
997
  this.config.minSendTimeout || 1e3,
@@ -994,17 +1005,17 @@ class ke {
994
1005
  manageCrossDomainLinking() {
995
1006
  if (!this.config.crossDomainLinking || !this.config.domains)
996
1007
  return;
997
- const e = this.config.domains.split(",").map((s) => s.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
998
- document.addEventListener("click", (s) => {
1008
+ const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1009
+ document.addEventListener("click", (i) => {
999
1010
  var c;
1000
- const n = this.findClosestLink(s.target);
1001
- if (!n) return;
1002
- const r = n.getAttribute("href");
1011
+ const s = this.findClosestLink(i.target);
1012
+ if (!s) return;
1013
+ const r = s.getAttribute("href");
1003
1014
  if (!r || !r.startsWith("http")) return;
1004
1015
  const o = new URL(r);
1005
1016
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1006
1017
  const l = (c = this.cookieManager) == null ? void 0 : c.get(t);
1007
- l && (o.searchParams.append("_um", l), n.setAttribute("href", o.toString()));
1018
+ l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
1008
1019
  }
1009
1020
  }), this.logger.debug("Cross-domain linking initialized");
1010
1021
  }
@@ -1016,72 +1027,72 @@ class ke {
1016
1027
  initializeTransport(e) {
1017
1028
  const t = "https://events.usermaven.com";
1018
1029
  if (!u())
1019
- return new we(e.trackingHost || t, e);
1020
- const s = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1030
+ return new Ee(e.trackingHost || t, e);
1031
+ const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1021
1032
  if (e.useBeaconApi && r)
1022
- return new fe(e.trackingHost || t, e, this.logger);
1023
- if (e.forceUseFetch && n)
1024
- return new D(e.trackingHost || t, e, this.logger);
1033
+ return new ke(e.trackingHost || t, e, this.logger);
1034
+ if (e.forceUseFetch && s)
1035
+ return new z(e.trackingHost || t, e, this.logger);
1036
+ if (i)
1037
+ return new ve(e.trackingHost || t, e, this.logger);
1025
1038
  if (s)
1026
- return new pe(e.trackingHost || t, e, this.logger);
1027
- if (n)
1028
- return new D(e.trackingHost || t, e, this.logger);
1039
+ return new z(e.trackingHost || t, e, this.logger);
1029
1040
  throw new Error("No suitable transport method available");
1030
1041
  }
1031
1042
  initializePersistence() {
1032
- return this.config.disableEventPersistence || !u() ? new me() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1043
+ return this.config.disableEventPersistence || !u() ? new _e() : new K(`${this.namespace}_${this.config.key}`, this.logger);
1033
1044
  }
1034
1045
  getOrCreateAnonymousId() {
1035
- var s, n;
1046
+ var i, s;
1036
1047
  if (!u())
1037
- return T();
1048
+ return x();
1038
1049
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1039
1050
  return "";
1040
1051
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1041
- let t = (s = this.cookieManager) == null ? void 0 : s.get(e);
1052
+ let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1042
1053
  if (!t) {
1043
1054
  if (this.config.crossDomainLinking) {
1044
1055
  const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
1045
- t = c || h || T();
1056
+ t = c || h || x();
1046
1057
  }
1047
- t || (t = T());
1058
+ t || (t = x());
1048
1059
  const r = 365 * 10;
1049
- (n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
1060
+ (s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
1050
1061
  }
1051
1062
  return t;
1052
1063
  }
1053
1064
  async id(e, t = !1) {
1054
- if (!k(e))
1065
+ if (!v(e))
1055
1066
  throw new Error("User data must be an object");
1056
- if (e.email && !ae(e.email))
1067
+ if (e.email && !de(e.email))
1057
1068
  throw new Error("Invalid email provided");
1058
- if (!e.id || !I(e.id))
1069
+ if (!e.id || !F(e.id))
1059
1070
  throw new Error("User ID must be a string");
1060
- const s = e.id;
1061
- if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
1062
- const n = {
1071
+ const i = e.id;
1072
+ if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
1073
+ const s = {
1063
1074
  ...e,
1064
1075
  anonymous_id: this.anonymousId
1065
1076
  };
1066
- await this.track("user_identify", n);
1077
+ await this.track("user_identify", s);
1067
1078
  }
1068
1079
  this.logger.info("User identified:", e);
1069
1080
  }
1070
- track(e, t, s = !1) {
1071
- this.trackInternal(e, t, s);
1081
+ track(e, t, i = !1) {
1082
+ this.trackInternal(e, t, i);
1072
1083
  }
1073
- trackInternal(e, t, s = !1) {
1074
- if (he()) {
1084
+ trackInternal(e, t, i = !1) {
1085
+ if (me()) {
1075
1086
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1076
1087
  return;
1077
1088
  }
1078
- if (!I(e))
1089
+ if (!F(e))
1079
1090
  throw new Error("Event name must be a string");
1080
1091
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1081
1092
  throw new Error("Event payload must be a non-null object and not an array");
1082
1093
  const r = this.createEventPayload(e, t);
1083
1094
  try {
1084
- if (s) {
1095
+ if (i) {
1085
1096
  this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
1086
1097
  return;
1087
1098
  }
@@ -1091,28 +1102,28 @@ class ke {
1091
1102
  }
1092
1103
  }
1093
1104
  rawTrack(e) {
1094
- if (!k(e))
1105
+ if (!v(e))
1095
1106
  throw new Error("Event payload must be an object");
1096
1107
  this.track("raw", e);
1097
1108
  }
1098
1109
  async group(e, t = !1) {
1099
- if (!k(e))
1110
+ if (!v(e))
1100
1111
  throw new Error("Company properties must be an object");
1101
1112
  if (!e.id || !e.name || !e.created_at)
1102
1113
  throw new Error("Company properties must include id, name, and created_at");
1103
1114
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1104
1115
  }
1105
1116
  createEventPayload(e, t) {
1106
- const s = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || (s == null ? void 0 : s.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1117
+ const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1107
1118
  let l = t || {};
1108
1119
  const a = {
1109
1120
  event_id: "",
1110
1121
  user: {
1111
1122
  anonymous_id: this.anonymousId,
1112
1123
  id: r,
1113
- ...s
1124
+ ...i
1114
1125
  },
1115
- ...n && { company: n },
1126
+ ...s && { company: s },
1116
1127
  ids: this.getThirdPartyIds(),
1117
1128
  utc_time: (/* @__PURE__ */ new Date()).toISOString(),
1118
1129
  local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
@@ -1133,9 +1144,9 @@ class ke {
1133
1144
  }
1134
1145
  processAutocaptureAttributes(e) {
1135
1146
  let t = {};
1136
- const s = e.$elements || [];
1137
- return s.length && (t = { ...s[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((n) => {
1138
- delete t[n];
1147
+ const i = e.$elements || [];
1148
+ 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) => {
1149
+ delete t[s];
1139
1150
  }), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
1140
1151
  }
1141
1152
  getCookie(e) {
@@ -1151,9 +1162,9 @@ class ke {
1151
1162
  return e;
1152
1163
  }
1153
1164
  getUtmParams() {
1154
- const e = {}, t = le(window.location.search);
1155
- return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((n) => {
1156
- t[n] && (e[n.replace("utm_", "")] = t[n]);
1165
+ const e = {}, t = ge(window.location.search);
1166
+ return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
1167
+ t[s] && (e[s.replace("utm_", "")] = t[s]);
1157
1168
  }), e;
1158
1169
  }
1159
1170
  pageview() {
@@ -1166,7 +1177,7 @@ class ke {
1166
1177
  setupPageLeaveTracking() {
1167
1178
  if (!u()) return;
1168
1179
  let e = !1, t = !1;
1169
- const s = () => {
1180
+ const i = () => {
1170
1181
  !e && !t && (e = !0, this.track("$pageleave", {
1171
1182
  url: window.location.href,
1172
1183
  referrer: document.referrer,
@@ -1178,12 +1189,12 @@ class ke {
1178
1189
  t = !1;
1179
1190
  }, 100);
1180
1191
  }), document.addEventListener("visibilitychange", () => {
1181
- document.visibilityState === "hidden" && !t && s();
1192
+ document.visibilityState === "hidden" && !t && i();
1182
1193
  });
1183
- const n = history.pushState;
1194
+ const s = history.pushState;
1184
1195
  history.pushState = function() {
1185
- return s(), n.apply(this, arguments);
1186
- }, window.addEventListener("popstate", s);
1196
+ return i(), s.apply(this, arguments);
1197
+ }, window.addEventListener("popstate", i);
1187
1198
  }
1188
1199
  getConfig() {
1189
1200
  return this.config;
@@ -1199,20 +1210,20 @@ class ke {
1199
1210
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1200
1211
  }
1201
1212
  set(e, t) {
1202
- if (!k(e))
1213
+ if (!v(e))
1203
1214
  throw new Error("Properties must be an object");
1204
- const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1205
- if (s) {
1206
- let r = this.persistence.get(`props_${s}`) || {};
1207
- r = { ...r, ...e }, this.persistence.set(`props_${s}`, r);
1215
+ const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1216
+ if (i) {
1217
+ let r = this.persistence.get(`props_${i}`) || {};
1218
+ r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
1208
1219
  } else {
1209
1220
  let r = this.persistence.get("global_props") || {};
1210
1221
  r = { ...r, ...e }, this.persistence.set("global_props", r);
1211
1222
  }
1212
- n && this.persistence.save(), this.logger.debug("Properties set", {
1223
+ s && this.persistence.save(), this.logger.debug("Properties set", {
1213
1224
  properties: e,
1214
- eventType: s || "global",
1215
- persist: n
1225
+ eventType: i || "global",
1226
+ persist: s
1216
1227
  });
1217
1228
  }
1218
1229
  setUserId(e) {
@@ -1221,106 +1232,138 @@ class ke {
1221
1232
  t.id = e, this.persistence.set("userProps", t), this.persistence.save();
1222
1233
  }
1223
1234
  unset(e, t) {
1224
- const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1225
- if (s) {
1226
- let r = this.persistence.get(`props_${s}`) || {};
1227
- delete r[e], this.persistence.set(`props_${s}`, r);
1235
+ const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1236
+ if (i) {
1237
+ let r = this.persistence.get(`props_${i}`) || {};
1238
+ delete r[e], this.persistence.set(`props_${i}`, r);
1228
1239
  } else {
1229
1240
  let r = this.persistence.get("global_props") || {};
1230
1241
  delete r[e], this.persistence.set("global_props", r);
1231
1242
  }
1232
- n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
1243
+ s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1233
1244
  }
1234
1245
  }
1235
- function ve(i) {
1236
- const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...F, ...t };
1237
- if (!s.key)
1246
+ function X() {
1247
+ return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1248
+ }
1249
+ function Pe() {
1250
+ return X() ? window.define : void 0;
1251
+ }
1252
+ const Ae = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1253
+ function C(n) {
1254
+ const e = JSON.parse(JSON.stringify(n)), t = I(e), i = { ...q, ...t };
1255
+ if (!i.key)
1238
1256
  throw new Error("API key is required!");
1239
- if (!s.trackingHost)
1257
+ if (!i.trackingHost)
1240
1258
  throw new Error("Tracking host is required!");
1241
- return new ke(s);
1259
+ const s = i.key || "", r = `${Ae}${s}`;
1260
+ return u() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), u() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new S(i);
1242
1261
  }
1243
- function _e(i) {
1244
- var n;
1262
+ function $e(n) {
1263
+ var s;
1245
1264
  const e = {
1246
- key: i.getAttribute("data-key") || void 0,
1247
- trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1248
- logLevel: ue(i.getAttribute("data-log-level")),
1249
- autocapture: i.getAttribute("data-autocapture") === "true",
1250
- formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
1251
- autoPageview: i.getAttribute("data-auto-pageview") === "true",
1252
- useBeaconApi: i.getAttribute("data-use-beacon-api") === "true",
1253
- forceUseFetch: i.getAttribute("data-force-use-fetch") === "true",
1254
- gaHook: i.getAttribute("data-ga-hook") === "true",
1255
- segmentHook: i.getAttribute("data-segment-hook") === "true",
1256
- randomizeUrl: i.getAttribute("data-randomize-url") === "true",
1257
- capture3rdPartyCookies: i.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1258
- idMethod: i.getAttribute("data-id-method") || void 0,
1259
- privacyPolicy: i.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1260
- ipPolicy: i.getAttribute("data-ip-policy") || void 0,
1261
- cookiePolicy: i.getAttribute("data-cookie-policy") || void 0,
1262
- minSendTimeout: parseInt(i.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1263
- maxSendTimeout: parseInt(i.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1264
- maxSendAttempts: parseInt(i.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1265
- propertiesStringMaxLength: parseInt(i.getAttribute("data-properties-string-max-length") || "", 10) || null,
1266
- propertyBlacklist: ((n = i.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
1267
- exclude: i.getAttribute("data-exclude") || void 0,
1268
- namespace: i.getAttribute("data-namespace") || void 0,
1269
- crossDomainLinking: i.getAttribute("data-cross-domain-linking") !== "false",
1270
- domains: i.getAttribute("data-domains") || void 0,
1271
- maskAllText: i.getAttribute("data-mask-all-text") === "true",
1272
- maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
1265
+ key: n.getAttribute("data-key") || void 0,
1266
+ trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1267
+ logLevel: pe(n.getAttribute("data-log-level")),
1268
+ autocapture: n.getAttribute("data-autocapture") === "true",
1269
+ formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
1270
+ autoPageview: n.getAttribute("data-auto-pageview") === "true",
1271
+ useBeaconApi: n.getAttribute("data-use-beacon-api") === "true",
1272
+ forceUseFetch: n.getAttribute("data-force-use-fetch") === "true",
1273
+ gaHook: n.getAttribute("data-ga-hook") === "true",
1274
+ segmentHook: n.getAttribute("data-segment-hook") === "true",
1275
+ randomizeUrl: n.getAttribute("data-randomize-url") === "true",
1276
+ capture3rdPartyCookies: n.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1277
+ idMethod: n.getAttribute("data-id-method") || void 0,
1278
+ privacyPolicy: n.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1279
+ ipPolicy: n.getAttribute("data-ip-policy") || void 0,
1280
+ cookiePolicy: n.getAttribute("data-cookie-policy") || void 0,
1281
+ minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1282
+ maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1283
+ maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1284
+ propertiesStringMaxLength: parseInt(n.getAttribute("data-properties-string-max-length") || "", 10) || null,
1285
+ propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
1286
+ exclude: n.getAttribute("data-exclude") || void 0,
1287
+ namespace: n.getAttribute("data-namespace") || void 0,
1288
+ crossDomainLinking: n.getAttribute("data-cross-domain-linking") !== "false",
1289
+ domains: n.getAttribute("data-domains") || void 0,
1290
+ maskAllText: n.getAttribute("data-mask-all-text") === "true",
1291
+ maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
1273
1292
  };
1274
1293
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1275
- const t = ve(e), s = e.namespace || "usermaven";
1276
- u() && t.pageview(), be(s, t);
1294
+ const t = C(e), i = e.namespace || "usermaven";
1295
+ return u() && e.autoPageview !== !1 && t.pageview(), Se(i, t), t;
1277
1296
  }
1278
- function be(i, e) {
1297
+ function Se(n, e) {
1279
1298
  let t = !1;
1280
- const s = [], n = [];
1299
+ const i = [], s = [];
1281
1300
  function r() {
1282
- for (; s.length > 0; ) {
1283
- const a = s.shift();
1284
- a && window[i].apply(null, a);
1301
+ for (; i.length > 0; ) {
1302
+ const a = i.shift();
1303
+ a && window[n].apply(null, a);
1285
1304
  }
1286
1305
  }
1287
1306
  function o() {
1288
- n.forEach((a) => a()), n.length = 0;
1307
+ s.forEach((a) => a()), s.length = 0;
1289
1308
  }
1290
- window[i] = function(...a) {
1309
+ window[n] = function(...a) {
1291
1310
  const h = a[0];
1292
1311
  if (h === "onLoad") {
1293
- typeof a[1] == "function" && (t ? a[1]() : n.push(a[1]));
1312
+ typeof a[1] == "function" && (t ? a[1]() : s.push(a[1]));
1294
1313
  return;
1295
1314
  }
1296
1315
  if (!t) {
1297
- s.push(a);
1316
+ i.push(a);
1298
1317
  return;
1299
1318
  }
1300
1319
  if (typeof e[h] == "function")
1301
1320
  return e[h].apply(e, a.slice(1));
1302
1321
  console.error(`Method ${h} not found on UsermavenClient`);
1303
1322
  };
1304
- const c = `${i}Q`, l = window[c] || [];
1323
+ const c = `${n}Q`, l = window[c] || [];
1305
1324
  for (window[c] = l, l.push = function(...a) {
1306
- return window[i].apply(null, a), Array.prototype.push.apply(this, a);
1325
+ return window[n].apply(null, a), Array.prototype.push.apply(this, a);
1307
1326
  }, setTimeout(() => {
1308
- t = !0, r(), o(), console.log(`Usermaven client for namespace ${i} is ready`);
1327
+ t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
1309
1328
  }, 0); l.length > 0; ) {
1310
1329
  const a = l.shift();
1311
- a && s.push(a);
1330
+ a && i.push(a);
1312
1331
  }
1313
1332
  }
1314
- u() && function(i, e) {
1315
- const t = i.currentScript;
1316
- function s() {
1317
- t && t.src.includes("lib.js") && _e(t);
1318
- }
1319
- typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
1320
- }(document, window);
1333
+ let M = !1, H = null;
1334
+ if (u()) {
1335
+ const n = Pe();
1336
+ n && n("usermaven", [], function() {
1337
+ return {
1338
+ usermavenClient: C,
1339
+ UsermavenClient: S,
1340
+ LogLevel: p,
1341
+ // Expose the script tag client if it exists
1342
+ getScriptTagClient: () => H
1343
+ };
1344
+ }), typeof window < "u" && (window.usermavenClient = C, window.UsermavenClient = S, window.usermavenScriptTagClient = () => H), function(e, t) {
1345
+ const i = e.currentScript;
1346
+ function s() {
1347
+ return M || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1348
+ }
1349
+ function r() {
1350
+ s() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(i), M = !0);
1351
+ }
1352
+ typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1353
+ }(document, window);
1354
+ }
1355
+ typeof module < "u" && module.exports && !X() && (module.exports = {
1356
+ usermavenClient: C,
1357
+ UsermavenClient: S,
1358
+ Config: void 0,
1359
+ UserProps: void 0,
1360
+ EventPayload: void 0,
1361
+ LogLevel: p,
1362
+ ClientProperties: void 0
1363
+ });
1321
1364
 
1322
1365
  function createClient(params) {
1323
- return ve(params);
1366
+ return C(params);
1324
1367
  }
1325
1368
 
1326
1369
  function useUsermaven() {