@usermaven/nextjs 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.
Files changed (2) hide show
  1. package/lib/index.es.js +190 -152
  2. package/package.json +2 -2
package/lib/index.es.js CHANGED
@@ -8,8 +8,8 @@ const UsermavenProvider = function ({ children, client }) {
8
8
  return React.createElement(Context.Provider, { value: client }, children);
9
9
  };
10
10
 
11
- var v = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(v || {});
12
- class W {
11
+ var p = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(p || {});
12
+ class Z {
13
13
  constructor(e) {
14
14
  this.level = e;
15
15
  }
@@ -27,10 +27,10 @@ class W {
27
27
  }
28
28
  }
29
29
  function d(i = 0) {
30
- return new W(i);
30
+ return new Z(i);
31
31
  }
32
- const U = {
33
- logLevel: v.ERROR,
32
+ const q = {
33
+ logLevel: p.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
36
36
  trackingHost: "t.usermaven.com",
@@ -55,7 +55,7 @@ const U = {
55
55
  maskAllText: !1,
56
56
  maskAllElementAttributes: !1
57
57
  };
58
- class X {
58
+ class j {
59
59
  constructor(e) {
60
60
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
61
  }
@@ -104,40 +104,40 @@ class X {
104
104
  return s ? s[0] : "";
105
105
  }
106
106
  }
107
- const K = Object.prototype, G = K.hasOwnProperty, Y = Array.prototype, E = Y.forEach, A = {};
108
- function Z(i, e, t) {
107
+ const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, E = ie.forEach, N = {};
108
+ function se(i, e, t) {
109
109
  if (Array.isArray(i)) {
110
110
  if (E && i.forEach === E)
111
111
  i.forEach(e, t);
112
112
  else if ("length" in i && i.length === +i.length) {
113
113
  for (let s = 0, n = i.length; s < n; s++)
114
- if (s in i && e.call(t, i[s], s) === A)
114
+ if (s in i && e.call(t, i[s], s) === N)
115
115
  return;
116
116
  }
117
117
  }
118
118
  }
119
- const x = function(i) {
119
+ const O = function(i) {
120
120
  return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, j = function(i) {
121
+ }, ne = function(i) {
122
122
  for (const e in i)
123
123
  typeof i[e] == "function" && (i[e] = i[e].bind(i));
124
124
  };
125
- function f(i, e, t) {
125
+ function g(i, e, t) {
126
126
  if (i != null) {
127
127
  if (E && Array.isArray(i) && i.forEach === E)
128
128
  i.forEach(e, t);
129
129
  else if ("length" in i && i.length === +i.length) {
130
130
  for (let s = 0, n = i.length; s < n; s++)
131
- if (s in i && e.call(t, i[s], s) === A)
131
+ if (s in i && e.call(t, i[s], s) === N)
132
132
  return;
133
133
  } else
134
134
  for (const s in i)
135
- if (G.call(i, s) && e.call(t, i[s], s) === A)
135
+ if (te.call(i, s) && e.call(t, i[s], s) === N)
136
136
  return;
137
137
  }
138
138
  }
139
- const ee = function(i, ...e) {
140
- return Z(e, function(t) {
139
+ const re = function(i, ...e) {
140
+ return se(e, function(t) {
141
141
  for (const s in t)
142
142
  t[s] !== void 0 && (i[s] = t[s]);
143
143
  }), i;
@@ -145,15 +145,15 @@ const ee = function(i, ...e) {
145
145
  function _(i, e) {
146
146
  return i.indexOf(e) !== -1;
147
147
  }
148
- const te = function(i) {
148
+ const oe = function(i) {
149
149
  try {
150
150
  return /^\s*\bfunction\b/.test(i);
151
151
  } catch {
152
152
  return !1;
153
153
  }
154
- }, ie = function(i) {
154
+ }, ae = function(i) {
155
155
  return i === void 0;
156
- }, m = function() {
156
+ }, y = function() {
157
157
  const i = function(s, n, r, o, c) {
158
158
  if (!s) {
159
159
  d().error("No valid element provided to register_event");
@@ -171,7 +171,7 @@ const te = function(i) {
171
171
  if (o = o || t(window.event), !o)
172
172
  return;
173
173
  let c = !0, l;
174
- te(r) && (l = r(o));
174
+ oe(r) && (l = r(o));
175
175
  const a = n.call(s, o);
176
176
  return (l === !1 || a === !1) && (c = !1), c;
177
177
  };
@@ -184,7 +184,7 @@ const te = function(i) {
184
184
  }, t.stopPropagation = function() {
185
185
  this.cancelBubble = !0;
186
186
  }, i;
187
- }(), se = function(i) {
187
+ }(), ce = function(i) {
188
188
  return function(...e) {
189
189
  try {
190
190
  return i.apply(this, e);
@@ -192,11 +192,11 @@ const te = function(i) {
192
192
  d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
193
193
  }
194
194
  };
195
- }, z = function(i) {
195
+ }, V = function(i) {
196
196
  for (const e in i)
197
- typeof i[e] == "function" && (i[e] = se(i[e]));
197
+ typeof i[e] == "function" && (i[e] = ce(i[e]));
198
198
  };
199
- function R(i) {
199
+ function D(i) {
200
200
  for (let e in i)
201
201
  (i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
202
202
  return i;
@@ -208,20 +208,20 @@ function u() {
208
208
  return d().warn("window is not available"), !1;
209
209
  }
210
210
  }
211
- function p(i = 5) {
211
+ function m(i = 5) {
212
212
  const e = new Uint8Array(i);
213
213
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
214
214
  }
215
- function ne(i) {
215
+ function le(i) {
216
216
  return i.replace(
217
217
  /([-_][a-z])/g,
218
218
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
219
  );
220
220
  }
221
- function H(i) {
222
- return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(H) : Object.keys(i).reduce((e, t) => {
223
- const s = ne(t);
224
- return e[s] = H(i[t]), e;
221
+ function R(i) {
222
+ return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(R) : Object.keys(i).reduce((e, t) => {
223
+ const s = le(t);
224
+ return e[s] = R(i[t]), e;
225
225
  }, {});
226
226
  }
227
227
  function $(i) {
@@ -234,37 +234,37 @@ function $(i) {
234
234
  return "";
235
235
  }
236
236
  }
237
- function L(i) {
237
+ function U(i) {
238
238
  let e = "";
239
- return O(i) && !M(i) && i.childNodes && i.childNodes.length && f(i.childNodes, function(t) {
240
- q(t) && t.textContent && (e += x(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
- }), x(e);
239
+ return L(i) && !W(i) && i.childNodes && i.childNodes.length && g(i.childNodes, function(t) {
240
+ Q(t) && t.textContent && (e += O(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
+ }), O(e);
242
242
  }
243
- function B(i) {
243
+ function J(i) {
244
244
  return !!i && i.nodeType === 1;
245
245
  }
246
- function g(i, e) {
246
+ function f(i, e) {
247
247
  return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
248
248
  }
249
- function q(i) {
249
+ function Q(i) {
250
250
  return !!i && i.nodeType === 3;
251
251
  }
252
- function N(i) {
252
+ function I(i) {
253
253
  return !!i && i.nodeType === 11;
254
254
  }
255
255
  const b = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function re(i, e) {
257
- if (!i || g(i, "html") || !B(i))
256
+ function ue(i, e) {
257
+ if (!i || f(i, "html") || !J(i))
258
258
  return !1;
259
259
  let t = i;
260
- for (; t && !g(t, "body"); ) {
260
+ for (; t && !f(t, "body"); ) {
261
261
  if (t.classList && t.classList.contains("um-no-capture"))
262
262
  return !1;
263
- t.parentNode && N(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
263
+ t.parentNode && I(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
264
  }
265
265
  let s = !1;
266
- for (t = i; t && !g(t, "body"); ) {
267
- if (t.parentNode && N(t.parentNode)) {
266
+ for (t = i; t && !f(t, "body"); ) {
267
+ if (t.parentNode && I(t.parentNode)) {
268
268
  t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
269
269
  continue;
270
270
  }
@@ -296,8 +296,8 @@ function re(i, e) {
296
296
  return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
297
297
  }
298
298
  }
299
- function O(i) {
300
- for (let s = i; s.parentNode && !g(s, "body"); s = s.parentNode) {
299
+ function L(i) {
300
+ for (let s = i; s.parentNode && !f(s, "body"); s = s.parentNode) {
301
301
  const n = $(s).split(" ");
302
302
  if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
303
303
  return !1;
@@ -315,23 +315,23 @@ function O(i) {
315
315
  const t = i.name || i.id || "";
316
316
  return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
317
317
  }
318
- function M(i) {
318
+ function W(i) {
319
319
  const e = ["button", "checkbox", "submit", "reset"];
320
- return !!(g(i, "input") && !e.includes(i.type) || g(i, "select") || g(i, "textarea") || i.getAttribute("contenteditable") === "true");
320
+ return !!(f(i, "input") && !e.includes(i.type) || f(i, "select") || f(i, "textarea") || i.getAttribute("contenteditable") === "true");
321
321
  }
322
322
  function P(i) {
323
- return !(i === null || ie(i) || typeof i == "string" && (i = x(i), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
323
+ 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)));
324
324
  }
325
- function oe(i) {
325
+ function he(i) {
326
326
  return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
327
327
  }
328
- function T() {
329
- return p(10);
328
+ function x() {
329
+ return m(10);
330
330
  }
331
- function ae(i) {
331
+ function de(i) {
332
332
  return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(i).toLowerCase());
333
333
  }
334
- function ce(i, e) {
334
+ function fe(i, e) {
335
335
  let t;
336
336
  return function(...s) {
337
337
  const n = () => {
@@ -340,7 +340,7 @@ function ce(i, e) {
340
340
  clearTimeout(t), t = setTimeout(n, e);
341
341
  };
342
342
  }
343
- function le(i) {
343
+ function ge(i) {
344
344
  const e = {}, t = i.replace(/^\?/, "").split("&");
345
345
  for (let s = 0; s < t.length; s++) {
346
346
  const n = t[s].split("=");
@@ -348,21 +348,25 @@ function le(i) {
348
348
  }
349
349
  return e;
350
350
  }
351
- function I(i) {
351
+ function F(i) {
352
352
  return typeof i == "string" || i instanceof String;
353
353
  }
354
- function k(i) {
354
+ function v(i) {
355
355
  return i !== null && typeof i == "object" && i.constructor === Object;
356
356
  }
357
- function ue(i) {
357
+ function pe(i) {
358
358
  if (i === null)
359
- return v.ERROR;
360
- const e = i.toUpperCase(), t = v[e];
361
- return t || t === 0 ? t : v.ERROR;
359
+ return p.ERROR;
360
+ const e = i.toUpperCase(), t = p[e];
361
+ return t || t === 0 ? t : p.ERROR;
362
362
  }
363
- class he {
363
+ const me = () => {
364
+ let i = "false";
365
+ return typeof window < "u" && window.localStorage && (i = localStorage.getItem("um_exclusion")), !(i == null || i === "false");
366
+ };
367
+ class ye {
364
368
  constructor(e) {
365
- this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ce(this.handleScroll.bind(this), 250), this.initializeEventListener();
369
+ this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = fe(this.handleScroll.bind(this), 250), this.initializeEventListener();
366
370
  }
367
371
  initializeEventListener() {
368
372
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -411,9 +415,9 @@ class he {
411
415
  });
412
416
  }
413
417
  }
414
- const C = class C {
418
+ const A = class A {
415
419
  constructor(e, t, s = d()) {
416
- this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new he(e), j(this), z(this);
420
+ this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new ye(e), ne(this), V(this);
417
421
  }
418
422
  init() {
419
423
  if (!(document && document.body)) {
@@ -426,7 +430,7 @@ const C = class C {
426
430
  const e = (t) => {
427
431
  t = t || window.event, this.captureEvent(t);
428
432
  };
429
- 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);
433
+ 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);
430
434
  }
431
435
  isPageRefresh() {
432
436
  if ("PerformanceNavigationTiming" in window) {
@@ -439,15 +443,15 @@ const C = class C {
439
443
  captureEvent(e) {
440
444
  var s, n;
441
445
  let t = this.getEventTarget(e);
442
- if (q(t) && (t = t.parentNode || null), e.type === "scroll")
446
+ if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
443
447
  return (s = this.scrollDepth) == null || s.track(), !0;
444
448
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
445
449
  return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
446
- if (t && re(t, e)) {
450
+ if (t && ue(t, e)) {
447
451
  const r = [t];
448
452
  let o = t;
449
- for (; o.parentNode && !g(o, "body"); ) {
450
- if (N(o.parentNode)) {
453
+ for (; o.parentNode && !f(o, "body"); ) {
454
+ if (I(o.parentNode)) {
451
455
  r.push(o.parentNode.host), o = o.parentNode.host;
452
456
  continue;
453
457
  }
@@ -455,20 +459,20 @@ const C = class C {
455
459
  }
456
460
  const c = [];
457
461
  let l, a = !1;
458
- if (f(r, (w) => {
459
- const J = O(w);
460
- w.tagName.toLowerCase() === "a" && (l = w.getAttribute("href"), l = J && P(l) && l);
461
- const Q = $(w).split(" ");
462
- _(Q, "ph-no-capture") && (a = !0), c.push(
462
+ if (g(r, (k) => {
463
+ const G = L(k);
464
+ k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = G && P(l) && l);
465
+ const Y = $(k).split(" ");
466
+ _(Y, "ph-no-capture") && (a = !0), c.push(
463
467
  this.getPropertiesFromElement(
464
- w,
468
+ k,
465
469
  this.options.maskAllElementAttributes ?? !1,
466
470
  this.options.maskAllText ?? !1
467
471
  )
468
472
  );
469
- }), this.options.maskAllText || (c[0].$el_text = L(t)), l && (c[0].attr__href = l), a)
473
+ }), this.options.maskAllText || (c[0].$el_text = U(t)), l && (c[0].attr__href = l), a)
470
474
  return !1;
471
- const h = ee(
475
+ const h = re(
472
476
  this.getDefaultProperties(e.type),
473
477
  {
474
478
  $elements: c
@@ -480,18 +484,18 @@ const C = class C {
480
484
  }
481
485
  getCustomProperties(e) {
482
486
  const t = {};
483
- return f(this.customProperties, (s) => {
484
- f(s.event_selectors, (n) => {
487
+ return g(this.customProperties, (s) => {
488
+ g(s.event_selectors, (n) => {
485
489
  const r = document.querySelectorAll(n);
486
- f(r, (o) => {
487
- _(e, o) && O(o) && (t[s.name] = this.extractCustomPropertyValue(s));
490
+ g(r, (o) => {
491
+ _(e, o) && L(o) && (t[s.name] = this.extractCustomPropertyValue(s));
488
492
  });
489
493
  });
490
494
  }), t;
491
495
  }
492
496
  extractCustomPropertyValue(e) {
493
497
  const t = [];
494
- return f(document.querySelectorAll(e.css_selector), function(s) {
498
+ return g(document.querySelectorAll(e.css_selector), function(s) {
495
499
  let n;
496
500
  ["input", "select"].indexOf(s.tagName.toLowerCase()) > -1 ? n = s.value : s.textContent && (n = s.textContent), P(n) && t.push(n);
497
501
  }), t.join(", ");
@@ -504,12 +508,12 @@ const C = class C {
504
508
  const n = e.tagName.toLowerCase(), r = {
505
509
  tag_name: n
506
510
  };
507
- b.indexOf(n) > -1 && !s && (r.$el_text = L(e));
511
+ b.indexOf(n) > -1 && !s && (r.$el_text = U(e));
508
512
  const o = $(e);
509
513
  o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
510
514
  return h !== "";
511
- })), f(e.attributes, function(h) {
512
- M(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !oe(h.name) && (r["attr__" + h.name] = h.value);
515
+ })), g(e.attributes, function(h) {
516
+ W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
513
517
  });
514
518
  let c = 1, l = 1, a = e;
515
519
  for (; a = this.previousElementSibling(a); )
@@ -523,7 +527,7 @@ const C = class C {
523
527
  let t = e;
524
528
  do
525
529
  t = t.previousSibling;
526
- while (t && !B(t));
530
+ while (t && !J(t));
527
531
  return t;
528
532
  }
529
533
  }
@@ -545,9 +549,9 @@ const C = class C {
545
549
  return n % t < s;
546
550
  }
547
551
  };
548
- C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
549
- let S = C;
550
- class de {
552
+ A.FORCE_CAPTURE_ATTR = "data-um-force-capture", A.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
553
+ let S = A;
554
+ class we {
551
555
  constructor(e) {
552
556
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
553
557
  }
@@ -576,7 +580,7 @@ class de {
576
580
  }));
577
581
  }
578
582
  }
579
- class ge {
583
+ class ke {
580
584
  constructor(e, t, s = d()) {
581
585
  this.trackingHost = e, this.logger = s, this.config = t;
582
586
  }
@@ -589,12 +593,12 @@ class ge {
589
593
  }
590
594
  constructUrl(e) {
591
595
  const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
592
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
596
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
593
597
  }
594
598
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
595
599
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
596
600
  }
597
- class D {
601
+ class z {
598
602
  constructor(e, t, s = d()) {
599
603
  this.trackingHost = e, this.logger = s, this.config = t;
600
604
  }
@@ -613,7 +617,7 @@ class D {
613
617
  }
614
618
  constructUrl(e) {
615
619
  const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
616
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
620
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
617
621
  }
618
622
  getCustomHeaders() {
619
623
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -622,7 +626,7 @@ class D {
622
626
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
623
627
  }
624
628
  }
625
- class fe {
629
+ class ve {
626
630
  constructor(e, t, s = d()) {
627
631
  this.trackingHost = e, this.logger = s, this.config = t;
628
632
  }
@@ -642,7 +646,7 @@ class fe {
642
646
  }
643
647
  constructUrl(e) {
644
648
  const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
645
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
649
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
646
650
  }
647
651
  getCustomHeaders() {
648
652
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -651,7 +655,7 @@ class fe {
651
655
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
652
656
  }
653
657
  }
654
- class V {
658
+ class X {
655
659
  constructor(e, t) {
656
660
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
657
661
  }
@@ -691,7 +695,7 @@ class V {
691
695
  }
692
696
  }
693
697
  }
694
- class pe {
698
+ class _e {
695
699
  constructor() {
696
700
  this.storage = {};
697
701
  }
@@ -710,10 +714,10 @@ class pe {
710
714
  this.storage = {};
711
715
  }
712
716
  }
713
- class F {
717
+ class M {
714
718
  // Default to true for server-side
715
719
  constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = d(), c = "default") {
716
- this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new V(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
720
+ 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());
717
721
  }
718
722
  add(e) {
719
723
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -757,9 +761,9 @@ class F {
757
761
  u() && this.persistence.set("queue", JSON.stringify(this.queue));
758
762
  }
759
763
  }
760
- class me {
764
+ class be {
761
765
  constructor(e) {
762
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
766
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
763
767
  }
764
768
  initializeEventListener() {
765
769
  document.addEventListener("click", this.handleClick.bind(this));
@@ -791,7 +795,7 @@ class me {
791
795
  }), this.clicks = [];
792
796
  }
793
797
  }
794
- class ye {
798
+ class Pe {
795
799
  constructor(e, t, s = d()) {
796
800
  this.trackingHost = e, this.logger = s, this.config = t;
797
801
  }
@@ -827,7 +831,7 @@ class ye {
827
831
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
828
832
  }
829
833
  }
830
- class y {
834
+ class w {
831
835
  constructor(e, t = "all", s = {}) {
832
836
  this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
833
837
  }
@@ -842,18 +846,18 @@ class y {
842
846
  }
843
847
  handleFormSubmit(e) {
844
848
  const t = e.target, s = this._getFormDetails(t);
845
- this.instance.track("$form", R(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
849
+ this.instance.track("$form", D(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
846
850
  }
847
851
  trackFieldChanges(e) {
848
852
  e.querySelectorAll("input, select, textarea").forEach((s) => {
849
853
  s.addEventListener("change", (n) => {
850
854
  const r = this._getFieldProps(n.target, 0);
851
- this.instance.track("$form_field_change", R(r));
855
+ this.instance.track("$form_field_change", D(r));
852
856
  });
853
857
  });
854
858
  }
855
859
  static getInstance(e, t = "all", s = {}) {
856
- return y.instance || (y.instance = new y(e, t, s)), y.instance;
860
+ return w.instance || (w.instance = new w(e, t, s)), w.instance;
857
861
  }
858
862
  _getFormDetails(e) {
859
863
  const t = {
@@ -941,9 +945,9 @@ class y {
941
945
  return e.slice(t, s + 1);
942
946
  }
943
947
  }
944
- class we {
948
+ class C {
945
949
  constructor(e) {
946
- 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(
950
+ 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(
947
951
  this.transport,
948
952
  this.config.maxSendAttempts || 3,
949
953
  this.config.minSendTimeout || 1e3,
@@ -955,13 +959,13 @@ class we {
955
959
  ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
956
960
  }
957
961
  initializeBrowserFeatures() {
958
- 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) {
962
+ 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) {
959
963
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
960
- this.formTracking = y.getInstance(this, e || "none", {
964
+ this.formTracking = w.getInstance(this, e || "none", {
961
965
  trackFieldChanges: !1
962
966
  });
963
967
  }
964
- this.config.autoPageview && (this.pageviewTracking = new de(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new me(this)), this.setupPageLeaveTracking();
968
+ this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
965
969
  }
966
970
  /**
967
971
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -972,11 +976,11 @@ class we {
972
976
  const s = JSON.parse(JSON.stringify(e));
973
977
  let n = { ...t, ...s };
974
978
  return Object.keys(t).forEach((r) => {
975
- k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
979
+ v(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
976
980
  }), n;
977
981
  }
978
982
  init(e) {
979
- 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(
983
+ this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new M(
980
984
  this.transport,
981
985
  this.config.maxSendAttempts || 3,
982
986
  this.config.minSendTimeout || 1e3,
@@ -1012,25 +1016,25 @@ class we {
1012
1016
  initializeTransport(e) {
1013
1017
  const t = "https://events.usermaven.com";
1014
1018
  if (!u())
1015
- return new ye(e.trackingHost || t, e);
1019
+ return new Pe(e.trackingHost || t, e);
1016
1020
  const s = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1017
1021
  if (e.useBeaconApi && r)
1018
- return new ge(e.trackingHost || t, e, this.logger);
1022
+ return new ke(e.trackingHost || t, e, this.logger);
1019
1023
  if (e.forceUseFetch && n)
1020
- return new D(e.trackingHost || t, e, this.logger);
1024
+ return new z(e.trackingHost || t, e, this.logger);
1021
1025
  if (s)
1022
- return new fe(e.trackingHost || t, e, this.logger);
1026
+ return new ve(e.trackingHost || t, e, this.logger);
1023
1027
  if (n)
1024
- return new D(e.trackingHost || t, e, this.logger);
1028
+ return new z(e.trackingHost || t, e, this.logger);
1025
1029
  throw new Error("No suitable transport method available");
1026
1030
  }
1027
1031
  initializePersistence() {
1028
- return this.config.disableEventPersistence || !u() ? new pe() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1032
+ return this.config.disableEventPersistence || !u() ? new _e() : new X(`${this.namespace}_${this.config.key}`, this.logger);
1029
1033
  }
1030
1034
  getOrCreateAnonymousId() {
1031
1035
  var s, n;
1032
1036
  if (!u())
1033
- return T();
1037
+ return x();
1034
1038
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1035
1039
  return "";
1036
1040
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
@@ -1038,20 +1042,20 @@ class we {
1038
1042
  if (!t) {
1039
1043
  if (this.config.crossDomainLinking) {
1040
1044
  const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
1041
- t = c || h || T();
1045
+ t = c || h || x();
1042
1046
  }
1043
- t || (t = T());
1047
+ t || (t = x());
1044
1048
  const r = 365 * 10;
1045
1049
  (n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
1046
1050
  }
1047
1051
  return t;
1048
1052
  }
1049
1053
  async id(e, t = !1) {
1050
- if (!k(e))
1054
+ if (!v(e))
1051
1055
  throw new Error("User data must be an object");
1052
- if (e.email && !ae(e.email))
1056
+ if (e.email && !de(e.email))
1053
1057
  throw new Error("Invalid email provided");
1054
- if (!e.id || !I(e.id))
1058
+ if (!e.id || !F(e.id))
1055
1059
  throw new Error("User ID must be a string");
1056
1060
  const s = e.id;
1057
1061
  if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
@@ -1067,28 +1071,32 @@ class we {
1067
1071
  this.trackInternal(e, t, s);
1068
1072
  }
1069
1073
  trackInternal(e, t, s = !1) {
1070
- if (!I(e))
1074
+ if (me()) {
1075
+ this.logger.debug("Tracking disabled due to um_exclusion setting");
1076
+ return;
1077
+ }
1078
+ if (!F(e))
1071
1079
  throw new Error("Event name must be a string");
1072
1080
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1073
1081
  throw new Error("Event payload must be a non-null object and not an array");
1074
- const n = this.createEventPayload(e, t);
1082
+ const r = this.createEventPayload(e, t);
1075
1083
  try {
1076
1084
  if (s) {
1077
- this.transport.send(n), this.logger.debug(`Event sent: ${e}`, [n]);
1085
+ this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
1078
1086
  return;
1079
1087
  }
1080
- this.retryQueue.add(n), this.logger.debug(`Event tracked: ${e}`, [n]);
1081
- } catch (r) {
1082
- throw this.logger.error(`Failed to track event: ${e}`, r), new Error(`Failed to track event: ${e}`);
1088
+ this.retryQueue.add(r), this.logger.debug(`Event tracked: ${e}`, [r]);
1089
+ } catch (o) {
1090
+ throw this.logger.error(`Failed to track event: ${e}`, o), new Error(`Failed to track event: ${e}`);
1083
1091
  }
1084
1092
  }
1085
1093
  rawTrack(e) {
1086
- if (!k(e))
1094
+ if (!v(e))
1087
1095
  throw new Error("Event payload must be an object");
1088
1096
  this.track("raw", e);
1089
1097
  }
1090
1098
  async group(e, t = !1) {
1091
- if (!k(e))
1099
+ if (!v(e))
1092
1100
  throw new Error("Company properties must be an object");
1093
1101
  if (!e.id || !e.name || !e.created_at)
1094
1102
  throw new Error("Company properties must include id, name, and created_at");
@@ -1143,7 +1151,7 @@ class we {
1143
1151
  return e;
1144
1152
  }
1145
1153
  getUtmParams() {
1146
- const e = {}, t = le(window.location.search);
1154
+ const e = {}, t = ge(window.location.search);
1147
1155
  return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((n) => {
1148
1156
  t[n] && (e[n.replace("utm_", "")] = t[n]);
1149
1157
  }), e;
@@ -1191,7 +1199,7 @@ class we {
1191
1199
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1192
1200
  }
1193
1201
  set(e, t) {
1194
- if (!k(e))
1202
+ if (!v(e))
1195
1203
  throw new Error("Properties must be an object");
1196
1204
  const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1197
1205
  if (s) {
@@ -1224,20 +1232,26 @@ class we {
1224
1232
  n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
1225
1233
  }
1226
1234
  }
1227
- function ke(i) {
1228
- const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...U, ...t };
1235
+ function K() {
1236
+ return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1237
+ }
1238
+ function Ee() {
1239
+ return K() ? window.define : void 0;
1240
+ }
1241
+ function T(i) {
1242
+ const e = JSON.parse(JSON.stringify(i)), t = R(e), s = { ...q, ...t };
1229
1243
  if (!s.key)
1230
1244
  throw new Error("API key is required!");
1231
1245
  if (!s.trackingHost)
1232
1246
  throw new Error("Tracking host is required!");
1233
- return new we(s);
1247
+ return new C(s);
1234
1248
  }
1235
- function ve(i) {
1249
+ function $e(i) {
1236
1250
  var n;
1237
1251
  const e = {
1238
1252
  key: i.getAttribute("data-key") || void 0,
1239
1253
  trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1240
- logLevel: ue(i.getAttribute("data-log-level")),
1254
+ logLevel: pe(i.getAttribute("data-log-level")),
1241
1255
  autocapture: i.getAttribute("data-autocapture") === "true",
1242
1256
  formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
1243
1257
  autoPageview: i.getAttribute("data-auto-pageview") === "true",
@@ -1264,10 +1278,10 @@ function ve(i) {
1264
1278
  maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
1265
1279
  };
1266
1280
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1267
- const t = ke(e), s = e.namespace || "usermaven";
1268
- u() && t.pageview(), _e(s, t);
1281
+ const t = T(e), s = e.namespace || "usermaven";
1282
+ return u() && e.autoPageview !== !1 && t.pageview(), Se(s, t), t;
1269
1283
  }
1270
- function _e(i, e) {
1284
+ function Se(i, e) {
1271
1285
  let t = !1;
1272
1286
  const s = [], n = [];
1273
1287
  function r() {
@@ -1303,19 +1317,43 @@ function _e(i, e) {
1303
1317
  a && s.push(a);
1304
1318
  }
1305
1319
  }
1306
- u() && function(i, e) {
1307
- const t = i.currentScript;
1308
- function s() {
1309
- t && t.src.includes("lib.js") && ve(t);
1310
- }
1311
- typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
1312
- }(document, window);
1320
+ let B = !1, H = null;
1321
+ if (u()) {
1322
+ const i = Ee();
1323
+ i && i("usermaven", [], function() {
1324
+ return {
1325
+ usermavenClient: T,
1326
+ UsermavenClient: C,
1327
+ LogLevel: p,
1328
+ // Expose the script tag client if it exists
1329
+ getScriptTagClient: () => H
1330
+ };
1331
+ }), typeof window < "u" && (window.usermavenClient = T, window.UsermavenClient = C, window.usermavenScriptTagClient = () => H), function(e, t) {
1332
+ const s = e.currentScript;
1333
+ function n() {
1334
+ return B || !s || !s.hasAttribute("data-key") || s.getAttribute("data-no-auto-init") === "true" ? !1 : s.src.includes("lib.js");
1335
+ }
1336
+ function r() {
1337
+ n() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(s), B = !0);
1338
+ }
1339
+ typeof t < "u" && s && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1340
+ }(document, window);
1341
+ }
1342
+ typeof module < "u" && module.exports && !K() && (module.exports = {
1343
+ usermavenClient: T,
1344
+ UsermavenClient: C,
1345
+ Config: void 0,
1346
+ UserProps: void 0,
1347
+ EventPayload: void 0,
1348
+ LogLevel: p,
1349
+ ClientProperties: void 0
1350
+ });
1313
1351
 
1314
1352
  function createClient(params) {
1315
1353
  if (typeof window === 'undefined') {
1316
1354
  return null;
1317
1355
  }
1318
- return ke(params);
1356
+ return T(params);
1319
1357
  }
1320
1358
 
1321
1359
  /******************************************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/nextjs",
3
- "version": "1.5.4",
3
+ "version": "1.5.5-rc.97",
4
4
  "description": "Usermaven JavaScript SDK for NextJS",
5
5
  "author": "Usermaven <hello@usermaven.com>",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@usermaven/sdk-js": "1.5.4",
21
+ "@usermaven/sdk-js": "1.5.5-rc.97",
22
22
  "cookie": "^0.5.0"
23
23
  },
24
24
  "peerDependencies": {