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