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

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__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(p || {});
2
+ class Z {
3
3
  constructor(e) {
4
4
  this.level = e;
5
5
  }
@@ -17,10 +17,10 @@ class W {
17
17
  }
18
18
  }
19
19
  function d(i = 0) {
20
- return new W(i);
20
+ return new Z(i);
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,7 +45,7 @@ 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
  }
@@ -94,40 +94,40 @@ class X {
94
94
  return s ? s[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) {
97
+ const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, E = ie.forEach, N = {};
98
+ function se(i, e, t) {
99
99
  if (Array.isArray(i)) {
100
100
  if (E && i.forEach === E)
101
101
  i.forEach(e, t);
102
102
  else if ("length" in i && i.length === +i.length) {
103
103
  for (let s = 0, n = i.length; s < n; s++)
104
- if (s in i && e.call(t, i[s], s) === A)
104
+ if (s in i && e.call(t, i[s], s) === N)
105
105
  return;
106
106
  }
107
107
  }
108
108
  }
109
- const x = function(i) {
109
+ const O = function(i) {
110
110
  return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
111
- }, j = function(i) {
111
+ }, ne = function(i) {
112
112
  for (const e in i)
113
113
  typeof i[e] == "function" && (i[e] = i[e].bind(i));
114
114
  };
115
- function f(i, e, t) {
115
+ function g(i, e, t) {
116
116
  if (i != null) {
117
117
  if (E && Array.isArray(i) && i.forEach === E)
118
118
  i.forEach(e, t);
119
119
  else if ("length" in i && i.length === +i.length) {
120
120
  for (let s = 0, n = i.length; s < n; s++)
121
- if (s in i && e.call(t, i[s], s) === A)
121
+ if (s in i && e.call(t, i[s], s) === N)
122
122
  return;
123
123
  } else
124
124
  for (const s in i)
125
- if (G.call(i, s) && e.call(t, i[s], s) === A)
125
+ if (te.call(i, s) && e.call(t, i[s], s) === N)
126
126
  return;
127
127
  }
128
128
  }
129
- const ee = function(i, ...e) {
130
- return Z(e, function(t) {
129
+ const re = function(i, ...e) {
130
+ return se(e, function(t) {
131
131
  for (const s in t)
132
132
  t[s] !== void 0 && (i[s] = t[s]);
133
133
  }), i;
@@ -135,15 +135,15 @@ const ee = function(i, ...e) {
135
135
  function _(i, e) {
136
136
  return i.indexOf(e) !== -1;
137
137
  }
138
- const te = function(i) {
138
+ const oe = function(i) {
139
139
  try {
140
140
  return /^\s*\bfunction\b/.test(i);
141
141
  } catch {
142
142
  return !1;
143
143
  }
144
- }, ie = function(i) {
144
+ }, ae = function(i) {
145
145
  return i === void 0;
146
- }, m = function() {
146
+ }, y = function() {
147
147
  const i = function(s, n, r, o, c) {
148
148
  if (!s) {
149
149
  d().error("No valid element provided to register_event");
@@ -161,7 +161,7 @@ const te = function(i) {
161
161
  if (o = o || t(window.event), !o)
162
162
  return;
163
163
  let c = !0, l;
164
- te(r) && (l = r(o));
164
+ oe(r) && (l = r(o));
165
165
  const a = n.call(s, o);
166
166
  return (l === !1 || a === !1) && (c = !1), c;
167
167
  };
@@ -174,7 +174,7 @@ const te = function(i) {
174
174
  }, t.stopPropagation = function() {
175
175
  this.cancelBubble = !0;
176
176
  }, i;
177
- }(), se = function(i) {
177
+ }(), ce = function(i) {
178
178
  return function(...e) {
179
179
  try {
180
180
  return i.apply(this, e);
@@ -182,11 +182,11 @@ const te = function(i) {
182
182
  d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
183
183
  }
184
184
  };
185
- }, z = function(i) {
185
+ }, V = function(i) {
186
186
  for (const e in i)
187
- typeof i[e] == "function" && (i[e] = se(i[e]));
187
+ typeof i[e] == "function" && (i[e] = ce(i[e]));
188
188
  };
189
- function R(i) {
189
+ function D(i) {
190
190
  for (let e in i)
191
191
  (i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
192
192
  return i;
@@ -198,20 +198,20 @@ function u() {
198
198
  return d().warn("window is not available"), !1;
199
199
  }
200
200
  }
201
- function p(i = 5) {
201
+ function m(i = 5) {
202
202
  const e = new Uint8Array(i);
203
203
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
204
204
  }
205
- function ne(i) {
205
+ function le(i) {
206
206
  return i.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 R(i) {
212
+ return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(R) : Object.keys(i).reduce((e, t) => {
213
+ const s = le(t);
214
+ return e[s] = R(i[t]), e;
215
215
  }, {});
216
216
  }
217
217
  function $(i) {
@@ -224,37 +224,37 @@ function $(i) {
224
224
  return "";
225
225
  }
226
226
  }
227
- function L(i) {
227
+ function U(i) {
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(i) && !W(i) && i.childNodes && i.childNodes.length && g(i.childNodes, function(t) {
230
+ Q(t) && t.textContent && (e += O(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
231
+ }), O(e);
232
232
  }
233
- function B(i) {
233
+ function J(i) {
234
234
  return !!i && i.nodeType === 1;
235
235
  }
236
- function g(i, e) {
236
+ function f(i, e) {
237
237
  return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
238
238
  }
239
- function q(i) {
239
+ function Q(i) {
240
240
  return !!i && i.nodeType === 3;
241
241
  }
242
- function N(i) {
242
+ function I(i) {
243
243
  return !!i && i.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(i, e) {
247
+ if (!i || f(i, "html") || !J(i))
248
248
  return !1;
249
249
  let t = i;
250
- for (; t && !g(t, "body"); ) {
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 && I(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
254
254
  }
255
255
  let s = !1;
256
- for (t = i; t && !g(t, "body"); ) {
257
- if (t.parentNode && N(t.parentNode)) {
256
+ for (t = i; t && !f(t, "body"); ) {
257
+ if (t.parentNode && I(t.parentNode)) {
258
258
  t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
259
259
  continue;
260
260
  }
@@ -286,8 +286,8 @@ function re(i, e) {
286
286
  return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
287
287
  }
288
288
  }
289
- function O(i) {
290
- for (let s = i; s.parentNode && !g(s, "body"); s = s.parentNode) {
289
+ function L(i) {
290
+ for (let s = i; s.parentNode && !f(s, "body"); s = s.parentNode) {
291
291
  const n = $(s).split(" ");
292
292
  if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
293
293
  return !1;
@@ -305,23 +305,23 @@ function O(i) {
305
305
  const t = i.name || i.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(i) {
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(i, "input") && !e.includes(i.type) || f(i, "select") || f(i, "textarea") || i.getAttribute("contenteditable") === "true");
311
311
  }
312
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)));
313
+ return !(i === null || ae(i) || typeof i == "string" && (i = O(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)));
314
314
  }
315
- function oe(i) {
315
+ function he(i) {
316
316
  return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.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) {
321
+ function de(i) {
322
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());
323
323
  }
324
- function ce(i, e) {
324
+ function fe(i, e) {
325
325
  let t;
326
326
  return function(...s) {
327
327
  const n = () => {
@@ -330,7 +330,7 @@ function ce(i, e) {
330
330
  clearTimeout(t), t = setTimeout(n, e);
331
331
  };
332
332
  }
333
- function le(i) {
333
+ function ge(i) {
334
334
  const e = {}, t = i.replace(/^\?/, "").split("&");
335
335
  for (let s = 0; s < t.length; s++) {
336
336
  const n = t[s].split("=");
@@ -338,21 +338,25 @@ function le(i) {
338
338
  }
339
339
  return e;
340
340
  }
341
- function I(i) {
341
+ function F(i) {
342
342
  return typeof i == "string" || i instanceof String;
343
343
  }
344
- function k(i) {
344
+ function v(i) {
345
345
  return i !== null && typeof i == "object" && i.constructor === Object;
346
346
  }
347
- function ue(i) {
347
+ function pe(i) {
348
348
  if (i === null)
349
- return v.ERROR;
350
- const e = i.toUpperCase(), t = v[e];
351
- return t || t === 0 ? t : v.ERROR;
349
+ return p.ERROR;
350
+ const e = i.toUpperCase(), t = p[e];
351
+ return t || t === 0 ? t : p.ERROR;
352
352
  }
353
- class he {
353
+ const me = () => {
354
+ let i = "false";
355
+ return typeof window < "u" && window.localStorage && (i = localStorage.getItem("um_exclusion")), !(i == null || i === "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);
@@ -401,9 +405,9 @@ class he {
401
405
  });
402
406
  }
403
407
  }
404
- const C = class C {
408
+ const A = class A {
405
409
  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);
410
+ this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new ye(e), ne(this), V(this);
407
411
  }
408
412
  init() {
409
413
  if (!(document && document.body)) {
@@ -416,7 +420,7 @@ const C = class C {
416
420
  const e = (t) => {
417
421
  t = t || window.event, this.captureEvent(t);
418
422
  };
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);
423
+ 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
424
  }
421
425
  isPageRefresh() {
422
426
  if ("PerformanceNavigationTiming" in window) {
@@ -429,15 +433,15 @@ const C = class C {
429
433
  captureEvent(e) {
430
434
  var s, n;
431
435
  let t = this.getEventTarget(e);
432
- if (q(t) && (t = t.parentNode || null), e.type === "scroll")
436
+ if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
433
437
  return (s = this.scrollDepth) == null || s.track(), !0;
434
438
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
435
439
  return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
436
- if (t && re(t, e)) {
440
+ if (t && ue(t, e)) {
437
441
  const r = [t];
438
442
  let o = t;
439
- for (; o.parentNode && !g(o, "body"); ) {
440
- if (N(o.parentNode)) {
443
+ for (; o.parentNode && !f(o, "body"); ) {
444
+ if (I(o.parentNode)) {
441
445
  r.push(o.parentNode.host), o = o.parentNode.host;
442
446
  continue;
443
447
  }
@@ -445,20 +449,20 @@ const C = class C {
445
449
  }
446
450
  const c = [];
447
451
  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(
452
+ if (g(r, (k) => {
453
+ const G = L(k);
454
+ k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = G && P(l) && l);
455
+ const Y = $(k).split(" ");
456
+ _(Y, "ph-no-capture") && (a = !0), c.push(
453
457
  this.getPropertiesFromElement(
454
- w,
458
+ k,
455
459
  this.options.maskAllElementAttributes ?? !1,
456
460
  this.options.maskAllText ?? !1
457
461
  )
458
462
  );
459
- }), this.options.maskAllText || (c[0].$el_text = L(t)), l && (c[0].attr__href = l), a)
463
+ }), this.options.maskAllText || (c[0].$el_text = U(t)), l && (c[0].attr__href = l), a)
460
464
  return !1;
461
- const h = ee(
465
+ const h = re(
462
466
  this.getDefaultProperties(e.type),
463
467
  {
464
468
  $elements: c
@@ -470,18 +474,18 @@ const C = class C {
470
474
  }
471
475
  getCustomProperties(e) {
472
476
  const t = {};
473
- return f(this.customProperties, (s) => {
474
- f(s.event_selectors, (n) => {
477
+ return g(this.customProperties, (s) => {
478
+ g(s.event_selectors, (n) => {
475
479
  const r = document.querySelectorAll(n);
476
- f(r, (o) => {
477
- _(e, o) && O(o) && (t[s.name] = this.extractCustomPropertyValue(s));
480
+ g(r, (o) => {
481
+ _(e, o) && L(o) && (t[s.name] = this.extractCustomPropertyValue(s));
478
482
  });
479
483
  });
480
484
  }), t;
481
485
  }
482
486
  extractCustomPropertyValue(e) {
483
487
  const t = [];
484
- return f(document.querySelectorAll(e.css_selector), function(s) {
488
+ return g(document.querySelectorAll(e.css_selector), function(s) {
485
489
  let n;
486
490
  ["input", "select"].indexOf(s.tagName.toLowerCase()) > -1 ? n = s.value : s.textContent && (n = s.textContent), P(n) && t.push(n);
487
491
  }), t.join(", ");
@@ -494,12 +498,12 @@ const C = class C {
494
498
  const n = e.tagName.toLowerCase(), r = {
495
499
  tag_name: n
496
500
  };
497
- b.indexOf(n) > -1 && !s && (r.$el_text = L(e));
501
+ b.indexOf(n) > -1 && !s && (r.$el_text = U(e));
498
502
  const o = $(e);
499
503
  o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
500
504
  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);
505
+ })), g(e.attributes, function(h) {
506
+ W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
503
507
  });
504
508
  let c = 1, l = 1, a = e;
505
509
  for (; a = this.previousElementSibling(a); )
@@ -513,7 +517,7 @@ const C = class C {
513
517
  let t = e;
514
518
  do
515
519
  t = t.previousSibling;
516
- while (t && !B(t));
520
+ while (t && !J(t));
517
521
  return t;
518
522
  }
519
523
  }
@@ -535,9 +539,9 @@ const C = class C {
535
539
  return n % t < s;
536
540
  }
537
541
  };
538
- C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
539
- let S = C;
540
- class de {
542
+ A.FORCE_CAPTURE_ATTR = "data-um-force-capture", A.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
543
+ let S = A;
544
+ class we {
541
545
  constructor(e) {
542
546
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
543
547
  }
@@ -566,7 +570,7 @@ class de {
566
570
  }));
567
571
  }
568
572
  }
569
- class ge {
573
+ class ke {
570
574
  constructor(e, t, s = d()) {
571
575
  this.trackingHost = e, this.logger = s, this.config = t;
572
576
  }
@@ -579,12 +583,12 @@ class ge {
579
583
  }
580
584
  constructUrl(e) {
581
585
  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}`;
586
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
583
587
  }
584
588
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
585
589
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
586
590
  }
587
- class D {
591
+ class z {
588
592
  constructor(e, t, s = d()) {
589
593
  this.trackingHost = e, this.logger = s, this.config = t;
590
594
  }
@@ -603,7 +607,7 @@ class D {
603
607
  }
604
608
  constructUrl(e) {
605
609
  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}`;
610
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
607
611
  }
608
612
  getCustomHeaders() {
609
613
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -612,7 +616,7 @@ class D {
612
616
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
613
617
  }
614
618
  }
615
- class fe {
619
+ class ve {
616
620
  constructor(e, t, s = d()) {
617
621
  this.trackingHost = e, this.logger = s, this.config = t;
618
622
  }
@@ -632,7 +636,7 @@ class fe {
632
636
  }
633
637
  constructUrl(e) {
634
638
  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}`;
639
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
636
640
  }
637
641
  getCustomHeaders() {
638
642
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -641,7 +645,7 @@ class fe {
641
645
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
642
646
  }
643
647
  }
644
- class V {
648
+ class X {
645
649
  constructor(e, t) {
646
650
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
647
651
  }
@@ -681,7 +685,7 @@ class V {
681
685
  }
682
686
  }
683
687
  }
684
- class pe {
688
+ class _e {
685
689
  constructor() {
686
690
  this.storage = {};
687
691
  }
@@ -700,10 +704,10 @@ class pe {
700
704
  this.storage = {};
701
705
  }
702
706
  }
703
- class F {
707
+ class M {
704
708
  // Default to true for server-side
705
709
  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());
710
+ 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 X(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
707
711
  }
708
712
  add(e) {
709
713
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -747,9 +751,9 @@ class F {
747
751
  u() && this.persistence.set("queue", JSON.stringify(this.queue));
748
752
  }
749
753
  }
750
- class me {
754
+ class be {
751
755
  constructor(e) {
752
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
756
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
753
757
  }
754
758
  initializeEventListener() {
755
759
  document.addEventListener("click", this.handleClick.bind(this));
@@ -781,7 +785,7 @@ class me {
781
785
  }), this.clicks = [];
782
786
  }
783
787
  }
784
- class ye {
788
+ class Pe {
785
789
  constructor(e, t, s = d()) {
786
790
  this.trackingHost = e, this.logger = s, this.config = t;
787
791
  }
@@ -817,7 +821,7 @@ class ye {
817
821
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
818
822
  }
819
823
  }
820
- class y {
824
+ class w {
821
825
  constructor(e, t = "all", s = {}) {
822
826
  this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
823
827
  }
@@ -832,18 +836,18 @@ class y {
832
836
  }
833
837
  handleFormSubmit(e) {
834
838
  const t = e.target, s = this._getFormDetails(t);
835
- this.instance.track("$form", R(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
839
+ this.instance.track("$form", D(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
836
840
  }
837
841
  trackFieldChanges(e) {
838
842
  e.querySelectorAll("input, select, textarea").forEach((s) => {
839
843
  s.addEventListener("change", (n) => {
840
844
  const r = this._getFieldProps(n.target, 0);
841
- this.instance.track("$form_field_change", R(r));
845
+ this.instance.track("$form_field_change", D(r));
842
846
  });
843
847
  });
844
848
  }
845
849
  static getInstance(e, t = "all", s = {}) {
846
- return y.instance || (y.instance = new y(e, t, s)), y.instance;
850
+ return w.instance || (w.instance = new w(e, t, s)), w.instance;
847
851
  }
848
852
  _getFormDetails(e) {
849
853
  const t = {
@@ -931,9 +935,9 @@ class y {
931
935
  return e.slice(t, s + 1);
932
936
  }
933
937
  }
934
- class we {
938
+ class C {
935
939
  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(
940
+ 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 M(
937
941
  this.transport,
938
942
  this.config.maxSendAttempts || 3,
939
943
  this.config.minSendTimeout || 1e3,
@@ -945,13 +949,13 @@ class we {
945
949
  ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
946
950
  }
947
951
  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) {
952
+ if (this.cookieManager = new j(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) {
949
953
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
950
- this.formTracking = y.getInstance(this, e || "none", {
954
+ this.formTracking = w.getInstance(this, e || "none", {
951
955
  trackFieldChanges: !1
952
956
  });
953
957
  }
954
- this.config.autoPageview && (this.pageviewTracking = new de(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new me(this)), this.setupPageLeaveTracking();
958
+ this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
955
959
  }
956
960
  /**
957
961
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -962,11 +966,11 @@ class we {
962
966
  const s = JSON.parse(JSON.stringify(e));
963
967
  let n = { ...t, ...s };
964
968
  return Object.keys(t).forEach((r) => {
965
- k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
969
+ v(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
966
970
  }), n;
967
971
  }
968
972
  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(
973
+ 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 M(
970
974
  this.transport,
971
975
  this.config.maxSendAttempts || 3,
972
976
  this.config.minSendTimeout || 1e3,
@@ -1002,25 +1006,25 @@ class we {
1002
1006
  initializeTransport(e) {
1003
1007
  const t = "https://events.usermaven.com";
1004
1008
  if (!u())
1005
- return new ye(e.trackingHost || t, e);
1009
+ return new Pe(e.trackingHost || t, e);
1006
1010
  const s = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1007
1011
  if (e.useBeaconApi && r)
1008
- return new ge(e.trackingHost || t, e, this.logger);
1012
+ return new ke(e.trackingHost || t, e, this.logger);
1009
1013
  if (e.forceUseFetch && n)
1010
- return new D(e.trackingHost || t, e, this.logger);
1014
+ return new z(e.trackingHost || t, e, this.logger);
1011
1015
  if (s)
1012
- return new fe(e.trackingHost || t, e, this.logger);
1016
+ return new ve(e.trackingHost || t, e, this.logger);
1013
1017
  if (n)
1014
- return new D(e.trackingHost || t, e, this.logger);
1018
+ return new z(e.trackingHost || t, e, this.logger);
1015
1019
  throw new Error("No suitable transport method available");
1016
1020
  }
1017
1021
  initializePersistence() {
1018
- return this.config.disableEventPersistence || !u() ? new pe() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1022
+ return this.config.disableEventPersistence || !u() ? new _e() : new X(`${this.namespace}_${this.config.key}`, this.logger);
1019
1023
  }
1020
1024
  getOrCreateAnonymousId() {
1021
1025
  var s, n;
1022
1026
  if (!u())
1023
- return T();
1027
+ return x();
1024
1028
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1025
1029
  return "";
1026
1030
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
@@ -1028,20 +1032,20 @@ class we {
1028
1032
  if (!t) {
1029
1033
  if (this.config.crossDomainLinking) {
1030
1034
  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();
1035
+ t = c || h || x();
1032
1036
  }
1033
- t || (t = T());
1037
+ t || (t = x());
1034
1038
  const r = 365 * 10;
1035
1039
  (n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
1036
1040
  }
1037
1041
  return t;
1038
1042
  }
1039
1043
  async id(e, t = !1) {
1040
- if (!k(e))
1044
+ if (!v(e))
1041
1045
  throw new Error("User data must be an object");
1042
- if (e.email && !ae(e.email))
1046
+ if (e.email && !de(e.email))
1043
1047
  throw new Error("Invalid email provided");
1044
- if (!e.id || !I(e.id))
1048
+ if (!e.id || !F(e.id))
1045
1049
  throw new Error("User ID must be a string");
1046
1050
  const s = e.id;
1047
1051
  if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
@@ -1057,28 +1061,32 @@ class we {
1057
1061
  this.trackInternal(e, t, s);
1058
1062
  }
1059
1063
  trackInternal(e, t, s = !1) {
1060
- if (!I(e))
1064
+ if (me()) {
1065
+ this.logger.debug("Tracking disabled due to um_exclusion setting");
1066
+ return;
1067
+ }
1068
+ if (!F(e))
1061
1069
  throw new Error("Event name must be a string");
1062
1070
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1063
1071
  throw new Error("Event payload must be a non-null object and not an array");
1064
- const n = this.createEventPayload(e, t);
1072
+ const r = this.createEventPayload(e, t);
1065
1073
  try {
1066
1074
  if (s) {
1067
- this.transport.send(n), this.logger.debug(`Event sent: ${e}`, [n]);
1075
+ this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
1068
1076
  return;
1069
1077
  }
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}`);
1078
+ this.retryQueue.add(r), this.logger.debug(`Event tracked: ${e}`, [r]);
1079
+ } catch (o) {
1080
+ throw this.logger.error(`Failed to track event: ${e}`, o), new Error(`Failed to track event: ${e}`);
1073
1081
  }
1074
1082
  }
1075
1083
  rawTrack(e) {
1076
- if (!k(e))
1084
+ if (!v(e))
1077
1085
  throw new Error("Event payload must be an object");
1078
1086
  this.track("raw", e);
1079
1087
  }
1080
1088
  async group(e, t = !1) {
1081
- if (!k(e))
1089
+ if (!v(e))
1082
1090
  throw new Error("Company properties must be an object");
1083
1091
  if (!e.id || !e.name || !e.created_at)
1084
1092
  throw new Error("Company properties must include id, name, and created_at");
@@ -1133,7 +1141,7 @@ class we {
1133
1141
  return e;
1134
1142
  }
1135
1143
  getUtmParams() {
1136
- const e = {}, t = le(window.location.search);
1144
+ const e = {}, t = ge(window.location.search);
1137
1145
  return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((n) => {
1138
1146
  t[n] && (e[n.replace("utm_", "")] = t[n]);
1139
1147
  }), e;
@@ -1181,7 +1189,7 @@ class we {
1181
1189
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1182
1190
  }
1183
1191
  set(e, t) {
1184
- if (!k(e))
1192
+ if (!v(e))
1185
1193
  throw new Error("Properties must be an object");
1186
1194
  const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1187
1195
  if (s) {
@@ -1214,20 +1222,26 @@ class we {
1214
1222
  n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
1215
1223
  }
1216
1224
  }
1217
- function ke(i) {
1218
- const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...U, ...t };
1225
+ function K() {
1226
+ return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1227
+ }
1228
+ function Ee() {
1229
+ return K() ? window.define : void 0;
1230
+ }
1231
+ function T(i) {
1232
+ const e = JSON.parse(JSON.stringify(i)), t = R(e), s = { ...q, ...t };
1219
1233
  if (!s.key)
1220
1234
  throw new Error("API key is required!");
1221
1235
  if (!s.trackingHost)
1222
1236
  throw new Error("Tracking host is required!");
1223
- return new we(s);
1237
+ return new C(s);
1224
1238
  }
1225
- function ve(i) {
1239
+ function $e(i) {
1226
1240
  var n;
1227
1241
  const e = {
1228
1242
  key: i.getAttribute("data-key") || void 0,
1229
1243
  trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1230
- logLevel: ue(i.getAttribute("data-log-level")),
1244
+ logLevel: pe(i.getAttribute("data-log-level")),
1231
1245
  autocapture: i.getAttribute("data-autocapture") === "true",
1232
1246
  formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
1233
1247
  autoPageview: i.getAttribute("data-auto-pageview") === "true",
@@ -1254,10 +1268,10 @@ function ve(i) {
1254
1268
  maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
1255
1269
  };
1256
1270
  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);
1271
+ const t = T(e), s = e.namespace || "usermaven";
1272
+ return u() && e.autoPageview !== !1 && t.pageview(), Se(s, t), t;
1259
1273
  }
1260
- function _e(i, e) {
1274
+ function Se(i, e) {
1261
1275
  let t = !1;
1262
1276
  const s = [], n = [];
1263
1277
  function r() {
@@ -1293,15 +1307,39 @@ function _e(i, e) {
1293
1307
  a && s.push(a);
1294
1308
  }
1295
1309
  }
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);
1310
+ let B = !1, H = null;
1311
+ if (u()) {
1312
+ const i = Ee();
1313
+ i && i("usermaven", [], function() {
1314
+ return {
1315
+ usermavenClient: T,
1316
+ UsermavenClient: C,
1317
+ LogLevel: p,
1318
+ // Expose the script tag client if it exists
1319
+ getScriptTagClient: () => H
1320
+ };
1321
+ }), typeof window < "u" && (window.usermavenClient = T, window.UsermavenClient = C, window.usermavenScriptTagClient = () => H), function(e, t) {
1322
+ const s = e.currentScript;
1323
+ function n() {
1324
+ return B || !s || !s.hasAttribute("data-key") || s.getAttribute("data-no-auto-init") === "true" ? !1 : s.src.includes("lib.js");
1325
+ }
1326
+ function r() {
1327
+ n() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(s), B = !0);
1328
+ }
1329
+ typeof t < "u" && s && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1330
+ }(document, window);
1331
+ }
1332
+ typeof module < "u" && module.exports && !K() && (module.exports = {
1333
+ usermavenClient: T,
1334
+ UsermavenClient: C,
1335
+ Config: void 0,
1336
+ UserProps: void 0,
1337
+ EventPayload: void 0,
1338
+ LogLevel: p,
1339
+ ClientProperties: void 0
1340
+ });
1303
1341
  export {
1304
- v as LogLevel,
1305
- we as UsermavenClient,
1306
- ke as usermavenClient
1342
+ p as LogLevel,
1343
+ C as UsermavenClient,
1344
+ T as usermavenClient
1307
1345
  };