@usermaven/nextjs 1.5.3 → 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.
- package/lib/index.es.js +48 -38
- 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
|
|
32
|
+
const F = {
|
|
33
33
|
logLevel: v.ERROR,
|
|
34
34
|
useBeaconApi: !1,
|
|
35
35
|
forceUseFetch: !1,
|
|
@@ -237,16 +237,16 @@ function $(i) {
|
|
|
237
237
|
function L(i) {
|
|
238
238
|
let e = "";
|
|
239
239
|
return O(i) && !M(i) && i.childNodes && i.childNodes.length && f(i.childNodes, function(t) {
|
|
240
|
-
|
|
240
|
+
q(t) && t.textContent && (e += x(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
241
241
|
}), x(e);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function B(i) {
|
|
244
244
|
return !!i && i.nodeType === 1;
|
|
245
245
|
}
|
|
246
246
|
function g(i, e) {
|
|
247
247
|
return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function q(i) {
|
|
250
250
|
return !!i && i.nodeType === 3;
|
|
251
251
|
}
|
|
252
252
|
function N(i) {
|
|
@@ -254,7 +254,7 @@ function N(i) {
|
|
|
254
254
|
}
|
|
255
255
|
const b = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
256
256
|
function re(i, e) {
|
|
257
|
-
if (!i || g(i, "html") || !
|
|
257
|
+
if (!i || g(i, "html") || !B(i))
|
|
258
258
|
return !1;
|
|
259
259
|
let t = i;
|
|
260
260
|
for (; t && !g(t, "body"); ) {
|
|
@@ -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
|
-
|
|
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
|
|
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)) {
|
|
@@ -439,7 +443,7 @@ const C = class C {
|
|
|
439
443
|
captureEvent(e) {
|
|
440
444
|
var s, n;
|
|
441
445
|
let t = this.getEventTarget(e);
|
|
442
|
-
if (
|
|
446
|
+
if (q(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
443
447
|
return (s = this.scrollDepth) == null || s.track(), !0;
|
|
444
448
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
445
449
|
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
@@ -523,7 +527,7 @@ const C = class C {
|
|
|
523
527
|
let t = e;
|
|
524
528
|
do
|
|
525
529
|
t = t.previousSibling;
|
|
526
|
-
while (t && !
|
|
530
|
+
while (t && !B(t));
|
|
527
531
|
return t;
|
|
528
532
|
}
|
|
529
533
|
}
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
948
|
+
class ke {
|
|
945
949
|
constructor(e) {
|
|
946
|
-
this.config = this.mergeConfig(e,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1082
|
+
const r = this.createEventPayload(e, t);
|
|
1075
1083
|
try {
|
|
1076
1084
|
if (s) {
|
|
1077
|
-
this.transport.send(
|
|
1085
|
+
this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
|
|
1078
1086
|
return;
|
|
1079
1087
|
}
|
|
1080
|
-
this.retryQueue.add(
|
|
1081
|
-
} catch (
|
|
1082
|
-
throw this.logger.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
|
|
1228
|
-
const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...
|
|
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
|
|
1241
|
+
return new ke(s);
|
|
1234
1242
|
}
|
|
1235
|
-
function
|
|
1243
|
+
function _e(i) {
|
|
1236
1244
|
var n;
|
|
1237
1245
|
const e = {
|
|
1238
1246
|
key: i.getAttribute("data-key") || void 0,
|
|
@@ -1262,10 +1270,12 @@ function ve(i) {
|
|
|
1262
1270
|
domains: i.getAttribute("data-domains") || void 0,
|
|
1263
1271
|
maskAllText: i.getAttribute("data-mask-all-text") === "true",
|
|
1264
1272
|
maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1273
|
+
};
|
|
1274
|
+
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1275
|
+
const t = ve(e), s = e.namespace || "usermaven";
|
|
1276
|
+
u() && t.pageview(), be(s, t);
|
|
1267
1277
|
}
|
|
1268
|
-
function
|
|
1278
|
+
function be(i, e) {
|
|
1269
1279
|
let t = !1;
|
|
1270
1280
|
const s = [], n = [];
|
|
1271
1281
|
function r() {
|
|
@@ -1304,7 +1314,7 @@ function _e(i, e) {
|
|
|
1304
1314
|
u() && function(i, e) {
|
|
1305
1315
|
const t = i.currentScript;
|
|
1306
1316
|
function s() {
|
|
1307
|
-
t && t.src.includes("lib.js") &&
|
|
1317
|
+
t && t.src.includes("lib.js") && _e(t);
|
|
1308
1318
|
}
|
|
1309
1319
|
typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
|
|
1310
1320
|
}(document, window);
|
|
@@ -1313,7 +1323,7 @@ function createClient(params) {
|
|
|
1313
1323
|
if (typeof window === 'undefined') {
|
|
1314
1324
|
return null;
|
|
1315
1325
|
}
|
|
1316
|
-
return
|
|
1326
|
+
return ve(params);
|
|
1317
1327
|
}
|
|
1318
1328
|
|
|
1319
1329
|
/******************************************************************************
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/nextjs",
|
|
3
|
-
"version": "1.5.
|
|
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.
|
|
21
|
+
"@usermaven/sdk-js": "1.5.4-rc.96",
|
|
22
22
|
"cookie": "^0.5.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|