@usermaven/nextjs 1.5.4 → 1.5.5-rc.100
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 +460 -409
- 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
|
|
12
|
-
class
|
|
11
|
+
var p = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(p || {});
|
|
12
|
+
class G {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
this.level = e;
|
|
15
15
|
}
|
|
@@ -26,11 +26,11 @@ class W {
|
|
|
26
26
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function d(
|
|
30
|
-
return new
|
|
29
|
+
function d(n = 0) {
|
|
30
|
+
return new G(n);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
logLevel:
|
|
32
|
+
const q = {
|
|
33
|
+
logLevel: p.ERROR,
|
|
34
34
|
useBeaconApi: !1,
|
|
35
35
|
forceUseFetch: !1,
|
|
36
36
|
trackingHost: "t.usermaven.com",
|
|
@@ -55,20 +55,20 @@ const U = {
|
|
|
55
55
|
maskAllText: !1,
|
|
56
56
|
maskAllElementAttributes: !1
|
|
57
57
|
};
|
|
58
|
-
class
|
|
58
|
+
class j {
|
|
59
59
|
constructor(e) {
|
|
60
60
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
61
61
|
}
|
|
62
|
-
set(e, t,
|
|
62
|
+
set(e, t, i = 365, s = !0, r = !1) {
|
|
63
63
|
const o = /* @__PURE__ */ new Date();
|
|
64
|
-
o.setTime(o.getTime() +
|
|
65
|
-
const c = `expires=${o.toUTCString()}`, l =
|
|
64
|
+
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
65
|
+
const c = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", a = r ? "; HttpOnly" : "";
|
|
66
66
|
document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
|
|
67
67
|
}
|
|
68
68
|
get(e) {
|
|
69
|
-
const t = e + "=",
|
|
70
|
-
for (let
|
|
71
|
-
let r = s
|
|
69
|
+
const t = e + "=", i = document.cookie.split(";");
|
|
70
|
+
for (let s = 0; s < i.length; s++) {
|
|
71
|
+
let r = i[s].trim();
|
|
72
72
|
if (r.indexOf(t) === 0)
|
|
73
73
|
return decodeURIComponent(r.substring(t.length));
|
|
74
74
|
}
|
|
@@ -88,7 +88,7 @@ class X {
|
|
|
88
88
|
}
|
|
89
89
|
isIpAddress(e) {
|
|
90
90
|
const t = e.split(".");
|
|
91
|
-
return t.length === 4 && t.every((
|
|
91
|
+
return t.length === 4 && t.every((i) => !isNaN(Number(i)));
|
|
92
92
|
}
|
|
93
93
|
extractHostname(e) {
|
|
94
94
|
let t;
|
|
@@ -96,110 +96,110 @@ class X {
|
|
|
96
96
|
}
|
|
97
97
|
extractRootDomain(e) {
|
|
98
98
|
let t = this.extractHostname(e);
|
|
99
|
-
const
|
|
100
|
-
return
|
|
99
|
+
const i = t.split("."), s = i.length;
|
|
100
|
+
return s > 2 && (i[s - 1].length == 2 ? (t = i[s - 2] + "." + i[s - 1], i[s - 2].length == 2 && (t = i[s - 3] + "." + t)) : t = i[s - 2] + "." + i[s - 1]), t;
|
|
101
101
|
}
|
|
102
102
|
extractTopLevelDomain(e) {
|
|
103
|
-
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,
|
|
104
|
-
return
|
|
103
|
+
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
|
|
104
|
+
return i ? i[0] : "";
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
function
|
|
109
|
-
if (Array.isArray(
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
else if ("length" in
|
|
113
|
-
for (let
|
|
114
|
-
if (
|
|
107
|
+
const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, P = ie.forEach, N = {};
|
|
108
|
+
function ne(n, e, t) {
|
|
109
|
+
if (Array.isArray(n)) {
|
|
110
|
+
if (P && n.forEach === P)
|
|
111
|
+
n.forEach(e, t);
|
|
112
|
+
else if ("length" in n && n.length === +n.length) {
|
|
113
|
+
for (let i = 0, s = n.length; i < s; i++)
|
|
114
|
+
if (i in n && e.call(t, n[i], i) === N)
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
},
|
|
122
|
-
for (const e in
|
|
123
|
-
typeof
|
|
119
|
+
const R = function(n) {
|
|
120
|
+
return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
121
|
+
}, se = function(n) {
|
|
122
|
+
for (const e in n)
|
|
123
|
+
typeof n[e] == "function" && (n[e] = n[e].bind(n));
|
|
124
124
|
};
|
|
125
|
-
function
|
|
126
|
-
if (
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
else if ("length" in
|
|
130
|
-
for (let
|
|
131
|
-
if (
|
|
125
|
+
function g(n, e, t) {
|
|
126
|
+
if (n != null) {
|
|
127
|
+
if (P && Array.isArray(n) && n.forEach === P)
|
|
128
|
+
n.forEach(e, t);
|
|
129
|
+
else if ("length" in n && n.length === +n.length) {
|
|
130
|
+
for (let i = 0, s = n.length; i < s; i++)
|
|
131
|
+
if (i in n && e.call(t, n[i], i) === N)
|
|
132
132
|
return;
|
|
133
133
|
} else
|
|
134
|
-
for (const
|
|
135
|
-
if (
|
|
134
|
+
for (const i in n)
|
|
135
|
+
if (te.call(n, i) && e.call(t, n[i], i) === N)
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
return
|
|
141
|
-
for (const
|
|
142
|
-
t[
|
|
143
|
-
}),
|
|
139
|
+
const re = function(n, ...e) {
|
|
140
|
+
return ne(e, function(t) {
|
|
141
|
+
for (const i in t)
|
|
142
|
+
t[i] !== void 0 && (n[i] = t[i]);
|
|
143
|
+
}), n;
|
|
144
144
|
};
|
|
145
|
-
function _(
|
|
146
|
-
return
|
|
145
|
+
function _(n, e) {
|
|
146
|
+
return n.indexOf(e) !== -1;
|
|
147
147
|
}
|
|
148
|
-
const
|
|
148
|
+
const oe = function(n) {
|
|
149
149
|
try {
|
|
150
|
-
return /^\s*\bfunction\b/.test(
|
|
150
|
+
return /^\s*\bfunction\b/.test(n);
|
|
151
151
|
} catch {
|
|
152
152
|
return !1;
|
|
153
153
|
}
|
|
154
|
-
},
|
|
155
|
-
return
|
|
156
|
-
},
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
154
|
+
}, ae = function(n) {
|
|
155
|
+
return n === void 0;
|
|
156
|
+
}, y = function() {
|
|
157
|
+
const n = function(i, s, r, o, c) {
|
|
158
|
+
if (!i) {
|
|
159
159
|
d().error("No valid element provided to register_event");
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
|
-
if (
|
|
163
|
-
|
|
162
|
+
if (i.addEventListener && !o)
|
|
163
|
+
i.addEventListener(s, r, !!c);
|
|
164
164
|
else {
|
|
165
|
-
const l = "on" +
|
|
166
|
-
|
|
165
|
+
const l = "on" + s, a = i[l];
|
|
166
|
+
i[l] = e(i, r, a);
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
|
-
function e(
|
|
169
|
+
function e(i, s, r) {
|
|
170
170
|
return function(o) {
|
|
171
171
|
if (o = o || t(window.event), !o)
|
|
172
172
|
return;
|
|
173
173
|
let c = !0, l;
|
|
174
|
-
|
|
175
|
-
const a =
|
|
174
|
+
oe(r) && (l = r(o));
|
|
175
|
+
const a = s.call(i, o);
|
|
176
176
|
return (l === !1 || a === !1) && (c = !1), c;
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
-
function t(
|
|
180
|
-
return
|
|
179
|
+
function t(i) {
|
|
180
|
+
return i && (i.preventDefault = t.preventDefault, i.stopPropagation = t.stopPropagation), i;
|
|
181
181
|
}
|
|
182
182
|
return t.preventDefault = function() {
|
|
183
183
|
this.returnValue = !1;
|
|
184
184
|
}, t.stopPropagation = function() {
|
|
185
185
|
this.cancelBubble = !0;
|
|
186
|
-
},
|
|
187
|
-
}(),
|
|
186
|
+
}, n;
|
|
187
|
+
}(), ce = function(n) {
|
|
188
188
|
return function(...e) {
|
|
189
189
|
try {
|
|
190
|
-
return
|
|
190
|
+
return n.apply(this, e);
|
|
191
191
|
} catch (t) {
|
|
192
192
|
d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
|
-
},
|
|
196
|
-
for (const e in
|
|
197
|
-
typeof
|
|
195
|
+
}, V = function(n) {
|
|
196
|
+
for (const e in n)
|
|
197
|
+
typeof n[e] == "function" && (n[e] = ce(n[e]));
|
|
198
198
|
};
|
|
199
|
-
function
|
|
200
|
-
for (let e in
|
|
201
|
-
(
|
|
202
|
-
return
|
|
199
|
+
function U(n) {
|
|
200
|
+
for (let e in n)
|
|
201
|
+
(n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
|
|
202
|
+
return n;
|
|
203
203
|
}
|
|
204
204
|
function u() {
|
|
205
205
|
try {
|
|
@@ -208,80 +208,80 @@ function u() {
|
|
|
208
208
|
return d().warn("window is not available"), !1;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
function
|
|
212
|
-
const e = new Uint8Array(
|
|
213
|
-
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0,
|
|
211
|
+
function m(n = 5) {
|
|
212
|
+
const e = new Uint8Array(n);
|
|
213
|
+
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
return
|
|
215
|
+
function le(n) {
|
|
216
|
+
return n.replace(
|
|
217
217
|
/([-_][a-z])/g,
|
|
218
218
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
return typeof
|
|
223
|
-
const
|
|
224
|
-
return e[
|
|
221
|
+
function I(n) {
|
|
222
|
+
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(I) : Object.keys(n).reduce((e, t) => {
|
|
223
|
+
const i = le(t);
|
|
224
|
+
return e[i] = I(n[t]), e;
|
|
225
225
|
}, {});
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
switch (typeof
|
|
227
|
+
function A(n) {
|
|
228
|
+
switch (typeof n.className) {
|
|
229
229
|
case "string":
|
|
230
|
-
return
|
|
230
|
+
return n.className;
|
|
231
231
|
case "object":
|
|
232
|
-
return ("baseVal" in
|
|
232
|
+
return ("baseVal" in n.className ? n.className.baseVal : null) || n.getAttribute("class") || "";
|
|
233
233
|
default:
|
|
234
234
|
return "";
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function D(n) {
|
|
238
238
|
let e = "";
|
|
239
|
-
return
|
|
240
|
-
|
|
241
|
-
}),
|
|
239
|
+
return L(n) && !W(n) && n.childNodes && n.childNodes.length && g(n.childNodes, function(t) {
|
|
240
|
+
Q(t) && t.textContent && (e += R(t.textContent).split(/(\s+)/).filter(E).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
241
|
+
}), R(e);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
return !!
|
|
243
|
+
function J(n) {
|
|
244
|
+
return !!n && n.nodeType === 1;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
247
|
-
return !!
|
|
246
|
+
function f(n, e) {
|
|
247
|
+
return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
return !!
|
|
249
|
+
function Q(n) {
|
|
250
|
+
return !!n && n.nodeType === 3;
|
|
251
251
|
}
|
|
252
|
-
function
|
|
253
|
-
return !!
|
|
252
|
+
function O(n) {
|
|
253
|
+
return !!n && n.nodeType === 11;
|
|
254
254
|
}
|
|
255
255
|
const b = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
256
|
-
function
|
|
257
|
-
if (!
|
|
256
|
+
function ue(n, e) {
|
|
257
|
+
if (!n || f(n, "html") || !J(n))
|
|
258
258
|
return !1;
|
|
259
|
-
let t =
|
|
260
|
-
for (; t && !
|
|
259
|
+
let t = n;
|
|
260
|
+
for (; t && !f(t, "body"); ) {
|
|
261
261
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
262
262
|
return !1;
|
|
263
|
-
t.parentNode &&
|
|
263
|
+
t.parentNode && O(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
264
264
|
}
|
|
265
|
-
let
|
|
266
|
-
for (t =
|
|
267
|
-
if (t.parentNode &&
|
|
268
|
-
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (
|
|
265
|
+
let i = !1;
|
|
266
|
+
for (t = n; t && !f(t, "body"); ) {
|
|
267
|
+
if (t.parentNode && O(t.parentNode)) {
|
|
268
|
+
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
269
269
|
continue;
|
|
270
270
|
}
|
|
271
271
|
const o = t.parentNode;
|
|
272
272
|
if (!o) break;
|
|
273
273
|
if (b.indexOf(o.tagName.toLowerCase()) > -1)
|
|
274
|
-
|
|
274
|
+
i = !0;
|
|
275
275
|
else {
|
|
276
276
|
const c = window.getComputedStyle(o);
|
|
277
|
-
c && c.getPropertyValue("cursor") === "pointer" && (
|
|
277
|
+
c && c.getPropertyValue("cursor") === "pointer" && (i = !0);
|
|
278
278
|
}
|
|
279
279
|
t = o;
|
|
280
280
|
}
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
281
|
+
const s = window.getComputedStyle(n);
|
|
282
|
+
if (s && s.getPropertyValue("cursor") === "pointer" && e.type === "click")
|
|
283
283
|
return !0;
|
|
284
|
-
const r =
|
|
284
|
+
const r = n.tagName.toLowerCase();
|
|
285
285
|
switch (r) {
|
|
286
286
|
case "html":
|
|
287
287
|
return !1;
|
|
@@ -293,18 +293,18 @@ function re(i, e) {
|
|
|
293
293
|
case "textarea":
|
|
294
294
|
return e.type === "change" || e.type === "click";
|
|
295
295
|
default:
|
|
296
|
-
return
|
|
296
|
+
return i ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
function
|
|
300
|
-
for (let
|
|
301
|
-
const
|
|
302
|
-
if (_(
|
|
299
|
+
function L(n) {
|
|
300
|
+
for (let i = n; i.parentNode && !f(i, "body"); i = i.parentNode) {
|
|
301
|
+
const s = A(i).split(" ");
|
|
302
|
+
if (_(s, "ph-sensitive") || _(s, "ph-no-capture"))
|
|
303
303
|
return !1;
|
|
304
304
|
}
|
|
305
|
-
if (_(
|
|
305
|
+
if (_(A(n).split(" "), "ph-include"))
|
|
306
306
|
return !0;
|
|
307
|
-
const e =
|
|
307
|
+
const e = n.type || "";
|
|
308
308
|
if (typeof e == "string")
|
|
309
309
|
switch (e.toLowerCase()) {
|
|
310
310
|
case "hidden":
|
|
@@ -312,57 +312,61 @@ function O(i) {
|
|
|
312
312
|
case "password":
|
|
313
313
|
return !1;
|
|
314
314
|
}
|
|
315
|
-
const t =
|
|
315
|
+
const t = n.name || n.id || "";
|
|
316
316
|
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
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function W(n) {
|
|
319
319
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
320
|
-
return !!(
|
|
320
|
+
return !!(f(n, "input") && !e.includes(n.type) || f(n, "select") || f(n, "textarea") || n.getAttribute("contenteditable") === "true");
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
return !(
|
|
322
|
+
function E(n) {
|
|
323
|
+
return !(n === null || ae(n) || typeof n == "string" && (n = R(n), /^(?:(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((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
return typeof
|
|
325
|
+
function he(n) {
|
|
326
|
+
return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
|
|
327
327
|
}
|
|
328
|
-
function
|
|
329
|
-
return
|
|
328
|
+
function x() {
|
|
329
|
+
return m(10);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
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(
|
|
331
|
+
function de(n) {
|
|
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(n).toLowerCase());
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function fe(n, e) {
|
|
335
335
|
let t;
|
|
336
|
-
return function(...
|
|
337
|
-
const
|
|
338
|
-
clearTimeout(t),
|
|
336
|
+
return function(...i) {
|
|
337
|
+
const s = () => {
|
|
338
|
+
clearTimeout(t), n(...i);
|
|
339
339
|
};
|
|
340
|
-
clearTimeout(t), t = setTimeout(
|
|
340
|
+
clearTimeout(t), t = setTimeout(s, e);
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
function
|
|
344
|
-
const e = {}, t =
|
|
345
|
-
for (let
|
|
346
|
-
const
|
|
347
|
-
|
|
343
|
+
function ge(n) {
|
|
344
|
+
const e = {}, t = n.replace(/^\?/, "").split("&");
|
|
345
|
+
for (let i = 0; i < t.length; i++) {
|
|
346
|
+
const s = t[i].split("=");
|
|
347
|
+
s[0] !== "" && (e[decodeURIComponent(s[0])] = decodeURIComponent(s[1] || ""));
|
|
348
348
|
}
|
|
349
349
|
return e;
|
|
350
350
|
}
|
|
351
|
-
function
|
|
352
|
-
return typeof
|
|
351
|
+
function F(n) {
|
|
352
|
+
return typeof n == "string" || n instanceof String;
|
|
353
353
|
}
|
|
354
|
-
function
|
|
355
|
-
return
|
|
354
|
+
function v(n) {
|
|
355
|
+
return n !== null && typeof n == "object" && n.constructor === Object;
|
|
356
356
|
}
|
|
357
|
-
function
|
|
358
|
-
if (
|
|
359
|
-
return
|
|
360
|
-
const e =
|
|
361
|
-
return t || t === 0 ? t :
|
|
357
|
+
function pe(n) {
|
|
358
|
+
if (n === null)
|
|
359
|
+
return p.ERROR;
|
|
360
|
+
const e = n.toUpperCase(), t = p[e];
|
|
361
|
+
return t || t === 0 ? t : p.ERROR;
|
|
362
362
|
}
|
|
363
|
-
|
|
363
|
+
const me = () => {
|
|
364
|
+
let n = "false";
|
|
365
|
+
return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
|
|
366
|
+
};
|
|
367
|
+
class ye {
|
|
364
368
|
constructor(e) {
|
|
365
|
-
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll =
|
|
369
|
+
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = fe(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
366
370
|
}
|
|
367
371
|
initializeEventListener() {
|
|
368
372
|
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
@@ -386,8 +390,8 @@ class he {
|
|
|
386
390
|
this.track();
|
|
387
391
|
}
|
|
388
392
|
getScrollDepth() {
|
|
389
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(),
|
|
390
|
-
return Math.min(100, Math.floor(
|
|
393
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), s = t - e;
|
|
394
|
+
return Math.min(100, Math.floor(i / s * 100));
|
|
391
395
|
}
|
|
392
396
|
getWindowHeight() {
|
|
393
397
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -406,27 +410,38 @@ class he {
|
|
|
406
410
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
407
411
|
}
|
|
408
412
|
checkMilestones(e) {
|
|
409
|
-
this.milestones.filter((
|
|
410
|
-
this.send(), this.milestones = this.milestones.filter((
|
|
413
|
+
this.milestones.filter((i) => e >= i).forEach((i) => {
|
|
414
|
+
this.send(), this.milestones = this.milestones.filter((s) => s !== i);
|
|
411
415
|
});
|
|
412
416
|
}
|
|
413
417
|
}
|
|
414
|
-
const
|
|
415
|
-
constructor(e, t,
|
|
416
|
-
this.logger =
|
|
418
|
+
const T = class T {
|
|
419
|
+
constructor(e, t, i = d()) {
|
|
420
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new ye(e), se(this), V(this);
|
|
421
|
+
}
|
|
422
|
+
isBrowserSupported() {
|
|
423
|
+
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
417
424
|
}
|
|
418
425
|
init() {
|
|
426
|
+
if (!this.isBrowserSupported()) {
|
|
427
|
+
this.logger.debug("Browser not supported for autocapture");
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (this.domHandlersAttached) {
|
|
431
|
+
this.logger.debug("Autocapture already initialized.");
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
419
434
|
if (!(document && document.body)) {
|
|
420
435
|
this.logger.debug("Document not ready yet, trying again in 500 milliseconds..."), setTimeout(() => this.init(), 500);
|
|
421
436
|
return;
|
|
422
437
|
}
|
|
423
|
-
this.addDomEventHandlers();
|
|
438
|
+
this.addDomEventHandlers(), this.domHandlersAttached = !0;
|
|
424
439
|
}
|
|
425
440
|
addDomEventHandlers() {
|
|
426
441
|
const e = (t) => {
|
|
427
442
|
t = t || window.event, this.captureEvent(t);
|
|
428
443
|
};
|
|
429
|
-
|
|
444
|
+
y(document, "submit", e, !1, !0), y(document, "change", e, !1, !0), y(document, "click", e, !1, !0), y(document, "visibilitychange", e, !1, !0), y(document, "scroll", e, !1, !0), y(window, "popstate", e, !1, !0);
|
|
430
445
|
}
|
|
431
446
|
isPageRefresh() {
|
|
432
447
|
if ("PerformanceNavigationTiming" in window) {
|
|
@@ -437,17 +452,17 @@ const C = class C {
|
|
|
437
452
|
return performance.navigation && performance.navigation.type === 1;
|
|
438
453
|
}
|
|
439
454
|
captureEvent(e) {
|
|
440
|
-
var
|
|
455
|
+
var i, s;
|
|
441
456
|
let t = this.getEventTarget(e);
|
|
442
|
-
if (
|
|
443
|
-
return (
|
|
457
|
+
if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
458
|
+
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
444
459
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
445
|
-
return this.isPageRefresh() || (
|
|
446
|
-
if (t &&
|
|
460
|
+
return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
|
|
461
|
+
if (t && ue(t, e)) {
|
|
447
462
|
const r = [t];
|
|
448
463
|
let o = t;
|
|
449
|
-
for (; o.parentNode && !
|
|
450
|
-
if (
|
|
464
|
+
for (; o.parentNode && !f(o, "body"); ) {
|
|
465
|
+
if (O(o.parentNode)) {
|
|
451
466
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
452
467
|
continue;
|
|
453
468
|
}
|
|
@@ -455,20 +470,20 @@ const C = class C {
|
|
|
455
470
|
}
|
|
456
471
|
const c = [];
|
|
457
472
|
let l, a = !1;
|
|
458
|
-
if (
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
_(
|
|
473
|
+
if (g(r, (k) => {
|
|
474
|
+
const Z = L(k);
|
|
475
|
+
k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = Z && E(l) && l);
|
|
476
|
+
const Y = A(k).split(" ");
|
|
477
|
+
_(Y, "ph-no-capture") && (a = !0), c.push(
|
|
463
478
|
this.getPropertiesFromElement(
|
|
464
|
-
|
|
479
|
+
k,
|
|
465
480
|
this.options.maskAllElementAttributes ?? !1,
|
|
466
481
|
this.options.maskAllText ?? !1
|
|
467
482
|
)
|
|
468
483
|
);
|
|
469
|
-
}), this.options.maskAllText || (c[0].$el_text =
|
|
484
|
+
}), this.options.maskAllText || (c[0].$el_text = D(t)), l && (c[0].attr__href = l), a)
|
|
470
485
|
return !1;
|
|
471
|
-
const h =
|
|
486
|
+
const h = re(
|
|
472
487
|
this.getDefaultProperties(e.type),
|
|
473
488
|
{
|
|
474
489
|
$elements: c
|
|
@@ -480,36 +495,36 @@ const C = class C {
|
|
|
480
495
|
}
|
|
481
496
|
getCustomProperties(e) {
|
|
482
497
|
const t = {};
|
|
483
|
-
return
|
|
484
|
-
|
|
485
|
-
const r = document.querySelectorAll(
|
|
486
|
-
|
|
487
|
-
_(e, o) &&
|
|
498
|
+
return g(this.customProperties, (i) => {
|
|
499
|
+
g(i.event_selectors, (s) => {
|
|
500
|
+
const r = document.querySelectorAll(s);
|
|
501
|
+
g(r, (o) => {
|
|
502
|
+
_(e, o) && L(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
488
503
|
});
|
|
489
504
|
});
|
|
490
505
|
}), t;
|
|
491
506
|
}
|
|
492
507
|
extractCustomPropertyValue(e) {
|
|
493
508
|
const t = [];
|
|
494
|
-
return
|
|
495
|
-
let
|
|
496
|
-
["input", "select"].indexOf(
|
|
509
|
+
return g(document.querySelectorAll(e.css_selector), function(i) {
|
|
510
|
+
let s;
|
|
511
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), E(s) && t.push(s);
|
|
497
512
|
}), t.join(", ");
|
|
498
513
|
}
|
|
499
514
|
getEventTarget(e) {
|
|
500
515
|
var t;
|
|
501
516
|
return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
502
517
|
}
|
|
503
|
-
getPropertiesFromElement(e, t,
|
|
504
|
-
const
|
|
505
|
-
tag_name:
|
|
518
|
+
getPropertiesFromElement(e, t, i) {
|
|
519
|
+
const s = e.tagName.toLowerCase(), r = {
|
|
520
|
+
tag_name: s
|
|
506
521
|
};
|
|
507
|
-
b.indexOf(
|
|
508
|
-
const o =
|
|
522
|
+
b.indexOf(s) > -1 && !i && (r.$el_text = D(e));
|
|
523
|
+
const o = A(e);
|
|
509
524
|
o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
|
|
510
525
|
return h !== "";
|
|
511
|
-
})),
|
|
512
|
-
|
|
526
|
+
})), g(e.attributes, function(h) {
|
|
527
|
+
W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && E(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
|
|
513
528
|
});
|
|
514
529
|
let c = 1, l = 1, a = e;
|
|
515
530
|
for (; a = this.previousElementSibling(a); )
|
|
@@ -523,7 +538,7 @@ const C = class C {
|
|
|
523
538
|
let t = e;
|
|
524
539
|
do
|
|
525
540
|
t = t.previousSibling;
|
|
526
|
-
while (t && !
|
|
541
|
+
while (t && !J(t));
|
|
527
542
|
return t;
|
|
528
543
|
}
|
|
529
544
|
}
|
|
@@ -536,18 +551,18 @@ const C = class C {
|
|
|
536
551
|
encodeHtml(e) {
|
|
537
552
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
538
553
|
}
|
|
539
|
-
static enabledForProject(e, t = 10,
|
|
554
|
+
static enabledForProject(e, t = 10, i = 10) {
|
|
540
555
|
if (!e)
|
|
541
556
|
return !1;
|
|
542
|
-
let
|
|
557
|
+
let s = 0;
|
|
543
558
|
for (let r = 0; r < e.length; r++)
|
|
544
|
-
|
|
545
|
-
return
|
|
559
|
+
s += e.charCodeAt(r);
|
|
560
|
+
return s % t < i;
|
|
546
561
|
}
|
|
547
562
|
};
|
|
548
|
-
|
|
549
|
-
let
|
|
550
|
-
class
|
|
563
|
+
T.FORCE_CAPTURE_ATTR = "data-um-force-capture", T.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
564
|
+
let $ = T;
|
|
565
|
+
class we {
|
|
551
566
|
constructor(e) {
|
|
552
567
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
553
568
|
}
|
|
@@ -576,44 +591,44 @@ class de {
|
|
|
576
591
|
}));
|
|
577
592
|
}
|
|
578
593
|
}
|
|
579
|
-
class
|
|
580
|
-
constructor(e, t,
|
|
581
|
-
this.trackingHost = e, this.logger =
|
|
594
|
+
class ke {
|
|
595
|
+
constructor(e, t, i = d()) {
|
|
596
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
582
597
|
}
|
|
583
598
|
async send(e) {
|
|
584
|
-
const t = this.config.key,
|
|
585
|
-
if (navigator.sendBeacon(
|
|
599
|
+
const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], { type: "application/json" });
|
|
600
|
+
if (navigator.sendBeacon(i, s))
|
|
586
601
|
this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
|
|
587
602
|
else
|
|
588
603
|
throw new Error("Failed to queue events via Beacon API");
|
|
589
604
|
}
|
|
590
605
|
constructUrl(e) {
|
|
591
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
592
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
606
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
607
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
593
608
|
}
|
|
594
609
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
595
610
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
596
611
|
}
|
|
597
|
-
class
|
|
598
|
-
constructor(e, t,
|
|
599
|
-
this.trackingHost = e, this.logger =
|
|
612
|
+
class z {
|
|
613
|
+
constructor(e, t, i = d()) {
|
|
614
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
600
615
|
}
|
|
601
616
|
async send(e) {
|
|
602
|
-
const t = this.config.key,
|
|
617
|
+
const t = this.config.key, i = this.constructUrl(t), s = JSON.stringify(e), r = {
|
|
603
618
|
"Content-Type": "application/json",
|
|
604
619
|
...this.getCustomHeaders()
|
|
605
|
-
}, o = await fetch(
|
|
620
|
+
}, o = await fetch(i, {
|
|
606
621
|
method: "POST",
|
|
607
622
|
headers: r,
|
|
608
|
-
body:
|
|
623
|
+
body: s
|
|
609
624
|
});
|
|
610
625
|
if (!o.ok)
|
|
611
626
|
throw new Error(`HTTP error! status: ${o.status}`);
|
|
612
627
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
613
628
|
}
|
|
614
629
|
constructUrl(e) {
|
|
615
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
616
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
630
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
631
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
617
632
|
}
|
|
618
633
|
getCustomHeaders() {
|
|
619
634
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -622,27 +637,27 @@ class D {
|
|
|
622
637
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
623
638
|
}
|
|
624
639
|
}
|
|
625
|
-
class
|
|
626
|
-
constructor(e, t,
|
|
627
|
-
this.trackingHost = e, this.logger =
|
|
640
|
+
class ve {
|
|
641
|
+
constructor(e, t, i = d()) {
|
|
642
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
628
643
|
}
|
|
629
644
|
send(e) {
|
|
630
|
-
return new Promise((t,
|
|
631
|
-
const
|
|
632
|
-
|
|
645
|
+
return new Promise((t, i) => {
|
|
646
|
+
const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
647
|
+
s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
|
|
633
648
|
const c = this.getCustomHeaders();
|
|
634
649
|
Object.keys(c).forEach((l) => {
|
|
635
|
-
|
|
636
|
-
}),
|
|
637
|
-
|
|
638
|
-
},
|
|
639
|
-
|
|
640
|
-
},
|
|
650
|
+
s.setRequestHeader(l, c[l]);
|
|
651
|
+
}), s.onload = () => {
|
|
652
|
+
s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
|
|
653
|
+
}, s.onerror = () => {
|
|
654
|
+
i(new Error("Network error"));
|
|
655
|
+
}, s.send(JSON.stringify(e));
|
|
641
656
|
});
|
|
642
657
|
}
|
|
643
658
|
constructUrl(e) {
|
|
644
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
645
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
659
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
660
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
646
661
|
}
|
|
647
662
|
getCustomHeaders() {
|
|
648
663
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -651,7 +666,7 @@ class fe {
|
|
|
651
666
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
652
667
|
}
|
|
653
668
|
}
|
|
654
|
-
class
|
|
669
|
+
class K {
|
|
655
670
|
constructor(e, t) {
|
|
656
671
|
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
|
|
657
672
|
}
|
|
@@ -691,7 +706,7 @@ class V {
|
|
|
691
706
|
}
|
|
692
707
|
}
|
|
693
708
|
}
|
|
694
|
-
class
|
|
709
|
+
class _e {
|
|
695
710
|
constructor() {
|
|
696
711
|
this.storage = {};
|
|
697
712
|
}
|
|
@@ -710,10 +725,10 @@ class pe {
|
|
|
710
725
|
this.storage = {};
|
|
711
726
|
}
|
|
712
727
|
}
|
|
713
|
-
class
|
|
728
|
+
class B {
|
|
714
729
|
// Default to true for server-side
|
|
715
|
-
constructor(e, t = 3,
|
|
716
|
-
this.transport = e, this.maxRetries = t, this.retryInterval =
|
|
730
|
+
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = d(), c = "default") {
|
|
731
|
+
this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new K(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
717
732
|
}
|
|
718
733
|
add(e) {
|
|
719
734
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -732,11 +747,11 @@ class F {
|
|
|
732
747
|
async processBatch() {
|
|
733
748
|
if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
734
749
|
this.processing = !0;
|
|
735
|
-
const e = this.queue.splice(0, this.batchSize), t = e.map((
|
|
750
|
+
const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
|
|
736
751
|
try {
|
|
737
752
|
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
|
|
738
|
-
} catch (
|
|
739
|
-
this.logger.error("Failed to send batch",
|
|
753
|
+
} catch (i) {
|
|
754
|
+
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
740
755
|
}
|
|
741
756
|
this.processing = !1;
|
|
742
757
|
}
|
|
@@ -757,9 +772,9 @@ class F {
|
|
|
757
772
|
u() && this.persistence.set("queue", JSON.stringify(this.queue));
|
|
758
773
|
}
|
|
759
774
|
}
|
|
760
|
-
class
|
|
775
|
+
class be {
|
|
761
776
|
constructor(e) {
|
|
762
|
-
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(),
|
|
777
|
+
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
|
|
763
778
|
}
|
|
764
779
|
initializeEventListener() {
|
|
765
780
|
document.addEventListener("click", this.handleClick.bind(this));
|
|
@@ -771,17 +786,17 @@ class me {
|
|
|
771
786
|
shouldCaptureElement(e) {
|
|
772
787
|
return !e.closest(".um-no-capture");
|
|
773
788
|
}
|
|
774
|
-
click(e, t,
|
|
775
|
-
const
|
|
776
|
-
this.clicks.push(
|
|
789
|
+
click(e, t, i) {
|
|
790
|
+
const s = { x: e, y: t, timestamp: i };
|
|
791
|
+
this.clicks.push(s), this.clicks = this.clicks.filter((r) => i - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
777
792
|
}
|
|
778
793
|
checkRageClick() {
|
|
779
|
-
const e = this.clicks[0],
|
|
794
|
+
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
780
795
|
this.clicks.every((r, o) => {
|
|
781
796
|
if (o === 0) return !0;
|
|
782
797
|
const c = this.clicks[o - 1];
|
|
783
798
|
return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
|
|
784
|
-
}) && this.sendRageClickEvent(
|
|
799
|
+
}) && this.sendRageClickEvent(i);
|
|
785
800
|
}
|
|
786
801
|
sendRageClickEvent(e) {
|
|
787
802
|
const t = this.clicks[this.clicks.length - 1];
|
|
@@ -791,15 +806,15 @@ class me {
|
|
|
791
806
|
}), this.clicks = [];
|
|
792
807
|
}
|
|
793
808
|
}
|
|
794
|
-
class
|
|
795
|
-
constructor(e, t,
|
|
796
|
-
this.trackingHost = e, this.logger =
|
|
809
|
+
class Ee {
|
|
810
|
+
constructor(e, t, i = d()) {
|
|
811
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
797
812
|
}
|
|
798
813
|
async send(e) {
|
|
799
|
-
const t = this.config.key,
|
|
800
|
-
hostname:
|
|
814
|
+
const t = this.config.key, i = new (void 0)(this.constructUrl(t)), s = {
|
|
815
|
+
hostname: i.hostname,
|
|
801
816
|
port: 443,
|
|
802
|
-
path: `${
|
|
817
|
+
path: `${i.pathname}${i.search}`,
|
|
803
818
|
method: "POST",
|
|
804
819
|
headers: {
|
|
805
820
|
"Content-Type": "application/json",
|
|
@@ -807,7 +822,7 @@ class ye {
|
|
|
807
822
|
}
|
|
808
823
|
};
|
|
809
824
|
return new Promise((r, o) => {
|
|
810
|
-
const c = (void 0)(
|
|
825
|
+
const c = (void 0)(s, (l) => {
|
|
811
826
|
l.on("data", (a) => {
|
|
812
827
|
}), l.on("end", () => {
|
|
813
828
|
const a = l.statusCode || 0;
|
|
@@ -820,16 +835,16 @@ class ye {
|
|
|
820
835
|
});
|
|
821
836
|
}
|
|
822
837
|
constructUrl(e) {
|
|
823
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
824
|
-
return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${
|
|
838
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
|
|
839
|
+
return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${i}`;
|
|
825
840
|
}
|
|
826
841
|
getCustomHeaders() {
|
|
827
842
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
828
843
|
}
|
|
829
844
|
}
|
|
830
|
-
class
|
|
831
|
-
constructor(e, t = "all",
|
|
832
|
-
this.instance = e, this.trackingType = t, this.options =
|
|
845
|
+
class w {
|
|
846
|
+
constructor(e, t = "all", i = {}) {
|
|
847
|
+
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
833
848
|
}
|
|
834
849
|
initialize() {
|
|
835
850
|
this.trackingType !== "none" && this.setupFormTracking();
|
|
@@ -841,19 +856,19 @@ class y {
|
|
|
841
856
|
});
|
|
842
857
|
}
|
|
843
858
|
handleFormSubmit(e) {
|
|
844
|
-
const t = e.target,
|
|
845
|
-
this.instance.track("$form",
|
|
859
|
+
const t = e.target, i = this._getFormDetails(t);
|
|
860
|
+
this.instance.track("$form", U(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
846
861
|
}
|
|
847
862
|
trackFieldChanges(e) {
|
|
848
|
-
e.querySelectorAll("input, select, textarea").forEach((
|
|
849
|
-
|
|
850
|
-
const r = this._getFieldProps(
|
|
851
|
-
this.instance.track("$form_field_change",
|
|
863
|
+
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
864
|
+
i.addEventListener("change", (s) => {
|
|
865
|
+
const r = this._getFieldProps(s.target, 0);
|
|
866
|
+
this.instance.track("$form_field_change", U(r));
|
|
852
867
|
});
|
|
853
868
|
});
|
|
854
869
|
}
|
|
855
|
-
static getInstance(e, t = "all",
|
|
856
|
-
return
|
|
870
|
+
static getInstance(e, t = "all", i = {}) {
|
|
871
|
+
return w.instance || (w.instance = new w(e, t, i)), w.instance;
|
|
857
872
|
}
|
|
858
873
|
_getFormDetails(e) {
|
|
859
874
|
const t = {
|
|
@@ -863,20 +878,20 @@ class y {
|
|
|
863
878
|
form_method: e.method,
|
|
864
879
|
form_class: e.className,
|
|
865
880
|
form_attributes: this._getElementAttributes(e)
|
|
866
|
-
},
|
|
867
|
-
return Array.from(
|
|
881
|
+
}, i = e.querySelectorAll("input, select, textarea");
|
|
882
|
+
return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
|
|
868
883
|
const c = this._getFieldProps(r, o);
|
|
869
884
|
Object.assign(t, c);
|
|
870
885
|
}), t;
|
|
871
886
|
}
|
|
872
887
|
_getFieldProps(e, t) {
|
|
873
|
-
const
|
|
888
|
+
const i = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, s = this.getSafeText(e);
|
|
874
889
|
return {
|
|
875
890
|
[`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
|
|
876
891
|
[`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
|
|
877
|
-
[`field_${t + 1}_data_attributes`]:
|
|
892
|
+
[`field_${t + 1}_data_attributes`]: i,
|
|
878
893
|
[`field_${t + 1}_id`]: e.id,
|
|
879
|
-
[`field_${t + 1}_value`]:
|
|
894
|
+
[`field_${t + 1}_value`]: s,
|
|
880
895
|
[`field_${t + 1}_class`]: e.className,
|
|
881
896
|
[`field_${t + 1}_name`]: e.name,
|
|
882
897
|
[`field_${t + 1}_attributes`]: this._getElementAttributes(e)
|
|
@@ -888,8 +903,8 @@ class y {
|
|
|
888
903
|
getSafeText(e) {
|
|
889
904
|
let t = "";
|
|
890
905
|
return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
|
|
891
|
-
(
|
|
892
|
-
).map((
|
|
906
|
+
(s) => s.nodeType === Node.TEXT_NODE
|
|
907
|
+
).map((s) => s.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
|
|
893
908
|
}
|
|
894
909
|
_scrubPotentiallySensitiveValues(e) {
|
|
895
910
|
return this._shouldCaptureValue(e) ? e : "<redacted>";
|
|
@@ -906,8 +921,8 @@ class y {
|
|
|
906
921
|
_trim(e) {
|
|
907
922
|
if (typeof String.prototype.trim == "function")
|
|
908
923
|
return e.trim();
|
|
909
|
-
let t = 0,
|
|
910
|
-
const
|
|
924
|
+
let t = 0, i = e.length - 1;
|
|
925
|
+
const s = [
|
|
911
926
|
" ",
|
|
912
927
|
`
|
|
913
928
|
`,
|
|
@@ -934,16 +949,16 @@ class y {
|
|
|
934
949
|
" ",
|
|
935
950
|
" "
|
|
936
951
|
].join("");
|
|
937
|
-
for (; t <=
|
|
952
|
+
for (; t <= i && s.indexOf(e[t]) > -1; )
|
|
938
953
|
t++;
|
|
939
|
-
for (;
|
|
940
|
-
|
|
941
|
-
return e.slice(t,
|
|
954
|
+
for (; i >= t && s.indexOf(e[i]) > -1; )
|
|
955
|
+
i--;
|
|
956
|
+
return e.slice(t, i + 1);
|
|
942
957
|
}
|
|
943
958
|
}
|
|
944
|
-
class
|
|
959
|
+
class S {
|
|
945
960
|
constructor(e) {
|
|
946
|
-
this.config = this.mergeConfig(e,
|
|
961
|
+
this.config = this.mergeConfig(e, q), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new B(
|
|
947
962
|
this.transport,
|
|
948
963
|
this.config.maxSendAttempts || 3,
|
|
949
964
|
this.config.minSendTimeout || 1e3,
|
|
@@ -955,13 +970,13 @@ class we {
|
|
|
955
970
|
), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
|
|
956
971
|
}
|
|
957
972
|
initializeBrowserFeatures() {
|
|
958
|
-
if (this.cookieManager = new
|
|
973
|
+
if (this.cookieManager = new j(this.config.cookieDomain), this.config.autocapture && $.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new $(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
959
974
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
960
|
-
this.formTracking =
|
|
975
|
+
this.formTracking = w.getInstance(this, e || "none", {
|
|
961
976
|
trackFieldChanges: !1
|
|
962
977
|
});
|
|
963
978
|
}
|
|
964
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
979
|
+
this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
|
|
965
980
|
}
|
|
966
981
|
/**
|
|
967
982
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -969,14 +984,14 @@ class we {
|
|
|
969
984
|
* @param defaultConfig
|
|
970
985
|
*/
|
|
971
986
|
mergeConfig(e, t) {
|
|
972
|
-
const
|
|
973
|
-
let
|
|
987
|
+
const i = JSON.parse(JSON.stringify(e));
|
|
988
|
+
let s = { ...t, ...i };
|
|
974
989
|
return Object.keys(t).forEach((r) => {
|
|
975
|
-
|
|
976
|
-
}),
|
|
990
|
+
v(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
|
|
991
|
+
}), s;
|
|
977
992
|
}
|
|
978
993
|
init(e) {
|
|
979
|
-
this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new
|
|
994
|
+
this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new B(
|
|
980
995
|
this.transport,
|
|
981
996
|
this.config.maxSendAttempts || 3,
|
|
982
997
|
this.config.minSendTimeout || 1e3,
|
|
@@ -990,17 +1005,17 @@ class we {
|
|
|
990
1005
|
manageCrossDomainLinking() {
|
|
991
1006
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
992
1007
|
return;
|
|
993
|
-
const e = this.config.domains.split(",").map((
|
|
994
|
-
document.addEventListener("click", (
|
|
1008
|
+
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1009
|
+
document.addEventListener("click", (i) => {
|
|
995
1010
|
var c;
|
|
996
|
-
const
|
|
997
|
-
if (!
|
|
998
|
-
const r =
|
|
1011
|
+
const s = this.findClosestLink(i.target);
|
|
1012
|
+
if (!s) return;
|
|
1013
|
+
const r = s.getAttribute("href");
|
|
999
1014
|
if (!r || !r.startsWith("http")) return;
|
|
1000
1015
|
const o = new URL(r);
|
|
1001
1016
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1002
1017
|
const l = (c = this.cookieManager) == null ? void 0 : c.get(t);
|
|
1003
|
-
l && (o.searchParams.append("_um", l),
|
|
1018
|
+
l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
|
|
1004
1019
|
}
|
|
1005
1020
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
1006
1021
|
}
|
|
@@ -1012,99 +1027,103 @@ class we {
|
|
|
1012
1027
|
initializeTransport(e) {
|
|
1013
1028
|
const t = "https://events.usermaven.com";
|
|
1014
1029
|
if (!u())
|
|
1015
|
-
return new
|
|
1016
|
-
const
|
|
1030
|
+
return new Ee(e.trackingHost || t, e);
|
|
1031
|
+
const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1017
1032
|
if (e.useBeaconApi && r)
|
|
1018
|
-
return new
|
|
1019
|
-
if (e.forceUseFetch &&
|
|
1020
|
-
return new
|
|
1033
|
+
return new ke(e.trackingHost || t, e, this.logger);
|
|
1034
|
+
if (e.forceUseFetch && s)
|
|
1035
|
+
return new z(e.trackingHost || t, e, this.logger);
|
|
1036
|
+
if (i)
|
|
1037
|
+
return new ve(e.trackingHost || t, e, this.logger);
|
|
1021
1038
|
if (s)
|
|
1022
|
-
return new
|
|
1023
|
-
if (n)
|
|
1024
|
-
return new D(e.trackingHost || t, e, this.logger);
|
|
1039
|
+
return new z(e.trackingHost || t, e, this.logger);
|
|
1025
1040
|
throw new Error("No suitable transport method available");
|
|
1026
1041
|
}
|
|
1027
1042
|
initializePersistence() {
|
|
1028
|
-
return this.config.disableEventPersistence || !u() ? new
|
|
1043
|
+
return this.config.disableEventPersistence || !u() ? new _e() : new K(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1029
1044
|
}
|
|
1030
1045
|
getOrCreateAnonymousId() {
|
|
1031
|
-
var
|
|
1046
|
+
var i, s;
|
|
1032
1047
|
if (!u())
|
|
1033
|
-
return
|
|
1048
|
+
return x();
|
|
1034
1049
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1035
1050
|
return "";
|
|
1036
1051
|
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1037
|
-
let t = (
|
|
1052
|
+
let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
|
|
1038
1053
|
if (!t) {
|
|
1039
1054
|
if (this.config.crossDomainLinking) {
|
|
1040
1055
|
const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
|
|
1041
|
-
t = c || h ||
|
|
1056
|
+
t = c || h || x();
|
|
1042
1057
|
}
|
|
1043
|
-
t || (t =
|
|
1058
|
+
t || (t = x());
|
|
1044
1059
|
const r = 365 * 10;
|
|
1045
|
-
(
|
|
1060
|
+
(s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
|
|
1046
1061
|
}
|
|
1047
1062
|
return t;
|
|
1048
1063
|
}
|
|
1049
1064
|
async id(e, t = !1) {
|
|
1050
|
-
if (!
|
|
1065
|
+
if (!v(e))
|
|
1051
1066
|
throw new Error("User data must be an object");
|
|
1052
|
-
if (e.email && !
|
|
1067
|
+
if (e.email && !de(e.email))
|
|
1053
1068
|
throw new Error("Invalid email provided");
|
|
1054
|
-
if (!e.id || !
|
|
1069
|
+
if (!e.id || !F(e.id))
|
|
1055
1070
|
throw new Error("User ID must be a string");
|
|
1056
|
-
const
|
|
1057
|
-
if (this.persistence.set("userId",
|
|
1058
|
-
const
|
|
1071
|
+
const i = e.id;
|
|
1072
|
+
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
1073
|
+
const s = {
|
|
1059
1074
|
...e,
|
|
1060
1075
|
anonymous_id: this.anonymousId
|
|
1061
1076
|
};
|
|
1062
|
-
await this.track("user_identify",
|
|
1077
|
+
await this.track("user_identify", s);
|
|
1063
1078
|
}
|
|
1064
1079
|
this.logger.info("User identified:", e);
|
|
1065
1080
|
}
|
|
1066
|
-
track(e, t,
|
|
1067
|
-
this.trackInternal(e, t,
|
|
1081
|
+
track(e, t, i = !1) {
|
|
1082
|
+
this.trackInternal(e, t, i);
|
|
1068
1083
|
}
|
|
1069
|
-
trackInternal(e, t,
|
|
1070
|
-
if (
|
|
1084
|
+
trackInternal(e, t, i = !1) {
|
|
1085
|
+
if (me()) {
|
|
1086
|
+
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
if (!F(e))
|
|
1071
1090
|
throw new Error("Event name must be a string");
|
|
1072
1091
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1073
1092
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
1074
|
-
const
|
|
1093
|
+
const r = this.createEventPayload(e, t);
|
|
1075
1094
|
try {
|
|
1076
|
-
if (
|
|
1077
|
-
this.transport.send(
|
|
1095
|
+
if (i) {
|
|
1096
|
+
this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
|
|
1078
1097
|
return;
|
|
1079
1098
|
}
|
|
1080
|
-
this.retryQueue.add(
|
|
1081
|
-
} catch (
|
|
1082
|
-
throw this.logger.error(`Failed to track event: ${e}`,
|
|
1099
|
+
this.retryQueue.add(r), this.logger.debug(`Event tracked: ${e}`, [r]);
|
|
1100
|
+
} catch (o) {
|
|
1101
|
+
throw this.logger.error(`Failed to track event: ${e}`, o), new Error(`Failed to track event: ${e}`);
|
|
1083
1102
|
}
|
|
1084
1103
|
}
|
|
1085
1104
|
rawTrack(e) {
|
|
1086
|
-
if (!
|
|
1105
|
+
if (!v(e))
|
|
1087
1106
|
throw new Error("Event payload must be an object");
|
|
1088
1107
|
this.track("raw", e);
|
|
1089
1108
|
}
|
|
1090
1109
|
async group(e, t = !1) {
|
|
1091
|
-
if (!
|
|
1110
|
+
if (!v(e))
|
|
1092
1111
|
throw new Error("Company properties must be an object");
|
|
1093
1112
|
if (!e.id || !e.name || !e.created_at)
|
|
1094
1113
|
throw new Error("Company properties must include id, name, and created_at");
|
|
1095
1114
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1096
1115
|
}
|
|
1097
1116
|
createEventPayload(e, t) {
|
|
1098
|
-
const
|
|
1117
|
+
const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
|
|
1099
1118
|
let l = t || {};
|
|
1100
1119
|
const a = {
|
|
1101
1120
|
event_id: "",
|
|
1102
1121
|
user: {
|
|
1103
1122
|
anonymous_id: this.anonymousId,
|
|
1104
1123
|
id: r,
|
|
1105
|
-
...
|
|
1124
|
+
...i
|
|
1106
1125
|
},
|
|
1107
|
-
...
|
|
1126
|
+
...s && { company: s },
|
|
1108
1127
|
ids: this.getThirdPartyIds(),
|
|
1109
1128
|
utc_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1110
1129
|
local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
@@ -1125,9 +1144,9 @@ class we {
|
|
|
1125
1144
|
}
|
|
1126
1145
|
processAutocaptureAttributes(e) {
|
|
1127
1146
|
let t = {};
|
|
1128
|
-
const
|
|
1129
|
-
return
|
|
1130
|
-
delete t[
|
|
1147
|
+
const i = e.$elements || [];
|
|
1148
|
+
return i.length && (t = { ...i[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((s) => {
|
|
1149
|
+
delete t[s];
|
|
1131
1150
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1132
1151
|
}
|
|
1133
1152
|
getCookie(e) {
|
|
@@ -1143,9 +1162,9 @@ class we {
|
|
|
1143
1162
|
return e;
|
|
1144
1163
|
}
|
|
1145
1164
|
getUtmParams() {
|
|
1146
|
-
const e = {}, t =
|
|
1147
|
-
return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((
|
|
1148
|
-
t[
|
|
1165
|
+
const e = {}, t = ge(window.location.search);
|
|
1166
|
+
return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
|
|
1167
|
+
t[s] && (e[s.replace("utm_", "")] = t[s]);
|
|
1149
1168
|
}), e;
|
|
1150
1169
|
}
|
|
1151
1170
|
pageview() {
|
|
@@ -1158,7 +1177,7 @@ class we {
|
|
|
1158
1177
|
setupPageLeaveTracking() {
|
|
1159
1178
|
if (!u()) return;
|
|
1160
1179
|
let e = !1, t = !1;
|
|
1161
|
-
const
|
|
1180
|
+
const i = () => {
|
|
1162
1181
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
1163
1182
|
url: window.location.href,
|
|
1164
1183
|
referrer: document.referrer,
|
|
@@ -1170,12 +1189,12 @@ class we {
|
|
|
1170
1189
|
t = !1;
|
|
1171
1190
|
}, 100);
|
|
1172
1191
|
}), document.addEventListener("visibilitychange", () => {
|
|
1173
|
-
document.visibilityState === "hidden" && !t &&
|
|
1192
|
+
document.visibilityState === "hidden" && !t && i();
|
|
1174
1193
|
});
|
|
1175
|
-
const
|
|
1194
|
+
const s = history.pushState;
|
|
1176
1195
|
history.pushState = function() {
|
|
1177
|
-
return
|
|
1178
|
-
}, window.addEventListener("popstate",
|
|
1196
|
+
return i(), s.apply(this, arguments);
|
|
1197
|
+
}, window.addEventListener("popstate", i);
|
|
1179
1198
|
}
|
|
1180
1199
|
getConfig() {
|
|
1181
1200
|
return this.config;
|
|
@@ -1191,20 +1210,20 @@ class we {
|
|
|
1191
1210
|
this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
|
|
1192
1211
|
}
|
|
1193
1212
|
set(e, t) {
|
|
1194
|
-
if (!
|
|
1213
|
+
if (!v(e))
|
|
1195
1214
|
throw new Error("Properties must be an object");
|
|
1196
|
-
const
|
|
1197
|
-
if (
|
|
1198
|
-
let r = this.persistence.get(`props_${
|
|
1199
|
-
r = { ...r, ...e }, this.persistence.set(`props_${
|
|
1215
|
+
const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
|
|
1216
|
+
if (i) {
|
|
1217
|
+
let r = this.persistence.get(`props_${i}`) || {};
|
|
1218
|
+
r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
|
|
1200
1219
|
} else {
|
|
1201
1220
|
let r = this.persistence.get("global_props") || {};
|
|
1202
1221
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1203
1222
|
}
|
|
1204
|
-
|
|
1223
|
+
s && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1205
1224
|
properties: e,
|
|
1206
|
-
eventType:
|
|
1207
|
-
persist:
|
|
1225
|
+
eventType: i || "global",
|
|
1226
|
+
persist: s
|
|
1208
1227
|
});
|
|
1209
1228
|
}
|
|
1210
1229
|
setUserId(e) {
|
|
@@ -1213,109 +1232,141 @@ class we {
|
|
|
1213
1232
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1214
1233
|
}
|
|
1215
1234
|
unset(e, t) {
|
|
1216
|
-
const
|
|
1217
|
-
if (
|
|
1218
|
-
let r = this.persistence.get(`props_${
|
|
1219
|
-
delete r[e], this.persistence.set(`props_${
|
|
1235
|
+
const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
|
|
1236
|
+
if (i) {
|
|
1237
|
+
let r = this.persistence.get(`props_${i}`) || {};
|
|
1238
|
+
delete r[e], this.persistence.set(`props_${i}`, r);
|
|
1220
1239
|
} else {
|
|
1221
1240
|
let r = this.persistence.get("global_props") || {};
|
|
1222
1241
|
delete r[e], this.persistence.set("global_props", r);
|
|
1223
1242
|
}
|
|
1224
|
-
|
|
1243
|
+
s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
|
|
1225
1244
|
}
|
|
1226
1245
|
}
|
|
1227
|
-
function
|
|
1228
|
-
|
|
1229
|
-
|
|
1246
|
+
function X() {
|
|
1247
|
+
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1248
|
+
}
|
|
1249
|
+
function Pe() {
|
|
1250
|
+
return X() ? window.define : void 0;
|
|
1251
|
+
}
|
|
1252
|
+
const Ae = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1253
|
+
function C(n) {
|
|
1254
|
+
const e = JSON.parse(JSON.stringify(n)), t = I(e), i = { ...q, ...t };
|
|
1255
|
+
if (!i.key)
|
|
1230
1256
|
throw new Error("API key is required!");
|
|
1231
|
-
if (!
|
|
1257
|
+
if (!i.trackingHost)
|
|
1232
1258
|
throw new Error("Tracking host is required!");
|
|
1233
|
-
|
|
1259
|
+
const s = i.key || "", r = `${Ae}${s}`;
|
|
1260
|
+
return u() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), u() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new S(i);
|
|
1234
1261
|
}
|
|
1235
|
-
function
|
|
1236
|
-
var
|
|
1262
|
+
function $e(n) {
|
|
1263
|
+
var s;
|
|
1237
1264
|
const e = {
|
|
1238
|
-
key:
|
|
1239
|
-
trackingHost:
|
|
1240
|
-
logLevel:
|
|
1241
|
-
autocapture:
|
|
1242
|
-
formTracking:
|
|
1243
|
-
autoPageview:
|
|
1244
|
-
useBeaconApi:
|
|
1245
|
-
forceUseFetch:
|
|
1246
|
-
gaHook:
|
|
1247
|
-
segmentHook:
|
|
1248
|
-
randomizeUrl:
|
|
1249
|
-
capture3rdPartyCookies:
|
|
1250
|
-
idMethod:
|
|
1251
|
-
privacyPolicy:
|
|
1252
|
-
ipPolicy:
|
|
1253
|
-
cookiePolicy:
|
|
1254
|
-
minSendTimeout: parseInt(
|
|
1255
|
-
maxSendTimeout: parseInt(
|
|
1256
|
-
maxSendAttempts: parseInt(
|
|
1257
|
-
propertiesStringMaxLength: parseInt(
|
|
1258
|
-
propertyBlacklist: ((
|
|
1259
|
-
exclude:
|
|
1260
|
-
namespace:
|
|
1261
|
-
crossDomainLinking:
|
|
1262
|
-
domains:
|
|
1263
|
-
maskAllText:
|
|
1264
|
-
maskAllElementAttributes:
|
|
1265
|
+
key: n.getAttribute("data-key") || void 0,
|
|
1266
|
+
trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1267
|
+
logLevel: pe(n.getAttribute("data-log-level")),
|
|
1268
|
+
autocapture: n.getAttribute("data-autocapture") === "true",
|
|
1269
|
+
formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
|
|
1270
|
+
autoPageview: n.getAttribute("data-auto-pageview") === "true",
|
|
1271
|
+
useBeaconApi: n.getAttribute("data-use-beacon-api") === "true",
|
|
1272
|
+
forceUseFetch: n.getAttribute("data-force-use-fetch") === "true",
|
|
1273
|
+
gaHook: n.getAttribute("data-ga-hook") === "true",
|
|
1274
|
+
segmentHook: n.getAttribute("data-segment-hook") === "true",
|
|
1275
|
+
randomizeUrl: n.getAttribute("data-randomize-url") === "true",
|
|
1276
|
+
capture3rdPartyCookies: n.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
|
|
1277
|
+
idMethod: n.getAttribute("data-id-method") || void 0,
|
|
1278
|
+
privacyPolicy: n.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
|
|
1279
|
+
ipPolicy: n.getAttribute("data-ip-policy") || void 0,
|
|
1280
|
+
cookiePolicy: n.getAttribute("data-cookie-policy") || void 0,
|
|
1281
|
+
minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1282
|
+
maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1283
|
+
maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1284
|
+
propertiesStringMaxLength: parseInt(n.getAttribute("data-properties-string-max-length") || "", 10) || null,
|
|
1285
|
+
propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
|
|
1286
|
+
exclude: n.getAttribute("data-exclude") || void 0,
|
|
1287
|
+
namespace: n.getAttribute("data-namespace") || void 0,
|
|
1288
|
+
crossDomainLinking: n.getAttribute("data-cross-domain-linking") !== "false",
|
|
1289
|
+
domains: n.getAttribute("data-domains") || void 0,
|
|
1290
|
+
maskAllText: n.getAttribute("data-mask-all-text") === "true",
|
|
1291
|
+
maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1265
1292
|
};
|
|
1266
1293
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1267
|
-
const t =
|
|
1268
|
-
u() && t.pageview(),
|
|
1294
|
+
const t = C(e), i = e.namespace || "usermaven";
|
|
1295
|
+
return u() && e.autoPageview !== !1 && t.pageview(), Se(i, t), t;
|
|
1269
1296
|
}
|
|
1270
|
-
function
|
|
1297
|
+
function Se(n, e) {
|
|
1271
1298
|
let t = !1;
|
|
1272
|
-
const
|
|
1299
|
+
const i = [], s = [];
|
|
1273
1300
|
function r() {
|
|
1274
|
-
for (;
|
|
1275
|
-
const a =
|
|
1276
|
-
a && window[
|
|
1301
|
+
for (; i.length > 0; ) {
|
|
1302
|
+
const a = i.shift();
|
|
1303
|
+
a && window[n].apply(null, a);
|
|
1277
1304
|
}
|
|
1278
1305
|
}
|
|
1279
1306
|
function o() {
|
|
1280
|
-
|
|
1307
|
+
s.forEach((a) => a()), s.length = 0;
|
|
1281
1308
|
}
|
|
1282
|
-
window[
|
|
1309
|
+
window[n] = function(...a) {
|
|
1283
1310
|
const h = a[0];
|
|
1284
1311
|
if (h === "onLoad") {
|
|
1285
|
-
typeof a[1] == "function" && (t ? a[1]() :
|
|
1312
|
+
typeof a[1] == "function" && (t ? a[1]() : s.push(a[1]));
|
|
1286
1313
|
return;
|
|
1287
1314
|
}
|
|
1288
1315
|
if (!t) {
|
|
1289
|
-
|
|
1316
|
+
i.push(a);
|
|
1290
1317
|
return;
|
|
1291
1318
|
}
|
|
1292
1319
|
if (typeof e[h] == "function")
|
|
1293
1320
|
return e[h].apply(e, a.slice(1));
|
|
1294
1321
|
console.error(`Method ${h} not found on UsermavenClient`);
|
|
1295
1322
|
};
|
|
1296
|
-
const c = `${
|
|
1323
|
+
const c = `${n}Q`, l = window[c] || [];
|
|
1297
1324
|
for (window[c] = l, l.push = function(...a) {
|
|
1298
|
-
return window[
|
|
1325
|
+
return window[n].apply(null, a), Array.prototype.push.apply(this, a);
|
|
1299
1326
|
}, setTimeout(() => {
|
|
1300
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1327
|
+
t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
|
|
1301
1328
|
}, 0); l.length > 0; ) {
|
|
1302
1329
|
const a = l.shift();
|
|
1303
|
-
a &&
|
|
1330
|
+
a && i.push(a);
|
|
1304
1331
|
}
|
|
1305
1332
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1333
|
+
let M = !1, H = null;
|
|
1334
|
+
if (u()) {
|
|
1335
|
+
const n = Pe();
|
|
1336
|
+
n && n("usermaven", [], function() {
|
|
1337
|
+
return {
|
|
1338
|
+
usermavenClient: C,
|
|
1339
|
+
UsermavenClient: S,
|
|
1340
|
+
LogLevel: p,
|
|
1341
|
+
// Expose the script tag client if it exists
|
|
1342
|
+
getScriptTagClient: () => H
|
|
1343
|
+
};
|
|
1344
|
+
}), typeof window < "u" && (window.usermavenClient = C, window.UsermavenClient = S, window.usermavenScriptTagClient = () => H), function(e, t) {
|
|
1345
|
+
const i = e.currentScript;
|
|
1346
|
+
function s() {
|
|
1347
|
+
return M || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1348
|
+
}
|
|
1349
|
+
function r() {
|
|
1350
|
+
s() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(i), M = !0);
|
|
1351
|
+
}
|
|
1352
|
+
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1353
|
+
}(document, window);
|
|
1354
|
+
}
|
|
1355
|
+
typeof module < "u" && module.exports && !X() && (module.exports = {
|
|
1356
|
+
usermavenClient: C,
|
|
1357
|
+
UsermavenClient: S,
|
|
1358
|
+
Config: void 0,
|
|
1359
|
+
UserProps: void 0,
|
|
1360
|
+
EventPayload: void 0,
|
|
1361
|
+
LogLevel: p,
|
|
1362
|
+
ClientProperties: void 0
|
|
1363
|
+
});
|
|
1313
1364
|
|
|
1314
1365
|
function createClient(params) {
|
|
1315
1366
|
if (typeof window === 'undefined') {
|
|
1316
1367
|
return null;
|
|
1317
1368
|
}
|
|
1318
|
-
return
|
|
1369
|
+
return C(params);
|
|
1319
1370
|
}
|
|
1320
1371
|
|
|
1321
1372
|
/******************************************************************************
|