@usermaven/nextjs 1.4.1-rc.63 → 1.4.1-rc.66
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 +53 -51
- package/package.json +2 -2
package/lib/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ class W {
|
|
|
26
26
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function d(i = 0) {
|
|
30
30
|
return new W(i);
|
|
31
31
|
}
|
|
32
32
|
const U = {
|
|
@@ -104,10 +104,10 @@ class X {
|
|
|
104
104
|
return s ? s[0] : "";
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
const K = Object.prototype, G = K.hasOwnProperty, Y = Array.prototype,
|
|
107
|
+
const K = Object.prototype, G = K.hasOwnProperty, Y = Array.prototype, E = Y.forEach, A = {};
|
|
108
108
|
function Z(i, e, t) {
|
|
109
109
|
if (Array.isArray(i)) {
|
|
110
|
-
if (
|
|
110
|
+
if (E && i.forEach === E)
|
|
111
111
|
i.forEach(e, t);
|
|
112
112
|
else if ("length" in i && i.length === +i.length) {
|
|
113
113
|
for (let s = 0, n = i.length; s < n; s++)
|
|
@@ -124,7 +124,7 @@ const x = function(i) {
|
|
|
124
124
|
};
|
|
125
125
|
function f(i, e, t) {
|
|
126
126
|
if (i != null) {
|
|
127
|
-
if (
|
|
127
|
+
if (E && Array.isArray(i) && i.forEach === E)
|
|
128
128
|
i.forEach(e, t);
|
|
129
129
|
else if ("length" in i && i.length === +i.length) {
|
|
130
130
|
for (let s = 0, n = i.length; s < n; s++)
|
|
@@ -156,7 +156,7 @@ const te = function(i) {
|
|
|
156
156
|
}, m = function() {
|
|
157
157
|
const i = function(s, n, r, o, c) {
|
|
158
158
|
if (!s) {
|
|
159
|
-
|
|
159
|
+
d().error("No valid element provided to register_event");
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
if (s.addEventListener && !o)
|
|
@@ -189,7 +189,7 @@ const te = function(i) {
|
|
|
189
189
|
try {
|
|
190
190
|
return i.apply(this, e);
|
|
191
191
|
} catch (t) {
|
|
192
|
-
|
|
192
|
+
d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
}, z = function(i) {
|
|
@@ -205,7 +205,7 @@ function u() {
|
|
|
205
205
|
try {
|
|
206
206
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
207
207
|
} catch {
|
|
208
|
-
return
|
|
208
|
+
return d().warn("window is not available"), !1;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
function p(i = 5) {
|
|
@@ -224,7 +224,7 @@ function H(i) {
|
|
|
224
224
|
return e[s] = H(i[t]), e;
|
|
225
225
|
}, {});
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function $(i) {
|
|
228
228
|
switch (typeof i.className) {
|
|
229
229
|
case "string":
|
|
230
230
|
return i.className;
|
|
@@ -243,7 +243,7 @@ function L(i) {
|
|
|
243
243
|
function q(i) {
|
|
244
244
|
return !!i && i.nodeType === 1;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function g(i, e) {
|
|
247
247
|
return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
|
|
248
248
|
}
|
|
249
249
|
function B(i) {
|
|
@@ -254,16 +254,16 @@ 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 ||
|
|
257
|
+
if (!i || g(i, "html") || !q(i))
|
|
258
258
|
return !1;
|
|
259
259
|
let t = i;
|
|
260
|
-
for (; t && !
|
|
260
|
+
for (; t && !g(t, "body"); ) {
|
|
261
261
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
262
262
|
return !1;
|
|
263
263
|
t.parentNode && N(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
264
264
|
}
|
|
265
265
|
let s = !1;
|
|
266
|
-
for (t = i; t && !
|
|
266
|
+
for (t = i; t && !g(t, "body"); ) {
|
|
267
267
|
if (t.parentNode && N(t.parentNode)) {
|
|
268
268
|
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
|
|
269
269
|
continue;
|
|
@@ -297,12 +297,12 @@ function re(i, e) {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
function O(i) {
|
|
300
|
-
for (let s = i; s.parentNode && !
|
|
301
|
-
const n =
|
|
300
|
+
for (let s = i; s.parentNode && !g(s, "body"); s = s.parentNode) {
|
|
301
|
+
const n = $(s).split(" ");
|
|
302
302
|
if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
|
|
303
303
|
return !1;
|
|
304
304
|
}
|
|
305
|
-
if (_(
|
|
305
|
+
if (_($(i).split(" "), "ph-include"))
|
|
306
306
|
return !0;
|
|
307
307
|
const e = i.type || "";
|
|
308
308
|
if (typeof e == "string")
|
|
@@ -317,7 +317,7 @@ function O(i) {
|
|
|
317
317
|
}
|
|
318
318
|
function M(i) {
|
|
319
319
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
320
|
-
return !!(
|
|
320
|
+
return !!(g(i, "input") && !e.includes(i.type) || g(i, "select") || g(i, "textarea") || i.getAttribute("contenteditable") === "true");
|
|
321
321
|
}
|
|
322
322
|
function P(i) {
|
|
323
323
|
return !(i === null || ie(i) || typeof i == "string" && (i = x(i), /^(?:(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((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
|
|
@@ -412,7 +412,7 @@ class he {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
const C = class C {
|
|
415
|
-
constructor(e, t, s =
|
|
415
|
+
constructor(e, t, s = d()) {
|
|
416
416
|
this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new he(e), j(this), z(this);
|
|
417
417
|
}
|
|
418
418
|
init() {
|
|
@@ -446,7 +446,7 @@ const C = class C {
|
|
|
446
446
|
if (t && re(t, e)) {
|
|
447
447
|
const r = [t];
|
|
448
448
|
let o = t;
|
|
449
|
-
for (; o.parentNode && !
|
|
449
|
+
for (; o.parentNode && !g(o, "body"); ) {
|
|
450
450
|
if (N(o.parentNode)) {
|
|
451
451
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
452
452
|
continue;
|
|
@@ -458,7 +458,7 @@ const C = class C {
|
|
|
458
458
|
if (f(r, (w) => {
|
|
459
459
|
const J = O(w);
|
|
460
460
|
w.tagName.toLowerCase() === "a" && (l = w.getAttribute("href"), l = J && P(l) && l);
|
|
461
|
-
const Q =
|
|
461
|
+
const Q = $(w).split(" ");
|
|
462
462
|
_(Q, "ph-no-capture") && (a = !0), c.push(
|
|
463
463
|
this.getPropertiesFromElement(
|
|
464
464
|
w,
|
|
@@ -505,7 +505,7 @@ const C = class C {
|
|
|
505
505
|
tag_name: n
|
|
506
506
|
};
|
|
507
507
|
b.indexOf(n) > -1 && !s && (r.$el_text = L(e));
|
|
508
|
-
const o =
|
|
508
|
+
const o = $(e);
|
|
509
509
|
o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
|
|
510
510
|
return h !== "";
|
|
511
511
|
})), f(e.attributes, function(h) {
|
|
@@ -547,7 +547,7 @@ const C = class C {
|
|
|
547
547
|
};
|
|
548
548
|
C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
549
549
|
let S = C;
|
|
550
|
-
class
|
|
550
|
+
class de {
|
|
551
551
|
constructor(e) {
|
|
552
552
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
553
553
|
}
|
|
@@ -576,8 +576,8 @@ class ge {
|
|
|
576
576
|
}));
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
-
class
|
|
580
|
-
constructor(e, t, s =
|
|
579
|
+
class ge {
|
|
580
|
+
constructor(e, t, s = d()) {
|
|
581
581
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
582
582
|
}
|
|
583
583
|
async send(e) {
|
|
@@ -595,7 +595,7 @@ class de {
|
|
|
595
595
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
596
596
|
}
|
|
597
597
|
class D {
|
|
598
|
-
constructor(e, t, s =
|
|
598
|
+
constructor(e, t, s = d()) {
|
|
599
599
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
600
600
|
}
|
|
601
601
|
async send(e) {
|
|
@@ -623,7 +623,7 @@ class D {
|
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
class fe {
|
|
626
|
-
constructor(e, t, s =
|
|
626
|
+
constructor(e, t, s = d()) {
|
|
627
627
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
628
628
|
}
|
|
629
629
|
send(e) {
|
|
@@ -653,7 +653,7 @@ class fe {
|
|
|
653
653
|
}
|
|
654
654
|
class V {
|
|
655
655
|
constructor(e, t) {
|
|
656
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t ||
|
|
656
|
+
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
|
|
657
657
|
}
|
|
658
658
|
set(e, t) {
|
|
659
659
|
this.storage[e] = t, this.save();
|
|
@@ -712,8 +712,8 @@ class pe {
|
|
|
712
712
|
}
|
|
713
713
|
class F {
|
|
714
714
|
// Default to true for server-side
|
|
715
|
-
constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o =
|
|
716
|
-
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(
|
|
715
|
+
constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = d(), c = "default") {
|
|
716
|
+
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());
|
|
717
717
|
}
|
|
718
718
|
add(e) {
|
|
719
719
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -792,7 +792,7 @@ class me {
|
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
794
|
class ye {
|
|
795
|
-
constructor(e, t, s =
|
|
795
|
+
constructor(e, t, s = d()) {
|
|
796
796
|
this.trackingHost = e, this.logger = s, this.config = t;
|
|
797
797
|
}
|
|
798
798
|
async send(e) {
|
|
@@ -943,14 +943,15 @@ class y {
|
|
|
943
943
|
}
|
|
944
944
|
class we {
|
|
945
945
|
constructor(e) {
|
|
946
|
-
this.config = this.mergeConfig(e, U), this.logger =
|
|
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(
|
|
947
947
|
this.transport,
|
|
948
948
|
this.config.maxSendAttempts || 3,
|
|
949
949
|
this.config.minSendTimeout || 1e3,
|
|
950
950
|
10,
|
|
951
951
|
200,
|
|
952
952
|
// Reduced interval to .2 second
|
|
953
|
-
this.logger
|
|
953
|
+
this.logger,
|
|
954
|
+
this.namespace
|
|
954
955
|
), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
|
|
955
956
|
}
|
|
956
957
|
initializeBrowserFeatures() {
|
|
@@ -960,7 +961,7 @@ class we {
|
|
|
960
961
|
trackFieldChanges: !1
|
|
961
962
|
});
|
|
962
963
|
}
|
|
963
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
964
|
+
this.config.autoPageview && (this.pageviewTracking = new de(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new me(this)), this.setupPageLeaveTracking();
|
|
964
965
|
}
|
|
965
966
|
/**
|
|
966
967
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -975,20 +976,21 @@ class we {
|
|
|
975
976
|
}), n;
|
|
976
977
|
}
|
|
977
978
|
init(e) {
|
|
978
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
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(
|
|
979
980
|
this.transport,
|
|
980
981
|
this.config.maxSendAttempts || 3,
|
|
981
982
|
this.config.minSendTimeout || 1e3,
|
|
982
983
|
10,
|
|
983
984
|
250,
|
|
984
985
|
// Reduced interval to .25 second
|
|
985
|
-
this.logger
|
|
986
|
+
this.logger,
|
|
987
|
+
this.namespace
|
|
986
988
|
), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
|
|
987
989
|
}
|
|
988
990
|
manageCrossDomainLinking() {
|
|
989
991
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
990
992
|
return;
|
|
991
|
-
const e = this.config.domains.split(",").map((s) => s.trim()), t = this.config.cookieName ||
|
|
993
|
+
const e = this.config.domains.split(",").map((s) => s.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
992
994
|
document.addEventListener("click", (s) => {
|
|
993
995
|
var c;
|
|
994
996
|
const n = this.findClosestLink(s.target);
|
|
@@ -1008,17 +1010,18 @@ class we {
|
|
|
1008
1010
|
return e;
|
|
1009
1011
|
}
|
|
1010
1012
|
initializeTransport(e) {
|
|
1013
|
+
const t = "https://events.usermaven.com";
|
|
1011
1014
|
if (!u())
|
|
1012
|
-
return new ye(e.trackingHost, e);
|
|
1013
|
-
const
|
|
1014
|
-
if (e.useBeaconApi &&
|
|
1015
|
-
return new
|
|
1016
|
-
if (e.forceUseFetch &&
|
|
1017
|
-
return new D(e.trackingHost, e, this.logger);
|
|
1018
|
-
if (t)
|
|
1019
|
-
return new fe(e.trackingHost, e, this.logger);
|
|
1015
|
+
return new ye(e.trackingHost || t, e);
|
|
1016
|
+
const s = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1017
|
+
if (e.useBeaconApi && r)
|
|
1018
|
+
return new ge(e.trackingHost || t, e, this.logger);
|
|
1019
|
+
if (e.forceUseFetch && n)
|
|
1020
|
+
return new D(e.trackingHost || t, e, this.logger);
|
|
1020
1021
|
if (s)
|
|
1021
|
-
return new
|
|
1022
|
+
return new fe(e.trackingHost || t, e, this.logger);
|
|
1023
|
+
if (n)
|
|
1024
|
+
return new D(e.trackingHost || t, e, this.logger);
|
|
1022
1025
|
throw new Error("No suitable transport method available");
|
|
1023
1026
|
}
|
|
1024
1027
|
initializePersistence() {
|
|
@@ -1030,7 +1033,7 @@ class we {
|
|
|
1030
1033
|
return T();
|
|
1031
1034
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1032
1035
|
return "";
|
|
1033
|
-
const e = this.config.cookieName ||
|
|
1036
|
+
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1034
1037
|
let t = (s = this.cookieManager) == null ? void 0 : s.get(e);
|
|
1035
1038
|
if (!t) {
|
|
1036
1039
|
if (this.config.crossDomainLinking) {
|
|
@@ -1092,7 +1095,7 @@ class we {
|
|
|
1092
1095
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1093
1096
|
}
|
|
1094
1097
|
createEventPayload(e, t) {
|
|
1095
|
-
const s = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || void 0, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
|
|
1098
|
+
const s = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || (s == null ? void 0 : s.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
|
|
1096
1099
|
let l = t || {};
|
|
1097
1100
|
const a = {
|
|
1098
1101
|
event_id: "",
|
|
@@ -1115,10 +1118,9 @@ class we {
|
|
|
1115
1118
|
if (e === "$autocapture") {
|
|
1116
1119
|
const h = this.processAutocaptureAttributes(t || {});
|
|
1117
1120
|
a.autocapture_attributes = h;
|
|
1118
|
-
} else
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}), a.event_attributes = l;
|
|
1121
|
+
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((h) => {
|
|
1122
|
+
delete l[h];
|
|
1123
|
+
}), a.event_attributes = l);
|
|
1122
1124
|
return u() && (a.referer = document.referrer, a.url = window.location.href, a.page_title = document.title, a.doc_path = window.location.pathname, a.doc_host = window.location.hostname, a.doc_search = window.location.search, a.screen_resolution = `${window.screen.width}x${window.screen.height}`, a.vp_size = `${window.innerWidth}x${window.innerHeight}`, a.user_agent = navigator.userAgent, a.user_language = navigator.language, a.doc_encoding = document.characterSet, a.utm = this.getUtmParams()), a;
|
|
1123
1125
|
}
|
|
1124
1126
|
processAutocaptureAttributes(e) {
|
|
@@ -1183,7 +1185,7 @@ class we {
|
|
|
1183
1185
|
}
|
|
1184
1186
|
async reset(e = !1) {
|
|
1185
1187
|
if (this.persistence.clear(), e && this.cookieManager) {
|
|
1186
|
-
const t = this.config.cookieName ||
|
|
1188
|
+
const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1187
1189
|
this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
|
|
1188
1190
|
}
|
|
1189
1191
|
this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/nextjs",
|
|
3
|
-
"version": "1.4.1-rc.
|
|
3
|
+
"version": "1.4.1-rc.66",
|
|
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.
|
|
21
|
+
"@usermaven/sdk-js": "1.4.1-rc.66",
|
|
22
22
|
"cookie": "^0.5.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|