@usermaven/react 1.5.8 → 1.5.9-rc.105
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/lib/index.es.js +345 -287
- package/package.json +2 -2
package/lib/index.es.js
CHANGED
|
@@ -8,8 +8,8 @@ const UsermavenProvider = ({ children, client }) => {
|
|
|
8
8
|
return React.createElement(Context.Provider, { value: client }, children);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
class
|
|
11
|
+
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 || {});
|
|
12
|
+
class ie {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
this.level = e;
|
|
15
15
|
}
|
|
@@ -26,11 +26,11 @@ class G {
|
|
|
26
26
|
this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return new
|
|
29
|
+
function f(n = 0) {
|
|
30
|
+
return new ie(n);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
logLevel:
|
|
32
|
+
const X = {
|
|
33
|
+
logLevel: k.ERROR,
|
|
34
34
|
useBeaconApi: !1,
|
|
35
35
|
forceUseFetch: !1,
|
|
36
36
|
trackingHost: "t.usermaven.com",
|
|
@@ -55,15 +55,15 @@ const q = {
|
|
|
55
55
|
maskAllText: !1,
|
|
56
56
|
maskAllElementAttributes: !1
|
|
57
57
|
};
|
|
58
|
-
class
|
|
58
|
+
class ne {
|
|
59
59
|
constructor(e) {
|
|
60
60
|
this.domain = e, this.cookieDomain = this.getCookieDomain();
|
|
61
61
|
}
|
|
62
62
|
set(e, t, i = 365, s = !0, r = !1) {
|
|
63
63
|
const o = /* @__PURE__ */ new Date();
|
|
64
64
|
o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
65
|
-
const
|
|
66
|
-
document.cookie = `${e}=${t};${
|
|
65
|
+
const a = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", c = r ? "; HttpOnly" : "";
|
|
66
|
+
document.cookie = `${e}=${t};${a};path=/;domain=${this.cookieDomain}${l}${c}`;
|
|
67
67
|
}
|
|
68
68
|
get(e) {
|
|
69
69
|
const t = e + "=", i = document.cookie.split(";");
|
|
@@ -104,76 +104,76 @@ class j {
|
|
|
104
104
|
return i ? i[0] : "";
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
function
|
|
107
|
+
const se = Object.prototype, re = se.hasOwnProperty, oe = Array.prototype, C = oe.forEach, U = {};
|
|
108
|
+
function ae(n, e, t) {
|
|
109
109
|
if (Array.isArray(n)) {
|
|
110
|
-
if (
|
|
110
|
+
if (C && n.forEach === C)
|
|
111
111
|
n.forEach(e, t);
|
|
112
112
|
else if ("length" in n && n.length === +n.length) {
|
|
113
113
|
for (let i = 0, s = n.length; i < s; i++)
|
|
114
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
114
|
+
if (i in n && e.call(t, n[i], i) === U)
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const D = function(n) {
|
|
120
120
|
return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
121
|
-
},
|
|
121
|
+
}, ce = function(n) {
|
|
122
122
|
for (const e in n)
|
|
123
123
|
typeof n[e] == "function" && (n[e] = n[e].bind(n));
|
|
124
124
|
};
|
|
125
|
-
function
|
|
125
|
+
function w(n, e, t) {
|
|
126
126
|
if (n != null) {
|
|
127
|
-
if (
|
|
127
|
+
if (C && Array.isArray(n) && n.forEach === C)
|
|
128
128
|
n.forEach(e, t);
|
|
129
129
|
else if ("length" in n && n.length === +n.length) {
|
|
130
130
|
for (let i = 0, s = n.length; i < s; i++)
|
|
131
|
-
if (i in n && e.call(t, n[i], i) ===
|
|
131
|
+
if (i in n && e.call(t, n[i], i) === U)
|
|
132
132
|
return;
|
|
133
133
|
} else
|
|
134
134
|
for (const i in n)
|
|
135
|
-
if (
|
|
135
|
+
if (re.call(n, i) && e.call(t, n[i], i) === U)
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
return
|
|
139
|
+
const le = function(n, ...e) {
|
|
140
|
+
return ae(e, function(t) {
|
|
141
141
|
for (const i in t)
|
|
142
142
|
t[i] !== void 0 && (n[i] = t[i]);
|
|
143
143
|
}), n;
|
|
144
144
|
};
|
|
145
|
-
function
|
|
145
|
+
function $(n, e) {
|
|
146
146
|
return n.indexOf(e) !== -1;
|
|
147
147
|
}
|
|
148
|
-
const
|
|
148
|
+
const ue = function(n) {
|
|
149
149
|
try {
|
|
150
150
|
return /^\s*\bfunction\b/.test(n);
|
|
151
151
|
} catch {
|
|
152
152
|
return !1;
|
|
153
153
|
}
|
|
154
|
-
},
|
|
154
|
+
}, he = function(n) {
|
|
155
155
|
return n === void 0;
|
|
156
|
-
},
|
|
157
|
-
const n = function(i, s, r, o,
|
|
156
|
+
}, E = function() {
|
|
157
|
+
const n = function(i, s, r, o, a) {
|
|
158
158
|
if (!i) {
|
|
159
|
-
|
|
159
|
+
f().error("No valid element provided to register_event");
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
if (i.addEventListener && !o)
|
|
163
|
-
i.addEventListener(s, r, !!
|
|
163
|
+
i.addEventListener(s, r, !!a);
|
|
164
164
|
else {
|
|
165
|
-
const l = "on" + s,
|
|
166
|
-
i[l] = e(i, r,
|
|
165
|
+
const l = "on" + s, c = i[l];
|
|
166
|
+
i[l] = e(i, r, c);
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
function e(i, s, r) {
|
|
170
170
|
return function(o) {
|
|
171
171
|
if (o = o || t(window.event), !o)
|
|
172
172
|
return;
|
|
173
|
-
let
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
return (l === !1 ||
|
|
173
|
+
let a = !0, l;
|
|
174
|
+
ue(r) && (l = r(o));
|
|
175
|
+
const c = s.call(i, o);
|
|
176
|
+
return (l === !1 || c === !1) && (a = !1), a;
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
function t(i) {
|
|
@@ -184,47 +184,47 @@ const oe = function(n) {
|
|
|
184
184
|
}, t.stopPropagation = function() {
|
|
185
185
|
this.cancelBubble = !0;
|
|
186
186
|
}, n;
|
|
187
|
-
}(),
|
|
187
|
+
}(), de = function(n) {
|
|
188
188
|
return function(...e) {
|
|
189
189
|
try {
|
|
190
190
|
return n.apply(this, e);
|
|
191
191
|
} catch (t) {
|
|
192
|
-
|
|
192
|
+
f().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
|
-
},
|
|
195
|
+
}, Z = function(n) {
|
|
196
196
|
for (const e in n)
|
|
197
|
-
typeof n[e] == "function" && (n[e] =
|
|
197
|
+
typeof n[e] == "function" && (n[e] = de(n[e]));
|
|
198
198
|
};
|
|
199
|
-
function
|
|
199
|
+
function q(n) {
|
|
200
200
|
for (let e in n)
|
|
201
201
|
(n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
|
|
202
202
|
return n;
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function h() {
|
|
205
205
|
try {
|
|
206
206
|
return typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
207
207
|
} catch {
|
|
208
|
-
return
|
|
208
|
+
return f().warn("window is not available"), !1;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function v(n = 5) {
|
|
212
212
|
const e = new Uint8Array(n);
|
|
213
213
|
return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function fe(n) {
|
|
216
216
|
return n.replace(
|
|
217
217
|
/([-_][a-z])/g,
|
|
218
218
|
(e) => e.toUpperCase().replace("-", "").replace("_", "")
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(
|
|
223
|
-
const i =
|
|
224
|
-
return e[i] =
|
|
221
|
+
function F(n) {
|
|
222
|
+
return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(F) : Object.keys(n).reduce((e, t) => {
|
|
223
|
+
const i = fe(t);
|
|
224
|
+
return e[i] = F(n[t]), e;
|
|
225
225
|
}, {});
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function x(n) {
|
|
228
228
|
switch (typeof n.className) {
|
|
229
229
|
case "string":
|
|
230
230
|
return n.className;
|
|
@@ -234,47 +234,47 @@ function A(n) {
|
|
|
234
234
|
return "";
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function V(n) {
|
|
238
238
|
let e = "";
|
|
239
|
-
return
|
|
240
|
-
|
|
241
|
-
}),
|
|
239
|
+
return M(n) && !j(n) && n.childNodes && n.childNodes.length && w(n.childNodes, function(t) {
|
|
240
|
+
G(t) && t.textContent && (e += D(t.textContent).split(/(\s+)/).filter(T).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
|
|
241
|
+
}), D(e);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function Y(n) {
|
|
244
244
|
return !!n && n.nodeType === 1;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function y(n, e) {
|
|
247
247
|
return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function G(n) {
|
|
250
250
|
return !!n && n.nodeType === 3;
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function z(n) {
|
|
253
253
|
return !!n && n.nodeType === 11;
|
|
254
254
|
}
|
|
255
|
-
const
|
|
256
|
-
function
|
|
257
|
-
if (!n ||
|
|
255
|
+
const A = ["a", "button", "form", "input", "select", "textarea", "label"];
|
|
256
|
+
function ge(n, e) {
|
|
257
|
+
if (!n || y(n, "html") || !Y(n))
|
|
258
258
|
return !1;
|
|
259
259
|
let t = n;
|
|
260
|
-
for (; t && !
|
|
260
|
+
for (; t && !y(t, "body"); ) {
|
|
261
261
|
if (t.classList && t.classList.contains("um-no-capture"))
|
|
262
262
|
return !1;
|
|
263
|
-
t.parentNode &&
|
|
263
|
+
t.parentNode && z(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
|
|
264
264
|
}
|
|
265
265
|
let i = !1;
|
|
266
|
-
for (t = n; t && !
|
|
267
|
-
if (t.parentNode &&
|
|
268
|
-
t = t.parentNode.host, t &&
|
|
266
|
+
for (t = n; t && !y(t, "body"); ) {
|
|
267
|
+
if (t.parentNode && z(t.parentNode)) {
|
|
268
|
+
t = t.parentNode.host, t && A.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
|
|
269
269
|
continue;
|
|
270
270
|
}
|
|
271
271
|
const o = t.parentNode;
|
|
272
272
|
if (!o) break;
|
|
273
|
-
if (
|
|
273
|
+
if (A.indexOf(o.tagName.toLowerCase()) > -1)
|
|
274
274
|
i = !0;
|
|
275
275
|
else {
|
|
276
|
-
const
|
|
277
|
-
|
|
276
|
+
const a = window.getComputedStyle(o);
|
|
277
|
+
a && a.getPropertyValue("cursor") === "pointer" && (i = !0);
|
|
278
278
|
}
|
|
279
279
|
t = o;
|
|
280
280
|
}
|
|
@@ -293,16 +293,16 @@ function ue(n, e) {
|
|
|
293
293
|
case "textarea":
|
|
294
294
|
return e.type === "change" || e.type === "click";
|
|
295
295
|
default:
|
|
296
|
-
return i ? e.type === "click" : e.type === "click" && (
|
|
296
|
+
return i ? e.type === "click" : e.type === "click" && (A.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
function
|
|
300
|
-
for (let i = n; i.parentNode && !
|
|
301
|
-
const s =
|
|
302
|
-
if (
|
|
299
|
+
function M(n) {
|
|
300
|
+
for (let i = n; i.parentNode && !y(i, "body"); i = i.parentNode) {
|
|
301
|
+
const s = x(i).split(" ");
|
|
302
|
+
if ($(s, "ph-sensitive") || $(s, "ph-no-capture"))
|
|
303
303
|
return !1;
|
|
304
304
|
}
|
|
305
|
-
if (
|
|
305
|
+
if ($(x(n).split(" "), "ph-include"))
|
|
306
306
|
return !0;
|
|
307
307
|
const e = n.type || "";
|
|
308
308
|
if (typeof e == "string")
|
|
@@ -315,23 +315,23 @@ function L(n) {
|
|
|
315
315
|
const t = n.name || n.id || "";
|
|
316
316
|
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, "")));
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function j(n) {
|
|
319
319
|
const e = ["button", "checkbox", "submit", "reset"];
|
|
320
|
-
return !!(
|
|
320
|
+
return !!(y(n, "input") && !e.includes(n.type) || y(n, "select") || y(n, "textarea") || n.getAttribute("contenteditable") === "true");
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
return !(n === null ||
|
|
322
|
+
function T(n) {
|
|
323
|
+
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)));
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function pe(n) {
|
|
326
326
|
return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
|
|
327
327
|
}
|
|
328
|
-
function
|
|
329
|
-
return
|
|
328
|
+
function R() {
|
|
329
|
+
return v(10);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function me(n) {
|
|
332
332
|
return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(n).toLowerCase());
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function ye(n, e) {
|
|
335
335
|
let t;
|
|
336
336
|
return function(...i) {
|
|
337
337
|
const s = () => {
|
|
@@ -340,7 +340,7 @@ function fe(n, e) {
|
|
|
340
340
|
clearTimeout(t), t = setTimeout(s, e);
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function we(n) {
|
|
344
344
|
const e = {}, t = n.replace(/^\?/, "").split("&");
|
|
345
345
|
for (let i = 0; i < t.length; i++) {
|
|
346
346
|
const s = t[i].split("=");
|
|
@@ -348,50 +348,72 @@ function ge(n) {
|
|
|
348
348
|
}
|
|
349
349
|
return e;
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function J(n) {
|
|
352
352
|
return typeof n == "string" || n instanceof String;
|
|
353
353
|
}
|
|
354
|
-
function
|
|
354
|
+
function S(n) {
|
|
355
355
|
return n !== null && typeof n == "object" && n.constructor === Object;
|
|
356
356
|
}
|
|
357
|
-
function
|
|
357
|
+
function ke(n) {
|
|
358
358
|
if (n === null)
|
|
359
|
-
return
|
|
360
|
-
const e = n.toUpperCase(), t =
|
|
361
|
-
return t || t === 0 ? t :
|
|
359
|
+
return k.ERROR;
|
|
360
|
+
const e = n.toUpperCase(), t = k[e];
|
|
361
|
+
return t || t === 0 ? t : k.ERROR;
|
|
362
362
|
}
|
|
363
|
-
const
|
|
363
|
+
const ve = () => {
|
|
364
364
|
let n = "false";
|
|
365
365
|
return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
|
|
366
366
|
};
|
|
367
|
-
class
|
|
367
|
+
class _e {
|
|
368
368
|
constructor(e) {
|
|
369
|
-
this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.
|
|
369
|
+
this.maxScrollDepth = 0, this.milestones = /* @__PURE__ */ new Set([25, 50, 75, 90]), this.reachedMilestones = /* @__PURE__ */ new Set(), this.hasSentFinalEvent = !1, this.scrollTimeout = null, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = this.createDebouncedScroll(250), this.initializeEventListeners();
|
|
370
|
+
}
|
|
371
|
+
createDebouncedScroll(e) {
|
|
372
|
+
ye(this.handleScroll.bind(this), e);
|
|
373
|
+
const t = () => {
|
|
374
|
+
this.scrollTimeout && clearTimeout(this.scrollTimeout), this.scrollTimeout = setTimeout(() => {
|
|
375
|
+
this.handleScroll(), this.scrollTimeout = null;
|
|
376
|
+
}, e);
|
|
377
|
+
};
|
|
378
|
+
return t.cancel = () => {
|
|
379
|
+
this.scrollTimeout && (clearTimeout(this.scrollTimeout), this.scrollTimeout = null);
|
|
380
|
+
}, t;
|
|
370
381
|
}
|
|
371
|
-
|
|
372
|
-
window.addEventListener("scroll", this.debouncedHandleScroll);
|
|
382
|
+
initializeEventListeners() {
|
|
383
|
+
window.addEventListener("scroll", this.debouncedHandleScroll, { passive: !0 }), window.addEventListener("pagehide", this.handlePageExit.bind(this)), window.addEventListener("beforeunload", this.handlePageExit.bind(this)), document.addEventListener("visibilitychange", this.handleVisibilityChange.bind(this));
|
|
373
384
|
}
|
|
374
385
|
track() {
|
|
375
386
|
const e = this.getScrollDepth();
|
|
376
|
-
e > this.
|
|
377
|
-
}
|
|
378
|
-
send(e = "$scroll") {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
percent: this.
|
|
387
|
+
e > this.maxScrollDepth && (this.maxScrollDepth = e, this.checkMilestones(e));
|
|
388
|
+
}
|
|
389
|
+
send(e = "$scroll", t) {
|
|
390
|
+
const i = this.getScrollDepth();
|
|
391
|
+
this.maxScrollDepth = Math.max(this.maxScrollDepth, i);
|
|
392
|
+
const s = {
|
|
393
|
+
percent: t ?? this.maxScrollDepth,
|
|
394
|
+
max_percent: this.maxScrollDepth,
|
|
383
395
|
window_height: this.getWindowHeight(),
|
|
384
396
|
document_height: this.getDocumentHeight(),
|
|
385
|
-
scroll_distance: this.getScrollDistance()
|
|
397
|
+
scroll_distance: this.getScrollDistance(),
|
|
398
|
+
is_final: e === "$scroll_exit"
|
|
386
399
|
};
|
|
387
|
-
this.client.track(e,
|
|
400
|
+
this.client.track(e, s);
|
|
388
401
|
}
|
|
389
402
|
handleScroll() {
|
|
390
403
|
this.track();
|
|
391
404
|
}
|
|
405
|
+
handlePageExit() {
|
|
406
|
+
this.hasSentFinalEvent || (this.debouncedHandleScroll.cancel && this.debouncedHandleScroll.cancel(), this.track(), this.send("$scroll_exit"), this.hasSentFinalEvent = !0);
|
|
407
|
+
}
|
|
408
|
+
handleVisibilityChange() {
|
|
409
|
+
document.hidden && (this.track(), this.send("$scroll_checkpoint"));
|
|
410
|
+
}
|
|
392
411
|
getScrollDepth() {
|
|
393
|
-
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance()
|
|
394
|
-
|
|
412
|
+
const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance();
|
|
413
|
+
if (t <= e)
|
|
414
|
+
return 100;
|
|
415
|
+
const s = t - e, r = i / s * 100;
|
|
416
|
+
return Math.min(100, Math.max(0, Math.round(r)));
|
|
395
417
|
}
|
|
396
418
|
getWindowHeight() {
|
|
397
419
|
return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
|
|
@@ -410,14 +432,17 @@ class ye {
|
|
|
410
432
|
return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
411
433
|
}
|
|
412
434
|
checkMilestones(e) {
|
|
413
|
-
this.milestones.
|
|
414
|
-
this.
|
|
435
|
+
this.milestones.forEach((t) => {
|
|
436
|
+
e >= t && !this.reachedMilestones.has(t) && (this.reachedMilestones.add(t), this.send(`$scroll_milestone_${t}`, t));
|
|
415
437
|
});
|
|
416
438
|
}
|
|
439
|
+
destroy() {
|
|
440
|
+
window.removeEventListener("scroll", this.debouncedHandleScroll), window.removeEventListener("pagehide", this.handlePageExit.bind(this)), window.removeEventListener("beforeunload", this.handlePageExit.bind(this)), document.removeEventListener("visibilitychange", this.handleVisibilityChange.bind(this)), this.hasSentFinalEvent || this.handlePageExit();
|
|
441
|
+
}
|
|
417
442
|
}
|
|
418
|
-
const
|
|
419
|
-
constructor(e, t, i =
|
|
420
|
-
this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new
|
|
443
|
+
const L = class L {
|
|
444
|
+
constructor(e, t, i = f()) {
|
|
445
|
+
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);
|
|
421
446
|
}
|
|
422
447
|
isBrowserSupported() {
|
|
423
448
|
return typeof document < "u" && typeof document.addEventListener == "function";
|
|
@@ -441,7 +466,7 @@ const T = class T {
|
|
|
441
466
|
const e = (t) => {
|
|
442
467
|
t = t || window.event, this.captureEvent(t);
|
|
443
468
|
};
|
|
444
|
-
|
|
469
|
+
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);
|
|
445
470
|
}
|
|
446
471
|
isPageRefresh() {
|
|
447
472
|
if ("PerformanceNavigationTiming" in window) {
|
|
@@ -454,61 +479,61 @@ const T = class T {
|
|
|
454
479
|
captureEvent(e) {
|
|
455
480
|
var i, s;
|
|
456
481
|
let t = this.getEventTarget(e);
|
|
457
|
-
if (
|
|
482
|
+
if (G(t) && (t = t.parentNode || null), e.type === "scroll")
|
|
458
483
|
return (i = this.scrollDepth) == null || i.track(), !0;
|
|
459
484
|
if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
|
|
460
485
|
return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
|
|
461
|
-
if (t &&
|
|
486
|
+
if (t && ge(t, e)) {
|
|
462
487
|
const r = [t];
|
|
463
488
|
let o = t;
|
|
464
|
-
for (; o.parentNode && !
|
|
465
|
-
if (
|
|
489
|
+
for (; o.parentNode && !y(o, "body"); ) {
|
|
490
|
+
if (z(o.parentNode)) {
|
|
466
491
|
r.push(o.parentNode.host), o = o.parentNode.host;
|
|
467
492
|
continue;
|
|
468
493
|
}
|
|
469
494
|
r.push(o.parentNode), o = o.parentNode;
|
|
470
495
|
}
|
|
471
|
-
const
|
|
472
|
-
let l,
|
|
473
|
-
if (
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
496
|
+
const a = [];
|
|
497
|
+
let l, c = !1;
|
|
498
|
+
if (w(r, (p) => {
|
|
499
|
+
const _ = M(p);
|
|
500
|
+
p.tagName.toLowerCase() === "a" && (l = p.getAttribute("href"), l = _ && T(l) && l);
|
|
501
|
+
const u = x(p).split(" ");
|
|
502
|
+
$(u, "ph-no-capture") && (c = !0), a.push(
|
|
478
503
|
this.getPropertiesFromElement(
|
|
479
|
-
|
|
504
|
+
p,
|
|
480
505
|
this.options.maskAllElementAttributes ?? !1,
|
|
481
506
|
this.options.maskAllText ?? !1
|
|
482
507
|
)
|
|
483
508
|
);
|
|
484
|
-
}), this.options.maskAllText || (
|
|
509
|
+
}), this.options.maskAllText || (a[0].$el_text = V(t)), l && (a[0].attr__href = l), c)
|
|
485
510
|
return !1;
|
|
486
|
-
const
|
|
511
|
+
const d = le(
|
|
487
512
|
this.getDefaultProperties(e.type),
|
|
488
513
|
{
|
|
489
|
-
$elements:
|
|
514
|
+
$elements: a
|
|
490
515
|
},
|
|
491
516
|
this.getCustomProperties(r)
|
|
492
517
|
);
|
|
493
|
-
return this.client.track("$autocapture",
|
|
518
|
+
return this.client.track("$autocapture", d), !0;
|
|
494
519
|
}
|
|
495
520
|
}
|
|
496
521
|
getCustomProperties(e) {
|
|
497
522
|
const t = {};
|
|
498
|
-
return
|
|
499
|
-
|
|
523
|
+
return w(this.customProperties, (i) => {
|
|
524
|
+
w(i.event_selectors, (s) => {
|
|
500
525
|
const r = document.querySelectorAll(s);
|
|
501
|
-
|
|
502
|
-
|
|
526
|
+
w(r, (o) => {
|
|
527
|
+
$(e, o) && M(o) && (t[i.name] = this.extractCustomPropertyValue(i));
|
|
503
528
|
});
|
|
504
529
|
});
|
|
505
530
|
}), t;
|
|
506
531
|
}
|
|
507
532
|
extractCustomPropertyValue(e) {
|
|
508
533
|
const t = [];
|
|
509
|
-
return
|
|
534
|
+
return w(document.querySelectorAll(e.css_selector), function(i) {
|
|
510
535
|
let s;
|
|
511
|
-
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent),
|
|
536
|
+
["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), T(s) && t.push(s);
|
|
512
537
|
}), t.join(", ");
|
|
513
538
|
}
|
|
514
539
|
getEventTarget(e) {
|
|
@@ -519,17 +544,17 @@ const T = class T {
|
|
|
519
544
|
const s = e.tagName.toLowerCase(), r = {
|
|
520
545
|
tag_name: s
|
|
521
546
|
};
|
|
522
|
-
|
|
523
|
-
const o =
|
|
524
|
-
o.length > 0 && (r.classes = o.split(" ").filter(function(
|
|
525
|
-
return
|
|
526
|
-
})),
|
|
527
|
-
|
|
547
|
+
A.indexOf(s) > -1 && !i && (r.$el_text = V(e));
|
|
548
|
+
const o = x(e);
|
|
549
|
+
o.length > 0 && (r.classes = o.split(" ").filter(function(d) {
|
|
550
|
+
return d !== "";
|
|
551
|
+
})), w(e.attributes, function(d) {
|
|
552
|
+
j(e) && ["name", "id", "class"].indexOf(d.name) === -1 || !t && T(d.value) && !pe(d.name) && (r["attr__" + d.name] = d.value);
|
|
528
553
|
});
|
|
529
|
-
let
|
|
530
|
-
for (;
|
|
531
|
-
|
|
532
|
-
return r.nth_child =
|
|
554
|
+
let a = 1, l = 1, c = e;
|
|
555
|
+
for (; c = this.previousElementSibling(c); )
|
|
556
|
+
a++, c.tagName === e.tagName && l++;
|
|
557
|
+
return r.nth_child = a, r.nth_of_type = l, r;
|
|
533
558
|
}
|
|
534
559
|
previousElementSibling(e) {
|
|
535
560
|
if (e.previousElementSibling)
|
|
@@ -538,7 +563,7 @@ const T = class T {
|
|
|
538
563
|
let t = e;
|
|
539
564
|
do
|
|
540
565
|
t = t.previousSibling;
|
|
541
|
-
while (t && !
|
|
566
|
+
while (t && !Y(t));
|
|
542
567
|
return t;
|
|
543
568
|
}
|
|
544
569
|
}
|
|
@@ -560,9 +585,9 @@ const T = class T {
|
|
|
560
585
|
return s % t < i;
|
|
561
586
|
}
|
|
562
587
|
};
|
|
563
|
-
|
|
564
|
-
let
|
|
565
|
-
class
|
|
588
|
+
L.FORCE_CAPTURE_ATTR = "data-um-force-capture", L.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
|
|
589
|
+
let H = L;
|
|
590
|
+
class be {
|
|
566
591
|
constructor(e) {
|
|
567
592
|
this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
|
|
568
593
|
}
|
|
@@ -591,8 +616,8 @@ class we {
|
|
|
591
616
|
}));
|
|
592
617
|
}
|
|
593
618
|
}
|
|
594
|
-
class
|
|
595
|
-
constructor(e, t, i =
|
|
619
|
+
class Ee {
|
|
620
|
+
constructor(e, t, i = f()) {
|
|
596
621
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
597
622
|
}
|
|
598
623
|
async send(e) {
|
|
@@ -603,14 +628,14 @@ class ke {
|
|
|
603
628
|
throw new Error("Failed to queue events via Beacon API");
|
|
604
629
|
}
|
|
605
630
|
constructUrl(e) {
|
|
606
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
607
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
631
|
+
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";
|
|
632
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
608
633
|
}
|
|
609
634
|
// Note: Beacon API doesn't support custom headers, so we can't use them here.
|
|
610
635
|
// If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
|
|
611
636
|
}
|
|
612
|
-
class
|
|
613
|
-
constructor(e, t, i =
|
|
637
|
+
class Q {
|
|
638
|
+
constructor(e, t, i = f()) {
|
|
614
639
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
615
640
|
}
|
|
616
641
|
async send(e) {
|
|
@@ -627,8 +652,8 @@ class z {
|
|
|
627
652
|
this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
|
|
628
653
|
}
|
|
629
654
|
constructUrl(e) {
|
|
630
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
631
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
655
|
+
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";
|
|
656
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
632
657
|
}
|
|
633
658
|
getCustomHeaders() {
|
|
634
659
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -637,17 +662,17 @@ class z {
|
|
|
637
662
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
638
663
|
}
|
|
639
664
|
}
|
|
640
|
-
class
|
|
641
|
-
constructor(e, t, i =
|
|
665
|
+
class Pe {
|
|
666
|
+
constructor(e, t, i = f()) {
|
|
642
667
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
643
668
|
}
|
|
644
669
|
send(e) {
|
|
645
670
|
return new Promise((t, i) => {
|
|
646
671
|
const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
|
|
647
672
|
s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
|
|
648
|
-
const
|
|
649
|
-
Object.keys(
|
|
650
|
-
s.setRequestHeader(l,
|
|
673
|
+
const a = this.getCustomHeaders();
|
|
674
|
+
Object.keys(a).forEach((l) => {
|
|
675
|
+
s.setRequestHeader(l, a[l]);
|
|
651
676
|
}), s.onload = () => {
|
|
652
677
|
s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
|
|
653
678
|
}, s.onerror = () => {
|
|
@@ -656,8 +681,8 @@ class ve {
|
|
|
656
681
|
});
|
|
657
682
|
}
|
|
658
683
|
constructUrl(e) {
|
|
659
|
-
const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s =
|
|
660
|
-
return this.config.randomizeUrl ? `${this.trackingHost}/api.${
|
|
684
|
+
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";
|
|
685
|
+
return this.config.randomizeUrl ? `${this.trackingHost}/api.${v()}?p_${v()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
|
|
661
686
|
}
|
|
662
687
|
getCustomHeaders() {
|
|
663
688
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
@@ -666,9 +691,9 @@ class ve {
|
|
|
666
691
|
this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
|
|
667
692
|
}
|
|
668
693
|
}
|
|
669
|
-
class
|
|
694
|
+
class ee {
|
|
670
695
|
constructor(e, t) {
|
|
671
|
-
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t ||
|
|
696
|
+
this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || f();
|
|
672
697
|
}
|
|
673
698
|
set(e, t) {
|
|
674
699
|
this.storage[e] = t, this.save();
|
|
@@ -683,7 +708,7 @@ class K {
|
|
|
683
708
|
this.storage = {}, this.save();
|
|
684
709
|
}
|
|
685
710
|
save() {
|
|
686
|
-
if (!
|
|
711
|
+
if (!h()) {
|
|
687
712
|
this.logger.warn("localStorage is not available in this environment");
|
|
688
713
|
return;
|
|
689
714
|
}
|
|
@@ -694,7 +719,7 @@ class K {
|
|
|
694
719
|
}
|
|
695
720
|
}
|
|
696
721
|
load() {
|
|
697
|
-
if (!
|
|
722
|
+
if (!h()) {
|
|
698
723
|
this.logger.warn("localStorage is not available in this environment");
|
|
699
724
|
return;
|
|
700
725
|
}
|
|
@@ -706,7 +731,7 @@ class K {
|
|
|
706
731
|
}
|
|
707
732
|
}
|
|
708
733
|
}
|
|
709
|
-
class
|
|
734
|
+
class Se {
|
|
710
735
|
constructor() {
|
|
711
736
|
this.storage = {};
|
|
712
737
|
}
|
|
@@ -725,56 +750,56 @@ class _e {
|
|
|
725
750
|
this.storage = {};
|
|
726
751
|
}
|
|
727
752
|
}
|
|
728
|
-
class
|
|
753
|
+
class W {
|
|
729
754
|
// Default to true for server-side
|
|
730
|
-
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o =
|
|
731
|
-
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
|
+
constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = f(), a = "default") {
|
|
756
|
+
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());
|
|
732
757
|
}
|
|
733
758
|
add(e) {
|
|
734
759
|
const t = { payload: e, retries: 0, timestamp: Date.now() };
|
|
735
|
-
this.queue.push(t),
|
|
760
|
+
this.queue.push(t), h() ? this.saveQueueToStorage() : this.processBatch();
|
|
736
761
|
}
|
|
737
762
|
initNetworkListeners() {
|
|
738
|
-
|
|
763
|
+
h() && (window.addEventListener("online", () => {
|
|
739
764
|
this.isOnline = !0, this.processBatch();
|
|
740
765
|
}), window.addEventListener("offline", () => {
|
|
741
766
|
this.isOnline = !1;
|
|
742
767
|
}));
|
|
743
768
|
}
|
|
744
769
|
scheduleBatch() {
|
|
745
|
-
|
|
770
|
+
h() && (this.batchTimeoutId !== null && clearTimeout(this.batchTimeoutId), this.batchTimeoutId = window.setTimeout(() => this.processBatch(), this.batchInterval));
|
|
746
771
|
}
|
|
747
772
|
async processBatch() {
|
|
748
|
-
if ((!
|
|
773
|
+
if ((!h() || this.isOnline) && !this.processing && this.queue.length > 0) {
|
|
749
774
|
this.processing = !0;
|
|
750
775
|
const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
|
|
751
776
|
try {
|
|
752
|
-
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`),
|
|
777
|
+
await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), h() && this.saveQueueToStorage();
|
|
753
778
|
} catch (i) {
|
|
754
779
|
this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
|
|
755
780
|
}
|
|
756
781
|
this.processing = !1;
|
|
757
782
|
}
|
|
758
|
-
|
|
783
|
+
h() && this.scheduleBatch();
|
|
759
784
|
}
|
|
760
785
|
async handleBatchFailure(e) {
|
|
761
786
|
for (const t of e)
|
|
762
787
|
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);
|
|
763
|
-
|
|
788
|
+
h() && (this.saveQueueToStorage(), await new Promise((t) => setTimeout(t, this.retryInterval)));
|
|
764
789
|
}
|
|
765
790
|
loadQueueFromStorage() {
|
|
766
|
-
if (
|
|
791
|
+
if (h()) {
|
|
767
792
|
const e = this.persistence.get("queue");
|
|
768
793
|
e && (this.queue = JSON.parse(e));
|
|
769
794
|
}
|
|
770
795
|
}
|
|
771
796
|
saveQueueToStorage() {
|
|
772
|
-
|
|
797
|
+
h() && this.persistence.set("queue", JSON.stringify(this.queue));
|
|
773
798
|
}
|
|
774
799
|
}
|
|
775
|
-
class
|
|
800
|
+
class $e {
|
|
776
801
|
constructor(e) {
|
|
777
|
-
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(),
|
|
802
|
+
this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), Z(this);
|
|
778
803
|
}
|
|
779
804
|
initializeEventListener() {
|
|
780
805
|
document.addEventListener("click", this.handleClick.bind(this));
|
|
@@ -794,8 +819,8 @@ class be {
|
|
|
794
819
|
const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
|
|
795
820
|
this.clicks.every((r, o) => {
|
|
796
821
|
if (o === 0) return !0;
|
|
797
|
-
const
|
|
798
|
-
return Math.sqrt(Math.pow(r.x -
|
|
822
|
+
const a = this.clicks[o - 1];
|
|
823
|
+
return Math.sqrt(Math.pow(r.x - a.x, 2) + Math.pow(r.y - a.y, 2)) < this.distanceThreshold;
|
|
799
824
|
}) && this.sendRageClickEvent(i);
|
|
800
825
|
}
|
|
801
826
|
sendRageClickEvent(e) {
|
|
@@ -806,8 +831,8 @@ class be {
|
|
|
806
831
|
}), this.clicks = [];
|
|
807
832
|
}
|
|
808
833
|
}
|
|
809
|
-
class
|
|
810
|
-
constructor(e, t, i =
|
|
834
|
+
class Ae {
|
|
835
|
+
constructor(e, t, i = f()) {
|
|
811
836
|
this.trackingHost = e, this.logger = i, this.config = t;
|
|
812
837
|
}
|
|
813
838
|
async send(e) {
|
|
@@ -822,16 +847,16 @@ class Ee {
|
|
|
822
847
|
}
|
|
823
848
|
};
|
|
824
849
|
return new Promise((r, o) => {
|
|
825
|
-
const
|
|
826
|
-
l.on("data", (
|
|
850
|
+
const a = (void 0)(s, (l) => {
|
|
851
|
+
l.on("data", (c) => {
|
|
827
852
|
}), l.on("end", () => {
|
|
828
|
-
const
|
|
829
|
-
|
|
853
|
+
const c = l.statusCode || 0;
|
|
854
|
+
c >= 200 && c < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), r()) : o(new Error(`HTTP error! status: ${c}`));
|
|
830
855
|
});
|
|
831
856
|
});
|
|
832
|
-
|
|
857
|
+
a.on("error", (l) => {
|
|
833
858
|
o(l);
|
|
834
|
-
}),
|
|
859
|
+
}), a.write(JSON.stringify(e)), a.end();
|
|
835
860
|
});
|
|
836
861
|
}
|
|
837
862
|
constructUrl(e) {
|
|
@@ -842,7 +867,7 @@ class Ee {
|
|
|
842
867
|
return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
|
|
843
868
|
}
|
|
844
869
|
}
|
|
845
|
-
class
|
|
870
|
+
class P {
|
|
846
871
|
constructor(e, t = "all", i = {}) {
|
|
847
872
|
this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
|
|
848
873
|
}
|
|
@@ -857,18 +882,18 @@ class w {
|
|
|
857
882
|
}
|
|
858
883
|
handleFormSubmit(e) {
|
|
859
884
|
const t = e.target, i = this._getFormDetails(t);
|
|
860
|
-
this.instance.track("$form",
|
|
885
|
+
this.instance.track("$form", q(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
|
|
861
886
|
}
|
|
862
887
|
trackFieldChanges(e) {
|
|
863
888
|
e.querySelectorAll("input, select, textarea").forEach((i) => {
|
|
864
889
|
i.addEventListener("change", (s) => {
|
|
865
890
|
const r = this._getFieldProps(s.target, 0);
|
|
866
|
-
this.instance.track("$form_field_change",
|
|
891
|
+
this.instance.track("$form_field_change", q(r));
|
|
867
892
|
});
|
|
868
893
|
});
|
|
869
894
|
}
|
|
870
895
|
static getInstance(e, t = "all", i = {}) {
|
|
871
|
-
return
|
|
896
|
+
return P.instance || (P.instance = new P(e, t, i)), P.instance;
|
|
872
897
|
}
|
|
873
898
|
_getFormDetails(e) {
|
|
874
899
|
const t = {
|
|
@@ -880,8 +905,8 @@ class w {
|
|
|
880
905
|
form_attributes: this._getElementAttributes(e)
|
|
881
906
|
}, i = e.querySelectorAll("input, select, textarea");
|
|
882
907
|
return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
|
|
883
|
-
const
|
|
884
|
-
Object.assign(t,
|
|
908
|
+
const a = this._getFieldProps(r, o);
|
|
909
|
+
Object.assign(t, a);
|
|
885
910
|
}), t;
|
|
886
911
|
}
|
|
887
912
|
_getFieldProps(e, t) {
|
|
@@ -956,9 +981,9 @@ class w {
|
|
|
956
981
|
return e.slice(t, i + 1);
|
|
957
982
|
}
|
|
958
983
|
}
|
|
959
|
-
class
|
|
984
|
+
class N {
|
|
960
985
|
constructor(e) {
|
|
961
|
-
this.config = this.mergeConfig(e,
|
|
986
|
+
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(
|
|
962
987
|
this.transport,
|
|
963
988
|
this.config.maxSendAttempts || 3,
|
|
964
989
|
this.config.minSendTimeout || 1e3,
|
|
@@ -967,16 +992,16 @@ class S {
|
|
|
967
992
|
// Reduced interval to .2 second
|
|
968
993
|
this.logger,
|
|
969
994
|
this.namespace
|
|
970
|
-
),
|
|
995
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
|
|
971
996
|
}
|
|
972
997
|
initializeBrowserFeatures() {
|
|
973
|
-
if (this.cookieManager = new
|
|
998
|
+
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) {
|
|
974
999
|
const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
|
|
975
|
-
this.formTracking =
|
|
1000
|
+
this.formTracking = P.getInstance(this, e || "none", {
|
|
976
1001
|
trackFieldChanges: !1
|
|
977
1002
|
});
|
|
978
1003
|
}
|
|
979
|
-
this.config.autoPageview && (this.pageviewTracking = new
|
|
1004
|
+
this.config.autoPageview && (this.pageviewTracking = new be(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new $e(this)), this.setupPageLeaveTracking();
|
|
980
1005
|
}
|
|
981
1006
|
/**
|
|
982
1007
|
* Recursively merge the provided configuration with the existing defaultConfig
|
|
@@ -987,11 +1012,11 @@ class S {
|
|
|
987
1012
|
const i = JSON.parse(JSON.stringify(e));
|
|
988
1013
|
let s = { ...t, ...i };
|
|
989
1014
|
return Object.keys(t).forEach((r) => {
|
|
990
|
-
|
|
1015
|
+
S(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
|
|
991
1016
|
}), s;
|
|
992
1017
|
}
|
|
993
1018
|
init(e) {
|
|
994
|
-
this.config = { ...this.config, ...e }, this.logger =
|
|
1019
|
+
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(
|
|
995
1020
|
this.transport,
|
|
996
1021
|
this.config.maxSendAttempts || 3,
|
|
997
1022
|
this.config.minSendTimeout || 1e3,
|
|
@@ -1000,21 +1025,21 @@ class S {
|
|
|
1000
1025
|
// Reduced interval to .25 second
|
|
1001
1026
|
this.logger,
|
|
1002
1027
|
this.namespace
|
|
1003
|
-
),
|
|
1028
|
+
), h() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client reinitialized for namespace: ${this.namespace}`);
|
|
1004
1029
|
}
|
|
1005
1030
|
manageCrossDomainLinking() {
|
|
1006
1031
|
if (!this.config.crossDomainLinking || !this.config.domains)
|
|
1007
1032
|
return;
|
|
1008
1033
|
const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1009
1034
|
document.addEventListener("click", (i) => {
|
|
1010
|
-
var
|
|
1035
|
+
var a;
|
|
1011
1036
|
const s = this.findClosestLink(i.target);
|
|
1012
1037
|
if (!s) return;
|
|
1013
1038
|
const r = s.getAttribute("href");
|
|
1014
1039
|
if (!r || !r.startsWith("http")) return;
|
|
1015
1040
|
const o = new URL(r);
|
|
1016
1041
|
if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
|
|
1017
|
-
const l = (
|
|
1042
|
+
const l = (a = this.cookieManager) == null ? void 0 : a.get(t);
|
|
1018
1043
|
l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
|
|
1019
1044
|
}
|
|
1020
1045
|
}), this.logger.debug("Cross-domain linking initialized");
|
|
@@ -1026,47 +1051,47 @@ class S {
|
|
|
1026
1051
|
}
|
|
1027
1052
|
initializeTransport(e) {
|
|
1028
1053
|
const t = "https://events.usermaven.com";
|
|
1029
|
-
if (!
|
|
1030
|
-
return new
|
|
1054
|
+
if (!h())
|
|
1055
|
+
return new Ae(e.trackingHost || t, e);
|
|
1031
1056
|
const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
|
|
1032
1057
|
if (e.useBeaconApi && r)
|
|
1033
|
-
return new
|
|
1058
|
+
return new Ee(e.trackingHost || t, e, this.logger);
|
|
1034
1059
|
if (e.forceUseFetch && s)
|
|
1035
|
-
return new
|
|
1060
|
+
return new Q(e.trackingHost || t, e, this.logger);
|
|
1036
1061
|
if (i)
|
|
1037
|
-
return new
|
|
1062
|
+
return new Pe(e.trackingHost || t, e, this.logger);
|
|
1038
1063
|
if (s)
|
|
1039
|
-
return new
|
|
1064
|
+
return new Q(e.trackingHost || t, e, this.logger);
|
|
1040
1065
|
throw new Error("No suitable transport method available");
|
|
1041
1066
|
}
|
|
1042
1067
|
initializePersistence() {
|
|
1043
|
-
return this.config.disableEventPersistence || !
|
|
1068
|
+
return this.config.disableEventPersistence || !h() ? new Se() : new ee(`${this.namespace}_${this.config.key}`, this.logger);
|
|
1044
1069
|
}
|
|
1045
1070
|
getOrCreateAnonymousId() {
|
|
1046
1071
|
var i, s;
|
|
1047
|
-
if (!
|
|
1048
|
-
return
|
|
1072
|
+
if (!h())
|
|
1073
|
+
return R();
|
|
1049
1074
|
if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
|
|
1050
1075
|
return "";
|
|
1051
1076
|
const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
|
|
1052
1077
|
let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
|
|
1053
1078
|
if (!t) {
|
|
1054
1079
|
if (this.config.crossDomainLinking) {
|
|
1055
|
-
const
|
|
1056
|
-
t =
|
|
1080
|
+
const a = new URLSearchParams(window.location.search).get("_um"), c = window.location.hash.substring(1).split("~"), d = c.length > 1 ? c[1] : void 0;
|
|
1081
|
+
t = a || d || R();
|
|
1057
1082
|
}
|
|
1058
|
-
t || (t =
|
|
1083
|
+
t || (t = R());
|
|
1059
1084
|
const r = 365 * 10;
|
|
1060
1085
|
(s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
|
|
1061
1086
|
}
|
|
1062
1087
|
return t;
|
|
1063
1088
|
}
|
|
1064
1089
|
async id(e, t = !1) {
|
|
1065
|
-
if (!
|
|
1090
|
+
if (!S(e))
|
|
1066
1091
|
throw new Error("User data must be an object");
|
|
1067
|
-
if (e.email && !
|
|
1092
|
+
if (e.email && !me(e.email))
|
|
1068
1093
|
throw new Error("Invalid email provided");
|
|
1069
|
-
if (!e.id || !
|
|
1094
|
+
if (!e.id || !J(e.id))
|
|
1070
1095
|
throw new Error("User ID must be a string");
|
|
1071
1096
|
const i = e.id;
|
|
1072
1097
|
if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
|
|
@@ -1082,11 +1107,11 @@ class S {
|
|
|
1082
1107
|
this.trackInternal(e, t, i);
|
|
1083
1108
|
}
|
|
1084
1109
|
trackInternal(e, t, i = !1) {
|
|
1085
|
-
if (
|
|
1110
|
+
if (ve()) {
|
|
1086
1111
|
this.logger.debug("Tracking disabled due to um_exclusion setting");
|
|
1087
1112
|
return;
|
|
1088
1113
|
}
|
|
1089
|
-
if (!
|
|
1114
|
+
if (!J(e))
|
|
1090
1115
|
throw new Error("Event name must be a string");
|
|
1091
1116
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
1092
1117
|
throw new Error("Event payload must be a non-null object and not an array");
|
|
@@ -1102,21 +1127,21 @@ class S {
|
|
|
1102
1127
|
}
|
|
1103
1128
|
}
|
|
1104
1129
|
rawTrack(e) {
|
|
1105
|
-
if (!
|
|
1130
|
+
if (!S(e))
|
|
1106
1131
|
throw new Error("Event payload must be an object");
|
|
1107
1132
|
this.track("raw", e);
|
|
1108
1133
|
}
|
|
1109
1134
|
async group(e, t = !1) {
|
|
1110
|
-
if (!
|
|
1135
|
+
if (!S(e))
|
|
1111
1136
|
throw new Error("Company properties must be an object");
|
|
1112
1137
|
if (!e.id || !e.name || !e.created_at)
|
|
1113
1138
|
throw new Error("Company properties must include id, name, and created_at");
|
|
1114
1139
|
this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
|
|
1115
1140
|
}
|
|
1116
1141
|
createEventPayload(e, t) {
|
|
1117
|
-
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") || {},
|
|
1142
|
+
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}`) || {};
|
|
1118
1143
|
let l = t || {};
|
|
1119
|
-
const
|
|
1144
|
+
const c = {
|
|
1120
1145
|
event_id: "",
|
|
1121
1146
|
user: {
|
|
1122
1147
|
anonymous_id: this.anonymousId,
|
|
@@ -1132,15 +1157,15 @@ class S {
|
|
|
1132
1157
|
event_type: e,
|
|
1133
1158
|
namespace: this.namespace,
|
|
1134
1159
|
...o,
|
|
1135
|
-
...
|
|
1160
|
+
...a
|
|
1136
1161
|
};
|
|
1137
1162
|
if (e === "$autocapture") {
|
|
1138
|
-
const
|
|
1139
|
-
|
|
1140
|
-
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((
|
|
1141
|
-
delete l[
|
|
1142
|
-
}),
|
|
1143
|
-
return
|
|
1163
|
+
const d = this.processAutocaptureAttributes(t || {});
|
|
1164
|
+
c.autocapture_attributes = d;
|
|
1165
|
+
} else e !== "user_identify" && e !== "group" && (Array.isArray(this.config.propertyBlacklist) && this.config.propertyBlacklist.forEach((d) => {
|
|
1166
|
+
delete l[d];
|
|
1167
|
+
}), c.event_attributes = l);
|
|
1168
|
+
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;
|
|
1144
1169
|
}
|
|
1145
1170
|
processAutocaptureAttributes(e) {
|
|
1146
1171
|
let t = {};
|
|
@@ -1155,27 +1180,27 @@ class S {
|
|
|
1155
1180
|
}
|
|
1156
1181
|
getThirdPartyIds() {
|
|
1157
1182
|
const e = {};
|
|
1158
|
-
if (
|
|
1183
|
+
if (h()) {
|
|
1159
1184
|
const t = this.getCookie("_fbp");
|
|
1160
1185
|
t && (e.fbp = t);
|
|
1161
1186
|
}
|
|
1162
1187
|
return e;
|
|
1163
1188
|
}
|
|
1164
1189
|
getUtmParams() {
|
|
1165
|
-
const e = {}, t =
|
|
1190
|
+
const e = {}, t = we(window.location.search);
|
|
1166
1191
|
return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
|
|
1167
1192
|
t[s] && (e[s.replace("utm_", "")] = t[s]);
|
|
1168
1193
|
}), e;
|
|
1169
1194
|
}
|
|
1170
1195
|
pageview() {
|
|
1171
|
-
|
|
1196
|
+
h() ? this.track("pageview", {
|
|
1172
1197
|
url: window.location.href,
|
|
1173
1198
|
referrer: document.referrer,
|
|
1174
1199
|
title: document.title
|
|
1175
1200
|
}, !0) : this.logger.warn("Pageview tracking is not available in server-side environments");
|
|
1176
1201
|
}
|
|
1177
1202
|
setupPageLeaveTracking() {
|
|
1178
|
-
if (!
|
|
1203
|
+
if (!h()) return;
|
|
1179
1204
|
let e = !1, t = !1;
|
|
1180
1205
|
const i = () => {
|
|
1181
1206
|
!e && !t && (e = !0, this.track("$pageleave", {
|
|
@@ -1210,7 +1235,7 @@ class S {
|
|
|
1210
1235
|
this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
|
|
1211
1236
|
}
|
|
1212
1237
|
set(e, t) {
|
|
1213
|
-
if (!
|
|
1238
|
+
if (!S(e))
|
|
1214
1239
|
throw new Error("Properties must be an object");
|
|
1215
1240
|
const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
|
|
1216
1241
|
if (i) {
|
|
@@ -1243,28 +1268,28 @@ class S {
|
|
|
1243
1268
|
s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
|
|
1244
1269
|
}
|
|
1245
1270
|
}
|
|
1246
|
-
function
|
|
1271
|
+
function te() {
|
|
1247
1272
|
return typeof window < "u" && typeof window.define == "function" && window.define.amd;
|
|
1248
1273
|
}
|
|
1249
|
-
function
|
|
1250
|
-
return
|
|
1274
|
+
function Te() {
|
|
1275
|
+
return te() ? window.define : void 0;
|
|
1251
1276
|
}
|
|
1252
|
-
const
|
|
1253
|
-
function
|
|
1254
|
-
const e = JSON.parse(JSON.stringify(n)), t =
|
|
1277
|
+
const Ce = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
|
|
1278
|
+
function I(n) {
|
|
1279
|
+
const e = JSON.parse(JSON.stringify(n)), t = F(e), i = { ...X, ...t };
|
|
1255
1280
|
if (!i.key)
|
|
1256
1281
|
throw new Error("API key is required!");
|
|
1257
1282
|
if (!i.trackingHost)
|
|
1258
1283
|
throw new Error("Tracking host is required!");
|
|
1259
|
-
const s = i.key || "", r = `${
|
|
1260
|
-
return
|
|
1284
|
+
const s = i.key || "", r = `${Ce}${s}`;
|
|
1285
|
+
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);
|
|
1261
1286
|
}
|
|
1262
|
-
function
|
|
1287
|
+
function xe(n) {
|
|
1263
1288
|
var s;
|
|
1264
1289
|
const e = {
|
|
1265
1290
|
key: n.getAttribute("data-key") || void 0,
|
|
1266
1291
|
trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
|
|
1267
|
-
logLevel:
|
|
1292
|
+
logLevel: ke(n.getAttribute("data-log-level")),
|
|
1268
1293
|
autocapture: n.getAttribute("data-autocapture") === "true",
|
|
1269
1294
|
formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
|
|
1270
1295
|
autoPageview: n.getAttribute("data-auto-pageview") === "true",
|
|
@@ -1291,79 +1316,112 @@ function $e(n) {
|
|
|
1291
1316
|
maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
|
|
1292
1317
|
};
|
|
1293
1318
|
e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
|
|
1294
|
-
const t =
|
|
1295
|
-
return
|
|
1319
|
+
const t = I(e), i = e.namespace || "usermaven";
|
|
1320
|
+
return h() && t.pageview(), He(i, t), t;
|
|
1296
1321
|
}
|
|
1297
|
-
function
|
|
1322
|
+
function He(n, e) {
|
|
1298
1323
|
let t = !1;
|
|
1299
1324
|
const i = [], s = [];
|
|
1300
1325
|
function r() {
|
|
1301
1326
|
for (; i.length > 0; ) {
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1327
|
+
const u = i.shift();
|
|
1328
|
+
if (u) {
|
|
1329
|
+
const g = u[u.length - 1];
|
|
1330
|
+
if (g && typeof g.resolve == "function") {
|
|
1331
|
+
const m = u.pop();
|
|
1332
|
+
try {
|
|
1333
|
+
const b = a.apply(null, u);
|
|
1334
|
+
b && typeof b.then == "function" ? b.then(m.resolve).catch(m.reject) : m.resolve(b);
|
|
1335
|
+
} catch (b) {
|
|
1336
|
+
m.reject(b);
|
|
1337
|
+
}
|
|
1338
|
+
} else
|
|
1339
|
+
try {
|
|
1340
|
+
a.apply(null, u);
|
|
1341
|
+
} catch (m) {
|
|
1342
|
+
console.error("Usermaven: Error processing queued command:", m);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1304
1345
|
}
|
|
1305
1346
|
}
|
|
1306
1347
|
function o() {
|
|
1307
|
-
s.forEach((
|
|
1348
|
+
s.forEach((u) => u()), s.length = 0;
|
|
1308
1349
|
}
|
|
1309
|
-
|
|
1310
|
-
const
|
|
1311
|
-
if (
|
|
1312
|
-
typeof
|
|
1350
|
+
function a(...u) {
|
|
1351
|
+
const g = u[0];
|
|
1352
|
+
if (g === "onLoad") {
|
|
1353
|
+
typeof u[1] == "function" && (t ? u[1]() : s.push(u[1]));
|
|
1313
1354
|
return;
|
|
1314
1355
|
}
|
|
1315
1356
|
if (!t) {
|
|
1316
|
-
i.push(
|
|
1357
|
+
i.push(u);
|
|
1317
1358
|
return;
|
|
1318
1359
|
}
|
|
1319
|
-
if (typeof e[
|
|
1320
|
-
return e[
|
|
1321
|
-
console.error(`Method ${
|
|
1322
|
-
}
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
|
|
1360
|
+
if (typeof e[g] == "function")
|
|
1361
|
+
return e[g].apply(e, u.slice(1));
|
|
1362
|
+
console.error(`Method ${g} not found on UsermavenClient`);
|
|
1363
|
+
}
|
|
1364
|
+
const l = ["id", "group", "reset"], c = ["track", "pageview", "set", "unset", "rawTrack", "setUserId"];
|
|
1365
|
+
[...l, ...c].forEach((u) => {
|
|
1366
|
+
a[u] = function(...g) {
|
|
1367
|
+
if (!t) {
|
|
1368
|
+
if (l.includes(u))
|
|
1369
|
+
return new Promise((B, m) => {
|
|
1370
|
+
i.push([u, ...g, { resolve: B, reject: m }]);
|
|
1371
|
+
});
|
|
1372
|
+
i.push([u, ...g]);
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
if (typeof e[u] == "function")
|
|
1376
|
+
return e[u].apply(e, g);
|
|
1377
|
+
};
|
|
1378
|
+
}), a.getConfig = function() {
|
|
1379
|
+
return t ? e.getConfig() : (console.warn("Usermaven client not ready yet"), null);
|
|
1380
|
+
}, window[n] = a;
|
|
1381
|
+
const p = `${n}Q`, _ = window[p] || [];
|
|
1382
|
+
for (window[p] = _, _.push = function(...u) {
|
|
1383
|
+
return a.apply(null, u), Array.prototype.push.apply(this, u);
|
|
1326
1384
|
}, setTimeout(() => {
|
|
1327
1385
|
t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
|
|
1328
|
-
}, 0);
|
|
1329
|
-
const
|
|
1330
|
-
|
|
1386
|
+
}, 0); _.length > 0; ) {
|
|
1387
|
+
const u = _.shift();
|
|
1388
|
+
u && i.push(u);
|
|
1331
1389
|
}
|
|
1332
1390
|
}
|
|
1333
|
-
let
|
|
1334
|
-
if (
|
|
1335
|
-
const n =
|
|
1391
|
+
let K = !1, O = null;
|
|
1392
|
+
if (h()) {
|
|
1393
|
+
const n = Te();
|
|
1336
1394
|
n && n("usermaven", [], function() {
|
|
1337
1395
|
return {
|
|
1338
|
-
usermavenClient:
|
|
1339
|
-
UsermavenClient:
|
|
1340
|
-
LogLevel:
|
|
1396
|
+
usermavenClient: I,
|
|
1397
|
+
UsermavenClient: N,
|
|
1398
|
+
LogLevel: k,
|
|
1341
1399
|
// Expose the script tag client if it exists
|
|
1342
|
-
getScriptTagClient: () =>
|
|
1400
|
+
getScriptTagClient: () => O
|
|
1343
1401
|
};
|
|
1344
|
-
}), typeof window < "u" && (window.usermavenClient =
|
|
1402
|
+
}), typeof window < "u" && (window.usermavenClient = I, window.UsermavenClient = N, window.usermavenScriptTagClient = () => O), function(e, t) {
|
|
1345
1403
|
const i = e.currentScript;
|
|
1346
1404
|
function s() {
|
|
1347
|
-
return
|
|
1405
|
+
return K || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
|
|
1348
1406
|
}
|
|
1349
1407
|
function r() {
|
|
1350
|
-
s() && (console.log("[Usermaven] Auto-initializing from script tag"),
|
|
1408
|
+
s() && (console.log("[Usermaven] Auto-initializing from script tag"), O = xe(i), K = !0);
|
|
1351
1409
|
}
|
|
1352
1410
|
typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
|
|
1353
1411
|
}(document, window);
|
|
1354
1412
|
}
|
|
1355
|
-
typeof module < "u" && module.exports && !
|
|
1356
|
-
usermavenClient:
|
|
1357
|
-
UsermavenClient:
|
|
1413
|
+
typeof module < "u" && module.exports && !te() && (module.exports = {
|
|
1414
|
+
usermavenClient: I,
|
|
1415
|
+
UsermavenClient: N,
|
|
1358
1416
|
Config: void 0,
|
|
1359
1417
|
UserProps: void 0,
|
|
1360
1418
|
EventPayload: void 0,
|
|
1361
|
-
LogLevel:
|
|
1419
|
+
LogLevel: k,
|
|
1362
1420
|
ClientProperties: void 0
|
|
1363
1421
|
});
|
|
1364
1422
|
|
|
1365
1423
|
function createClient(params) {
|
|
1366
|
-
return
|
|
1424
|
+
return I(params);
|
|
1367
1425
|
}
|
|
1368
1426
|
|
|
1369
1427
|
function useUsermaven() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9-rc.105",
|
|
4
4
|
"description": "Usermaven JavaScript SDK for React",
|
|
5
5
|
"author": "Usermaven <hello@usermaven.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@usermaven/sdk-js": "1.5.
|
|
21
|
+
"@usermaven/sdk-js": "1.5.9-rc.105"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "15.x || 16.x || 17.x || 18.x || 19.x",
|