@usermaven/nextjs 1.4.1-rc.60 → 1.4.1-rc.62
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 +300 -304
- package/package.json +2 -2
package/lib/index.es.js
CHANGED
|
@@ -8,8 +8,8 @@ const UsermavenProvider = function ({ children, client }) {
|
|
|
8
8
|
return React.createElement(Context.Provider, { value: client }, children);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
var v = /* @__PURE__ */ ((
|
|
12
|
-
class
|
|
11
|
+
var v = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(v || {});
|
|
12
|
+
class V {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
this.level = e;
|
|
15
15
|
}
|
|
@@ -26,10 +26,10 @@ class J {
|
|
|
26
26
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function h(
|
|
30
|
-
return new
|
|
29
|
+
function h(i = 0) {
|
|
30
|
+
return new V(i);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const I = {
|
|
33
33
|
logLevel: v.ERROR,
|
|
34
34
|
useBeaconApi: !1,
|
|
35
35
|
forceUseFetch: !1,
|
|
@@ -57,19 +57,18 @@ const D = {
|
|
|
57
57
|
};
|
|
58
58
|
class Q {
|
|
59
59
|
constructor(e) {
|
|
60
|
-
this.domain = e, this.cookieDomain = this.getCookieDomain()
|
|
60
|
+
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
61
61
|
}
|
|
62
|
-
set(e, t,
|
|
63
|
-
console.log("Setting cookie", e, t, i, n, r);
|
|
62
|
+
set(e, t, s = 365, n = !0, r = !1) {
|
|
64
63
|
const o = /* @__PURE__ */ new Date();
|
|
65
|
-
o.setTime(o.getTime() +
|
|
64
|
+
o.setTime(o.getTime() + s * 24 * 60 * 60 * 1e3);
|
|
66
65
|
const c = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", a = r ? "; HttpOnly" : "";
|
|
67
66
|
document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
|
|
68
67
|
}
|
|
69
68
|
get(e) {
|
|
70
|
-
const t = e + "=",
|
|
71
|
-
for (let n = 0; n <
|
|
72
|
-
let r =
|
|
69
|
+
const t = e + "=", s = document.cookie.split(";");
|
|
70
|
+
for (let n = 0; n < s.length; n++) {
|
|
71
|
+
let r = s[n].trim();
|
|
73
72
|
if (r.indexOf(t) === 0)
|
|
74
73
|
return decodeURIComponent(r.substring(t.length));
|
|
75
74
|
}
|
|
@@ -89,7 +88,7 @@ class Q {
|
|
|
89
88
|
}
|
|
90
89
|
isIpAddress(e) {
|
|
91
90
|
const t = e.split(".");
|
|
92
|
-
return t.length === 4 && t.every((
|
|
91
|
+
return t.length === 4 && t.every((s) => !isNaN(Number(s)));
|
|
93
92
|
}
|
|
94
93
|
extractHostname(e) {
|
|
95
94
|
let t;
|
|
@@ -97,110 +96,110 @@ class Q {
|
|
|
97
96
|
}
|
|
98
97
|
extractRootDomain(e) {
|
|
99
98
|
let t = this.extractHostname(e);
|
|
100
|
-
const
|
|
101
|
-
return n > 2 && (
|
|
99
|
+
const s = t.split("."), n = s.length;
|
|
100
|
+
return n > 2 && (s[n - 1].length == 2 ? (t = s[n - 2] + "." + s[n - 1], s[n - 2].length == 2 && (t = s[n - 3] + "." + t)) : t = s[n - 2] + "." + s[n - 1]), t;
|
|
102
101
|
}
|
|
103
102
|
extractTopLevelDomain(e) {
|
|
104
|
-
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,
|
|
105
|
-
return
|
|
103
|
+
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, s = e.match(t);
|
|
104
|
+
return s ? s[0] : "";
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
const W = Object.prototype, X = W.hasOwnProperty, K = Array.prototype, E = K.forEach, T = {};
|
|
109
|
-
function Z(
|
|
110
|
-
if (Array.isArray(
|
|
111
|
-
if (E &&
|
|
112
|
-
|
|
113
|
-
else if ("length" in
|
|
114
|
-
for (let
|
|
115
|
-
if (
|
|
108
|
+
function Z(i, e, t) {
|
|
109
|
+
if (Array.isArray(i)) {
|
|
110
|
+
if (E && i.forEach === E)
|
|
111
|
+
i.forEach(e, t);
|
|
112
|
+
else if ("length" in i && i.length === +i.length) {
|
|
113
|
+
for (let s = 0, n = i.length; s < n; s++)
|
|
114
|
+
if (s in i && e.call(t, i[s], s) === T)
|
|
116
115
|
return;
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
|
-
const A = function(
|
|
121
|
-
return
|
|
122
|
-
}, G = function(
|
|
123
|
-
for (const e in
|
|
124
|
-
typeof
|
|
119
|
+
const A = function(i) {
|
|
120
|
+
return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
121
|
+
}, G = function(i) {
|
|
122
|
+
for (const e in i)
|
|
123
|
+
typeof i[e] == "function" && (i[e] = i[e].bind(i));
|
|
125
124
|
};
|
|
126
|
-
function S(
|
|
127
|
-
if (
|
|
128
|
-
if (E && Array.isArray(
|
|
129
|
-
|
|
130
|
-
else if ("length" in
|
|
131
|
-
for (let
|
|
132
|
-
if (
|
|
125
|
+
function S(i, e, t) {
|
|
126
|
+
if (i != null) {
|
|
127
|
+
if (E && Array.isArray(i) && i.forEach === E)
|
|
128
|
+
i.forEach(e, t);
|
|
129
|
+
else if ("length" in i && i.length === +i.length) {
|
|
130
|
+
for (let s = 0, n = i.length; s < n; s++)
|
|
131
|
+
if (s in i && e.call(t, i[s], s) === T)
|
|
133
132
|
return;
|
|
134
133
|
} else
|
|
135
|
-
for (const
|
|
136
|
-
if (X.call(
|
|
134
|
+
for (const s in i)
|
|
135
|
+
if (X.call(i, s) && e.call(t, i[s], s) === T)
|
|
137
136
|
return;
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
|
-
const Y = function(
|
|
139
|
+
const Y = function(i, ...e) {
|
|
141
140
|
return Z(e, function(t) {
|
|
142
|
-
for (const
|
|
143
|
-
t[
|
|
144
|
-
}),
|
|
141
|
+
for (const s in t)
|
|
142
|
+
t[s] !== void 0 && (i[s] = t[s]);
|
|
143
|
+
}), i;
|
|
145
144
|
};
|
|
146
|
-
function _(
|
|
147
|
-
return
|
|
145
|
+
function _(i, e) {
|
|
146
|
+
return i.indexOf(e) !== -1;
|
|
148
147
|
}
|
|
149
|
-
const F = function(
|
|
148
|
+
const F = function(i) {
|
|
150
149
|
try {
|
|
151
|
-
return /^\s*\bfunction\b/.test(
|
|
150
|
+
return /^\s*\bfunction\b/.test(i);
|
|
152
151
|
} catch {
|
|
153
152
|
return !1;
|
|
154
153
|
}
|
|
155
|
-
}, j = function(
|
|
156
|
-
return
|
|
154
|
+
}, j = function(i) {
|
|
155
|
+
return i === void 0;
|
|
157
156
|
}, p = function() {
|
|
158
|
-
const
|
|
159
|
-
if (!
|
|
157
|
+
const i = function(s, n, r, o, c) {
|
|
158
|
+
if (!s) {
|
|
160
159
|
h().error("No valid element provided to register_event");
|
|
161
160
|
return;
|
|
162
161
|
}
|
|
163
|
-
if (
|
|
164
|
-
|
|
162
|
+
if (s.addEventListener && !o)
|
|
163
|
+
s.addEventListener(n, r, !!c);
|
|
165
164
|
else {
|
|
166
|
-
const l = "on" + n, a =
|
|
167
|
-
|
|
165
|
+
const l = "on" + n, a = s[l];
|
|
166
|
+
s[l] = e(s, r, a);
|
|
168
167
|
}
|
|
169
168
|
};
|
|
170
|
-
function e(
|
|
169
|
+
function e(s, n, r) {
|
|
171
170
|
return function(o) {
|
|
172
171
|
if (o = o || t(window.event), !o)
|
|
173
172
|
return;
|
|
174
173
|
let c = !0, l;
|
|
175
174
|
F(r) && (l = r(o));
|
|
176
|
-
const a = n.call(
|
|
175
|
+
const a = n.call(s, o);
|
|
177
176
|
return (l === !1 || a === !1) && (c = !1), c;
|
|
178
177
|
};
|
|
179
178
|
}
|
|
180
|
-
function t(
|
|
181
|
-
return
|
|
179
|
+
function t(s) {
|
|
180
|
+
return s && (s.preventDefault = t.preventDefault, s.stopPropagation = t.stopPropagation), s;
|
|
182
181
|
}
|
|
183
182
|
return t.preventDefault = function() {
|
|
184
183
|
this.returnValue = !1;
|
|
185
184
|
}, t.stopPropagation = function() {
|
|
186
185
|
this.cancelBubble = !0;
|
|
187
|
-
},
|
|
188
|
-
}(), ee = function(
|
|
186
|
+
}, i;
|
|
187
|
+
}(), ee = function(i) {
|
|
189
188
|
return function(...e) {
|
|
190
189
|
try {
|
|
191
|
-
return
|
|
190
|
+
return i.apply(this, e);
|
|
192
191
|
} catch (t) {
|
|
193
192
|
h().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
194
193
|
}
|
|
195
194
|
};
|
|
196
|
-
}, z = function(
|
|
197
|
-
for (const e in
|
|
198
|
-
typeof
|
|
195
|
+
}, z = function(i) {
|
|
196
|
+
for (const e in i)
|
|
197
|
+
typeof i[e] == "function" && (i[e] = ee(i[e]));
|
|
199
198
|
};
|
|
200
|
-
function N(
|
|
201
|
-
for (let e in
|
|
202
|
-
(
|
|
203
|
-
return
|
|
199
|
+
function N(i) {
|
|
200
|
+
for (let e in i)
|
|
201
|
+
(i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
|
|
202
|
+
return i;
|
|
204
203
|
}
|
|
205
204
|
function u() {
|
|
206
205
|
try {
|
|
@@ -209,80 +208,80 @@ function u() {
|
|
|
209
208
|
return h().warn("window is not available"), !1;
|
|
210
209
|
}
|
|
211
210
|
}
|
|
212
|
-
function f(
|
|
213
|
-
const e = new Uint8Array(
|
|
214
|
-
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0,
|
|
211
|
+
function f(i = 5) {
|
|
212
|
+
const e = new Uint8Array(i);
|
|
213
|
+
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
|
|
215
214
|
}
|
|
216
|
-
function te(
|
|
217
|
-
return
|
|
215
|
+
function te(i) {
|
|
216
|
+
return i.replace(
|
|
218
217
|
/([-_][a-z])/g,
|
|
219
218
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
220
219
|
);
|
|
221
220
|
}
|
|
222
|
-
function C(
|
|
223
|
-
return typeof
|
|
224
|
-
const
|
|
225
|
-
return e[
|
|
221
|
+
function C(i) {
|
|
222
|
+
return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(C) : Object.keys(i).reduce((e, t) => {
|
|
223
|
+
const s = te(t);
|
|
224
|
+
return e[s] = C(i[t]), e;
|
|
226
225
|
}, {});
|
|
227
226
|
}
|
|
228
|
-
function P(
|
|
229
|
-
switch (typeof
|
|
227
|
+
function P(i) {
|
|
228
|
+
switch (typeof i.className) {
|
|
230
229
|
case "string":
|
|
231
|
-
return
|
|
230
|
+
return i.className;
|
|
232
231
|
case "object":
|
|
233
|
-
return ("baseVal" in
|
|
232
|
+
return ("baseVal" in i.className ? i.className.baseVal : null) || i.getAttribute("class") || "";
|
|
234
233
|
default:
|
|
235
234
|
return "";
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
|
-
function O(
|
|
237
|
+
function O(i) {
|
|
239
238
|
let e = "";
|
|
240
|
-
return M(
|
|
239
|
+
return M(i) && !q(i) && i.childNodes && i.childNodes.length && S(i.childNodes, function(t) {
|
|
241
240
|
B(t) && t.textContent && (e += A(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
242
241
|
}), A(e);
|
|
243
242
|
}
|
|
244
|
-
function R(
|
|
245
|
-
return !!
|
|
243
|
+
function R(i) {
|
|
244
|
+
return !!i && i.nodeType === 1;
|
|
246
245
|
}
|
|
247
|
-
function d(
|
|
248
|
-
return !!
|
|
246
|
+
function d(i, e) {
|
|
247
|
+
return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
|
|
249
248
|
}
|
|
250
|
-
function B(
|
|
251
|
-
return !!
|
|
249
|
+
function B(i) {
|
|
250
|
+
return !!i && i.nodeType === 3;
|
|
252
251
|
}
|
|
253
|
-
function x(
|
|
254
|
-
return !!
|
|
252
|
+
function x(i) {
|
|
253
|
+
return !!i && i.nodeType === 11;
|
|
255
254
|
}
|
|
256
255
|
const b = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
257
|
-
function ie(
|
|
258
|
-
if (!
|
|
256
|
+
function ie(i, e) {
|
|
257
|
+
if (!i || d(i, "html") || !R(i))
|
|
259
258
|
return !1;
|
|
260
|
-
let t =
|
|
259
|
+
let t = i;
|
|
261
260
|
for (; t && !d(t, "body"); ) {
|
|
262
261
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
263
262
|
return !1;
|
|
264
263
|
t.parentNode && x(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
265
264
|
}
|
|
266
|
-
let
|
|
267
|
-
for (t =
|
|
265
|
+
let s = !1;
|
|
266
|
+
for (t = i; t && !d(t, "body"); ) {
|
|
268
267
|
if (t.parentNode && x(t.parentNode)) {
|
|
269
|
-
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (
|
|
268
|
+
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
|
|
270
269
|
continue;
|
|
271
270
|
}
|
|
272
271
|
const o = t.parentNode;
|
|
273
272
|
if (!o) break;
|
|
274
273
|
if (b.indexOf(o.tagName.toLowerCase()) > -1)
|
|
275
|
-
|
|
274
|
+
s = !0;
|
|
276
275
|
else {
|
|
277
276
|
const c = window.getComputedStyle(o);
|
|
278
|
-
c && c.getPropertyValue("cursor") === "pointer" && (
|
|
277
|
+
c && c.getPropertyValue("cursor") === "pointer" && (s = !0);
|
|
279
278
|
}
|
|
280
279
|
t = o;
|
|
281
280
|
}
|
|
282
|
-
const n = window.getComputedStyle(
|
|
281
|
+
const n = window.getComputedStyle(i);
|
|
283
282
|
if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
|
|
284
283
|
return !0;
|
|
285
|
-
const r =
|
|
284
|
+
const r = i.tagName.toLowerCase();
|
|
286
285
|
switch (r) {
|
|
287
286
|
case "html":
|
|
288
287
|
return !1;
|
|
@@ -294,80 +293,80 @@ function ie(s, e) {
|
|
|
294
293
|
case "textarea":
|
|
295
294
|
return e.type === "change" || e.type === "click";
|
|
296
295
|
default:
|
|
297
|
-
return
|
|
296
|
+
return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
|
|
298
297
|
}
|
|
299
298
|
}
|
|
300
|
-
function M(
|
|
301
|
-
if (!
|
|
299
|
+
function M(i) {
|
|
300
|
+
if (!i || !R(i))
|
|
302
301
|
return !1;
|
|
303
|
-
if (typeof
|
|
304
|
-
if (
|
|
302
|
+
if (typeof i.hasAttribute == "function") {
|
|
303
|
+
if (i.hasAttribute(w.FORCE_CAPTURE_ATTR))
|
|
305
304
|
return !0;
|
|
306
|
-
if (
|
|
305
|
+
if (i.hasAttribute(w.PREVENT_CAPTURE_ATTR))
|
|
307
306
|
return !1;
|
|
308
307
|
}
|
|
309
|
-
let e =
|
|
308
|
+
let e = i;
|
|
310
309
|
for (; e && e.parentElement && !d(e, "body"); ) {
|
|
311
310
|
const n = P(e).split(" ");
|
|
312
311
|
if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
|
|
313
312
|
return !1;
|
|
314
313
|
e = e.parentElement;
|
|
315
314
|
}
|
|
316
|
-
if (_(P(
|
|
315
|
+
if (_(P(i).split(" "), "ph-include"))
|
|
317
316
|
return !0;
|
|
318
|
-
const t =
|
|
317
|
+
const t = i.type;
|
|
319
318
|
if (typeof t == "string")
|
|
320
319
|
switch (t.toLowerCase()) {
|
|
321
320
|
case "hidden":
|
|
322
321
|
case "password":
|
|
323
322
|
return !1;
|
|
324
323
|
}
|
|
325
|
-
const
|
|
326
|
-
return !(typeof
|
|
324
|
+
const s = i.name || i.id || "";
|
|
325
|
+
return !(typeof s == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g, "")));
|
|
327
326
|
}
|
|
328
|
-
function q(
|
|
327
|
+
function q(i) {
|
|
329
328
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
330
|
-
return !!(d(
|
|
329
|
+
return !!(d(i, "input") && !e.includes(i.type) || d(i, "select") || d(i, "textarea") || i.getAttribute("contenteditable") === "true");
|
|
331
330
|
}
|
|
332
|
-
function H(
|
|
333
|
-
return !(
|
|
331
|
+
function H(i) {
|
|
332
|
+
return !(i === null || j(i) || typeof i == "string" && (i = A(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)));
|
|
334
333
|
}
|
|
335
|
-
function se(
|
|
336
|
-
return typeof
|
|
334
|
+
function se(i) {
|
|
335
|
+
return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
|
|
337
336
|
}
|
|
338
337
|
function $() {
|
|
339
338
|
return f(10);
|
|
340
339
|
}
|
|
341
|
-
function ne(
|
|
342
|
-
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(
|
|
340
|
+
function ne(i) {
|
|
341
|
+
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(i).toLowerCase());
|
|
343
342
|
}
|
|
344
|
-
function re(
|
|
343
|
+
function re(i, e) {
|
|
345
344
|
let t;
|
|
346
|
-
return function(...
|
|
345
|
+
return function(...s) {
|
|
347
346
|
const n = () => {
|
|
348
|
-
clearTimeout(t),
|
|
347
|
+
clearTimeout(t), i(...s);
|
|
349
348
|
};
|
|
350
349
|
clearTimeout(t), t = setTimeout(n, e);
|
|
351
350
|
};
|
|
352
351
|
}
|
|
353
|
-
function oe(
|
|
354
|
-
const e = {}, t =
|
|
355
|
-
for (let
|
|
356
|
-
const n = t[
|
|
352
|
+
function oe(i) {
|
|
353
|
+
const e = {}, t = i.replace(/^\?/, "").split("&");
|
|
354
|
+
for (let s = 0; s < t.length; s++) {
|
|
355
|
+
const n = t[s].split("=");
|
|
357
356
|
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
358
357
|
}
|
|
359
358
|
return e;
|
|
360
359
|
}
|
|
361
|
-
function L(
|
|
362
|
-
return typeof
|
|
360
|
+
function L(i) {
|
|
361
|
+
return typeof i == "string" || i instanceof String;
|
|
363
362
|
}
|
|
364
|
-
function k(
|
|
365
|
-
return
|
|
363
|
+
function k(i) {
|
|
364
|
+
return i !== null && typeof i == "object" && i.constructor === Object;
|
|
366
365
|
}
|
|
367
|
-
function ae(
|
|
368
|
-
if (
|
|
366
|
+
function ae(i) {
|
|
367
|
+
if (i === null)
|
|
369
368
|
return v.ERROR;
|
|
370
|
-
const e =
|
|
369
|
+
const e = i.toUpperCase(), t = v[e];
|
|
371
370
|
return t || t === 0 ? t : v.ERROR;
|
|
372
371
|
}
|
|
373
372
|
class ce {
|
|
@@ -382,6 +381,8 @@ class ce {
|
|
|
382
381
|
e > this.lastScrollDepth && (this.lastScrollDepth = e, this.checkMilestones(e));
|
|
383
382
|
}
|
|
384
383
|
send(e = "$scroll") {
|
|
384
|
+
if (!this.lastScrollDepth)
|
|
385
|
+
return;
|
|
385
386
|
const t = {
|
|
386
387
|
percent: this.lastScrollDepth,
|
|
387
388
|
window_height: this.getWindowHeight(),
|
|
@@ -394,8 +395,8 @@ class ce {
|
|
|
394
395
|
this.track();
|
|
395
396
|
}
|
|
396
397
|
getScrollDepth() {
|
|
397
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(),
|
|
398
|
-
return Math.min(100, Math.floor(
|
|
398
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), s = this.getScrollDistance(), n = t - e;
|
|
399
|
+
return Math.min(100, Math.floor(s / n * 100));
|
|
399
400
|
}
|
|
400
401
|
getWindowHeight() {
|
|
401
402
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -414,14 +415,14 @@ class ce {
|
|
|
414
415
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
415
416
|
}
|
|
416
417
|
checkMilestones(e) {
|
|
417
|
-
this.milestones.filter((
|
|
418
|
-
this.send(), this.milestones = this.milestones.filter((n) => n !==
|
|
418
|
+
this.milestones.filter((s) => e >= s).forEach((s) => {
|
|
419
|
+
this.send(), this.milestones = this.milestones.filter((n) => n !== s);
|
|
419
420
|
});
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
423
|
const y = class y {
|
|
423
|
-
constructor(e, t,
|
|
424
|
-
this.logger =
|
|
424
|
+
constructor(e, t, s = h()) {
|
|
425
|
+
this.logger = s, this.scrollDepth = null, this.client = e, this.options = t, this.scrollDepth = new ce(e), G(this), z(this);
|
|
425
426
|
}
|
|
426
427
|
init() {
|
|
427
428
|
if (!(document && document.body)) {
|
|
@@ -445,10 +446,10 @@ const y = class y {
|
|
|
445
446
|
return performance.navigation && performance.navigation.type === 1;
|
|
446
447
|
}
|
|
447
448
|
captureEvent(e) {
|
|
448
|
-
var
|
|
449
|
+
var s, n;
|
|
449
450
|
let t = this.getEventTarget(e);
|
|
450
451
|
if (B(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
451
|
-
return (
|
|
452
|
+
return (s = this.scrollDepth) == null || s.track(), !0;
|
|
452
453
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
453
454
|
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
454
455
|
if (t && this.shouldCaptureElement(t, e)) {
|
|
@@ -470,13 +471,13 @@ const y = class y {
|
|
|
470
471
|
}
|
|
471
472
|
getElementList(e) {
|
|
472
473
|
const t = [e];
|
|
473
|
-
let
|
|
474
|
-
for (;
|
|
475
|
-
x(
|
|
474
|
+
let s = e;
|
|
475
|
+
for (; s.parentNode && !d(s, "body"); )
|
|
476
|
+
x(s.parentNode) ? (t.push(s.parentNode.host), s = s.parentNode.host) : (t.push(s.parentNode), s = s.parentNode);
|
|
476
477
|
return t;
|
|
477
478
|
}
|
|
478
479
|
getElementsJson(e, t) {
|
|
479
|
-
const
|
|
480
|
+
const s = [];
|
|
480
481
|
let n = null, r = !1;
|
|
481
482
|
return S(e, (o) => {
|
|
482
483
|
if (d(o, "a")) {
|
|
@@ -484,16 +485,16 @@ const y = class y {
|
|
|
484
485
|
l !== null && M(o) && H(l) && (n = l);
|
|
485
486
|
}
|
|
486
487
|
const c = P(o).split(" ");
|
|
487
|
-
_(c, "ph-no-capture") && (r = !0),
|
|
488
|
-
}), this.options.maskAllText || (
|
|
488
|
+
_(c, "ph-no-capture") && (r = !0), s.push(this.getPropertiesFromElement(o));
|
|
489
|
+
}), this.options.maskAllText || (s[0].$el_text = this.sanitizeText(O(e[0]))), n !== null && (s[0].attr__href = n), r ? [] : s;
|
|
489
490
|
}
|
|
490
491
|
getPropertiesFromElement(e) {
|
|
491
492
|
const t = {
|
|
492
493
|
tag_name: e.tagName.toLowerCase()
|
|
493
494
|
};
|
|
494
495
|
b.indexOf(t.tag_name) > -1 && !this.options.maskAllText && (t.$el_text = this.sanitizeText(O(e)));
|
|
495
|
-
const
|
|
496
|
-
|
|
496
|
+
const s = P(e);
|
|
497
|
+
s.length > 0 && (t.classes = s.split(" ").filter((c) => c !== "")), S(e.attributes, (c) => {
|
|
497
498
|
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));
|
|
498
499
|
});
|
|
499
500
|
let n = 1, r = 1, o = e;
|
|
@@ -542,13 +543,13 @@ const y = class y {
|
|
|
542
543
|
encodeHtml(e) {
|
|
543
544
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
544
545
|
}
|
|
545
|
-
static enabledForProject(e, t = 10,
|
|
546
|
+
static enabledForProject(e, t = 10, s = 10) {
|
|
546
547
|
if (!e)
|
|
547
548
|
return !1;
|
|
548
549
|
let n = 0;
|
|
549
550
|
for (let r = 0; r < e.length; r++)
|
|
550
551
|
n += e.charCodeAt(r);
|
|
551
|
-
return n % t <
|
|
552
|
+
return n % t < s;
|
|
552
553
|
}
|
|
553
554
|
static isBrowserSupported() {
|
|
554
555
|
return F(document.querySelectorAll);
|
|
@@ -586,32 +587,32 @@ class le {
|
|
|
586
587
|
}
|
|
587
588
|
}
|
|
588
589
|
class ue {
|
|
589
|
-
constructor(e, t,
|
|
590
|
-
this.trackingHost = e, this.logger =
|
|
590
|
+
constructor(e, t, s = h()) {
|
|
591
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
591
592
|
}
|
|
592
593
|
async send(e) {
|
|
593
|
-
const t = this.config.key,
|
|
594
|
-
if (navigator.sendBeacon(
|
|
594
|
+
const t = this.config.key, s = this.constructUrl(t), n = new Blob([JSON.stringify(e)], { type: "application/json" });
|
|
595
|
+
if (navigator.sendBeacon(s, n))
|
|
595
596
|
this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
|
|
596
597
|
else
|
|
597
598
|
throw new Error("Failed to queue events via Beacon API");
|
|
598
599
|
}
|
|
599
600
|
constructUrl(e) {
|
|
600
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
601
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${
|
|
601
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
602
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
602
603
|
}
|
|
603
604
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
604
605
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
605
606
|
}
|
|
606
607
|
class U {
|
|
607
|
-
constructor(e, t,
|
|
608
|
-
this.trackingHost = e, this.logger =
|
|
608
|
+
constructor(e, t, s = h()) {
|
|
609
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
609
610
|
}
|
|
610
611
|
async send(e) {
|
|
611
|
-
const t = this.config.key,
|
|
612
|
+
const t = this.config.key, s = this.constructUrl(t), n = JSON.stringify(e), r = {
|
|
612
613
|
"Content-Type": "application/json",
|
|
613
614
|
...this.getCustomHeaders()
|
|
614
|
-
}, o = await fetch(
|
|
615
|
+
}, o = await fetch(s, {
|
|
615
616
|
method: "POST",
|
|
616
617
|
headers: r,
|
|
617
618
|
body: n
|
|
@@ -621,8 +622,8 @@ class U {
|
|
|
621
622
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
622
623
|
}
|
|
623
624
|
constructUrl(e) {
|
|
624
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
625
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${
|
|
625
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
626
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
626
627
|
}
|
|
627
628
|
getCustomHeaders() {
|
|
628
629
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -632,26 +633,26 @@ class U {
|
|
|
632
633
|
}
|
|
633
634
|
}
|
|
634
635
|
class he {
|
|
635
|
-
constructor(e, t,
|
|
636
|
-
this.trackingHost = e, this.logger =
|
|
636
|
+
constructor(e, t, s = h()) {
|
|
637
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
637
638
|
}
|
|
638
639
|
send(e) {
|
|
639
|
-
return new Promise((t,
|
|
640
|
+
return new Promise((t, s) => {
|
|
640
641
|
const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
641
642
|
n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
|
|
642
643
|
const c = this.getCustomHeaders();
|
|
643
644
|
Object.keys(c).forEach((l) => {
|
|
644
645
|
n.setRequestHeader(l, c[l]);
|
|
645
646
|
}), n.onload = () => {
|
|
646
|
-
n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) :
|
|
647
|
+
n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : s(new Error(`HTTP error! status: ${n.status}`));
|
|
647
648
|
}, n.onerror = () => {
|
|
648
|
-
|
|
649
|
+
s(new Error("Network error"));
|
|
649
650
|
}, n.send(JSON.stringify(e));
|
|
650
651
|
});
|
|
651
652
|
}
|
|
652
653
|
constructUrl(e) {
|
|
653
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
654
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${
|
|
654
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
655
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
655
656
|
}
|
|
656
657
|
getCustomHeaders() {
|
|
657
658
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -660,7 +661,7 @@ class he {
|
|
|
660
661
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
661
662
|
}
|
|
662
663
|
}
|
|
663
|
-
class
|
|
664
|
+
class J {
|
|
664
665
|
constructor(e, t) {
|
|
665
666
|
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || h();
|
|
666
667
|
}
|
|
@@ -719,10 +720,10 @@ class ge {
|
|
|
719
720
|
this.storage = {};
|
|
720
721
|
}
|
|
721
722
|
}
|
|
722
|
-
class
|
|
723
|
+
class D {
|
|
723
724
|
// Default to true for server-side
|
|
724
|
-
constructor(e, t = 3,
|
|
725
|
-
this.transport = e, this.maxRetries = t, this.retryInterval =
|
|
725
|
+
constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = h()) {
|
|
726
|
+
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 J("offline_queue"), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
726
727
|
}
|
|
727
728
|
add(e) {
|
|
728
729
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -741,11 +742,11 @@ class I {
|
|
|
741
742
|
async processBatch() {
|
|
742
743
|
if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
743
744
|
this.processing = !0;
|
|
744
|
-
const e = this.queue.splice(0, this.batchSize), t = e.map((
|
|
745
|
+
const e = this.queue.splice(0, this.batchSize), t = e.map((s) => s.payload);
|
|
745
746
|
try {
|
|
746
747
|
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
|
|
747
|
-
} catch (
|
|
748
|
-
this.logger.error("Failed to send batch",
|
|
748
|
+
} catch (s) {
|
|
749
|
+
this.logger.error("Failed to send batch", s), await this.handleBatchFailure(e);
|
|
749
750
|
}
|
|
750
751
|
this.processing = !1;
|
|
751
752
|
}
|
|
@@ -780,17 +781,17 @@ class de {
|
|
|
780
781
|
shouldCaptureElement(e) {
|
|
781
782
|
return !e.closest(".um-no-capture");
|
|
782
783
|
}
|
|
783
|
-
click(e, t,
|
|
784
|
-
const n = { x: e, y: t, timestamp:
|
|
785
|
-
this.clicks.push(n), this.clicks = this.clicks.filter((r) =>
|
|
784
|
+
click(e, t, s) {
|
|
785
|
+
const n = { x: e, y: t, timestamp: s };
|
|
786
|
+
this.clicks.push(n), this.clicks = this.clicks.filter((r) => s - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
786
787
|
}
|
|
787
788
|
checkRageClick() {
|
|
788
|
-
const e = this.clicks[0],
|
|
789
|
+
const e = this.clicks[0], s = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
789
790
|
this.clicks.every((r, o) => {
|
|
790
791
|
if (o === 0) return !0;
|
|
791
792
|
const c = this.clicks[o - 1];
|
|
792
793
|
return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
|
|
793
|
-
}) && this.sendRageClickEvent(
|
|
794
|
+
}) && this.sendRageClickEvent(s);
|
|
794
795
|
}
|
|
795
796
|
sendRageClickEvent(e) {
|
|
796
797
|
const t = this.clicks[this.clicks.length - 1];
|
|
@@ -801,14 +802,14 @@ class de {
|
|
|
801
802
|
}
|
|
802
803
|
}
|
|
803
804
|
class fe {
|
|
804
|
-
constructor(e, t,
|
|
805
|
-
this.trackingHost = e, this.logger =
|
|
805
|
+
constructor(e, t, s = h()) {
|
|
806
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
806
807
|
}
|
|
807
808
|
async send(e) {
|
|
808
|
-
const t = this.config.key,
|
|
809
|
-
hostname:
|
|
809
|
+
const t = this.config.key, s = new (void 0)(this.constructUrl(t)), n = {
|
|
810
|
+
hostname: s.hostname,
|
|
810
811
|
port: 443,
|
|
811
|
-
path: `${
|
|
812
|
+
path: `${s.pathname}${s.search}`,
|
|
812
813
|
method: "POST",
|
|
813
814
|
headers: {
|
|
814
815
|
"Content-Type": "application/json",
|
|
@@ -829,16 +830,16 @@ class fe {
|
|
|
829
830
|
});
|
|
830
831
|
}
|
|
831
832
|
constructUrl(e) {
|
|
832
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
833
|
-
return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${
|
|
833
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
|
|
834
|
+
return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${s}`;
|
|
834
835
|
}
|
|
835
836
|
getCustomHeaders() {
|
|
836
837
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
837
838
|
}
|
|
838
839
|
}
|
|
839
840
|
class m {
|
|
840
|
-
constructor(e, t = "all",
|
|
841
|
-
this.instance = e, this.trackingType = t, this.options =
|
|
841
|
+
constructor(e, t = "all", s = {}) {
|
|
842
|
+
this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
842
843
|
}
|
|
843
844
|
initialize() {
|
|
844
845
|
this.trackingType !== "none" && this.setupFormTracking();
|
|
@@ -850,19 +851,19 @@ class m {
|
|
|
850
851
|
});
|
|
851
852
|
}
|
|
852
853
|
handleFormSubmit(e) {
|
|
853
|
-
const t = e.target,
|
|
854
|
-
this.instance.track("$form", N(
|
|
854
|
+
const t = e.target, s = this._getFormDetails(t);
|
|
855
|
+
this.instance.track("$form", N(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
855
856
|
}
|
|
856
857
|
trackFieldChanges(e) {
|
|
857
|
-
e.querySelectorAll("input, select, textarea").forEach((
|
|
858
|
-
|
|
858
|
+
e.querySelectorAll("input, select, textarea").forEach((s) => {
|
|
859
|
+
s.addEventListener("change", (n) => {
|
|
859
860
|
const r = this._getFieldProps(n.target, 0);
|
|
860
861
|
this.instance.track("$form_field_change", N(r));
|
|
861
862
|
});
|
|
862
863
|
});
|
|
863
864
|
}
|
|
864
|
-
static getInstance(e, t = "all",
|
|
865
|
-
return m.instance || (m.instance = new m(e, t,
|
|
865
|
+
static getInstance(e, t = "all", s = {}) {
|
|
866
|
+
return m.instance || (m.instance = new m(e, t, s)), m.instance;
|
|
866
867
|
}
|
|
867
868
|
_getFormDetails(e) {
|
|
868
869
|
const t = {
|
|
@@ -872,18 +873,18 @@ class m {
|
|
|
872
873
|
form_method: e.method,
|
|
873
874
|
form_class: e.className,
|
|
874
875
|
form_attributes: this._getElementAttributes(e)
|
|
875
|
-
},
|
|
876
|
-
return Array.from(
|
|
876
|
+
}, s = e.querySelectorAll("input, select, textarea");
|
|
877
|
+
return Array.from(s).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
|
|
877
878
|
const c = this._getFieldProps(r, o);
|
|
878
879
|
Object.assign(t, c);
|
|
879
880
|
}), t;
|
|
880
881
|
}
|
|
881
882
|
_getFieldProps(e, t) {
|
|
882
|
-
const
|
|
883
|
+
const s = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, n = this.getSafeText(e);
|
|
883
884
|
return {
|
|
884
885
|
[`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
|
|
885
886
|
[`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
|
|
886
|
-
[`field_${t + 1}_data_attributes`]:
|
|
887
|
+
[`field_${t + 1}_data_attributes`]: s,
|
|
887
888
|
[`field_${t + 1}_id`]: e.id,
|
|
888
889
|
[`field_${t + 1}_value`]: n,
|
|
889
890
|
[`field_${t + 1}_class`]: e.className,
|
|
@@ -892,12 +893,7 @@ class m {
|
|
|
892
893
|
};
|
|
893
894
|
}
|
|
894
895
|
_getElementAttributes(e) {
|
|
895
|
-
|
|
896
|
-
for (let i = 0; i < e.attributes.length; i++) {
|
|
897
|
-
const n = e.attributes[i];
|
|
898
|
-
n.name !== "value" && !n.name.startsWith("data-") && (t[n.name] = n.value);
|
|
899
|
-
}
|
|
900
|
-
return t;
|
|
896
|
+
return Object.keys(e.dataset).length ? JSON.parse(JSON.stringify(e.dataset)) : {};
|
|
901
897
|
}
|
|
902
898
|
getSafeText(e) {
|
|
903
899
|
let t = "";
|
|
@@ -920,7 +916,7 @@ class m {
|
|
|
920
916
|
_trim(e) {
|
|
921
917
|
if (typeof String.prototype.trim == "function")
|
|
922
918
|
return e.trim();
|
|
923
|
-
let t = 0,
|
|
919
|
+
let t = 0, s = e.length - 1;
|
|
924
920
|
const n = [
|
|
925
921
|
" ",
|
|
926
922
|
`
|
|
@@ -948,16 +944,16 @@ class m {
|
|
|
948
944
|
" ",
|
|
949
945
|
" "
|
|
950
946
|
].join("");
|
|
951
|
-
for (; t <=
|
|
947
|
+
for (; t <= s && n.indexOf(e[t]) > -1; )
|
|
952
948
|
t++;
|
|
953
|
-
for (;
|
|
954
|
-
|
|
955
|
-
return e.slice(t,
|
|
949
|
+
for (; s >= t && n.indexOf(e[s]) > -1; )
|
|
950
|
+
s--;
|
|
951
|
+
return e.slice(t, s + 1);
|
|
956
952
|
}
|
|
957
953
|
}
|
|
958
954
|
class pe {
|
|
959
955
|
constructor(e) {
|
|
960
|
-
this.config = this.mergeConfig(e,
|
|
956
|
+
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 D(
|
|
961
957
|
this.transport,
|
|
962
958
|
this.config.maxSendAttempts || 3,
|
|
963
959
|
this.config.minSendTimeout || 1e3,
|
|
@@ -982,14 +978,14 @@ class pe {
|
|
|
982
978
|
* @param defaultConfig
|
|
983
979
|
*/
|
|
984
980
|
mergeConfig(e, t) {
|
|
985
|
-
const
|
|
986
|
-
let n = { ...t, ...
|
|
981
|
+
const s = JSON.parse(JSON.stringify(e));
|
|
982
|
+
let n = { ...t, ...s };
|
|
987
983
|
return Object.keys(t).forEach((r) => {
|
|
988
984
|
k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
|
|
989
985
|
}), n;
|
|
990
986
|
}
|
|
991
987
|
init(e) {
|
|
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
|
|
988
|
+
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 D(
|
|
993
989
|
this.transport,
|
|
994
990
|
this.config.maxSendAttempts || 3,
|
|
995
991
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1002,10 +998,10 @@ class pe {
|
|
|
1002
998
|
manageCrossDomainLinking() {
|
|
1003
999
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
1004
1000
|
return;
|
|
1005
|
-
const e = this.config.domains.split(",").map((
|
|
1006
|
-
document.addEventListener("click", (
|
|
1001
|
+
const e = this.config.domains.split(",").map((s) => s.trim()), t = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
|
|
1002
|
+
document.addEventListener("click", (s) => {
|
|
1007
1003
|
var c;
|
|
1008
|
-
const n = this.findClosestLink(
|
|
1004
|
+
const n = this.findClosestLink(s.target);
|
|
1009
1005
|
if (!n) return;
|
|
1010
1006
|
const r = n.getAttribute("href");
|
|
1011
1007
|
if (!r || !r.startsWith("http")) return;
|
|
@@ -1024,28 +1020,28 @@ class pe {
|
|
|
1024
1020
|
initializeTransport(e) {
|
|
1025
1021
|
if (!u())
|
|
1026
1022
|
return new fe(e.trackingHost, e);
|
|
1027
|
-
const t = "XMLHttpRequest" in window,
|
|
1023
|
+
const t = "XMLHttpRequest" in window, s = typeof fetch < "u", n = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1028
1024
|
if (e.useBeaconApi && n)
|
|
1029
1025
|
return new ue(e.trackingHost, e, this.logger);
|
|
1030
|
-
if (e.forceUseFetch &&
|
|
1026
|
+
if (e.forceUseFetch && s)
|
|
1031
1027
|
return new U(e.trackingHost, e, this.logger);
|
|
1032
1028
|
if (t)
|
|
1033
1029
|
return new he(e.trackingHost, e, this.logger);
|
|
1034
|
-
if (
|
|
1030
|
+
if (s)
|
|
1035
1031
|
return new U(e.trackingHost, e, this.logger);
|
|
1036
1032
|
throw new Error("No suitable transport method available");
|
|
1037
1033
|
}
|
|
1038
1034
|
initializePersistence() {
|
|
1039
|
-
return this.config.disableEventPersistence || !u() ? new ge() : new
|
|
1035
|
+
return this.config.disableEventPersistence || !u() ? new ge() : new J(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1040
1036
|
}
|
|
1041
1037
|
getOrCreateAnonymousId() {
|
|
1042
|
-
var
|
|
1038
|
+
var s, n;
|
|
1043
1039
|
if (!u())
|
|
1044
1040
|
return $();
|
|
1045
1041
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1046
|
-
return
|
|
1042
|
+
return "";
|
|
1047
1043
|
const e = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
|
|
1048
|
-
let t = (
|
|
1044
|
+
let t = (s = this.cookieManager) == null ? void 0 : s.get(e);
|
|
1049
1045
|
if (!t) {
|
|
1050
1046
|
if (this.config.crossDomainLinking) {
|
|
1051
1047
|
const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), g = a.length > 1 ? a[1] : void 0;
|
|
@@ -1058,13 +1054,13 @@ class pe {
|
|
|
1058
1054
|
return t;
|
|
1059
1055
|
}
|
|
1060
1056
|
generateFingerprint() {
|
|
1061
|
-
const e = navigator.userAgent, t = `${screen.width}x${screen.height}`,
|
|
1057
|
+
const e = navigator.userAgent, t = `${screen.width}x${screen.height}`, s = screen.colorDepth, n = Intl.DateTimeFormat().resolvedOptions().timeZone, r = `${e}|${t}|${s}|${n}`;
|
|
1062
1058
|
return this.hashString(r);
|
|
1063
1059
|
}
|
|
1064
1060
|
hashString(e) {
|
|
1065
1061
|
let t = 0;
|
|
1066
|
-
for (let
|
|
1067
|
-
const n = e.charCodeAt(
|
|
1062
|
+
for (let s = 0; s < e.length; s++) {
|
|
1063
|
+
const n = e.charCodeAt(s);
|
|
1068
1064
|
t = (t << 5) - t + n, t = t & t;
|
|
1069
1065
|
}
|
|
1070
1066
|
return t.toString(36);
|
|
@@ -1076,8 +1072,8 @@ class pe {
|
|
|
1076
1072
|
throw new Error("Invalid email provided");
|
|
1077
1073
|
if (!e.id || !L(e.id))
|
|
1078
1074
|
throw new Error("User ID must be a string");
|
|
1079
|
-
const
|
|
1080
|
-
if (this.persistence.set("userId",
|
|
1075
|
+
const s = e.id;
|
|
1076
|
+
if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
|
|
1081
1077
|
const n = {
|
|
1082
1078
|
...e,
|
|
1083
1079
|
anonymous_id: this.anonymousId
|
|
@@ -1086,17 +1082,17 @@ class pe {
|
|
|
1086
1082
|
}
|
|
1087
1083
|
this.logger.info("User identified:", e);
|
|
1088
1084
|
}
|
|
1089
|
-
track(e, t,
|
|
1090
|
-
this.trackInternal(e, t,
|
|
1085
|
+
track(e, t, s = !1) {
|
|
1086
|
+
this.trackInternal(e, t, s);
|
|
1091
1087
|
}
|
|
1092
|
-
trackInternal(e, t,
|
|
1088
|
+
trackInternal(e, t, s = !1) {
|
|
1093
1089
|
if (!L(e))
|
|
1094
1090
|
throw new Error("Event name must be a string");
|
|
1095
1091
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1096
1092
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
1097
1093
|
const n = this.createEventPayload(e, t);
|
|
1098
1094
|
try {
|
|
1099
|
-
if (
|
|
1095
|
+
if (s) {
|
|
1100
1096
|
this.transport.send(n), this.logger.debug(`Event sent: ${e}`, [n]);
|
|
1101
1097
|
return;
|
|
1102
1098
|
}
|
|
@@ -1118,14 +1114,14 @@ class pe {
|
|
|
1118
1114
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1119
1115
|
}
|
|
1120
1116
|
createEventPayload(e, t) {
|
|
1121
|
-
const
|
|
1117
|
+
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}`) || {};
|
|
1122
1118
|
let l = t || {};
|
|
1123
1119
|
const a = {
|
|
1124
1120
|
event_id: "",
|
|
1125
1121
|
user: {
|
|
1126
1122
|
anonymous_id: this.anonymousId,
|
|
1127
1123
|
id: r,
|
|
1128
|
-
...
|
|
1124
|
+
...s
|
|
1129
1125
|
},
|
|
1130
1126
|
...n && { company: n },
|
|
1131
1127
|
ids: this.getThirdPartyIds(),
|
|
@@ -1149,8 +1145,8 @@ class pe {
|
|
|
1149
1145
|
}
|
|
1150
1146
|
processAutocaptureAttributes(e) {
|
|
1151
1147
|
let t = {};
|
|
1152
|
-
const
|
|
1153
|
-
return
|
|
1148
|
+
const s = e.$elements || [];
|
|
1149
|
+
return s.length && (t = { ...s[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((n) => {
|
|
1154
1150
|
delete t[n];
|
|
1155
1151
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1156
1152
|
}
|
|
@@ -1182,7 +1178,7 @@ class pe {
|
|
|
1182
1178
|
setupPageLeaveTracking() {
|
|
1183
1179
|
if (!u()) return;
|
|
1184
1180
|
let e = !1, t = !1;
|
|
1185
|
-
const
|
|
1181
|
+
const s = () => {
|
|
1186
1182
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
1187
1183
|
url: window.location.href,
|
|
1188
1184
|
referrer: document.referrer,
|
|
@@ -1194,12 +1190,12 @@ class pe {
|
|
|
1194
1190
|
t = !1;
|
|
1195
1191
|
}, 100);
|
|
1196
1192
|
}), document.addEventListener("visibilitychange", () => {
|
|
1197
|
-
document.visibilityState === "hidden" && !t &&
|
|
1193
|
+
document.visibilityState === "hidden" && !t && s();
|
|
1198
1194
|
});
|
|
1199
1195
|
const n = history.pushState;
|
|
1200
1196
|
history.pushState = function() {
|
|
1201
|
-
return
|
|
1202
|
-
}, window.addEventListener("popstate",
|
|
1197
|
+
return s(), n.apply(this, arguments);
|
|
1198
|
+
}, window.addEventListener("popstate", s);
|
|
1203
1199
|
}
|
|
1204
1200
|
getConfig() {
|
|
1205
1201
|
return this.config;
|
|
@@ -1217,17 +1213,17 @@ class pe {
|
|
|
1217
1213
|
set(e, t) {
|
|
1218
1214
|
if (!k(e))
|
|
1219
1215
|
throw new Error("Properties must be an object");
|
|
1220
|
-
const
|
|
1221
|
-
if (
|
|
1222
|
-
let r = this.persistence.get(`props_${
|
|
1223
|
-
r = { ...r, ...e }, this.persistence.set(`props_${
|
|
1216
|
+
const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1217
|
+
if (s) {
|
|
1218
|
+
let r = this.persistence.get(`props_${s}`) || {};
|
|
1219
|
+
r = { ...r, ...e }, this.persistence.set(`props_${s}`, r);
|
|
1224
1220
|
} else {
|
|
1225
1221
|
let r = this.persistence.get("global_props") || {};
|
|
1226
1222
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1227
1223
|
}
|
|
1228
1224
|
n && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1229
1225
|
properties: e,
|
|
1230
|
-
eventType:
|
|
1226
|
+
eventType: s || "global",
|
|
1231
1227
|
persist: n
|
|
1232
1228
|
});
|
|
1233
1229
|
}
|
|
@@ -1237,100 +1233,100 @@ class pe {
|
|
|
1237
1233
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1238
1234
|
}
|
|
1239
1235
|
unset(e, t) {
|
|
1240
|
-
const
|
|
1241
|
-
if (
|
|
1242
|
-
let r = this.persistence.get(`props_${
|
|
1243
|
-
delete r[e], this.persistence.set(`props_${
|
|
1236
|
+
const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1237
|
+
if (s) {
|
|
1238
|
+
let r = this.persistence.get(`props_${s}`) || {};
|
|
1239
|
+
delete r[e], this.persistence.set(`props_${s}`, r);
|
|
1244
1240
|
} else {
|
|
1245
1241
|
let r = this.persistence.get("global_props") || {};
|
|
1246
1242
|
delete r[e], this.persistence.set("global_props", r);
|
|
1247
1243
|
}
|
|
1248
|
-
n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${
|
|
1244
|
+
n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
|
|
1249
1245
|
}
|
|
1250
1246
|
}
|
|
1251
|
-
function me(
|
|
1252
|
-
const e = JSON.parse(JSON.stringify(
|
|
1253
|
-
if (!
|
|
1247
|
+
function me(i) {
|
|
1248
|
+
const e = JSON.parse(JSON.stringify(i)), t = C(e), s = { ...I, ...t };
|
|
1249
|
+
if (!s.key)
|
|
1254
1250
|
throw new Error("API key is required!");
|
|
1255
|
-
if (!
|
|
1251
|
+
if (!s.trackingHost)
|
|
1256
1252
|
throw new Error("Tracking host is required!");
|
|
1257
|
-
return new pe(
|
|
1253
|
+
return new pe(s);
|
|
1258
1254
|
}
|
|
1259
|
-
function ye(
|
|
1255
|
+
function ye(i) {
|
|
1260
1256
|
var n;
|
|
1261
1257
|
const e = {
|
|
1262
|
-
key:
|
|
1263
|
-
trackingHost:
|
|
1264
|
-
logLevel: ae(
|
|
1265
|
-
autocapture:
|
|
1266
|
-
formTracking:
|
|
1267
|
-
autoPageview:
|
|
1268
|
-
useBeaconApi:
|
|
1269
|
-
forceUseFetch:
|
|
1270
|
-
gaHook:
|
|
1271
|
-
segmentHook:
|
|
1272
|
-
randomizeUrl:
|
|
1273
|
-
capture3rdPartyCookies:
|
|
1274
|
-
idMethod:
|
|
1275
|
-
privacyPolicy:
|
|
1276
|
-
ipPolicy:
|
|
1277
|
-
cookiePolicy:
|
|
1278
|
-
minSendTimeout: parseInt(
|
|
1279
|
-
maxSendTimeout: parseInt(
|
|
1280
|
-
maxSendAttempts: parseInt(
|
|
1281
|
-
propertiesStringMaxLength: parseInt(
|
|
1282
|
-
propertyBlacklist: ((n =
|
|
1283
|
-
exclude:
|
|
1284
|
-
namespace:
|
|
1285
|
-
crossDomainLinking:
|
|
1286
|
-
domains:
|
|
1287
|
-
maskAllText:
|
|
1288
|
-
maskAllElementAttributes:
|
|
1289
|
-
}, t = me(e),
|
|
1290
|
-
u() && t.pageview(), we(
|
|
1258
|
+
key: i.getAttribute("data-key") || void 0,
|
|
1259
|
+
trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1260
|
+
logLevel: ae(i.getAttribute("data-log-level")),
|
|
1261
|
+
autocapture: i.getAttribute("data-autocapture") === "true",
|
|
1262
|
+
formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
|
|
1263
|
+
autoPageview: i.getAttribute("data-auto-pageview") === "true",
|
|
1264
|
+
useBeaconApi: i.getAttribute("data-use-beacon-api") === "true",
|
|
1265
|
+
forceUseFetch: i.getAttribute("data-force-use-fetch") === "true",
|
|
1266
|
+
gaHook: i.getAttribute("data-ga-hook") === "true",
|
|
1267
|
+
segmentHook: i.getAttribute("data-segment-hook") === "true",
|
|
1268
|
+
randomizeUrl: i.getAttribute("data-randomize-url") === "true",
|
|
1269
|
+
capture3rdPartyCookies: i.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
|
|
1270
|
+
idMethod: i.getAttribute("data-id-method") || void 0,
|
|
1271
|
+
privacyPolicy: i.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
|
|
1272
|
+
ipPolicy: i.getAttribute("data-ip-policy") || void 0,
|
|
1273
|
+
cookiePolicy: i.getAttribute("data-cookie-policy") || void 0,
|
|
1274
|
+
minSendTimeout: parseInt(i.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1275
|
+
maxSendTimeout: parseInt(i.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1276
|
+
maxSendAttempts: parseInt(i.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1277
|
+
propertiesStringMaxLength: parseInt(i.getAttribute("data-properties-string-max-length") || "", 10) || null,
|
|
1278
|
+
propertyBlacklist: ((n = i.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
|
|
1279
|
+
exclude: i.getAttribute("data-exclude") || void 0,
|
|
1280
|
+
namespace: i.getAttribute("data-namespace") || void 0,
|
|
1281
|
+
crossDomainLinking: i.getAttribute("data-cross-domain-linking") !== "false",
|
|
1282
|
+
domains: i.getAttribute("data-domains") || void 0,
|
|
1283
|
+
maskAllText: i.getAttribute("data-mask-all-text") === "true",
|
|
1284
|
+
maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1285
|
+
}, t = me(e), s = e.namespace || "usermaven";
|
|
1286
|
+
u() && t.pageview(), we(s, t);
|
|
1291
1287
|
}
|
|
1292
|
-
function we(
|
|
1288
|
+
function we(i, e) {
|
|
1293
1289
|
let t = !1;
|
|
1294
|
-
const
|
|
1290
|
+
const s = [], n = [];
|
|
1295
1291
|
function r() {
|
|
1296
|
-
for (;
|
|
1297
|
-
const a =
|
|
1298
|
-
a && window[
|
|
1292
|
+
for (; s.length > 0; ) {
|
|
1293
|
+
const a = s.shift();
|
|
1294
|
+
a && window[i].apply(null, a);
|
|
1299
1295
|
}
|
|
1300
1296
|
}
|
|
1301
1297
|
function o() {
|
|
1302
1298
|
n.forEach((a) => a()), n.length = 0;
|
|
1303
1299
|
}
|
|
1304
|
-
window[
|
|
1300
|
+
window[i] = function(...a) {
|
|
1305
1301
|
const g = a[0];
|
|
1306
1302
|
if (g === "onLoad") {
|
|
1307
1303
|
typeof a[1] == "function" && (t ? a[1]() : n.push(a[1]));
|
|
1308
1304
|
return;
|
|
1309
1305
|
}
|
|
1310
1306
|
if (!t) {
|
|
1311
|
-
|
|
1307
|
+
s.push(a);
|
|
1312
1308
|
return;
|
|
1313
1309
|
}
|
|
1314
1310
|
if (typeof e[g] == "function")
|
|
1315
1311
|
return e[g].apply(e, a.slice(1));
|
|
1316
1312
|
console.error(`Method ${g} not found on UsermavenClient`);
|
|
1317
1313
|
};
|
|
1318
|
-
const c = `${
|
|
1314
|
+
const c = `${i}Q`, l = window[c] || [];
|
|
1319
1315
|
for (window[c] = l, l.push = function(...a) {
|
|
1320
|
-
return window[
|
|
1316
|
+
return window[i].apply(null, a), Array.prototype.push.apply(this, a);
|
|
1321
1317
|
}, setTimeout(() => {
|
|
1322
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1318
|
+
t = !0, r(), o(), console.log(`Usermaven client for namespace ${i} is ready`);
|
|
1323
1319
|
}, 0); l.length > 0; ) {
|
|
1324
1320
|
const a = l.shift();
|
|
1325
|
-
a &&
|
|
1321
|
+
a && s.push(a);
|
|
1326
1322
|
}
|
|
1327
1323
|
}
|
|
1328
|
-
u() && function(
|
|
1329
|
-
const t =
|
|
1330
|
-
function
|
|
1324
|
+
u() && function(i, e) {
|
|
1325
|
+
const t = i.currentScript;
|
|
1326
|
+
function s() {
|
|
1331
1327
|
t && t.src.includes("lib.js") && ye(t);
|
|
1332
1328
|
}
|
|
1333
|
-
typeof e < "u" && (
|
|
1329
|
+
typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
|
|
1334
1330
|
}(document, window);
|
|
1335
1331
|
|
|
1336
1332
|
function createClient(params) {
|
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.62",
|
|
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.62",
|
|
22
22
|
"cookie": "^0.5.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|