@usermaven/nextjs 1.5.3-rc.95 → 1.5.4-rc.96

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 +40 -32
  2. package/package.json +2 -2
package/lib/index.es.js CHANGED
@@ -29,7 +29,7 @@ class W {
29
29
  function d(i = 0) {
30
30
  return new W(i);
31
31
  }
32
- const U = {
32
+ const F = {
33
33
  logLevel: v.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
@@ -360,7 +360,11 @@ function ue(i) {
360
360
  const e = i.toUpperCase(), t = v[e];
361
361
  return t || t === 0 ? t : v.ERROR;
362
362
  }
363
- class he {
363
+ const he = () => {
364
+ let i = "false";
365
+ return typeof window < "u" && window.localStorage && (i = localStorage.getItem("um_exclusion")), !(i == null || i === "false");
366
+ };
367
+ class de {
364
368
  constructor(e) {
365
369
  this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ce(this.handleScroll.bind(this), 250), this.initializeEventListener();
366
370
  }
@@ -413,7 +417,7 @@ class he {
413
417
  }
414
418
  const C = class C {
415
419
  constructor(e, t, s = d()) {
416
- this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new he(e), j(this), z(this);
420
+ this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new de(e), j(this), z(this);
417
421
  }
418
422
  init() {
419
423
  if (!(document && document.body)) {
@@ -547,7 +551,7 @@ const C = class C {
547
551
  };
548
552
  C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
549
553
  let S = C;
550
- class de {
554
+ class ge {
551
555
  constructor(e) {
552
556
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
553
557
  }
@@ -576,7 +580,7 @@ class de {
576
580
  }));
577
581
  }
578
582
  }
579
- class ge {
583
+ class fe {
580
584
  constructor(e, t, s = d()) {
581
585
  this.trackingHost = e, this.logger = s, this.config = t;
582
586
  }
@@ -622,7 +626,7 @@ class D {
622
626
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
623
627
  }
624
628
  }
625
- class fe {
629
+ class pe {
626
630
  constructor(e, t, s = d()) {
627
631
  this.trackingHost = e, this.logger = s, this.config = t;
628
632
  }
@@ -691,7 +695,7 @@ class V {
691
695
  }
692
696
  }
693
697
  }
694
- class pe {
698
+ class me {
695
699
  constructor() {
696
700
  this.storage = {};
697
701
  }
@@ -710,7 +714,7 @@ class pe {
710
714
  this.storage = {};
711
715
  }
712
716
  }
713
- class F {
717
+ class U {
714
718
  // Default to true for server-side
715
719
  constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = d(), c = "default") {
716
720
  this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new V(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
@@ -757,7 +761,7 @@ class F {
757
761
  u() && this.persistence.set("queue", JSON.stringify(this.queue));
758
762
  }
759
763
  }
760
- class me {
764
+ class ye {
761
765
  constructor(e) {
762
766
  this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
763
767
  }
@@ -791,7 +795,7 @@ class me {
791
795
  }), this.clicks = [];
792
796
  }
793
797
  }
794
- class ye {
798
+ class we {
795
799
  constructor(e, t, s = d()) {
796
800
  this.trackingHost = e, this.logger = s, this.config = t;
797
801
  }
@@ -941,9 +945,9 @@ class y {
941
945
  return e.slice(t, s + 1);
942
946
  }
943
947
  }
944
- class we {
948
+ class ke {
945
949
  constructor(e) {
946
- this.config = this.mergeConfig(e, U), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new F(
950
+ this.config = this.mergeConfig(e, F), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new U(
947
951
  this.transport,
948
952
  this.config.maxSendAttempts || 3,
949
953
  this.config.minSendTimeout || 1e3,
@@ -961,7 +965,7 @@ class we {
961
965
  trackFieldChanges: !1
962
966
  });
963
967
  }
964
- this.config.autoPageview && (this.pageviewTracking = new de(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new me(this)), this.setupPageLeaveTracking();
968
+ this.config.autoPageview && (this.pageviewTracking = new ge(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new ye(this)), this.setupPageLeaveTracking();
965
969
  }
966
970
  /**
967
971
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -976,7 +980,7 @@ class we {
976
980
  }), n;
977
981
  }
978
982
  init(e) {
979
- this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new F(
983
+ this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new U(
980
984
  this.transport,
981
985
  this.config.maxSendAttempts || 3,
982
986
  this.config.minSendTimeout || 1e3,
@@ -1012,20 +1016,20 @@ class we {
1012
1016
  initializeTransport(e) {
1013
1017
  const t = "https://events.usermaven.com";
1014
1018
  if (!u())
1015
- return new ye(e.trackingHost || t, e);
1019
+ return new we(e.trackingHost || t, e);
1016
1020
  const s = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1017
1021
  if (e.useBeaconApi && r)
1018
- return new ge(e.trackingHost || t, e, this.logger);
1022
+ return new fe(e.trackingHost || t, e, this.logger);
1019
1023
  if (e.forceUseFetch && n)
1020
1024
  return new D(e.trackingHost || t, e, this.logger);
1021
1025
  if (s)
1022
- return new fe(e.trackingHost || t, e, this.logger);
1026
+ return new pe(e.trackingHost || t, e, this.logger);
1023
1027
  if (n)
1024
1028
  return new D(e.trackingHost || t, e, this.logger);
1025
1029
  throw new Error("No suitable transport method available");
1026
1030
  }
1027
1031
  initializePersistence() {
1028
- return this.config.disableEventPersistence || !u() ? new pe() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1032
+ return this.config.disableEventPersistence || !u() ? new me() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1029
1033
  }
1030
1034
  getOrCreateAnonymousId() {
1031
1035
  var s, n;
@@ -1067,19 +1071,23 @@ class we {
1067
1071
  this.trackInternal(e, t, s);
1068
1072
  }
1069
1073
  trackInternal(e, t, s = !1) {
1074
+ if (he()) {
1075
+ this.logger.debug("Tracking disabled due to um_exclusion setting");
1076
+ return;
1077
+ }
1070
1078
  if (!I(e))
1071
1079
  throw new Error("Event name must be a string");
1072
1080
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1073
1081
  throw new Error("Event payload must be a non-null object and not an array");
1074
- const n = this.createEventPayload(e, t);
1082
+ const r = this.createEventPayload(e, t);
1075
1083
  try {
1076
1084
  if (s) {
1077
- this.transport.send(n), this.logger.debug(`Event sent: ${e}`, [n]);
1085
+ this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
1078
1086
  return;
1079
1087
  }
1080
- this.retryQueue.add(n), this.logger.debug(`Event tracked: ${e}`, [n]);
1081
- } catch (r) {
1082
- throw this.logger.error(`Failed to track event: ${e}`, r), new Error(`Failed to track event: ${e}`);
1088
+ this.retryQueue.add(r), this.logger.debug(`Event tracked: ${e}`, [r]);
1089
+ } catch (o) {
1090
+ throw this.logger.error(`Failed to track event: ${e}`, o), new Error(`Failed to track event: ${e}`);
1083
1091
  }
1084
1092
  }
1085
1093
  rawTrack(e) {
@@ -1224,15 +1232,15 @@ class we {
1224
1232
  n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
1225
1233
  }
1226
1234
  }
1227
- function ke(i) {
1228
- const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...U, ...t };
1235
+ function ve(i) {
1236
+ const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...F, ...t };
1229
1237
  if (!s.key)
1230
1238
  throw new Error("API key is required!");
1231
1239
  if (!s.trackingHost)
1232
1240
  throw new Error("Tracking host is required!");
1233
- return new we(s);
1241
+ return new ke(s);
1234
1242
  }
1235
- function ve(i) {
1243
+ function _e(i) {
1236
1244
  var n;
1237
1245
  const e = {
1238
1246
  key: i.getAttribute("data-key") || void 0,
@@ -1264,10 +1272,10 @@ function ve(i) {
1264
1272
  maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
1265
1273
  };
1266
1274
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1267
- const t = ke(e), s = e.namespace || "usermaven";
1268
- u() && t.pageview(), _e(s, t);
1275
+ const t = ve(e), s = e.namespace || "usermaven";
1276
+ u() && t.pageview(), be(s, t);
1269
1277
  }
1270
- function _e(i, e) {
1278
+ function be(i, e) {
1271
1279
  let t = !1;
1272
1280
  const s = [], n = [];
1273
1281
  function r() {
@@ -1306,7 +1314,7 @@ function _e(i, e) {
1306
1314
  u() && function(i, e) {
1307
1315
  const t = i.currentScript;
1308
1316
  function s() {
1309
- t && t.src.includes("lib.js") && ve(t);
1317
+ t && t.src.includes("lib.js") && _e(t);
1310
1318
  }
1311
1319
  typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
1312
1320
  }(document, window);
@@ -1315,7 +1323,7 @@ function createClient(params) {
1315
1323
  if (typeof window === 'undefined') {
1316
1324
  return null;
1317
1325
  }
1318
- return ke(params);
1326
+ return ve(params);
1319
1327
  }
1320
1328
 
1321
1329
  /******************************************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/nextjs",
3
- "version": "1.5.3-rc.95",
3
+ "version": "1.5.4-rc.96",
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.3-rc.95",
21
+ "@usermaven/sdk-js": "1.5.4-rc.96",
22
22
  "cookie": "^0.5.0"
23
23
  },
24
24
  "peerDependencies": {