@usermaven/nextjs 1.5.10-rc.109 → 1.5.10-rc.110

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.
package/lib/index.es.js CHANGED
@@ -9,7 +9,7 @@ const UsermavenProvider = function ({ children, client }) {
9
9
  };
10
10
 
11
11
  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 || {});
12
- class ie {
12
+ class ne {
13
13
  constructor(e) {
14
14
  this.level = e;
15
15
  }
@@ -27,9 +27,9 @@ class ie {
27
27
  }
28
28
  }
29
29
  function f(n = 0) {
30
- return new ie(n);
30
+ return new ne(n);
31
31
  }
32
- const X = {
32
+ const Z = {
33
33
  logLevel: k.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
@@ -55,7 +55,7 @@ const X = {
55
55
  maskAllText: !1,
56
56
  maskAllElementAttributes: !1
57
57
  };
58
- class ne {
58
+ class se {
59
59
  constructor(e) {
60
60
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
61
  }
@@ -104,21 +104,21 @@ class ne {
104
104
  return i ? i[0] : "";
105
105
  }
106
106
  }
107
- const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, $ = oe.forEach, U = {};
108
- function ae(n, e, t) {
107
+ const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, $ = ae.forEach, D = {};
108
+ function ce(n, e, t) {
109
109
  if (Array.isArray(n)) {
110
110
  if ($ && n.forEach === $)
111
111
  n.forEach(e, t);
112
112
  else if ("length" in n && n.length === +n.length) {
113
113
  for (let i = 0, s = n.length; i < s; i++)
114
- if (i in n && e.call(t, n[i], i) === U)
114
+ if (i in n && e.call(t, n[i], i) === D)
115
115
  return;
116
116
  }
117
117
  }
118
118
  }
119
- const D = function(n) {
119
+ const F = function(n) {
120
120
  return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, ce = function(n) {
121
+ }, le = function(n) {
122
122
  for (const e in n)
123
123
  typeof n[e] == "function" && (n[e] = n[e].bind(n));
124
124
  };
@@ -128,16 +128,16 @@ function w(n, e, t) {
128
128
  n.forEach(e, t);
129
129
  else if ("length" in n && n.length === +n.length) {
130
130
  for (let i = 0, s = n.length; i < s; i++)
131
- if (i in n && e.call(t, n[i], i) === U)
131
+ if (i in n && e.call(t, n[i], i) === D)
132
132
  return;
133
133
  } else
134
134
  for (const i in n)
135
- if (re.call(n, i) && e.call(t, n[i], i) === U)
135
+ if (oe.call(n, i) && e.call(t, n[i], i) === D)
136
136
  return;
137
137
  }
138
138
  }
139
- const le = function(n, ...e) {
140
- return ae(e, function(t) {
139
+ const ue = function(n, ...e) {
140
+ return ce(e, function(t) {
141
141
  for (const i in t)
142
142
  t[i] !== void 0 && (n[i] = t[i]);
143
143
  }), n;
@@ -145,13 +145,13 @@ const le = function(n, ...e) {
145
145
  function S(n, e) {
146
146
  return n.indexOf(e) !== -1;
147
147
  }
148
- const ue = function(n) {
148
+ const he = function(n) {
149
149
  try {
150
150
  return /^\s*\bfunction\b/.test(n);
151
151
  } catch {
152
152
  return !1;
153
153
  }
154
- }, he = function(n) {
154
+ }, de = function(n) {
155
155
  return n === void 0;
156
156
  }, E = function() {
157
157
  const n = function(i, s, r, o, a) {
@@ -171,7 +171,7 @@ const ue = function(n) {
171
171
  if (o = o || t(window.event), !o)
172
172
  return;
173
173
  let a = !0, l;
174
- ue(r) && (l = r(o));
174
+ he(r) && (l = r(o));
175
175
  const c = s.call(i, o);
176
176
  return (l === !1 || c === !1) && (a = !1), a;
177
177
  };
@@ -184,7 +184,7 @@ const ue = function(n) {
184
184
  }, t.stopPropagation = function() {
185
185
  this.cancelBubble = !0;
186
186
  }, n;
187
- }(), de = function(n) {
187
+ }(), fe = function(n) {
188
188
  return function(...e) {
189
189
  try {
190
190
  return n.apply(this, e);
@@ -192,11 +192,11 @@ const ue = function(n) {
192
192
  f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
193
193
  }
194
194
  };
195
- }, Z = function(n) {
195
+ }, Y = function(n) {
196
196
  for (const e in n)
197
- typeof n[e] == "function" && (n[e] = de(n[e]));
197
+ typeof n[e] == "function" && (n[e] = fe(n[e]));
198
198
  };
199
- function q(n) {
199
+ function V(n) {
200
200
  for (let e in n)
201
201
  (n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
202
202
  return n;
@@ -212,16 +212,16 @@ function v(n = 5) {
212
212
  const e = new Uint8Array(n);
213
213
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
214
214
  }
215
- function fe(n) {
215
+ function ge(n) {
216
216
  return n.replace(
217
217
  /([-_][a-z])/g,
218
218
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
219
  );
220
220
  }
221
- function F(n) {
222
- return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(F) : Object.keys(n).reduce((e, t) => {
223
- const i = fe(t);
224
- return e[i] = F(n[t]), e;
221
+ function z(n) {
222
+ return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(z) : Object.keys(n).reduce((e, t) => {
223
+ const i = ge(t);
224
+ return e[i] = z(n[t]), e;
225
225
  }, {});
226
226
  }
227
227
  function x(n) {
@@ -234,37 +234,37 @@ function x(n) {
234
234
  return "";
235
235
  }
236
236
  }
237
- function V(n) {
237
+ function Q(n) {
238
238
  let e = "";
239
- return M(n) && !j(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
240
- G(t) && t.textContent && (e += D(t.textContent).split(/(\s+)/).filter(T).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
- }), D(e);
239
+ return B(n) && !ee(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
240
+ j(t) && t.textContent && (e += F(t.textContent).split(/(\s+)/).filter(T).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
+ }), F(e);
242
242
  }
243
- function Y(n) {
243
+ function G(n) {
244
244
  return !!n && n.nodeType === 1;
245
245
  }
246
246
  function y(n, e) {
247
247
  return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
248
248
  }
249
- function G(n) {
249
+ function j(n) {
250
250
  return !!n && n.nodeType === 3;
251
251
  }
252
- function z(n) {
252
+ function M(n) {
253
253
  return !!n && n.nodeType === 11;
254
254
  }
255
255
  const C = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function ge(n, e) {
257
- if (!n || y(n, "html") || !Y(n))
256
+ function pe(n, e) {
257
+ if (!n || y(n, "html") || !G(n))
258
258
  return !1;
259
259
  let t = n;
260
260
  for (; t && !y(t, "body"); ) {
261
261
  if (t.classList && t.classList.contains("um-no-capture"))
262
262
  return !1;
263
- t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
263
+ t.parentNode && M(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
264
  }
265
265
  let i = !1;
266
266
  for (t = n; t && !y(t, "body"); ) {
267
- if (t.parentNode && z(t.parentNode)) {
267
+ if (t.parentNode && M(t.parentNode)) {
268
268
  t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
269
269
  continue;
270
270
  }
@@ -296,7 +296,7 @@ function ge(n, e) {
296
296
  return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
297
297
  }
298
298
  }
299
- function M(n) {
299
+ function B(n) {
300
300
  for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
301
301
  const s = x(i).split(" ");
302
302
  if (S(s, "ph-sensitive") || S(s, "ph-no-capture"))
@@ -315,20 +315,20 @@ function M(n) {
315
315
  const t = n.name || n.id || "";
316
316
  return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
317
317
  }
318
- function j(n) {
318
+ function ee(n) {
319
319
  const e = ["button", "checkbox", "submit", "reset"];
320
320
  return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
321
321
  }
322
322
  function T(n) {
323
- return !(n === null || he(n) || typeof n == "string" && (n = D(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)));
323
+ 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)));
324
324
  }
325
- function pe(n) {
325
+ function me(n) {
326
326
  return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
327
327
  }
328
328
  function R() {
329
329
  return v(10);
330
330
  }
331
- function me(n) {
331
+ function J(n) {
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(n).toLowerCase());
333
333
  }
334
334
  function ye(n, e) {
@@ -348,10 +348,10 @@ function we(n) {
348
348
  }
349
349
  return e;
350
350
  }
351
- function Q(n) {
351
+ function L(n) {
352
352
  return typeof n == "string" || n instanceof String;
353
353
  }
354
- function A(n) {
354
+ function P(n) {
355
355
  return n !== null && typeof n == "object" && n.constructor === Object;
356
356
  }
357
357
  function ke(n) {
@@ -420,7 +420,7 @@ class _e {
420
420
  }
421
421
  const I = class I {
422
422
  constructor(e, t, i = f()) {
423
- this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), ce(this), Z(this);
423
+ 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);
424
424
  }
425
425
  isBrowserSupported() {
426
426
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -457,15 +457,15 @@ const I = class I {
457
457
  captureEvent(e) {
458
458
  var i, s;
459
459
  let t = this.getEventTarget(e);
460
- if (G(t) && (t = t.parentNode || null), e.type === "scroll")
460
+ if (j(t) && (t = t.parentNode || null), e.type === "scroll")
461
461
  return (i = this.scrollDepth) == null || i.track(), !0;
462
462
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
463
463
  return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
464
- if (t && ge(t, e)) {
464
+ if (t && pe(t, e)) {
465
465
  const r = [t];
466
466
  let o = t;
467
467
  for (; o.parentNode && !y(o, "body"); ) {
468
- if (z(o.parentNode)) {
468
+ if (M(o.parentNode)) {
469
469
  r.push(o.parentNode.host), o = o.parentNode.host;
470
470
  continue;
471
471
  }
@@ -474,7 +474,7 @@ const I = class I {
474
474
  const a = [];
475
475
  let l, c = !1;
476
476
  if (w(r, (p) => {
477
- const _ = M(p);
477
+ const _ = B(p);
478
478
  p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && T(l) && l);
479
479
  const u = x(p).split(" ");
480
480
  S(u, "ph-no-capture") && (c = !0), a.push(
@@ -484,9 +484,9 @@ const I = class I {
484
484
  this.options.maskAllText ?? !1
485
485
  )
486
486
  );
487
- }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
487
+ }), this.options.maskAllText || (a[0].$el_text = Q(t)), l && (a[0].attr__href = l), c)
488
488
  return !1;
489
- const d = le(
489
+ const d = ue(
490
490
  this.getDefaultProperties(e.type),
491
491
  {
492
492
  $elements: a
@@ -502,7 +502,7 @@ const I = class I {
502
502
  w(i.event_selectors, (s) => {
503
503
  const r = document.querySelectorAll(s);
504
504
  w(r, (o) => {
505
- S(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
505
+ S(e, o) && B(o) && (t[i.name] = this.extractCustomPropertyValue(i));
506
506
  });
507
507
  });
508
508
  }), t;
@@ -522,12 +522,12 @@ const I = class I {
522
522
  const s = e.tagName.toLowerCase(), r = {
523
523
  tag_name: s
524
524
  };
525
- C.indexOf(s) > -1 && !i && (r.$el_text = V(e));
525
+ C.indexOf(s) > -1 && !i && (r.$el_text = Q(e));
526
526
  const o = x(e);
527
527
  o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
528
528
  return d !== "";
529
529
  })), w(e.attributes, function(d) {
530
- j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && T(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
530
+ ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && T(d.value) && !me(d.name) && (r["attr__" + d.name] = d.value);
531
531
  });
532
532
  let a = 1, l = 1, c = e;
533
533
  for (; c = this.previousElementSibling(c); )
@@ -541,7 +541,7 @@ const I = class I {
541
541
  let t = e;
542
542
  do
543
543
  t = t.previousSibling;
544
- while (t && !Y(t));
544
+ while (t && !G(t));
545
545
  return t;
546
546
  }
547
547
  }
@@ -612,7 +612,7 @@ class Ee {
612
612
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
613
613
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
614
614
  }
615
- class J {
615
+ class W {
616
616
  constructor(e, t, i = f()) {
617
617
  this.trackingHost = e, this.logger = i, this.config = t;
618
618
  }
@@ -669,7 +669,7 @@ class Pe {
669
669
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
670
670
  }
671
671
  }
672
- class ee {
672
+ class te {
673
673
  constructor(e, t) {
674
674
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
675
675
  }
@@ -728,10 +728,10 @@ class Ae {
728
728
  this.storage = {};
729
729
  }
730
730
  }
731
- class W {
731
+ class K {
732
732
  // Default to true for server-side
733
733
  constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
734
- 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 ee(`offline_queue_${a}`), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
734
+ 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());
735
735
  }
736
736
  add(e) {
737
737
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -777,7 +777,7 @@ class W {
777
777
  }
778
778
  class Se {
779
779
  constructor(e) {
780
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
780
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
781
781
  }
782
782
  initializeEventListener() {
783
783
  document.addEventListener("click", this.handleClick.bind(this));
@@ -845,7 +845,7 @@ class Ce {
845
845
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
846
846
  }
847
847
  }
848
- class P {
848
+ class A {
849
849
  constructor(e, t = "all", i = {}) {
850
850
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
851
851
  }
@@ -860,13 +860,13 @@ class P {
860
860
  }
861
861
  handleFormSubmit(e) {
862
862
  const t = e.target, i = this._getFormDetails(t);
863
- this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
863
+ this.instance.track("$form", V(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
864
864
  }
865
865
  trackFieldChanges(e) {
866
866
  e.querySelectorAll("input, select, textarea").forEach((i) => {
867
867
  i.addEventListener("change", (s) => {
868
868
  const r = this._getFieldProps(s.target);
869
- this.instance.track("$form_field_change", q({
869
+ this.instance.track("$form_field_change", V({
870
870
  form_id: e.id,
871
871
  form_name: e.name || "",
872
872
  field: r
@@ -875,7 +875,7 @@ class P {
875
875
  });
876
876
  }
877
877
  static getInstance(e, t = "all", i = {}) {
878
- return P.instance || (P.instance = new P(e, t, i)), P.instance;
878
+ return A.instance || (A.instance = new A(e, t, i)), A.instance;
879
879
  }
880
880
  _getFormDetails(e) {
881
881
  const t = {
@@ -972,7 +972,7 @@ class P {
972
972
  }
973
973
  class N {
974
974
  constructor(e) {
975
- this.config = this.mergeConfig(e, X), this.logger = f(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new W(
975
+ 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(
976
976
  this.transport,
977
977
  this.config.maxSendAttempts || 3,
978
978
  this.config.minSendTimeout || 1e3,
@@ -984,9 +984,9 @@ class N {
984
984
  ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
985
985
  }
986
986
  initializeBrowserFeatures() {
987
- 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) {
987
+ 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) {
988
988
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
989
- this.formTracking = P.getInstance(this, e || "none", {
989
+ this.formTracking = A.getInstance(this, e || "none", {
990
990
  trackFieldChanges: !1
991
991
  });
992
992
  }
@@ -1001,11 +1001,11 @@ class N {
1001
1001
  const i = JSON.parse(JSON.stringify(e));
1002
1002
  let s = { ...t, ...i };
1003
1003
  return Object.keys(t).forEach((r) => {
1004
- A(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
1004
+ P(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
1005
1005
  }), s;
1006
1006
  }
1007
1007
  init(e) {
1008
- 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 W(
1008
+ 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(
1009
1009
  this.transport,
1010
1010
  this.config.maxSendAttempts || 3,
1011
1011
  this.config.minSendTimeout || 1e3,
@@ -1046,15 +1046,15 @@ class N {
1046
1046
  if (e.useBeaconApi && r)
1047
1047
  return new Ee(e.trackingHost || t, e, this.logger);
1048
1048
  if (e.forceUseFetch && s)
1049
- return new J(e.trackingHost || t, e, this.logger);
1049
+ return new W(e.trackingHost || t, e, this.logger);
1050
1050
  if (i)
1051
1051
  return new Pe(e.trackingHost || t, e, this.logger);
1052
1052
  if (s)
1053
- return new J(e.trackingHost || t, e, this.logger);
1053
+ return new W(e.trackingHost || t, e, this.logger);
1054
1054
  throw new Error("No suitable transport method available");
1055
1055
  }
1056
1056
  initializePersistence() {
1057
- return this.config.disableEventPersistence || !h() ? new Ae() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
1057
+ return this.config.disableEventPersistence || !h() ? new Ae() : new te(`${this.namespace}_${this.config.key}`, this.logger);
1058
1058
  }
1059
1059
  getOrCreateAnonymousId() {
1060
1060
  var i, s;
@@ -1076,11 +1076,11 @@ class N {
1076
1076
  return t;
1077
1077
  }
1078
1078
  async id(e, t = !1) {
1079
- if (!A(e))
1079
+ if (!P(e))
1080
1080
  throw new Error("User data must be an object");
1081
- if (e.email && !me(e.email))
1081
+ if (e.email && !J(e.email))
1082
1082
  throw new Error("Invalid email provided");
1083
- if (!e.id || !Q(e.id))
1083
+ if (!e.id || !L(e.id))
1084
1084
  throw new Error("User ID must be a string");
1085
1085
  const i = e.id;
1086
1086
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1095,12 +1095,27 @@ class N {
1095
1095
  track(e, t, i = !1) {
1096
1096
  this.trackInternal(e, t, i);
1097
1097
  }
1098
+ lead(e, t = !1) {
1099
+ if (!P(e))
1100
+ throw new Error("Lead payload must be a non-null object and not an array");
1101
+ const i = e.email;
1102
+ if (!L(i)) {
1103
+ this.logger.error("Lead event requires a valid email attribute");
1104
+ return;
1105
+ }
1106
+ const s = i.trim();
1107
+ if (!s || !J(s)) {
1108
+ this.logger.error("Lead event requires a valid email attribute");
1109
+ return;
1110
+ }
1111
+ e.email = s, this.track("lead", e, t);
1112
+ }
1098
1113
  trackInternal(e, t, i = !1) {
1099
1114
  if (ve()) {
1100
1115
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1101
1116
  return;
1102
1117
  }
1103
- if (!Q(e))
1118
+ if (!L(e))
1104
1119
  throw new Error("Event name must be a string");
1105
1120
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1106
1121
  throw new Error("Event payload must be a non-null object and not an array");
@@ -1116,12 +1131,12 @@ class N {
1116
1131
  }
1117
1132
  }
1118
1133
  rawTrack(e) {
1119
- if (!A(e))
1134
+ if (!P(e))
1120
1135
  throw new Error("Event payload must be an object");
1121
1136
  this.track("raw", e);
1122
1137
  }
1123
1138
  async group(e, t = !1) {
1124
- if (!A(e))
1139
+ if (!P(e))
1125
1140
  throw new Error("Company properties must be an object");
1126
1141
  if (!e.id || !e.name || !e.created_at)
1127
1142
  throw new Error("Company properties must include id, name, and created_at");
@@ -1224,7 +1239,7 @@ class N {
1224
1239
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1225
1240
  }
1226
1241
  set(e, t) {
1227
- if (!A(e))
1242
+ if (!P(e))
1228
1243
  throw new Error("Properties must be an object");
1229
1244
  const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1230
1245
  if (i) {
@@ -1257,15 +1272,15 @@ class N {
1257
1272
  s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1258
1273
  }
1259
1274
  }
1260
- function te() {
1275
+ function ie() {
1261
1276
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1262
1277
  }
1263
1278
  function Te() {
1264
- return te() ? window.define : void 0;
1279
+ return ie() ? window.define : void 0;
1265
1280
  }
1266
1281
  const $e = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1267
1282
  function O(n) {
1268
- const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
1283
+ const e = JSON.parse(JSON.stringify(n)), t = z(e), i = { ...Z, ...t };
1269
1284
  if (!i.key)
1270
1285
  throw new Error("API key is required!");
1271
1286
  if (!i.trackingHost)
@@ -1350,13 +1365,13 @@ function He(n, e) {
1350
1365
  return e[g].apply(e, u.slice(1));
1351
1366
  console.error(`Method ${g} not found on UsermavenClient`);
1352
1367
  }
1353
- const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
1368
+ const l = ["id", "group", "reset"], c = ["track", "lead", "pageview", "set", "unset", "rawTrack", "setUserId"];
1354
1369
  [...l, ...c].forEach((u) => {
1355
1370
  a[u] = function(...g) {
1356
1371
  if (!t) {
1357
1372
  if (l.includes(u))
1358
- return new Promise((B, m) => {
1359
- i.push([u, ...g, { resolve: B, reject: m }]);
1373
+ return new Promise((q, m) => {
1374
+ i.push([u, ...g, { resolve: q, reject: m }]);
1360
1375
  });
1361
1376
  i.push([u, ...g]);
1362
1377
  return;
@@ -1377,7 +1392,7 @@ function He(n, e) {
1377
1392
  u && i.push(u);
1378
1393
  }
1379
1394
  }
1380
- let K = !1, L = null;
1395
+ let X = !1, U = null;
1381
1396
  if (h()) {
1382
1397
  const n = Te();
1383
1398
  n && n("usermaven", [], function() {
@@ -1386,20 +1401,20 @@ if (h()) {
1386
1401
  UsermavenClient: N,
1387
1402
  LogLevel: k,
1388
1403
  // Expose the script tag client if it exists
1389
- getScriptTagClient: () => L
1404
+ getScriptTagClient: () => U
1390
1405
  };
1391
- }), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = N, window.usermavenScriptTagClient = () => L), function(e, t) {
1406
+ }), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = N, window.usermavenScriptTagClient = () => U), function(e, t) {
1392
1407
  const i = e.currentScript;
1393
1408
  function s() {
1394
- return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1409
+ return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1395
1410
  }
1396
1411
  function r() {
1397
- s() && (console.log("[Usermaven] Auto-initializing from script tag"), L = xe(i), K = !0);
1412
+ s() && (console.log("[Usermaven] Auto-initializing from script tag"), U = xe(i), X = !0);
1398
1413
  }
1399
1414
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1400
1415
  }(document, window);
1401
1416
  }
1402
- typeof module < "u" && module.exports && !te() && (module.exports = {
1417
+ typeof module < "u" && module.exports && !ie() && (module.exports = {
1403
1418
  usermavenClient: O,
1404
1419
  UsermavenClient: N,
1405
1420
  Config: void 0,
@@ -1450,6 +1465,7 @@ const createNoopClient = () => ({
1450
1465
  trackPageView: () => { },
1451
1466
  id: () => __awaiter(void 0, void 0, void 0, function* () { }),
1452
1467
  track: () => { },
1468
+ lead: () => { },
1453
1469
  rawTrack: () => { },
1454
1470
  set: () => { },
1455
1471
  unset: () => { },
@@ -1462,11 +1478,13 @@ function useUsermaven() {
1462
1478
  const id = useCallback((userData, doNotSendEvent) => client.id(userData, doNotSendEvent), [client]);
1463
1479
  const trackPageView = useCallback(() => client.track('pageview'), [client]);
1464
1480
  const track = useCallback((typeName, payload) => client.track(typeName, payload), [client]);
1481
+ const lead = useCallback((payload, directSend) => client.lead(payload, directSend), [client]);
1465
1482
  const rawTrack = useCallback((payload) => client.rawTrack(payload), [client]);
1466
1483
  const set = useCallback((properties, opts) => client.set(properties, opts), [client]);
1467
1484
  const unset = useCallback((propertyName, opts) => client.unset(propertyName, opts), [client]);
1468
1485
  return Object.assign(Object.assign({}, client), { id,
1469
1486
  track,
1487
+ lead,
1470
1488
  trackPageView,
1471
1489
  rawTrack,
1472
1490
  set,
@@ -3,6 +3,7 @@ export type UsermavenClient = {
3
3
  trackPageView: () => void;
4
4
  id: (userData: UserProps, doNotSendEvent?: boolean) => Promise<void>;
5
5
  track: (typeName: string, payload?: EventPayload) => void;
6
+ lead: (payload: EventPayload, directSend?: boolean) => void;
6
7
  rawTrack: (payload: any) => void;
7
8
  set: (properties: Record<string, any>, opts?: {
8
9
  eventType?: string;
@@ -15,6 +15,7 @@ const createNoopClient = () => ({
15
15
  trackPageView: () => { },
16
16
  id: () => __awaiter(void 0, void 0, void 0, function* () { }),
17
17
  track: () => { },
18
+ lead: () => { },
18
19
  rawTrack: () => { },
19
20
  set: () => { },
20
21
  unset: () => { },
@@ -27,11 +28,13 @@ function useUsermaven() {
27
28
  const id = (0, react_1.useCallback)((userData, doNotSendEvent) => client.id(userData, doNotSendEvent), [client]);
28
29
  const trackPageView = (0, react_1.useCallback)(() => client.track('pageview'), [client]);
29
30
  const track = (0, react_1.useCallback)((typeName, payload) => client.track(typeName, payload), [client]);
31
+ const lead = (0, react_1.useCallback)((payload, directSend) => client.lead(payload, directSend), [client]);
30
32
  const rawTrack = (0, react_1.useCallback)((payload) => client.rawTrack(payload), [client]);
31
33
  const set = (0, react_1.useCallback)((properties, opts) => client.set(properties, opts), [client]);
32
34
  const unset = (0, react_1.useCallback)((propertyName, opts) => client.unset(propertyName, opts), [client]);
33
35
  return Object.assign(Object.assign({}, client), { id,
34
36
  track,
37
+ lead,
35
38
  trackPageView,
36
39
  rawTrack,
37
40
  set,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/nextjs",
3
- "version": "1.5.10-rc.109",
3
+ "version": "1.5.10-rc.110",
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.10-rc.109",
21
+ "@usermaven/sdk-js": "1.5.10-rc.110",
22
22
  "cookie": "^0.5.0"
23
23
  },
24
24
  "peerDependencies": {