@usermaven/react 1.5.10-rc.109 → 1.5.10-rc.111

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,3 +1,3 @@
1
- import { UsermavenClient } from "@usermaven/sdk-js";
1
+ import { UsermavenClient } from '@usermaven/sdk-js';
2
2
  declare const UsermavenContext: import("react").Context<UsermavenClient>;
3
3
  export default UsermavenContext;
package/lib/client.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { UsermavenClient, UsermavenOptions } from "@usermaven/sdk-js";
1
+ import { UsermavenClient, UsermavenOptions } from '@usermaven/sdk-js';
2
2
  declare function createClient(params: UsermavenOptions): UsermavenClient;
3
3
  export default createClient;
package/lib/index.es.js CHANGED
@@ -9,7 +9,7 @@ const UsermavenProvider = ({ 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,
@@ -42,7 +42,13 @@ const X = {
42
42
  gaHook: !1,
43
43
  segmentHook: !1,
44
44
  randomizeUrl: !1,
45
- capture3rdPartyCookies: ["_ga", "_fbp", "_ym_uid", "ajs_user_id", "ajs_anonymous_id"],
45
+ capture3rdPartyCookies: [
46
+ "_ga",
47
+ "_fbp",
48
+ "_ym_uid",
49
+ "ajs_user_id",
50
+ "ajs_anonymous_id"
51
+ ],
46
52
  idMethod: "cookie",
47
53
  ipPolicy: "keep",
48
54
  cookiePolicy: "keep",
@@ -55,7 +61,7 @@ const X = {
55
61
  maskAllText: !1,
56
62
  maskAllElementAttributes: !1
57
63
  };
58
- class ne {
64
+ class se {
59
65
  constructor(e) {
60
66
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
67
  }
@@ -104,21 +110,21 @@ class ne {
104
110
  return i ? i[0] : "";
105
111
  }
106
112
  }
107
- const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, $ = oe.forEach, U = {};
108
- function ae(n, e, t) {
113
+ const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, $ = ae.forEach, D = {};
114
+ function ce(n, e, t) {
109
115
  if (Array.isArray(n)) {
110
116
  if ($ && n.forEach === $)
111
117
  n.forEach(e, t);
112
118
  else if ("length" in n && n.length === +n.length) {
113
119
  for (let i = 0, s = n.length; i < s; i++)
114
- if (i in n && e.call(t, n[i], i) === U)
120
+ if (i in n && e.call(t, n[i], i) === D)
115
121
  return;
116
122
  }
117
123
  }
118
124
  }
119
- const D = function(n) {
125
+ const F = function(n) {
120
126
  return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, ce = function(n) {
127
+ }, le = function(n) {
122
128
  for (const e in n)
123
129
  typeof n[e] == "function" && (n[e] = n[e].bind(n));
124
130
  };
@@ -128,16 +134,16 @@ function w(n, e, t) {
128
134
  n.forEach(e, t);
129
135
  else if ("length" in n && n.length === +n.length) {
130
136
  for (let i = 0, s = n.length; i < s; i++)
131
- if (i in n && e.call(t, n[i], i) === U)
137
+ if (i in n && e.call(t, n[i], i) === D)
132
138
  return;
133
139
  } else
134
140
  for (const i in n)
135
- if (re.call(n, i) && e.call(t, n[i], i) === U)
141
+ if (oe.call(n, i) && e.call(t, n[i], i) === D)
136
142
  return;
137
143
  }
138
144
  }
139
- const le = function(n, ...e) {
140
- return ae(e, function(t) {
145
+ const ue = function(n, ...e) {
146
+ return ce(e, function(t) {
141
147
  for (const i in t)
142
148
  t[i] !== void 0 && (n[i] = t[i]);
143
149
  }), n;
@@ -145,13 +151,13 @@ const le = function(n, ...e) {
145
151
  function S(n, e) {
146
152
  return n.indexOf(e) !== -1;
147
153
  }
148
- const ue = function(n) {
154
+ const he = function(n) {
149
155
  try {
150
156
  return /^\s*\bfunction\b/.test(n);
151
157
  } catch {
152
158
  return !1;
153
159
  }
154
- }, he = function(n) {
160
+ }, de = function(n) {
155
161
  return n === void 0;
156
162
  }, E = function() {
157
163
  const n = function(i, s, r, o, a) {
@@ -171,7 +177,7 @@ const ue = function(n) {
171
177
  if (o = o || t(window.event), !o)
172
178
  return;
173
179
  let a = !0, l;
174
- ue(r) && (l = r(o));
180
+ he(r) && (l = r(o));
175
181
  const c = s.call(i, o);
176
182
  return (l === !1 || c === !1) && (a = !1), a;
177
183
  };
@@ -184,19 +190,22 @@ const ue = function(n) {
184
190
  }, t.stopPropagation = function() {
185
191
  this.cancelBubble = !0;
186
192
  }, n;
187
- }(), de = function(n) {
193
+ }(), fe = function(n) {
188
194
  return function(...e) {
189
195
  try {
190
196
  return n.apply(this, e);
191
197
  } catch (t) {
192
- f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
198
+ f().error(
199
+ "Implementation error. Please turn on debug and contact support@usermaven.com.",
200
+ t
201
+ );
193
202
  }
194
203
  };
195
- }, Z = function(n) {
204
+ }, Y = function(n) {
196
205
  for (const e in n)
197
- typeof n[e] == "function" && (n[e] = de(n[e]));
206
+ typeof n[e] == "function" && (n[e] = fe(n[e]));
198
207
  };
199
- function q(n) {
208
+ function V(n) {
200
209
  for (let e in n)
201
210
  (n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
202
211
  return n;
@@ -212,17 +221,20 @@ function v(n = 5) {
212
221
  const e = new Uint8Array(n);
213
222
  return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
214
223
  }
215
- function fe(n) {
224
+ function ge(n) {
216
225
  return n.replace(
217
226
  /([-_][a-z])/g,
218
227
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
228
  );
220
229
  }
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;
225
- }, {});
230
+ function z(n) {
231
+ return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(z) : Object.keys(n).reduce(
232
+ (e, t) => {
233
+ const i = ge(t);
234
+ return e[i] = z(n[t]), e;
235
+ },
236
+ {}
237
+ );
226
238
  }
227
239
  function x(n) {
228
240
  switch (typeof n.className) {
@@ -234,37 +246,45 @@ function x(n) {
234
246
  return "";
235
247
  }
236
248
  }
237
- function V(n) {
249
+ function Q(n) {
238
250
  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);
251
+ return B(n) && !ee(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
252
+ j(t) && t.textContent && (e += F(t.textContent).split(/(\s+)/).filter(T).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
253
+ }), F(e);
242
254
  }
243
- function Y(n) {
255
+ function G(n) {
244
256
  return !!n && n.nodeType === 1;
245
257
  }
246
258
  function y(n, e) {
247
259
  return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
248
260
  }
249
- function G(n) {
261
+ function j(n) {
250
262
  return !!n && n.nodeType === 3;
251
263
  }
252
- function z(n) {
264
+ function M(n) {
253
265
  return !!n && n.nodeType === 11;
254
266
  }
255
- const C = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function ge(n, e) {
257
- if (!n || y(n, "html") || !Y(n))
267
+ const C = [
268
+ "a",
269
+ "button",
270
+ "form",
271
+ "input",
272
+ "select",
273
+ "textarea",
274
+ "label"
275
+ ];
276
+ function pe(n, e) {
277
+ if (!n || y(n, "html") || !G(n))
258
278
  return !1;
259
279
  let t = n;
260
280
  for (; t && !y(t, "body"); ) {
261
281
  if (t.classList && t.classList.contains("um-no-capture"))
262
282
  return !1;
263
- t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
283
+ t.parentNode && M(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
284
  }
265
285
  let i = !1;
266
286
  for (t = n; t && !y(t, "body"); ) {
267
- if (t.parentNode && z(t.parentNode)) {
287
+ if (t.parentNode && M(t.parentNode)) {
268
288
  t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
269
289
  continue;
270
290
  }
@@ -296,7 +316,7 @@ function ge(n, e) {
296
316
  return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
297
317
  }
298
318
  }
299
- function M(n) {
319
+ function B(n) {
300
320
  for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
301
321
  const s = x(i).split(" ");
302
322
  if (S(s, "ph-sensitive") || S(s, "ph-no-capture"))
@@ -315,20 +335,20 @@ function M(n) {
315
335
  const t = n.name || n.id || "";
316
336
  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
337
  }
318
- function j(n) {
338
+ function ee(n) {
319
339
  const e = ["button", "checkbox", "submit", "reset"];
320
340
  return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
321
341
  }
322
342
  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)));
343
+ 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
344
  }
325
- function pe(n) {
345
+ function me(n) {
326
346
  return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
327
347
  }
328
348
  function R() {
329
349
  return v(10);
330
350
  }
331
- function me(n) {
351
+ function J(n) {
332
352
  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
353
  }
334
354
  function ye(n, e) {
@@ -348,10 +368,10 @@ function we(n) {
348
368
  }
349
369
  return e;
350
370
  }
351
- function Q(n) {
371
+ function L(n) {
352
372
  return typeof n == "string" || n instanceof String;
353
373
  }
354
- function A(n) {
374
+ function P(n) {
355
375
  return n !== null && typeof n == "object" && n.constructor === Object;
356
376
  }
357
377
  function ke(n) {
@@ -410,7 +430,9 @@ class _e {
410
430
  return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
411
431
  }
412
432
  checkMilestones(e) {
413
- this.milestones.filter((i) => e >= i).forEach((i) => {
433
+ this.milestones.filter(
434
+ (i) => e >= i
435
+ ).forEach((i) => {
414
436
  this.send(), this.milestones = this.milestones.filter((s) => s !== i);
415
437
  });
416
438
  }
@@ -420,7 +442,7 @@ class _e {
420
442
  }
421
443
  const I = class I {
422
444
  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);
445
+ 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
446
  }
425
447
  isBrowserSupported() {
426
448
  return typeof document < "u" && typeof document.addEventListener == "function";
@@ -435,7 +457,9 @@ const I = class I {
435
457
  return;
436
458
  }
437
459
  if (!(document && document.body)) {
438
- this.logger.debug("Document not ready yet, trying again in 500 milliseconds..."), setTimeout(() => this.init(), 500);
460
+ this.logger.debug(
461
+ "Document not ready yet, trying again in 500 milliseconds..."
462
+ ), setTimeout(() => this.init(), 500);
439
463
  return;
440
464
  }
441
465
  this.addDomEventHandlers(), this.domHandlersAttached = !0;
@@ -457,15 +481,15 @@ const I = class I {
457
481
  captureEvent(e) {
458
482
  var i, s;
459
483
  let t = this.getEventTarget(e);
460
- if (G(t) && (t = t.parentNode || null), e.type === "scroll")
484
+ if (j(t) && (t = t.parentNode || null), e.type === "scroll")
461
485
  return (i = this.scrollDepth) == null || i.track(), !0;
462
486
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
463
487
  return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
464
- if (t && ge(t, e)) {
488
+ if (t && pe(t, e)) {
465
489
  const r = [t];
466
490
  let o = t;
467
491
  for (; o.parentNode && !y(o, "body"); ) {
468
- if (z(o.parentNode)) {
492
+ if (M(o.parentNode)) {
469
493
  r.push(o.parentNode.host), o = o.parentNode.host;
470
494
  continue;
471
495
  }
@@ -474,7 +498,7 @@ const I = class I {
474
498
  const a = [];
475
499
  let l, c = !1;
476
500
  if (w(r, (p) => {
477
- const _ = M(p);
501
+ const _ = B(p);
478
502
  p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && T(l) && l);
479
503
  const u = x(p).split(" ");
480
504
  S(u, "ph-no-capture") && (c = !0), a.push(
@@ -484,9 +508,9 @@ const I = class I {
484
508
  this.options.maskAllText ?? !1
485
509
  )
486
510
  );
487
- }), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
511
+ }), this.options.maskAllText || (a[0].$el_text = Q(t)), l && (a[0].attr__href = l), c)
488
512
  return !1;
489
- const d = le(
513
+ const d = ue(
490
514
  this.getDefaultProperties(e.type),
491
515
  {
492
516
  $elements: a
@@ -502,17 +526,20 @@ const I = class I {
502
526
  w(i.event_selectors, (s) => {
503
527
  const r = document.querySelectorAll(s);
504
528
  w(r, (o) => {
505
- S(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
529
+ S(e, o) && B(o) && (t[i.name] = this.extractCustomPropertyValue(i));
506
530
  });
507
531
  });
508
532
  }), t;
509
533
  }
510
534
  extractCustomPropertyValue(e) {
511
535
  const t = [];
512
- return w(document.querySelectorAll(e.css_selector), function(i) {
513
- let s;
514
- ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), T(s) && t.push(s);
515
- }), t.join(", ");
536
+ return w(
537
+ document.querySelectorAll(e.css_selector),
538
+ function(i) {
539
+ let s;
540
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), T(s) && t.push(s);
541
+ }
542
+ ), t.join(", ");
516
543
  }
517
544
  getEventTarget(e) {
518
545
  var t;
@@ -522,12 +549,12 @@ const I = class I {
522
549
  const s = e.tagName.toLowerCase(), r = {
523
550
  tag_name: s
524
551
  };
525
- C.indexOf(s) > -1 && !i && (r.$el_text = V(e));
552
+ C.indexOf(s) > -1 && !i && (r.$el_text = Q(e));
526
553
  const o = x(e);
527
554
  o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
528
555
  return d !== "";
529
556
  })), 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);
557
+ ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && T(d.value) && !me(d.name) && (r["attr__" + d.name] = d.value);
531
558
  });
532
559
  let a = 1, l = 1, c = e;
533
560
  for (; c = this.previousElementSibling(c); )
@@ -541,7 +568,7 @@ const I = class I {
541
568
  let t = e;
542
569
  do
543
570
  t = t.previousSibling;
544
- while (t && !Y(t));
571
+ while (t && !G(t));
545
572
  return t;
546
573
  }
547
574
  }
@@ -599,9 +626,13 @@ class Ee {
599
626
  this.trackingHost = e, this.logger = i, this.config = t;
600
627
  }
601
628
  async send(e) {
602
- const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], { type: "application/json" });
629
+ const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], {
630
+ type: "application/json"
631
+ });
603
632
  if (navigator.sendBeacon(i, s))
604
- this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
633
+ this.logger.debug(
634
+ `Successfully queued ${e.length} event(s) via Beacon API`
635
+ );
605
636
  else
606
637
  throw new Error("Failed to queue events via Beacon API");
607
638
  }
@@ -612,7 +643,7 @@ class Ee {
612
643
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
613
644
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
614
645
  }
615
- class J {
646
+ class W {
616
647
  constructor(e, t, i = f()) {
617
648
  this.trackingHost = e, this.logger = i, this.config = t;
618
649
  }
@@ -669,7 +700,7 @@ class Pe {
669
700
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
670
701
  }
671
702
  }
672
- class ee {
703
+ class te {
673
704
  constructor(e, t) {
674
705
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
675
706
  }
@@ -728,10 +759,12 @@ class Ae {
728
759
  this.storage = {};
729
760
  }
730
761
  }
731
- class W {
762
+ class K {
732
763
  // Default to true for server-side
733
764
  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());
765
+ 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(
766
+ `offline_queue_${a}`
767
+ ), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
735
768
  }
736
769
  add(e) {
737
770
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -745,14 +778,19 @@ class W {
745
778
  }));
746
779
  }
747
780
  scheduleBatch() {
748
- h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
781
+ h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
782
+ () => this.processBatch(),
783
+ this.batchInterval
784
+ ));
749
785
  }
750
786
  async processBatch() {
751
787
  if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
752
788
  this.processing = !0;
753
789
  const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
754
790
  try {
755
- await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
791
+ await this.transport.send(t), this.logger.debug(
792
+ `Successfully sent batch of ${e.length} payloads`
793
+ ), h() && this.saveQueueToStorage();
756
794
  } catch (i) {
757
795
  this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
758
796
  }
@@ -762,7 +800,10 @@ class W {
762
800
  }
763
801
  async handleBatchFailure(e) {
764
802
  for (const t of e)
765
- t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error("Max retries reached, discarding payload", t.payload);
803
+ t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
804
+ "Max retries reached, discarding payload",
805
+ t.payload
806
+ );
766
807
  h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
767
808
  }
768
809
  loadQueueFromStorage() {
@@ -777,7 +818,7 @@ class W {
777
818
  }
778
819
  class Se {
779
820
  constructor(e) {
780
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
821
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
781
822
  }
782
823
  initializeEventListener() {
783
824
  document.addEventListener("click", this.handleClick.bind(this));
@@ -791,14 +832,18 @@ class Se {
791
832
  }
792
833
  click(e, t, i) {
793
834
  const s = { x: e, y: t, timestamp: i };
794
- this.clicks.push(s), this.clicks = this.clicks.filter((r) => i - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
835
+ this.clicks.push(s), this.clicks = this.clicks.filter(
836
+ (r) => i - r.timestamp < this.timeWindow
837
+ ), this.clicks.length >= this.threshold && this.checkRageClick();
795
838
  }
796
839
  checkRageClick() {
797
840
  const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
798
841
  this.clicks.every((r, o) => {
799
842
  if (o === 0) return !0;
800
843
  const a = this.clicks[o - 1];
801
- return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
844
+ return Math.sqrt(
845
+ Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)
846
+ ) < this.distanceThreshold;
802
847
  }) && this.sendRageClickEvent(i);
803
848
  }
804
849
  sendRageClickEvent(e) {
@@ -845,7 +890,7 @@ class Ce {
845
890
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
846
891
  }
847
892
  }
848
- class P {
893
+ class A {
849
894
  constructor(e, t = "all", i = {}) {
850
895
  this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
851
896
  }
@@ -860,22 +905,27 @@ class P {
860
905
  }
861
906
  handleFormSubmit(e) {
862
907
  const t = e.target, i = this._getFormDetails(t);
863
- this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
908
+ this.instance.track("$form", V(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
864
909
  }
865
910
  trackFieldChanges(e) {
866
911
  e.querySelectorAll("input, select, textarea").forEach((i) => {
867
912
  i.addEventListener("change", (s) => {
868
- const r = this._getFieldProps(s.target);
869
- this.instance.track("$form_field_change", q({
870
- form_id: e.id,
871
- form_name: e.name || "",
872
- field: r
873
- }));
913
+ const r = this._getFieldProps(
914
+ s.target
915
+ );
916
+ this.instance.track(
917
+ "$form_field_change",
918
+ V({
919
+ form_id: e.id,
920
+ form_name: e.name || "",
921
+ field: r
922
+ })
923
+ );
874
924
  });
875
925
  });
876
926
  }
877
927
  static getInstance(e, t = "all", i = {}) {
878
- return P.instance || (P.instance = new P(e, t, i)), P.instance;
928
+ return A.instance || (A.instance = new A(e, t, i)), A.instance;
879
929
  }
880
930
  _getFormDetails(e) {
881
931
  const t = {
@@ -886,11 +936,17 @@ class P {
886
936
  form_class: e.className,
887
937
  form_attributes: this._getElementAttributes(e),
888
938
  fields: []
889
- }, i = e.querySelectorAll("input, select, textarea");
890
- return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r) => {
891
- const o = this._getFieldProps(r);
892
- t.fields.push(o);
893
- }), t;
939
+ }, i = e.querySelectorAll(
940
+ "input, select, textarea"
941
+ );
942
+ return Array.from(i).filter(
943
+ (r) => !r.classList.contains("um-no-capture")
944
+ ).forEach(
945
+ (r) => {
946
+ const o = this._getFieldProps(r);
947
+ t.fields.push(o);
948
+ }
949
+ ), t;
894
950
  }
895
951
  _getFieldProps(e) {
896
952
  const t = Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : void 0, i = this.getSafeText(e);
@@ -972,7 +1028,7 @@ class P {
972
1028
  }
973
1029
  class N {
974
1030
  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(
1031
+ 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
1032
  this.transport,
977
1033
  this.config.maxSendAttempts || 3,
978
1034
  this.config.minSendTimeout || 1e3,
@@ -981,14 +1037,20 @@ class N {
981
1037
  // Reduced interval to .2 second
982
1038
  this.logger,
983
1039
  this.namespace
984
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
1040
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1041
+ `Usermaven client initialized for namespace: ${this.namespace}`
1042
+ );
985
1043
  }
986
1044
  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) {
1045
+ 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
1046
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
989
- this.formTracking = P.getInstance(this, e || "none", {
990
- trackFieldChanges: !1
991
- });
1047
+ this.formTracking = A.getInstance(
1048
+ this,
1049
+ e || "none",
1050
+ {
1051
+ trackFieldChanges: !1
1052
+ }
1053
+ );
992
1054
  }
993
1055
  this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Se(this)), this.setupPageLeaveTracking();
994
1056
  }
@@ -1001,11 +1063,11 @@ class N {
1001
1063
  const i = JSON.parse(JSON.stringify(e));
1002
1064
  let s = { ...t, ...i };
1003
1065
  return Object.keys(t).forEach((r) => {
1004
- A(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
1066
+ P(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
1005
1067
  }), s;
1006
1068
  }
1007
1069
  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(
1070
+ 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
1071
  this.transport,
1010
1072
  this.config.maxSendAttempts || 3,
1011
1073
  this.config.minSendTimeout || 1e3,
@@ -1014,7 +1076,9 @@ class N {
1014
1076
  // Reduced interval to .25 second
1015
1077
  this.logger,
1016
1078
  this.namespace
1017
- ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
1079
+ ), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
1080
+ `Usermaven client reinitialized for namespace: ${this.namespace}`
1081
+ );
1018
1082
  }
1019
1083
  manageCrossDomainLinking() {
1020
1084
  if (!this.config.crossDomainLinking || !this.config.domains)
@@ -1044,17 +1108,36 @@ class N {
1044
1108
  return new Ce(e.trackingHost || t, e);
1045
1109
  const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1046
1110
  if (e.useBeaconApi && r)
1047
- return new Ee(e.trackingHost || t, e, this.logger);
1111
+ return new Ee(
1112
+ e.trackingHost || t,
1113
+ e,
1114
+ this.logger
1115
+ );
1048
1116
  if (e.forceUseFetch && s)
1049
- return new J(e.trackingHost || t, e, this.logger);
1117
+ return new W(
1118
+ e.trackingHost || t,
1119
+ e,
1120
+ this.logger
1121
+ );
1050
1122
  if (i)
1051
- return new Pe(e.trackingHost || t, e, this.logger);
1123
+ return new Pe(
1124
+ e.trackingHost || t,
1125
+ e,
1126
+ this.logger
1127
+ );
1052
1128
  if (s)
1053
- return new J(e.trackingHost || t, e, this.logger);
1129
+ return new W(
1130
+ e.trackingHost || t,
1131
+ e,
1132
+ this.logger
1133
+ );
1054
1134
  throw new Error("No suitable transport method available");
1055
1135
  }
1056
1136
  initializePersistence() {
1057
- return this.config.disableEventPersistence || !h() ? new Ae() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
1137
+ return this.config.disableEventPersistence || !h() ? new Ae() : new te(
1138
+ `${this.namespace}_${this.config.key}`,
1139
+ this.logger
1140
+ );
1058
1141
  }
1059
1142
  getOrCreateAnonymousId() {
1060
1143
  var i, s;
@@ -1071,16 +1154,22 @@ class N {
1071
1154
  }
1072
1155
  t || (t = R());
1073
1156
  const r = 365 * 10;
1074
- (s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
1157
+ (s = this.cookieManager) == null || s.set(
1158
+ e,
1159
+ t,
1160
+ r,
1161
+ document.location.protocol !== "http:",
1162
+ !1
1163
+ );
1075
1164
  }
1076
1165
  return t;
1077
1166
  }
1078
1167
  async id(e, t = !1) {
1079
- if (!A(e))
1168
+ if (!P(e))
1080
1169
  throw new Error("User data must be an object");
1081
- if (e.email && !me(e.email))
1170
+ if (e.email && !J(e.email))
1082
1171
  throw new Error("Invalid email provided");
1083
- if (!e.id || !Q(e.id))
1172
+ if (!e.id || !L(e.id))
1084
1173
  throw new Error("User ID must be a string");
1085
1174
  const i = e.id;
1086
1175
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1095,15 +1184,34 @@ class N {
1095
1184
  track(e, t, i = !1) {
1096
1185
  this.trackInternal(e, t, i);
1097
1186
  }
1187
+ lead(e, t = !1) {
1188
+ if (!P(e))
1189
+ throw new Error(
1190
+ "Lead payload must be a non-null object and not an array"
1191
+ );
1192
+ const i = e.email;
1193
+ if (!L(i)) {
1194
+ this.logger.error("Lead event requires a valid email attribute");
1195
+ return;
1196
+ }
1197
+ const s = i.trim();
1198
+ if (!s || !J(s)) {
1199
+ this.logger.error("Lead event requires a valid email attribute");
1200
+ return;
1201
+ }
1202
+ e.email = s, this.track("lead", e, t);
1203
+ }
1098
1204
  trackInternal(e, t, i = !1) {
1099
1205
  if (ve()) {
1100
1206
  this.logger.debug("Tracking disabled due to um_exclusion setting");
1101
1207
  return;
1102
1208
  }
1103
- if (!Q(e))
1209
+ if (!L(e))
1104
1210
  throw new Error("Event name must be a string");
1105
1211
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1106
- throw new Error("Event payload must be a non-null object and not an array");
1212
+ throw new Error(
1213
+ "Event payload must be a non-null object and not an array"
1214
+ );
1107
1215
  const r = this.createEventPayload(e, t);
1108
1216
  try {
1109
1217
  if (i) {
@@ -1116,15 +1224,17 @@ class N {
1116
1224
  }
1117
1225
  }
1118
1226
  rawTrack(e) {
1119
- if (!A(e))
1227
+ if (!P(e))
1120
1228
  throw new Error("Event payload must be an object");
1121
1229
  this.track("raw", e);
1122
1230
  }
1123
1231
  async group(e, t = !1) {
1124
- if (!A(e))
1232
+ if (!P(e))
1125
1233
  throw new Error("Company properties must be an object");
1126
1234
  if (!e.id || !e.name || !e.created_at)
1127
- throw new Error("Company properties must include id, name, and created_at");
1235
+ throw new Error(
1236
+ "Company properties must include id, name, and created_at"
1237
+ );
1128
1238
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1129
1239
  }
1130
1240
  createEventPayload(e, t) {
@@ -1149,7 +1259,9 @@ class N {
1149
1259
  ...a
1150
1260
  };
1151
1261
  if (e === "$autocapture") {
1152
- const d = this.processAutocaptureAttributes(t || {});
1262
+ const d = this.processAutocaptureAttributes(
1263
+ t || {}
1264
+ );
1153
1265
  c.autocapture_attributes = d;
1154
1266
  } else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
1155
1267
  delete l[d];
@@ -1159,7 +1271,15 @@ class N {
1159
1271
  processAutocaptureAttributes(e) {
1160
1272
  let t = {};
1161
1273
  const i = e.$elements || [];
1162
- return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", ["$ce_version", "$event_type", "$initial_referrer", "$initial_referring_domain", "$referrer", "$referring_domain", "$elements"].forEach((s) => {
1274
+ return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
1275
+ "$ce_version",
1276
+ "$event_type",
1277
+ "$initial_referrer",
1278
+ "$initial_referring_domain",
1279
+ "$referrer",
1280
+ "$referring_domain",
1281
+ "$elements"
1282
+ ].forEach((s) => {
1163
1283
  delete t[s];
1164
1284
  }), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
1165
1285
  }
@@ -1177,16 +1297,28 @@ class N {
1177
1297
  }
1178
1298
  getUtmParams() {
1179
1299
  const e = {}, t = we(window.location.search);
1180
- return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
1300
+ return [
1301
+ "utm_source",
1302
+ "utm_medium",
1303
+ "utm_campaign",
1304
+ "utm_term",
1305
+ "utm_content"
1306
+ ].forEach((s) => {
1181
1307
  t[s] && (e[s.replace("utm_", "")] = t[s]);
1182
1308
  }), e;
1183
1309
  }
1184
1310
  pageview() {
1185
- h() ? this.track("pageview", {
1186
- url: window.location.href,
1187
- referrer: document.referrer,
1188
- title: document.title
1189
- }, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
1311
+ h() ? this.track(
1312
+ "pageview",
1313
+ {
1314
+ url: window.location.href,
1315
+ referrer: document.referrer,
1316
+ title: document.title
1317
+ },
1318
+ !0
1319
+ ) : this.logger.warn(
1320
+ "Pageview tracking is not available in server-side environments"
1321
+ );
1190
1322
  }
1191
1323
  setupPageLeaveTracking() {
1192
1324
  if (!h()) return;
@@ -1221,10 +1353,13 @@ class N {
1221
1353
  const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1222
1354
  this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
1223
1355
  }
1224
- this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1356
+ this.logger.info("core state reset", {
1357
+ resetAnonId: e,
1358
+ namespace: this.namespace
1359
+ });
1225
1360
  }
1226
1361
  set(e, t) {
1227
- if (!A(e))
1362
+ if (!P(e))
1228
1363
  throw new Error("Properties must be an object");
1229
1364
  const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1230
1365
  if (i) {
@@ -1254,24 +1389,32 @@ class N {
1254
1389
  let r = this.persistence.get("global_props") || {};
1255
1390
  delete r[e], this.persistence.set("global_props", r);
1256
1391
  }
1257
- s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1392
+ s && this.persistence.save(), this.logger.debug(
1393
+ `Property unset: ${e}`,
1394
+ `Event type: ${i || "global"}`
1395
+ );
1258
1396
  }
1259
1397
  }
1260
- function te() {
1398
+ function ie() {
1261
1399
  return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1262
1400
  }
1263
1401
  function Te() {
1264
- return te() ? window.define : void 0;
1402
+ return ie() ? window.define : void 0;
1265
1403
  }
1266
1404
  const $e = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1267
1405
  function O(n) {
1268
- const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
1406
+ const e = JSON.parse(JSON.stringify(n)), t = z(e), i = {
1407
+ ...Z,
1408
+ ...t
1409
+ };
1269
1410
  if (!i.key)
1270
1411
  throw new Error("API key is required!");
1271
1412
  if (!i.trackingHost)
1272
1413
  throw new Error("Tracking host is required!");
1273
1414
  const s = i.key || "", r = `${$e}${s}`;
1274
- return h() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
1415
+ return h() && i.autocapture && window[r] && (console.warn(
1416
+ "Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
1417
+ ), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
1275
1418
  }
1276
1419
  function xe(n) {
1277
1420
  var s;
@@ -1295,7 +1438,10 @@ function xe(n) {
1295
1438
  minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1296
1439
  maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1297
1440
  maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1298
- propertiesStringMaxLength: parseInt(n.getAttribute("data-properties-string-max-length") || "", 10) || null,
1441
+ propertiesStringMaxLength: parseInt(
1442
+ n.getAttribute("data-properties-string-max-length") || "",
1443
+ 10
1444
+ ) || null,
1299
1445
  propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
1300
1446
  exclude: n.getAttribute("data-exclude") || void 0,
1301
1447
  namespace: n.getAttribute("data-namespace") || void 0,
@@ -1350,13 +1496,21 @@ function He(n, e) {
1350
1496
  return e[g].apply(e, u.slice(1));
1351
1497
  console.error(`Method ${g} not found on UsermavenClient`);
1352
1498
  }
1353
- const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
1499
+ const l = ["id", "group", "reset"], c = [
1500
+ "track",
1501
+ "lead",
1502
+ "pageview",
1503
+ "set",
1504
+ "unset",
1505
+ "rawTrack",
1506
+ "setUserId"
1507
+ ];
1354
1508
  [...l, ...c].forEach((u) => {
1355
1509
  a[u] = function(...g) {
1356
1510
  if (!t) {
1357
1511
  if (l.includes(u))
1358
- return new Promise((B, m) => {
1359
- i.push([u, ...g, { resolve: B, reject: m }]);
1512
+ return new Promise((q, m) => {
1513
+ i.push([u, ...g, { resolve: q, reject: m }]);
1360
1514
  });
1361
1515
  i.push([u, ...g]);
1362
1516
  return;
@@ -1377,7 +1531,7 @@ function He(n, e) {
1377
1531
  u && i.push(u);
1378
1532
  }
1379
1533
  }
1380
- let K = !1, L = null;
1534
+ let X = !1, U = null;
1381
1535
  if (h()) {
1382
1536
  const n = Te();
1383
1537
  n && n("usermaven", [], function() {
@@ -1386,20 +1540,20 @@ if (h()) {
1386
1540
  UsermavenClient: N,
1387
1541
  LogLevel: k,
1388
1542
  // Expose the script tag client if it exists
1389
- getScriptTagClient: () => L
1543
+ getScriptTagClient: () => U
1390
1544
  };
1391
- }), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = N, window.usermavenScriptTagClient = () => L), function(e, t) {
1545
+ }), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = N, window.usermavenScriptTagClient = () => U), function(e, t) {
1392
1546
  const i = e.currentScript;
1393
1547
  function s() {
1394
- return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1548
+ return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1395
1549
  }
1396
1550
  function r() {
1397
- s() && (console.log("[Usermaven] Auto-initializing from script tag"), L = xe(i), K = !0);
1551
+ s() && (console.log("[Usermaven] Auto-initializing from script tag"), U = xe(i), X = !0);
1398
1552
  }
1399
1553
  typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1400
1554
  }(document, window);
1401
1555
  }
1402
- typeof module < "u" && module.exports && !te() && (module.exports = {
1556
+ typeof module < "u" && module.exports && !ie() && (module.exports = {
1403
1557
  usermavenClient: O,
1404
1558
  UsermavenClient: N,
1405
1559
  Config: void 0,
@@ -1416,16 +1570,18 @@ function createClient(params) {
1416
1570
  function useUsermaven() {
1417
1571
  const client = useContext(UsermavenContext);
1418
1572
  if (!client) {
1419
- throw new Error("Before calling useUsermaven() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react");
1573
+ throw new Error('Before calling useUsermaven() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react');
1420
1574
  }
1421
1575
  const id = useCallback((userData, doNotSendEvent) => client === null || client === void 0 ? void 0 : client.id(userData, doNotSendEvent), [client]);
1422
1576
  const trackPageView = useCallback(() => client === null || client === void 0 ? void 0 : client.track('pageview'), [client]);
1423
1577
  const track = useCallback((typeName, payload) => client === null || client === void 0 ? void 0 : client.track(typeName, payload), [client]);
1578
+ const lead = useCallback((payload, directSend) => client === null || client === void 0 ? void 0 : client.lead(payload, directSend), [client]);
1424
1579
  const rawTrack = useCallback((payload) => client === null || client === void 0 ? void 0 : client.rawTrack(payload), [client]);
1425
1580
  const set = useCallback((properties, opts) => client === null || client === void 0 ? void 0 : client.set(properties, opts), [client]);
1426
1581
  const unset = useCallback((propertyName, opts) => client === null || client === void 0 ? void 0 : client.unset(propertyName, opts), [client]);
1427
1582
  return Object.assign(Object.assign({}, client), { id,
1428
1583
  track,
1584
+ lead,
1429
1585
  trackPageView,
1430
1586
  rawTrack,
1431
1587
  set,
@@ -1,5 +1,5 @@
1
- import { UsermavenClient } from "./useUsermaven";
2
- import { EventPayload } from "@usermaven/sdk-js";
1
+ import { UsermavenClient } from './useUsermaven';
2
+ import { EventPayload } from '@usermaven/sdk-js';
3
3
  declare function usePageView(opts?: {
4
4
  before?: (usermaven: UsermavenClient) => void;
5
5
  typeName?: string;
@@ -1,8 +1,9 @@
1
- import { EventPayload, UserProps } from "@usermaven/sdk-js";
1
+ import { EventPayload, UserProps } from '@usermaven/sdk-js';
2
2
  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;
@@ -5,16 +5,18 @@ const UsermavenContext_1 = require("./UsermavenContext");
5
5
  function useUsermaven() {
6
6
  const client = (0, react_1.useContext)(UsermavenContext_1.default);
7
7
  if (!client) {
8
- throw new Error("Before calling useUsermaven() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react");
8
+ throw new Error('Before calling useUsermaven() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react');
9
9
  }
10
10
  const id = (0, react_1.useCallback)((userData, doNotSendEvent) => client === null || client === void 0 ? void 0 : client.id(userData, doNotSendEvent), [client]);
11
11
  const trackPageView = (0, react_1.useCallback)(() => client === null || client === void 0 ? void 0 : client.track('pageview'), [client]);
12
12
  const track = (0, react_1.useCallback)((typeName, payload) => client === null || client === void 0 ? void 0 : client.track(typeName, payload), [client]);
13
+ const lead = (0, react_1.useCallback)((payload, directSend) => client === null || client === void 0 ? void 0 : client.lead(payload, directSend), [client]);
13
14
  const rawTrack = (0, react_1.useCallback)((payload) => client === null || client === void 0 ? void 0 : client.rawTrack(payload), [client]);
14
15
  const set = (0, react_1.useCallback)((properties, opts) => client === null || client === void 0 ? void 0 : client.set(properties, opts), [client]);
15
16
  const unset = (0, react_1.useCallback)((propertyName, opts) => client === null || client === void 0 ? void 0 : client.unset(propertyName, opts), [client]);
16
17
  return Object.assign(Object.assign({}, client), { id,
17
18
  track,
19
+ lead,
18
20
  trackPageView,
19
21
  rawTrack,
20
22
  set,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/react",
3
- "version": "1.5.10-rc.109",
3
+ "version": "1.5.10-rc.111",
4
4
  "description": "Usermaven JavaScript SDK for React",
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.111"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "15.x || 16.x || 17.x || 18.x || 19.x",