@usermaven/react 1.5.10 → 1.5.11
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/client.d.ts +1 -1
- package/lib/index.es.js +747 -477
- package/lib/usePageView.d.ts +2 -2
- package/lib/useUsermaven.d.ts +2 -1
- package/lib/useUsermaven.js +3 -1
- package/package.json +2 -2
package/lib/index.es.js
CHANGED
|
@@ -8,8 +8,8 @@ const UsermavenProvider = ({ children, client }) => {
|
|
|
8
8
|
return React.createElement(Context.Provider, { value: client }, children);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
class
|
|
11
|
+
var _ = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(_ || {});
|
|
12
|
+
class se {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
this.level = e;
|
|
15
15
|
}
|
|
@@ -26,11 +26,11 @@ class ie {
|
|
|
26
26
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return new
|
|
29
|
+
function p(s = 0) {
|
|
30
|
+
return new se(s);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
logLevel:
|
|
32
|
+
const Y = {
|
|
33
|
+
logLevel: _.ERROR,
|
|
34
34
|
useBeaconApi: !1,
|
|
35
35
|
forceUseFetch: !1,
|
|
36
36
|
trackingHost: "t.usermaven.com",
|
|
@@ -42,7 +42,13 @@ const X = {
|
|
|
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",
|
|
@@ -59,16 +65,16 @@ 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()}`,
|
|
66
|
-
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${
|
|
71
|
+
const a = `expires=${o.toUTCString()}`, c = n ? "; Secure" : "", h = r ? "; HttpOnly" : "";
|
|
72
|
+
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${c}${h}`;
|
|
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,84 +102,84 @@ class ne {
|
|
|
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
|
|
108
|
-
function
|
|
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, I = ae.forEach, F = {};
|
|
114
|
+
function ce(s, e, t) {
|
|
115
|
+
if (Array.isArray(s)) {
|
|
116
|
+
if (I && s.forEach === I)
|
|
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) === F)
|
|
115
121
|
return;
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
},
|
|
122
|
-
for (const e in
|
|
123
|
-
typeof
|
|
125
|
+
const v = 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
|
|
126
|
-
if (
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
else if ("length" in
|
|
130
|
-
for (let i = 0,
|
|
131
|
-
if (i in
|
|
131
|
+
function k(s, e, t) {
|
|
132
|
+
if (s != null) {
|
|
133
|
+
if (I && Array.isArray(s) && s.forEach === I)
|
|
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) === F)
|
|
132
138
|
return;
|
|
133
139
|
} else
|
|
134
|
-
for (const i in
|
|
135
|
-
if (
|
|
140
|
+
for (const i in s)
|
|
141
|
+
if (oe.call(s, i) && e.call(t, s[i], i) === F)
|
|
136
142
|
return;
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
|
-
const
|
|
140
|
-
return
|
|
145
|
+
const ue = function(s, ...e) {
|
|
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 $(s, e) {
|
|
152
|
+
return s.indexOf(e) !== -1;
|
|
147
153
|
}
|
|
148
|
-
const
|
|
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
|
-
},
|
|
155
|
-
return
|
|
156
|
-
},
|
|
157
|
-
const
|
|
160
|
+
}, de = function(s) {
|
|
161
|
+
return s === void 0;
|
|
162
|
+
}, A = function() {
|
|
163
|
+
const s = function(i, n, r, o, a) {
|
|
158
164
|
if (!i) {
|
|
159
|
-
|
|
165
|
+
p().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
|
|
166
|
-
i[
|
|
171
|
+
const c = "on" + n, h = i[c];
|
|
172
|
+
i[c] = e(i, r, h);
|
|
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
|
-
let a = !0,
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
return (
|
|
179
|
+
let a = !0, c;
|
|
180
|
+
he(r) && (c = r(o));
|
|
181
|
+
const h = n.call(i, o);
|
|
182
|
+
return (c === !1 || h === !1) && (a = !1), a;
|
|
177
183
|
};
|
|
178
184
|
}
|
|
179
185
|
function t(i) {
|
|
@@ -183,105 +189,121 @@ const ue = function(n) {
|
|
|
183
189
|
this.returnValue = !1;
|
|
184
190
|
}, t.stopPropagation = function() {
|
|
185
191
|
this.cancelBubble = !0;
|
|
186
|
-
},
|
|
187
|
-
}(),
|
|
192
|
+
}, s;
|
|
193
|
+
}(), fe = function(s) {
|
|
188
194
|
return function(...e) {
|
|
189
195
|
try {
|
|
190
|
-
return
|
|
196
|
+
return s.apply(this, e);
|
|
191
197
|
} catch (t) {
|
|
192
|
-
|
|
198
|
+
p().error(
|
|
199
|
+
"Implementation error. Please turn on debug and contact support@usermaven.com.",
|
|
200
|
+
t
|
|
201
|
+
);
|
|
193
202
|
}
|
|
194
203
|
};
|
|
195
|
-
},
|
|
196
|
-
for (const e in
|
|
197
|
-
typeof
|
|
204
|
+
}, G = function(s) {
|
|
205
|
+
for (const e in s)
|
|
206
|
+
typeof s[e] == "function" && (s[e] = fe(s[e]));
|
|
198
207
|
};
|
|
199
|
-
function
|
|
200
|
-
for (let e in
|
|
201
|
-
(
|
|
202
|
-
return
|
|
208
|
+
function V(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
|
-
function
|
|
213
|
+
function d() {
|
|
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 p().warn("window is not available"), !1;
|
|
209
218
|
}
|
|
210
219
|
}
|
|
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,
|
|
220
|
+
function E(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 ge(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 Q(s) {
|
|
231
|
+
return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(Q) : Object.keys(s).reduce(
|
|
232
|
+
(e, t) => {
|
|
233
|
+
const i = ge(t);
|
|
234
|
+
return e[i] = Q(s[t]), e;
|
|
235
|
+
},
|
|
236
|
+
{}
|
|
237
|
+
);
|
|
226
238
|
}
|
|
227
|
-
function
|
|
228
|
-
switch (typeof
|
|
239
|
+
function O(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 J(s) {
|
|
238
250
|
let e = "";
|
|
239
|
-
return
|
|
240
|
-
|
|
241
|
-
}),
|
|
251
|
+
return z(s) && !ee(s) && s.childNodes && s.childNodes.length && k(s.childNodes, function(t) {
|
|
252
|
+
j(t) && t.textContent && (e += v(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
253
|
+
}), v(e);
|
|
242
254
|
}
|
|
243
|
-
function
|
|
244
|
-
return !!
|
|
255
|
+
function b(s) {
|
|
256
|
+
return !!s && s.nodeType === 1;
|
|
245
257
|
}
|
|
246
|
-
function
|
|
247
|
-
return !!
|
|
258
|
+
function w(s, e) {
|
|
259
|
+
return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
|
|
248
260
|
}
|
|
249
|
-
function
|
|
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
|
|
256
|
-
|
|
257
|
-
|
|
267
|
+
const T = [
|
|
268
|
+
"a",
|
|
269
|
+
"button",
|
|
270
|
+
"form",
|
|
271
|
+
"input",
|
|
272
|
+
"select",
|
|
273
|
+
"textarea",
|
|
274
|
+
"label"
|
|
275
|
+
];
|
|
276
|
+
function pe(s, e) {
|
|
277
|
+
var o, a;
|
|
278
|
+
if (!s || w(s, "html") || !b(s))
|
|
258
279
|
return !1;
|
|
259
|
-
let t =
|
|
260
|
-
for (; t && !
|
|
280
|
+
let t = s;
|
|
281
|
+
for (; t && !w(t, "body"); ) {
|
|
261
282
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
262
283
|
return !1;
|
|
263
|
-
t.parentNode &&
|
|
284
|
+
t.parentNode && q(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
264
285
|
}
|
|
265
286
|
let i = !1;
|
|
266
|
-
for (t =
|
|
267
|
-
if (t.parentNode &&
|
|
268
|
-
t = t.parentNode.host, t &&
|
|
287
|
+
for (t = s; t && !w(t, "body"); ) {
|
|
288
|
+
if (t.parentNode && q(t.parentNode)) {
|
|
289
|
+
t = t.parentNode.host, t && b(t) && T.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
269
290
|
continue;
|
|
270
291
|
}
|
|
271
|
-
const
|
|
272
|
-
if (!
|
|
273
|
-
if (
|
|
292
|
+
const c = t.parentNode;
|
|
293
|
+
if (!c || !b(c)) break;
|
|
294
|
+
if (T.indexOf(c.tagName.toLowerCase()) > -1)
|
|
274
295
|
i = !0;
|
|
275
296
|
else {
|
|
276
|
-
const
|
|
277
|
-
|
|
297
|
+
const h = window.getComputedStyle(c);
|
|
298
|
+
h && h.getPropertyValue("cursor") === "pointer" && (i = !0);
|
|
278
299
|
}
|
|
279
|
-
t =
|
|
300
|
+
t = c;
|
|
280
301
|
}
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
302
|
+
const n = window.getComputedStyle(s);
|
|
303
|
+
if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
|
|
283
304
|
return !0;
|
|
284
|
-
const r =
|
|
305
|
+
const r = (a = (o = s.tagName) == null ? void 0 : o.toLowerCase) == null ? void 0 : a.call(o);
|
|
306
|
+
if (!r) return !1;
|
|
285
307
|
switch (r) {
|
|
286
308
|
case "html":
|
|
287
309
|
return !1;
|
|
@@ -293,18 +315,18 @@ function ge(n, e) {
|
|
|
293
315
|
case "textarea":
|
|
294
316
|
return e.type === "change" || e.type === "click";
|
|
295
317
|
default:
|
|
296
|
-
return i ? e.type === "click" : e.type === "click" && (
|
|
318
|
+
return i ? e.type === "click" : e.type === "click" && (T.indexOf(r) > -1 || s.getAttribute("contenteditable") === "true");
|
|
297
319
|
}
|
|
298
320
|
}
|
|
299
|
-
function
|
|
300
|
-
for (let i =
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
321
|
+
function z(s) {
|
|
322
|
+
for (let i = s; i.parentNode && !w(i, "body"); i = i.parentNode) {
|
|
323
|
+
const n = O(i).split(" ");
|
|
324
|
+
if ($(n, "ph-sensitive") || $(n, "ph-no-capture"))
|
|
303
325
|
return !1;
|
|
304
326
|
}
|
|
305
|
-
if (
|
|
327
|
+
if ($(O(s).split(" "), "ph-include"))
|
|
306
328
|
return !0;
|
|
307
|
-
const e =
|
|
329
|
+
const e = s.type || "";
|
|
308
330
|
if (typeof e == "string")
|
|
309
331
|
switch (e.toLowerCase()) {
|
|
310
332
|
case "hidden":
|
|
@@ -312,61 +334,89 @@ function M(n) {
|
|
|
312
334
|
case "password":
|
|
313
335
|
return !1;
|
|
314
336
|
}
|
|
315
|
-
const t =
|
|
337
|
+
const t = s.name || s.id || "";
|
|
316
338
|
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
339
|
}
|
|
318
|
-
function
|
|
340
|
+
function ee(s) {
|
|
319
341
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
320
|
-
return !!(
|
|
342
|
+
return !!(w(s, "input") && !e.includes(s.type) || w(s, "select") || w(s, "textarea") || s.getAttribute("contenteditable") === "true");
|
|
343
|
+
}
|
|
344
|
+
function H(s) {
|
|
345
|
+
return !(s === null || de(s) || typeof s == "string" && (s = v(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)));
|
|
321
346
|
}
|
|
322
|
-
function
|
|
323
|
-
return
|
|
347
|
+
function me(s) {
|
|
348
|
+
return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
|
|
324
349
|
}
|
|
325
|
-
function
|
|
326
|
-
|
|
350
|
+
function ye(s) {
|
|
351
|
+
if (!s)
|
|
352
|
+
return !1;
|
|
353
|
+
const e = s.$el_text;
|
|
354
|
+
if (typeof e == "string" && v(e).length > 0)
|
|
355
|
+
return !0;
|
|
356
|
+
const t = s.classes;
|
|
357
|
+
if (Array.isArray(t) && t.some((n) => v(n).length > 0))
|
|
358
|
+
return !0;
|
|
359
|
+
const i = [
|
|
360
|
+
"attr__id",
|
|
361
|
+
"attr__name",
|
|
362
|
+
"attr__class",
|
|
363
|
+
"attr__aria-label",
|
|
364
|
+
"attr__aria-labelledby",
|
|
365
|
+
"attr__label",
|
|
366
|
+
"attr__href"
|
|
367
|
+
];
|
|
368
|
+
for (const n of i) {
|
|
369
|
+
const r = s[n];
|
|
370
|
+
if (typeof r == "string" && v(r).length > 0)
|
|
371
|
+
return !0;
|
|
372
|
+
}
|
|
373
|
+
for (const [n, r] of Object.entries(s))
|
|
374
|
+
if (n.startsWith("attr__data-") && typeof r == "string" && v(r).length > 0)
|
|
375
|
+
return !0;
|
|
376
|
+
return !1;
|
|
327
377
|
}
|
|
328
|
-
function
|
|
329
|
-
return
|
|
378
|
+
function x() {
|
|
379
|
+
return E(10);
|
|
330
380
|
}
|
|
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(
|
|
381
|
+
function W(s) {
|
|
382
|
+
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
383
|
}
|
|
334
|
-
function
|
|
384
|
+
function we(s, e) {
|
|
335
385
|
let t;
|
|
336
386
|
return function(...i) {
|
|
337
|
-
const
|
|
338
|
-
clearTimeout(t),
|
|
387
|
+
const n = () => {
|
|
388
|
+
clearTimeout(t), s(...i);
|
|
339
389
|
};
|
|
340
|
-
clearTimeout(t), t = setTimeout(
|
|
390
|
+
clearTimeout(t), t = setTimeout(n, e);
|
|
341
391
|
};
|
|
342
392
|
}
|
|
343
|
-
function
|
|
344
|
-
const e = {}, t =
|
|
393
|
+
function ke(s) {
|
|
394
|
+
const e = {}, t = s.replace(/^\?/, "").split("&");
|
|
345
395
|
for (let i = 0; i < t.length; i++) {
|
|
346
|
-
const
|
|
347
|
-
|
|
396
|
+
const n = t[i].split("=");
|
|
397
|
+
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
348
398
|
}
|
|
349
399
|
return e;
|
|
350
400
|
}
|
|
351
|
-
function
|
|
352
|
-
return typeof
|
|
401
|
+
function U(s) {
|
|
402
|
+
return typeof s == "string" || s instanceof String;
|
|
353
403
|
}
|
|
354
|
-
function
|
|
355
|
-
return
|
|
404
|
+
function S(s) {
|
|
405
|
+
return s !== null && typeof s == "object" && s.constructor === Object;
|
|
356
406
|
}
|
|
357
|
-
function
|
|
358
|
-
if (
|
|
359
|
-
return
|
|
360
|
-
const e =
|
|
361
|
-
return t || t === 0 ? t :
|
|
407
|
+
function ve(s) {
|
|
408
|
+
if (s === null)
|
|
409
|
+
return _.ERROR;
|
|
410
|
+
const e = s.toUpperCase(), t = _[e];
|
|
411
|
+
return t || t === 0 ? t : _.ERROR;
|
|
362
412
|
}
|
|
363
|
-
const
|
|
364
|
-
let
|
|
365
|
-
return typeof window < "u" && window.localStorage && (
|
|
413
|
+
const be = () => {
|
|
414
|
+
let s = "false";
|
|
415
|
+
return typeof window < "u" && window.localStorage && (s = localStorage.getItem("um_exclusion")), !(s == null || s === "false");
|
|
366
416
|
};
|
|
367
417
|
class _e {
|
|
368
418
|
constructor(e) {
|
|
369
|
-
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll =
|
|
419
|
+
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = we(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
370
420
|
}
|
|
371
421
|
initializeEventListener() {
|
|
372
422
|
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
@@ -390,8 +440,8 @@ class _e {
|
|
|
390
440
|
this.track();
|
|
391
441
|
}
|
|
392
442
|
getScrollDepth() {
|
|
393
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(),
|
|
394
|
-
return Math.min(100, Math.floor(i /
|
|
443
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
|
|
444
|
+
return Math.min(100, Math.floor(i / n * 100));
|
|
395
445
|
}
|
|
396
446
|
getWindowHeight() {
|
|
397
447
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -410,17 +460,19 @@ class _e {
|
|
|
410
460
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
411
461
|
}
|
|
412
462
|
checkMilestones(e) {
|
|
413
|
-
this.milestones.filter(
|
|
414
|
-
|
|
463
|
+
this.milestones.filter(
|
|
464
|
+
(i) => e >= i
|
|
465
|
+
).forEach((i) => {
|
|
466
|
+
this.send(), this.milestones = this.milestones.filter((n) => n !== i);
|
|
415
467
|
});
|
|
416
468
|
}
|
|
417
469
|
destroy() {
|
|
418
470
|
window.removeEventListener("scroll", this.debouncedHandleScroll);
|
|
419
471
|
}
|
|
420
472
|
}
|
|
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 _e(e),
|
|
473
|
+
const D = class D {
|
|
474
|
+
constructor(e, t, i = p()) {
|
|
475
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), le(this), G(this);
|
|
424
476
|
}
|
|
425
477
|
isBrowserSupported() {
|
|
426
478
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -435,7 +487,9 @@ const R = class R {
|
|
|
435
487
|
return;
|
|
436
488
|
}
|
|
437
489
|
if (!(document && document.body)) {
|
|
438
|
-
this.logger.debug(
|
|
490
|
+
this.logger.debug(
|
|
491
|
+
"Document not ready yet, trying again in 500 milliseconds..."
|
|
492
|
+
), setTimeout(() => this.init(), 500);
|
|
439
493
|
return;
|
|
440
494
|
}
|
|
441
495
|
this.addDomEventHandlers(), this.domHandlersAttached = !0;
|
|
@@ -444,7 +498,7 @@ const R = class R {
|
|
|
444
498
|
const e = (t) => {
|
|
445
499
|
t = t || window.event, this.captureEvent(t);
|
|
446
500
|
};
|
|
447
|
-
|
|
501
|
+
A(document, "submit", e, !1, !0), A(document, "change", e, !1, !0), A(document, "click", e, !1, !0), A(document, "visibilitychange", e, !1, !0), A(document, "scroll", e, !1, !0), A(window, "popstate", e, !1, !0);
|
|
448
502
|
}
|
|
449
503
|
isPageRefresh() {
|
|
450
504
|
if ("PerformanceNavigationTiming" in window) {
|
|
@@ -455,84 +509,94 @@ const R = class R {
|
|
|
455
509
|
return performance.navigation && performance.navigation.type === 1;
|
|
456
510
|
}
|
|
457
511
|
captureEvent(e) {
|
|
458
|
-
var i,
|
|
512
|
+
var i, n;
|
|
459
513
|
let t = this.getEventTarget(e);
|
|
460
|
-
if (
|
|
514
|
+
if (j(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
461
515
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
462
516
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
463
|
-
return this.isPageRefresh() || (
|
|
464
|
-
if (t &&
|
|
517
|
+
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
518
|
+
if (!(!t || !b(t)) && t && pe(t, e)) {
|
|
465
519
|
const r = [t];
|
|
466
520
|
let o = t;
|
|
467
|
-
for (; o.parentNode && !
|
|
468
|
-
if (
|
|
469
|
-
|
|
521
|
+
for (; o != null && o.parentNode && !w(o, "body"); ) {
|
|
522
|
+
if (q(o == null ? void 0 : o.parentNode)) {
|
|
523
|
+
const g = (o == null ? void 0 : o.parentNode).host;
|
|
524
|
+
g && b(g) && r.push(g), o = g;
|
|
470
525
|
continue;
|
|
471
526
|
}
|
|
472
|
-
|
|
527
|
+
const l = o == null ? void 0 : o.parentNode;
|
|
528
|
+
if (!l || !b(l)) break;
|
|
529
|
+
r.push(l), o = l;
|
|
473
530
|
}
|
|
474
531
|
const a = [];
|
|
475
|
-
let
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
|
|
532
|
+
let c, h = !1;
|
|
533
|
+
if (k(r, (l) => {
|
|
534
|
+
if (!l.tagName)
|
|
535
|
+
return;
|
|
536
|
+
const g = z(l);
|
|
537
|
+
l.tagName.toLowerCase() === "a" && (c = l.getAttribute("href"), c = g && H(c) && c);
|
|
538
|
+
const u = O(l).split(" ");
|
|
539
|
+
$(u, "ph-no-capture") && (h = !0), a.push(
|
|
481
540
|
this.getPropertiesFromElement(
|
|
482
|
-
|
|
541
|
+
l,
|
|
483
542
|
this.options.maskAllElementAttributes ?? !1,
|
|
484
543
|
this.options.maskAllText ?? !1
|
|
485
544
|
)
|
|
486
545
|
);
|
|
487
|
-
}), this.options.maskAllText || (a[0].$el_text =
|
|
546
|
+
}), this.options.maskAllText || (a[0].$el_text = J(t)), c && (a[0].attr__href = c), h)
|
|
488
547
|
return !1;
|
|
489
|
-
|
|
548
|
+
if (!ye(a[0]))
|
|
549
|
+
return this.logger.debug("Dropping autocapture event without identifiers."), !1;
|
|
550
|
+
const f = ue(
|
|
490
551
|
this.getDefaultProperties(e.type),
|
|
491
552
|
{
|
|
492
553
|
$elements: a
|
|
493
554
|
},
|
|
494
555
|
this.getCustomProperties(r)
|
|
495
556
|
);
|
|
496
|
-
return this.client.track("$autocapture",
|
|
557
|
+
return this.client.track("$autocapture", f), !0;
|
|
497
558
|
}
|
|
498
559
|
}
|
|
499
560
|
getCustomProperties(e) {
|
|
500
561
|
const t = {};
|
|
501
|
-
return
|
|
502
|
-
|
|
503
|
-
const r = document.querySelectorAll(
|
|
504
|
-
|
|
505
|
-
|
|
562
|
+
return k(this.customProperties, (i) => {
|
|
563
|
+
k(i.event_selectors, (n) => {
|
|
564
|
+
const r = document.querySelectorAll(n);
|
|
565
|
+
k(r, (o) => {
|
|
566
|
+
$(e, o) && z(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
506
567
|
});
|
|
507
568
|
});
|
|
508
569
|
}), t;
|
|
509
570
|
}
|
|
510
571
|
extractCustomPropertyValue(e) {
|
|
511
572
|
const t = [];
|
|
512
|
-
return
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
573
|
+
return k(
|
|
574
|
+
document.querySelectorAll(e.css_selector),
|
|
575
|
+
function(i) {
|
|
576
|
+
let n;
|
|
577
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? n = i.value : i.textContent && (n = i.textContent), H(n) && t.push(n);
|
|
578
|
+
}
|
|
579
|
+
), t.join(", ");
|
|
516
580
|
}
|
|
517
581
|
getEventTarget(e) {
|
|
518
582
|
var t;
|
|
519
583
|
return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
520
584
|
}
|
|
521
585
|
getPropertiesFromElement(e, t, i) {
|
|
522
|
-
const
|
|
523
|
-
tag_name:
|
|
586
|
+
const n = e.tagName.toLowerCase(), r = {
|
|
587
|
+
tag_name: n
|
|
524
588
|
};
|
|
525
|
-
|
|
526
|
-
const o =
|
|
527
|
-
o.length > 0 && (r.classes = o.split(" ").filter(function(
|
|
528
|
-
return
|
|
529
|
-
})),
|
|
530
|
-
|
|
589
|
+
T.indexOf(n) > -1 && !i && (r.$el_text = J(e));
|
|
590
|
+
const o = O(e);
|
|
591
|
+
o.length > 0 && (r.classes = o.split(" ").filter(function(f) {
|
|
592
|
+
return f !== "";
|
|
593
|
+
})), k(e.attributes, function(f) {
|
|
594
|
+
ee(e) && ["name", "id", "class"].indexOf(f.name) === -1 || !t && H(f.value) && !me(f.name) && (r["attr__" + f.name] = f.value);
|
|
531
595
|
});
|
|
532
|
-
let a = 1,
|
|
533
|
-
for (;
|
|
534
|
-
a++,
|
|
535
|
-
return r.nth_child = a, r.nth_of_type =
|
|
596
|
+
let a = 1, c = 1, h = e;
|
|
597
|
+
for (; h = this.previousElementSibling(h); )
|
|
598
|
+
a++, h.tagName === e.tagName && c++;
|
|
599
|
+
return r.nth_child = a, r.nth_of_type = c, r;
|
|
536
600
|
}
|
|
537
601
|
previousElementSibling(e) {
|
|
538
602
|
if (e.previousElementSibling)
|
|
@@ -541,7 +605,7 @@ const R = class R {
|
|
|
541
605
|
let t = e;
|
|
542
606
|
do
|
|
543
607
|
t = t.previousSibling;
|
|
544
|
-
while (t && !
|
|
608
|
+
while (t && !b(t));
|
|
545
609
|
return t;
|
|
546
610
|
}
|
|
547
611
|
}
|
|
@@ -557,15 +621,15 @@ const R = class R {
|
|
|
557
621
|
static enabledForProject(e, t = 10, i = 10) {
|
|
558
622
|
if (!e)
|
|
559
623
|
return !1;
|
|
560
|
-
let
|
|
624
|
+
let n = 0;
|
|
561
625
|
for (let r = 0; r < e.length; r++)
|
|
562
|
-
|
|
563
|
-
return
|
|
626
|
+
n += e.charCodeAt(r);
|
|
627
|
+
return n % t < i;
|
|
564
628
|
}
|
|
565
629
|
};
|
|
566
|
-
|
|
567
|
-
let
|
|
568
|
-
class
|
|
630
|
+
D.FORCE_CAPTURE_ATTR = "data-um-force-capture", D.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
631
|
+
let N = D;
|
|
632
|
+
class Ee {
|
|
569
633
|
constructor(e) {
|
|
570
634
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
571
635
|
}
|
|
@@ -594,44 +658,48 @@ class be {
|
|
|
594
658
|
}));
|
|
595
659
|
}
|
|
596
660
|
}
|
|
597
|
-
class
|
|
598
|
-
constructor(e, t, i =
|
|
661
|
+
class Pe {
|
|
662
|
+
constructor(e, t, i = p()) {
|
|
599
663
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
600
664
|
}
|
|
601
665
|
async send(e) {
|
|
602
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
603
|
-
|
|
604
|
-
|
|
666
|
+
const t = this.config.key, i = this.constructUrl(t), n = new Blob([JSON.stringify(e)], {
|
|
667
|
+
type: "application/json"
|
|
668
|
+
});
|
|
669
|
+
if (navigator.sendBeacon(i, n))
|
|
670
|
+
this.logger.debug(
|
|
671
|
+
`Successfully queued ${e.length} event(s) via Beacon API`
|
|
672
|
+
);
|
|
605
673
|
else
|
|
606
674
|
throw new Error("Failed to queue events via Beacon API");
|
|
607
675
|
}
|
|
608
676
|
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.${
|
|
677
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
678
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
611
679
|
}
|
|
612
680
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
613
681
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
614
682
|
}
|
|
615
|
-
class
|
|
616
|
-
constructor(e, t, i =
|
|
683
|
+
class K {
|
|
684
|
+
constructor(e, t, i = p()) {
|
|
617
685
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
618
686
|
}
|
|
619
687
|
async send(e) {
|
|
620
|
-
const t = this.config.key, i = this.constructUrl(t),
|
|
688
|
+
const t = this.config.key, i = this.constructUrl(t), n = JSON.stringify(e), r = {
|
|
621
689
|
"Content-Type": "application/json",
|
|
622
690
|
...this.getCustomHeaders()
|
|
623
691
|
}, o = await fetch(i, {
|
|
624
692
|
method: "POST",
|
|
625
693
|
headers: r,
|
|
626
|
-
body:
|
|
694
|
+
body: n
|
|
627
695
|
});
|
|
628
696
|
if (!o.ok)
|
|
629
697
|
throw new Error(`HTTP error! status: ${o.status}`);
|
|
630
698
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
631
699
|
}
|
|
632
700
|
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.${
|
|
701
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
702
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
635
703
|
}
|
|
636
704
|
getCustomHeaders() {
|
|
637
705
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -640,27 +708,27 @@ class Q {
|
|
|
640
708
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
641
709
|
}
|
|
642
710
|
}
|
|
643
|
-
class
|
|
644
|
-
constructor(e, t, i =
|
|
711
|
+
class Ae {
|
|
712
|
+
constructor(e, t, i = p()) {
|
|
645
713
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
646
714
|
}
|
|
647
715
|
send(e) {
|
|
648
716
|
return new Promise((t, i) => {
|
|
649
|
-
const
|
|
650
|
-
|
|
717
|
+
const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
718
|
+
n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
|
|
651
719
|
const a = this.getCustomHeaders();
|
|
652
|
-
Object.keys(a).forEach((
|
|
653
|
-
|
|
654
|
-
}),
|
|
655
|
-
|
|
656
|
-
},
|
|
720
|
+
Object.keys(a).forEach((c) => {
|
|
721
|
+
n.setRequestHeader(c, a[c]);
|
|
722
|
+
}), n.onload = () => {
|
|
723
|
+
n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${n.status}`));
|
|
724
|
+
}, n.onerror = () => {
|
|
657
725
|
i(new Error("Network error"));
|
|
658
|
-
},
|
|
726
|
+
}, n.send(JSON.stringify(e));
|
|
659
727
|
});
|
|
660
728
|
}
|
|
661
729
|
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.${
|
|
730
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = d() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
731
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${E()}?p_${E()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
|
|
664
732
|
}
|
|
665
733
|
getCustomHeaders() {
|
|
666
734
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -669,9 +737,9 @@ class Pe {
|
|
|
669
737
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
670
738
|
}
|
|
671
739
|
}
|
|
672
|
-
class
|
|
740
|
+
class te {
|
|
673
741
|
constructor(e, t) {
|
|
674
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.
|
|
742
|
+
this.storage = {}, this.storageDisabled = !1, this.quotaErrorLogged = !1, this.prefix = `usermaven_${e}_`, this.logger = t || p(), this.load();
|
|
675
743
|
}
|
|
676
744
|
set(e, t) {
|
|
677
745
|
this.storage[e] = t, this.save();
|
|
@@ -685,19 +753,11 @@ class ee {
|
|
|
685
753
|
clear() {
|
|
686
754
|
this.storage = {}, this.save();
|
|
687
755
|
}
|
|
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
|
-
}
|
|
756
|
+
isStorageEnabled() {
|
|
757
|
+
return !this.storageDisabled;
|
|
698
758
|
}
|
|
699
759
|
load() {
|
|
700
|
-
if (!
|
|
760
|
+
if (!d()) {
|
|
701
761
|
this.logger.warn("localStorage is not available in this environment");
|
|
702
762
|
return;
|
|
703
763
|
}
|
|
@@ -705,11 +765,32 @@ class ee {
|
|
|
705
765
|
const e = localStorage.getItem(this.prefix + "data");
|
|
706
766
|
e && (this.storage = JSON.parse(e));
|
|
707
767
|
} catch (e) {
|
|
708
|
-
this.logger.error("Error loading from localStorage:", e);
|
|
768
|
+
this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error loading from localStorage:", e);
|
|
709
769
|
}
|
|
710
770
|
}
|
|
771
|
+
save() {
|
|
772
|
+
if (!d())
|
|
773
|
+
return this.logger.warn("localStorage is not available in this environment"), !1;
|
|
774
|
+
if (this.storageDisabled)
|
|
775
|
+
return !1;
|
|
776
|
+
try {
|
|
777
|
+
return localStorage.setItem(this.prefix + "data", JSON.stringify(this.storage)), !0;
|
|
778
|
+
} catch (e) {
|
|
779
|
+
return this.isQuotaError(e) ? (this.storageDisabled = !0, this.logQuotaOnce(e)) : this.logger.error("Error saving to localStorage:", e), !1;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
isQuotaError(e) {
|
|
783
|
+
const t = e == null ? void 0 : e.name;
|
|
784
|
+
return t === "QuotaExceededError" || t === "NS_ERROR_DOM_QUOTA_REACHED" || (e == null ? void 0 : e.code) === 22 || (e == null ? void 0 : e.code) === 1014;
|
|
785
|
+
}
|
|
786
|
+
logQuotaOnce(e) {
|
|
787
|
+
this.quotaErrorLogged || (this.quotaErrorLogged = !0, this.logger.error(
|
|
788
|
+
"localStorage quota exceeded; persisting disabled. Continuing with in-memory storage only.",
|
|
789
|
+
e
|
|
790
|
+
));
|
|
791
|
+
}
|
|
711
792
|
}
|
|
712
|
-
class
|
|
793
|
+
class Se {
|
|
713
794
|
constructor() {
|
|
714
795
|
this.storage = {};
|
|
715
796
|
}
|
|
@@ -728,56 +809,119 @@ class Ae {
|
|
|
728
809
|
this.storage = {};
|
|
729
810
|
}
|
|
730
811
|
}
|
|
731
|
-
class
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
812
|
+
class X {
|
|
813
|
+
constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = p(), a = "default", c = 1e3, h = 25e5) {
|
|
814
|
+
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(
|
|
815
|
+
`offline_queue_${a}`
|
|
816
|
+
), this.maxQueueItems = c, this.maxQueueBytes = h, d() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
735
817
|
}
|
|
736
818
|
add(e) {
|
|
737
|
-
const t = {
|
|
738
|
-
|
|
819
|
+
const t = {
|
|
820
|
+
payload: e,
|
|
821
|
+
retries: 0,
|
|
822
|
+
timestamp: Date.now()
|
|
823
|
+
};
|
|
824
|
+
t.bytes = this.estimateItemBytes(t), this.queue.push(t), this.totalQueueBytes += t.bytes, this.enforceQueueLimits(), d() ? this.saveQueueToStorage() : this.processBatch();
|
|
739
825
|
}
|
|
740
826
|
initNetworkListeners() {
|
|
741
|
-
|
|
827
|
+
d() && (window.addEventListener("online", () => {
|
|
742
828
|
this.isOnline = !0, this.processBatch();
|
|
743
829
|
}), window.addEventListener("offline", () => {
|
|
744
830
|
this.isOnline = !1;
|
|
745
831
|
}));
|
|
746
832
|
}
|
|
747
833
|
scheduleBatch() {
|
|
748
|
-
|
|
834
|
+
d() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
835
|
+
() => this.processBatch(),
|
|
836
|
+
this.batchInterval
|
|
837
|
+
));
|
|
749
838
|
}
|
|
750
839
|
async processBatch() {
|
|
751
|
-
if ((!
|
|
840
|
+
if ((!d() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
752
841
|
this.processing = !0;
|
|
753
|
-
const e = this.queue.splice(0, this.batchSize)
|
|
842
|
+
const e = this.queue.splice(0, this.batchSize);
|
|
843
|
+
this.totalQueueBytes = Math.max(
|
|
844
|
+
0,
|
|
845
|
+
this.totalQueueBytes - e.reduce((i, n) => i + (n.bytes || 0), 0)
|
|
846
|
+
);
|
|
847
|
+
const t = e.map((i) => i.payload);
|
|
754
848
|
try {
|
|
755
|
-
await this.transport.send(t), this.logger.debug(
|
|
849
|
+
await this.transport.send(t), this.logger.debug(
|
|
850
|
+
`Successfully sent batch of ${e.length} payloads`
|
|
851
|
+
), d() && this.saveQueueToStorage();
|
|
756
852
|
} catch (i) {
|
|
757
853
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
758
854
|
}
|
|
759
855
|
this.processing = !1;
|
|
760
856
|
}
|
|
761
|
-
|
|
857
|
+
d() && this.scheduleBatch();
|
|
762
858
|
}
|
|
763
859
|
async handleBatchFailure(e) {
|
|
764
860
|
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(
|
|
766
|
-
|
|
861
|
+
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(
|
|
862
|
+
"Max retries reached, discarding payload",
|
|
863
|
+
t.payload
|
|
864
|
+
);
|
|
865
|
+
d() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
866
|
+
}
|
|
867
|
+
enforceQueueLimits() {
|
|
868
|
+
if (this.maxQueueItems > 0 && this.queue.length > this.maxQueueItems) {
|
|
869
|
+
const e = this.queue.length - this.maxQueueItems, t = this.queue.splice(0, e);
|
|
870
|
+
this.totalQueueBytes = Math.max(
|
|
871
|
+
0,
|
|
872
|
+
this.totalQueueBytes - t.reduce((i, n) => i + (n.bytes || 0), 0)
|
|
873
|
+
), this.logger.warn(
|
|
874
|
+
`Retry queue exceeded ${this.maxQueueItems} items; dropped ${t.length} oldest payload(s)`
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
if (this.maxQueueBytes > 0 && this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 0) {
|
|
878
|
+
let e = 0;
|
|
879
|
+
for (; this.totalQueueBytes > this.maxQueueBytes && this.queue.length > 1; ) {
|
|
880
|
+
const t = this.queue.shift();
|
|
881
|
+
t && (this.totalQueueBytes -= t.bytes || this.estimateItemBytes(t), e++);
|
|
882
|
+
}
|
|
883
|
+
this.totalQueueBytes = Math.max(0, this.totalQueueBytes), e > 0 && this.logger.warn(
|
|
884
|
+
`Retry queue exceeded ${this.maxQueueBytes} bytes; dropped ${e} oldest payload(s)`
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
estimateItemBytes(e) {
|
|
889
|
+
const t = { ...e };
|
|
890
|
+
delete t.bytes;
|
|
891
|
+
try {
|
|
892
|
+
return JSON.stringify(t).length;
|
|
893
|
+
} catch {
|
|
894
|
+
return 0;
|
|
895
|
+
}
|
|
767
896
|
}
|
|
768
897
|
loadQueueFromStorage() {
|
|
769
|
-
if (
|
|
898
|
+
if (d()) {
|
|
770
899
|
const e = this.persistence.get("queue");
|
|
771
|
-
|
|
900
|
+
if (!e) return;
|
|
901
|
+
try {
|
|
902
|
+
const t = JSON.parse(e);
|
|
903
|
+
this.queue = t.map((i) => ({
|
|
904
|
+
...i,
|
|
905
|
+
bytes: i.bytes || this.estimateItemBytes(i)
|
|
906
|
+
})), this.totalQueueBytes = this.queue.reduce(
|
|
907
|
+
(i, n) => i + (n.bytes || 0),
|
|
908
|
+
0
|
|
909
|
+
), this.enforceQueueLimits();
|
|
910
|
+
} catch (t) {
|
|
911
|
+
this.logger.error("Failed to parse stored queue", t), this.queue = [], this.totalQueueBytes = 0;
|
|
912
|
+
}
|
|
772
913
|
}
|
|
773
914
|
}
|
|
774
915
|
saveQueueToStorage() {
|
|
775
|
-
|
|
916
|
+
if (d()) {
|
|
917
|
+
const e = this.queue.map(({ bytes: t, ...i }) => i);
|
|
918
|
+
this.persistence.set("queue", JSON.stringify(e));
|
|
919
|
+
}
|
|
776
920
|
}
|
|
777
921
|
}
|
|
778
|
-
class
|
|
922
|
+
class Ce {
|
|
779
923
|
constructor(e) {
|
|
780
|
-
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(),
|
|
924
|
+
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), G(this);
|
|
781
925
|
}
|
|
782
926
|
initializeEventListener() {
|
|
783
927
|
document.addEventListener("click", this.handleClick.bind(this));
|
|
@@ -790,15 +934,19 @@ class Se {
|
|
|
790
934
|
return !e.closest(".um-no-capture");
|
|
791
935
|
}
|
|
792
936
|
click(e, t, i) {
|
|
793
|
-
const
|
|
794
|
-
this.clicks.push(
|
|
937
|
+
const n = { x: e, y: t, timestamp: i };
|
|
938
|
+
this.clicks.push(n), this.clicks = this.clicks.filter(
|
|
939
|
+
(r) => i - r.timestamp < this.timeWindow
|
|
940
|
+
), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
795
941
|
}
|
|
796
942
|
checkRageClick() {
|
|
797
943
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
798
944
|
this.clicks.every((r, o) => {
|
|
799
945
|
if (o === 0) return !0;
|
|
800
946
|
const a = this.clicks[o - 1];
|
|
801
|
-
return Math.sqrt(
|
|
947
|
+
return Math.sqrt(
|
|
948
|
+
Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)
|
|
949
|
+
) < this.distanceThreshold;
|
|
802
950
|
}) && this.sendRageClickEvent(i);
|
|
803
951
|
}
|
|
804
952
|
sendRageClickEvent(e) {
|
|
@@ -810,11 +958,11 @@ class Se {
|
|
|
810
958
|
}
|
|
811
959
|
}
|
|
812
960
|
class $e {
|
|
813
|
-
constructor(e, t, i =
|
|
961
|
+
constructor(e, t, i = p()) {
|
|
814
962
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
815
963
|
}
|
|
816
964
|
async send(e) {
|
|
817
|
-
const t = this.config.key, i = new (void 0)(this.constructUrl(t)),
|
|
965
|
+
const t = this.config.key, i = new (void 0)(this.constructUrl(t)), n = {
|
|
818
966
|
hostname: i.hostname,
|
|
819
967
|
port: 443,
|
|
820
968
|
path: `${i.pathname}${i.search}`,
|
|
@@ -825,15 +973,15 @@ class $e {
|
|
|
825
973
|
}
|
|
826
974
|
};
|
|
827
975
|
return new Promise((r, o) => {
|
|
828
|
-
const a = (void 0)(
|
|
829
|
-
|
|
830
|
-
}),
|
|
831
|
-
const
|
|
832
|
-
|
|
976
|
+
const a = (void 0)(n, (c) => {
|
|
977
|
+
c.on("data", (h) => {
|
|
978
|
+
}), c.on("end", () => {
|
|
979
|
+
const h = c.statusCode || 0;
|
|
980
|
+
h >= 200 && h < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${h}`));
|
|
833
981
|
});
|
|
834
982
|
});
|
|
835
|
-
a.on("error", (
|
|
836
|
-
o(
|
|
983
|
+
a.on("error", (c) => {
|
|
984
|
+
o(c);
|
|
837
985
|
}), a.write(JSON.stringify(e)), a.end();
|
|
838
986
|
});
|
|
839
987
|
}
|
|
@@ -845,7 +993,7 @@ class $e {
|
|
|
845
993
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
846
994
|
}
|
|
847
995
|
}
|
|
848
|
-
class
|
|
996
|
+
class C {
|
|
849
997
|
constructor(e, t = "all", i = {}) {
|
|
850
998
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
851
999
|
}
|
|
@@ -860,18 +1008,27 @@ class P {
|
|
|
860
1008
|
}
|
|
861
1009
|
handleFormSubmit(e) {
|
|
862
1010
|
const t = e.target, i = this._getFormDetails(t);
|
|
863
|
-
this.instance.track("$form",
|
|
1011
|
+
this.instance.track("$form", V(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
864
1012
|
}
|
|
865
1013
|
trackFieldChanges(e) {
|
|
866
1014
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
867
|
-
i.addEventListener("change", (
|
|
868
|
-
const r = this._getFieldProps(
|
|
869
|
-
|
|
1015
|
+
i.addEventListener("change", (n) => {
|
|
1016
|
+
const r = this._getFieldProps(
|
|
1017
|
+
n.target
|
|
1018
|
+
);
|
|
1019
|
+
this.instance.track(
|
|
1020
|
+
"$form_field_change",
|
|
1021
|
+
V({
|
|
1022
|
+
form_id: e.id,
|
|
1023
|
+
form_name: e.name || "",
|
|
1024
|
+
field: r
|
|
1025
|
+
})
|
|
1026
|
+
);
|
|
870
1027
|
});
|
|
871
1028
|
});
|
|
872
1029
|
}
|
|
873
1030
|
static getInstance(e, t = "all", i = {}) {
|
|
874
|
-
return
|
|
1031
|
+
return C.instance || (C.instance = new C(e, t, i)), C.instance;
|
|
875
1032
|
}
|
|
876
1033
|
_getFormDetails(e) {
|
|
877
1034
|
const t = {
|
|
@@ -880,34 +1037,47 @@ class P {
|
|
|
880
1037
|
form_action: e.action,
|
|
881
1038
|
form_method: e.method,
|
|
882
1039
|
form_class: e.className,
|
|
883
|
-
form_attributes: this._getElementAttributes(e)
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1040
|
+
form_attributes: this._getElementAttributes(e),
|
|
1041
|
+
fields: []
|
|
1042
|
+
}, i = e.querySelectorAll(
|
|
1043
|
+
"input, select, textarea"
|
|
1044
|
+
);
|
|
1045
|
+
return Array.from(i).filter(
|
|
1046
|
+
(r) => !r.classList.contains("um-no-capture")
|
|
1047
|
+
).forEach(
|
|
1048
|
+
(r) => {
|
|
1049
|
+
const o = this._getFieldProps(r);
|
|
1050
|
+
t.fields.push(o);
|
|
1051
|
+
}
|
|
1052
|
+
), t;
|
|
889
1053
|
}
|
|
890
|
-
_getFieldProps(e
|
|
891
|
-
const
|
|
1054
|
+
_getFieldProps(e) {
|
|
1055
|
+
const t = Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : void 0, i = this.getSafeText(e);
|
|
892
1056
|
return {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1057
|
+
tag: e.tagName.toLowerCase(),
|
|
1058
|
+
type: e instanceof HTMLInputElement ? e.type : void 0,
|
|
1059
|
+
data_attributes: t,
|
|
1060
|
+
id: e.id,
|
|
1061
|
+
value: i,
|
|
1062
|
+
class: e.className,
|
|
1063
|
+
name: e.name,
|
|
1064
|
+
attributes: this._getElementAttributes(e)
|
|
901
1065
|
};
|
|
902
1066
|
}
|
|
903
1067
|
_getElementAttributes(e) {
|
|
904
|
-
return Object.keys(e.dataset).length ?
|
|
1068
|
+
return Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : {};
|
|
1069
|
+
}
|
|
1070
|
+
_convertDOMStringMapToObject(e) {
|
|
1071
|
+
const t = {};
|
|
1072
|
+
for (const i in e)
|
|
1073
|
+
e.hasOwnProperty(i) && e[i] !== void 0 && (t[i] = e[i]);
|
|
1074
|
+
return t;
|
|
905
1075
|
}
|
|
906
1076
|
getSafeText(e) {
|
|
907
1077
|
let t = "";
|
|
908
1078
|
return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
|
|
909
|
-
(
|
|
910
|
-
).map((
|
|
1079
|
+
(n) => n.nodeType === Node.TEXT_NODE
|
|
1080
|
+
).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
|
|
911
1081
|
}
|
|
912
1082
|
_scrubPotentiallySensitiveValues(e) {
|
|
913
1083
|
return this._shouldCaptureValue(e) ? e : "<redacted>";
|
|
@@ -925,7 +1095,7 @@ class P {
|
|
|
925
1095
|
if (typeof String.prototype.trim == "function")
|
|
926
1096
|
return e.trim();
|
|
927
1097
|
let t = 0, i = e.length - 1;
|
|
928
|
-
const
|
|
1098
|
+
const n = [
|
|
929
1099
|
" ",
|
|
930
1100
|
`
|
|
931
1101
|
`,
|
|
@@ -952,16 +1122,16 @@ class P {
|
|
|
952
1122
|
" ",
|
|
953
1123
|
" "
|
|
954
1124
|
].join("");
|
|
955
|
-
for (; t <= i &&
|
|
1125
|
+
for (; t <= i && n.indexOf(e[t]) > -1; )
|
|
956
1126
|
t++;
|
|
957
|
-
for (; i >= t &&
|
|
1127
|
+
for (; i >= t && n.indexOf(e[i]) > -1; )
|
|
958
1128
|
i--;
|
|
959
1129
|
return e.slice(t, i + 1);
|
|
960
1130
|
}
|
|
961
1131
|
}
|
|
962
|
-
class
|
|
1132
|
+
class R {
|
|
963
1133
|
constructor(e) {
|
|
964
|
-
this.config = this.mergeConfig(e,
|
|
1134
|
+
this.config = this.mergeConfig(e, Y), this.logger = p(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new X(
|
|
965
1135
|
this.transport,
|
|
966
1136
|
this.config.maxSendAttempts || 3,
|
|
967
1137
|
this.config.minSendTimeout || 1e3,
|
|
@@ -970,16 +1140,22 @@ class N {
|
|
|
970
1140
|
// Reduced interval to .2 second
|
|
971
1141
|
this.logger,
|
|
972
1142
|
this.namespace
|
|
973
|
-
),
|
|
1143
|
+
), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1144
|
+
`Usermaven client initialized for namespace: ${this.namespace}`
|
|
1145
|
+
);
|
|
974
1146
|
}
|
|
975
1147
|
initializeBrowserFeatures() {
|
|
976
|
-
if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture &&
|
|
1148
|
+
if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && N.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new N(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
977
1149
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
978
|
-
this.formTracking =
|
|
979
|
-
|
|
980
|
-
|
|
1150
|
+
this.formTracking = C.getInstance(
|
|
1151
|
+
this,
|
|
1152
|
+
e || "none",
|
|
1153
|
+
{
|
|
1154
|
+
trackFieldChanges: !1
|
|
1155
|
+
}
|
|
1156
|
+
);
|
|
981
1157
|
}
|
|
982
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
1158
|
+
this.config.autoPageview && (this.pageviewTracking = new Ee(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Ce(this)), this.setupPageLeaveTracking();
|
|
983
1159
|
}
|
|
984
1160
|
/**
|
|
985
1161
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -988,13 +1164,13 @@ class N {
|
|
|
988
1164
|
*/
|
|
989
1165
|
mergeConfig(e, t) {
|
|
990
1166
|
const i = JSON.parse(JSON.stringify(e));
|
|
991
|
-
let
|
|
1167
|
+
let n = { ...t, ...i };
|
|
992
1168
|
return Object.keys(t).forEach((r) => {
|
|
993
|
-
|
|
994
|
-
}),
|
|
1169
|
+
S(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
|
|
1170
|
+
}), n;
|
|
995
1171
|
}
|
|
996
1172
|
init(e) {
|
|
997
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
1173
|
+
this.config = { ...this.config, ...e }, this.logger = p(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new X(
|
|
998
1174
|
this.transport,
|
|
999
1175
|
this.config.maxSendAttempts || 3,
|
|
1000
1176
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1003,7 +1179,9 @@ class N {
|
|
|
1003
1179
|
// Reduced interval to .25 second
|
|
1004
1180
|
this.logger,
|
|
1005
1181
|
this.namespace
|
|
1006
|
-
),
|
|
1182
|
+
), d() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1183
|
+
`Usermaven client reinitialized for namespace: ${this.namespace}`
|
|
1184
|
+
);
|
|
1007
1185
|
}
|
|
1008
1186
|
manageCrossDomainLinking() {
|
|
1009
1187
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
@@ -1011,14 +1189,14 @@ class N {
|
|
|
1011
1189
|
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1012
1190
|
document.addEventListener("click", (i) => {
|
|
1013
1191
|
var a;
|
|
1014
|
-
const
|
|
1015
|
-
if (!
|
|
1016
|
-
const r =
|
|
1192
|
+
const n = this.findClosestLink(i.target);
|
|
1193
|
+
if (!n) return;
|
|
1194
|
+
const r = n.getAttribute("href");
|
|
1017
1195
|
if (!r || !r.startsWith("http")) return;
|
|
1018
1196
|
const o = new URL(r);
|
|
1019
1197
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1198
|
+
const c = (a = this.cookieManager) == null ? void 0 : a.get(t);
|
|
1199
|
+
c && (o.searchParams.append("_um", c), n.setAttribute("href", o.toString()));
|
|
1022
1200
|
}
|
|
1023
1201
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
1024
1202
|
}
|
|
@@ -1029,70 +1207,114 @@ class N {
|
|
|
1029
1207
|
}
|
|
1030
1208
|
initializeTransport(e) {
|
|
1031
1209
|
const t = "https://events.usermaven.com";
|
|
1032
|
-
if (!
|
|
1210
|
+
if (!d())
|
|
1033
1211
|
return new $e(e.trackingHost || t, e);
|
|
1034
|
-
const i = "XMLHttpRequest" in window,
|
|
1212
|
+
const i = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1035
1213
|
if (e.useBeaconApi && r)
|
|
1036
|
-
return new
|
|
1037
|
-
|
|
1038
|
-
|
|
1214
|
+
return new Pe(
|
|
1215
|
+
e.trackingHost || t,
|
|
1216
|
+
e,
|
|
1217
|
+
this.logger
|
|
1218
|
+
);
|
|
1219
|
+
if (e.forceUseFetch && n)
|
|
1220
|
+
return new K(
|
|
1221
|
+
e.trackingHost || t,
|
|
1222
|
+
e,
|
|
1223
|
+
this.logger
|
|
1224
|
+
);
|
|
1039
1225
|
if (i)
|
|
1040
|
-
return new
|
|
1041
|
-
|
|
1042
|
-
|
|
1226
|
+
return new Ae(
|
|
1227
|
+
e.trackingHost || t,
|
|
1228
|
+
e,
|
|
1229
|
+
this.logger
|
|
1230
|
+
);
|
|
1231
|
+
if (n)
|
|
1232
|
+
return new K(
|
|
1233
|
+
e.trackingHost || t,
|
|
1234
|
+
e,
|
|
1235
|
+
this.logger
|
|
1236
|
+
);
|
|
1043
1237
|
throw new Error("No suitable transport method available");
|
|
1044
1238
|
}
|
|
1045
1239
|
initializePersistence() {
|
|
1046
|
-
return this.config.disableEventPersistence || !
|
|
1240
|
+
return this.config.disableEventPersistence || !d() ? new Se() : new te(
|
|
1241
|
+
`${this.namespace}_${this.config.key}`,
|
|
1242
|
+
this.logger
|
|
1243
|
+
);
|
|
1047
1244
|
}
|
|
1048
1245
|
getOrCreateAnonymousId() {
|
|
1049
|
-
var i,
|
|
1050
|
-
if (!
|
|
1051
|
-
return
|
|
1246
|
+
var i, n;
|
|
1247
|
+
if (!d())
|
|
1248
|
+
return x();
|
|
1052
1249
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1053
1250
|
return "";
|
|
1054
1251
|
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1055
1252
|
let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
|
|
1056
1253
|
if (!t) {
|
|
1057
1254
|
if (this.config.crossDomainLinking) {
|
|
1058
|
-
const a = new URLSearchParams(window.location.search).get("_um"),
|
|
1059
|
-
t = a ||
|
|
1255
|
+
const a = new URLSearchParams(window.location.search).get("_um"), h = window.location.hash.substring(1).split("~"), f = h.length > 1 ? h[1] : void 0;
|
|
1256
|
+
t = a || f || x();
|
|
1060
1257
|
}
|
|
1061
|
-
t || (t =
|
|
1258
|
+
t || (t = x());
|
|
1062
1259
|
const r = 365 * 10;
|
|
1063
|
-
(
|
|
1260
|
+
(n = this.cookieManager) == null || n.set(
|
|
1261
|
+
e,
|
|
1262
|
+
t,
|
|
1263
|
+
r,
|
|
1264
|
+
document.location.protocol !== "http:",
|
|
1265
|
+
!1
|
|
1266
|
+
);
|
|
1064
1267
|
}
|
|
1065
1268
|
return t;
|
|
1066
1269
|
}
|
|
1067
1270
|
async id(e, t = !1) {
|
|
1068
|
-
if (!
|
|
1271
|
+
if (!S(e))
|
|
1069
1272
|
throw new Error("User data must be an object");
|
|
1070
|
-
if (e.email && !
|
|
1273
|
+
if (e.email && !W(e.email))
|
|
1071
1274
|
throw new Error("Invalid email provided");
|
|
1072
|
-
if (!e.id || !
|
|
1275
|
+
if (!e.id || !U(e.id))
|
|
1073
1276
|
throw new Error("User ID must be a string");
|
|
1074
1277
|
const i = e.id;
|
|
1075
1278
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
1076
|
-
const
|
|
1279
|
+
const n = {
|
|
1077
1280
|
...e,
|
|
1078
1281
|
anonymous_id: this.anonymousId
|
|
1079
1282
|
};
|
|
1080
|
-
await this.track("user_identify",
|
|
1283
|
+
await this.track("user_identify", n);
|
|
1081
1284
|
}
|
|
1082
1285
|
this.logger.info("User identified:", e);
|
|
1083
1286
|
}
|
|
1084
1287
|
track(e, t, i = !1) {
|
|
1085
1288
|
this.trackInternal(e, t, i);
|
|
1086
1289
|
}
|
|
1290
|
+
lead(e, t = !1) {
|
|
1291
|
+
if (!S(e))
|
|
1292
|
+
throw new Error(
|
|
1293
|
+
"Lead payload must be a non-null object and not an array"
|
|
1294
|
+
);
|
|
1295
|
+
const i = e.email;
|
|
1296
|
+
if (!U(i)) {
|
|
1297
|
+
this.logger.error("Lead event requires a valid email attribute");
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
const n = i.trim();
|
|
1301
|
+
if (!n || !W(n)) {
|
|
1302
|
+
this.logger.error("Lead event requires a valid email attribute");
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
e.email = n, this.track("lead", e, t);
|
|
1306
|
+
}
|
|
1087
1307
|
trackInternal(e, t, i = !1) {
|
|
1088
|
-
if (
|
|
1308
|
+
if (be()) {
|
|
1089
1309
|
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1090
1310
|
return;
|
|
1091
1311
|
}
|
|
1092
|
-
if (!
|
|
1312
|
+
if (!U(e))
|
|
1093
1313
|
throw new Error("Event name must be a string");
|
|
1094
1314
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1095
|
-
throw new Error(
|
|
1315
|
+
throw new Error(
|
|
1316
|
+
"Event payload must be a non-null object and not an array"
|
|
1317
|
+
);
|
|
1096
1318
|
const r = this.createEventPayload(e, t);
|
|
1097
1319
|
try {
|
|
1098
1320
|
if (i) {
|
|
@@ -1105,28 +1327,30 @@ class N {
|
|
|
1105
1327
|
}
|
|
1106
1328
|
}
|
|
1107
1329
|
rawTrack(e) {
|
|
1108
|
-
if (!
|
|
1330
|
+
if (!S(e))
|
|
1109
1331
|
throw new Error("Event payload must be an object");
|
|
1110
1332
|
this.track("raw", e);
|
|
1111
1333
|
}
|
|
1112
1334
|
async group(e, t = !1) {
|
|
1113
|
-
if (!
|
|
1335
|
+
if (!S(e))
|
|
1114
1336
|
throw new Error("Company properties must be an object");
|
|
1115
1337
|
if (!e.id || !e.name || !e.created_at)
|
|
1116
|
-
throw new Error(
|
|
1338
|
+
throw new Error(
|
|
1339
|
+
"Company properties must include id, name, and created_at"
|
|
1340
|
+
);
|
|
1117
1341
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1118
1342
|
}
|
|
1119
1343
|
createEventPayload(e, t) {
|
|
1120
|
-
const i = this.persistence.get("userProps") || {},
|
|
1121
|
-
let
|
|
1122
|
-
const
|
|
1123
|
-
event_id:
|
|
1344
|
+
const { event_id: i, ...n } = t || {}, r = this.persistence.get("userProps") || {}, o = this.persistence.get("companyProps") || (r == null ? void 0 : r.company) || {}, a = this.persistence.get("userId"), c = this.persistence.get("global_props") || {}, h = this.persistence.get(`props_${e}`) || {};
|
|
1345
|
+
let f = n;
|
|
1346
|
+
const l = {
|
|
1347
|
+
event_id: i || x(),
|
|
1124
1348
|
user: {
|
|
1125
1349
|
anonymous_id: this.anonymousId,
|
|
1126
|
-
id:
|
|
1127
|
-
...
|
|
1350
|
+
id: a,
|
|
1351
|
+
...r
|
|
1128
1352
|
},
|
|
1129
|
-
...
|
|
1353
|
+
...o && { company: o },
|
|
1130
1354
|
ids: this.getThirdPartyIds(),
|
|
1131
1355
|
utc_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1132
1356
|
local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
@@ -1134,22 +1358,32 @@ class N {
|
|
|
1134
1358
|
src: "usermaven",
|
|
1135
1359
|
event_type: e,
|
|
1136
1360
|
namespace: this.namespace,
|
|
1137
|
-
...
|
|
1138
|
-
...
|
|
1361
|
+
...c,
|
|
1362
|
+
...h
|
|
1139
1363
|
};
|
|
1140
1364
|
if (e === "$autocapture") {
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
})
|
|
1146
|
-
|
|
1365
|
+
const g = this.processAutocaptureAttributes(
|
|
1366
|
+
t || {}
|
|
1367
|
+
);
|
|
1368
|
+
l.autocapture_attributes = g;
|
|
1369
|
+
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((g) => {
|
|
1370
|
+
delete f[g];
|
|
1371
|
+
}), l.event_attributes = f);
|
|
1372
|
+
return d() && (l.referer = document.referrer, l.url = window.location.href, l.page_title = document.title, l.doc_path = window.location.pathname, l.doc_host = window.location.hostname, l.doc_search = window.location.search, l.screen_resolution = `${window.screen.width}x${window.screen.height}`, l.vp_size = `${window.innerWidth}x${window.innerHeight}`, l.user_agent = navigator.userAgent, l.user_language = navigator.language, l.doc_encoding = document.characterSet, l.utm = this.getUtmParams()), l;
|
|
1147
1373
|
}
|
|
1148
1374
|
processAutocaptureAttributes(e) {
|
|
1149
1375
|
let t = {};
|
|
1150
1376
|
const i = e.$elements || [];
|
|
1151
|
-
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1152
|
-
|
|
1377
|
+
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1378
|
+
"$ce_version",
|
|
1379
|
+
"$event_type",
|
|
1380
|
+
"$initial_referrer",
|
|
1381
|
+
"$initial_referring_domain",
|
|
1382
|
+
"$referrer",
|
|
1383
|
+
"$referring_domain",
|
|
1384
|
+
"$elements"
|
|
1385
|
+
].forEach((n) => {
|
|
1386
|
+
delete t[n];
|
|
1153
1387
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1154
1388
|
}
|
|
1155
1389
|
getCookie(e) {
|
|
@@ -1158,27 +1392,39 @@ class N {
|
|
|
1158
1392
|
}
|
|
1159
1393
|
getThirdPartyIds() {
|
|
1160
1394
|
const e = {};
|
|
1161
|
-
if (
|
|
1395
|
+
if (d()) {
|
|
1162
1396
|
const t = this.getCookie("_fbp");
|
|
1163
1397
|
t && (e.fbp = t);
|
|
1164
1398
|
}
|
|
1165
1399
|
return e;
|
|
1166
1400
|
}
|
|
1167
1401
|
getUtmParams() {
|
|
1168
|
-
const e = {}, t =
|
|
1169
|
-
return [
|
|
1170
|
-
|
|
1402
|
+
const e = {}, t = ke(window.location.search);
|
|
1403
|
+
return [
|
|
1404
|
+
"utm_source",
|
|
1405
|
+
"utm_medium",
|
|
1406
|
+
"utm_campaign",
|
|
1407
|
+
"utm_term",
|
|
1408
|
+
"utm_content"
|
|
1409
|
+
].forEach((n) => {
|
|
1410
|
+
t[n] && (e[n.replace("utm_", "")] = t[n]);
|
|
1171
1411
|
}), e;
|
|
1172
1412
|
}
|
|
1173
1413
|
pageview() {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1414
|
+
d() ? this.track(
|
|
1415
|
+
"pageview",
|
|
1416
|
+
{
|
|
1417
|
+
url: window.location.href,
|
|
1418
|
+
referrer: document.referrer,
|
|
1419
|
+
title: document.title
|
|
1420
|
+
},
|
|
1421
|
+
!0
|
|
1422
|
+
) : this.logger.warn(
|
|
1423
|
+
"Pageview tracking is not available in server-side environments"
|
|
1424
|
+
);
|
|
1179
1425
|
}
|
|
1180
1426
|
setupPageLeaveTracking() {
|
|
1181
|
-
if (!
|
|
1427
|
+
if (!d()) return;
|
|
1182
1428
|
let e = !1, t = !1;
|
|
1183
1429
|
const i = () => {
|
|
1184
1430
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
@@ -1194,9 +1440,9 @@ class N {
|
|
|
1194
1440
|
}), document.addEventListener("visibilitychange", () => {
|
|
1195
1441
|
document.visibilityState === "hidden" && !t && i();
|
|
1196
1442
|
});
|
|
1197
|
-
const
|
|
1443
|
+
const n = history.pushState;
|
|
1198
1444
|
history.pushState = function() {
|
|
1199
|
-
return i(),
|
|
1445
|
+
return i(), n.apply(this, arguments);
|
|
1200
1446
|
}, window.addEventListener("popstate", i);
|
|
1201
1447
|
}
|
|
1202
1448
|
getConfig() {
|
|
@@ -1210,12 +1456,15 @@ class N {
|
|
|
1210
1456
|
const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1211
1457
|
this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
|
|
1212
1458
|
}
|
|
1213
|
-
this.logger.info("core state reset", {
|
|
1459
|
+
this.logger.info("core state reset", {
|
|
1460
|
+
resetAnonId: e,
|
|
1461
|
+
namespace: this.namespace
|
|
1462
|
+
});
|
|
1214
1463
|
}
|
|
1215
1464
|
set(e, t) {
|
|
1216
|
-
if (!
|
|
1465
|
+
if (!S(e))
|
|
1217
1466
|
throw new Error("Properties must be an object");
|
|
1218
|
-
const i = t == null ? void 0 : t.eventType,
|
|
1467
|
+
const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1219
1468
|
if (i) {
|
|
1220
1469
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1221
1470
|
r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
|
|
@@ -1223,10 +1472,10 @@ class N {
|
|
|
1223
1472
|
let r = this.persistence.get("global_props") || {};
|
|
1224
1473
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1225
1474
|
}
|
|
1226
|
-
|
|
1475
|
+
n && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1227
1476
|
properties: e,
|
|
1228
1477
|
eventType: i || "global",
|
|
1229
|
-
persist:
|
|
1478
|
+
persist: n
|
|
1230
1479
|
});
|
|
1231
1480
|
}
|
|
1232
1481
|
setUserId(e) {
|
|
@@ -1235,7 +1484,7 @@ class N {
|
|
|
1235
1484
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1236
1485
|
}
|
|
1237
1486
|
unset(e, t) {
|
|
1238
|
-
const i = t == null ? void 0 : t.eventType,
|
|
1487
|
+
const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1239
1488
|
if (i) {
|
|
1240
1489
|
let r = this.persistence.get(`props_${i}`) || {};
|
|
1241
1490
|
delete r[e], this.persistence.set(`props_${i}`, r);
|
|
@@ -1243,178 +1492,199 @@ class N {
|
|
|
1243
1492
|
let r = this.persistence.get("global_props") || {};
|
|
1244
1493
|
delete r[e], this.persistence.set("global_props", r);
|
|
1245
1494
|
}
|
|
1246
|
-
|
|
1495
|
+
n && this.persistence.save(), this.logger.debug(
|
|
1496
|
+
`Property unset: ${e}`,
|
|
1497
|
+
`Event type: ${i || "global"}`
|
|
1498
|
+
);
|
|
1247
1499
|
}
|
|
1248
1500
|
}
|
|
1249
|
-
function
|
|
1501
|
+
function ie() {
|
|
1250
1502
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1251
1503
|
}
|
|
1252
|
-
function
|
|
1253
|
-
return
|
|
1504
|
+
function xe() {
|
|
1505
|
+
return ie() ? window.define : void 0;
|
|
1254
1506
|
}
|
|
1255
1507
|
const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1256
|
-
function
|
|
1257
|
-
const e = JSON.parse(JSON.stringify(
|
|
1508
|
+
function L(s) {
|
|
1509
|
+
const e = JSON.parse(JSON.stringify(s)), t = Q(e), i = {
|
|
1510
|
+
...Y,
|
|
1511
|
+
...t
|
|
1512
|
+
};
|
|
1258
1513
|
if (!i.key)
|
|
1259
1514
|
throw new Error("API key is required!");
|
|
1260
1515
|
if (!i.trackingHost)
|
|
1261
1516
|
throw new Error("Tracking host is required!");
|
|
1262
|
-
const
|
|
1263
|
-
return
|
|
1517
|
+
const n = i.key || "", r = `${Te}${n}`;
|
|
1518
|
+
return d() && i.autocapture && window[r] && (console.warn(
|
|
1519
|
+
"Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
|
|
1520
|
+
), i.disableAutocaptureListenerRegistration = !0), d() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new R(i);
|
|
1264
1521
|
}
|
|
1265
|
-
function
|
|
1266
|
-
var
|
|
1522
|
+
function He(s) {
|
|
1523
|
+
var n;
|
|
1267
1524
|
const e = {
|
|
1268
|
-
key:
|
|
1269
|
-
trackingHost:
|
|
1270
|
-
logLevel:
|
|
1271
|
-
autocapture:
|
|
1272
|
-
formTracking:
|
|
1273
|
-
autoPageview:
|
|
1274
|
-
useBeaconApi:
|
|
1275
|
-
forceUseFetch:
|
|
1276
|
-
gaHook:
|
|
1277
|
-
segmentHook:
|
|
1278
|
-
randomizeUrl:
|
|
1279
|
-
capture3rdPartyCookies:
|
|
1280
|
-
idMethod:
|
|
1281
|
-
privacyPolicy:
|
|
1282
|
-
ipPolicy:
|
|
1283
|
-
cookiePolicy:
|
|
1284
|
-
minSendTimeout: parseInt(
|
|
1285
|
-
maxSendTimeout: parseInt(
|
|
1286
|
-
maxSendAttempts: parseInt(
|
|
1287
|
-
propertiesStringMaxLength: parseInt(
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1525
|
+
key: s.getAttribute("data-key") || void 0,
|
|
1526
|
+
trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1527
|
+
logLevel: ve(s.getAttribute("data-log-level")),
|
|
1528
|
+
autocapture: s.getAttribute("data-autocapture") === "true",
|
|
1529
|
+
formTracking: s.getAttribute("data-form-tracking") === "false" ? !1 : s.getAttribute("data-form-tracking") === "true" ? "all" : s.getAttribute("data-form-tracking"),
|
|
1530
|
+
autoPageview: s.getAttribute("data-auto-pageview") === "true",
|
|
1531
|
+
useBeaconApi: s.getAttribute("data-use-beacon-api") === "true",
|
|
1532
|
+
forceUseFetch: s.getAttribute("data-force-use-fetch") === "true",
|
|
1533
|
+
gaHook: s.getAttribute("data-ga-hook") === "true",
|
|
1534
|
+
segmentHook: s.getAttribute("data-segment-hook") === "true",
|
|
1535
|
+
randomizeUrl: s.getAttribute("data-randomize-url") === "true",
|
|
1536
|
+
capture3rdPartyCookies: s.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
|
|
1537
|
+
idMethod: s.getAttribute("data-id-method") || void 0,
|
|
1538
|
+
privacyPolicy: s.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
|
|
1539
|
+
ipPolicy: s.getAttribute("data-ip-policy") || void 0,
|
|
1540
|
+
cookiePolicy: s.getAttribute("data-cookie-policy") || void 0,
|
|
1541
|
+
minSendTimeout: parseInt(s.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1542
|
+
maxSendTimeout: parseInt(s.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1543
|
+
maxSendAttempts: parseInt(s.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1544
|
+
propertiesStringMaxLength: parseInt(
|
|
1545
|
+
s.getAttribute("data-properties-string-max-length") || "",
|
|
1546
|
+
10
|
|
1547
|
+
) || null,
|
|
1548
|
+
propertyBlacklist: ((n = s.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
|
|
1549
|
+
exclude: s.getAttribute("data-exclude") || void 0,
|
|
1550
|
+
namespace: s.getAttribute("data-namespace") || void 0,
|
|
1551
|
+
crossDomainLinking: s.getAttribute("data-cross-domain-linking") !== "false",
|
|
1552
|
+
domains: s.getAttribute("data-domains") || void 0,
|
|
1553
|
+
maskAllText: s.getAttribute("data-mask-all-text") === "true",
|
|
1554
|
+
maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1295
1555
|
};
|
|
1296
1556
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1297
|
-
const t =
|
|
1298
|
-
return
|
|
1557
|
+
const t = L(e), i = e.namespace || "usermaven";
|
|
1558
|
+
return d() && t.pageview(), Ie(i, t), t;
|
|
1299
1559
|
}
|
|
1300
|
-
function
|
|
1560
|
+
function Ie(s, e) {
|
|
1301
1561
|
let t = !1;
|
|
1302
|
-
const i = [],
|
|
1562
|
+
const i = [], n = [];
|
|
1303
1563
|
function r() {
|
|
1304
1564
|
for (; i.length > 0; ) {
|
|
1305
1565
|
const u = i.shift();
|
|
1306
1566
|
if (u) {
|
|
1307
|
-
const
|
|
1308
|
-
if (
|
|
1309
|
-
const
|
|
1567
|
+
const m = u[u.length - 1];
|
|
1568
|
+
if (m && typeof m.resolve == "function") {
|
|
1569
|
+
const y = u.pop();
|
|
1310
1570
|
try {
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1313
|
-
} catch (
|
|
1314
|
-
|
|
1571
|
+
const P = a.apply(null, u);
|
|
1572
|
+
P && typeof P.then == "function" ? P.then(y.resolve).catch(y.reject) : y.resolve(P);
|
|
1573
|
+
} catch (P) {
|
|
1574
|
+
y.reject(P);
|
|
1315
1575
|
}
|
|
1316
1576
|
} else
|
|
1317
1577
|
try {
|
|
1318
1578
|
a.apply(null, u);
|
|
1319
|
-
} catch (
|
|
1320
|
-
console.error("Usermaven: Error processing queued command:",
|
|
1579
|
+
} catch (y) {
|
|
1580
|
+
console.error("Usermaven: Error processing queued command:", y);
|
|
1321
1581
|
}
|
|
1322
1582
|
}
|
|
1323
1583
|
}
|
|
1324
1584
|
}
|
|
1325
1585
|
function o() {
|
|
1326
|
-
|
|
1586
|
+
n.forEach((u) => u()), n.length = 0;
|
|
1327
1587
|
}
|
|
1328
1588
|
function a(...u) {
|
|
1329
|
-
const
|
|
1330
|
-
if (
|
|
1331
|
-
typeof u[1] == "function" && (t ? u[1]() :
|
|
1589
|
+
const m = u[0];
|
|
1590
|
+
if (m === "onLoad") {
|
|
1591
|
+
typeof u[1] == "function" && (t ? u[1]() : n.push(u[1]));
|
|
1332
1592
|
return;
|
|
1333
1593
|
}
|
|
1334
1594
|
if (!t) {
|
|
1335
1595
|
i.push(u);
|
|
1336
1596
|
return;
|
|
1337
1597
|
}
|
|
1338
|
-
if (typeof e[
|
|
1339
|
-
return e[
|
|
1340
|
-
console.error(`Method ${
|
|
1341
|
-
}
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1344
|
-
|
|
1598
|
+
if (typeof e[m] == "function")
|
|
1599
|
+
return e[m].apply(e, u.slice(1));
|
|
1600
|
+
console.error(`Method ${m} not found on UsermavenClient`);
|
|
1601
|
+
}
|
|
1602
|
+
const c = ["id", "group", "reset"], h = [
|
|
1603
|
+
"track",
|
|
1604
|
+
"lead",
|
|
1605
|
+
"pageview",
|
|
1606
|
+
"set",
|
|
1607
|
+
"unset",
|
|
1608
|
+
"rawTrack",
|
|
1609
|
+
"setUserId"
|
|
1610
|
+
];
|
|
1611
|
+
[...c, ...h].forEach((u) => {
|
|
1612
|
+
a[u] = function(...m) {
|
|
1345
1613
|
if (!t) {
|
|
1346
|
-
if (
|
|
1347
|
-
return new Promise((
|
|
1348
|
-
i.push([u, ...
|
|
1614
|
+
if (c.includes(u))
|
|
1615
|
+
return new Promise((M, y) => {
|
|
1616
|
+
i.push([u, ...m, { resolve: M, reject: y }]);
|
|
1349
1617
|
});
|
|
1350
|
-
i.push([u, ...
|
|
1618
|
+
i.push([u, ...m]);
|
|
1351
1619
|
return;
|
|
1352
1620
|
}
|
|
1353
1621
|
if (typeof e[u] == "function")
|
|
1354
|
-
return e[u].apply(e,
|
|
1622
|
+
return e[u].apply(e, m);
|
|
1355
1623
|
};
|
|
1356
1624
|
}), a.getConfig = function() {
|
|
1357
1625
|
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1358
|
-
}, window[
|
|
1359
|
-
const
|
|
1360
|
-
for (window[
|
|
1626
|
+
}, window[s] = a;
|
|
1627
|
+
const l = `${s}Q`, g = window[l] || [];
|
|
1628
|
+
for (window[l] = g, g.push = function(...u) {
|
|
1361
1629
|
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1362
1630
|
}, setTimeout(() => {
|
|
1363
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1364
|
-
}, 0);
|
|
1365
|
-
const u =
|
|
1631
|
+
t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
|
|
1632
|
+
}, 0); g.length > 0; ) {
|
|
1633
|
+
const u = g.shift();
|
|
1366
1634
|
u && i.push(u);
|
|
1367
1635
|
}
|
|
1368
1636
|
}
|
|
1369
|
-
let
|
|
1370
|
-
if (
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1637
|
+
let Z = !1, B = null;
|
|
1638
|
+
if (d()) {
|
|
1639
|
+
const s = xe();
|
|
1640
|
+
s && s("usermaven", [], function() {
|
|
1373
1641
|
return {
|
|
1374
|
-
usermavenClient:
|
|
1375
|
-
UsermavenClient:
|
|
1376
|
-
LogLevel:
|
|
1642
|
+
usermavenClient: L,
|
|
1643
|
+
UsermavenClient: R,
|
|
1644
|
+
LogLevel: _,
|
|
1377
1645
|
// Expose the script tag client if it exists
|
|
1378
|
-
getScriptTagClient: () =>
|
|
1646
|
+
getScriptTagClient: () => B
|
|
1379
1647
|
};
|
|
1380
|
-
}), typeof window < "u" && (window.usermavenClient =
|
|
1648
|
+
}), typeof window < "u" && (window.usermavenClient = L, window.UsermavenClient = R, window.usermavenScriptTagClient = () => B), function(e, t) {
|
|
1381
1649
|
const i = e.currentScript;
|
|
1382
|
-
function
|
|
1383
|
-
return
|
|
1650
|
+
function n() {
|
|
1651
|
+
return Z || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1384
1652
|
}
|
|
1385
1653
|
function r() {
|
|
1386
|
-
|
|
1654
|
+
n() && (console.log("[Usermaven] Auto-initializing from script tag"), B = He(i), Z = !0);
|
|
1387
1655
|
}
|
|
1388
1656
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1389
1657
|
}(document, window);
|
|
1390
1658
|
}
|
|
1391
|
-
typeof module < "u" && module.exports && !
|
|
1392
|
-
usermavenClient:
|
|
1393
|
-
UsermavenClient:
|
|
1659
|
+
typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
1660
|
+
usermavenClient: L,
|
|
1661
|
+
UsermavenClient: R,
|
|
1394
1662
|
Config: void 0,
|
|
1395
1663
|
UserProps: void 0,
|
|
1396
1664
|
EventPayload: void 0,
|
|
1397
|
-
LogLevel:
|
|
1665
|
+
LogLevel: _,
|
|
1398
1666
|
ClientProperties: void 0
|
|
1399
1667
|
});
|
|
1400
1668
|
|
|
1401
1669
|
function createClient(params) {
|
|
1402
|
-
return
|
|
1670
|
+
return L(params);
|
|
1403
1671
|
}
|
|
1404
1672
|
|
|
1405
1673
|
function useUsermaven() {
|
|
1406
1674
|
const client = useContext(UsermavenContext);
|
|
1407
1675
|
if (!client) {
|
|
1408
|
-
throw new Error(
|
|
1676
|
+
throw new Error('Before calling useUsermaven() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react');
|
|
1409
1677
|
}
|
|
1410
1678
|
const id = useCallback((userData, doNotSendEvent) => client === null || client === void 0 ? void 0 : client.id(userData, doNotSendEvent), [client]);
|
|
1411
1679
|
const trackPageView = useCallback(() => client === null || client === void 0 ? void 0 : client.track('pageview'), [client]);
|
|
1412
1680
|
const track = useCallback((typeName, payload) => client === null || client === void 0 ? void 0 : client.track(typeName, payload), [client]);
|
|
1681
|
+
const lead = useCallback((payload, directSend) => client === null || client === void 0 ? void 0 : client.lead(payload, directSend), [client]);
|
|
1413
1682
|
const rawTrack = useCallback((payload) => client === null || client === void 0 ? void 0 : client.rawTrack(payload), [client]);
|
|
1414
1683
|
const set = useCallback((properties, opts) => client === null || client === void 0 ? void 0 : client.set(properties, opts), [client]);
|
|
1415
1684
|
const unset = useCallback((propertyName, opts) => client === null || client === void 0 ? void 0 : client.unset(propertyName, opts), [client]);
|
|
1416
1685
|
return Object.assign(Object.assign({}, client), { id,
|
|
1417
1686
|
track,
|
|
1687
|
+
lead,
|
|
1418
1688
|
trackPageView,
|
|
1419
1689
|
rawTrack,
|
|
1420
1690
|
set,
|