@usermaven/nextjs 1.5.10-rc.110 → 1.5.10-rc.112
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/UsermavenContext.d.ts +1 -1
- package/lib/UsermavenProvider.d.ts +2 -2
- package/lib/client.d.ts +1 -1
- package/lib/index.es.js +590 -379
- package/lib/middlewareEnv.d.ts +3 -3
- package/lib/middlewareEnv.js +23 -17
- package/lib/usePageView.d.ts +1 -1
- package/lib/useUsermaven.d.ts +1 -1
- 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 k = /* @__PURE__ */ ((
|
|
12
|
-
class
|
|
11
|
+
var k = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(k || {});
|
|
12
|
+
class se {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
this.level = e;
|
|
15
15
|
}
|
|
@@ -26,8 +26,8 @@ class ne {
|
|
|
26
26
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return new
|
|
29
|
+
function g(s = 0) {
|
|
30
|
+
return new se(s);
|
|
31
31
|
}
|
|
32
32
|
const Z = {
|
|
33
33
|
logLevel: k.ERROR,
|
|
@@ -42,7 +42,13 @@ const Z = {
|
|
|
42
42
|
gaHook: !1,
|
|
43
43
|
segmentHook: !1,
|
|
44
44
|
randomizeUrl: !1,
|
|
45
|
-
capture3rdPartyCookies: [
|
|
45
|
+
capture3rdPartyCookies: [
|
|
46
|
+
"_ga",
|
|
47
|
+
"_fbp",
|
|
48
|
+
"_ym_uid",
|
|
49
|
+
"ajs_user_id",
|
|
50
|
+
"ajs_anonymous_id"
|
|
51
|
+
],
|
|
46
52
|
idMethod: "cookie",
|
|
47
53
|
ipPolicy: "keep",
|
|
48
54
|
cookiePolicy: "keep",
|
|
@@ -55,20 +61,20 @@ const Z = {
|
|
|
55
61
|
maskAllText: !1,
|
|
56
62
|
maskAllElementAttributes: !1
|
|
57
63
|
};
|
|
58
|
-
class
|
|
64
|
+
class ne {
|
|
59
65
|
constructor(e) {
|
|
60
66
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
61
67
|
}
|
|
62
|
-
set(e, t, i = 365,
|
|
68
|
+
set(e, t, i = 365, n = !0, r = !1) {
|
|
63
69
|
const o = /* @__PURE__ */ new Date();
|
|
64
70
|
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
65
|
-
const a = `expires=${o.toUTCString()}`, l =
|
|
71
|
+
const a = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", c = r ? "; HttpOnly" : "";
|
|
66
72
|
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
|
|
67
73
|
}
|
|
68
74
|
get(e) {
|
|
69
75
|
const t = e + "=", i = document.cookie.split(";");
|
|
70
|
-
for (let
|
|
71
|
-
let r = i[
|
|
76
|
+
for (let n = 0; n < i.length; n++) {
|
|
77
|
+
let r = i[n].trim();
|
|
72
78
|
if (r.indexOf(t) === 0)
|
|
73
79
|
return decodeURIComponent(r.substring(t.length));
|
|
74
80
|
}
|
|
@@ -96,83 +102,83 @@ class se {
|
|
|
96
102
|
}
|
|
97
103
|
extractRootDomain(e) {
|
|
98
104
|
let t = this.extractHostname(e);
|
|
99
|
-
const i = t.split("."),
|
|
100
|
-
return
|
|
105
|
+
const i = t.split("."), n = i.length;
|
|
106
|
+
return n > 2 && (i[n - 1].length == 2 ? (t = i[n - 2] + "." + i[n - 1], i[n - 2].length == 2 && (t = i[n - 3] + "." + t)) : t = i[n - 2] + "." + i[n - 1]), t;
|
|
101
107
|
}
|
|
102
108
|
extractTopLevelDomain(e) {
|
|
103
109
|
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
|
|
104
110
|
return i ? i[0] : "";
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
|
-
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype,
|
|
108
|
-
function ce(
|
|
109
|
-
if (Array.isArray(
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
else if ("length" in
|
|
113
|
-
for (let i = 0,
|
|
114
|
-
if (i in
|
|
113
|
+
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, T = ae.forEach, U = {};
|
|
114
|
+
function ce(s, e, t) {
|
|
115
|
+
if (Array.isArray(s)) {
|
|
116
|
+
if (T && s.forEach === T)
|
|
117
|
+
s.forEach(e, t);
|
|
118
|
+
else if ("length" in s && s.length === +s.length) {
|
|
119
|
+
for (let i = 0, n = s.length; i < n; i++)
|
|
120
|
+
if (i in s && e.call(t, s[i], i) === U)
|
|
115
121
|
return;
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
}, le = function(
|
|
122
|
-
for (const e in
|
|
123
|
-
typeof
|
|
125
|
+
const B = function(s) {
|
|
126
|
+
return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
127
|
+
}, le = function(s) {
|
|
128
|
+
for (const e in s)
|
|
129
|
+
typeof s[e] == "function" && (s[e] = s[e].bind(s));
|
|
124
130
|
};
|
|
125
|
-
function w(
|
|
126
|
-
if (
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
else if ("length" in
|
|
130
|
-
for (let i = 0,
|
|
131
|
-
if (i in
|
|
131
|
+
function w(s, e, t) {
|
|
132
|
+
if (s != null) {
|
|
133
|
+
if (T && Array.isArray(s) && s.forEach === T)
|
|
134
|
+
s.forEach(e, t);
|
|
135
|
+
else if ("length" in s && s.length === +s.length) {
|
|
136
|
+
for (let i = 0, n = s.length; i < n; i++)
|
|
137
|
+
if (i in s && e.call(t, s[i], i) === U)
|
|
132
138
|
return;
|
|
133
139
|
} else
|
|
134
|
-
for (const i in
|
|
135
|
-
if (oe.call(
|
|
140
|
+
for (const i in s)
|
|
141
|
+
if (oe.call(s, i) && e.call(t, s[i], i) === U)
|
|
136
142
|
return;
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
|
-
const ue = function(
|
|
145
|
+
const ue = function(s, ...e) {
|
|
140
146
|
return ce(e, function(t) {
|
|
141
147
|
for (const i in t)
|
|
142
|
-
t[i] !== void 0 && (
|
|
143
|
-
}),
|
|
148
|
+
t[i] !== void 0 && (s[i] = t[i]);
|
|
149
|
+
}), s;
|
|
144
150
|
};
|
|
145
|
-
function
|
|
146
|
-
return
|
|
151
|
+
function A(s, e) {
|
|
152
|
+
return s.indexOf(e) !== -1;
|
|
147
153
|
}
|
|
148
|
-
const he = function(
|
|
154
|
+
const he = function(s) {
|
|
149
155
|
try {
|
|
150
|
-
return /^\s*\bfunction\b/.test(
|
|
156
|
+
return /^\s*\bfunction\b/.test(s);
|
|
151
157
|
} catch {
|
|
152
158
|
return !1;
|
|
153
159
|
}
|
|
154
|
-
}, de = function(
|
|
155
|
-
return
|
|
160
|
+
}, de = function(s) {
|
|
161
|
+
return s === void 0;
|
|
156
162
|
}, E = function() {
|
|
157
|
-
const
|
|
163
|
+
const s = function(i, n, r, o, a) {
|
|
158
164
|
if (!i) {
|
|
159
|
-
|
|
165
|
+
g().error("No valid element provided to register_event");
|
|
160
166
|
return;
|
|
161
167
|
}
|
|
162
168
|
if (i.addEventListener && !o)
|
|
163
|
-
i.addEventListener(
|
|
169
|
+
i.addEventListener(n, r, !!a);
|
|
164
170
|
else {
|
|
165
|
-
const l = "on" +
|
|
171
|
+
const l = "on" + n, c = i[l];
|
|
166
172
|
i[l] = e(i, r, c);
|
|
167
173
|
}
|
|
168
174
|
};
|
|
169
|
-
function e(i,
|
|
175
|
+
function e(i, n, r) {
|
|
170
176
|
return function(o) {
|
|
171
177
|
if (o = o || t(window.event), !o)
|
|
172
178
|
return;
|
|
173
179
|
let a = !0, l;
|
|
174
180
|
he(r) && (l = r(o));
|
|
175
|
-
const c =
|
|
181
|
+
const c = n.call(i, o);
|
|
176
182
|
return (l === !1 || c === !1) && (a = !1), a;
|
|
177
183
|
};
|
|
178
184
|
}
|
|
@@ -183,88 +189,102 @@ const he = function(n) {
|
|
|
183
189
|
this.returnValue = !1;
|
|
184
190
|
}, t.stopPropagation = function() {
|
|
185
191
|
this.cancelBubble = !0;
|
|
186
|
-
},
|
|
187
|
-
}(),
|
|
192
|
+
}, s;
|
|
193
|
+
}(), ge = function(s) {
|
|
188
194
|
return function(...e) {
|
|
189
195
|
try {
|
|
190
|
-
return
|
|
196
|
+
return s.apply(this, e);
|
|
191
197
|
} catch (t) {
|
|
192
|
-
|
|
198
|
+
g().error(
|
|
199
|
+
"Implementation error. Please turn on debug and contact support@usermaven.com.",
|
|
200
|
+
t
|
|
201
|
+
);
|
|
193
202
|
}
|
|
194
203
|
};
|
|
195
|
-
}, Y = function(
|
|
196
|
-
for (const e in
|
|
197
|
-
typeof
|
|
204
|
+
}, Y = function(s) {
|
|
205
|
+
for (const e in s)
|
|
206
|
+
typeof s[e] == "function" && (s[e] = ge(s[e]));
|
|
198
207
|
};
|
|
199
|
-
function
|
|
200
|
-
for (let e in
|
|
201
|
-
(
|
|
202
|
-
return
|
|
208
|
+
function M(s) {
|
|
209
|
+
for (let e in s)
|
|
210
|
+
(s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
|
|
211
|
+
return s;
|
|
203
212
|
}
|
|
204
213
|
function h() {
|
|
205
214
|
try {
|
|
206
215
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
207
216
|
} catch {
|
|
208
|
-
return
|
|
217
|
+
return g().warn("window is not available"), !1;
|
|
209
218
|
}
|
|
210
219
|
}
|
|
211
|
-
function v(
|
|
212
|
-
const e = new Uint8Array(
|
|
213
|
-
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0,
|
|
220
|
+
function v(s = 5) {
|
|
221
|
+
const e = new Uint8Array(s);
|
|
222
|
+
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, s);
|
|
214
223
|
}
|
|
215
|
-
function
|
|
216
|
-
return
|
|
224
|
+
function fe(s) {
|
|
225
|
+
return s.replace(
|
|
217
226
|
/([-_][a-z])/g,
|
|
218
227
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
219
228
|
);
|
|
220
229
|
}
|
|
221
|
-
function
|
|
222
|
-
return typeof
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
function F(s) {
|
|
231
|
+
return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(F) : Object.keys(s).reduce(
|
|
232
|
+
(e, t) => {
|
|
233
|
+
const i = fe(t);
|
|
234
|
+
return e[i] = F(s[t]), e;
|
|
235
|
+
},
|
|
236
|
+
{}
|
|
237
|
+
);
|
|
226
238
|
}
|
|
227
|
-
function x(
|
|
228
|
-
switch (typeof
|
|
239
|
+
function x(s) {
|
|
240
|
+
switch (typeof s.className) {
|
|
229
241
|
case "string":
|
|
230
|
-
return
|
|
242
|
+
return s.className;
|
|
231
243
|
case "object":
|
|
232
|
-
return ("baseVal" in
|
|
244
|
+
return ("baseVal" in s.className ? s.className.baseVal : null) || s.getAttribute("class") || "";
|
|
233
245
|
default:
|
|
234
246
|
return "";
|
|
235
247
|
}
|
|
236
248
|
}
|
|
237
|
-
function
|
|
249
|
+
function V(s) {
|
|
238
250
|
let e = "";
|
|
239
|
-
return
|
|
240
|
-
j(t) && t.textContent && (e +=
|
|
241
|
-
}),
|
|
251
|
+
return q(s) && !ee(s) && s.childNodes && s.childNodes.length && w(s.childNodes, function(t) {
|
|
252
|
+
j(t) && t.textContent && (e += B(t.textContent).split(/(\s+)/).filter($).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
253
|
+
}), B(e);
|
|
242
254
|
}
|
|
243
|
-
function G(
|
|
244
|
-
return !!
|
|
255
|
+
function G(s) {
|
|
256
|
+
return !!s && s.nodeType === 1;
|
|
245
257
|
}
|
|
246
|
-
function y(
|
|
247
|
-
return !!
|
|
258
|
+
function y(s, e) {
|
|
259
|
+
return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
|
|
248
260
|
}
|
|
249
|
-
function j(
|
|
250
|
-
return !!
|
|
261
|
+
function j(s) {
|
|
262
|
+
return !!s && s.nodeType === 3;
|
|
251
263
|
}
|
|
252
|
-
function
|
|
253
|
-
return !!
|
|
264
|
+
function Q(s) {
|
|
265
|
+
return !!s && s.nodeType === 11;
|
|
254
266
|
}
|
|
255
|
-
const C = [
|
|
256
|
-
|
|
257
|
-
|
|
267
|
+
const C = [
|
|
268
|
+
"a",
|
|
269
|
+
"button",
|
|
270
|
+
"form",
|
|
271
|
+
"input",
|
|
272
|
+
"select",
|
|
273
|
+
"textarea",
|
|
274
|
+
"label"
|
|
275
|
+
];
|
|
276
|
+
function pe(s, e) {
|
|
277
|
+
if (!s || y(s, "html") || !G(s))
|
|
258
278
|
return !1;
|
|
259
|
-
let t =
|
|
279
|
+
let t = s;
|
|
260
280
|
for (; t && !y(t, "body"); ) {
|
|
261
281
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
262
282
|
return !1;
|
|
263
|
-
t.parentNode &&
|
|
283
|
+
t.parentNode && Q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
264
284
|
}
|
|
265
285
|
let i = !1;
|
|
266
|
-
for (t =
|
|
267
|
-
if (t.parentNode &&
|
|
286
|
+
for (t = s; t && !y(t, "body"); ) {
|
|
287
|
+
if (t.parentNode && Q(t.parentNode)) {
|
|
268
288
|
t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
269
289
|
continue;
|
|
270
290
|
}
|
|
@@ -278,10 +298,10 @@ function pe(n, e) {
|
|
|
278
298
|
}
|
|
279
299
|
t = o;
|
|
280
300
|
}
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
301
|
+
const n = window.getComputedStyle(s);
|
|
302
|
+
if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
|
|
283
303
|
return !0;
|
|
284
|
-
const r =
|
|
304
|
+
const r = s.tagName.toLowerCase();
|
|
285
305
|
switch (r) {
|
|
286
306
|
case "html":
|
|
287
307
|
return !1;
|
|
@@ -293,18 +313,18 @@ function pe(n, e) {
|
|
|
293
313
|
case "textarea":
|
|
294
314
|
return e.type === "change" || e.type === "click";
|
|
295
315
|
default:
|
|
296
|
-
return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 ||
|
|
316
|
+
return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
|
|
297
317
|
}
|
|
298
318
|
}
|
|
299
|
-
function
|
|
300
|
-
for (let i =
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
319
|
+
function q(s) {
|
|
320
|
+
for (let i = s; i.parentNode && !y(i, "body"); i = i.parentNode) {
|
|
321
|
+
const n = x(i).split(" ");
|
|
322
|
+
if (A(n, "ph-sensitive") || A(n, "ph-no-capture"))
|
|
303
323
|
return !1;
|
|
304
324
|
}
|
|
305
|
-
if (
|
|
325
|
+
if (A(x(s).split(" "), "ph-include"))
|
|
306
326
|
return !0;
|
|
307
|
-
const e =
|
|
327
|
+
const e = s.type || "";
|
|
308
328
|
if (typeof e == "string")
|
|
309
329
|
switch (e.toLowerCase()) {
|
|
310
330
|
case "hidden":
|
|
@@ -312,59 +332,59 @@ function B(n) {
|
|
|
312
332
|
case "password":
|
|
313
333
|
return !1;
|
|
314
334
|
}
|
|
315
|
-
const t =
|
|
335
|
+
const t = s.name || s.id || "";
|
|
316
336
|
return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
|
|
317
337
|
}
|
|
318
|
-
function ee(
|
|
338
|
+
function ee(s) {
|
|
319
339
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
320
|
-
return !!(y(
|
|
340
|
+
return !!(y(s, "input") && !e.includes(s.type) || y(s, "select") || y(s, "textarea") || s.getAttribute("contenteditable") === "true");
|
|
321
341
|
}
|
|
322
|
-
function
|
|
323
|
-
return !(
|
|
342
|
+
function $(s) {
|
|
343
|
+
return !(s === null || de(s) || typeof s == "string" && (s = B(s), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
|
|
324
344
|
}
|
|
325
|
-
function me(
|
|
326
|
-
return typeof
|
|
345
|
+
function me(s) {
|
|
346
|
+
return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
|
|
327
347
|
}
|
|
328
348
|
function R() {
|
|
329
349
|
return v(10);
|
|
330
350
|
}
|
|
331
|
-
function J(
|
|
332
|
-
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(
|
|
351
|
+
function J(s) {
|
|
352
|
+
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(s).toLowerCase());
|
|
333
353
|
}
|
|
334
|
-
function ye(
|
|
354
|
+
function ye(s, e) {
|
|
335
355
|
let t;
|
|
336
356
|
return function(...i) {
|
|
337
|
-
const
|
|
338
|
-
clearTimeout(t),
|
|
357
|
+
const n = () => {
|
|
358
|
+
clearTimeout(t), s(...i);
|
|
339
359
|
};
|
|
340
|
-
clearTimeout(t), t = setTimeout(
|
|
360
|
+
clearTimeout(t), t = setTimeout(n, e);
|
|
341
361
|
};
|
|
342
362
|
}
|
|
343
|
-
function we(
|
|
344
|
-
const e = {}, t =
|
|
363
|
+
function we(s) {
|
|
364
|
+
const e = {}, t = s.replace(/^\?/, "").split("&");
|
|
345
365
|
for (let i = 0; i < t.length; i++) {
|
|
346
|
-
const
|
|
347
|
-
|
|
366
|
+
const n = t[i].split("=");
|
|
367
|
+
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
348
368
|
}
|
|
349
369
|
return e;
|
|
350
370
|
}
|
|
351
|
-
function L(
|
|
352
|
-
return typeof
|
|
371
|
+
function L(s) {
|
|
372
|
+
return typeof s == "string" || s instanceof String;
|
|
353
373
|
}
|
|
354
|
-
function P(
|
|
355
|
-
return
|
|
374
|
+
function P(s) {
|
|
375
|
+
return s !== null && typeof s == "object" && s.constructor === Object;
|
|
356
376
|
}
|
|
357
|
-
function ke(
|
|
358
|
-
if (
|
|
377
|
+
function ke(s) {
|
|
378
|
+
if (s === null)
|
|
359
379
|
return k.ERROR;
|
|
360
|
-
const e =
|
|
380
|
+
const e = s.toUpperCase(), t = k[e];
|
|
361
381
|
return t || t === 0 ? t : k.ERROR;
|
|
362
382
|
}
|
|
363
383
|
const ve = () => {
|
|
364
|
-
let
|
|
365
|
-
return typeof window < "u" && window.localStorage && (
|
|
384
|
+
let s = "false";
|
|
385
|
+
return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
|
|
366
386
|
};
|
|
367
|
-
class
|
|
387
|
+
class be {
|
|
368
388
|
constructor(e) {
|
|
369
389
|
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ye(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
370
390
|
}
|
|
@@ -390,8 +410,8 @@ class _e {
|
|
|
390
410
|
this.track();
|
|
391
411
|
}
|
|
392
412
|
getScrollDepth() {
|
|
393
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(),
|
|
394
|
-
return Math.min(100, Math.floor(i /
|
|
413
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
|
|
414
|
+
return Math.min(100, Math.floor(i / n * 100));
|
|
395
415
|
}
|
|
396
416
|
getWindowHeight() {
|
|
397
417
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -410,17 +430,19 @@ class _e {
|
|
|
410
430
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
411
431
|
}
|
|
412
432
|
checkMilestones(e) {
|
|
413
|
-
this.milestones.filter(
|
|
414
|
-
|
|
433
|
+
this.milestones.filter(
|
|
434
|
+
(i) => e >= i
|
|
435
|
+
).forEach((i) => {
|
|
436
|
+
this.send(), this.milestones = this.milestones.filter((n) => n !== i);
|
|
415
437
|
});
|
|
416
438
|
}
|
|
417
439
|
destroy() {
|
|
418
440
|
window.removeEventListener("scroll", this.debouncedHandleScroll);
|
|
419
441
|
}
|
|
420
442
|
}
|
|
421
|
-
const
|
|
422
|
-
constructor(e, t, i =
|
|
423
|
-
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new
|
|
443
|
+
const N = class N {
|
|
444
|
+
constructor(e, t, i = g()) {
|
|
445
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new be(e), le(this), Y(this);
|
|
424
446
|
}
|
|
425
447
|
isBrowserSupported() {
|
|
426
448
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -435,7 +457,9 @@ const I = class I {
|
|
|
435
457
|
return;
|
|
436
458
|
}
|
|
437
459
|
if (!(document && document.body)) {
|
|
438
|
-
this.logger.debug(
|
|
460
|
+
this.logger.debug(
|
|
461
|
+
"Document not ready yet, trying again in 500 milliseconds..."
|
|
462
|
+
), setTimeout(() => this.init(), 500);
|
|
439
463
|
return;
|
|
440
464
|
}
|
|
441
465
|
this.addDomEventHandlers(), this.domHandlersAttached = !0;
|
|
@@ -455,17 +479,17 @@ const I = class I {
|
|
|
455
479
|
return performance.navigation && performance.navigation.type === 1;
|
|
456
480
|
}
|
|
457
481
|
captureEvent(e) {
|
|
458
|
-
var i,
|
|
482
|
+
var i, n;
|
|
459
483
|
let t = this.getEventTarget(e);
|
|
460
484
|
if (j(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
461
485
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
462
486
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
463
|
-
return this.isPageRefresh() || (
|
|
487
|
+
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
464
488
|
if (t && pe(t, e)) {
|
|
465
489
|
const r = [t];
|
|
466
490
|
let o = t;
|
|
467
491
|
for (; o.parentNode && !y(o, "body"); ) {
|
|
468
|
-
if (
|
|
492
|
+
if (Q(o.parentNode)) {
|
|
469
493
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
470
494
|
continue;
|
|
471
495
|
}
|
|
@@ -474,17 +498,17 @@ const I = class I {
|
|
|
474
498
|
const a = [];
|
|
475
499
|
let l, c = !1;
|
|
476
500
|
if (w(r, (p) => {
|
|
477
|
-
const
|
|
478
|
-
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l =
|
|
501
|
+
const b = q(p);
|
|
502
|
+
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = b && $(l) && l);
|
|
479
503
|
const u = x(p).split(" ");
|
|
480
|
-
|
|
504
|
+
A(u, "ph-no-capture") && (c = !0), a.push(
|
|
481
505
|
this.getPropertiesFromElement(
|
|
482
506
|
p,
|
|
483
507
|
this.options.maskAllElementAttributes ?? !1,
|
|
484
508
|
this.options.maskAllText ?? !1
|
|
485
509
|
)
|
|
486
510
|
);
|
|
487
|
-
}), this.options.maskAllText || (a[0].$el_text =
|
|
511
|
+
}), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
|
|
488
512
|
return !1;
|
|
489
513
|
const d = ue(
|
|
490
514
|
this.getDefaultProperties(e.type),
|
|
@@ -499,35 +523,38 @@ const I = class I {
|
|
|
499
523
|
getCustomProperties(e) {
|
|
500
524
|
const t = {};
|
|
501
525
|
return w(this.customProperties, (i) => {
|
|
502
|
-
w(i.event_selectors, (
|
|
503
|
-
const r = document.querySelectorAll(
|
|
526
|
+
w(i.event_selectors, (n) => {
|
|
527
|
+
const r = document.querySelectorAll(n);
|
|
504
528
|
w(r, (o) => {
|
|
505
|
-
|
|
529
|
+
A(e, o) && q(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
506
530
|
});
|
|
507
531
|
});
|
|
508
532
|
}), t;
|
|
509
533
|
}
|
|
510
534
|
extractCustomPropertyValue(e) {
|
|
511
535
|
const t = [];
|
|
512
|
-
return w(
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
536
|
+
return w(
|
|
537
|
+
document.querySelectorAll(e.css_selector),
|
|
538
|
+
function(i) {
|
|
539
|
+
let n;
|
|
540
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), $(n) && t.push(n);
|
|
541
|
+
}
|
|
542
|
+
), t.join(", ");
|
|
516
543
|
}
|
|
517
544
|
getEventTarget(e) {
|
|
518
545
|
var t;
|
|
519
546
|
return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
520
547
|
}
|
|
521
548
|
getPropertiesFromElement(e, t, i) {
|
|
522
|
-
const
|
|
523
|
-
tag_name:
|
|
549
|
+
const n = e.tagName.toLowerCase(), r = {
|
|
550
|
+
tag_name: n
|
|
524
551
|
};
|
|
525
|
-
C.indexOf(
|
|
552
|
+
C.indexOf(n) > -1 && !i && (r.$el_text = V(e));
|
|
526
553
|
const o = x(e);
|
|
527
554
|
o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
|
|
528
555
|
return d !== "";
|
|
529
556
|
})), w(e.attributes, function(d) {
|
|
530
|
-
ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t &&
|
|
557
|
+
ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && $(d.value) && !me(d.name) && (r["attr__" + d.name] = d.value);
|
|
531
558
|
});
|
|
532
559
|
let a = 1, l = 1, c = e;
|
|
533
560
|
for (; c = this.previousElementSibling(c); )
|
|
@@ -557,15 +584,15 @@ const I = class I {
|
|
|
557
584
|
static enabledForProject(e, t = 10, i = 10) {
|
|
558
585
|
if (!e)
|
|
559
586
|
return !1;
|
|
560
|
-
let
|
|
587
|
+
let n = 0;
|
|
561
588
|
for (let r = 0; r < e.length; r++)
|
|
562
|
-
|
|
563
|
-
return
|
|
589
|
+
n += e.charCodeAt(r);
|
|
590
|
+
return n % t < i;
|
|
564
591
|
}
|
|
565
592
|
};
|
|
566
|
-
|
|
567
|
-
let H =
|
|
568
|
-
class
|
|
593
|
+
N.FORCE_CAPTURE_ATTR = "data-um-force-capture", N.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
594
|
+
let H = N;
|
|
595
|
+
class _e {
|
|
569
596
|
constructor(e) {
|
|
570
597
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
571
598
|
}
|
|
@@ -595,43 +622,47 @@ class be {
|
|
|
595
622
|
}
|
|
596
623
|
}
|
|
597
624
|
class Ee {
|
|
598
|
-
constructor(e, t, i =
|
|
625
|
+
constructor(e, t, i = g()) {
|
|
599
626
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
600
627
|
}
|
|
601
628
|
async send(e) {
|
|
602
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
603
|
-
|
|
604
|
-
|
|
629
|
+
const t = this.config.key, i = this.constructUrl(t), n = new Blob([JSON.stringify(e)], {
|
|
630
|
+
type: "application/json"
|
|
631
|
+
});
|
|
632
|
+
if (navigator.sendBeacon(i, n))
|
|
633
|
+
this.logger.debug(
|
|
634
|
+
`Successfully queued ${e.length} event(s) via Beacon API`
|
|
635
|
+
);
|
|
605
636
|
else
|
|
606
637
|
throw new Error("Failed to queue events via Beacon API");
|
|
607
638
|
}
|
|
608
639
|
constructUrl(e) {
|
|
609
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
610
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${
|
|
640
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
641
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
611
642
|
}
|
|
612
643
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
613
644
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
614
645
|
}
|
|
615
646
|
class W {
|
|
616
|
-
constructor(e, t, i =
|
|
647
|
+
constructor(e, t, i = g()) {
|
|
617
648
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
618
649
|
}
|
|
619
650
|
async send(e) {
|
|
620
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
651
|
+
const t = this.config.key, i = this.constructUrl(t), n = JSON.stringify(e), r = {
|
|
621
652
|
"Content-Type": "application/json",
|
|
622
653
|
...this.getCustomHeaders()
|
|
623
654
|
}, o = await fetch(i, {
|
|
624
655
|
method: "POST",
|
|
625
656
|
headers: r,
|
|
626
|
-
body:
|
|
657
|
+
body: n
|
|
627
658
|
});
|
|
628
659
|
if (!o.ok)
|
|
629
660
|
throw new Error(`HTTP error! status: ${o.status}`);
|
|
630
661
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
631
662
|
}
|
|
632
663
|
constructUrl(e) {
|
|
633
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
634
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${
|
|
664
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
665
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
635
666
|
}
|
|
636
667
|
getCustomHeaders() {
|
|
637
668
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -641,26 +672,26 @@ class W {
|
|
|
641
672
|
}
|
|
642
673
|
}
|
|
643
674
|
class Pe {
|
|
644
|
-
constructor(e, t, i =
|
|
675
|
+
constructor(e, t, i = g()) {
|
|
645
676
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
646
677
|
}
|
|
647
678
|
send(e) {
|
|
648
679
|
return new Promise((t, i) => {
|
|
649
|
-
const
|
|
650
|
-
|
|
680
|
+
const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
681
|
+
n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
|
|
651
682
|
const a = this.getCustomHeaders();
|
|
652
683
|
Object.keys(a).forEach((l) => {
|
|
653
|
-
|
|
654
|
-
}),
|
|
655
|
-
|
|
656
|
-
},
|
|
684
|
+
n.setRequestHeader(l, a[l]);
|
|
685
|
+
}), n.onload = () => {
|
|
686
|
+
n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${n.status}`));
|
|
687
|
+
}, n.onerror = () => {
|
|
657
688
|
i(new Error("Network error"));
|
|
658
|
-
},
|
|
689
|
+
}, n.send(JSON.stringify(e));
|
|
659
690
|
});
|
|
660
691
|
}
|
|
661
692
|
constructUrl(e) {
|
|
662
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "",
|
|
663
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${
|
|
693
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
694
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
664
695
|
}
|
|
665
696
|
getCustomHeaders() {
|
|
666
697
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -671,7 +702,7 @@ class Pe {
|
|
|
671
702
|
}
|
|
672
703
|
class te {
|
|
673
704
|
constructor(e, t) {
|
|
674
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.
|
|
705
|
+
this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || g(), this.load();
|
|
675
706
|
}
|
|
676
707
|
set(e, t) {
|
|
677
708
|
this.storage[e] = t, this.save();
|
|
@@ -685,16 +716,8 @@ class te {
|
|
|
685
716
|
clear() {
|
|
686
717
|
this.storage = {}, this.save();
|
|
687
718
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
this.logger.warn("localStorage is not available in this environment");
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
try {
|
|
694
|
-
localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage));
|
|
695
|
-
} catch (e) {
|
|
696
|
-
this.logger.error("Error saving to localStorage:", e);
|
|
697
|
-
}
|
|
719
|
+
isStorageEnabled() {
|
|
720
|
+
return !this.storageDisabled;
|
|
698
721
|
}
|
|
699
722
|
load() {
|
|
700
723
|
if (!h()) {
|
|
@@ -705,11 +728,32 @@ class te {
|
|
|
705
728
|
const e = localStorage.getItem(this.prefix + "data");
|
|
706
729
|
e && (this.storage = JSON.parse(e));
|
|
707
730
|
} catch (e) {
|
|
708
|
-
this.logger.error("Error loading from localStorage:", e);
|
|
731
|
+
this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error loading from localStorage:", e);
|
|
709
732
|
}
|
|
710
733
|
}
|
|
734
|
+
save() {
|
|
735
|
+
if (!h())
|
|
736
|
+
return this.logger.warn("localStorage is not available in this environment"), !1;
|
|
737
|
+
if (this.storageDisabled)
|
|
738
|
+
return !1;
|
|
739
|
+
try {
|
|
740
|
+
return localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage)), !0;
|
|
741
|
+
} catch (e) {
|
|
742
|
+
return this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error saving to localStorage:", e), !1;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
isQuotaError(e) {
|
|
746
|
+
const t = e == null ? void 0 : e.name;
|
|
747
|
+
return t === "QuotaExceededError" || t === "NS_ERROR_DOM_QUOTA_REACHED" || (e == null ? void 0 : e.code) === 22 || (e == null ? void 0 : e.code) === 1014;
|
|
748
|
+
}
|
|
749
|
+
logQuotaOnce(e) {
|
|
750
|
+
this.quotaErrorLogged || (this.quotaErrorLogged = !0, this.logger.error(
|
|
751
|
+
"localStorage quota exceeded; persisting disabled. Continuing with in-memory storage only.",
|
|
752
|
+
e
|
|
753
|
+
));
|
|
754
|
+
}
|
|
711
755
|
}
|
|
712
|
-
class
|
|
756
|
+
class Se {
|
|
713
757
|
constructor() {
|
|
714
758
|
this.storage = {};
|
|
715
759
|
}
|
|
@@ -729,13 +773,18 @@ class Ae {
|
|
|
729
773
|
}
|
|
730
774
|
}
|
|
731
775
|
class K {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
776
|
+
constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = g(), a = "default", l = 1e3, c = 25e5) {
|
|
777
|
+
this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.totalQueueBytes = 0, this.persistence = new te(
|
|
778
|
+
`offline_queue_${a}`
|
|
779
|
+
), this.maxQueueItems = l, this.maxQueueBytes = c, h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
735
780
|
}
|
|
736
781
|
add(e) {
|
|
737
|
-
const t = {
|
|
738
|
-
|
|
782
|
+
const t = {
|
|
783
|
+
payload: e,
|
|
784
|
+
retries: 0,
|
|
785
|
+
timestamp: Date.now()
|
|
786
|
+
};
|
|
787
|
+
t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), h() ? this.saveQueueToStorage() : this.processBatch();
|
|
739
788
|
}
|
|
740
789
|
initNetworkListeners() {
|
|
741
790
|
h() && (window.addEventListener("online", () => {
|
|
@@ -745,14 +794,24 @@ class K {
|
|
|
745
794
|
}));
|
|
746
795
|
}
|
|
747
796
|
scheduleBatch() {
|
|
748
|
-
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
797
|
+
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
798
|
+
() => this.processBatch(),
|
|
799
|
+
this.batchInterval
|
|
800
|
+
));
|
|
749
801
|
}
|
|
750
802
|
async processBatch() {
|
|
751
803
|
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
752
804
|
this.processing = !0;
|
|
753
|
-
const e = this.queue.splice(0, this.batchSize)
|
|
805
|
+
const e = this.queue.splice(0, this.batchSize);
|
|
806
|
+
this.totalQueueBytes = Math.max(
|
|
807
|
+
0,
|
|
808
|
+
this.totalQueueBytes - e.reduce((i, n) => i + (n.bytes || 0), 0)
|
|
809
|
+
);
|
|
810
|
+
const t = e.map((i) => i.payload);
|
|
754
811
|
try {
|
|
755
|
-
await this.transport.send(t), this.logger.debug(
|
|
812
|
+
await this.transport.send(t), this.logger.debug(
|
|
813
|
+
`Successfully sent batch of ${e.length} payloads`
|
|
814
|
+
), h() && this.saveQueueToStorage();
|
|
756
815
|
} catch (i) {
|
|
757
816
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
758
817
|
}
|
|
@@ -762,20 +821,68 @@ class K {
|
|
|
762
821
|
}
|
|
763
822
|
async handleBatchFailure(e) {
|
|
764
823
|
for (const t of e)
|
|
765
|
-
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
824
|
+
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.totalQueueBytes += t.bytes || this.estimateItemBytes(t), this.enforceQueueLimits(), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
825
|
+
"Max retries reached, discarding payload",
|
|
826
|
+
t.payload
|
|
827
|
+
);
|
|
766
828
|
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
767
829
|
}
|
|
830
|
+
enforceQueueLimits() {
|
|
831
|
+
if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
|
|
832
|
+
const e = this.queue.length - this.maxQueueItems, t = this.queue.splice(0, e);
|
|
833
|
+
this.totalQueueBytes = Math.max(
|
|
834
|
+
0,
|
|
835
|
+
this.totalQueueBytes - t.reduce((i, n) => i + (n.bytes || 0), 0)
|
|
836
|
+
), this.logger.warn(
|
|
837
|
+
`Retry queue exceeded ${this.maxQueueItems} items; dropped ${t.length} oldest payload(s)`
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
if (this.maxQueueBytes > 0 && this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 0) {
|
|
841
|
+
let e = 0;
|
|
842
|
+
for (; this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 1; ) {
|
|
843
|
+
const t = this.queue.shift();
|
|
844
|
+
t && (this.totalQueueBytes -= t.bytes || this.estimateItemBytes(t), e++);
|
|
845
|
+
}
|
|
846
|
+
this.totalQueueBytes = Math.max(0, this.totalQueueBytes), e > 0 && this.logger.warn(
|
|
847
|
+
`Retry queue exceeded ${this.maxQueueBytes} bytes; dropped ${e} oldest payload(s)`
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
estimateItemBytes(e) {
|
|
852
|
+
const t = { ...e };
|
|
853
|
+
delete t.bytes;
|
|
854
|
+
try {
|
|
855
|
+
return JSON.stringify(t).length;
|
|
856
|
+
} catch {
|
|
857
|
+
return 0;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
768
860
|
loadQueueFromStorage() {
|
|
769
861
|
if (h()) {
|
|
770
862
|
const e = this.persistence.get("queue");
|
|
771
|
-
|
|
863
|
+
if (!e) return;
|
|
864
|
+
try {
|
|
865
|
+
const t = JSON.parse(e);
|
|
866
|
+
this.queue = t.map((i) => ({
|
|
867
|
+
...i,
|
|
868
|
+
bytes: i.bytes || this.estimateItemBytes(i)
|
|
869
|
+
})), this.totalQueueBytes = this.queue.reduce(
|
|
870
|
+
(i, n) => i + (n.bytes || 0),
|
|
871
|
+
0
|
|
872
|
+
), this.enforceQueueLimits();
|
|
873
|
+
} catch (t) {
|
|
874
|
+
this.logger.error("Failed to parse stored queue", t), this.queue = [], this.totalQueueBytes = 0;
|
|
875
|
+
}
|
|
772
876
|
}
|
|
773
877
|
}
|
|
774
878
|
saveQueueToStorage() {
|
|
775
|
-
|
|
879
|
+
if (h()) {
|
|
880
|
+
const e = this.queue.map(({ bytes: t, ...i }) => i);
|
|
881
|
+
this.persistence.set("queue", JSON.stringify(e));
|
|
882
|
+
}
|
|
776
883
|
}
|
|
777
884
|
}
|
|
778
|
-
class
|
|
885
|
+
class Ae {
|
|
779
886
|
constructor(e) {
|
|
780
887
|
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
|
|
781
888
|
}
|
|
@@ -790,15 +897,19 @@ class Se {
|
|
|
790
897
|
return !e.closest(".um-no-capture");
|
|
791
898
|
}
|
|
792
899
|
click(e, t, i) {
|
|
793
|
-
const
|
|
794
|
-
this.clicks.push(
|
|
900
|
+
const n = { x: e, y: t, timestamp: i };
|
|
901
|
+
this.clicks.push(n), this.clicks = this.clicks.filter(
|
|
902
|
+
(r) => i - r.timestamp < this.timeWindow
|
|
903
|
+
), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
795
904
|
}
|
|
796
905
|
checkRageClick() {
|
|
797
906
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
798
907
|
this.clicks.every((r, o) => {
|
|
799
908
|
if (o === 0) return !0;
|
|
800
909
|
const a = this.clicks[o - 1];
|
|
801
|
-
return Math.sqrt(
|
|
910
|
+
return Math.sqrt(
|
|
911
|
+
Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)
|
|
912
|
+
) < this.distanceThreshold;
|
|
802
913
|
}) && this.sendRageClickEvent(i);
|
|
803
914
|
}
|
|
804
915
|
sendRageClickEvent(e) {
|
|
@@ -810,11 +921,11 @@ class Se {
|
|
|
810
921
|
}
|
|
811
922
|
}
|
|
812
923
|
class Ce {
|
|
813
|
-
constructor(e, t, i =
|
|
924
|
+
constructor(e, t, i = g()) {
|
|
814
925
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
815
926
|
}
|
|
816
927
|
async send(e) {
|
|
817
|
-
const t = this.config.key, i = new (void 0)(this.constructUrl(t)),
|
|
928
|
+
const t = this.config.key, i = new (void 0)(this.constructUrl(t)), n = {
|
|
818
929
|
hostname: i.hostname,
|
|
819
930
|
port: 443,
|
|
820
931
|
path: `${i.pathname}${i.search}`,
|
|
@@ -825,7 +936,7 @@ class Ce {
|
|
|
825
936
|
}
|
|
826
937
|
};
|
|
827
938
|
return new Promise((r, o) => {
|
|
828
|
-
const a = (void 0)(
|
|
939
|
+
const a = (void 0)(n, (l) => {
|
|
829
940
|
l.on("data", (c) => {
|
|
830
941
|
}), l.on("end", () => {
|
|
831
942
|
const c = l.statusCode || 0;
|
|
@@ -845,7 +956,7 @@ class Ce {
|
|
|
845
956
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
846
957
|
}
|
|
847
958
|
}
|
|
848
|
-
class
|
|
959
|
+
class S {
|
|
849
960
|
constructor(e, t = "all", i = {}) {
|
|
850
961
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
851
962
|
}
|
|
@@ -860,22 +971,27 @@ class A {
|
|
|
860
971
|
}
|
|
861
972
|
handleFormSubmit(e) {
|
|
862
973
|
const t = e.target, i = this._getFormDetails(t);
|
|
863
|
-
this.instance.track("$form",
|
|
974
|
+
this.instance.track("$form", M(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
864
975
|
}
|
|
865
976
|
trackFieldChanges(e) {
|
|
866
977
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
867
|
-
i.addEventListener("change", (
|
|
868
|
-
const r = this._getFieldProps(
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
978
|
+
i.addEventListener("change", (n) => {
|
|
979
|
+
const r = this._getFieldProps(
|
|
980
|
+
n.target
|
|
981
|
+
);
|
|
982
|
+
this.instance.track(
|
|
983
|
+
"$form_field_change",
|
|
984
|
+
M({
|
|
985
|
+
form_id: e.id,
|
|
986
|
+
form_name: e.name || "",
|
|
987
|
+
field: r
|
|
988
|
+
})
|
|
989
|
+
);
|
|
874
990
|
});
|
|
875
991
|
});
|
|
876
992
|
}
|
|
877
993
|
static getInstance(e, t = "all", i = {}) {
|
|
878
|
-
return
|
|
994
|
+
return S.instance || (S.instance = new S(e, t, i)), S.instance;
|
|
879
995
|
}
|
|
880
996
|
_getFormDetails(e) {
|
|
881
997
|
const t = {
|
|
@@ -886,11 +1002,17 @@ class A {
|
|
|
886
1002
|
form_class: e.className,
|
|
887
1003
|
form_attributes: this._getElementAttributes(e),
|
|
888
1004
|
fields: []
|
|
889
|
-
}, i = e.querySelectorAll(
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1005
|
+
}, i = e.querySelectorAll(
|
|
1006
|
+
"input, select, textarea"
|
|
1007
|
+
);
|
|
1008
|
+
return Array.from(i).filter(
|
|
1009
|
+
(r) => !r.classList.contains("um-no-capture")
|
|
1010
|
+
).forEach(
|
|
1011
|
+
(r) => {
|
|
1012
|
+
const o = this._getFieldProps(r);
|
|
1013
|
+
t.fields.push(o);
|
|
1014
|
+
}
|
|
1015
|
+
), t;
|
|
894
1016
|
}
|
|
895
1017
|
_getFieldProps(e) {
|
|
896
1018
|
const t = Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : void 0, i = this.getSafeText(e);
|
|
@@ -917,8 +1039,8 @@ class A {
|
|
|
917
1039
|
getSafeText(e) {
|
|
918
1040
|
let t = "";
|
|
919
1041
|
return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
|
|
920
|
-
(
|
|
921
|
-
).map((
|
|
1042
|
+
(n) => n.nodeType === Node.TEXT_NODE
|
|
1043
|
+
).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
|
|
922
1044
|
}
|
|
923
1045
|
_scrubPotentiallySensitiveValues(e) {
|
|
924
1046
|
return this._shouldCaptureValue(e) ? e : "<redacted>";
|
|
@@ -936,7 +1058,7 @@ class A {
|
|
|
936
1058
|
if (typeof String.prototype.trim == "function")
|
|
937
1059
|
return e.trim();
|
|
938
1060
|
let t = 0, i = e.length - 1;
|
|
939
|
-
const
|
|
1061
|
+
const n = [
|
|
940
1062
|
" ",
|
|
941
1063
|
`
|
|
942
1064
|
`,
|
|
@@ -963,16 +1085,16 @@ class A {
|
|
|
963
1085
|
" ",
|
|
964
1086
|
" "
|
|
965
1087
|
].join("");
|
|
966
|
-
for (; t <= i &&
|
|
1088
|
+
for (; t <= i && n.indexOf(e[t]) > -1; )
|
|
967
1089
|
t++;
|
|
968
|
-
for (; i >= t &&
|
|
1090
|
+
for (; i >= t && n.indexOf(e[i]) > -1; )
|
|
969
1091
|
i--;
|
|
970
1092
|
return e.slice(t, i + 1);
|
|
971
1093
|
}
|
|
972
1094
|
}
|
|
973
|
-
class
|
|
1095
|
+
class I {
|
|
974
1096
|
constructor(e) {
|
|
975
|
-
this.config = this.mergeConfig(e, Z), this.logger =
|
|
1097
|
+
this.config = this.mergeConfig(e, Z), this.logger = g(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new K(
|
|
976
1098
|
this.transport,
|
|
977
1099
|
this.config.maxSendAttempts || 3,
|
|
978
1100
|
this.config.minSendTimeout || 1e3,
|
|
@@ -981,16 +1103,22 @@ class N {
|
|
|
981
1103
|
// Reduced interval to .2 second
|
|
982
1104
|
this.logger,
|
|
983
1105
|
this.namespace
|
|
984
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1106
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1107
|
+
`Usermaven client initialized for namespace: ${this.namespace}`
|
|
1108
|
+
);
|
|
985
1109
|
}
|
|
986
1110
|
initializeBrowserFeatures() {
|
|
987
|
-
if (this.cookieManager = new
|
|
1111
|
+
if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && H.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new H(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
988
1112
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
989
|
-
this.formTracking =
|
|
990
|
-
|
|
991
|
-
|
|
1113
|
+
this.formTracking = S.getInstance(
|
|
1114
|
+
this,
|
|
1115
|
+
e || "none",
|
|
1116
|
+
{
|
|
1117
|
+
trackFieldChanges: !1
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
992
1120
|
}
|
|
993
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
1121
|
+
this.config.autoPageview && (this.pageviewTracking = new _e(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ae(this)), this.setupPageLeaveTracking();
|
|
994
1122
|
}
|
|
995
1123
|
/**
|
|
996
1124
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -999,13 +1127,13 @@ class N {
|
|
|
999
1127
|
*/
|
|
1000
1128
|
mergeConfig(e, t) {
|
|
1001
1129
|
const i = JSON.parse(JSON.stringify(e));
|
|
1002
|
-
let
|
|
1130
|
+
let n = { ...t, ...i };
|
|
1003
1131
|
return Object.keys(t).forEach((r) => {
|
|
1004
|
-
P(t[r]) && (
|
|
1005
|
-
}),
|
|
1132
|
+
P(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
|
|
1133
|
+
}), n;
|
|
1006
1134
|
}
|
|
1007
1135
|
init(e) {
|
|
1008
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
1136
|
+
this.config = { ...this.config, ...e }, this.logger = g(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new K(
|
|
1009
1137
|
this.transport,
|
|
1010
1138
|
this.config.maxSendAttempts || 3,
|
|
1011
1139
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1014,7 +1142,9 @@ class N {
|
|
|
1014
1142
|
// Reduced interval to .25 second
|
|
1015
1143
|
this.logger,
|
|
1016
1144
|
this.namespace
|
|
1017
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1145
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1146
|
+
`Usermaven client reinitialized for namespace: ${this.namespace}`
|
|
1147
|
+
);
|
|
1018
1148
|
}
|
|
1019
1149
|
manageCrossDomainLinking() {
|
|
1020
1150
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
@@ -1022,14 +1152,14 @@ class N {
|
|
|
1022
1152
|
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1023
1153
|
document.addEventListener("click", (i) => {
|
|
1024
1154
|
var a;
|
|
1025
|
-
const
|
|
1026
|
-
if (!
|
|
1027
|
-
const r =
|
|
1155
|
+
const n = this.findClosestLink(i.target);
|
|
1156
|
+
if (!n) return;
|
|
1157
|
+
const r = n.getAttribute("href");
|
|
1028
1158
|
if (!r || !r.startsWith("http")) return;
|
|
1029
1159
|
const o = new URL(r);
|
|
1030
1160
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1031
1161
|
const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
|
|
1032
|
-
l && (o.searchParams.append("_um", l),
|
|
1162
|
+
l && (o.searchParams.append("_um", l), n.setAttribute("href", o.toString()));
|
|
1033
1163
|
}
|
|
1034
1164
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
1035
1165
|
}
|
|
@@ -1042,22 +1172,41 @@ class N {
|
|
|
1042
1172
|
const t = "https://events.usermaven.com";
|
|
1043
1173
|
if (!h())
|
|
1044
1174
|
return new Ce(e.trackingHost || t, e);
|
|
1045
|
-
const i = "XMLHttpRequest" in window,
|
|
1175
|
+
const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1046
1176
|
if (e.useBeaconApi && r)
|
|
1047
|
-
return new Ee(
|
|
1048
|
-
|
|
1049
|
-
|
|
1177
|
+
return new Ee(
|
|
1178
|
+
e.trackingHost || t,
|
|
1179
|
+
e,
|
|
1180
|
+
this.logger
|
|
1181
|
+
);
|
|
1182
|
+
if (e.forceUseFetch && n)
|
|
1183
|
+
return new W(
|
|
1184
|
+
e.trackingHost || t,
|
|
1185
|
+
e,
|
|
1186
|
+
this.logger
|
|
1187
|
+
);
|
|
1050
1188
|
if (i)
|
|
1051
|
-
return new Pe(
|
|
1052
|
-
|
|
1053
|
-
|
|
1189
|
+
return new Pe(
|
|
1190
|
+
e.trackingHost || t,
|
|
1191
|
+
e,
|
|
1192
|
+
this.logger
|
|
1193
|
+
);
|
|
1194
|
+
if (n)
|
|
1195
|
+
return new W(
|
|
1196
|
+
e.trackingHost || t,
|
|
1197
|
+
e,
|
|
1198
|
+
this.logger
|
|
1199
|
+
);
|
|
1054
1200
|
throw new Error("No suitable transport method available");
|
|
1055
1201
|
}
|
|
1056
1202
|
initializePersistence() {
|
|
1057
|
-
return this.config.disableEventPersistence || !h() ? new
|
|
1203
|
+
return this.config.disableEventPersistence || !h() ? new Se() : new te(
|
|
1204
|
+
`${this.namespace}_${this.config.key}`,
|
|
1205
|
+
this.logger
|
|
1206
|
+
);
|
|
1058
1207
|
}
|
|
1059
1208
|
getOrCreateAnonymousId() {
|
|
1060
|
-
var i,
|
|
1209
|
+
var i, n;
|
|
1061
1210
|
if (!h())
|
|
1062
1211
|
return R();
|
|
1063
1212
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
@@ -1071,7 +1220,13 @@ class N {
|
|
|
1071
1220
|
}
|
|
1072
1221
|
t || (t = R());
|
|
1073
1222
|
const r = 365 * 10;
|
|
1074
|
-
(
|
|
1223
|
+
(n = this.cookieManager) == null || n.set(
|
|
1224
|
+
e,
|
|
1225
|
+
t,
|
|
1226
|
+
r,
|
|
1227
|
+
document.location.protocol !== "http:",
|
|
1228
|
+
!1
|
|
1229
|
+
);
|
|
1075
1230
|
}
|
|
1076
1231
|
return t;
|
|
1077
1232
|
}
|
|
@@ -1084,11 +1239,11 @@ class N {
|
|
|
1084
1239
|
throw new Error("User ID must be a string");
|
|
1085
1240
|
const i = e.id;
|
|
1086
1241
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
1087
|
-
const
|
|
1242
|
+
const n = {
|
|
1088
1243
|
...e,
|
|
1089
1244
|
anonymous_id: this.anonymousId
|
|
1090
1245
|
};
|
|
1091
|
-
await this.track("user_identify",
|
|
1246
|
+
await this.track("user_identify", n);
|
|
1092
1247
|
}
|
|
1093
1248
|
this.logger.info("User identified:", e);
|
|
1094
1249
|
}
|
|
@@ -1097,18 +1252,20 @@ class N {
|
|
|
1097
1252
|
}
|
|
1098
1253
|
lead(e, t = !1) {
|
|
1099
1254
|
if (!P(e))
|
|
1100
|
-
throw new Error(
|
|
1255
|
+
throw new Error(
|
|
1256
|
+
"Lead payload must be a non-null object and not an array"
|
|
1257
|
+
);
|
|
1101
1258
|
const i = e.email;
|
|
1102
1259
|
if (!L(i)) {
|
|
1103
1260
|
this.logger.error("Lead event requires a valid email attribute");
|
|
1104
1261
|
return;
|
|
1105
1262
|
}
|
|
1106
|
-
const
|
|
1107
|
-
if (!
|
|
1263
|
+
const n = i.trim();
|
|
1264
|
+
if (!n || !J(n)) {
|
|
1108
1265
|
this.logger.error("Lead event requires a valid email attribute");
|
|
1109
1266
|
return;
|
|
1110
1267
|
}
|
|
1111
|
-
e.email =
|
|
1268
|
+
e.email = n, this.track("lead", e, t);
|
|
1112
1269
|
}
|
|
1113
1270
|
trackInternal(e, t, i = !1) {
|
|
1114
1271
|
if (ve()) {
|
|
@@ -1118,7 +1275,9 @@ class N {
|
|
|
1118
1275
|
if (!L(e))
|
|
1119
1276
|
throw new Error("Event name must be a string");
|
|
1120
1277
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1121
|
-
throw new Error(
|
|
1278
|
+
throw new Error(
|
|
1279
|
+
"Event payload must be a non-null object and not an array"
|
|
1280
|
+
);
|
|
1122
1281
|
const r = this.createEventPayload(e, t);
|
|
1123
1282
|
try {
|
|
1124
1283
|
if (i) {
|
|
@@ -1139,11 +1298,13 @@ class N {
|
|
|
1139
1298
|
if (!P(e))
|
|
1140
1299
|
throw new Error("Company properties must be an object");
|
|
1141
1300
|
if (!e.id || !e.name || !e.created_at)
|
|
1142
|
-
throw new Error(
|
|
1301
|
+
throw new Error(
|
|
1302
|
+
"Company properties must include id, name, and created_at"
|
|
1303
|
+
);
|
|
1143
1304
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1144
1305
|
}
|
|
1145
1306
|
createEventPayload(e, t) {
|
|
1146
|
-
const i = this.persistence.get("userProps") || {},
|
|
1307
|
+
const i = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, a = this.persistence.get(`props_${e}`) || {};
|
|
1147
1308
|
let l = t || {};
|
|
1148
1309
|
const c = {
|
|
1149
1310
|
event_id: "",
|
|
@@ -1152,7 +1313,7 @@ class N {
|
|
|
1152
1313
|
id: r,
|
|
1153
1314
|
...i
|
|
1154
1315
|
},
|
|
1155
|
-
...
|
|
1316
|
+
...n && { company: n },
|
|
1156
1317
|
ids: this.getThirdPartyIds(),
|
|
1157
1318
|
utc_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1158
1319
|
local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
@@ -1164,7 +1325,9 @@ class N {
|
|
|
1164
1325
|
...a
|
|
1165
1326
|
};
|
|
1166
1327
|
if (e === "$autocapture") {
|
|
1167
|
-
const d = this.processAutocaptureAttributes(
|
|
1328
|
+
const d = this.processAutocaptureAttributes(
|
|
1329
|
+
t || {}
|
|
1330
|
+
);
|
|
1168
1331
|
c.autocapture_attributes = d;
|
|
1169
1332
|
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
|
|
1170
1333
|
delete l[d];
|
|
@@ -1174,8 +1337,16 @@ class N {
|
|
|
1174
1337
|
processAutocaptureAttributes(e) {
|
|
1175
1338
|
let t = {};
|
|
1176
1339
|
const i = e.$elements || [];
|
|
1177
|
-
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1178
|
-
|
|
1340
|
+
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1341
|
+
"$ce_version",
|
|
1342
|
+
"$event_type",
|
|
1343
|
+
"$initial_referrer",
|
|
1344
|
+
"$initial_referring_domain",
|
|
1345
|
+
"$referrer",
|
|
1346
|
+
"$referring_domain",
|
|
1347
|
+
"$elements"
|
|
1348
|
+
].forEach((n) => {
|
|
1349
|
+
delete t[n];
|
|
1179
1350
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1180
1351
|
}
|
|
1181
1352
|
getCookie(e) {
|
|
@@ -1192,16 +1363,28 @@ class N {
|
|
|
1192
1363
|
}
|
|
1193
1364
|
getUtmParams() {
|
|
1194
1365
|
const e = {}, t = we(window.location.search);
|
|
1195
|
-
return [
|
|
1196
|
-
|
|
1366
|
+
return [
|
|
1367
|
+
"utm_source",
|
|
1368
|
+
"utm_medium",
|
|
1369
|
+
"utm_campaign",
|
|
1370
|
+
"utm_term",
|
|
1371
|
+
"utm_content"
|
|
1372
|
+
].forEach((n) => {
|
|
1373
|
+
t[n] && (e[n.replace("utm_", "")] = t[n]);
|
|
1197
1374
|
}), e;
|
|
1198
1375
|
}
|
|
1199
1376
|
pageview() {
|
|
1200
|
-
h() ? this.track(
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1377
|
+
h() ? this.track(
|
|
1378
|
+
"pageview",
|
|
1379
|
+
{
|
|
1380
|
+
url: window.location.href,
|
|
1381
|
+
referrer: document.referrer,
|
|
1382
|
+
title: document.title
|
|
1383
|
+
},
|
|
1384
|
+
!0
|
|
1385
|
+
) : this.logger.warn(
|
|
1386
|
+
"Pageview tracking is not available in server-side environments"
|
|
1387
|
+
);
|
|
1205
1388
|
}
|
|
1206
1389
|
setupPageLeaveTracking() {
|
|
1207
1390
|
if (!h()) return;
|
|
@@ -1220,9 +1403,9 @@ class N {
|
|
|
1220
1403
|
}), document.addEventListener("visibilitychange", () => {
|
|
1221
1404
|
document.visibilityState === "hidden" && !t && i();
|
|
1222
1405
|
});
|
|
1223
|
-
const
|
|
1406
|
+
const n = history.pushState;
|
|
1224
1407
|
history.pushState = function() {
|
|
1225
|
-
return i(),
|
|
1408
|
+
return i(), n.apply(this, arguments);
|
|
1226
1409
|
}, window.addEventListener("popstate", i);
|
|
1227
1410
|
}
|
|
1228
1411
|
getConfig() {
|
|
@@ -1236,12 +1419,15 @@ class N {
|
|
|
1236
1419
|
const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1237
1420
|
this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
|
|
1238
1421
|
}
|
|
1239
|
-
this.logger.info("core state reset", {
|
|
1422
|
+
this.logger.info("core state reset", {
|
|
1423
|
+
resetAnonId: e,
|
|
1424
|
+
namespace: this.namespace
|
|
1425
|
+
});
|
|
1240
1426
|
}
|
|
1241
1427
|
set(e, t) {
|
|
1242
1428
|
if (!P(e))
|
|
1243
1429
|
throw new Error("Properties must be an object");
|
|
1244
|
-
const i = t == null ? void 0 : t.eventType,
|
|
1430
|
+
const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1245
1431
|
if (i) {
|
|
1246
1432
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1247
1433
|
r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
|
|
@@ -1249,10 +1435,10 @@ class N {
|
|
|
1249
1435
|
let r = this.persistence.get("global_props") || {};
|
|
1250
1436
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1251
1437
|
}
|
|
1252
|
-
|
|
1438
|
+
n && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1253
1439
|
properties: e,
|
|
1254
1440
|
eventType: i || "global",
|
|
1255
|
-
persist:
|
|
1441
|
+
persist: n
|
|
1256
1442
|
});
|
|
1257
1443
|
}
|
|
1258
1444
|
setUserId(e) {
|
|
@@ -1261,7 +1447,7 @@ class N {
|
|
|
1261
1447
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1262
1448
|
}
|
|
1263
1449
|
unset(e, t) {
|
|
1264
|
-
const i = t == null ? void 0 : t.eventType,
|
|
1450
|
+
const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1265
1451
|
if (i) {
|
|
1266
1452
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1267
1453
|
delete r[e], this.persistence.set(`props_${i}`, r);
|
|
@@ -1269,75 +1455,86 @@ class N {
|
|
|
1269
1455
|
let r = this.persistence.get("global_props") || {};
|
|
1270
1456
|
delete r[e], this.persistence.set("global_props", r);
|
|
1271
1457
|
}
|
|
1272
|
-
|
|
1458
|
+
n && this.persistence.save(), this.logger.debug(
|
|
1459
|
+
`Property unset: ${e}`,
|
|
1460
|
+
`Event type: ${i || "global"}`
|
|
1461
|
+
);
|
|
1273
1462
|
}
|
|
1274
1463
|
}
|
|
1275
1464
|
function ie() {
|
|
1276
1465
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1277
1466
|
}
|
|
1278
|
-
function
|
|
1467
|
+
function $e() {
|
|
1279
1468
|
return ie() ? window.define : void 0;
|
|
1280
1469
|
}
|
|
1281
|
-
const
|
|
1282
|
-
function O(
|
|
1283
|
-
const e = JSON.parse(JSON.stringify(
|
|
1470
|
+
const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1471
|
+
function O(s) {
|
|
1472
|
+
const e = JSON.parse(JSON.stringify(s)), t = F(e), i = {
|
|
1473
|
+
...Z,
|
|
1474
|
+
...t
|
|
1475
|
+
};
|
|
1284
1476
|
if (!i.key)
|
|
1285
1477
|
throw new Error("API key is required!");
|
|
1286
1478
|
if (!i.trackingHost)
|
|
1287
1479
|
throw new Error("Tracking host is required!");
|
|
1288
|
-
const
|
|
1289
|
-
return h() && i.autocapture && window[r] && (console.warn(
|
|
1480
|
+
const n = i.key || "", r = `${Te}${n}`;
|
|
1481
|
+
return h() && i.autocapture && window[r] && (console.warn(
|
|
1482
|
+
"Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
|
|
1483
|
+
), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new I(i);
|
|
1290
1484
|
}
|
|
1291
|
-
function xe(
|
|
1292
|
-
var
|
|
1485
|
+
function xe(s) {
|
|
1486
|
+
var n;
|
|
1293
1487
|
const e = {
|
|
1294
|
-
key:
|
|
1295
|
-
trackingHost:
|
|
1296
|
-
logLevel: ke(
|
|
1297
|
-
autocapture:
|
|
1298
|
-
formTracking:
|
|
1299
|
-
autoPageview:
|
|
1300
|
-
useBeaconApi:
|
|
1301
|
-
forceUseFetch:
|
|
1302
|
-
gaHook:
|
|
1303
|
-
segmentHook:
|
|
1304
|
-
randomizeUrl:
|
|
1305
|
-
capture3rdPartyCookies:
|
|
1306
|
-
idMethod:
|
|
1307
|
-
privacyPolicy:
|
|
1308
|
-
ipPolicy:
|
|
1309
|
-
cookiePolicy:
|
|
1310
|
-
minSendTimeout: parseInt(
|
|
1311
|
-
maxSendTimeout: parseInt(
|
|
1312
|
-
maxSendAttempts: parseInt(
|
|
1313
|
-
propertiesStringMaxLength: parseInt(
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1488
|
+
key: s.getAttribute("data-key") || void 0,
|
|
1489
|
+
trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1490
|
+
logLevel: ke(s.getAttribute("data-log-level")),
|
|
1491
|
+
autocapture: s.getAttribute("data-autocapture") === "true",
|
|
1492
|
+
formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
|
|
1493
|
+
autoPageview: s.getAttribute("data-auto-pageview") === "true",
|
|
1494
|
+
useBeaconApi: s.getAttribute("data-use-beacon-api") === "true",
|
|
1495
|
+
forceUseFetch: s.getAttribute("data-force-use-fetch") === "true",
|
|
1496
|
+
gaHook: s.getAttribute("data-ga-hook") === "true",
|
|
1497
|
+
segmentHook: s.getAttribute("data-segment-hook") === "true",
|
|
1498
|
+
randomizeUrl: s.getAttribute("data-randomize-url") === "true",
|
|
1499
|
+
capture3rdPartyCookies: s.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
|
|
1500
|
+
idMethod: s.getAttribute("data-id-method") || void 0,
|
|
1501
|
+
privacyPolicy: s.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
|
|
1502
|
+
ipPolicy: s.getAttribute("data-ip-policy") || void 0,
|
|
1503
|
+
cookiePolicy: s.getAttribute("data-cookie-policy") || void 0,
|
|
1504
|
+
minSendTimeout: parseInt(s.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1505
|
+
maxSendTimeout: parseInt(s.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1506
|
+
maxSendAttempts: parseInt(s.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1507
|
+
propertiesStringMaxLength: parseInt(
|
|
1508
|
+
s.getAttribute("data-properties-string-max-length") || "",
|
|
1509
|
+
10
|
|
1510
|
+
) || null,
|
|
1511
|
+
propertyBlacklist: ((n = s.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
|
|
1512
|
+
exclude: s.getAttribute("data-exclude") || void 0,
|
|
1513
|
+
namespace: s.getAttribute("data-namespace") || void 0,
|
|
1514
|
+
crossDomainLinking: s.getAttribute("data-cross-domain-linking") !== "false",
|
|
1515
|
+
domains: s.getAttribute("data-domains") || void 0,
|
|
1516
|
+
maskAllText: s.getAttribute("data-mask-all-text") === "true",
|
|
1517
|
+
maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1321
1518
|
};
|
|
1322
1519
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1323
1520
|
const t = O(e), i = e.namespace || "usermaven";
|
|
1324
1521
|
return h() && t.pageview(), He(i, t), t;
|
|
1325
1522
|
}
|
|
1326
|
-
function He(
|
|
1523
|
+
function He(s, e) {
|
|
1327
1524
|
let t = !1;
|
|
1328
|
-
const i = [],
|
|
1525
|
+
const i = [], n = [];
|
|
1329
1526
|
function r() {
|
|
1330
1527
|
for (; i.length > 0; ) {
|
|
1331
1528
|
const u = i.shift();
|
|
1332
1529
|
if (u) {
|
|
1333
|
-
const
|
|
1334
|
-
if (
|
|
1530
|
+
const f = u[u.length - 1];
|
|
1531
|
+
if (f && typeof f.resolve == "function") {
|
|
1335
1532
|
const m = u.pop();
|
|
1336
1533
|
try {
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
} catch (
|
|
1340
|
-
m.reject(
|
|
1534
|
+
const _ = a.apply(null, u);
|
|
1535
|
+
_ && typeof _.then == "function" ? _.then(m.resolve).catch(m.reject) : m.resolve(_);
|
|
1536
|
+
} catch (_) {
|
|
1537
|
+
m.reject(_);
|
|
1341
1538
|
}
|
|
1342
1539
|
} else
|
|
1343
1540
|
try {
|
|
@@ -1349,74 +1546,82 @@ function He(n, e) {
|
|
|
1349
1546
|
}
|
|
1350
1547
|
}
|
|
1351
1548
|
function o() {
|
|
1352
|
-
|
|
1549
|
+
n.forEach((u) => u()), n.length = 0;
|
|
1353
1550
|
}
|
|
1354
1551
|
function a(...u) {
|
|
1355
|
-
const
|
|
1356
|
-
if (
|
|
1357
|
-
typeof u[1] == "function" && (t ? u[1]() :
|
|
1552
|
+
const f = u[0];
|
|
1553
|
+
if (f === "onLoad") {
|
|
1554
|
+
typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
|
|
1358
1555
|
return;
|
|
1359
1556
|
}
|
|
1360
1557
|
if (!t) {
|
|
1361
1558
|
i.push(u);
|
|
1362
1559
|
return;
|
|
1363
1560
|
}
|
|
1364
|
-
if (typeof e[
|
|
1365
|
-
return e[
|
|
1366
|
-
console.error(`Method ${
|
|
1367
|
-
}
|
|
1368
|
-
const l = ["id", "group", "reset"], c = [
|
|
1561
|
+
if (typeof e[f] == "function")
|
|
1562
|
+
return e[f].apply(e, u.slice(1));
|
|
1563
|
+
console.error(`Method ${f} not found on UsermavenClient`);
|
|
1564
|
+
}
|
|
1565
|
+
const l = ["id", "group", "reset"], c = [
|
|
1566
|
+
"track",
|
|
1567
|
+
"lead",
|
|
1568
|
+
"pageview",
|
|
1569
|
+
"set",
|
|
1570
|
+
"unset",
|
|
1571
|
+
"rawTrack",
|
|
1572
|
+
"setUserId"
|
|
1573
|
+
];
|
|
1369
1574
|
[...l, ...c].forEach((u) => {
|
|
1370
|
-
a[u] = function(...
|
|
1575
|
+
a[u] = function(...f) {
|
|
1371
1576
|
if (!t) {
|
|
1372
1577
|
if (l.includes(u))
|
|
1373
|
-
return new Promise((
|
|
1374
|
-
i.push([u, ...
|
|
1578
|
+
return new Promise((z, m) => {
|
|
1579
|
+
i.push([u, ...f, { resolve: z, reject: m }]);
|
|
1375
1580
|
});
|
|
1376
|
-
i.push([u, ...
|
|
1581
|
+
i.push([u, ...f]);
|
|
1377
1582
|
return;
|
|
1378
1583
|
}
|
|
1379
1584
|
if (typeof e[u] == "function")
|
|
1380
|
-
return e[u].apply(e,
|
|
1585
|
+
return e[u].apply(e, f);
|
|
1381
1586
|
};
|
|
1382
1587
|
}), a.getConfig = function() {
|
|
1383
1588
|
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1384
|
-
}, window[
|
|
1385
|
-
const p = `${
|
|
1386
|
-
for (window[p] =
|
|
1589
|
+
}, window[s] = a;
|
|
1590
|
+
const p = `${s}Q`, b = window[p] || [];
|
|
1591
|
+
for (window[p] = b, b.push = function(...u) {
|
|
1387
1592
|
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1388
1593
|
}, setTimeout(() => {
|
|
1389
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1390
|
-
}, 0);
|
|
1391
|
-
const u =
|
|
1594
|
+
t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
|
|
1595
|
+
}, 0); b.length > 0; ) {
|
|
1596
|
+
const u = b.shift();
|
|
1392
1597
|
u && i.push(u);
|
|
1393
1598
|
}
|
|
1394
1599
|
}
|
|
1395
|
-
let X = !1,
|
|
1600
|
+
let X = !1, D = null;
|
|
1396
1601
|
if (h()) {
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1602
|
+
const s = $e();
|
|
1603
|
+
s && s("usermaven", [], function() {
|
|
1399
1604
|
return {
|
|
1400
1605
|
usermavenClient: O,
|
|
1401
|
-
UsermavenClient:
|
|
1606
|
+
UsermavenClient: I,
|
|
1402
1607
|
LogLevel: k,
|
|
1403
1608
|
// Expose the script tag client if it exists
|
|
1404
|
-
getScriptTagClient: () =>
|
|
1609
|
+
getScriptTagClient: () => D
|
|
1405
1610
|
};
|
|
1406
|
-
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient =
|
|
1611
|
+
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = I, window.usermavenScriptTagClient = () => D), function(e, t) {
|
|
1407
1612
|
const i = e.currentScript;
|
|
1408
|
-
function
|
|
1613
|
+
function n() {
|
|
1409
1614
|
return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1410
1615
|
}
|
|
1411
1616
|
function r() {
|
|
1412
|
-
|
|
1617
|
+
n() && (console.log("[Usermaven] Auto-initializing from script tag"), D = xe(i), X = !0);
|
|
1413
1618
|
}
|
|
1414
1619
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1415
1620
|
}(document, window);
|
|
1416
1621
|
}
|
|
1417
1622
|
typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
1418
1623
|
usermavenClient: O,
|
|
1419
|
-
UsermavenClient:
|
|
1624
|
+
UsermavenClient: I,
|
|
1420
1625
|
Config: void 0,
|
|
1421
1626
|
UserProps: void 0,
|
|
1422
1627
|
EventPayload: void 0,
|
|
@@ -1732,9 +1937,9 @@ function hasSetMethod(cookies) {
|
|
|
1732
1937
|
}
|
|
1733
1938
|
function middlewareEnv(req, res, opts = {}) {
|
|
1734
1939
|
return {
|
|
1735
|
-
getAnonymousId({ name, domain }) {
|
|
1940
|
+
getAnonymousId({ name, domain, }) {
|
|
1736
1941
|
if (opts === null || opts === void 0 ? void 0 : opts.disableCookies) {
|
|
1737
|
-
return
|
|
1942
|
+
return '';
|
|
1738
1943
|
}
|
|
1739
1944
|
let cookie;
|
|
1740
1945
|
if (hasGetMethod(req.cookies)) {
|
|
@@ -1750,7 +1955,7 @@ function middlewareEnv(req, res, opts = {}) {
|
|
|
1750
1955
|
const cookieOpts = {
|
|
1751
1956
|
maxAge: 31622400 * 10,
|
|
1752
1957
|
httpOnly: false,
|
|
1753
|
-
path:
|
|
1958
|
+
path: '/',
|
|
1754
1959
|
};
|
|
1755
1960
|
if (domain) {
|
|
1756
1961
|
cookieOpts.domain = domain;
|
|
@@ -1762,36 +1967,42 @@ function middlewareEnv(req, res, opts = {}) {
|
|
|
1762
1967
|
value: newId,
|
|
1763
1968
|
maxAge: cookieOpts.maxAge,
|
|
1764
1969
|
domain: cookieOpts.domain,
|
|
1765
|
-
httpOnly: cookieOpts.httpOnly
|
|
1970
|
+
httpOnly: cookieOpts.httpOnly,
|
|
1766
1971
|
});
|
|
1767
1972
|
}
|
|
1768
1973
|
else {
|
|
1769
|
-
res.headers.set(
|
|
1974
|
+
res.headers.set('Set-Cookie', serialize_1(name, newId, cookieOpts));
|
|
1770
1975
|
}
|
|
1771
1976
|
return newId;
|
|
1772
1977
|
},
|
|
1773
1978
|
getSourceIp() {
|
|
1774
|
-
let ip = req.headers.get(
|
|
1775
|
-
|
|
1979
|
+
let ip = req.headers.get('x-forwarded-for') ||
|
|
1980
|
+
req.headers.get('x-real-ip') ||
|
|
1981
|
+
'';
|
|
1982
|
+
return ip && ip.split(',')[0].trim();
|
|
1776
1983
|
},
|
|
1777
1984
|
describeClient() {
|
|
1778
1985
|
var _a;
|
|
1779
|
-
const requestHost = req.headers.get(
|
|
1780
|
-
|
|
1986
|
+
const requestHost = req.headers.get('x-forwarded-host') ||
|
|
1987
|
+
req.headers.get('host') ||
|
|
1988
|
+
req.nextUrl.hostname;
|
|
1989
|
+
const proto = req.headers.get('x-forwarded-proto') ||
|
|
1990
|
+
((_a = req.nextUrl.protocol) === null || _a === void 0 ? void 0 : _a.replace(':', ''));
|
|
1781
1991
|
let query = req.nextUrl.search;
|
|
1782
1992
|
let path = req.nextUrl.pathname;
|
|
1783
1993
|
return {
|
|
1784
|
-
doc_encoding:
|
|
1994
|
+
doc_encoding: '',
|
|
1785
1995
|
doc_host: requestHost,
|
|
1786
1996
|
doc_path: req.url,
|
|
1787
1997
|
doc_search: query,
|
|
1788
|
-
page_title:
|
|
1789
|
-
referer: req.headers.get(
|
|
1790
|
-
screen_resolution:
|
|
1791
|
-
url: `${proto}://${requestHost}${path ||
|
|
1792
|
-
user_agent: req.headers.get(
|
|
1793
|
-
user_language: req.headers.get(
|
|
1794
|
-
|
|
1998
|
+
page_title: '',
|
|
1999
|
+
referer: req.headers.get('referrer'),
|
|
2000
|
+
screen_resolution: '',
|
|
2001
|
+
url: `${proto}://${requestHost}${path || ''}${query || ''}`,
|
|
2002
|
+
user_agent: req.headers.get('user-agent'),
|
|
2003
|
+
user_language: req.headers.get('accept-language') &&
|
|
2004
|
+
req.headers.get('accept-language').split(',')[0],
|
|
2005
|
+
vp_size: '',
|
|
1795
2006
|
};
|
|
1796
2007
|
},
|
|
1797
2008
|
};
|