@usermaven/sdk-js 1.5.10-rc.109 → 1.5.10-rc.111
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/client.d.ts +1 -0
- package/dist/core/types.d.ts +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/lib.js +2 -2
- package/dist/usermaven.cjs.js +2 -2
- package/dist/usermaven.es.js +292 -138
- package/package.json +2 -3
package/dist/usermaven.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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
|
|
2
|
+
class ne {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.level = e;
|
|
5
5
|
}
|
|
@@ -17,9 +17,9 @@ class ie {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function f(n = 0) {
|
|
20
|
-
return new
|
|
20
|
+
return new ne(n);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const Z = {
|
|
23
23
|
logLevel: k.ERROR,
|
|
24
24
|
useBeaconApi: !1,
|
|
25
25
|
forceUseFetch: !1,
|
|
@@ -32,7 +32,13 @@ const X = {
|
|
|
32
32
|
gaHook: !1,
|
|
33
33
|
segmentHook: !1,
|
|
34
34
|
randomizeUrl: !1,
|
|
35
|
-
capture3rdPartyCookies: [
|
|
35
|
+
capture3rdPartyCookies: [
|
|
36
|
+
"_ga",
|
|
37
|
+
"_fbp",
|
|
38
|
+
"_ym_uid",
|
|
39
|
+
"ajs_user_id",
|
|
40
|
+
"ajs_anonymous_id"
|
|
41
|
+
],
|
|
36
42
|
idMethod: "cookie",
|
|
37
43
|
ipPolicy: "keep",
|
|
38
44
|
cookiePolicy: "keep",
|
|
@@ -45,7 +51,7 @@ const X = {
|
|
|
45
51
|
maskAllText: !1,
|
|
46
52
|
maskAllElementAttributes: !1
|
|
47
53
|
};
|
|
48
|
-
class
|
|
54
|
+
class se {
|
|
49
55
|
constructor(e) {
|
|
50
56
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
51
57
|
}
|
|
@@ -94,21 +100,21 @@ class ne {
|
|
|
94
100
|
return i ? i[0] : "";
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
const
|
|
98
|
-
function
|
|
103
|
+
const re = Object.prototype, oe = re.hasOwnProperty, ae = Array.prototype, $ = ae.forEach, D = {};
|
|
104
|
+
function ce(n, e, t) {
|
|
99
105
|
if (Array.isArray(n)) {
|
|
100
106
|
if ($ && n.forEach === $)
|
|
101
107
|
n.forEach(e, t);
|
|
102
108
|
else if ("length" in n && n.length === +n.length) {
|
|
103
109
|
for (let i = 0, s = n.length; i < s; i++)
|
|
104
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
110
|
+
if (i in n && e.call(t, n[i], i) === D)
|
|
105
111
|
return;
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
|
-
const
|
|
115
|
+
const F = function(n) {
|
|
110
116
|
return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
111
|
-
},
|
|
117
|
+
}, le = function(n) {
|
|
112
118
|
for (const e in n)
|
|
113
119
|
typeof n[e] == "function" && (n[e] = n[e].bind(n));
|
|
114
120
|
};
|
|
@@ -118,16 +124,16 @@ function w(n, e, t) {
|
|
|
118
124
|
n.forEach(e, t);
|
|
119
125
|
else if ("length" in n && n.length === +n.length) {
|
|
120
126
|
for (let i = 0, s = n.length; i < s; i++)
|
|
121
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
127
|
+
if (i in n && e.call(t, n[i], i) === D)
|
|
122
128
|
return;
|
|
123
129
|
} else
|
|
124
130
|
for (const i in n)
|
|
125
|
-
if (
|
|
131
|
+
if (oe.call(n, i) && e.call(t, n[i], i) === D)
|
|
126
132
|
return;
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
|
-
const
|
|
130
|
-
return
|
|
135
|
+
const ue = function(n, ...e) {
|
|
136
|
+
return ce(e, function(t) {
|
|
131
137
|
for (const i in t)
|
|
132
138
|
t[i] !== void 0 && (n[i] = t[i]);
|
|
133
139
|
}), n;
|
|
@@ -135,13 +141,13 @@ const le = function(n, ...e) {
|
|
|
135
141
|
function S(n, e) {
|
|
136
142
|
return n.indexOf(e) !== -1;
|
|
137
143
|
}
|
|
138
|
-
const
|
|
144
|
+
const he = function(n) {
|
|
139
145
|
try {
|
|
140
146
|
return /^\s*\bfunction\b/.test(n);
|
|
141
147
|
} catch {
|
|
142
148
|
return !1;
|
|
143
149
|
}
|
|
144
|
-
},
|
|
150
|
+
}, de = function(n) {
|
|
145
151
|
return n === void 0;
|
|
146
152
|
}, E = function() {
|
|
147
153
|
const n = function(i, s, r, o, a) {
|
|
@@ -161,7 +167,7 @@ const ue = function(n) {
|
|
|
161
167
|
if (o = o || t(window.event), !o)
|
|
162
168
|
return;
|
|
163
169
|
let a = !0, l;
|
|
164
|
-
|
|
170
|
+
he(r) && (l = r(o));
|
|
165
171
|
const c = s.call(i, o);
|
|
166
172
|
return (l === !1 || c === !1) && (a = !1), a;
|
|
167
173
|
};
|
|
@@ -174,19 +180,22 @@ const ue = function(n) {
|
|
|
174
180
|
}, t.stopPropagation = function() {
|
|
175
181
|
this.cancelBubble = !0;
|
|
176
182
|
}, n;
|
|
177
|
-
}(),
|
|
183
|
+
}(), fe = function(n) {
|
|
178
184
|
return function(...e) {
|
|
179
185
|
try {
|
|
180
186
|
return n.apply(this, e);
|
|
181
187
|
} catch (t) {
|
|
182
|
-
f().error(
|
|
188
|
+
f().error(
|
|
189
|
+
"Implementation error. Please turn on debug and contact support@usermaven.com.",
|
|
190
|
+
t
|
|
191
|
+
);
|
|
183
192
|
}
|
|
184
193
|
};
|
|
185
|
-
},
|
|
194
|
+
}, Y = function(n) {
|
|
186
195
|
for (const e in n)
|
|
187
|
-
typeof n[e] == "function" && (n[e] =
|
|
196
|
+
typeof n[e] == "function" && (n[e] = fe(n[e]));
|
|
188
197
|
};
|
|
189
|
-
function
|
|
198
|
+
function V(n) {
|
|
190
199
|
for (let e in n)
|
|
191
200
|
(n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
|
|
192
201
|
return n;
|
|
@@ -202,17 +211,20 @@ function v(n = 5) {
|
|
|
202
211
|
const e = new Uint8Array(n);
|
|
203
212
|
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
|
|
204
213
|
}
|
|
205
|
-
function
|
|
214
|
+
function ge(n) {
|
|
206
215
|
return n.replace(
|
|
207
216
|
/([-_][a-z])/g,
|
|
208
217
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
209
218
|
);
|
|
210
219
|
}
|
|
211
|
-
function
|
|
212
|
-
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
function z(n) {
|
|
221
|
+
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(z) : Object.keys(n).reduce(
|
|
222
|
+
(e, t) => {
|
|
223
|
+
const i = ge(t);
|
|
224
|
+
return e[i] = z(n[t]), e;
|
|
225
|
+
},
|
|
226
|
+
{}
|
|
227
|
+
);
|
|
216
228
|
}
|
|
217
229
|
function x(n) {
|
|
218
230
|
switch (typeof n.className) {
|
|
@@ -224,37 +236,45 @@ function x(n) {
|
|
|
224
236
|
return "";
|
|
225
237
|
}
|
|
226
238
|
}
|
|
227
|
-
function
|
|
239
|
+
function Q(n) {
|
|
228
240
|
let e = "";
|
|
229
|
-
return
|
|
230
|
-
|
|
231
|
-
}),
|
|
241
|
+
return B(n) && !ee(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
|
|
242
|
+
j(t) && t.textContent && (e += F(t.textContent).split(/(\s+)/).filter(T).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
243
|
+
}), F(e);
|
|
232
244
|
}
|
|
233
|
-
function
|
|
245
|
+
function G(n) {
|
|
234
246
|
return !!n && n.nodeType === 1;
|
|
235
247
|
}
|
|
236
248
|
function y(n, e) {
|
|
237
249
|
return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
|
|
238
250
|
}
|
|
239
|
-
function
|
|
251
|
+
function j(n) {
|
|
240
252
|
return !!n && n.nodeType === 3;
|
|
241
253
|
}
|
|
242
|
-
function
|
|
254
|
+
function M(n) {
|
|
243
255
|
return !!n && n.nodeType === 11;
|
|
244
256
|
}
|
|
245
|
-
const C = [
|
|
246
|
-
|
|
247
|
-
|
|
257
|
+
const C = [
|
|
258
|
+
"a",
|
|
259
|
+
"button",
|
|
260
|
+
"form",
|
|
261
|
+
"input",
|
|
262
|
+
"select",
|
|
263
|
+
"textarea",
|
|
264
|
+
"label"
|
|
265
|
+
];
|
|
266
|
+
function pe(n, e) {
|
|
267
|
+
if (!n || y(n, "html") || !G(n))
|
|
248
268
|
return !1;
|
|
249
269
|
let t = n;
|
|
250
270
|
for (; t && !y(t, "body"); ) {
|
|
251
271
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
252
272
|
return !1;
|
|
253
|
-
t.parentNode &&
|
|
273
|
+
t.parentNode && M(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
254
274
|
}
|
|
255
275
|
let i = !1;
|
|
256
276
|
for (t = n; t && !y(t, "body"); ) {
|
|
257
|
-
if (t.parentNode &&
|
|
277
|
+
if (t.parentNode && M(t.parentNode)) {
|
|
258
278
|
t = t.parentNode.host, t && C.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
259
279
|
continue;
|
|
260
280
|
}
|
|
@@ -286,7 +306,7 @@ function ge(n, e) {
|
|
|
286
306
|
return i ? e.type === "click" : e.type === "click" && (C.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
|
|
287
307
|
}
|
|
288
308
|
}
|
|
289
|
-
function
|
|
309
|
+
function B(n) {
|
|
290
310
|
for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
|
|
291
311
|
const s = x(i).split(" ");
|
|
292
312
|
if (S(s, "ph-sensitive") || S(s, "ph-no-capture"))
|
|
@@ -305,20 +325,20 @@ function M(n) {
|
|
|
305
325
|
const t = n.name || n.id || "";
|
|
306
326
|
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
327
|
}
|
|
308
|
-
function
|
|
328
|
+
function ee(n) {
|
|
309
329
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
310
330
|
return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
|
|
311
331
|
}
|
|
312
332
|
function T(n) {
|
|
313
|
-
return !(n === null ||
|
|
333
|
+
return !(n === null || de(n) || typeof n == "string" && (n = F(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
334
|
}
|
|
315
|
-
function
|
|
335
|
+
function me(n) {
|
|
316
336
|
return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
|
|
317
337
|
}
|
|
318
338
|
function R() {
|
|
319
339
|
return v(10);
|
|
320
340
|
}
|
|
321
|
-
function
|
|
341
|
+
function J(n) {
|
|
322
342
|
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
343
|
}
|
|
324
344
|
function ye(n, e) {
|
|
@@ -338,10 +358,10 @@ function we(n) {
|
|
|
338
358
|
}
|
|
339
359
|
return e;
|
|
340
360
|
}
|
|
341
|
-
function
|
|
361
|
+
function L(n) {
|
|
342
362
|
return typeof n == "string" || n instanceof String;
|
|
343
363
|
}
|
|
344
|
-
function
|
|
364
|
+
function P(n) {
|
|
345
365
|
return n !== null && typeof n == "object" && n.constructor === Object;
|
|
346
366
|
}
|
|
347
367
|
function ke(n) {
|
|
@@ -400,7 +420,9 @@ class _e {
|
|
|
400
420
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
401
421
|
}
|
|
402
422
|
checkMilestones(e) {
|
|
403
|
-
this.milestones.filter(
|
|
423
|
+
this.milestones.filter(
|
|
424
|
+
(i) => e >= i
|
|
425
|
+
).forEach((i) => {
|
|
404
426
|
this.send(), this.milestones = this.milestones.filter((s) => s !== i);
|
|
405
427
|
});
|
|
406
428
|
}
|
|
@@ -410,7 +432,7 @@ class _e {
|
|
|
410
432
|
}
|
|
411
433
|
const I = class I {
|
|
412
434
|
constructor(e, t, i = f()) {
|
|
413
|
-
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e),
|
|
435
|
+
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new _e(e), le(this), Y(this);
|
|
414
436
|
}
|
|
415
437
|
isBrowserSupported() {
|
|
416
438
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -425,7 +447,9 @@ const I = class I {
|
|
|
425
447
|
return;
|
|
426
448
|
}
|
|
427
449
|
if (!(document && document.body)) {
|
|
428
|
-
this.logger.debug(
|
|
450
|
+
this.logger.debug(
|
|
451
|
+
"Document not ready yet, trying again in 500 milliseconds..."
|
|
452
|
+
), setTimeout(() => this.init(), 500);
|
|
429
453
|
return;
|
|
430
454
|
}
|
|
431
455
|
this.addDomEventHandlers(), this.domHandlersAttached = !0;
|
|
@@ -447,15 +471,15 @@ const I = class I {
|
|
|
447
471
|
captureEvent(e) {
|
|
448
472
|
var i, s;
|
|
449
473
|
let t = this.getEventTarget(e);
|
|
450
|
-
if (
|
|
474
|
+
if (j(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
451
475
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
452
476
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
453
477
|
return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
|
|
454
|
-
if (t &&
|
|
478
|
+
if (t && pe(t, e)) {
|
|
455
479
|
const r = [t];
|
|
456
480
|
let o = t;
|
|
457
481
|
for (; o.parentNode && !y(o, "body"); ) {
|
|
458
|
-
if (
|
|
482
|
+
if (M(o.parentNode)) {
|
|
459
483
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
460
484
|
continue;
|
|
461
485
|
}
|
|
@@ -464,7 +488,7 @@ const I = class I {
|
|
|
464
488
|
const a = [];
|
|
465
489
|
let l, c = !1;
|
|
466
490
|
if (w(r, (p) => {
|
|
467
|
-
const _ =
|
|
491
|
+
const _ = B(p);
|
|
468
492
|
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && T(l) && l);
|
|
469
493
|
const u = x(p).split(" ");
|
|
470
494
|
S(u, "ph-no-capture") && (c = !0), a.push(
|
|
@@ -474,9 +498,9 @@ const I = class I {
|
|
|
474
498
|
this.options.maskAllText ?? !1
|
|
475
499
|
)
|
|
476
500
|
);
|
|
477
|
-
}), this.options.maskAllText || (a[0].$el_text =
|
|
501
|
+
}), this.options.maskAllText || (a[0].$el_text = Q(t)), l && (a[0].attr__href = l), c)
|
|
478
502
|
return !1;
|
|
479
|
-
const d =
|
|
503
|
+
const d = ue(
|
|
480
504
|
this.getDefaultProperties(e.type),
|
|
481
505
|
{
|
|
482
506
|
$elements: a
|
|
@@ -492,17 +516,20 @@ const I = class I {
|
|
|
492
516
|
w(i.event_selectors, (s) => {
|
|
493
517
|
const r = document.querySelectorAll(s);
|
|
494
518
|
w(r, (o) => {
|
|
495
|
-
S(e, o) &&
|
|
519
|
+
S(e, o) && B(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
496
520
|
});
|
|
497
521
|
});
|
|
498
522
|
}), t;
|
|
499
523
|
}
|
|
500
524
|
extractCustomPropertyValue(e) {
|
|
501
525
|
const t = [];
|
|
502
|
-
return w(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
526
|
+
return w(
|
|
527
|
+
document.querySelectorAll(e.css_selector),
|
|
528
|
+
function(i) {
|
|
529
|
+
let s;
|
|
530
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), T(s) && t.push(s);
|
|
531
|
+
}
|
|
532
|
+
), t.join(", ");
|
|
506
533
|
}
|
|
507
534
|
getEventTarget(e) {
|
|
508
535
|
var t;
|
|
@@ -512,12 +539,12 @@ const I = class I {
|
|
|
512
539
|
const s = e.tagName.toLowerCase(), r = {
|
|
513
540
|
tag_name: s
|
|
514
541
|
};
|
|
515
|
-
C.indexOf(s) > -1 && !i && (r.$el_text =
|
|
542
|
+
C.indexOf(s) > -1 && !i && (r.$el_text = Q(e));
|
|
516
543
|
const o = x(e);
|
|
517
544
|
o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
|
|
518
545
|
return d !== "";
|
|
519
546
|
})), w(e.attributes, function(d) {
|
|
520
|
-
|
|
547
|
+
ee(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && T(d.value) && !me(d.name) && (r["attr__" + d.name] = d.value);
|
|
521
548
|
});
|
|
522
549
|
let a = 1, l = 1, c = e;
|
|
523
550
|
for (; c = this.previousElementSibling(c); )
|
|
@@ -531,7 +558,7 @@ const I = class I {
|
|
|
531
558
|
let t = e;
|
|
532
559
|
do
|
|
533
560
|
t = t.previousSibling;
|
|
534
|
-
while (t && !
|
|
561
|
+
while (t && !G(t));
|
|
535
562
|
return t;
|
|
536
563
|
}
|
|
537
564
|
}
|
|
@@ -589,9 +616,13 @@ class Ee {
|
|
|
589
616
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
590
617
|
}
|
|
591
618
|
async send(e) {
|
|
592
|
-
const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], {
|
|
619
|
+
const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], {
|
|
620
|
+
type: "application/json"
|
|
621
|
+
});
|
|
593
622
|
if (navigator.sendBeacon(i, s))
|
|
594
|
-
this.logger.debug(
|
|
623
|
+
this.logger.debug(
|
|
624
|
+
`Successfully queued ${e.length} event(s) via Beacon API`
|
|
625
|
+
);
|
|
595
626
|
else
|
|
596
627
|
throw new Error("Failed to queue events via Beacon API");
|
|
597
628
|
}
|
|
@@ -602,7 +633,7 @@ class Ee {
|
|
|
602
633
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
603
634
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
604
635
|
}
|
|
605
|
-
class
|
|
636
|
+
class W {
|
|
606
637
|
constructor(e, t, i = f()) {
|
|
607
638
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
608
639
|
}
|
|
@@ -659,7 +690,7 @@ class Pe {
|
|
|
659
690
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
660
691
|
}
|
|
661
692
|
}
|
|
662
|
-
class
|
|
693
|
+
class te {
|
|
663
694
|
constructor(e, t) {
|
|
664
695
|
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
|
|
665
696
|
}
|
|
@@ -718,10 +749,12 @@ class Ae {
|
|
|
718
749
|
this.storage = {};
|
|
719
750
|
}
|
|
720
751
|
}
|
|
721
|
-
class
|
|
752
|
+
class K {
|
|
722
753
|
// Default to true for server-side
|
|
723
754
|
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
|
|
724
|
-
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
|
|
755
|
+
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 te(
|
|
756
|
+
`offline_queue_${a}`
|
|
757
|
+
), h() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
|
|
725
758
|
}
|
|
726
759
|
add(e) {
|
|
727
760
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
@@ -735,14 +768,19 @@ class W {
|
|
|
735
768
|
}));
|
|
736
769
|
}
|
|
737
770
|
scheduleBatch() {
|
|
738
|
-
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
771
|
+
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(
|
|
772
|
+
() => this.processBatch(),
|
|
773
|
+
this.batchInterval
|
|
774
|
+
));
|
|
739
775
|
}
|
|
740
776
|
async processBatch() {
|
|
741
777
|
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
742
778
|
this.processing = !0;
|
|
743
779
|
const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
|
|
744
780
|
try {
|
|
745
|
-
await this.transport.send(t), this.logger.debug(
|
|
781
|
+
await this.transport.send(t), this.logger.debug(
|
|
782
|
+
`Successfully sent batch of ${e.length} payloads`
|
|
783
|
+
), h() && this.saveQueueToStorage();
|
|
746
784
|
} catch (i) {
|
|
747
785
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
748
786
|
}
|
|
@@ -752,7 +790,10 @@ class W {
|
|
|
752
790
|
}
|
|
753
791
|
async handleBatchFailure(e) {
|
|
754
792
|
for (const t of e)
|
|
755
|
-
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
793
|
+
t.retries < this.maxRetries ? (t.retries++, this.queue.unshift(t), this.logger.warn(`Retry attempt ${t.retries} for payload`)) : this.logger.error(
|
|
794
|
+
"Max retries reached, discarding payload",
|
|
795
|
+
t.payload
|
|
796
|
+
);
|
|
756
797
|
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
757
798
|
}
|
|
758
799
|
loadQueueFromStorage() {
|
|
@@ -767,7 +808,7 @@ class W {
|
|
|
767
808
|
}
|
|
768
809
|
class Se {
|
|
769
810
|
constructor(e) {
|
|
770
|
-
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(),
|
|
811
|
+
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Y(this);
|
|
771
812
|
}
|
|
772
813
|
initializeEventListener() {
|
|
773
814
|
document.addEventListener("click", this.handleClick.bind(this));
|
|
@@ -781,14 +822,18 @@ class Se {
|
|
|
781
822
|
}
|
|
782
823
|
click(e, t, i) {
|
|
783
824
|
const s = { x: e, y: t, timestamp: i };
|
|
784
|
-
this.clicks.push(s), this.clicks = this.clicks.filter(
|
|
825
|
+
this.clicks.push(s), this.clicks = this.clicks.filter(
|
|
826
|
+
(r) => i - r.timestamp < this.timeWindow
|
|
827
|
+
), this.clicks.length >= this.threshold && this.checkRageClick();
|
|
785
828
|
}
|
|
786
829
|
checkRageClick() {
|
|
787
830
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
788
831
|
this.clicks.every((r, o) => {
|
|
789
832
|
if (o === 0) return !0;
|
|
790
833
|
const a = this.clicks[o - 1];
|
|
791
|
-
return Math.sqrt(
|
|
834
|
+
return Math.sqrt(
|
|
835
|
+
Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)
|
|
836
|
+
) < this.distanceThreshold;
|
|
792
837
|
}) && this.sendRageClickEvent(i);
|
|
793
838
|
}
|
|
794
839
|
sendRageClickEvent(e) {
|
|
@@ -835,7 +880,7 @@ class Ce {
|
|
|
835
880
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
836
881
|
}
|
|
837
882
|
}
|
|
838
|
-
class
|
|
883
|
+
class A {
|
|
839
884
|
constructor(e, t = "all", i = {}) {
|
|
840
885
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
841
886
|
}
|
|
@@ -850,22 +895,27 @@ class P {
|
|
|
850
895
|
}
|
|
851
896
|
handleFormSubmit(e) {
|
|
852
897
|
const t = e.target, i = this._getFormDetails(t);
|
|
853
|
-
this.instance.track("$form",
|
|
898
|
+
this.instance.track("$form", V(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
854
899
|
}
|
|
855
900
|
trackFieldChanges(e) {
|
|
856
901
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
857
902
|
i.addEventListener("change", (s) => {
|
|
858
|
-
const r = this._getFieldProps(
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
903
|
+
const r = this._getFieldProps(
|
|
904
|
+
s.target
|
|
905
|
+
);
|
|
906
|
+
this.instance.track(
|
|
907
|
+
"$form_field_change",
|
|
908
|
+
V({
|
|
909
|
+
form_id: e.id,
|
|
910
|
+
form_name: e.name || "",
|
|
911
|
+
field: r
|
|
912
|
+
})
|
|
913
|
+
);
|
|
864
914
|
});
|
|
865
915
|
});
|
|
866
916
|
}
|
|
867
917
|
static getInstance(e, t = "all", i = {}) {
|
|
868
|
-
return
|
|
918
|
+
return A.instance || (A.instance = new A(e, t, i)), A.instance;
|
|
869
919
|
}
|
|
870
920
|
_getFormDetails(e) {
|
|
871
921
|
const t = {
|
|
@@ -876,11 +926,17 @@ class P {
|
|
|
876
926
|
form_class: e.className,
|
|
877
927
|
form_attributes: this._getElementAttributes(e),
|
|
878
928
|
fields: []
|
|
879
|
-
}, i = e.querySelectorAll(
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
929
|
+
}, i = e.querySelectorAll(
|
|
930
|
+
"input, select, textarea"
|
|
931
|
+
);
|
|
932
|
+
return Array.from(i).filter(
|
|
933
|
+
(r) => !r.classList.contains("um-no-capture")
|
|
934
|
+
).forEach(
|
|
935
|
+
(r) => {
|
|
936
|
+
const o = this._getFieldProps(r);
|
|
937
|
+
t.fields.push(o);
|
|
938
|
+
}
|
|
939
|
+
), t;
|
|
884
940
|
}
|
|
885
941
|
_getFieldProps(e) {
|
|
886
942
|
const t = Object.keys(e.dataset).length ? this._convertDOMStringMapToObject(e.dataset) : void 0, i = this.getSafeText(e);
|
|
@@ -962,7 +1018,7 @@ class P {
|
|
|
962
1018
|
}
|
|
963
1019
|
class N {
|
|
964
1020
|
constructor(e) {
|
|
965
|
-
this.config = this.mergeConfig(e,
|
|
1021
|
+
this.config = this.mergeConfig(e, Z), this.logger = f(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new K(
|
|
966
1022
|
this.transport,
|
|
967
1023
|
this.config.maxSendAttempts || 3,
|
|
968
1024
|
this.config.minSendTimeout || 1e3,
|
|
@@ -971,14 +1027,20 @@ class N {
|
|
|
971
1027
|
// Reduced interval to .2 second
|
|
972
1028
|
this.logger,
|
|
973
1029
|
this.namespace
|
|
974
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1030
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1031
|
+
`Usermaven client initialized for namespace: ${this.namespace}`
|
|
1032
|
+
);
|
|
975
1033
|
}
|
|
976
1034
|
initializeBrowserFeatures() {
|
|
977
|
-
if (this.cookieManager = new
|
|
1035
|
+
if (this.cookieManager = new se(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) {
|
|
978
1036
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
979
|
-
this.formTracking =
|
|
980
|
-
|
|
981
|
-
|
|
1037
|
+
this.formTracking = A.getInstance(
|
|
1038
|
+
this,
|
|
1039
|
+
e || "none",
|
|
1040
|
+
{
|
|
1041
|
+
trackFieldChanges: !1
|
|
1042
|
+
}
|
|
1043
|
+
);
|
|
982
1044
|
}
|
|
983
1045
|
this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new Se(this)), this.setupPageLeaveTracking();
|
|
984
1046
|
}
|
|
@@ -991,11 +1053,11 @@ class N {
|
|
|
991
1053
|
const i = JSON.parse(JSON.stringify(e));
|
|
992
1054
|
let s = { ...t, ...i };
|
|
993
1055
|
return Object.keys(t).forEach((r) => {
|
|
994
|
-
|
|
1056
|
+
P(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
|
|
995
1057
|
}), s;
|
|
996
1058
|
}
|
|
997
1059
|
init(e) {
|
|
998
|
-
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
|
|
1060
|
+
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 K(
|
|
999
1061
|
this.transport,
|
|
1000
1062
|
this.config.maxSendAttempts || 3,
|
|
1001
1063
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1004,7 +1066,9 @@ class N {
|
|
|
1004
1066
|
// Reduced interval to .25 second
|
|
1005
1067
|
this.logger,
|
|
1006
1068
|
this.namespace
|
|
1007
|
-
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1069
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(
|
|
1070
|
+
`Usermaven client reinitialized for namespace: ${this.namespace}`
|
|
1071
|
+
);
|
|
1008
1072
|
}
|
|
1009
1073
|
manageCrossDomainLinking() {
|
|
1010
1074
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
@@ -1034,17 +1098,36 @@ class N {
|
|
|
1034
1098
|
return new Ce(e.trackingHost || t, e);
|
|
1035
1099
|
const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1036
1100
|
if (e.useBeaconApi && r)
|
|
1037
|
-
return new Ee(
|
|
1101
|
+
return new Ee(
|
|
1102
|
+
e.trackingHost || t,
|
|
1103
|
+
e,
|
|
1104
|
+
this.logger
|
|
1105
|
+
);
|
|
1038
1106
|
if (e.forceUseFetch && s)
|
|
1039
|
-
return new
|
|
1107
|
+
return new W(
|
|
1108
|
+
e.trackingHost || t,
|
|
1109
|
+
e,
|
|
1110
|
+
this.logger
|
|
1111
|
+
);
|
|
1040
1112
|
if (i)
|
|
1041
|
-
return new Pe(
|
|
1113
|
+
return new Pe(
|
|
1114
|
+
e.trackingHost || t,
|
|
1115
|
+
e,
|
|
1116
|
+
this.logger
|
|
1117
|
+
);
|
|
1042
1118
|
if (s)
|
|
1043
|
-
return new
|
|
1119
|
+
return new W(
|
|
1120
|
+
e.trackingHost || t,
|
|
1121
|
+
e,
|
|
1122
|
+
this.logger
|
|
1123
|
+
);
|
|
1044
1124
|
throw new Error("No suitable transport method available");
|
|
1045
1125
|
}
|
|
1046
1126
|
initializePersistence() {
|
|
1047
|
-
return this.config.disableEventPersistence || !h() ? new Ae() : new
|
|
1127
|
+
return this.config.disableEventPersistence || !h() ? new Ae() : new te(
|
|
1128
|
+
`${this.namespace}_${this.config.key}`,
|
|
1129
|
+
this.logger
|
|
1130
|
+
);
|
|
1048
1131
|
}
|
|
1049
1132
|
getOrCreateAnonymousId() {
|
|
1050
1133
|
var i, s;
|
|
@@ -1061,16 +1144,22 @@ class N {
|
|
|
1061
1144
|
}
|
|
1062
1145
|
t || (t = R());
|
|
1063
1146
|
const r = 365 * 10;
|
|
1064
|
-
(s = this.cookieManager) == null || s.set(
|
|
1147
|
+
(s = this.cookieManager) == null || s.set(
|
|
1148
|
+
e,
|
|
1149
|
+
t,
|
|
1150
|
+
r,
|
|
1151
|
+
document.location.protocol !== "http:",
|
|
1152
|
+
!1
|
|
1153
|
+
);
|
|
1065
1154
|
}
|
|
1066
1155
|
return t;
|
|
1067
1156
|
}
|
|
1068
1157
|
async id(e, t = !1) {
|
|
1069
|
-
if (!
|
|
1158
|
+
if (!P(e))
|
|
1070
1159
|
throw new Error("User data must be an object");
|
|
1071
|
-
if (e.email && !
|
|
1160
|
+
if (e.email && !J(e.email))
|
|
1072
1161
|
throw new Error("Invalid email provided");
|
|
1073
|
-
if (!e.id || !
|
|
1162
|
+
if (!e.id || !L(e.id))
|
|
1074
1163
|
throw new Error("User ID must be a string");
|
|
1075
1164
|
const i = e.id;
|
|
1076
1165
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
@@ -1085,15 +1174,34 @@ class N {
|
|
|
1085
1174
|
track(e, t, i = !1) {
|
|
1086
1175
|
this.trackInternal(e, t, i);
|
|
1087
1176
|
}
|
|
1177
|
+
lead(e, t = !1) {
|
|
1178
|
+
if (!P(e))
|
|
1179
|
+
throw new Error(
|
|
1180
|
+
"Lead payload must be a non-null object and not an array"
|
|
1181
|
+
);
|
|
1182
|
+
const i = e.email;
|
|
1183
|
+
if (!L(i)) {
|
|
1184
|
+
this.logger.error("Lead event requires a valid email attribute");
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
const s = i.trim();
|
|
1188
|
+
if (!s || !J(s)) {
|
|
1189
|
+
this.logger.error("Lead event requires a valid email attribute");
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
e.email = s, this.track("lead", e, t);
|
|
1193
|
+
}
|
|
1088
1194
|
trackInternal(e, t, i = !1) {
|
|
1089
1195
|
if (ve()) {
|
|
1090
1196
|
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1091
1197
|
return;
|
|
1092
1198
|
}
|
|
1093
|
-
if (!
|
|
1199
|
+
if (!L(e))
|
|
1094
1200
|
throw new Error("Event name must be a string");
|
|
1095
1201
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1096
|
-
throw new Error(
|
|
1202
|
+
throw new Error(
|
|
1203
|
+
"Event payload must be a non-null object and not an array"
|
|
1204
|
+
);
|
|
1097
1205
|
const r = this.createEventPayload(e, t);
|
|
1098
1206
|
try {
|
|
1099
1207
|
if (i) {
|
|
@@ -1106,15 +1214,17 @@ class N {
|
|
|
1106
1214
|
}
|
|
1107
1215
|
}
|
|
1108
1216
|
rawTrack(e) {
|
|
1109
|
-
if (!
|
|
1217
|
+
if (!P(e))
|
|
1110
1218
|
throw new Error("Event payload must be an object");
|
|
1111
1219
|
this.track("raw", e);
|
|
1112
1220
|
}
|
|
1113
1221
|
async group(e, t = !1) {
|
|
1114
|
-
if (!
|
|
1222
|
+
if (!P(e))
|
|
1115
1223
|
throw new Error("Company properties must be an object");
|
|
1116
1224
|
if (!e.id || !e.name || !e.created_at)
|
|
1117
|
-
throw new Error(
|
|
1225
|
+
throw new Error(
|
|
1226
|
+
"Company properties must include id, name, and created_at"
|
|
1227
|
+
);
|
|
1118
1228
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1119
1229
|
}
|
|
1120
1230
|
createEventPayload(e, t) {
|
|
@@ -1139,7 +1249,9 @@ class N {
|
|
|
1139
1249
|
...a
|
|
1140
1250
|
};
|
|
1141
1251
|
if (e === "$autocapture") {
|
|
1142
|
-
const d = this.processAutocaptureAttributes(
|
|
1252
|
+
const d = this.processAutocaptureAttributes(
|
|
1253
|
+
t || {}
|
|
1254
|
+
);
|
|
1143
1255
|
c.autocapture_attributes = d;
|
|
1144
1256
|
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
|
|
1145
1257
|
delete l[d];
|
|
@@ -1149,7 +1261,15 @@ class N {
|
|
|
1149
1261
|
processAutocaptureAttributes(e) {
|
|
1150
1262
|
let t = {};
|
|
1151
1263
|
const i = e.$elements || [];
|
|
1152
|
-
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1264
|
+
return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", [
|
|
1265
|
+
"$ce_version",
|
|
1266
|
+
"$event_type",
|
|
1267
|
+
"$initial_referrer",
|
|
1268
|
+
"$initial_referring_domain",
|
|
1269
|
+
"$referrer",
|
|
1270
|
+
"$referring_domain",
|
|
1271
|
+
"$elements"
|
|
1272
|
+
].forEach((s) => {
|
|
1153
1273
|
delete t[s];
|
|
1154
1274
|
}), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
|
|
1155
1275
|
}
|
|
@@ -1167,16 +1287,28 @@ class N {
|
|
|
1167
1287
|
}
|
|
1168
1288
|
getUtmParams() {
|
|
1169
1289
|
const e = {}, t = we(window.location.search);
|
|
1170
|
-
return [
|
|
1290
|
+
return [
|
|
1291
|
+
"utm_source",
|
|
1292
|
+
"utm_medium",
|
|
1293
|
+
"utm_campaign",
|
|
1294
|
+
"utm_term",
|
|
1295
|
+
"utm_content"
|
|
1296
|
+
].forEach((s) => {
|
|
1171
1297
|
t[s] && (e[s.replace("utm_", "")] = t[s]);
|
|
1172
1298
|
}), e;
|
|
1173
1299
|
}
|
|
1174
1300
|
pageview() {
|
|
1175
|
-
h() ? this.track(
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1301
|
+
h() ? this.track(
|
|
1302
|
+
"pageview",
|
|
1303
|
+
{
|
|
1304
|
+
url: window.location.href,
|
|
1305
|
+
referrer: document.referrer,
|
|
1306
|
+
title: document.title
|
|
1307
|
+
},
|
|
1308
|
+
!0
|
|
1309
|
+
) : this.logger.warn(
|
|
1310
|
+
"Pageview tracking is not available in server-side environments"
|
|
1311
|
+
);
|
|
1180
1312
|
}
|
|
1181
1313
|
setupPageLeaveTracking() {
|
|
1182
1314
|
if (!h()) return;
|
|
@@ -1211,10 +1343,13 @@ class N {
|
|
|
1211
1343
|
const t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1212
1344
|
this.cookieManager.delete(t), this.anonymousId = this.getOrCreateAnonymousId();
|
|
1213
1345
|
}
|
|
1214
|
-
this.logger.info("core state reset", {
|
|
1346
|
+
this.logger.info("core state reset", {
|
|
1347
|
+
resetAnonId: e,
|
|
1348
|
+
namespace: this.namespace
|
|
1349
|
+
});
|
|
1215
1350
|
}
|
|
1216
1351
|
set(e, t) {
|
|
1217
|
-
if (!
|
|
1352
|
+
if (!P(e))
|
|
1218
1353
|
throw new Error("Properties must be an object");
|
|
1219
1354
|
const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
|
|
1220
1355
|
if (i) {
|
|
@@ -1244,24 +1379,32 @@ class N {
|
|
|
1244
1379
|
let r = this.persistence.get("global_props") || {};
|
|
1245
1380
|
delete r[e], this.persistence.set("global_props", r);
|
|
1246
1381
|
}
|
|
1247
|
-
s && this.persistence.save(), this.logger.debug(
|
|
1382
|
+
s && this.persistence.save(), this.logger.debug(
|
|
1383
|
+
`Property unset: ${e}`,
|
|
1384
|
+
`Event type: ${i || "global"}`
|
|
1385
|
+
);
|
|
1248
1386
|
}
|
|
1249
1387
|
}
|
|
1250
|
-
function
|
|
1388
|
+
function ie() {
|
|
1251
1389
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1252
1390
|
}
|
|
1253
1391
|
function Te() {
|
|
1254
|
-
return
|
|
1392
|
+
return ie() ? window.define : void 0;
|
|
1255
1393
|
}
|
|
1256
1394
|
const $e = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1257
1395
|
function O(n) {
|
|
1258
|
-
const e = JSON.parse(JSON.stringify(n)), t =
|
|
1396
|
+
const e = JSON.parse(JSON.stringify(n)), t = z(e), i = {
|
|
1397
|
+
...Z,
|
|
1398
|
+
...t
|
|
1399
|
+
};
|
|
1259
1400
|
if (!i.key)
|
|
1260
1401
|
throw new Error("API key is required!");
|
|
1261
1402
|
if (!i.trackingHost)
|
|
1262
1403
|
throw new Error("Tracking host is required!");
|
|
1263
1404
|
const s = i.key || "", r = `${$e}${s}`;
|
|
1264
|
-
return h() && i.autocapture && window[r] && (console.warn(
|
|
1405
|
+
return h() && i.autocapture && window[r] && (console.warn(
|
|
1406
|
+
"Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."
|
|
1407
|
+
), i.disableAutocaptureListenerRegistration = !0), h() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new N(i);
|
|
1265
1408
|
}
|
|
1266
1409
|
function xe(n) {
|
|
1267
1410
|
var s;
|
|
@@ -1285,7 +1428,10 @@ function xe(n) {
|
|
|
1285
1428
|
minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
|
|
1286
1429
|
maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
|
|
1287
1430
|
maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
|
|
1288
|
-
propertiesStringMaxLength: parseInt(
|
|
1431
|
+
propertiesStringMaxLength: parseInt(
|
|
1432
|
+
n.getAttribute("data-properties-string-max-length") || "",
|
|
1433
|
+
10
|
|
1434
|
+
) || null,
|
|
1289
1435
|
propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
|
|
1290
1436
|
exclude: n.getAttribute("data-exclude") || void 0,
|
|
1291
1437
|
namespace: n.getAttribute("data-namespace") || void 0,
|
|
@@ -1340,13 +1486,21 @@ function He(n, e) {
|
|
|
1340
1486
|
return e[g].apply(e, u.slice(1));
|
|
1341
1487
|
console.error(`Method ${g} not found on UsermavenClient`);
|
|
1342
1488
|
}
|
|
1343
|
-
const l = ["id", "group", "reset"], c = [
|
|
1489
|
+
const l = ["id", "group", "reset"], c = [
|
|
1490
|
+
"track",
|
|
1491
|
+
"lead",
|
|
1492
|
+
"pageview",
|
|
1493
|
+
"set",
|
|
1494
|
+
"unset",
|
|
1495
|
+
"rawTrack",
|
|
1496
|
+
"setUserId"
|
|
1497
|
+
];
|
|
1344
1498
|
[...l, ...c].forEach((u) => {
|
|
1345
1499
|
a[u] = function(...g) {
|
|
1346
1500
|
if (!t) {
|
|
1347
1501
|
if (l.includes(u))
|
|
1348
|
-
return new Promise((
|
|
1349
|
-
i.push([u, ...g, { resolve:
|
|
1502
|
+
return new Promise((q, m) => {
|
|
1503
|
+
i.push([u, ...g, { resolve: q, reject: m }]);
|
|
1350
1504
|
});
|
|
1351
1505
|
i.push([u, ...g]);
|
|
1352
1506
|
return;
|
|
@@ -1367,7 +1521,7 @@ function He(n, e) {
|
|
|
1367
1521
|
u && i.push(u);
|
|
1368
1522
|
}
|
|
1369
1523
|
}
|
|
1370
|
-
let
|
|
1524
|
+
let X = !1, U = null;
|
|
1371
1525
|
if (h()) {
|
|
1372
1526
|
const n = Te();
|
|
1373
1527
|
n && n("usermaven", [], function() {
|
|
@@ -1376,20 +1530,20 @@ if (h()) {
|
|
|
1376
1530
|
UsermavenClient: N,
|
|
1377
1531
|
LogLevel: k,
|
|
1378
1532
|
// Expose the script tag client if it exists
|
|
1379
|
-
getScriptTagClient: () =>
|
|
1533
|
+
getScriptTagClient: () => U
|
|
1380
1534
|
};
|
|
1381
|
-
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = N, window.usermavenScriptTagClient = () =>
|
|
1535
|
+
}), typeof window < "u" && (window.usermavenClient = O, window.UsermavenClient = N, window.usermavenScriptTagClient = () => U), function(e, t) {
|
|
1382
1536
|
const i = e.currentScript;
|
|
1383
1537
|
function s() {
|
|
1384
|
-
return
|
|
1538
|
+
return X || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1385
1539
|
}
|
|
1386
1540
|
function r() {
|
|
1387
|
-
s() && (console.log("[Usermaven] Auto-initializing from script tag"),
|
|
1541
|
+
s() && (console.log("[Usermaven] Auto-initializing from script tag"), U = xe(i), X = !0);
|
|
1388
1542
|
}
|
|
1389
1543
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1390
1544
|
}(document, window);
|
|
1391
1545
|
}
|
|
1392
|
-
typeof module < "u" && module.exports && !
|
|
1546
|
+
typeof module < "u" && module.exports && !ie() && (module.exports = {
|
|
1393
1547
|
usermavenClient: O,
|
|
1394
1548
|
UsermavenClient: N,
|
|
1395
1549
|
Config: void 0,
|