@usermaven/sdk-js 1.4.1-rc.60 → 1.4.1-rc.61
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/dist/lib.js +2 -2
- package/dist/usermaven.cjs.js +2 -2
- package/dist/usermaven.es.js +299 -303
- package/package.json +1 -1
package/dist/usermaven.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var v = /* @__PURE__ */ ((
|
|
2
|
-
class
|
|
1
|
+
var v = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(v || {});
|
|
2
|
+
class V {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.level = e;
|
|
5
5
|
}
|
|
@@ -16,10 +16,10 @@ class J {
|
|
|
16
16
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function h(
|
|
20
|
-
return new
|
|
19
|
+
function h(i = 0) {
|
|
20
|
+
return new V(i);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const I = {
|
|
23
23
|
logLevel: v.ERROR,
|
|
24
24
|
useBeaconApi: !1,
|
|
25
25
|
forceUseFetch: !1,
|
|
@@ -47,19 +47,18 @@ const D = {
|
|
|
47
47
|
};
|
|
48
48
|
class Q {
|
|
49
49
|
constructor(e) {
|
|
50
|
-
this.domain = e, this.cookieDomain = this.getCookieDomain()
|
|
50
|
+
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
51
51
|
}
|
|
52
|
-
set(e, t,
|
|
53
|
-
console.log("Setting cookie", e, t, i, n, r);
|
|
52
|
+
set(e, t, s = 365, n = !0, r = !1) {
|
|
54
53
|
const o = /* @__PURE__ */ new Date();
|
|
55
|
-
o.setTime(o.getTime() +
|
|
54
|
+
o.setTime(o.getTime() + s * 24 * 60 * 60 * 1e3);
|
|
56
55
|
const c = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", a = r ? "; HttpOnly" : "";
|
|
57
56
|
document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
|
|
58
57
|
}
|
|
59
58
|
get(e) {
|
|
60
|
-
const t = e + "=",
|
|
61
|
-
for (let n = 0; n <
|
|
62
|
-
let r =
|
|
59
|
+
const t = e + "=", s = document.cookie.split(";");
|
|
60
|
+
for (let n = 0; n < s.length; n++) {
|
|
61
|
+
let r = s[n].trim();
|
|
63
62
|
if (r.indexOf(t) === 0)
|
|
64
63
|
return decodeURIComponent(r.substring(t.length));
|
|
65
64
|
}
|
|
@@ -79,7 +78,7 @@ class Q {
|
|
|
79
78
|
}
|
|
80
79
|
isIpAddress(e) {
|
|
81
80
|
const t = e.split(".");
|
|
82
|
-
return t.length === 4 && t.every((
|
|
81
|
+
return t.length === 4 && t.every((s) => !isNaN(Number(s)));
|
|
83
82
|
}
|
|
84
83
|
extractHostname(e) {
|
|
85
84
|
let t;
|
|
@@ -87,110 +86,110 @@ class Q {
|
|
|
87
86
|
}
|
|
88
87
|
extractRootDomain(e) {
|
|
89
88
|
let t = this.extractHostname(e);
|
|
90
|
-
const
|
|
91
|
-
return n > 2 && (
|
|
89
|
+
const s = t.split("."), n = s.length;
|
|
90
|
+
return n > 2 && (s[n - 1].length == 2 ? (t = s[n - 2] + "." + s[n - 1], s[n - 2].length == 2 && (t = s[n - 3] + "." + t)) : t = s[n - 2] + "." + s[n - 1]), t;
|
|
92
91
|
}
|
|
93
92
|
extractTopLevelDomain(e) {
|
|
94
|
-
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,
|
|
95
|
-
return
|
|
93
|
+
const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, s = e.match(t);
|
|
94
|
+
return s ? s[0] : "";
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
const W = Object.prototype, X = W.hasOwnProperty, K = Array.prototype, E = K.forEach, T = {};
|
|
99
|
-
function Z(
|
|
100
|
-
if (Array.isArray(
|
|
101
|
-
if (E &&
|
|
102
|
-
|
|
103
|
-
else if ("length" in
|
|
104
|
-
for (let
|
|
105
|
-
if (
|
|
98
|
+
function Z(i, e, t) {
|
|
99
|
+
if (Array.isArray(i)) {
|
|
100
|
+
if (E && i.forEach === E)
|
|
101
|
+
i.forEach(e, t);
|
|
102
|
+
else if ("length" in i && i.length === +i.length) {
|
|
103
|
+
for (let s = 0, n = i.length; s < n; s++)
|
|
104
|
+
if (s in i && e.call(t, i[s], s) === T)
|
|
106
105
|
return;
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
|
-
const A = function(
|
|
111
|
-
return
|
|
112
|
-
}, G = function(
|
|
113
|
-
for (const e in
|
|
114
|
-
typeof
|
|
109
|
+
const A = function(i) {
|
|
110
|
+
return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
111
|
+
}, G = function(i) {
|
|
112
|
+
for (const e in i)
|
|
113
|
+
typeof i[e] == "function" && (i[e] = i[e].bind(i));
|
|
115
114
|
};
|
|
116
|
-
function S(
|
|
117
|
-
if (
|
|
118
|
-
if (E && Array.isArray(
|
|
119
|
-
|
|
120
|
-
else if ("length" in
|
|
121
|
-
for (let
|
|
122
|
-
if (
|
|
115
|
+
function S(i, e, t) {
|
|
116
|
+
if (i != null) {
|
|
117
|
+
if (E && Array.isArray(i) && i.forEach === E)
|
|
118
|
+
i.forEach(e, t);
|
|
119
|
+
else if ("length" in i && i.length === +i.length) {
|
|
120
|
+
for (let s = 0, n = i.length; s < n; s++)
|
|
121
|
+
if (s in i && e.call(t, i[s], s) === T)
|
|
123
122
|
return;
|
|
124
123
|
} else
|
|
125
|
-
for (const
|
|
126
|
-
if (X.call(
|
|
124
|
+
for (const s in i)
|
|
125
|
+
if (X.call(i, s) && e.call(t, i[s], s) === T)
|
|
127
126
|
return;
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
|
-
const Y = function(
|
|
129
|
+
const Y = function(i, ...e) {
|
|
131
130
|
return Z(e, function(t) {
|
|
132
|
-
for (const
|
|
133
|
-
t[
|
|
134
|
-
}),
|
|
131
|
+
for (const s in t)
|
|
132
|
+
t[s] !== void 0 && (i[s] = t[s]);
|
|
133
|
+
}), i;
|
|
135
134
|
};
|
|
136
|
-
function _(
|
|
137
|
-
return
|
|
135
|
+
function _(i, e) {
|
|
136
|
+
return i.indexOf(e) !== -1;
|
|
138
137
|
}
|
|
139
|
-
const F = function(
|
|
138
|
+
const F = function(i) {
|
|
140
139
|
try {
|
|
141
|
-
return /^\s*\bfunction\b/.test(
|
|
140
|
+
return /^\s*\bfunction\b/.test(i);
|
|
142
141
|
} catch {
|
|
143
142
|
return !1;
|
|
144
143
|
}
|
|
145
|
-
}, j = function(
|
|
146
|
-
return
|
|
144
|
+
}, j = function(i) {
|
|
145
|
+
return i === void 0;
|
|
147
146
|
}, p = function() {
|
|
148
|
-
const
|
|
149
|
-
if (!
|
|
147
|
+
const i = function(s, n, r, o, c) {
|
|
148
|
+
if (!s) {
|
|
150
149
|
h().error("No valid element provided to register_event");
|
|
151
150
|
return;
|
|
152
151
|
}
|
|
153
|
-
if (
|
|
154
|
-
|
|
152
|
+
if (s.addEventListener && !o)
|
|
153
|
+
s.addEventListener(n, r, !!c);
|
|
155
154
|
else {
|
|
156
|
-
const l = "on" + n, a =
|
|
157
|
-
|
|
155
|
+
const l = "on" + n, a = s[l];
|
|
156
|
+
s[l] = e(s, r, a);
|
|
158
157
|
}
|
|
159
158
|
};
|
|
160
|
-
function e(
|
|
159
|
+
function e(s, n, r) {
|
|
161
160
|
return function(o) {
|
|
162
161
|
if (o = o || t(window.event), !o)
|
|
163
162
|
return;
|
|
164
163
|
let c = !0, l;
|
|
165
164
|
F(r) && (l = r(o));
|
|
166
|
-
const a = n.call(
|
|
165
|
+
const a = n.call(s, o);
|
|
167
166
|
return (l === !1 || a === !1) && (c = !1), c;
|
|
168
167
|
};
|
|
169
168
|
}
|
|
170
|
-
function t(
|
|
171
|
-
return
|
|
169
|
+
function t(s) {
|
|
170
|
+
return s && (s.preventDefault = t.preventDefault, s.stopPropagation = t.stopPropagation), s;
|
|
172
171
|
}
|
|
173
172
|
return t.preventDefault = function() {
|
|
174
173
|
this.returnValue = !1;
|
|
175
174
|
}, t.stopPropagation = function() {
|
|
176
175
|
this.cancelBubble = !0;
|
|
177
|
-
},
|
|
178
|
-
}(), ee = function(
|
|
176
|
+
}, i;
|
|
177
|
+
}(), ee = function(i) {
|
|
179
178
|
return function(...e) {
|
|
180
179
|
try {
|
|
181
|
-
return
|
|
180
|
+
return i.apply(this, e);
|
|
182
181
|
} catch (t) {
|
|
183
182
|
h().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
184
183
|
}
|
|
185
184
|
};
|
|
186
|
-
}, z = function(
|
|
187
|
-
for (const e in
|
|
188
|
-
typeof
|
|
185
|
+
}, z = function(i) {
|
|
186
|
+
for (const e in i)
|
|
187
|
+
typeof i[e] == "function" && (i[e] = ee(i[e]));
|
|
189
188
|
};
|
|
190
|
-
function N(
|
|
191
|
-
for (let e in
|
|
192
|
-
(
|
|
193
|
-
return
|
|
189
|
+
function N(i) {
|
|
190
|
+
for (let e in i)
|
|
191
|
+
(i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
|
|
192
|
+
return i;
|
|
194
193
|
}
|
|
195
194
|
function u() {
|
|
196
195
|
try {
|
|
@@ -199,80 +198,80 @@ function u() {
|
|
|
199
198
|
return h().warn("window is not available"), !1;
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
|
-
function f(
|
|
203
|
-
const e = new Uint8Array(
|
|
204
|
-
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0,
|
|
201
|
+
function f(i = 5) {
|
|
202
|
+
const e = new Uint8Array(i);
|
|
203
|
+
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
|
|
205
204
|
}
|
|
206
|
-
function te(
|
|
207
|
-
return
|
|
205
|
+
function te(i) {
|
|
206
|
+
return i.replace(
|
|
208
207
|
/([-_][a-z])/g,
|
|
209
208
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
210
209
|
);
|
|
211
210
|
}
|
|
212
|
-
function C(
|
|
213
|
-
return typeof
|
|
214
|
-
const
|
|
215
|
-
return e[
|
|
211
|
+
function C(i) {
|
|
212
|
+
return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(C) : Object.keys(i).reduce((e, t) => {
|
|
213
|
+
const s = te(t);
|
|
214
|
+
return e[s] = C(i[t]), e;
|
|
216
215
|
}, {});
|
|
217
216
|
}
|
|
218
|
-
function P(
|
|
219
|
-
switch (typeof
|
|
217
|
+
function P(i) {
|
|
218
|
+
switch (typeof i.className) {
|
|
220
219
|
case "string":
|
|
221
|
-
return
|
|
220
|
+
return i.className;
|
|
222
221
|
case "object":
|
|
223
|
-
return ("baseVal" in
|
|
222
|
+
return ("baseVal" in i.className ? i.className.baseVal : null) || i.getAttribute("class") || "";
|
|
224
223
|
default:
|
|
225
224
|
return "";
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
|
-
function O(
|
|
227
|
+
function O(i) {
|
|
229
228
|
let e = "";
|
|
230
|
-
return M(
|
|
229
|
+
return M(i) && !q(i) && i.childNodes && i.childNodes.length && S(i.childNodes, function(t) {
|
|
231
230
|
B(t) && t.textContent && (e += A(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
232
231
|
}), A(e);
|
|
233
232
|
}
|
|
234
|
-
function R(
|
|
235
|
-
return !!
|
|
233
|
+
function R(i) {
|
|
234
|
+
return !!i && i.nodeType === 1;
|
|
236
235
|
}
|
|
237
|
-
function d(
|
|
238
|
-
return !!
|
|
236
|
+
function d(i, e) {
|
|
237
|
+
return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
|
|
239
238
|
}
|
|
240
|
-
function B(
|
|
241
|
-
return !!
|
|
239
|
+
function B(i) {
|
|
240
|
+
return !!i && i.nodeType === 3;
|
|
242
241
|
}
|
|
243
|
-
function x(
|
|
244
|
-
return !!
|
|
242
|
+
function x(i) {
|
|
243
|
+
return !!i && i.nodeType === 11;
|
|
245
244
|
}
|
|
246
245
|
const b = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
247
|
-
function ie(
|
|
248
|
-
if (!
|
|
246
|
+
function ie(i, e) {
|
|
247
|
+
if (!i || d(i, "html") || !R(i))
|
|
249
248
|
return !1;
|
|
250
|
-
let t =
|
|
249
|
+
let t = i;
|
|
251
250
|
for (; t && !d(t, "body"); ) {
|
|
252
251
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
253
252
|
return !1;
|
|
254
253
|
t.parentNode && x(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
255
254
|
}
|
|
256
|
-
let
|
|
257
|
-
for (t =
|
|
255
|
+
let s = !1;
|
|
256
|
+
for (t = i; t && !d(t, "body"); ) {
|
|
258
257
|
if (t.parentNode && x(t.parentNode)) {
|
|
259
|
-
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (
|
|
258
|
+
t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
|
|
260
259
|
continue;
|
|
261
260
|
}
|
|
262
261
|
const o = t.parentNode;
|
|
263
262
|
if (!o) break;
|
|
264
263
|
if (b.indexOf(o.tagName.toLowerCase()) > -1)
|
|
265
|
-
|
|
264
|
+
s = !0;
|
|
266
265
|
else {
|
|
267
266
|
const c = window.getComputedStyle(o);
|
|
268
|
-
c && c.getPropertyValue("cursor") === "pointer" && (
|
|
267
|
+
c && c.getPropertyValue("cursor") === "pointer" && (s = !0);
|
|
269
268
|
}
|
|
270
269
|
t = o;
|
|
271
270
|
}
|
|
272
|
-
const n = window.getComputedStyle(
|
|
271
|
+
const n = window.getComputedStyle(i);
|
|
273
272
|
if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
|
|
274
273
|
return !0;
|
|
275
|
-
const r =
|
|
274
|
+
const r = i.tagName.toLowerCase();
|
|
276
275
|
switch (r) {
|
|
277
276
|
case "html":
|
|
278
277
|
return !1;
|
|
@@ -284,80 +283,80 @@ function ie(s, e) {
|
|
|
284
283
|
case "textarea":
|
|
285
284
|
return e.type === "change" || e.type === "click";
|
|
286
285
|
default:
|
|
287
|
-
return
|
|
286
|
+
return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
|
|
288
287
|
}
|
|
289
288
|
}
|
|
290
|
-
function M(
|
|
291
|
-
if (!
|
|
289
|
+
function M(i) {
|
|
290
|
+
if (!i || !R(i))
|
|
292
291
|
return !1;
|
|
293
|
-
if (typeof
|
|
294
|
-
if (
|
|
292
|
+
if (typeof i.hasAttribute == "function") {
|
|
293
|
+
if (i.hasAttribute(w.FORCE_CAPTURE_ATTR))
|
|
295
294
|
return !0;
|
|
296
|
-
if (
|
|
295
|
+
if (i.hasAttribute(w.PREVENT_CAPTURE_ATTR))
|
|
297
296
|
return !1;
|
|
298
297
|
}
|
|
299
|
-
let e =
|
|
298
|
+
let e = i;
|
|
300
299
|
for (; e && e.parentElement && !d(e, "body"); ) {
|
|
301
300
|
const n = P(e).split(" ");
|
|
302
301
|
if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
|
|
303
302
|
return !1;
|
|
304
303
|
e = e.parentElement;
|
|
305
304
|
}
|
|
306
|
-
if (_(P(
|
|
305
|
+
if (_(P(i).split(" "), "ph-include"))
|
|
307
306
|
return !0;
|
|
308
|
-
const t =
|
|
307
|
+
const t = i.type;
|
|
309
308
|
if (typeof t == "string")
|
|
310
309
|
switch (t.toLowerCase()) {
|
|
311
310
|
case "hidden":
|
|
312
311
|
case "password":
|
|
313
312
|
return !1;
|
|
314
313
|
}
|
|
315
|
-
const
|
|
316
|
-
return !(typeof
|
|
314
|
+
const s = i.name || i.id || "";
|
|
315
|
+
return !(typeof s == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g, "")));
|
|
317
316
|
}
|
|
318
|
-
function q(
|
|
317
|
+
function q(i) {
|
|
319
318
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
320
|
-
return !!(d(
|
|
319
|
+
return !!(d(i, "input") && !e.includes(i.type) || d(i, "select") || d(i, "textarea") || i.getAttribute("contenteditable") === "true");
|
|
321
320
|
}
|
|
322
|
-
function H(
|
|
323
|
-
return !(
|
|
321
|
+
function H(i) {
|
|
322
|
+
return !(i === null || j(i) || typeof i == "string" && (i = A(i), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
|
|
324
323
|
}
|
|
325
|
-
function se(
|
|
326
|
-
return typeof
|
|
324
|
+
function se(i) {
|
|
325
|
+
return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
|
|
327
326
|
}
|
|
328
327
|
function $() {
|
|
329
328
|
return f(10);
|
|
330
329
|
}
|
|
331
|
-
function ne(
|
|
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(
|
|
330
|
+
function ne(i) {
|
|
331
|
+
return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(i).toLowerCase());
|
|
333
332
|
}
|
|
334
|
-
function re(
|
|
333
|
+
function re(i, e) {
|
|
335
334
|
let t;
|
|
336
|
-
return function(...
|
|
335
|
+
return function(...s) {
|
|
337
336
|
const n = () => {
|
|
338
|
-
clearTimeout(t),
|
|
337
|
+
clearTimeout(t), i(...s);
|
|
339
338
|
};
|
|
340
339
|
clearTimeout(t), t = setTimeout(n, e);
|
|
341
340
|
};
|
|
342
341
|
}
|
|
343
|
-
function oe(
|
|
344
|
-
const e = {}, t =
|
|
345
|
-
for (let
|
|
346
|
-
const n = t[
|
|
342
|
+
function oe(i) {
|
|
343
|
+
const e = {}, t = i.replace(/^\?/, "").split("&");
|
|
344
|
+
for (let s = 0; s < t.length; s++) {
|
|
345
|
+
const n = t[s].split("=");
|
|
347
346
|
n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
|
|
348
347
|
}
|
|
349
348
|
return e;
|
|
350
349
|
}
|
|
351
|
-
function L(
|
|
352
|
-
return typeof
|
|
350
|
+
function L(i) {
|
|
351
|
+
return typeof i == "string" || i instanceof String;
|
|
353
352
|
}
|
|
354
|
-
function k(
|
|
355
|
-
return
|
|
353
|
+
function k(i) {
|
|
354
|
+
return i !== null && typeof i == "object" && i.constructor === Object;
|
|
356
355
|
}
|
|
357
|
-
function ae(
|
|
358
|
-
if (
|
|
356
|
+
function ae(i) {
|
|
357
|
+
if (i === null)
|
|
359
358
|
return v.ERROR;
|
|
360
|
-
const e =
|
|
359
|
+
const e = i.toUpperCase(), t = v[e];
|
|
361
360
|
return t || t === 0 ? t : v.ERROR;
|
|
362
361
|
}
|
|
363
362
|
class ce {
|
|
@@ -372,6 +371,8 @@ class ce {
|
|
|
372
371
|
e > this.lastScrollDepth && (this.lastScrollDepth = e, this.checkMilestones(e));
|
|
373
372
|
}
|
|
374
373
|
send(e = "$scroll") {
|
|
374
|
+
if (!this.lastScrollDepth)
|
|
375
|
+
return;
|
|
375
376
|
const t = {
|
|
376
377
|
percent: this.lastScrollDepth,
|
|
377
378
|
window_height: this.getWindowHeight(),
|
|
@@ -384,8 +385,8 @@ class ce {
|
|
|
384
385
|
this.track();
|
|
385
386
|
}
|
|
386
387
|
getScrollDepth() {
|
|
387
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(),
|
|
388
|
-
return Math.min(100, Math.floor(
|
|
388
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), s = this.getScrollDistance(), n = t - e;
|
|
389
|
+
return Math.min(100, Math.floor(s / n * 100));
|
|
389
390
|
}
|
|
390
391
|
getWindowHeight() {
|
|
391
392
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -404,14 +405,14 @@ class ce {
|
|
|
404
405
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
405
406
|
}
|
|
406
407
|
checkMilestones(e) {
|
|
407
|
-
this.milestones.filter((
|
|
408
|
-
this.send(), this.milestones = this.milestones.filter((n) => n !==
|
|
408
|
+
this.milestones.filter((s) => e >= s).forEach((s) => {
|
|
409
|
+
this.send(), this.milestones = this.milestones.filter((n) => n !== s);
|
|
409
410
|
});
|
|
410
411
|
}
|
|
411
412
|
}
|
|
412
413
|
const y = class y {
|
|
413
|
-
constructor(e, t,
|
|
414
|
-
this.logger =
|
|
414
|
+
constructor(e, t, s = h()) {
|
|
415
|
+
this.logger = s, this.scrollDepth = null, this.client = e, this.options = t, this.scrollDepth = new ce(e), G(this), z(this);
|
|
415
416
|
}
|
|
416
417
|
init() {
|
|
417
418
|
if (!(document && document.body)) {
|
|
@@ -435,10 +436,10 @@ const y = class y {
|
|
|
435
436
|
return performance.navigation && performance.navigation.type === 1;
|
|
436
437
|
}
|
|
437
438
|
captureEvent(e) {
|
|
438
|
-
var
|
|
439
|
+
var s, n;
|
|
439
440
|
let t = this.getEventTarget(e);
|
|
440
441
|
if (B(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
441
|
-
return (
|
|
442
|
+
return (s = this.scrollDepth) == null || s.track(), !0;
|
|
442
443
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
443
444
|
return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
|
|
444
445
|
if (t && this.shouldCaptureElement(t, e)) {
|
|
@@ -460,13 +461,13 @@ const y = class y {
|
|
|
460
461
|
}
|
|
461
462
|
getElementList(e) {
|
|
462
463
|
const t = [e];
|
|
463
|
-
let
|
|
464
|
-
for (;
|
|
465
|
-
x(
|
|
464
|
+
let s = e;
|
|
465
|
+
for (; s.parentNode && !d(s, "body"); )
|
|
466
|
+
x(s.parentNode) ? (t.push(s.parentNode.host), s = s.parentNode.host) : (t.push(s.parentNode), s = s.parentNode);
|
|
466
467
|
return t;
|
|
467
468
|
}
|
|
468
469
|
getElementsJson(e, t) {
|
|
469
|
-
const
|
|
470
|
+
const s = [];
|
|
470
471
|
let n = null, r = !1;
|
|
471
472
|
return S(e, (o) => {
|
|
472
473
|
if (d(o, "a")) {
|
|
@@ -474,16 +475,16 @@ const y = class y {
|
|
|
474
475
|
l !== null && M(o) && H(l) && (n = l);
|
|
475
476
|
}
|
|
476
477
|
const c = P(o).split(" ");
|
|
477
|
-
_(c, "ph-no-capture") && (r = !0),
|
|
478
|
-
}), this.options.maskAllText || (
|
|
478
|
+
_(c, "ph-no-capture") && (r = !0), s.push(this.getPropertiesFromElement(o));
|
|
479
|
+
}), this.options.maskAllText || (s[0].$el_text = this.sanitizeText(O(e[0]))), n !== null && (s[0].attr__href = n), r ? [] : s;
|
|
479
480
|
}
|
|
480
481
|
getPropertiesFromElement(e) {
|
|
481
482
|
const t = {
|
|
482
483
|
tag_name: e.tagName.toLowerCase()
|
|
483
484
|
};
|
|
484
485
|
b.indexOf(t.tag_name) > -1 && !this.options.maskAllText && (t.$el_text = this.sanitizeText(O(e)));
|
|
485
|
-
const
|
|
486
|
-
|
|
486
|
+
const s = P(e);
|
|
487
|
+
s.length > 0 && (t.classes = s.split(" ").filter((c) => c !== "")), S(e.attributes, (c) => {
|
|
487
488
|
q(e) && ["name", "id", "class"].indexOf(c.name) === -1 || !this.options.maskAllElementAttributes && H(c.value) && !se(c.name) && (t["attr__" + c.name] = this.sanitizeAttributeValue(c.name, c.value));
|
|
488
489
|
});
|
|
489
490
|
let n = 1, r = 1, o = e;
|
|
@@ -532,13 +533,13 @@ const y = class y {
|
|
|
532
533
|
encodeHtml(e) {
|
|
533
534
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
534
535
|
}
|
|
535
|
-
static enabledForProject(e, t = 10,
|
|
536
|
+
static enabledForProject(e, t = 10, s = 10) {
|
|
536
537
|
if (!e)
|
|
537
538
|
return !1;
|
|
538
539
|
let n = 0;
|
|
539
540
|
for (let r = 0; r < e.length; r++)
|
|
540
541
|
n += e.charCodeAt(r);
|
|
541
|
-
return n % t <
|
|
542
|
+
return n % t < s;
|
|
542
543
|
}
|
|
543
544
|
static isBrowserSupported() {
|
|
544
545
|
return F(document.querySelectorAll);
|
|
@@ -576,32 +577,32 @@ class le {
|
|
|
576
577
|
}
|
|
577
578
|
}
|
|
578
579
|
class ue {
|
|
579
|
-
constructor(e, t,
|
|
580
|
-
this.trackingHost = e, this.logger =
|
|
580
|
+
constructor(e, t, s = h()) {
|
|
581
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
581
582
|
}
|
|
582
583
|
async send(e) {
|
|
583
|
-
const t = this.config.key,
|
|
584
|
-
if (navigator.sendBeacon(
|
|
584
|
+
const t = this.config.key, s = this.constructUrl(t), n = new Blob([JSON.stringify(e)], { type: "application/json" });
|
|
585
|
+
if (navigator.sendBeacon(s, n))
|
|
585
586
|
this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
|
|
586
587
|
else
|
|
587
588
|
throw new Error("Failed to queue events via Beacon API");
|
|
588
589
|
}
|
|
589
590
|
constructUrl(e) {
|
|
590
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
591
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${
|
|
591
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
592
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
592
593
|
}
|
|
593
594
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
594
595
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
595
596
|
}
|
|
596
597
|
class U {
|
|
597
|
-
constructor(e, t,
|
|
598
|
-
this.trackingHost = e, this.logger =
|
|
598
|
+
constructor(e, t, s = h()) {
|
|
599
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
599
600
|
}
|
|
600
601
|
async send(e) {
|
|
601
|
-
const t = this.config.key,
|
|
602
|
+
const t = this.config.key, s = this.constructUrl(t), n = JSON.stringify(e), r = {
|
|
602
603
|
"Content-Type": "application/json",
|
|
603
604
|
...this.getCustomHeaders()
|
|
604
|
-
}, o = await fetch(
|
|
605
|
+
}, o = await fetch(s, {
|
|
605
606
|
method: "POST",
|
|
606
607
|
headers: r,
|
|
607
608
|
body: n
|
|
@@ -611,8 +612,8 @@ class U {
|
|
|
611
612
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
612
613
|
}
|
|
613
614
|
constructUrl(e) {
|
|
614
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
615
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${
|
|
615
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
616
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
616
617
|
}
|
|
617
618
|
getCustomHeaders() {
|
|
618
619
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -622,26 +623,26 @@ class U {
|
|
|
622
623
|
}
|
|
623
624
|
}
|
|
624
625
|
class he {
|
|
625
|
-
constructor(e, t,
|
|
626
|
-
this.trackingHost = e, this.logger =
|
|
626
|
+
constructor(e, t, s = h()) {
|
|
627
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
627
628
|
}
|
|
628
629
|
send(e) {
|
|
629
|
-
return new Promise((t,
|
|
630
|
+
return new Promise((t, s) => {
|
|
630
631
|
const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
631
632
|
n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
|
|
632
633
|
const c = this.getCustomHeaders();
|
|
633
634
|
Object.keys(c).forEach((l) => {
|
|
634
635
|
n.setRequestHeader(l, c[l]);
|
|
635
636
|
}), n.onload = () => {
|
|
636
|
-
n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) :
|
|
637
|
+
n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : s(new Error(`HTTP error! status: ${n.status}`));
|
|
637
638
|
}, n.onerror = () => {
|
|
638
|
-
|
|
639
|
+
s(new Error("Network error"));
|
|
639
640
|
}, n.send(JSON.stringify(e));
|
|
640
641
|
});
|
|
641
642
|
}
|
|
642
643
|
constructUrl(e) {
|
|
643
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
644
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${
|
|
644
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
645
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
|
|
645
646
|
}
|
|
646
647
|
getCustomHeaders() {
|
|
647
648
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -650,7 +651,7 @@ class he {
|
|
|
650
651
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
651
652
|
}
|
|
652
653
|
}
|
|
653
|
-
class
|
|
654
|
+
class J {
|
|
654
655
|
constructor(e, t) {
|
|
655
656
|
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || h();
|
|
656
657
|
}
|
|
@@ -709,10 +710,10 @@ class ge {
|
|
|
709
710
|
this.storage = {};
|
|
710
711
|
}
|
|
711
712
|
}
|
|
712
|
-
class
|
|
713
|
+
class D {
|
|
713
714
|
// Default to true for server-side
|
|
714
|
-
constructor(e, t = 3,
|
|
715
|
-
this.transport = e, this.maxRetries = t, this.retryInterval =
|
|
715
|
+
constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = h()) {
|
|
716
|
+
this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new J("offline_queue"), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
716
717
|
}
|
|
717
718
|
add(e) {
|
|
718
719
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -731,11 +732,11 @@ class I {
|
|
|
731
732
|
async processBatch() {
|
|
732
733
|
if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
733
734
|
this.processing = !0;
|
|
734
|
-
const e = this.queue.splice(0, this.batchSize), t = e.map((
|
|
735
|
+
const e = this.queue.splice(0, this.batchSize), t = e.map((s) => s.payload);
|
|
735
736
|
try {
|
|
736
737
|
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
|
|
737
|
-
} catch (
|
|
738
|
-
this.logger.error("Failed to send batch",
|
|
738
|
+
} catch (s) {
|
|
739
|
+
this.logger.error("Failed to send batch", s), await this.handleBatchFailure(e);
|
|
739
740
|
}
|
|
740
741
|
this.processing = !1;
|
|
741
742
|
}
|
|
@@ -770,17 +771,17 @@ class de {
|
|
|
770
771
|
shouldCaptureElement(e) {
|
|
771
772
|
return !e.closest(".um-no-capture");
|
|
772
773
|
}
|
|
773
|
-
click(e, t,
|
|
774
|
-
const n = { x: e, y: t, timestamp:
|
|
775
|
-
this.clicks.push(n), this.clicks = this.clicks.filter((r) =>
|
|
774
|
+
click(e, t, s) {
|
|
775
|
+
const n = { x: e, y: t, timestamp: s };
|
|
776
|
+
this.clicks.push(n), this.clicks = this.clicks.filter((r) => s - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
776
777
|
}
|
|
777
778
|
checkRageClick() {
|
|
778
|
-
const e = this.clicks[0],
|
|
779
|
+
const e = this.clicks[0], s = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
779
780
|
this.clicks.every((r, o) => {
|
|
780
781
|
if (o === 0) return !0;
|
|
781
782
|
const c = this.clicks[o - 1];
|
|
782
783
|
return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
|
|
783
|
-
}) && this.sendRageClickEvent(
|
|
784
|
+
}) && this.sendRageClickEvent(s);
|
|
784
785
|
}
|
|
785
786
|
sendRageClickEvent(e) {
|
|
786
787
|
const t = this.clicks[this.clicks.length - 1];
|
|
@@ -791,14 +792,14 @@ class de {
|
|
|
791
792
|
}
|
|
792
793
|
}
|
|
793
794
|
class fe {
|
|
794
|
-
constructor(e, t,
|
|
795
|
-
this.trackingHost = e, this.logger =
|
|
795
|
+
constructor(e, t, s = h()) {
|
|
796
|
+
this.trackingHost = e, this.logger = s, this.config = t;
|
|
796
797
|
}
|
|
797
798
|
async send(e) {
|
|
798
|
-
const t = this.config.key,
|
|
799
|
-
hostname:
|
|
799
|
+
const t = this.config.key, s = new (void 0)(this.constructUrl(t)), n = {
|
|
800
|
+
hostname: s.hostname,
|
|
800
801
|
port: 443,
|
|
801
|
-
path: `${
|
|
802
|
+
path: `${s.pathname}${s.search}`,
|
|
802
803
|
method: "POST",
|
|
803
804
|
headers: {
|
|
804
805
|
"Content-Type": "application/json",
|
|
@@ -819,16 +820,16 @@ class fe {
|
|
|
819
820
|
});
|
|
820
821
|
}
|
|
821
822
|
constructUrl(e) {
|
|
822
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
823
|
-
return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${
|
|
823
|
+
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
|
|
824
|
+
return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${s}`;
|
|
824
825
|
}
|
|
825
826
|
getCustomHeaders() {
|
|
826
827
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
827
828
|
}
|
|
828
829
|
}
|
|
829
830
|
class m {
|
|
830
|
-
constructor(e, t = "all",
|
|
831
|
-
this.instance = e, this.trackingType = t, this.options =
|
|
831
|
+
constructor(e, t = "all", s = {}) {
|
|
832
|
+
this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
832
833
|
}
|
|
833
834
|
initialize() {
|
|
834
835
|
this.trackingType !== "none" && this.setupFormTracking();
|
|
@@ -840,19 +841,19 @@ class m {
|
|
|
840
841
|
});
|
|
841
842
|
}
|
|
842
843
|
handleFormSubmit(e) {
|
|
843
|
-
const t = e.target,
|
|
844
|
-
this.instance.track("$form", N(
|
|
844
|
+
const t = e.target, s = this._getFormDetails(t);
|
|
845
|
+
this.instance.track("$form", N(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
845
846
|
}
|
|
846
847
|
trackFieldChanges(e) {
|
|
847
|
-
e.querySelectorAll("input, select, textarea").forEach((
|
|
848
|
-
|
|
848
|
+
e.querySelectorAll("input, select, textarea").forEach((s) => {
|
|
849
|
+
s.addEventListener("change", (n) => {
|
|
849
850
|
const r = this._getFieldProps(n.target, 0);
|
|
850
851
|
this.instance.track("$form_field_change", N(r));
|
|
851
852
|
});
|
|
852
853
|
});
|
|
853
854
|
}
|
|
854
|
-
static getInstance(e, t = "all",
|
|
855
|
-
return m.instance || (m.instance = new m(e, t,
|
|
855
|
+
static getInstance(e, t = "all", s = {}) {
|
|
856
|
+
return m.instance || (m.instance = new m(e, t, s)), m.instance;
|
|
856
857
|
}
|
|
857
858
|
_getFormDetails(e) {
|
|
858
859
|
const t = {
|
|
@@ -862,18 +863,18 @@ class m {
|
|
|
862
863
|
form_method: e.method,
|
|
863
864
|
form_class: e.className,
|
|
864
865
|
form_attributes: this._getElementAttributes(e)
|
|
865
|
-
},
|
|
866
|
-
return Array.from(
|
|
866
|
+
}, s = e.querySelectorAll("input, select, textarea");
|
|
867
|
+
return Array.from(s).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
|
|
867
868
|
const c = this._getFieldProps(r, o);
|
|
868
869
|
Object.assign(t, c);
|
|
869
870
|
}), t;
|
|
870
871
|
}
|
|
871
872
|
_getFieldProps(e, t) {
|
|
872
|
-
const
|
|
873
|
+
const s = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, n = this.getSafeText(e);
|
|
873
874
|
return {
|
|
874
875
|
[`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
|
|
875
876
|
[`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
|
|
876
|
-
[`field_${t + 1}_data_attributes`]:
|
|
877
|
+
[`field_${t + 1}_data_attributes`]: s,
|
|
877
878
|
[`field_${t + 1}_id`]: e.id,
|
|
878
879
|
[`field_${t + 1}_value`]: n,
|
|
879
880
|
[`field_${t + 1}_class`]: e.className,
|
|
@@ -882,12 +883,7 @@ class m {
|
|
|
882
883
|
};
|
|
883
884
|
}
|
|
884
885
|
_getElementAttributes(e) {
|
|
885
|
-
|
|
886
|
-
for (let i = 0; i < e.attributes.length; i++) {
|
|
887
|
-
const n = e.attributes[i];
|
|
888
|
-
n.name !== "value" && !n.name.startsWith("data-") && (t[n.name] = n.value);
|
|
889
|
-
}
|
|
890
|
-
return t;
|
|
886
|
+
return Object.keys(e.dataset).length ? JSON.parse(JSON.stringify(e.dataset)) : {};
|
|
891
887
|
}
|
|
892
888
|
getSafeText(e) {
|
|
893
889
|
let t = "";
|
|
@@ -910,7 +906,7 @@ class m {
|
|
|
910
906
|
_trim(e) {
|
|
911
907
|
if (typeof String.prototype.trim == "function")
|
|
912
908
|
return e.trim();
|
|
913
|
-
let t = 0,
|
|
909
|
+
let t = 0, s = e.length - 1;
|
|
914
910
|
const n = [
|
|
915
911
|
" ",
|
|
916
912
|
`
|
|
@@ -938,16 +934,16 @@ class m {
|
|
|
938
934
|
" ",
|
|
939
935
|
" "
|
|
940
936
|
].join("");
|
|
941
|
-
for (; t <=
|
|
937
|
+
for (; t <= s && n.indexOf(e[t]) > -1; )
|
|
942
938
|
t++;
|
|
943
|
-
for (;
|
|
944
|
-
|
|
945
|
-
return e.slice(t,
|
|
939
|
+
for (; s >= t && n.indexOf(e[s]) > -1; )
|
|
940
|
+
s--;
|
|
941
|
+
return e.slice(t, s + 1);
|
|
946
942
|
}
|
|
947
943
|
}
|
|
948
944
|
class pe {
|
|
949
945
|
constructor(e) {
|
|
950
|
-
this.config = this.mergeConfig(e,
|
|
946
|
+
this.config = this.mergeConfig(e, I), this.logger = h(this.config.logLevel), this.namespace = e.namespace || "usermaven", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new D(
|
|
951
947
|
this.transport,
|
|
952
948
|
this.config.maxSendAttempts || 3,
|
|
953
949
|
this.config.minSendTimeout || 1e3,
|
|
@@ -972,14 +968,14 @@ class pe {
|
|
|
972
968
|
* @param defaultConfig
|
|
973
969
|
*/
|
|
974
970
|
mergeConfig(e, t) {
|
|
975
|
-
const
|
|
976
|
-
let n = { ...t, ...
|
|
971
|
+
const s = JSON.parse(JSON.stringify(e));
|
|
972
|
+
let n = { ...t, ...s };
|
|
977
973
|
return Object.keys(t).forEach((r) => {
|
|
978
974
|
k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
|
|
979
975
|
}), n;
|
|
980
976
|
}
|
|
981
977
|
init(e) {
|
|
982
|
-
this.config = { ...this.config, ...e }, this.logger = h(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new
|
|
978
|
+
this.config = { ...this.config, ...e }, this.logger = h(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new D(
|
|
983
979
|
this.transport,
|
|
984
980
|
this.config.maxSendAttempts || 3,
|
|
985
981
|
this.config.minSendTimeout || 1e3,
|
|
@@ -992,10 +988,10 @@ class pe {
|
|
|
992
988
|
manageCrossDomainLinking() {
|
|
993
989
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
994
990
|
return;
|
|
995
|
-
const e = this.config.domains.split(",").map((
|
|
996
|
-
document.addEventListener("click", (
|
|
991
|
+
const e = this.config.domains.split(",").map((s) => s.trim()), t = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
|
|
992
|
+
document.addEventListener("click", (s) => {
|
|
997
993
|
var c;
|
|
998
|
-
const n = this.findClosestLink(
|
|
994
|
+
const n = this.findClosestLink(s.target);
|
|
999
995
|
if (!n) return;
|
|
1000
996
|
const r = n.getAttribute("href");
|
|
1001
997
|
if (!r || !r.startsWith("http")) return;
|
|
@@ -1014,28 +1010,28 @@ class pe {
|
|
|
1014
1010
|
initializeTransport(e) {
|
|
1015
1011
|
if (!u())
|
|
1016
1012
|
return new fe(e.trackingHost, e);
|
|
1017
|
-
const t = "XMLHttpRequest" in window,
|
|
1013
|
+
const t = "XMLHttpRequest" in window, s = typeof fetch < "u", n = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1018
1014
|
if (e.useBeaconApi && n)
|
|
1019
1015
|
return new ue(e.trackingHost, e, this.logger);
|
|
1020
|
-
if (e.forceUseFetch &&
|
|
1016
|
+
if (e.forceUseFetch && s)
|
|
1021
1017
|
return new U(e.trackingHost, e, this.logger);
|
|
1022
1018
|
if (t)
|
|
1023
1019
|
return new he(e.trackingHost, e, this.logger);
|
|
1024
|
-
if (
|
|
1020
|
+
if (s)
|
|
1025
1021
|
return new U(e.trackingHost, e, this.logger);
|
|
1026
1022
|
throw new Error("No suitable transport method available");
|
|
1027
1023
|
}
|
|
1028
1024
|
initializePersistence() {
|
|
1029
|
-
return this.config.disableEventPersistence || !u() ? new ge() : new
|
|
1025
|
+
return this.config.disableEventPersistence || !u() ? new ge() : new J(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1030
1026
|
}
|
|
1031
1027
|
getOrCreateAnonymousId() {
|
|
1032
|
-
var
|
|
1028
|
+
var s, n;
|
|
1033
1029
|
if (!u())
|
|
1034
1030
|
return $();
|
|
1035
1031
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1036
1032
|
return this.generateFingerprint();
|
|
1037
1033
|
const e = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
|
|
1038
|
-
let t = (
|
|
1034
|
+
let t = (s = this.cookieManager) == null ? void 0 : s.get(e);
|
|
1039
1035
|
if (!t) {
|
|
1040
1036
|
if (this.config.crossDomainLinking) {
|
|
1041
1037
|
const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), g = a.length > 1 ? a[1] : void 0;
|
|
@@ -1048,13 +1044,13 @@ class pe {
|
|
|
1048
1044
|
return t;
|
|
1049
1045
|
}
|
|
1050
1046
|
generateFingerprint() {
|
|
1051
|
-
const e = navigator.userAgent, t = `${screen.width}x${screen.height}`,
|
|
1047
|
+
const e = navigator.userAgent, t = `${screen.width}x${screen.height}`, s = screen.colorDepth, n = Intl.DateTimeFormat().resolvedOptions().timeZone, r = `${e}|${t}|${s}|${n}`;
|
|
1052
1048
|
return this.hashString(r);
|
|
1053
1049
|
}
|
|
1054
1050
|
hashString(e) {
|
|
1055
1051
|
let t = 0;
|
|
1056
|
-
for (let
|
|
1057
|
-
const n = e.charCodeAt(
|
|
1052
|
+
for (let s = 0; s < e.length; s++) {
|
|
1053
|
+
const n = e.charCodeAt(s);
|
|
1058
1054
|
t = (t << 5) - t + n, t = t & t;
|
|
1059
1055
|
}
|
|
1060
1056
|
return t.toString(36);
|
|
@@ -1066,8 +1062,8 @@ class pe {
|
|
|
1066
1062
|
throw new Error("Invalid email provided");
|
|
1067
1063
|
if (!e.id || !L(e.id))
|
|
1068
1064
|
throw new Error("User ID must be a string");
|
|
1069
|
-
const
|
|
1070
|
-
if (this.persistence.set("userId",
|
|
1065
|
+
const s = e.id;
|
|
1066
|
+
if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
|
|
1071
1067
|
const n = {
|
|
1072
1068
|
...e,
|
|
1073
1069
|
anonymous_id: this.anonymousId
|
|
@@ -1076,17 +1072,17 @@ class pe {
|
|
|
1076
1072
|
}
|
|
1077
1073
|
this.logger.info("User identified:", e);
|
|
1078
1074
|
}
|
|
1079
|
-
track(e, t,
|
|
1080
|
-
this.trackInternal(e, t,
|
|
1075
|
+
track(e, t, s = !1) {
|
|
1076
|
+
this.trackInternal(e, t, s);
|
|
1081
1077
|
}
|
|
1082
|
-
trackInternal(e, t,
|
|
1078
|
+
trackInternal(e, t, s = !1) {
|
|
1083
1079
|
if (!L(e))
|
|
1084
1080
|
throw new Error("Event name must be a string");
|
|
1085
1081
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1086
1082
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
1087
1083
|
const n = this.createEventPayload(e, t);
|
|
1088
1084
|
try {
|
|
1089
|
-
if (
|
|
1085
|
+
if (s) {
|
|
1090
1086
|
this.transport.send(n), this.logger.debug(`Event sent: ${e}`, [n]);
|
|
1091
1087
|
return;
|
|
1092
1088
|
}
|
|
@@ -1108,14 +1104,14 @@ class pe {
|
|
|
1108
1104
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1109
1105
|
}
|
|
1110
1106
|
createEventPayload(e, t) {
|
|
1111
|
-
const
|
|
1107
|
+
const s = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || void 0, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
|
|
1112
1108
|
let l = t || {};
|
|
1113
1109
|
const a = {
|
|
1114
1110
|
event_id: "",
|
|
1115
1111
|
user: {
|
|
1116
1112
|
anonymous_id: this.anonymousId,
|
|
1117
1113
|
id: r,
|
|
1118
|
-
...
|
|
1114
|
+
...s
|
|
1119
1115
|
},
|
|
1120
1116
|
...n && { company: n },
|
|
1121
1117
|
ids: this.getThirdPartyIds(),
|
|
@@ -1139,8 +1135,8 @@ class pe {
|
|
|
1139
1135
|
}
|
|
1140
1136
|
processAutocaptureAttributes(e) {
|
|
1141
1137
|
let t = {};
|
|
1142
|
-
const
|
|
1143
|
-
return
|
|
1138
|
+
const s = e.$elements || [];
|
|
1139
|
+
return s.length && (t = { ...s[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", ["$ce_version", "$event_type", "$initial_referrer", "$initial_referring_domain", "$referrer", "$referring_domain", "$elements"].forEach((n) => {
|
|
1144
1140
|
delete t[n];
|
|
1145
1141
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1146
1142
|
}
|
|
@@ -1172,7 +1168,7 @@ class pe {
|
|
|
1172
1168
|
setupPageLeaveTracking() {
|
|
1173
1169
|
if (!u()) return;
|
|
1174
1170
|
let e = !1, t = !1;
|
|
1175
|
-
const
|
|
1171
|
+
const s = () => {
|
|
1176
1172
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
1177
1173
|
url: window.location.href,
|
|
1178
1174
|
referrer: document.referrer,
|
|
@@ -1184,12 +1180,12 @@ class pe {
|
|
|
1184
1180
|
t = !1;
|
|
1185
1181
|
}, 100);
|
|
1186
1182
|
}), document.addEventListener("visibilitychange", () => {
|
|
1187
|
-
document.visibilityState === "hidden" && !t &&
|
|
1183
|
+
document.visibilityState === "hidden" && !t && s();
|
|
1188
1184
|
});
|
|
1189
1185
|
const n = history.pushState;
|
|
1190
1186
|
history.pushState = function() {
|
|
1191
|
-
return
|
|
1192
|
-
}, window.addEventListener("popstate",
|
|
1187
|
+
return s(), n.apply(this, arguments);
|
|
1188
|
+
}, window.addEventListener("popstate", s);
|
|
1193
1189
|
}
|
|
1194
1190
|
getConfig() {
|
|
1195
1191
|
return this.config;
|
|
@@ -1207,17 +1203,17 @@ class pe {
|
|
|
1207
1203
|
set(e, t) {
|
|
1208
1204
|
if (!k(e))
|
|
1209
1205
|
throw new Error("Properties must be an object");
|
|
1210
|
-
const
|
|
1211
|
-
if (
|
|
1212
|
-
let r = this.persistence.get(`props_${
|
|
1213
|
-
r = { ...r, ...e }, this.persistence.set(`props_${
|
|
1206
|
+
const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1207
|
+
if (s) {
|
|
1208
|
+
let r = this.persistence.get(`props_${s}`) || {};
|
|
1209
|
+
r = { ...r, ...e }, this.persistence.set(`props_${s}`, r);
|
|
1214
1210
|
} else {
|
|
1215
1211
|
let r = this.persistence.get("global_props") || {};
|
|
1216
1212
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1217
1213
|
}
|
|
1218
1214
|
n && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1219
1215
|
properties: e,
|
|
1220
|
-
eventType:
|
|
1216
|
+
eventType: s || "global",
|
|
1221
1217
|
persist: n
|
|
1222
1218
|
});
|
|
1223
1219
|
}
|
|
@@ -1227,100 +1223,100 @@ class pe {
|
|
|
1227
1223
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1228
1224
|
}
|
|
1229
1225
|
unset(e, t) {
|
|
1230
|
-
const
|
|
1231
|
-
if (
|
|
1232
|
-
let r = this.persistence.get(`props_${
|
|
1233
|
-
delete r[e], this.persistence.set(`props_${
|
|
1226
|
+
const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
|
|
1227
|
+
if (s) {
|
|
1228
|
+
let r = this.persistence.get(`props_${s}`) || {};
|
|
1229
|
+
delete r[e], this.persistence.set(`props_${s}`, r);
|
|
1234
1230
|
} else {
|
|
1235
1231
|
let r = this.persistence.get("global_props") || {};
|
|
1236
1232
|
delete r[e], this.persistence.set("global_props", r);
|
|
1237
1233
|
}
|
|
1238
|
-
n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${
|
|
1234
|
+
n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
|
|
1239
1235
|
}
|
|
1240
1236
|
}
|
|
1241
|
-
function me(
|
|
1242
|
-
const e = JSON.parse(JSON.stringify(
|
|
1243
|
-
if (!
|
|
1237
|
+
function me(i) {
|
|
1238
|
+
const e = JSON.parse(JSON.stringify(i)), t = C(e), s = { ...I, ...t };
|
|
1239
|
+
if (!s.key)
|
|
1244
1240
|
throw new Error("API key is required!");
|
|
1245
|
-
if (!
|
|
1241
|
+
if (!s.trackingHost)
|
|
1246
1242
|
throw new Error("Tracking host is required!");
|
|
1247
|
-
return new pe(
|
|
1243
|
+
return new pe(s);
|
|
1248
1244
|
}
|
|
1249
|
-
function ye(
|
|
1245
|
+
function ye(i) {
|
|
1250
1246
|
var n;
|
|
1251
1247
|
const e = {
|
|
1252
|
-
key:
|
|
1253
|
-
trackingHost:
|
|
1254
|
-
logLevel: ae(
|
|
1255
|
-
autocapture:
|
|
1256
|
-
formTracking:
|
|
1257
|
-
autoPageview:
|
|
1258
|
-
useBeaconApi:
|
|
1259
|
-
forceUseFetch:
|
|
1260
|
-
gaHook:
|
|
1261
|
-
segmentHook:
|
|
1262
|
-
randomizeUrl:
|
|
1263
|
-
capture3rdPartyCookies:
|
|
1264
|
-
idMethod:
|
|
1265
|
-
privacyPolicy:
|
|
1266
|
-
ipPolicy:
|
|
1267
|
-
cookiePolicy:
|
|
1268
|
-
minSendTimeout: parseInt(
|
|
1269
|
-
maxSendTimeout: parseInt(
|
|
1270
|
-
maxSendAttempts: parseInt(
|
|
1271
|
-
propertiesStringMaxLength: parseInt(
|
|
1272
|
-
propertyBlacklist: ((n =
|
|
1273
|
-
exclude:
|
|
1274
|
-
namespace:
|
|
1275
|
-
crossDomainLinking:
|
|
1276
|
-
domains:
|
|
1277
|
-
maskAllText:
|
|
1278
|
-
maskAllElementAttributes:
|
|
1279
|
-
}, t = me(e),
|
|
1280
|
-
u() && t.pageview(), we(
|
|
1248
|
+
key: i.getAttribute("data-key") || void 0,
|
|
1249
|
+
trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1250
|
+
logLevel: ae(i.getAttribute("data-log-level")),
|
|
1251
|
+
autocapture: i.getAttribute("data-autocapture") === "true",
|
|
1252
|
+
formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
|
|
1253
|
+
autoPageview: i.getAttribute("data-auto-pageview") === "true",
|
|
1254
|
+
useBeaconApi: i.getAttribute("data-use-beacon-api") === "true",
|
|
1255
|
+
forceUseFetch: i.getAttribute("data-force-use-fetch") === "true",
|
|
1256
|
+
gaHook: i.getAttribute("data-ga-hook") === "true",
|
|
1257
|
+
segmentHook: i.getAttribute("data-segment-hook") === "true",
|
|
1258
|
+
randomizeUrl: i.getAttribute("data-randomize-url") === "true",
|
|
1259
|
+
capture3rdPartyCookies: i.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
|
|
1260
|
+
idMethod: i.getAttribute("data-id-method") || void 0,
|
|
1261
|
+
privacyPolicy: i.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
|
|
1262
|
+
ipPolicy: i.getAttribute("data-ip-policy") || void 0,
|
|
1263
|
+
cookiePolicy: i.getAttribute("data-cookie-policy") || void 0,
|
|
1264
|
+
minSendTimeout: parseInt(i.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1265
|
+
maxSendTimeout: parseInt(i.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1266
|
+
maxSendAttempts: parseInt(i.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1267
|
+
propertiesStringMaxLength: parseInt(i.getAttribute("data-properties-string-max-length") || "", 10) || null,
|
|
1268
|
+
propertyBlacklist: ((n = i.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
|
|
1269
|
+
exclude: i.getAttribute("data-exclude") || void 0,
|
|
1270
|
+
namespace: i.getAttribute("data-namespace") || void 0,
|
|
1271
|
+
crossDomainLinking: i.getAttribute("data-cross-domain-linking") !== "false",
|
|
1272
|
+
domains: i.getAttribute("data-domains") || void 0,
|
|
1273
|
+
maskAllText: i.getAttribute("data-mask-all-text") === "true",
|
|
1274
|
+
maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1275
|
+
}, t = me(e), s = e.namespace || "usermaven";
|
|
1276
|
+
u() && t.pageview(), we(s, t);
|
|
1281
1277
|
}
|
|
1282
|
-
function we(
|
|
1278
|
+
function we(i, e) {
|
|
1283
1279
|
let t = !1;
|
|
1284
|
-
const
|
|
1280
|
+
const s = [], n = [];
|
|
1285
1281
|
function r() {
|
|
1286
|
-
for (;
|
|
1287
|
-
const a =
|
|
1288
|
-
a && window[
|
|
1282
|
+
for (; s.length > 0; ) {
|
|
1283
|
+
const a = s.shift();
|
|
1284
|
+
a && window[i].apply(null, a);
|
|
1289
1285
|
}
|
|
1290
1286
|
}
|
|
1291
1287
|
function o() {
|
|
1292
1288
|
n.forEach((a) => a()), n.length = 0;
|
|
1293
1289
|
}
|
|
1294
|
-
window[
|
|
1290
|
+
window[i] = function(...a) {
|
|
1295
1291
|
const g = a[0];
|
|
1296
1292
|
if (g === "onLoad") {
|
|
1297
1293
|
typeof a[1] == "function" && (t ? a[1]() : n.push(a[1]));
|
|
1298
1294
|
return;
|
|
1299
1295
|
}
|
|
1300
1296
|
if (!t) {
|
|
1301
|
-
|
|
1297
|
+
s.push(a);
|
|
1302
1298
|
return;
|
|
1303
1299
|
}
|
|
1304
1300
|
if (typeof e[g] == "function")
|
|
1305
1301
|
return e[g].apply(e, a.slice(1));
|
|
1306
1302
|
console.error(`Method ${g} not found on UsermavenClient`);
|
|
1307
1303
|
};
|
|
1308
|
-
const c = `${
|
|
1304
|
+
const c = `${i}Q`, l = window[c] || [];
|
|
1309
1305
|
for (window[c] = l, l.push = function(...a) {
|
|
1310
|
-
return window[
|
|
1306
|
+
return window[i].apply(null, a), Array.prototype.push.apply(this, a);
|
|
1311
1307
|
}, setTimeout(() => {
|
|
1312
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1308
|
+
t = !0, r(), o(), console.log(`Usermaven client for namespace ${i} is ready`);
|
|
1313
1309
|
}, 0); l.length > 0; ) {
|
|
1314
1310
|
const a = l.shift();
|
|
1315
|
-
a &&
|
|
1311
|
+
a && s.push(a);
|
|
1316
1312
|
}
|
|
1317
1313
|
}
|
|
1318
|
-
u() && function(
|
|
1319
|
-
const t =
|
|
1320
|
-
function
|
|
1314
|
+
u() && function(i, e) {
|
|
1315
|
+
const t = i.currentScript;
|
|
1316
|
+
function s() {
|
|
1321
1317
|
t && t.src.includes("lib.js") && ye(t);
|
|
1322
1318
|
}
|
|
1323
|
-
typeof e < "u" && (
|
|
1319
|
+
typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
|
|
1324
1320
|
}(document, window);
|
|
1325
1321
|
export {
|
|
1326
1322
|
v as LogLevel,
|