@usermaven/sdk-js 1.5.8 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/types.d.ts +37 -0
- package/dist/lib.js +2 -2
- package/dist/usermaven.cjs.js +2 -2
- package/dist/usermaven.es.js +307 -274
- package/package.json +1 -1
package/dist/usermaven.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
class
|
|
1
|
+
var k = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(k || {});
|
|
2
|
+
class ie {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.level = e;
|
|
5
5
|
}
|
|
@@ -16,11 +16,11 @@ class G {
|
|
|
16
16
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return new
|
|
19
|
+
function f(n = 0) {
|
|
20
|
+
return new ie(n);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
logLevel:
|
|
22
|
+
const X = {
|
|
23
|
+
logLevel: k.ERROR,
|
|
24
24
|
useBeaconApi: !1,
|
|
25
25
|
forceUseFetch: !1,
|
|
26
26
|
trackingHost: "t.usermaven.com",
|
|
@@ -45,15 +45,15 @@ const q = {
|
|
|
45
45
|
maskAllText: !1,
|
|
46
46
|
maskAllElementAttributes: !1
|
|
47
47
|
};
|
|
48
|
-
class
|
|
48
|
+
class ne {
|
|
49
49
|
constructor(e) {
|
|
50
50
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
51
51
|
}
|
|
52
52
|
set(e, t, i = 365, s = !0, r = !1) {
|
|
53
53
|
const o = /* @__PURE__ */ new Date();
|
|
54
54
|
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
55
|
-
const
|
|
56
|
-
document.cookie = `${e}=${t};${
|
|
55
|
+
const a = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", c = r ? "; HttpOnly" : "";
|
|
56
|
+
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
|
|
57
57
|
}
|
|
58
58
|
get(e) {
|
|
59
59
|
const t = e + "=", i = document.cookie.split(";");
|
|
@@ -94,76 +94,76 @@ class j {
|
|
|
94
94
|
return i ? i[0] : "";
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
const
|
|
98
|
-
function
|
|
97
|
+
const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, T = oe.forEach, L = {};
|
|
98
|
+
function ae(n, e, t) {
|
|
99
99
|
if (Array.isArray(n)) {
|
|
100
|
-
if (
|
|
100
|
+
if (T && n.forEach === T)
|
|
101
101
|
n.forEach(e, t);
|
|
102
102
|
else if ("length" in n && n.length === +n.length) {
|
|
103
103
|
for (let i = 0, s = n.length; i < s; i++)
|
|
104
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
104
|
+
if (i in n && e.call(t, n[i], i) === L)
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const D = function(n) {
|
|
110
110
|
return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
111
|
-
},
|
|
111
|
+
}, ce = function(n) {
|
|
112
112
|
for (const e in n)
|
|
113
113
|
typeof n[e] == "function" && (n[e] = n[e].bind(n));
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function w(n, e, t) {
|
|
116
116
|
if (n != null) {
|
|
117
|
-
if (
|
|
117
|
+
if (T && Array.isArray(n) && n.forEach === T)
|
|
118
118
|
n.forEach(e, t);
|
|
119
119
|
else if ("length" in n && n.length === +n.length) {
|
|
120
120
|
for (let i = 0, s = n.length; i < s; i++)
|
|
121
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
121
|
+
if (i in n && e.call(t, n[i], i) === L)
|
|
122
122
|
return;
|
|
123
123
|
} else
|
|
124
124
|
for (const i in n)
|
|
125
|
-
if (
|
|
125
|
+
if (re.call(n, i) && e.call(t, n[i], i) === L)
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
return
|
|
129
|
+
const le = function(n, ...e) {
|
|
130
|
+
return ae(e, function(t) {
|
|
131
131
|
for (const i in t)
|
|
132
132
|
t[i] !== void 0 && (n[i] = t[i]);
|
|
133
133
|
}), n;
|
|
134
134
|
};
|
|
135
|
-
function
|
|
135
|
+
function $(n, e) {
|
|
136
136
|
return n.indexOf(e) !== -1;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const ue = function(n) {
|
|
139
139
|
try {
|
|
140
140
|
return /^\s*\bfunction\b/.test(n);
|
|
141
141
|
} catch {
|
|
142
142
|
return !1;
|
|
143
143
|
}
|
|
144
|
-
},
|
|
144
|
+
}, he = function(n) {
|
|
145
145
|
return n === void 0;
|
|
146
|
-
},
|
|
147
|
-
const n = function(i, s, r, o,
|
|
146
|
+
}, E = function() {
|
|
147
|
+
const n = function(i, s, r, o, a) {
|
|
148
148
|
if (!i) {
|
|
149
|
-
|
|
149
|
+
f().error("No valid element provided to register_event");
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
if (i.addEventListener && !o)
|
|
153
|
-
i.addEventListener(s, r, !!
|
|
153
|
+
i.addEventListener(s, r, !!a);
|
|
154
154
|
else {
|
|
155
|
-
const l = "on" + s,
|
|
156
|
-
i[l] = e(i, r,
|
|
155
|
+
const l = "on" + s, c = i[l];
|
|
156
|
+
i[l] = e(i, r, c);
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
159
|
function e(i, s, r) {
|
|
160
160
|
return function(o) {
|
|
161
161
|
if (o = o || t(window.event), !o)
|
|
162
162
|
return;
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
return (l === !1 ||
|
|
163
|
+
let a = !0, l;
|
|
164
|
+
ue(r) && (l = r(o));
|
|
165
|
+
const c = s.call(i, o);
|
|
166
|
+
return (l === !1 || c === !1) && (a = !1), a;
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
function t(i) {
|
|
@@ -174,47 +174,47 @@ const oe = function(n) {
|
|
|
174
174
|
}, t.stopPropagation = function() {
|
|
175
175
|
this.cancelBubble = !0;
|
|
176
176
|
}, n;
|
|
177
|
-
}(),
|
|
177
|
+
}(), de = function(n) {
|
|
178
178
|
return function(...e) {
|
|
179
179
|
try {
|
|
180
180
|
return n.apply(this, e);
|
|
181
181
|
} catch (t) {
|
|
182
|
-
|
|
182
|
+
f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
},
|
|
185
|
+
}, Z = function(n) {
|
|
186
186
|
for (const e in n)
|
|
187
|
-
typeof n[e] == "function" && (n[e] =
|
|
187
|
+
typeof n[e] == "function" && (n[e] = de(n[e]));
|
|
188
188
|
};
|
|
189
|
-
function
|
|
189
|
+
function q(n) {
|
|
190
190
|
for (let e in n)
|
|
191
191
|
(n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
|
|
192
192
|
return n;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function h() {
|
|
195
195
|
try {
|
|
196
196
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
197
197
|
} catch {
|
|
198
|
-
return
|
|
198
|
+
return f().warn("window is not available"), !1;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function v(n = 5) {
|
|
202
202
|
const e = new Uint8Array(n);
|
|
203
203
|
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function fe(n) {
|
|
206
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 n != "object" || n === null ? n : Array.isArray(n) ? n.map(
|
|
213
|
-
const i =
|
|
214
|
-
return e[i] =
|
|
211
|
+
function F(n) {
|
|
212
|
+
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(F) : Object.keys(n).reduce((e, t) => {
|
|
213
|
+
const i = fe(t);
|
|
214
|
+
return e[i] = F(n[t]), e;
|
|
215
215
|
}, {});
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function x(n) {
|
|
218
218
|
switch (typeof n.className) {
|
|
219
219
|
case "string":
|
|
220
220
|
return n.className;
|
|
@@ -224,47 +224,47 @@ function A(n) {
|
|
|
224
224
|
return "";
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function V(n) {
|
|
228
228
|
let e = "";
|
|
229
|
-
return
|
|
230
|
-
|
|
231
|
-
}),
|
|
229
|
+
return M(n) && !j(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
|
|
230
|
+
G(t) && t.textContent && (e += D(t.textContent).split(/(\s+)/).filter(C).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
231
|
+
}), D(e);
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function Y(n) {
|
|
234
234
|
return !!n && n.nodeType === 1;
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function y(n, e) {
|
|
237
237
|
return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function G(n) {
|
|
240
240
|
return !!n && n.nodeType === 3;
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function z(n) {
|
|
243
243
|
return !!n && n.nodeType === 11;
|
|
244
244
|
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
247
|
-
if (!n ||
|
|
245
|
+
const S = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
246
|
+
function ge(n, e) {
|
|
247
|
+
if (!n || y(n, "html") || !Y(n))
|
|
248
248
|
return !1;
|
|
249
249
|
let t = n;
|
|
250
|
-
for (; t && !
|
|
250
|
+
for (; t && !y(t, "body"); ) {
|
|
251
251
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
252
252
|
return !1;
|
|
253
|
-
t.parentNode &&
|
|
253
|
+
t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
254
254
|
}
|
|
255
255
|
let i = !1;
|
|
256
|
-
for (t = n; t && !
|
|
257
|
-
if (t.parentNode &&
|
|
258
|
-
t = t.parentNode.host, t &&
|
|
256
|
+
for (t = n; t && !y(t, "body"); ) {
|
|
257
|
+
if (t.parentNode && z(t.parentNode)) {
|
|
258
|
+
t = t.parentNode.host, t && S.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
259
259
|
continue;
|
|
260
260
|
}
|
|
261
261
|
const o = t.parentNode;
|
|
262
262
|
if (!o) break;
|
|
263
|
-
if (
|
|
263
|
+
if (S.indexOf(o.tagName.toLowerCase()) > -1)
|
|
264
264
|
i = !0;
|
|
265
265
|
else {
|
|
266
|
-
const
|
|
267
|
-
|
|
266
|
+
const a = window.getComputedStyle(o);
|
|
267
|
+
a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
|
|
268
268
|
}
|
|
269
269
|
t = o;
|
|
270
270
|
}
|
|
@@ -283,16 +283,16 @@ function ue(n, e) {
|
|
|
283
283
|
case "textarea":
|
|
284
284
|
return e.type === "change" || e.type === "click";
|
|
285
285
|
default:
|
|
286
|
-
return i ? e.type === "click" : e.type === "click" && (
|
|
286
|
+
return i ? e.type === "click" : e.type === "click" && (S.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
for (let i = n; i.parentNode && !
|
|
291
|
-
const s =
|
|
292
|
-
if (
|
|
289
|
+
function M(n) {
|
|
290
|
+
for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
|
|
291
|
+
const s = x(i).split(" ");
|
|
292
|
+
if ($(s, "ph-sensitive") || $(s, "ph-no-capture"))
|
|
293
293
|
return !1;
|
|
294
294
|
}
|
|
295
|
-
if (
|
|
295
|
+
if ($(x(n).split(" "), "ph-include"))
|
|
296
296
|
return !0;
|
|
297
297
|
const e = n.type || "";
|
|
298
298
|
if (typeof e == "string")
|
|
@@ -305,23 +305,23 @@ function L(n) {
|
|
|
305
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 j(n) {
|
|
309
309
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
310
|
-
return !!(
|
|
310
|
+
return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
return !(n === null ||
|
|
312
|
+
function C(n) {
|
|
313
|
+
return !(n === null || he(n) || typeof n == "string" && (n = D(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
|
|
315
|
+
function pe(n) {
|
|
316
316
|
return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
return
|
|
318
|
+
function O() {
|
|
319
|
+
return v(10);
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function me(n) {
|
|
322
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 ye(n, e) {
|
|
325
325
|
let t;
|
|
326
326
|
return function(...i) {
|
|
327
327
|
const s = () => {
|
|
@@ -330,7 +330,7 @@ function fe(n, e) {
|
|
|
330
330
|
clearTimeout(t), t = setTimeout(s, e);
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
|
-
function
|
|
333
|
+
function we(n) {
|
|
334
334
|
const e = {}, t = n.replace(/^\?/, "").split("&");
|
|
335
335
|
for (let i = 0; i < t.length; i++) {
|
|
336
336
|
const s = t[i].split("=");
|
|
@@ -338,25 +338,25 @@ function ge(n) {
|
|
|
338
338
|
}
|
|
339
339
|
return e;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function J(n) {
|
|
342
342
|
return typeof n == "string" || n instanceof String;
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function A(n) {
|
|
345
345
|
return n !== null && typeof n == "object" && n.constructor === Object;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function ke(n) {
|
|
348
348
|
if (n === null)
|
|
349
|
-
return
|
|
350
|
-
const e = n.toUpperCase(), t =
|
|
351
|
-
return t || t === 0 ? t :
|
|
349
|
+
return k.ERROR;
|
|
350
|
+
const e = n.toUpperCase(), t = k[e];
|
|
351
|
+
return t || t === 0 ? t : k.ERROR;
|
|
352
352
|
}
|
|
353
|
-
const
|
|
353
|
+
const ve = () => {
|
|
354
354
|
let n = "false";
|
|
355
355
|
return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
|
|
356
356
|
};
|
|
357
|
-
class
|
|
357
|
+
class _e {
|
|
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 = ye(this.handleScroll.bind(this), 250), this.initializeEventListener();
|
|
360
360
|
}
|
|
361
361
|
initializeEventListener() {
|
|
362
362
|
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
@@ -405,9 +405,9 @@ class ye {
|
|
|
405
405
|
});
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
const
|
|
409
|
-
constructor(e, t, i =
|
|
410
|
-
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new
|
|
408
|
+
const R = class R {
|
|
409
|
+
constructor(e, t, i = f()) {
|
|
410
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), ce(this), Z(this);
|
|
411
411
|
}
|
|
412
412
|
isBrowserSupported() {
|
|
413
413
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -431,7 +431,7 @@ const T = class T {
|
|
|
431
431
|
const e = (t) => {
|
|
432
432
|
t = t || window.event, this.captureEvent(t);
|
|
433
433
|
};
|
|
434
|
-
|
|
434
|
+
E(document, "submit", e, !1, !0), E(document, "change", e, !1, !0), E(document, "click", e, !1, !0), E(document, "visibilitychange", e, !1, !0), E(document, "scroll", e, !1, !0), E(window, "popstate", e, !1, !0);
|
|
435
435
|
}
|
|
436
436
|
isPageRefresh() {
|
|
437
437
|
if ("PerformanceNavigationTiming" in window) {
|
|
@@ -444,61 +444,61 @@ const T = class T {
|
|
|
444
444
|
captureEvent(e) {
|
|
445
445
|
var i, s;
|
|
446
446
|
let t = this.getEventTarget(e);
|
|
447
|
-
if (
|
|
447
|
+
if (G(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
448
448
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
449
449
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
450
450
|
return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
|
|
451
|
-
if (t &&
|
|
451
|
+
if (t && ge(t, e)) {
|
|
452
452
|
const r = [t];
|
|
453
453
|
let o = t;
|
|
454
|
-
for (; o.parentNode && !
|
|
455
|
-
if (
|
|
454
|
+
for (; o.parentNode && !y(o, "body"); ) {
|
|
455
|
+
if (z(o.parentNode)) {
|
|
456
456
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
457
457
|
continue;
|
|
458
458
|
}
|
|
459
459
|
r.push(o.parentNode), o = o.parentNode;
|
|
460
460
|
}
|
|
461
|
-
const
|
|
462
|
-
let l,
|
|
463
|
-
if (
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
const
|
|
467
|
-
|
|
461
|
+
const a = [];
|
|
462
|
+
let l, c = !1;
|
|
463
|
+
if (w(r, (p) => {
|
|
464
|
+
const _ = M(p);
|
|
465
|
+
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && C(l) && l);
|
|
466
|
+
const u = x(p).split(" ");
|
|
467
|
+
$(u, "ph-no-capture") && (c = !0), a.push(
|
|
468
468
|
this.getPropertiesFromElement(
|
|
469
|
-
|
|
469
|
+
p,
|
|
470
470
|
this.options.maskAllElementAttributes ?? !1,
|
|
471
471
|
this.options.maskAllText ?? !1
|
|
472
472
|
)
|
|
473
473
|
);
|
|
474
|
-
}), this.options.maskAllText || (
|
|
474
|
+
}), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
|
|
475
475
|
return !1;
|
|
476
|
-
const
|
|
476
|
+
const d = le(
|
|
477
477
|
this.getDefaultProperties(e.type),
|
|
478
478
|
{
|
|
479
|
-
$elements:
|
|
479
|
+
$elements: a
|
|
480
480
|
},
|
|
481
481
|
this.getCustomProperties(r)
|
|
482
482
|
);
|
|
483
|
-
return this.client.track("$autocapture",
|
|
483
|
+
return this.client.track("$autocapture", d), !0;
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
getCustomProperties(e) {
|
|
487
487
|
const t = {};
|
|
488
|
-
return
|
|
489
|
-
|
|
488
|
+
return w(this.customProperties, (i) => {
|
|
489
|
+
w(i.event_selectors, (s) => {
|
|
490
490
|
const r = document.querySelectorAll(s);
|
|
491
|
-
|
|
492
|
-
|
|
491
|
+
w(r, (o) => {
|
|
492
|
+
$(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
493
493
|
});
|
|
494
494
|
});
|
|
495
495
|
}), t;
|
|
496
496
|
}
|
|
497
497
|
extractCustomPropertyValue(e) {
|
|
498
498
|
const t = [];
|
|
499
|
-
return
|
|
499
|
+
return w(document.querySelectorAll(e.css_selector), function(i) {
|
|
500
500
|
let s;
|
|
501
|
-
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent),
|
|
501
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), C(s) && t.push(s);
|
|
502
502
|
}), t.join(", ");
|
|
503
503
|
}
|
|
504
504
|
getEventTarget(e) {
|
|
@@ -509,17 +509,17 @@ const T = class T {
|
|
|
509
509
|
const s = e.tagName.toLowerCase(), r = {
|
|
510
510
|
tag_name: s
|
|
511
511
|
};
|
|
512
|
-
|
|
513
|
-
const o =
|
|
514
|
-
o.length > 0 && (r.classes = o.split(" ").filter(function(
|
|
515
|
-
return
|
|
516
|
-
})),
|
|
517
|
-
|
|
512
|
+
S.indexOf(s) > -1 && !i && (r.$el_text = V(e));
|
|
513
|
+
const o = x(e);
|
|
514
|
+
o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
|
|
515
|
+
return d !== "";
|
|
516
|
+
})), w(e.attributes, function(d) {
|
|
517
|
+
j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && C(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
|
|
518
518
|
});
|
|
519
|
-
let
|
|
520
|
-
for (;
|
|
521
|
-
|
|
522
|
-
return r.nth_child =
|
|
519
|
+
let a = 1, l = 1, c = e;
|
|
520
|
+
for (; c = this.previousElementSibling(c); )
|
|
521
|
+
a++, c.tagName === e.tagName && l++;
|
|
522
|
+
return r.nth_child = a, r.nth_of_type = l, r;
|
|
523
523
|
}
|
|
524
524
|
previousElementSibling(e) {
|
|
525
525
|
if (e.previousElementSibling)
|
|
@@ -528,7 +528,7 @@ const T = class T {
|
|
|
528
528
|
let t = e;
|
|
529
529
|
do
|
|
530
530
|
t = t.previousSibling;
|
|
531
|
-
while (t && !
|
|
531
|
+
while (t && !Y(t));
|
|
532
532
|
return t;
|
|
533
533
|
}
|
|
534
534
|
}
|
|
@@ -550,9 +550,9 @@ const T = class T {
|
|
|
550
550
|
return s % t < i;
|
|
551
551
|
}
|
|
552
552
|
};
|
|
553
|
-
|
|
554
|
-
let
|
|
555
|
-
class
|
|
553
|
+
R.FORCE_CAPTURE_ATTR = "data-um-force-capture", R.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
554
|
+
let H = R;
|
|
555
|
+
class be {
|
|
556
556
|
constructor(e) {
|
|
557
557
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
558
558
|
}
|
|
@@ -581,8 +581,8 @@ class we {
|
|
|
581
581
|
}));
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
|
-
class
|
|
585
|
-
constructor(e, t, i =
|
|
584
|
+
class Ee {
|
|
585
|
+
constructor(e, t, i = f()) {
|
|
586
586
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
587
587
|
}
|
|
588
588
|
async send(e) {
|
|
@@ -593,14 +593,14 @@ class ke {
|
|
|
593
593
|
throw new Error("Failed to queue events via Beacon API");
|
|
594
594
|
}
|
|
595
595
|
constructUrl(e) {
|
|
596
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
597
|
-
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 = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
597
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
598
598
|
}
|
|
599
599
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
600
600
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
601
601
|
}
|
|
602
|
-
class
|
|
603
|
-
constructor(e, t, i =
|
|
602
|
+
class Q {
|
|
603
|
+
constructor(e, t, i = f()) {
|
|
604
604
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
605
605
|
}
|
|
606
606
|
async send(e) {
|
|
@@ -617,8 +617,8 @@ class z {
|
|
|
617
617
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
618
618
|
}
|
|
619
619
|
constructUrl(e) {
|
|
620
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
621
|
-
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 = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
621
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
622
622
|
}
|
|
623
623
|
getCustomHeaders() {
|
|
624
624
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -627,17 +627,17 @@ class z {
|
|
|
627
627
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
class
|
|
631
|
-
constructor(e, t, i =
|
|
630
|
+
class Pe {
|
|
631
|
+
constructor(e, t, i = f()) {
|
|
632
632
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
633
633
|
}
|
|
634
634
|
send(e) {
|
|
635
635
|
return new Promise((t, i) => {
|
|
636
636
|
const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
637
637
|
s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
|
|
638
|
-
const
|
|
639
|
-
Object.keys(
|
|
640
|
-
s.setRequestHeader(l,
|
|
638
|
+
const a = this.getCustomHeaders();
|
|
639
|
+
Object.keys(a).forEach((l) => {
|
|
640
|
+
s.setRequestHeader(l, a[l]);
|
|
641
641
|
}), s.onload = () => {
|
|
642
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
643
|
}, s.onerror = () => {
|
|
@@ -646,8 +646,8 @@ class ve {
|
|
|
646
646
|
});
|
|
647
647
|
}
|
|
648
648
|
constructUrl(e) {
|
|
649
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
650
|
-
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 = h() ? "/api/v1/event" : "/api/v1/s2s/event";
|
|
650
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
651
651
|
}
|
|
652
652
|
getCustomHeaders() {
|
|
653
653
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -656,9 +656,9 @@ class ve {
|
|
|
656
656
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
|
-
class
|
|
659
|
+
class ee {
|
|
660
660
|
constructor(e, t) {
|
|
661
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t ||
|
|
661
|
+
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
|
|
662
662
|
}
|
|
663
663
|
set(e, t) {
|
|
664
664
|
this.storage[e] = t, this.save();
|
|
@@ -673,7 +673,7 @@ class K {
|
|
|
673
673
|
this.storage = {}, this.save();
|
|
674
674
|
}
|
|
675
675
|
save() {
|
|
676
|
-
if (!
|
|
676
|
+
if (!h()) {
|
|
677
677
|
this.logger.warn("localStorage is not available in this environment");
|
|
678
678
|
return;
|
|
679
679
|
}
|
|
@@ -684,7 +684,7 @@ class K {
|
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
load() {
|
|
687
|
-
if (!
|
|
687
|
+
if (!h()) {
|
|
688
688
|
this.logger.warn("localStorage is not available in this environment");
|
|
689
689
|
return;
|
|
690
690
|
}
|
|
@@ -696,7 +696,7 @@ class K {
|
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
|
-
class
|
|
699
|
+
class Ae {
|
|
700
700
|
constructor() {
|
|
701
701
|
this.storage = {};
|
|
702
702
|
}
|
|
@@ -715,56 +715,56 @@ class _e {
|
|
|
715
715
|
this.storage = {};
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
class
|
|
718
|
+
class W {
|
|
719
719
|
// Default to true for server-side
|
|
720
|
-
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o =
|
|
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
|
|
720
|
+
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "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 ee(`offline_queue_${a}`), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
722
722
|
}
|
|
723
723
|
add(e) {
|
|
724
724
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
725
|
-
this.queue.push(t),
|
|
725
|
+
this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
|
|
726
726
|
}
|
|
727
727
|
initNetworkListeners() {
|
|
728
|
-
|
|
728
|
+
h() && (window.addEventListener("online", () => {
|
|
729
729
|
this.isOnline = !0, this.processBatch();
|
|
730
730
|
}), window.addEventListener("offline", () => {
|
|
731
731
|
this.isOnline = !1;
|
|
732
732
|
}));
|
|
733
733
|
}
|
|
734
734
|
scheduleBatch() {
|
|
735
|
-
|
|
735
|
+
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
|
|
736
736
|
}
|
|
737
737
|
async processBatch() {
|
|
738
|
-
if ((!
|
|
738
|
+
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
739
739
|
this.processing = !0;
|
|
740
740
|
const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
|
|
741
741
|
try {
|
|
742
|
-
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`),
|
|
742
|
+
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
|
|
743
743
|
} catch (i) {
|
|
744
744
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
745
745
|
}
|
|
746
746
|
this.processing = !1;
|
|
747
747
|
}
|
|
748
|
-
|
|
748
|
+
h() && this.scheduleBatch();
|
|
749
749
|
}
|
|
750
750
|
async handleBatchFailure(e) {
|
|
751
751
|
for (const t of e)
|
|
752
752
|
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error("Max retries reached, discarding payload", t.payload);
|
|
753
|
-
|
|
753
|
+
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
754
754
|
}
|
|
755
755
|
loadQueueFromStorage() {
|
|
756
|
-
if (
|
|
756
|
+
if (h()) {
|
|
757
757
|
const e = this.persistence.get("queue");
|
|
758
758
|
e && (this.queue = JSON.parse(e));
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
saveQueueToStorage() {
|
|
762
|
-
|
|
762
|
+
h() && this.persistence.set("queue", JSON.stringify(this.queue));
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
|
-
class
|
|
765
|
+
class $e {
|
|
766
766
|
constructor(e) {
|
|
767
|
-
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(), Z(this);
|
|
768
768
|
}
|
|
769
769
|
initializeEventListener() {
|
|
770
770
|
document.addEventListener("click", this.handleClick.bind(this));
|
|
@@ -784,8 +784,8 @@ class be {
|
|
|
784
784
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
785
785
|
this.clicks.every((r, o) => {
|
|
786
786
|
if (o === 0) return !0;
|
|
787
|
-
const
|
|
788
|
-
return Math.sqrt(Math.pow(r.x -
|
|
787
|
+
const a = this.clicks[o - 1];
|
|
788
|
+
return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
|
|
789
789
|
}) && this.sendRageClickEvent(i);
|
|
790
790
|
}
|
|
791
791
|
sendRageClickEvent(e) {
|
|
@@ -796,8 +796,8 @@ class be {
|
|
|
796
796
|
}), this.clicks = [];
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
|
-
class
|
|
800
|
-
constructor(e, t, i =
|
|
799
|
+
class Se {
|
|
800
|
+
constructor(e, t, i = f()) {
|
|
801
801
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
802
802
|
}
|
|
803
803
|
async send(e) {
|
|
@@ -812,16 +812,16 @@ class Ee {
|
|
|
812
812
|
}
|
|
813
813
|
};
|
|
814
814
|
return new Promise((r, o) => {
|
|
815
|
-
const
|
|
816
|
-
l.on("data", (
|
|
815
|
+
const a = (void 0)(s, (l) => {
|
|
816
|
+
l.on("data", (c) => {
|
|
817
817
|
}), l.on("end", () => {
|
|
818
|
-
const
|
|
819
|
-
|
|
818
|
+
const c = l.statusCode || 0;
|
|
819
|
+
c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
|
|
820
820
|
});
|
|
821
821
|
});
|
|
822
|
-
|
|
822
|
+
a.on("error", (l) => {
|
|
823
823
|
o(l);
|
|
824
|
-
}),
|
|
824
|
+
}), a.write(JSON.stringify(e)), a.end();
|
|
825
825
|
});
|
|
826
826
|
}
|
|
827
827
|
constructUrl(e) {
|
|
@@ -832,7 +832,7 @@ class Ee {
|
|
|
832
832
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
833
833
|
}
|
|
834
834
|
}
|
|
835
|
-
class
|
|
835
|
+
class P {
|
|
836
836
|
constructor(e, t = "all", i = {}) {
|
|
837
837
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
838
838
|
}
|
|
@@ -847,18 +847,18 @@ class w {
|
|
|
847
847
|
}
|
|
848
848
|
handleFormSubmit(e) {
|
|
849
849
|
const t = e.target, i = this._getFormDetails(t);
|
|
850
|
-
this.instance.track("$form",
|
|
850
|
+
this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
851
851
|
}
|
|
852
852
|
trackFieldChanges(e) {
|
|
853
853
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
854
854
|
i.addEventListener("change", (s) => {
|
|
855
855
|
const r = this._getFieldProps(s.target, 0);
|
|
856
|
-
this.instance.track("$form_field_change",
|
|
856
|
+
this.instance.track("$form_field_change", q(r));
|
|
857
857
|
});
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
860
|
static getInstance(e, t = "all", i = {}) {
|
|
861
|
-
return
|
|
861
|
+
return P.instance || (P.instance = new P(e, t, i)), P.instance;
|
|
862
862
|
}
|
|
863
863
|
_getFormDetails(e) {
|
|
864
864
|
const t = {
|
|
@@ -870,8 +870,8 @@ class w {
|
|
|
870
870
|
form_attributes: this._getElementAttributes(e)
|
|
871
871
|
}, i = e.querySelectorAll("input, select, textarea");
|
|
872
872
|
return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
|
|
873
|
-
const
|
|
874
|
-
Object.assign(t,
|
|
873
|
+
const a = this._getFieldProps(r, o);
|
|
874
|
+
Object.assign(t, a);
|
|
875
875
|
}), t;
|
|
876
876
|
}
|
|
877
877
|
_getFieldProps(e, t) {
|
|
@@ -946,9 +946,9 @@ class w {
|
|
|
946
946
|
return e.slice(t, i + 1);
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
|
-
class
|
|
949
|
+
class N {
|
|
950
950
|
constructor(e) {
|
|
951
|
-
this.config = this.mergeConfig(e,
|
|
951
|
+
this.config = this.mergeConfig(e, X), this.logger = f(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new W(
|
|
952
952
|
this.transport,
|
|
953
953
|
this.config.maxSendAttempts || 3,
|
|
954
954
|
this.config.minSendTimeout || 1e3,
|
|
@@ -957,16 +957,16 @@ class S {
|
|
|
957
957
|
// Reduced interval to .2 second
|
|
958
958
|
this.logger,
|
|
959
959
|
this.namespace
|
|
960
|
-
),
|
|
960
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
|
|
961
961
|
}
|
|
962
962
|
initializeBrowserFeatures() {
|
|
963
|
-
if (this.cookieManager = new
|
|
963
|
+
if (this.cookieManager = new ne(this.config.cookieDomain), this.config.autocapture && H.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new H(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
|
|
964
964
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
965
|
-
this.formTracking =
|
|
965
|
+
this.formTracking = P.getInstance(this, e || "none", {
|
|
966
966
|
trackFieldChanges: !1
|
|
967
967
|
});
|
|
968
968
|
}
|
|
969
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
969
|
+
this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new $e(this)), this.setupPageLeaveTracking();
|
|
970
970
|
}
|
|
971
971
|
/**
|
|
972
972
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -977,11 +977,11 @@ class S {
|
|
|
977
977
|
const i = JSON.parse(JSON.stringify(e));
|
|
978
978
|
let s = { ...t, ...i };
|
|
979
979
|
return Object.keys(t).forEach((r) => {
|
|
980
|
-
|
|
980
|
+
A(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
|
|
981
981
|
}), s;
|
|
982
982
|
}
|
|
983
983
|
init(e) {
|
|
984
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
984
|
+
this.config = { ...this.config, ...e }, this.logger = f(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new W(
|
|
985
985
|
this.transport,
|
|
986
986
|
this.config.maxSendAttempts || 3,
|
|
987
987
|
this.config.minSendTimeout || 1e3,
|
|
@@ -990,21 +990,21 @@ class S {
|
|
|
990
990
|
// Reduced interval to .25 second
|
|
991
991
|
this.logger,
|
|
992
992
|
this.namespace
|
|
993
|
-
),
|
|
993
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
|
|
994
994
|
}
|
|
995
995
|
manageCrossDomainLinking() {
|
|
996
996
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
997
997
|
return;
|
|
998
998
|
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
999
999
|
document.addEventListener("click", (i) => {
|
|
1000
|
-
var
|
|
1000
|
+
var a;
|
|
1001
1001
|
const s = this.findClosestLink(i.target);
|
|
1002
1002
|
if (!s) return;
|
|
1003
1003
|
const r = s.getAttribute("href");
|
|
1004
1004
|
if (!r || !r.startsWith("http")) return;
|
|
1005
1005
|
const o = new URL(r);
|
|
1006
1006
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1007
|
-
const l = (
|
|
1007
|
+
const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
|
|
1008
1008
|
l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
|
|
1009
1009
|
}
|
|
1010
1010
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
@@ -1016,47 +1016,47 @@ class S {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
initializeTransport(e) {
|
|
1018
1018
|
const t = "https://events.usermaven.com";
|
|
1019
|
-
if (!
|
|
1020
|
-
return new
|
|
1019
|
+
if (!h())
|
|
1020
|
+
return new Se(e.trackingHost || t, e);
|
|
1021
1021
|
const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1022
1022
|
if (e.useBeaconApi && r)
|
|
1023
|
-
return new
|
|
1023
|
+
return new Ee(e.trackingHost || t, e, this.logger);
|
|
1024
1024
|
if (e.forceUseFetch && s)
|
|
1025
|
-
return new
|
|
1025
|
+
return new Q(e.trackingHost || t, e, this.logger);
|
|
1026
1026
|
if (i)
|
|
1027
|
-
return new
|
|
1027
|
+
return new Pe(e.trackingHost || t, e, this.logger);
|
|
1028
1028
|
if (s)
|
|
1029
|
-
return new
|
|
1029
|
+
return new Q(e.trackingHost || t, e, this.logger);
|
|
1030
1030
|
throw new Error("No suitable transport method available");
|
|
1031
1031
|
}
|
|
1032
1032
|
initializePersistence() {
|
|
1033
|
-
return this.config.disableEventPersistence || !
|
|
1033
|
+
return this.config.disableEventPersistence || !h() ? new Ae() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1034
1034
|
}
|
|
1035
1035
|
getOrCreateAnonymousId() {
|
|
1036
1036
|
var i, s;
|
|
1037
|
-
if (!
|
|
1038
|
-
return
|
|
1037
|
+
if (!h())
|
|
1038
|
+
return O();
|
|
1039
1039
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1040
1040
|
return "";
|
|
1041
1041
|
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1042
1042
|
let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
|
|
1043
1043
|
if (!t) {
|
|
1044
1044
|
if (this.config.crossDomainLinking) {
|
|
1045
|
-
const
|
|
1046
|
-
t =
|
|
1045
|
+
const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
|
|
1046
|
+
t = a || d || O();
|
|
1047
1047
|
}
|
|
1048
|
-
t || (t =
|
|
1048
|
+
t || (t = O());
|
|
1049
1049
|
const r = 365 * 10;
|
|
1050
1050
|
(s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
|
|
1051
1051
|
}
|
|
1052
1052
|
return t;
|
|
1053
1053
|
}
|
|
1054
1054
|
async id(e, t = !1) {
|
|
1055
|
-
if (!
|
|
1055
|
+
if (!A(e))
|
|
1056
1056
|
throw new Error("User data must be an object");
|
|
1057
|
-
if (e.email && !
|
|
1057
|
+
if (e.email && !me(e.email))
|
|
1058
1058
|
throw new Error("Invalid email provided");
|
|
1059
|
-
if (!e.id || !
|
|
1059
|
+
if (!e.id || !J(e.id))
|
|
1060
1060
|
throw new Error("User ID must be a string");
|
|
1061
1061
|
const i = e.id;
|
|
1062
1062
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
@@ -1072,11 +1072,11 @@ class S {
|
|
|
1072
1072
|
this.trackInternal(e, t, i);
|
|
1073
1073
|
}
|
|
1074
1074
|
trackInternal(e, t, i = !1) {
|
|
1075
|
-
if (
|
|
1075
|
+
if (ve()) {
|
|
1076
1076
|
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1077
1077
|
return;
|
|
1078
1078
|
}
|
|
1079
|
-
if (!
|
|
1079
|
+
if (!J(e))
|
|
1080
1080
|
throw new Error("Event name must be a string");
|
|
1081
1081
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1082
1082
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
@@ -1092,21 +1092,21 @@ class S {
|
|
|
1092
1092
|
}
|
|
1093
1093
|
}
|
|
1094
1094
|
rawTrack(e) {
|
|
1095
|
-
if (!
|
|
1095
|
+
if (!A(e))
|
|
1096
1096
|
throw new Error("Event payload must be an object");
|
|
1097
1097
|
this.track("raw", e);
|
|
1098
1098
|
}
|
|
1099
1099
|
async group(e, t = !1) {
|
|
1100
|
-
if (!
|
|
1100
|
+
if (!A(e))
|
|
1101
1101
|
throw new Error("Company properties must be an object");
|
|
1102
1102
|
if (!e.id || !e.name || !e.created_at)
|
|
1103
1103
|
throw new Error("Company properties must include id, name, and created_at");
|
|
1104
1104
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1105
1105
|
}
|
|
1106
1106
|
createEventPayload(e, t) {
|
|
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") || {},
|
|
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") || {}, a = this.persistence.get(`props_${e}`) || {};
|
|
1108
1108
|
let l = t || {};
|
|
1109
|
-
const
|
|
1109
|
+
const c = {
|
|
1110
1110
|
event_id: "",
|
|
1111
1111
|
user: {
|
|
1112
1112
|
anonymous_id: this.anonymousId,
|
|
@@ -1122,15 +1122,15 @@ class S {
|
|
|
1122
1122
|
event_type: e,
|
|
1123
1123
|
namespace: this.namespace,
|
|
1124
1124
|
...o,
|
|
1125
|
-
...
|
|
1125
|
+
...a
|
|
1126
1126
|
};
|
|
1127
1127
|
if (e === "$autocapture") {
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((
|
|
1131
|
-
delete l[
|
|
1132
|
-
}),
|
|
1133
|
-
return
|
|
1128
|
+
const d = this.processAutocaptureAttributes(t || {});
|
|
1129
|
+
c.autocapture_attributes = d;
|
|
1130
|
+
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
|
|
1131
|
+
delete l[d];
|
|
1132
|
+
}), c.event_attributes = l);
|
|
1133
|
+
return h() && (c.referer = document.referrer, c.url = window.location.href, c.page_title = document.title, c.doc_path = window.location.pathname, c.doc_host = window.location.hostname, c.doc_search = window.location.search, c.screen_resolution = `${window.screen.width}x${window.screen.height}`, c.vp_size = `${window.innerWidth}x${window.innerHeight}`, c.user_agent = navigator.userAgent, c.user_language = navigator.language, c.doc_encoding = document.characterSet, c.utm = this.getUtmParams()), c;
|
|
1134
1134
|
}
|
|
1135
1135
|
processAutocaptureAttributes(e) {
|
|
1136
1136
|
let t = {};
|
|
@@ -1145,27 +1145,27 @@ class S {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
getThirdPartyIds() {
|
|
1147
1147
|
const e = {};
|
|
1148
|
-
if (
|
|
1148
|
+
if (h()) {
|
|
1149
1149
|
const t = this.getCookie("_fbp");
|
|
1150
1150
|
t && (e.fbp = t);
|
|
1151
1151
|
}
|
|
1152
1152
|
return e;
|
|
1153
1153
|
}
|
|
1154
1154
|
getUtmParams() {
|
|
1155
|
-
const e = {}, t =
|
|
1155
|
+
const e = {}, t = we(window.location.search);
|
|
1156
1156
|
return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
|
|
1157
1157
|
t[s] && (e[s.replace("utm_", "")] = t[s]);
|
|
1158
1158
|
}), e;
|
|
1159
1159
|
}
|
|
1160
1160
|
pageview() {
|
|
1161
|
-
|
|
1161
|
+
h() ? this.track("pageview", {
|
|
1162
1162
|
url: window.location.href,
|
|
1163
1163
|
referrer: document.referrer,
|
|
1164
1164
|
title: document.title
|
|
1165
1165
|
}, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
|
|
1166
1166
|
}
|
|
1167
1167
|
setupPageLeaveTracking() {
|
|
1168
|
-
if (!
|
|
1168
|
+
if (!h()) return;
|
|
1169
1169
|
let e = !1, t = !1;
|
|
1170
1170
|
const i = () => {
|
|
1171
1171
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
@@ -1200,7 +1200,7 @@ class S {
|
|
|
1200
1200
|
this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
|
|
1201
1201
|
}
|
|
1202
1202
|
set(e, t) {
|
|
1203
|
-
if (!
|
|
1203
|
+
if (!A(e))
|
|
1204
1204
|
throw new Error("Properties must be an object");
|
|
1205
1205
|
const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
|
|
1206
1206
|
if (i) {
|
|
@@ -1233,28 +1233,28 @@ class S {
|
|
|
1233
1233
|
s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
|
|
1234
1234
|
}
|
|
1235
1235
|
}
|
|
1236
|
-
function
|
|
1236
|
+
function te() {
|
|
1237
1237
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1238
1238
|
}
|
|
1239
|
-
function
|
|
1240
|
-
return
|
|
1239
|
+
function Ce() {
|
|
1240
|
+
return te() ? window.define : void 0;
|
|
1241
1241
|
}
|
|
1242
|
-
const
|
|
1243
|
-
function
|
|
1244
|
-
const e = JSON.parse(JSON.stringify(n)), t =
|
|
1242
|
+
const Te = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1243
|
+
function I(n) {
|
|
1244
|
+
const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
|
|
1245
1245
|
if (!i.key)
|
|
1246
1246
|
throw new Error("API key is required!");
|
|
1247
1247
|
if (!i.trackingHost)
|
|
1248
1248
|
throw new Error("Tracking host is required!");
|
|
1249
|
-
const s = i.key || "", r = `${
|
|
1250
|
-
return
|
|
1249
|
+
const s = i.key || "", r = `${Te}${s}`;
|
|
1250
|
+
return h() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
|
|
1251
1251
|
}
|
|
1252
|
-
function
|
|
1252
|
+
function xe(n) {
|
|
1253
1253
|
var s;
|
|
1254
1254
|
const e = {
|
|
1255
1255
|
key: n.getAttribute("data-key") || void 0,
|
|
1256
1256
|
trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1257
|
-
logLevel:
|
|
1257
|
+
logLevel: ke(n.getAttribute("data-log-level")),
|
|
1258
1258
|
autocapture: n.getAttribute("data-autocapture") === "true",
|
|
1259
1259
|
formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
|
|
1260
1260
|
autoPageview: n.getAttribute("data-auto-pageview") === "true",
|
|
@@ -1281,78 +1281,111 @@ function $e(n) {
|
|
|
1281
1281
|
maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1282
1282
|
};
|
|
1283
1283
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1284
|
-
const t =
|
|
1285
|
-
return
|
|
1284
|
+
const t = I(e), i = e.namespace || "usermaven";
|
|
1285
|
+
return h() && t.pageview(), He(i, t), t;
|
|
1286
1286
|
}
|
|
1287
|
-
function
|
|
1287
|
+
function He(n, e) {
|
|
1288
1288
|
let t = !1;
|
|
1289
1289
|
const i = [], s = [];
|
|
1290
1290
|
function r() {
|
|
1291
1291
|
for (; i.length > 0; ) {
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1292
|
+
const u = i.shift();
|
|
1293
|
+
if (u) {
|
|
1294
|
+
const g = u[u.length - 1];
|
|
1295
|
+
if (g && typeof g.resolve == "function") {
|
|
1296
|
+
const m = u.pop();
|
|
1297
|
+
try {
|
|
1298
|
+
const b = a.apply(null, u);
|
|
1299
|
+
b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
|
|
1300
|
+
} catch (b) {
|
|
1301
|
+
m.reject(b);
|
|
1302
|
+
}
|
|
1303
|
+
} else
|
|
1304
|
+
try {
|
|
1305
|
+
a.apply(null, u);
|
|
1306
|
+
} catch (m) {
|
|
1307
|
+
console.error("Usermaven: Error processing queued command:", m);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1294
1310
|
}
|
|
1295
1311
|
}
|
|
1296
1312
|
function o() {
|
|
1297
|
-
s.forEach((
|
|
1313
|
+
s.forEach((u) => u()), s.length = 0;
|
|
1298
1314
|
}
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
if (
|
|
1302
|
-
typeof
|
|
1315
|
+
function a(...u) {
|
|
1316
|
+
const g = u[0];
|
|
1317
|
+
if (g === "onLoad") {
|
|
1318
|
+
typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
|
|
1303
1319
|
return;
|
|
1304
1320
|
}
|
|
1305
1321
|
if (!t) {
|
|
1306
|
-
i.push(
|
|
1322
|
+
i.push(u);
|
|
1307
1323
|
return;
|
|
1308
1324
|
}
|
|
1309
|
-
if (typeof e[
|
|
1310
|
-
return e[
|
|
1311
|
-
console.error(`Method ${
|
|
1312
|
-
}
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1325
|
+
if (typeof e[g] == "function")
|
|
1326
|
+
return e[g].apply(e, u.slice(1));
|
|
1327
|
+
console.error(`Method ${g} not found on UsermavenClient`);
|
|
1328
|
+
}
|
|
1329
|
+
const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
|
|
1330
|
+
[...l, ...c].forEach((u) => {
|
|
1331
|
+
a[u] = function(...g) {
|
|
1332
|
+
if (!t) {
|
|
1333
|
+
if (l.includes(u))
|
|
1334
|
+
return new Promise((B, m) => {
|
|
1335
|
+
i.push([u, ...g, { resolve: B, reject: m }]);
|
|
1336
|
+
});
|
|
1337
|
+
i.push([u, ...g]);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
if (typeof e[u] == "function")
|
|
1341
|
+
return e[u].apply(e, g);
|
|
1342
|
+
};
|
|
1343
|
+
}), a.getConfig = function() {
|
|
1344
|
+
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1345
|
+
}, window[n] = a;
|
|
1346
|
+
const p = `${n}Q`, _ = window[p] || [];
|
|
1347
|
+
for (window[p] = _, _.push = function(...u) {
|
|
1348
|
+
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1316
1349
|
}, setTimeout(() => {
|
|
1317
1350
|
t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
|
|
1318
|
-
}, 0);
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1351
|
+
}, 0); _.length > 0; ) {
|
|
1352
|
+
const u = _.shift();
|
|
1353
|
+
u && i.push(u);
|
|
1321
1354
|
}
|
|
1322
1355
|
}
|
|
1323
|
-
let
|
|
1324
|
-
if (
|
|
1325
|
-
const n =
|
|
1356
|
+
let K = !1, U = null;
|
|
1357
|
+
if (h()) {
|
|
1358
|
+
const n = Ce();
|
|
1326
1359
|
n && n("usermaven", [], function() {
|
|
1327
1360
|
return {
|
|
1328
|
-
usermavenClient:
|
|
1329
|
-
UsermavenClient:
|
|
1330
|
-
LogLevel:
|
|
1361
|
+
usermavenClient: I,
|
|
1362
|
+
UsermavenClient: N,
|
|
1363
|
+
LogLevel: k,
|
|
1331
1364
|
// Expose the script tag client if it exists
|
|
1332
|
-
getScriptTagClient: () =>
|
|
1365
|
+
getScriptTagClient: () => U
|
|
1333
1366
|
};
|
|
1334
|
-
}), typeof window < "u" && (window.usermavenClient =
|
|
1367
|
+
}), typeof window < "u" && (window.usermavenClient = I, window.UsermavenClient = N, window.usermavenScriptTagClient = () => U), function(e, t) {
|
|
1335
1368
|
const i = e.currentScript;
|
|
1336
1369
|
function s() {
|
|
1337
|
-
return
|
|
1370
|
+
return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1338
1371
|
}
|
|
1339
1372
|
function r() {
|
|
1340
|
-
s() && (console.log("[Usermaven] Auto-initializing from script tag"),
|
|
1373
|
+
s() && (console.log("[Usermaven] Auto-initializing from script tag"), U = xe(i), K = !0);
|
|
1341
1374
|
}
|
|
1342
1375
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1343
1376
|
}(document, window);
|
|
1344
1377
|
}
|
|
1345
|
-
typeof module < "u" && module.exports && !
|
|
1346
|
-
usermavenClient:
|
|
1347
|
-
UsermavenClient:
|
|
1378
|
+
typeof module < "u" && module.exports && !te() && (module.exports = {
|
|
1379
|
+
usermavenClient: I,
|
|
1380
|
+
UsermavenClient: N,
|
|
1348
1381
|
Config: void 0,
|
|
1349
1382
|
UserProps: void 0,
|
|
1350
1383
|
EventPayload: void 0,
|
|
1351
|
-
LogLevel:
|
|
1384
|
+
LogLevel: k,
|
|
1352
1385
|
ClientProperties: void 0
|
|
1353
1386
|
});
|
|
1354
1387
|
export {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1388
|
+
k as LogLevel,
|
|
1389
|
+
N as UsermavenClient,
|
|
1390
|
+
I as usermavenClient
|
|
1358
1391
|
};
|