@usermaven/nextjs 1.4.1-rc.59 → 1.4.1-rc.60

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 +83 -78
  2. package/package.json +2 -2
package/lib/index.es.js CHANGED
@@ -29,7 +29,7 @@ class J {
29
29
  function h(s = 0) {
30
30
  return new J(s);
31
31
  }
32
- const I = {
32
+ const D = {
33
33
  logLevel: v.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
@@ -105,35 +105,35 @@ class Q {
105
105
  return i ? i[0] : "";
106
106
  }
107
107
  }
108
- const W = Object.prototype, X = W.hasOwnProperty, K = Array.prototype, b = K.forEach, $ = {};
108
+ const W = Object.prototype, X = W.hasOwnProperty, K = Array.prototype, E = K.forEach, T = {};
109
109
  function Z(s, e, t) {
110
110
  if (Array.isArray(s)) {
111
- if (b && s.forEach === b)
111
+ if (E && s.forEach === E)
112
112
  s.forEach(e, t);
113
113
  else if ("length" in s && s.length === +s.length) {
114
114
  for (let i = 0, n = s.length; i < n; i++)
115
- if (i in s && e.call(t, s[i], i) === $)
115
+ if (i in s && e.call(t, s[i], i) === T)
116
116
  return;
117
117
  }
118
118
  }
119
119
  }
120
- const T = function(s) {
120
+ const A = function(s) {
121
121
  return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
122
122
  }, G = function(s) {
123
123
  for (const e in s)
124
124
  typeof s[e] == "function" && (s[e] = s[e].bind(s));
125
125
  };
126
- function A(s, e, t) {
126
+ function S(s, e, t) {
127
127
  if (s != null) {
128
- if (b && Array.isArray(s) && s.forEach === b)
128
+ if (E && Array.isArray(s) && s.forEach === E)
129
129
  s.forEach(e, t);
130
130
  else if ("length" in s && s.length === +s.length) {
131
131
  for (let i = 0, n = s.length; i < n; i++)
132
- if (i in s && e.call(t, s[i], i) === $)
132
+ if (i in s && e.call(t, s[i], i) === T)
133
133
  return;
134
134
  } else
135
135
  for (const i in s)
136
- if (X.call(s, i) && e.call(t, s[i], i) === $)
136
+ if (X.call(s, i) && e.call(t, s[i], i) === T)
137
137
  return;
138
138
  }
139
139
  }
@@ -146,7 +146,7 @@ const Y = function(s, ...e) {
146
146
  function _(s, e) {
147
147
  return s.indexOf(e) !== -1;
148
148
  }
149
- const D = function(s) {
149
+ const F = function(s) {
150
150
  try {
151
151
  return /^\s*\bfunction\b/.test(s);
152
152
  } catch {
@@ -172,7 +172,7 @@ const D = function(s) {
172
172
  if (o = o || t(window.event), !o)
173
173
  return;
174
174
  let c = !0, l;
175
- D(r) && (l = r(o));
175
+ F(r) && (l = r(o));
176
176
  const a = n.call(i, o);
177
177
  return (l === !1 || a === !1) && (c = !1), c;
178
178
  };
@@ -193,11 +193,11 @@ const D = function(s) {
193
193
  h().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
194
194
  }
195
195
  };
196
- }, F = function(s) {
196
+ }, z = function(s) {
197
197
  for (const e in s)
198
198
  typeof s[e] == "function" && (s[e] = ee(s[e]));
199
199
  };
200
- function R(s) {
200
+ function N(s) {
201
201
  for (let e in s)
202
202
  (s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
203
203
  return s;
@@ -219,13 +219,13 @@ function te(s) {
219
219
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
220
220
  );
221
221
  }
222
- function S(s) {
223
- return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(S) : Object.keys(s).reduce((e, t) => {
222
+ function C(s) {
223
+ return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(C) : Object.keys(s).reduce((e, t) => {
224
224
  const i = te(t);
225
- return e[i] = S(s[t]), e;
225
+ return e[i] = C(s[t]), e;
226
226
  }, {});
227
227
  }
228
- function E(s) {
228
+ function P(s) {
229
229
  switch (typeof s.className) {
230
230
  case "string":
231
231
  return s.className;
@@ -235,50 +235,55 @@ function E(s) {
235
235
  return "";
236
236
  }
237
237
  }
238
- function N(s) {
238
+ function O(s) {
239
239
  let e = "";
240
- return M(s) && !q(s) && s.childNodes && s.childNodes.length && A(s.childNodes, function(t) {
241
- z(t) && t.textContent && (e += T(t.textContent).split(/(\s+)/).filter(x).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
242
- }), T(e);
240
+ return M(s) && !q(s) && s.childNodes && s.childNodes.length && S(s.childNodes, function(t) {
241
+ B(t) && t.textContent && (e += A(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
242
+ }), A(e);
243
243
  }
244
- function H(s) {
244
+ function R(s) {
245
245
  return !!s && s.nodeType === 1;
246
246
  }
247
247
  function d(s, e) {
248
248
  return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
249
249
  }
250
- function z(s) {
250
+ function B(s) {
251
251
  return !!s && s.nodeType === 3;
252
252
  }
253
- function B(s) {
253
+ function x(s) {
254
254
  return !!s && s.nodeType === 11;
255
255
  }
256
- const C = ["a", "button", "form", "input", "select", "textarea", "label"];
256
+ const b = ["a", "button", "form", "input", "select", "textarea", "label"];
257
257
  function ie(s, e) {
258
- if (!s || d(s, "html") || !H(s) || s.classList && s.classList.contains("um-no-capture"))
258
+ if (!s || d(s, "html") || !R(s))
259
259
  return !1;
260
- let t = !1;
261
- const i = [s];
262
- let n = !0, r = s;
263
- for (; r.parentNode && !d(r, "body"); ) {
264
- if (B(r.parentNode)) {
265
- i.push(r.parentNode.host), r = r.parentNode.host;
260
+ let t = s;
261
+ for (; t && !d(t, "body"); ) {
262
+ if (t.classList && t.classList.contains("um-no-capture"))
263
+ return !1;
264
+ t.parentNode && x(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
265
+ }
266
+ let i = !1;
267
+ for (t = s; t && !d(t, "body"); ) {
268
+ if (t.parentNode && x(t.parentNode)) {
269
+ t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
266
270
  continue;
267
271
  }
268
- if (n = r.parentNode || !1, !n) break;
269
- if (C.indexOf(n.tagName.toLowerCase()) > -1)
270
- t = !0;
272
+ const o = t.parentNode;
273
+ if (!o) break;
274
+ if (b.indexOf(o.tagName.toLowerCase()) > -1)
275
+ i = !0;
271
276
  else {
272
- const l = window.getComputedStyle(n);
273
- l && l.getPropertyValue("cursor") === "pointer" && (t = !0);
277
+ const c = window.getComputedStyle(o);
278
+ c && c.getPropertyValue("cursor") === "pointer" && (i = !0);
274
279
  }
275
- i.push(n), r = n;
280
+ t = o;
276
281
  }
277
- const o = window.getComputedStyle(s);
278
- if (o && o.getPropertyValue("cursor") === "pointer" && e.type === "click")
282
+ const n = window.getComputedStyle(s);
283
+ if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
279
284
  return !0;
280
- const c = s.tagName.toLowerCase();
281
- switch (c) {
285
+ const r = s.tagName.toLowerCase();
286
+ switch (r) {
282
287
  case "html":
283
288
  return !1;
284
289
  case "form":
@@ -289,11 +294,11 @@ function ie(s, e) {
289
294
  case "textarea":
290
295
  return e.type === "change" || e.type === "click";
291
296
  default:
292
- return t ? e.type === "click" : e.type === "click" && (C.indexOf(c) > -1 || s.getAttribute("contenteditable") === "true");
297
+ return i ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
293
298
  }
294
299
  }
295
300
  function M(s) {
296
- if (!s || !H(s))
301
+ if (!s || !R(s))
297
302
  return !1;
298
303
  if (typeof s.hasAttribute == "function") {
299
304
  if (s.hasAttribute(w.FORCE_CAPTURE_ATTR))
@@ -303,12 +308,12 @@ function M(s) {
303
308
  }
304
309
  let e = s;
305
310
  for (; e && e.parentElement && !d(e, "body"); ) {
306
- const n = E(e).split(" ");
311
+ const n = P(e).split(" ");
307
312
  if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
308
313
  return !1;
309
314
  e = e.parentElement;
310
315
  }
311
- if (_(E(s).split(" "), "ph-include"))
316
+ if (_(P(s).split(" "), "ph-include"))
312
317
  return !0;
313
318
  const t = s.type;
314
319
  if (typeof t == "string")
@@ -324,13 +329,13 @@ function q(s) {
324
329
  const e = ["button", "checkbox", "submit", "reset"];
325
330
  return !!(d(s, "input") && !e.includes(s.type) || d(s, "select") || d(s, "textarea") || s.getAttribute("contenteditable") === "true");
326
331
  }
327
- function x(s) {
328
- return !(s === null || j(s) || typeof s == "string" && (s = T(s), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
332
+ function H(s) {
333
+ return !(s === null || j(s) || typeof s == "string" && (s = A(s), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
329
334
  }
330
335
  function se(s) {
331
336
  return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
332
337
  }
333
- function P() {
338
+ function $() {
334
339
  return f(10);
335
340
  }
336
341
  function ne(s) {
@@ -353,7 +358,7 @@ function oe(s) {
353
358
  }
354
359
  return e;
355
360
  }
356
- function O(s) {
361
+ function L(s) {
357
362
  return typeof s == "string" || s instanceof String;
358
363
  }
359
364
  function k(s) {
@@ -416,7 +421,7 @@ class ce {
416
421
  }
417
422
  const y = class y {
418
423
  constructor(e, t, i = h()) {
419
- this.logger = i, this.scrollDepth = null, this.client = e, this.options = t, this.scrollDepth = new ce(e), G(this), F(this);
424
+ this.logger = i, this.scrollDepth = null, this.client = e, this.options = t, this.scrollDepth = new ce(e), G(this), z(this);
420
425
  }
421
426
  init() {
422
427
  if (!(document && document.body)) {
@@ -442,7 +447,7 @@ const y = class y {
442
447
  captureEvent(e) {
443
448
  var i, n;
444
449
  let t = this.getEventTarget(e);
445
- if (z(t) && (t = t.parentNode || null), e.type === "scroll")
450
+ if (B(t) && (t = t.parentNode || null), e.type === "scroll")
446
451
  return (i = this.scrollDepth) == null || i.track(), !0;
447
452
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
448
453
  return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
@@ -467,29 +472,29 @@ const y = class y {
467
472
  const t = [e];
468
473
  let i = e;
469
474
  for (; i.parentNode && !d(i, "body"); )
470
- B(i.parentNode) ? (t.push(i.parentNode.host), i = i.parentNode.host) : (t.push(i.parentNode), i = i.parentNode);
475
+ x(i.parentNode) ? (t.push(i.parentNode.host), i = i.parentNode.host) : (t.push(i.parentNode), i = i.parentNode);
471
476
  return t;
472
477
  }
473
478
  getElementsJson(e, t) {
474
479
  const i = [];
475
480
  let n = null, r = !1;
476
- return A(e, (o) => {
481
+ return S(e, (o) => {
477
482
  if (d(o, "a")) {
478
483
  const l = o.getAttribute("href");
479
- l !== null && M(o) && x(l) && (n = l);
484
+ l !== null && M(o) && H(l) && (n = l);
480
485
  }
481
- const c = E(o).split(" ");
486
+ const c = P(o).split(" ");
482
487
  _(c, "ph-no-capture") && (r = !0), i.push(this.getPropertiesFromElement(o));
483
- }), this.options.maskAllText || (i[0].$el_text = this.sanitizeText(N(e[0]))), n !== null && (i[0].attr__href = n), r ? [] : i;
488
+ }), this.options.maskAllText || (i[0].$el_text = this.sanitizeText(O(e[0]))), n !== null && (i[0].attr__href = n), r ? [] : i;
484
489
  }
485
490
  getPropertiesFromElement(e) {
486
491
  const t = {
487
492
  tag_name: e.tagName.toLowerCase()
488
493
  };
489
- C.indexOf(t.tag_name) > -1 && !this.options.maskAllText && (t.$el_text = this.sanitizeText(N(e)));
490
- const i = E(e);
491
- i.length > 0 && (t.classes = i.split(" ").filter((c) => c !== "")), A(e.attributes, (c) => {
492
- q(e) && ["name", "id", "class"].indexOf(c.name) === -1 || !this.options.maskAllElementAttributes && x(c.value) && !se(c.name) && (t["attr__" + c.name] = this.sanitizeAttributeValue(c.name, c.value));
494
+ b.indexOf(t.tag_name) > -1 && !this.options.maskAllText && (t.$el_text = this.sanitizeText(O(e)));
495
+ const i = P(e);
496
+ i.length > 0 && (t.classes = i.split(" ").filter((c) => c !== "")), S(e.attributes, (c) => {
497
+ q(e) && ["name", "id", "class"].indexOf(c.name) === -1 || !this.options.maskAllElementAttributes && H(c.value) && !se(c.name) && (t["attr__" + c.name] = this.sanitizeAttributeValue(c.name, c.value));
493
498
  });
494
499
  let n = 1, r = 1, o = e;
495
500
  for (; o = this.previousElementSibling(o); )
@@ -501,7 +506,7 @@ const y = class y {
501
506
  return e.previousElementSibling;
502
507
  do
503
508
  e = e.previousSibling;
504
- while (e && !H(e));
509
+ while (e && !R(e));
505
510
  return e;
506
511
  }
507
512
  getDefaultProperties(e) {
@@ -546,7 +551,7 @@ const y = class y {
546
551
  return n % t < i;
547
552
  }
548
553
  static isBrowserSupported() {
549
- return D(document.querySelectorAll);
554
+ return F(document.querySelectorAll);
550
555
  }
551
556
  };
552
557
  y.FORCE_CAPTURE_ATTR = "data-um-force-capture", y.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
@@ -598,7 +603,7 @@ class ue {
598
603
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
599
604
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
600
605
  }
601
- class L {
606
+ class U {
602
607
  constructor(e, t, i = h()) {
603
608
  this.trackingHost = e, this.logger = i, this.config = t;
604
609
  }
@@ -714,7 +719,7 @@ class ge {
714
719
  this.storage = {};
715
720
  }
716
721
  }
717
- class U {
722
+ class I {
718
723
  // Default to true for server-side
719
724
  constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = h()) {
720
725
  this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new V("offline_queue"), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
@@ -763,7 +768,7 @@ class U {
763
768
  }
764
769
  class de {
765
770
  constructor(e) {
766
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), F(this);
771
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
767
772
  }
768
773
  initializeEventListener() {
769
774
  document.addEventListener("click", this.handleClick.bind(this));
@@ -846,13 +851,13 @@ class m {
846
851
  }
847
852
  handleFormSubmit(e) {
848
853
  const t = e.target, i = this._getFormDetails(t);
849
- this.instance.track("$form", R(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
854
+ this.instance.track("$form", N(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
850
855
  }
851
856
  trackFieldChanges(e) {
852
857
  e.querySelectorAll("input, select, textarea").forEach((i) => {
853
858
  i.addEventListener("change", (n) => {
854
859
  const r = this._getFieldProps(n.target, 0);
855
- this.instance.track("$form_field_change", R(r));
860
+ this.instance.track("$form_field_change", N(r));
856
861
  });
857
862
  });
858
863
  }
@@ -952,7 +957,7 @@ class m {
952
957
  }
953
958
  class pe {
954
959
  constructor(e) {
955
- this.config = this.mergeConfig(e, I), this.logger = h(this.config.logLevel), this.namespace = e.namespace || "usermaven", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new U(
960
+ this.config = this.mergeConfig(e, D), this.logger = h(this.config.logLevel), this.namespace = e.namespace || "usermaven", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new I(
956
961
  this.transport,
957
962
  this.config.maxSendAttempts || 3,
958
963
  this.config.minSendTimeout || 1e3,
@@ -984,7 +989,7 @@ class pe {
984
989
  }), n;
985
990
  }
986
991
  init(e) {
987
- this.config = { ...this.config, ...e }, this.logger = h(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new U(
992
+ this.config = { ...this.config, ...e }, this.logger = h(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new I(
988
993
  this.transport,
989
994
  this.config.maxSendAttempts || 3,
990
995
  this.config.minSendTimeout || 1e3,
@@ -1023,11 +1028,11 @@ class pe {
1023
1028
  if (e.useBeaconApi && n)
1024
1029
  return new ue(e.trackingHost, e, this.logger);
1025
1030
  if (e.forceUseFetch && i)
1026
- return new L(e.trackingHost, e, this.logger);
1031
+ return new U(e.trackingHost, e, this.logger);
1027
1032
  if (t)
1028
1033
  return new he(e.trackingHost, e, this.logger);
1029
1034
  if (i)
1030
- return new L(e.trackingHost, e, this.logger);
1035
+ return new U(e.trackingHost, e, this.logger);
1031
1036
  throw new Error("No suitable transport method available");
1032
1037
  }
1033
1038
  initializePersistence() {
@@ -1036,7 +1041,7 @@ class pe {
1036
1041
  getOrCreateAnonymousId() {
1037
1042
  var i, n;
1038
1043
  if (!u())
1039
- return P();
1044
+ return $();
1040
1045
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1041
1046
  return this.generateFingerprint();
1042
1047
  const e = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
@@ -1044,9 +1049,9 @@ class pe {
1044
1049
  if (!t) {
1045
1050
  if (this.config.crossDomainLinking) {
1046
1051
  const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), g = a.length > 1 ? a[1] : void 0;
1047
- t = c || g || P();
1052
+ t = c || g || $();
1048
1053
  }
1049
- t || (t = P());
1054
+ t || (t = $());
1050
1055
  const r = 365 * 10;
1051
1056
  (n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
1052
1057
  }
@@ -1069,7 +1074,7 @@ class pe {
1069
1074
  throw new Error("User data must be an object");
1070
1075
  if (e.email && !ne(e.email))
1071
1076
  throw new Error("Invalid email provided");
1072
- if (!e.id || !O(e.id))
1077
+ if (!e.id || !L(e.id))
1073
1078
  throw new Error("User ID must be a string");
1074
1079
  const i = e.id;
1075
1080
  if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
@@ -1085,7 +1090,7 @@ class pe {
1085
1090
  this.trackInternal(e, t, i);
1086
1091
  }
1087
1092
  trackInternal(e, t, i = !1) {
1088
- if (!O(e))
1093
+ if (!L(e))
1089
1094
  throw new Error("Event name must be a string");
1090
1095
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1091
1096
  throw new Error("Event payload must be a non-null object and not an array");
@@ -1244,7 +1249,7 @@ class pe {
1244
1249
  }
1245
1250
  }
1246
1251
  function me(s) {
1247
- const e = JSON.parse(JSON.stringify(s)), t = S(e), i = { ...I, ...t };
1252
+ const e = JSON.parse(JSON.stringify(s)), t = C(e), i = { ...D, ...t };
1248
1253
  if (!i.key)
1249
1254
  throw new Error("API key is required!");
1250
1255
  if (!i.trackingHost)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/nextjs",
3
- "version": "1.4.1-rc.59",
3
+ "version": "1.4.1-rc.60",
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.4.1-rc.59",
21
+ "@usermaven/sdk-js": "1.4.1-rc.60",
22
22
  "cookie": "^0.5.0"
23
23
  },
24
24
  "peerDependencies": {