@usermaven/sdk-js 1.5.10-rc.110 → 1.5.10-rc.112

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