@usermaven/sdk-js 1.5.4 → 1.5.5-rc.100

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