@usermaven/sdk-js 1.5.4 → 1.5.5-rc.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +462 -411
- package/dist/utils/amd-detector.d.ts +2 -0
- package/dist/utils/helpers.d.ts +1 -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,11 +16,11 @@ 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",
|
|
@@ -45,20 +45,20 @@ const U = {
|
|
|
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,57 +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
|
-
|
|
353
|
+
const me = () => {
|
|
354
|
+
let n = "false";
|
|
355
|
+
return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
|
|
356
|
+
};
|
|
357
|
+
class ye {
|
|
354
358
|
constructor(e) {
|
|
355
|
-
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();
|
|
356
360
|
}
|
|
357
361
|
initializeEventListener() {
|
|
358
362
|
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
@@ -376,8 +380,8 @@ class he {
|
|
|
376
380
|
this.track();
|
|
377
381
|
}
|
|
378
382
|
getScrollDepth() {
|
|
379
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(),
|
|
380
|
-
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));
|
|
381
385
|
}
|
|
382
386
|
getWindowHeight() {
|
|
383
387
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -396,27 +400,38 @@ class he {
|
|
|
396
400
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
397
401
|
}
|
|
398
402
|
checkMilestones(e) {
|
|
399
|
-
this.milestones.filter((
|
|
400
|
-
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);
|
|
401
405
|
});
|
|
402
406
|
}
|
|
403
407
|
}
|
|
404
|
-
const
|
|
405
|
-
constructor(e, t,
|
|
406
|
-
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";
|
|
407
414
|
}
|
|
408
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
|
+
}
|
|
409
424
|
if (!(document && document.body)) {
|
|
410
425
|
this.logger.debug("Document not ready yet, trying again in 500 milliseconds..."), setTimeout(() => this.init(), 500);
|
|
411
426
|
return;
|
|
412
427
|
}
|
|
413
|
-
this.addDomEventHandlers();
|
|
428
|
+
this.addDomEventHandlers(), this.domHandlersAttached = !0;
|
|
414
429
|
}
|
|
415
430
|
addDomEventHandlers() {
|
|
416
431
|
const e = (t) => {
|
|
417
432
|
t = t || window.event, this.captureEvent(t);
|
|
418
433
|
};
|
|
419
|
-
|
|
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);
|
|
420
435
|
}
|
|
421
436
|
isPageRefresh() {
|
|
422
437
|
if ("PerformanceNavigationTiming" in window) {
|
|
@@ -427,17 +442,17 @@ const C = class C {
|
|
|
427
442
|
return performance.navigation && performance.navigation.type === 1;
|
|
428
443
|
}
|
|
429
444
|
captureEvent(e) {
|
|
430
|
-
var
|
|
445
|
+
var i, s;
|
|
431
446
|
let t = this.getEventTarget(e);
|
|
432
|
-
if (
|
|
433
|
-
return (
|
|
447
|
+
if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
448
|
+
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
434
449
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
435
|
-
return this.isPageRefresh() || (
|
|
436
|
-
if (t &&
|
|
450
|
+
return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
|
|
451
|
+
if (t && ue(t, e)) {
|
|
437
452
|
const r = [t];
|
|
438
453
|
let o = t;
|
|
439
|
-
for (; o.parentNode && !
|
|
440
|
-
if (
|
|
454
|
+
for (; o.parentNode && !f(o, "body"); ) {
|
|
455
|
+
if (O(o.parentNode)) {
|
|
441
456
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
442
457
|
continue;
|
|
443
458
|
}
|
|
@@ -445,20 +460,20 @@ const C = class C {
|
|
|
445
460
|
}
|
|
446
461
|
const c = [];
|
|
447
462
|
let l, a = !1;
|
|
448
|
-
if (
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
_(
|
|
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(
|
|
453
468
|
this.getPropertiesFromElement(
|
|
454
|
-
|
|
469
|
+
k,
|
|
455
470
|
this.options.maskAllElementAttributes ?? !1,
|
|
456
471
|
this.options.maskAllText ?? !1
|
|
457
472
|
)
|
|
458
473
|
);
|
|
459
|
-
}), this.options.maskAllText || (c[0].$el_text =
|
|
474
|
+
}), this.options.maskAllText || (c[0].$el_text = D(t)), l && (c[0].attr__href = l), a)
|
|
460
475
|
return !1;
|
|
461
|
-
const h =
|
|
476
|
+
const h = re(
|
|
462
477
|
this.getDefaultProperties(e.type),
|
|
463
478
|
{
|
|
464
479
|
$elements: c
|
|
@@ -470,36 +485,36 @@ const C = class C {
|
|
|
470
485
|
}
|
|
471
486
|
getCustomProperties(e) {
|
|
472
487
|
const t = {};
|
|
473
|
-
return
|
|
474
|
-
|
|
475
|
-
const r = document.querySelectorAll(
|
|
476
|
-
|
|
477
|
-
_(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));
|
|
478
493
|
});
|
|
479
494
|
});
|
|
480
495
|
}), t;
|
|
481
496
|
}
|
|
482
497
|
extractCustomPropertyValue(e) {
|
|
483
498
|
const t = [];
|
|
484
|
-
return
|
|
485
|
-
let
|
|
486
|
-
["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);
|
|
487
502
|
}), t.join(", ");
|
|
488
503
|
}
|
|
489
504
|
getEventTarget(e) {
|
|
490
505
|
var t;
|
|
491
506
|
return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
492
507
|
}
|
|
493
|
-
getPropertiesFromElement(e, t,
|
|
494
|
-
const
|
|
495
|
-
tag_name:
|
|
508
|
+
getPropertiesFromElement(e, t, i) {
|
|
509
|
+
const s = e.tagName.toLowerCase(), r = {
|
|
510
|
+
tag_name: s
|
|
496
511
|
};
|
|
497
|
-
b.indexOf(
|
|
498
|
-
const o =
|
|
512
|
+
b.indexOf(s) > -1 && !i && (r.$el_text = D(e));
|
|
513
|
+
const o = A(e);
|
|
499
514
|
o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
|
|
500
515
|
return h !== "";
|
|
501
|
-
})),
|
|
502
|
-
|
|
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);
|
|
503
518
|
});
|
|
504
519
|
let c = 1, l = 1, a = e;
|
|
505
520
|
for (; a = this.previousElementSibling(a); )
|
|
@@ -513,7 +528,7 @@ const C = class C {
|
|
|
513
528
|
let t = e;
|
|
514
529
|
do
|
|
515
530
|
t = t.previousSibling;
|
|
516
|
-
while (t && !
|
|
531
|
+
while (t && !J(t));
|
|
517
532
|
return t;
|
|
518
533
|
}
|
|
519
534
|
}
|
|
@@ -526,18 +541,18 @@ const C = class C {
|
|
|
526
541
|
encodeHtml(e) {
|
|
527
542
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
528
543
|
}
|
|
529
|
-
static enabledForProject(e, t = 10,
|
|
544
|
+
static enabledForProject(e, t = 10, i = 10) {
|
|
530
545
|
if (!e)
|
|
531
546
|
return !1;
|
|
532
|
-
let
|
|
547
|
+
let s = 0;
|
|
533
548
|
for (let r = 0; r < e.length; r++)
|
|
534
|
-
|
|
535
|
-
return
|
|
549
|
+
s += e.charCodeAt(r);
|
|
550
|
+
return s % t < i;
|
|
536
551
|
}
|
|
537
552
|
};
|
|
538
|
-
|
|
539
|
-
let
|
|
540
|
-
class
|
|
553
|
+
T.FORCE_CAPTURE_ATTR = "data-um-force-capture", T.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
554
|
+
let $ = T;
|
|
555
|
+
class we {
|
|
541
556
|
constructor(e) {
|
|
542
557
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
543
558
|
}
|
|
@@ -566,44 +581,44 @@ class de {
|
|
|
566
581
|
}));
|
|
567
582
|
}
|
|
568
583
|
}
|
|
569
|
-
class
|
|
570
|
-
constructor(e, t,
|
|
571
|
-
this.trackingHost = e, this.logger =
|
|
584
|
+
class ke {
|
|
585
|
+
constructor(e, t, i = d()) {
|
|
586
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
572
587
|
}
|
|
573
588
|
async send(e) {
|
|
574
|
-
const t = this.config.key,
|
|
575
|
-
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))
|
|
576
591
|
this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
|
|
577
592
|
else
|
|
578
593
|
throw new Error("Failed to queue events via Beacon API");
|
|
579
594
|
}
|
|
580
595
|
constructUrl(e) {
|
|
581
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
582
|
-
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}`;
|
|
583
598
|
}
|
|
584
599
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
585
600
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
586
601
|
}
|
|
587
|
-
class
|
|
588
|
-
constructor(e, t,
|
|
589
|
-
this.trackingHost = e, this.logger =
|
|
602
|
+
class z {
|
|
603
|
+
constructor(e, t, i = d()) {
|
|
604
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
590
605
|
}
|
|
591
606
|
async send(e) {
|
|
592
|
-
const t = this.config.key,
|
|
607
|
+
const t = this.config.key, i = this.constructUrl(t), s = JSON.stringify(e), r = {
|
|
593
608
|
"Content-Type": "application/json",
|
|
594
609
|
...this.getCustomHeaders()
|
|
595
|
-
}, o = await fetch(
|
|
610
|
+
}, o = await fetch(i, {
|
|
596
611
|
method: "POST",
|
|
597
612
|
headers: r,
|
|
598
|
-
body:
|
|
613
|
+
body: s
|
|
599
614
|
});
|
|
600
615
|
if (!o.ok)
|
|
601
616
|
throw new Error(`HTTP error! status: ${o.status}`);
|
|
602
617
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
603
618
|
}
|
|
604
619
|
constructUrl(e) {
|
|
605
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
606
|
-
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}`;
|
|
607
622
|
}
|
|
608
623
|
getCustomHeaders() {
|
|
609
624
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -612,27 +627,27 @@ class D {
|
|
|
612
627
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
613
628
|
}
|
|
614
629
|
}
|
|
615
|
-
class
|
|
616
|
-
constructor(e, t,
|
|
617
|
-
this.trackingHost = e, this.logger =
|
|
630
|
+
class ve {
|
|
631
|
+
constructor(e, t, i = d()) {
|
|
632
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
618
633
|
}
|
|
619
634
|
send(e) {
|
|
620
|
-
return new Promise((t,
|
|
621
|
-
const
|
|
622
|
-
|
|
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");
|
|
623
638
|
const c = this.getCustomHeaders();
|
|
624
639
|
Object.keys(c).forEach((l) => {
|
|
625
|
-
|
|
626
|
-
}),
|
|
627
|
-
|
|
628
|
-
},
|
|
629
|
-
|
|
630
|
-
},
|
|
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));
|
|
631
646
|
});
|
|
632
647
|
}
|
|
633
648
|
constructUrl(e) {
|
|
634
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
635
|
-
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}`;
|
|
636
651
|
}
|
|
637
652
|
getCustomHeaders() {
|
|
638
653
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -641,7 +656,7 @@ class fe {
|
|
|
641
656
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
642
657
|
}
|
|
643
658
|
}
|
|
644
|
-
class
|
|
659
|
+
class K {
|
|
645
660
|
constructor(e, t) {
|
|
646
661
|
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
|
|
647
662
|
}
|
|
@@ -681,7 +696,7 @@ class V {
|
|
|
681
696
|
}
|
|
682
697
|
}
|
|
683
698
|
}
|
|
684
|
-
class
|
|
699
|
+
class _e {
|
|
685
700
|
constructor() {
|
|
686
701
|
this.storage = {};
|
|
687
702
|
}
|
|
@@ -700,10 +715,10 @@ class pe {
|
|
|
700
715
|
this.storage = {};
|
|
701
716
|
}
|
|
702
717
|
}
|
|
703
|
-
class
|
|
718
|
+
class B {
|
|
704
719
|
// Default to true for server-side
|
|
705
|
-
constructor(e, t = 3,
|
|
706
|
-
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());
|
|
707
722
|
}
|
|
708
723
|
add(e) {
|
|
709
724
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -722,11 +737,11 @@ class F {
|
|
|
722
737
|
async processBatch() {
|
|
723
738
|
if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
724
739
|
this.processing = !0;
|
|
725
|
-
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);
|
|
726
741
|
try {
|
|
727
742
|
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
|
|
728
|
-
} catch (
|
|
729
|
-
this.logger.error("Failed to send batch",
|
|
743
|
+
} catch (i) {
|
|
744
|
+
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
730
745
|
}
|
|
731
746
|
this.processing = !1;
|
|
732
747
|
}
|
|
@@ -747,9 +762,9 @@ class F {
|
|
|
747
762
|
u() && this.persistence.set("queue", JSON.stringify(this.queue));
|
|
748
763
|
}
|
|
749
764
|
}
|
|
750
|
-
class
|
|
765
|
+
class be {
|
|
751
766
|
constructor(e) {
|
|
752
|
-
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);
|
|
753
768
|
}
|
|
754
769
|
initializeEventListener() {
|
|
755
770
|
document.addEventListener("click", this.handleClick.bind(this));
|
|
@@ -761,17 +776,17 @@ class me {
|
|
|
761
776
|
shouldCaptureElement(e) {
|
|
762
777
|
return !e.closest(".um-no-capture");
|
|
763
778
|
}
|
|
764
|
-
click(e, t,
|
|
765
|
-
const
|
|
766
|
-
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();
|
|
767
782
|
}
|
|
768
783
|
checkRageClick() {
|
|
769
|
-
const e = this.clicks[0],
|
|
784
|
+
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
770
785
|
this.clicks.every((r, o) => {
|
|
771
786
|
if (o === 0) return !0;
|
|
772
787
|
const c = this.clicks[o - 1];
|
|
773
788
|
return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
|
|
774
|
-
}) && this.sendRageClickEvent(
|
|
789
|
+
}) && this.sendRageClickEvent(i);
|
|
775
790
|
}
|
|
776
791
|
sendRageClickEvent(e) {
|
|
777
792
|
const t = this.clicks[this.clicks.length - 1];
|
|
@@ -781,15 +796,15 @@ class me {
|
|
|
781
796
|
}), this.clicks = [];
|
|
782
797
|
}
|
|
783
798
|
}
|
|
784
|
-
class
|
|
785
|
-
constructor(e, t,
|
|
786
|
-
this.trackingHost = e, this.logger =
|
|
799
|
+
class Ee {
|
|
800
|
+
constructor(e, t, i = d()) {
|
|
801
|
+
this.trackingHost = e, this.logger = i, this.config = t;
|
|
787
802
|
}
|
|
788
803
|
async send(e) {
|
|
789
|
-
const t = this.config.key,
|
|
790
|
-
hostname:
|
|
804
|
+
const t = this.config.key, i = new (void 0)(this.constructUrl(t)), s = {
|
|
805
|
+
hostname: i.hostname,
|
|
791
806
|
port: 443,
|
|
792
|
-
path: `${
|
|
807
|
+
path: `${i.pathname}${i.search}`,
|
|
793
808
|
method: "POST",
|
|
794
809
|
headers: {
|
|
795
810
|
"Content-Type": "application/json",
|
|
@@ -797,7 +812,7 @@ class ye {
|
|
|
797
812
|
}
|
|
798
813
|
};
|
|
799
814
|
return new Promise((r, o) => {
|
|
800
|
-
const c = (void 0)(
|
|
815
|
+
const c = (void 0)(s, (l) => {
|
|
801
816
|
l.on("data", (a) => {
|
|
802
817
|
}), l.on("end", () => {
|
|
803
818
|
const a = l.statusCode || 0;
|
|
@@ -810,16 +825,16 @@ class ye {
|
|
|
810
825
|
});
|
|
811
826
|
}
|
|
812
827
|
constructUrl(e) {
|
|
813
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "",
|
|
814
|
-
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}`;
|
|
815
830
|
}
|
|
816
831
|
getCustomHeaders() {
|
|
817
832
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
818
833
|
}
|
|
819
834
|
}
|
|
820
|
-
class
|
|
821
|
-
constructor(e, t = "all",
|
|
822
|
-
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();
|
|
823
838
|
}
|
|
824
839
|
initialize() {
|
|
825
840
|
this.trackingType !== "none" && this.setupFormTracking();
|
|
@@ -831,19 +846,19 @@ class y {
|
|
|
831
846
|
});
|
|
832
847
|
}
|
|
833
848
|
handleFormSubmit(e) {
|
|
834
|
-
const t = e.target,
|
|
835
|
-
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);
|
|
836
851
|
}
|
|
837
852
|
trackFieldChanges(e) {
|
|
838
|
-
e.querySelectorAll("input, select, textarea").forEach((
|
|
839
|
-
|
|
840
|
-
const r = this._getFieldProps(
|
|
841
|
-
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));
|
|
842
857
|
});
|
|
843
858
|
});
|
|
844
859
|
}
|
|
845
|
-
static getInstance(e, t = "all",
|
|
846
|
-
return
|
|
860
|
+
static getInstance(e, t = "all", i = {}) {
|
|
861
|
+
return w.instance || (w.instance = new w(e, t, i)), w.instance;
|
|
847
862
|
}
|
|
848
863
|
_getFormDetails(e) {
|
|
849
864
|
const t = {
|
|
@@ -853,20 +868,20 @@ class y {
|
|
|
853
868
|
form_method: e.method,
|
|
854
869
|
form_class: e.className,
|
|
855
870
|
form_attributes: this._getElementAttributes(e)
|
|
856
|
-
},
|
|
857
|
-
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) => {
|
|
858
873
|
const c = this._getFieldProps(r, o);
|
|
859
874
|
Object.assign(t, c);
|
|
860
875
|
}), t;
|
|
861
876
|
}
|
|
862
877
|
_getFieldProps(e, t) {
|
|
863
|
-
const
|
|
878
|
+
const i = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, s = this.getSafeText(e);
|
|
864
879
|
return {
|
|
865
880
|
[`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
|
|
866
881
|
[`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
|
|
867
|
-
[`field_${t + 1}_data_attributes`]:
|
|
882
|
+
[`field_${t + 1}_data_attributes`]: i,
|
|
868
883
|
[`field_${t + 1}_id`]: e.id,
|
|
869
|
-
[`field_${t + 1}_value`]:
|
|
884
|
+
[`field_${t + 1}_value`]: s,
|
|
870
885
|
[`field_${t + 1}_class`]: e.className,
|
|
871
886
|
[`field_${t + 1}_name`]: e.name,
|
|
872
887
|
[`field_${t + 1}_attributes`]: this._getElementAttributes(e)
|
|
@@ -878,8 +893,8 @@ class y {
|
|
|
878
893
|
getSafeText(e) {
|
|
879
894
|
let t = "";
|
|
880
895
|
return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
|
|
881
|
-
(
|
|
882
|
-
).map((
|
|
896
|
+
(s) => s.nodeType === Node.TEXT_NODE
|
|
897
|
+
).map((s) => s.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
|
|
883
898
|
}
|
|
884
899
|
_scrubPotentiallySensitiveValues(e) {
|
|
885
900
|
return this._shouldCaptureValue(e) ? e : "<redacted>";
|
|
@@ -896,8 +911,8 @@ class y {
|
|
|
896
911
|
_trim(e) {
|
|
897
912
|
if (typeof String.prototype.trim == "function")
|
|
898
913
|
return e.trim();
|
|
899
|
-
let t = 0,
|
|
900
|
-
const
|
|
914
|
+
let t = 0, i = e.length - 1;
|
|
915
|
+
const s = [
|
|
901
916
|
" ",
|
|
902
917
|
`
|
|
903
918
|
`,
|
|
@@ -924,16 +939,16 @@ class y {
|
|
|
924
939
|
" ",
|
|
925
940
|
" "
|
|
926
941
|
].join("");
|
|
927
|
-
for (; t <=
|
|
942
|
+
for (; t <= i && s.indexOf(e[t]) > -1; )
|
|
928
943
|
t++;
|
|
929
|
-
for (;
|
|
930
|
-
|
|
931
|
-
return e.slice(t,
|
|
944
|
+
for (; i >= t && s.indexOf(e[i]) > -1; )
|
|
945
|
+
i--;
|
|
946
|
+
return e.slice(t, i + 1);
|
|
932
947
|
}
|
|
933
948
|
}
|
|
934
|
-
class
|
|
949
|
+
class S {
|
|
935
950
|
constructor(e) {
|
|
936
|
-
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(
|
|
937
952
|
this.transport,
|
|
938
953
|
this.config.maxSendAttempts || 3,
|
|
939
954
|
this.config.minSendTimeout || 1e3,
|
|
@@ -945,13 +960,13 @@ class we {
|
|
|
945
960
|
), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
|
|
946
961
|
}
|
|
947
962
|
initializeBrowserFeatures() {
|
|
948
|
-
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) {
|
|
949
964
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
950
|
-
this.formTracking =
|
|
965
|
+
this.formTracking = w.getInstance(this, e || "none", {
|
|
951
966
|
trackFieldChanges: !1
|
|
952
967
|
});
|
|
953
968
|
}
|
|
954
|
-
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();
|
|
955
970
|
}
|
|
956
971
|
/**
|
|
957
972
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -959,14 +974,14 @@ class we {
|
|
|
959
974
|
* @param defaultConfig
|
|
960
975
|
*/
|
|
961
976
|
mergeConfig(e, t) {
|
|
962
|
-
const
|
|
963
|
-
let
|
|
977
|
+
const i = JSON.parse(JSON.stringify(e));
|
|
978
|
+
let s = { ...t, ...i };
|
|
964
979
|
return Object.keys(t).forEach((r) => {
|
|
965
|
-
|
|
966
|
-
}),
|
|
980
|
+
v(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
|
|
981
|
+
}), s;
|
|
967
982
|
}
|
|
968
983
|
init(e) {
|
|
969
|
-
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(
|
|
970
985
|
this.transport,
|
|
971
986
|
this.config.maxSendAttempts || 3,
|
|
972
987
|
this.config.minSendTimeout || 1e3,
|
|
@@ -980,17 +995,17 @@ class we {
|
|
|
980
995
|
manageCrossDomainLinking() {
|
|
981
996
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
982
997
|
return;
|
|
983
|
-
const e = this.config.domains.split(",").map((
|
|
984
|
-
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) => {
|
|
985
1000
|
var c;
|
|
986
|
-
const
|
|
987
|
-
if (!
|
|
988
|
-
const r =
|
|
1001
|
+
const s = this.findClosestLink(i.target);
|
|
1002
|
+
if (!s) return;
|
|
1003
|
+
const r = s.getAttribute("href");
|
|
989
1004
|
if (!r || !r.startsWith("http")) return;
|
|
990
1005
|
const o = new URL(r);
|
|
991
1006
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
992
1007
|
const l = (c = this.cookieManager) == null ? void 0 : c.get(t);
|
|
993
|
-
l && (o.searchParams.append("_um", l),
|
|
1008
|
+
l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
|
|
994
1009
|
}
|
|
995
1010
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
996
1011
|
}
|
|
@@ -1002,99 +1017,103 @@ class we {
|
|
|
1002
1017
|
initializeTransport(e) {
|
|
1003
1018
|
const t = "https://events.usermaven.com";
|
|
1004
1019
|
if (!u())
|
|
1005
|
-
return new
|
|
1006
|
-
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;
|
|
1007
1022
|
if (e.useBeaconApi && r)
|
|
1008
|
-
return new
|
|
1009
|
-
if (e.forceUseFetch &&
|
|
1010
|
-
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);
|
|
1011
1028
|
if (s)
|
|
1012
|
-
return new
|
|
1013
|
-
if (n)
|
|
1014
|
-
return new D(e.trackingHost || t, e, this.logger);
|
|
1029
|
+
return new z(e.trackingHost || t, e, this.logger);
|
|
1015
1030
|
throw new Error("No suitable transport method available");
|
|
1016
1031
|
}
|
|
1017
1032
|
initializePersistence() {
|
|
1018
|
-
return this.config.disableEventPersistence || !u() ? new
|
|
1033
|
+
return this.config.disableEventPersistence || !u() ? new _e() : new K(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1019
1034
|
}
|
|
1020
1035
|
getOrCreateAnonymousId() {
|
|
1021
|
-
var
|
|
1036
|
+
var i, s;
|
|
1022
1037
|
if (!u())
|
|
1023
|
-
return
|
|
1038
|
+
return x();
|
|
1024
1039
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1025
1040
|
return "";
|
|
1026
1041
|
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1027
|
-
let t = (
|
|
1042
|
+
let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
|
|
1028
1043
|
if (!t) {
|
|
1029
1044
|
if (this.config.crossDomainLinking) {
|
|
1030
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;
|
|
1031
|
-
t = c || h ||
|
|
1046
|
+
t = c || h || x();
|
|
1032
1047
|
}
|
|
1033
|
-
t || (t =
|
|
1048
|
+
t || (t = x());
|
|
1034
1049
|
const r = 365 * 10;
|
|
1035
|
-
(
|
|
1050
|
+
(s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
|
|
1036
1051
|
}
|
|
1037
1052
|
return t;
|
|
1038
1053
|
}
|
|
1039
1054
|
async id(e, t = !1) {
|
|
1040
|
-
if (!
|
|
1055
|
+
if (!v(e))
|
|
1041
1056
|
throw new Error("User data must be an object");
|
|
1042
|
-
if (e.email && !
|
|
1057
|
+
if (e.email && !de(e.email))
|
|
1043
1058
|
throw new Error("Invalid email provided");
|
|
1044
|
-
if (!e.id || !
|
|
1059
|
+
if (!e.id || !F(e.id))
|
|
1045
1060
|
throw new Error("User ID must be a string");
|
|
1046
|
-
const
|
|
1047
|
-
if (this.persistence.set("userId",
|
|
1048
|
-
const
|
|
1061
|
+
const i = e.id;
|
|
1062
|
+
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
1063
|
+
const s = {
|
|
1049
1064
|
...e,
|
|
1050
1065
|
anonymous_id: this.anonymousId
|
|
1051
1066
|
};
|
|
1052
|
-
await this.track("user_identify",
|
|
1067
|
+
await this.track("user_identify", s);
|
|
1053
1068
|
}
|
|
1054
1069
|
this.logger.info("User identified:", e);
|
|
1055
1070
|
}
|
|
1056
|
-
track(e, t,
|
|
1057
|
-
this.trackInternal(e, t,
|
|
1071
|
+
track(e, t, i = !1) {
|
|
1072
|
+
this.trackInternal(e, t, i);
|
|
1058
1073
|
}
|
|
1059
|
-
trackInternal(e, t,
|
|
1060
|
-
if (
|
|
1074
|
+
trackInternal(e, t, i = !1) {
|
|
1075
|
+
if (me()) {
|
|
1076
|
+
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
if (!F(e))
|
|
1061
1080
|
throw new Error("Event name must be a string");
|
|
1062
1081
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1063
1082
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
1064
|
-
const
|
|
1083
|
+
const r = this.createEventPayload(e, t);
|
|
1065
1084
|
try {
|
|
1066
|
-
if (
|
|
1067
|
-
this.transport.send(
|
|
1085
|
+
if (i) {
|
|
1086
|
+
this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
|
|
1068
1087
|
return;
|
|
1069
1088
|
}
|
|
1070
|
-
this.retryQueue.add(
|
|
1071
|
-
} catch (
|
|
1072
|
-
throw this.logger.error(`Failed to track event: ${e}`,
|
|
1089
|
+
this.retryQueue.add(r), this.logger.debug(`Event tracked: ${e}`, [r]);
|
|
1090
|
+
} catch (o) {
|
|
1091
|
+
throw this.logger.error(`Failed to track event: ${e}`, o), new Error(`Failed to track event: ${e}`);
|
|
1073
1092
|
}
|
|
1074
1093
|
}
|
|
1075
1094
|
rawTrack(e) {
|
|
1076
|
-
if (!
|
|
1095
|
+
if (!v(e))
|
|
1077
1096
|
throw new Error("Event payload must be an object");
|
|
1078
1097
|
this.track("raw", e);
|
|
1079
1098
|
}
|
|
1080
1099
|
async group(e, t = !1) {
|
|
1081
|
-
if (!
|
|
1100
|
+
if (!v(e))
|
|
1082
1101
|
throw new Error("Company properties must be an object");
|
|
1083
1102
|
if (!e.id || !e.name || !e.created_at)
|
|
1084
1103
|
throw new Error("Company properties must include id, name, and created_at");
|
|
1085
1104
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1086
1105
|
}
|
|
1087
1106
|
createEventPayload(e, t) {
|
|
1088
|
-
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}`) || {};
|
|
1089
1108
|
let l = t || {};
|
|
1090
1109
|
const a = {
|
|
1091
1110
|
event_id: "",
|
|
1092
1111
|
user: {
|
|
1093
1112
|
anonymous_id: this.anonymousId,
|
|
1094
1113
|
id: r,
|
|
1095
|
-
...
|
|
1114
|
+
...i
|
|
1096
1115
|
},
|
|
1097
|
-
...
|
|
1116
|
+
...s && { company: s },
|
|
1098
1117
|
ids: this.getThirdPartyIds(),
|
|
1099
1118
|
utc_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1100
1119
|
local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
@@ -1115,9 +1134,9 @@ class we {
|
|
|
1115
1134
|
}
|
|
1116
1135
|
processAutocaptureAttributes(e) {
|
|
1117
1136
|
let t = {};
|
|
1118
|
-
const
|
|
1119
|
-
return
|
|
1120
|
-
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];
|
|
1121
1140
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1122
1141
|
}
|
|
1123
1142
|
getCookie(e) {
|
|
@@ -1133,9 +1152,9 @@ class we {
|
|
|
1133
1152
|
return e;
|
|
1134
1153
|
}
|
|
1135
1154
|
getUtmParams() {
|
|
1136
|
-
const e = {}, t =
|
|
1137
|
-
return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((
|
|
1138
|
-
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]);
|
|
1139
1158
|
}), e;
|
|
1140
1159
|
}
|
|
1141
1160
|
pageview() {
|
|
@@ -1148,7 +1167,7 @@ class we {
|
|
|
1148
1167
|
setupPageLeaveTracking() {
|
|
1149
1168
|
if (!u()) return;
|
|
1150
1169
|
let e = !1, t = !1;
|
|
1151
|
-
const
|
|
1170
|
+
const i = () => {
|
|
1152
1171
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
1153
1172
|
url: window.location.href,
|
|
1154
1173
|
referrer: document.referrer,
|
|
@@ -1160,12 +1179,12 @@ class we {
|
|
|
1160
1179
|
t = !1;
|
|
1161
1180
|
}, 100);
|
|
1162
1181
|
}), document.addEventListener("visibilitychange", () => {
|
|
1163
|
-
document.visibilityState === "hidden" && !t &&
|
|
1182
|
+
document.visibilityState === "hidden" && !t && i();
|
|
1164
1183
|
});
|
|
1165
|
-
const
|
|
1184
|
+
const s = history.pushState;
|
|
1166
1185
|
history.pushState = function() {
|
|
1167
|
-
return
|
|
1168
|
-
}, window.addEventListener("popstate",
|
|
1186
|
+
return i(), s.apply(this, arguments);
|
|
1187
|
+
}, window.addEventListener("popstate", i);
|
|
1169
1188
|
}
|
|
1170
1189
|
getConfig() {
|
|
1171
1190
|
return this.config;
|
|
@@ -1181,20 +1200,20 @@ class we {
|
|
|
1181
1200
|
this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
|
|
1182
1201
|
}
|
|
1183
1202
|
set(e, t) {
|
|
1184
|
-
if (!
|
|
1203
|
+
if (!v(e))
|
|
1185
1204
|
throw new Error("Properties must be an object");
|
|
1186
|
-
const
|
|
1187
|
-
if (
|
|
1188
|
-
let r = this.persistence.get(`props_${
|
|
1189
|
-
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);
|
|
1190
1209
|
} else {
|
|
1191
1210
|
let r = this.persistence.get("global_props") || {};
|
|
1192
1211
|
r = { ...r, ...e }, this.persistence.set("global_props", r);
|
|
1193
1212
|
}
|
|
1194
|
-
|
|
1213
|
+
s && this.persistence.save(), this.logger.debug("Properties set", {
|
|
1195
1214
|
properties: e,
|
|
1196
|
-
eventType:
|
|
1197
|
-
persist:
|
|
1215
|
+
eventType: i || "global",
|
|
1216
|
+
persist: s
|
|
1198
1217
|
});
|
|
1199
1218
|
}
|
|
1200
1219
|
setUserId(e) {
|
|
@@ -1203,105 +1222,137 @@ class we {
|
|
|
1203
1222
|
t.id = e, this.persistence.set("userProps", t), this.persistence.save();
|
|
1204
1223
|
}
|
|
1205
1224
|
unset(e, t) {
|
|
1206
|
-
const
|
|
1207
|
-
if (
|
|
1208
|
-
let r = this.persistence.get(`props_${
|
|
1209
|
-
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);
|
|
1210
1229
|
} else {
|
|
1211
1230
|
let r = this.persistence.get("global_props") || {};
|
|
1212
1231
|
delete r[e], this.persistence.set("global_props", r);
|
|
1213
1232
|
}
|
|
1214
|
-
|
|
1233
|
+
s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
|
|
1215
1234
|
}
|
|
1216
1235
|
}
|
|
1217
|
-
function
|
|
1218
|
-
|
|
1219
|
-
|
|
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)
|
|
1220
1246
|
throw new Error("API key is required!");
|
|
1221
|
-
if (!
|
|
1247
|
+
if (!i.trackingHost)
|
|
1222
1248
|
throw new Error("Tracking host is required!");
|
|
1223
|
-
|
|
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);
|
|
1224
1251
|
}
|
|
1225
|
-
function
|
|
1226
|
-
var
|
|
1252
|
+
function $e(n) {
|
|
1253
|
+
var s;
|
|
1227
1254
|
const e = {
|
|
1228
|
-
key:
|
|
1229
|
-
trackingHost:
|
|
1230
|
-
logLevel:
|
|
1231
|
-
autocapture:
|
|
1232
|
-
formTracking:
|
|
1233
|
-
autoPageview:
|
|
1234
|
-
useBeaconApi:
|
|
1235
|
-
forceUseFetch:
|
|
1236
|
-
gaHook:
|
|
1237
|
-
segmentHook:
|
|
1238
|
-
randomizeUrl:
|
|
1239
|
-
capture3rdPartyCookies:
|
|
1240
|
-
idMethod:
|
|
1241
|
-
privacyPolicy:
|
|
1242
|
-
ipPolicy:
|
|
1243
|
-
cookiePolicy:
|
|
1244
|
-
minSendTimeout: parseInt(
|
|
1245
|
-
maxSendTimeout: parseInt(
|
|
1246
|
-
maxSendAttempts: parseInt(
|
|
1247
|
-
propertiesStringMaxLength: parseInt(
|
|
1248
|
-
propertyBlacklist: ((
|
|
1249
|
-
exclude:
|
|
1250
|
-
namespace:
|
|
1251
|
-
crossDomainLinking:
|
|
1252
|
-
domains:
|
|
1253
|
-
maskAllText:
|
|
1254
|
-
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"
|
|
1255
1282
|
};
|
|
1256
1283
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1257
|
-
const t =
|
|
1258
|
-
u() && t.pageview(),
|
|
1284
|
+
const t = C(e), i = e.namespace || "usermaven";
|
|
1285
|
+
return u() && e.autoPageview !== !1 && t.pageview(), Se(i, t), t;
|
|
1259
1286
|
}
|
|
1260
|
-
function
|
|
1287
|
+
function Se(n, e) {
|
|
1261
1288
|
let t = !1;
|
|
1262
|
-
const
|
|
1289
|
+
const i = [], s = [];
|
|
1263
1290
|
function r() {
|
|
1264
|
-
for (;
|
|
1265
|
-
const a =
|
|
1266
|
-
a && window[
|
|
1291
|
+
for (; i.length > 0; ) {
|
|
1292
|
+
const a = i.shift();
|
|
1293
|
+
a && window[n].apply(null, a);
|
|
1267
1294
|
}
|
|
1268
1295
|
}
|
|
1269
1296
|
function o() {
|
|
1270
|
-
|
|
1297
|
+
s.forEach((a) => a()), s.length = 0;
|
|
1271
1298
|
}
|
|
1272
|
-
window[
|
|
1299
|
+
window[n] = function(...a) {
|
|
1273
1300
|
const h = a[0];
|
|
1274
1301
|
if (h === "onLoad") {
|
|
1275
|
-
typeof a[1] == "function" && (t ? a[1]() :
|
|
1302
|
+
typeof a[1] == "function" && (t ? a[1]() : s.push(a[1]));
|
|
1276
1303
|
return;
|
|
1277
1304
|
}
|
|
1278
1305
|
if (!t) {
|
|
1279
|
-
|
|
1306
|
+
i.push(a);
|
|
1280
1307
|
return;
|
|
1281
1308
|
}
|
|
1282
1309
|
if (typeof e[h] == "function")
|
|
1283
1310
|
return e[h].apply(e, a.slice(1));
|
|
1284
1311
|
console.error(`Method ${h} not found on UsermavenClient`);
|
|
1285
1312
|
};
|
|
1286
|
-
const c = `${
|
|
1313
|
+
const c = `${n}Q`, l = window[c] || [];
|
|
1287
1314
|
for (window[c] = l, l.push = function(...a) {
|
|
1288
|
-
return window[
|
|
1315
|
+
return window[n].apply(null, a), Array.prototype.push.apply(this, a);
|
|
1289
1316
|
}, setTimeout(() => {
|
|
1290
|
-
t = !0, r(), o(), console.log(`Usermaven client for namespace ${
|
|
1317
|
+
t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
|
|
1291
1318
|
}, 0); l.length > 0; ) {
|
|
1292
1319
|
const a = l.shift();
|
|
1293
|
-
a &&
|
|
1320
|
+
a && i.push(a);
|
|
1294
1321
|
}
|
|
1295
1322
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
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
|
+
});
|
|
1303
1354
|
export {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1355
|
+
p as LogLevel,
|
|
1356
|
+
S as UsermavenClient,
|
|
1357
|
+
C as usermavenClient
|
|
1307
1358
|
};
|