@levo-so/insights 0.1.85 → 0.1.86
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/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, M as i, O as a, S as o, T as s, b as c, c as l, f as u, i as d, j as f, k as p, l as m, m as h, n as g, o as _, s as v, u as y, v as b,
|
|
2
|
-
import { AnalyticsEvents as
|
|
3
|
-
import { getVisitorSource as
|
|
4
|
-
import
|
|
5
|
-
import { Analytics as
|
|
1
|
+
import { A as e, C as t, D as n, E as r, M as i, O as a, S as o, T as s, b as c, c as l, f as u, i as d, j as f, k as p, l as m, m as h, n as g, o as _, s as v, u as y, v as b, x, y as S } from "./textSelection-DC99Tbqq.js";
|
|
2
|
+
import { AnalyticsEvents as C, getLevoError as w } from "@levo-so/core";
|
|
3
|
+
import { getVisitorSource as T } from "@analytics/visitor-source";
|
|
4
|
+
import E from "get-user-locale";
|
|
5
|
+
import { Analytics as D } from "analytics";
|
|
6
6
|
//#region src/utils/rageclick.ts
|
|
7
|
-
var
|
|
8
|
-
let r =
|
|
9
|
-
if (r && Math.abs(e - r.x) + Math.abs(t - r.y) <
|
|
10
|
-
if (
|
|
7
|
+
var O = 30, k = 1e3, A = 3, j = [], M = (e, t, n) => {
|
|
8
|
+
let r = j[j.length - 1];
|
|
9
|
+
if (r && Math.abs(e - r.x) + Math.abs(t - r.y) < O && n - r.timestamp < k) {
|
|
10
|
+
if (j.push({
|
|
11
11
|
x: e,
|
|
12
12
|
y: t,
|
|
13
13
|
timestamp: n
|
|
14
|
-
}),
|
|
15
|
-
} else
|
|
14
|
+
}), j.length >= A) return j = [], !0;
|
|
15
|
+
} else j = [{
|
|
16
16
|
x: e,
|
|
17
17
|
y: t,
|
|
18
18
|
timestamp: n
|
|
19
19
|
}];
|
|
20
20
|
return !1;
|
|
21
|
-
},
|
|
21
|
+
}, N = (e) => {
|
|
22
22
|
let t = e, n = 0;
|
|
23
23
|
for (; t && n < 10;) {
|
|
24
24
|
let e = t.getAttribute?.("href");
|
|
@@ -26,8 +26,8 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
26
26
|
t = t.parentElement, n++;
|
|
27
27
|
}
|
|
28
28
|
return null;
|
|
29
|
-
},
|
|
30
|
-
let t = e.closest("a[href]"), n = t?.getAttribute("href") ||
|
|
29
|
+
}, P = (e) => {
|
|
30
|
+
let t = e.closest("a[href]"), n = t?.getAttribute("href") || N(e);
|
|
31
31
|
if (!n) return {
|
|
32
32
|
type: null,
|
|
33
33
|
href: null
|
|
@@ -54,12 +54,12 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
54
54
|
href: n
|
|
55
55
|
};
|
|
56
56
|
} catch (e) {
|
|
57
|
-
return console.warn("[insights] Failed to classify link",
|
|
57
|
+
return console.warn("[insights] Failed to classify link", w(e)), {
|
|
58
58
|
type: "internal",
|
|
59
59
|
href: n
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
},
|
|
62
|
+
}, F = (e) => {
|
|
63
63
|
if (typeof window > "u") return () => {};
|
|
64
64
|
let t = 0, n = null, r = (e, t = !1, n) => {
|
|
65
65
|
let r = n ?? m(e), i = "clientX" in e ? e.clientX : e.changedTouches?.[0]?.clientX ?? 0, a = "clientY" in e ? e.clientY : e.changedTouches?.[0]?.clientY ?? 0, o = {
|
|
@@ -71,7 +71,7 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
71
71
|
event_type: t ? "dblclick" : "click",
|
|
72
72
|
button_type: "button" in e ? e.button : 0
|
|
73
73
|
};
|
|
74
|
-
return r instanceof HTMLElement && (o.rage_click =
|
|
74
|
+
return r instanceof HTMLElement && (o.rage_click = M(i, a, Date.now()), o = {
|
|
75
75
|
...o,
|
|
76
76
|
...l(r)
|
|
77
77
|
}), o;
|
|
@@ -86,25 +86,25 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
86
86
|
is_navigation: !0
|
|
87
87
|
});
|
|
88
88
|
} catch (e) {
|
|
89
|
-
console.error("[insights] Failed to track navigation click",
|
|
89
|
+
console.error("[insights] Failed to track navigation click", w(e));
|
|
90
90
|
}
|
|
91
91
|
}, a = (n, i = !1, a) => {
|
|
92
92
|
try {
|
|
93
93
|
let o = a ?? m(n);
|
|
94
94
|
if (!o || Date.now() - t < 300) return;
|
|
95
|
-
let s = r(n, i, o), c =
|
|
95
|
+
let s = r(n, i, o), c = P(o);
|
|
96
96
|
e.track("page.click", {
|
|
97
97
|
...s,
|
|
98
98
|
href: c.href || void 0,
|
|
99
99
|
link_type: c.type || void 0
|
|
100
100
|
});
|
|
101
101
|
} catch (e) {
|
|
102
|
-
console.error("[insights] Failed to track click",
|
|
102
|
+
console.error("[insights] Failed to track click", w(e));
|
|
103
103
|
}
|
|
104
104
|
}, o = (e) => {
|
|
105
105
|
let t = m(e);
|
|
106
106
|
if (!t) return;
|
|
107
|
-
let r =
|
|
107
|
+
let r = P(t);
|
|
108
108
|
if (r.type === "external" || r.type === "download") {
|
|
109
109
|
i(e, r, t);
|
|
110
110
|
return;
|
|
@@ -123,7 +123,7 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
123
123
|
let i = m(n);
|
|
124
124
|
if (!i) return;
|
|
125
125
|
t = Date.now();
|
|
126
|
-
let a =
|
|
126
|
+
let a = P(i);
|
|
127
127
|
if (a.type === "external" || a.type === "download") {
|
|
128
128
|
let t = r(n, !1, i);
|
|
129
129
|
e.track("page.click", {
|
|
@@ -143,26 +143,26 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
143
143
|
is_touch: !0
|
|
144
144
|
});
|
|
145
145
|
} catch (e) {
|
|
146
|
-
console.error("[insights] Failed to track touch",
|
|
146
|
+
console.error("[insights] Failed to track touch", w(e));
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
return document.addEventListener("click", o), document.addEventListener("dblclick", s), document.addEventListener("touchend", c, { passive: !0 }), () => {
|
|
150
150
|
document.removeEventListener("click", o), document.removeEventListener("dblclick", s), document.removeEventListener("touchend", c), n && clearTimeout(n);
|
|
151
151
|
};
|
|
152
|
-
},
|
|
152
|
+
}, I = (e) => {
|
|
153
153
|
if (typeof window > "u") return () => {};
|
|
154
154
|
let t = (t) => (n) => {
|
|
155
155
|
try {
|
|
156
156
|
let r = y(n, t);
|
|
157
157
|
r && e.track("page.copy", r);
|
|
158
158
|
} catch (e) {
|
|
159
|
-
console.error(`[insights] Failed to track clipboard ${t}`,
|
|
159
|
+
console.error(`[insights] Failed to track clipboard ${t}`, w(e));
|
|
160
160
|
}
|
|
161
161
|
}, n = t("copy"), r = t("cut");
|
|
162
162
|
return document.addEventListener("copy", n, { capture: !0 }), document.addEventListener("cut", r, { capture: !0 }), () => {
|
|
163
163
|
document.removeEventListener("copy", n, { capture: !0 }), document.removeEventListener("cut", r, { capture: !0 });
|
|
164
164
|
};
|
|
165
|
-
},
|
|
165
|
+
}, L = (e) => {
|
|
166
166
|
if (typeof window > "u") return () => {};
|
|
167
167
|
let t = (t) => (n) => {
|
|
168
168
|
try {
|
|
@@ -172,20 +172,19 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
172
172
|
e.track(n, r);
|
|
173
173
|
}
|
|
174
174
|
} catch (e) {
|
|
175
|
-
console.error(`[insights] Failed to track form ${t}`,
|
|
175
|
+
console.error(`[insights] Failed to track form ${t}`, w(e));
|
|
176
176
|
}
|
|
177
177
|
}, n = t("change"), r = t("submit");
|
|
178
178
|
return document.addEventListener("change", n, { capture: !0 }), document.addEventListener("submit", r, { capture: !0 }), () => {
|
|
179
179
|
document.removeEventListener("change", n, { capture: !0 }), document.removeEventListener("submit", r, { capture: !0 });
|
|
180
180
|
};
|
|
181
|
-
},
|
|
181
|
+
}, R = (e) => {
|
|
182
182
|
if (typeof window > "u") return () => {};
|
|
183
183
|
let { page_id: t } = p.get(), n = t || "", r = typeof window < "u" ? window.location.href : "", i = () => {
|
|
184
|
-
|
|
185
|
-
if (t) try {
|
|
184
|
+
try {
|
|
186
185
|
e.page({ resource: "page" });
|
|
187
186
|
} catch (e) {
|
|
188
|
-
console.error("[insights] Failed to send page view",
|
|
187
|
+
console.error("[insights] Failed to send page view", w(e));
|
|
189
188
|
}
|
|
190
189
|
};
|
|
191
190
|
if (t) {
|
|
@@ -210,7 +209,7 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
210
209
|
window.removeEventListener("popstate", e), window.history.pushState = t;
|
|
211
210
|
};
|
|
212
211
|
}
|
|
213
|
-
},
|
|
212
|
+
}, z = async (e, t) => {
|
|
214
213
|
let n = null;
|
|
215
214
|
try {
|
|
216
215
|
let r = new AbortController();
|
|
@@ -224,7 +223,7 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
224
223
|
} finally {
|
|
225
224
|
n && clearTimeout(n);
|
|
226
225
|
}
|
|
227
|
-
},
|
|
226
|
+
}, B = async (e) => {
|
|
228
227
|
let { mode: t = "auto", insightsUrl: n, directInsightsUrl: r, pingTimeout: i = 1e3, debug: a = !1 } = e;
|
|
229
228
|
if (a) return {
|
|
230
229
|
mode: "proxy",
|
|
@@ -239,7 +238,7 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
239
238
|
mode: "proxy",
|
|
240
239
|
url: n ?? null
|
|
241
240
|
};
|
|
242
|
-
let [s, c] = await Promise.all([n ?
|
|
241
|
+
let [s, c] = await Promise.all([n ? z(`${n}/ping`, o) : Promise.resolve(!1), r ? z(`${r}/ping`, o) : Promise.resolve(!1)]);
|
|
243
242
|
return s ? {
|
|
244
243
|
mode: "proxy",
|
|
245
244
|
url: n ?? null
|
|
@@ -250,9 +249,9 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
250
249
|
mode: "proxy",
|
|
251
250
|
url: n ?? null
|
|
252
251
|
};
|
|
253
|
-
},
|
|
252
|
+
}, V = () => {
|
|
254
253
|
if (typeof document > "u") return {};
|
|
255
|
-
let { type: e, referrer: t, data: n = {} } =
|
|
254
|
+
let { type: e, referrer: t, data: n = {} } = T({
|
|
256
255
|
referrer: document.referrer,
|
|
257
256
|
currentUrl: window.location.href,
|
|
258
257
|
mapper: null
|
|
@@ -264,7 +263,7 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
264
263
|
data: n,
|
|
265
264
|
raw: document.referrer
|
|
266
265
|
};
|
|
267
|
-
},
|
|
266
|
+
}, H = () => new Promise((e, t) => {
|
|
268
267
|
let n = "Unknown";
|
|
269
268
|
function r(t) {
|
|
270
269
|
e({
|
|
@@ -361,12 +360,12 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
361
360
|
o() ? (n = "Safari", f()) : s() ? (n = i(), g()) : c() ? (n = "Firefox", _()) : l() ? (n = "Internet Explorer", v()) : t(/* @__PURE__ */ Error("detectIncognito cannot determine the browser"));
|
|
362
361
|
}
|
|
363
362
|
y();
|
|
364
|
-
}),
|
|
363
|
+
}), U = () => {
|
|
365
364
|
let e = document.createElement("canvas"), t = e?.getContext("webgl") || e?.getContext("experimental-webgl");
|
|
366
365
|
if (!t) return null;
|
|
367
366
|
let n = t?.getExtension("WEBGL_debug_renderer_info");
|
|
368
367
|
return n ? t?.getParameter(n.UNMASKED_RENDERER_WEBGL) : null;
|
|
369
|
-
},
|
|
368
|
+
}, W = async () => {
|
|
370
369
|
let e = "", t = "", n = !1, r = !1, i = {};
|
|
371
370
|
if (!window) return {
|
|
372
371
|
locale: e,
|
|
@@ -376,26 +375,20 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
376
375
|
properties: i
|
|
377
376
|
};
|
|
378
377
|
let [a, o, s] = await Promise.allSettled([
|
|
379
|
-
|
|
378
|
+
H(),
|
|
380
379
|
navigator.getBattery?.() ?? Promise.reject(),
|
|
381
380
|
"mediaDevices" in navigator ? navigator.mediaDevices.enumerateDevices() : Promise.reject()
|
|
382
381
|
]);
|
|
383
382
|
a.status === "fulfilled" && (r = a.value.isPrivate);
|
|
384
383
|
try {
|
|
385
384
|
n = window.matchMedia?.("(prefers-color-scheme: dark)").matches;
|
|
386
|
-
} catch
|
|
387
|
-
console.error(e);
|
|
388
|
-
}
|
|
385
|
+
} catch {}
|
|
389
386
|
try {
|
|
390
387
|
t = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
391
|
-
} catch
|
|
392
|
-
console.error(e);
|
|
393
|
-
}
|
|
388
|
+
} catch {}
|
|
394
389
|
try {
|
|
395
|
-
e =
|
|
396
|
-
} catch
|
|
397
|
-
console.error(e);
|
|
398
|
-
}
|
|
390
|
+
e = E();
|
|
391
|
+
} catch {}
|
|
399
392
|
let c = navigator, l = c.connection ?? c.mozConnection ?? c.webkitConnection;
|
|
400
393
|
if (l && (i.network_type = l.effectiveType), i.width = window?.innerWidth, i.height = window?.innerHeight, i.pixel_ratio = window?.devicePixelRatio, screen && (i.screen_width = screen?.width, i.screen_height = screen?.height, i.color_depth = screen?.colorDepth, i.orientation = screen?.orientation?.type), o.status === "fulfilled") {
|
|
401
394
|
let e = o.value;
|
|
@@ -405,14 +398,14 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
405
398
|
let e = s.value;
|
|
406
399
|
i.camera_supported = e.some((e) => e?.kind === "videoinput"), i.microphone_supported = e.some((e) => e?.kind === "audioinput");
|
|
407
400
|
}
|
|
408
|
-
return i.gpu =
|
|
401
|
+
return i.gpu = U(), {
|
|
409
402
|
locale: e,
|
|
410
403
|
timezone: t,
|
|
411
404
|
dark_mode: n,
|
|
412
405
|
private_mode: r,
|
|
413
406
|
properties: i
|
|
414
407
|
};
|
|
415
|
-
},
|
|
408
|
+
}, G = (t, r, i) => {
|
|
416
409
|
let { debug: l } = e();
|
|
417
410
|
if (!t) return null;
|
|
418
411
|
let u = {
|
|
@@ -467,10 +460,10 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
467
460
|
isIdentifying: !1,
|
|
468
461
|
sessionId: "debug-session",
|
|
469
462
|
deviceId: "debug-device"
|
|
470
|
-
}),
|
|
463
|
+
}), S(c());
|
|
471
464
|
return;
|
|
472
465
|
}
|
|
473
|
-
let
|
|
466
|
+
let C = {
|
|
474
467
|
Accept: "application/json",
|
|
475
468
|
"Content-Type": "application/json",
|
|
476
469
|
...a({
|
|
@@ -478,11 +471,11 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
478
471
|
deviceToken: h,
|
|
479
472
|
mode: d
|
|
480
473
|
})
|
|
481
|
-
},
|
|
474
|
+
}, T = (e = 0) => {
|
|
482
475
|
t.fetch.url(g, !0).url("/v1/insights/event/welcome").options({
|
|
483
476
|
keepalive: !0,
|
|
484
477
|
credentials: d === "proxy" ? "include" : "omit"
|
|
485
|
-
}).headers(
|
|
478
|
+
}).headers(C).post(x).json().then((e) => {
|
|
486
479
|
if (!i()) {
|
|
487
480
|
n({ isIdentifying: !1 });
|
|
488
481
|
return;
|
|
@@ -498,32 +491,32 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
498
491
|
let n = e.content.meta;
|
|
499
492
|
n.device_token && (t.deviceToken = n.device_token), n.session_token && (t.sessionToken = n.session_token);
|
|
500
493
|
}
|
|
501
|
-
n(t),
|
|
494
|
+
n(t), S(c());
|
|
502
495
|
}
|
|
503
496
|
}).catch((r) => {
|
|
504
|
-
if (t.logger?.error("/welcome failed with error",
|
|
497
|
+
if (t.logger?.error("/welcome failed with error", w(r)), e < 2 && i()) {
|
|
505
498
|
let t = 5e3 * 2 ** e;
|
|
506
499
|
setTimeout(() => {
|
|
507
|
-
i() && !s().isIdentified ?
|
|
500
|
+
i() && !s().isIdentified ? T(e + 1) : n({ isIdentifying: !1 });
|
|
508
501
|
}, t);
|
|
509
502
|
} else n({ isIdentifying: !1 });
|
|
510
503
|
});
|
|
511
504
|
};
|
|
512
|
-
|
|
505
|
+
T();
|
|
513
506
|
}
|
|
514
507
|
};
|
|
515
|
-
return
|
|
508
|
+
return D({
|
|
516
509
|
app: t.workspace || "",
|
|
517
510
|
debug: !!l,
|
|
518
511
|
plugins: [u]
|
|
519
512
|
});
|
|
520
|
-
},
|
|
513
|
+
}, K = null, q = !1, J = [], Y = (a, o) => {
|
|
521
514
|
let { insightsUrl: l, debug: p = !1, site: m = null } = o;
|
|
522
515
|
f({
|
|
523
516
|
workspace: a.workspace,
|
|
524
517
|
debug: p,
|
|
525
518
|
site_id: m
|
|
526
|
-
}), typeof window < "u" && Promise.all([
|
|
519
|
+
}), typeof window < "u" && Promise.all([W(), V()]).then(([e, t]) => {
|
|
527
520
|
let r = t?.type ? {
|
|
528
521
|
type: t.type,
|
|
529
522
|
referrer: t.referrer,
|
|
@@ -551,7 +544,7 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
551
544
|
let y = async (t, n) => {
|
|
552
545
|
if (typeof window > "u") return;
|
|
553
546
|
let { page_id: r } = e(), { allTabs: i } = s(), a = _(), o = i.length;
|
|
554
|
-
|
|
547
|
+
x({
|
|
555
548
|
event: t,
|
|
556
549
|
version: n?.version || 1,
|
|
557
550
|
properties: {
|
|
@@ -575,8 +568,8 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
575
568
|
tab_id: a ?? "",
|
|
576
569
|
tab_count: o
|
|
577
570
|
});
|
|
578
|
-
},
|
|
579
|
-
!
|
|
571
|
+
}, C = (e) => {
|
|
572
|
+
!K || !q || K.identify("", { withLock: e?.withLock ?? !0 });
|
|
580
573
|
}, w = (t) => {
|
|
581
574
|
let { page_id: n } = e();
|
|
582
575
|
n !== t && i("page_id", t);
|
|
@@ -585,46 +578,46 @@ var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
|
585
578
|
init: (e = {}) => {
|
|
586
579
|
if (typeof window > "u") throw Error("[@levo-so/insights] init() should only be called on the client side.");
|
|
587
580
|
let { pageId: i } = e;
|
|
588
|
-
if (i && w(i),
|
|
581
|
+
if (i && w(i), q || a.NODE_ENV === "development" && !p) return;
|
|
589
582
|
if (!l) {
|
|
590
583
|
console.error("[@levo-so/insights] The utility could not be initialized due to missing insights endpoint.");
|
|
591
584
|
return;
|
|
592
585
|
}
|
|
593
|
-
|
|
586
|
+
q = !0;
|
|
594
587
|
let c = s();
|
|
595
588
|
c.mode === "direct" && c.isIdentified && (!c.sessionToken || !c.deviceToken) && n({ isIdentified: !1 }), r(() => {
|
|
596
|
-
if (!
|
|
589
|
+
if (!q) return;
|
|
597
590
|
let { insightsBaseUrl: e } = s();
|
|
598
|
-
e ||
|
|
599
|
-
|
|
591
|
+
e || B(o).then(({ mode: e, url: t }) => {
|
|
592
|
+
q && t && n({
|
|
600
593
|
mode: e,
|
|
601
594
|
insightsBaseUrl: t
|
|
602
595
|
});
|
|
603
596
|
}).catch(() => {
|
|
604
|
-
|
|
597
|
+
q && l && n({
|
|
605
598
|
mode: "proxy",
|
|
606
599
|
insightsBaseUrl: l
|
|
607
600
|
});
|
|
608
601
|
});
|
|
609
602
|
let r = t.subscribe((e) => {
|
|
610
|
-
if (!(!e || !
|
|
611
|
-
let e =
|
|
612
|
-
|
|
603
|
+
if (!(!e || !q) && !K) {
|
|
604
|
+
let e = G(a, y, () => K === e);
|
|
605
|
+
K = e, s().insightsBaseUrl && K && (J.push(h(K), u(K), F(K), I(K), v(K), L(K), R(K), d(K), g(K)), C(), K.page({ resource: "page" }));
|
|
613
606
|
}
|
|
614
607
|
});
|
|
615
|
-
|
|
608
|
+
J.push(r);
|
|
616
609
|
});
|
|
617
610
|
},
|
|
618
611
|
destroy: () => {
|
|
619
|
-
|
|
612
|
+
q &&= (S(c()), b(), J.forEach((e) => {
|
|
620
613
|
e();
|
|
621
|
-
}),
|
|
614
|
+
}), J.length = 0, K = null, !1);
|
|
622
615
|
},
|
|
623
616
|
track: y,
|
|
624
617
|
get instance() {
|
|
625
|
-
return
|
|
618
|
+
return K;
|
|
626
619
|
}
|
|
627
620
|
};
|
|
628
621
|
};
|
|
629
622
|
//#endregion
|
|
630
|
-
export {
|
|
623
|
+
export { C as AnalyticsEvents, Y as createLevoInsights };
|
package/dist/stores.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as e, _ as t, a as n, d as r, g as i, h as a, k as o, p as s, r as c, t as l, w as u } from "./textSelection-
|
|
1
|
+
import { C as e, _ as t, a as n, d as r, g as i, h as a, k as o, p as s, r as c, t as l, w as u } from "./textSelection-DC99Tbqq.js";
|
|
2
2
|
export { s as $activity, o as $config, n as $currentTab, a as $eventQueue, e as $isContextReady, i as $lifetimePageCount, r as $pageLifecycle, c as $scrollBehavior, l as $selectedText, u as $session, t as $totalEventCount };
|
|
@@ -153,7 +153,9 @@ var x = () => g.get(), S = (e) => {
|
|
|
153
153
|
headers: g,
|
|
154
154
|
keepalive: !0,
|
|
155
155
|
credentials: o === "proxy" ? "include" : "omit"
|
|
156
|
-
}).catch(() => {
|
|
156
|
+
}).catch((e) => {
|
|
157
|
+
console.warn("[@levo-so/insights] Event flush failed, batch lost:", e);
|
|
158
|
+
});
|
|
157
159
|
}, A = () => {
|
|
158
160
|
if (D.get()) return;
|
|
159
161
|
let e = setTimeout(() => {
|
|
@@ -275,11 +277,13 @@ var se = () => {
|
|
|
275
277
|
}) : e === P.HIDDEN && k(O());
|
|
276
278
|
}), l = o.get().page_id, u = o.listen((e) => {
|
|
277
279
|
e.page_id !== l && (t = !1, l = e.page_id);
|
|
280
|
+
}), d = T.listen((e) => {
|
|
281
|
+
e === 0 && (t = !1);
|
|
278
282
|
});
|
|
279
283
|
return () => {
|
|
280
284
|
s.forEach((e) => {
|
|
281
285
|
window.removeEventListener(e, a, { capture: !0 });
|
|
282
|
-
}), window.removeEventListener("beforeunload", r), c(), u(), t = !1, F.set(P.ACTIVE);
|
|
286
|
+
}), window.removeEventListener("beforeunload", r), c(), u(), d(), t = !1, F.set(P.ACTIVE);
|
|
283
287
|
};
|
|
284
288
|
}, I = (e) => Object.prototype.toString.call(e) == "[object String]", fe = (e, t) => e.indexOf(t) !== -1, L = (e) => e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), R = (e) => e === void 0, pe = (e) => e === null, z = (e) => R(e) || pe(e), B = (e) => !!e && e?.nodeType === 3;
|
|
285
289
|
function me(e) {
|
|
@@ -483,8 +487,17 @@ var Ee = (e) => {
|
|
|
483
487
|
return null;
|
|
484
488
|
}, Z = e(null), ke = (e) => {
|
|
485
489
|
if (typeof window > "u") return () => {};
|
|
486
|
-
let t =
|
|
487
|
-
|
|
490
|
+
let t = null;
|
|
491
|
+
try {
|
|
492
|
+
t = sessionStorage.getItem(d.current_tab);
|
|
493
|
+
} catch {}
|
|
494
|
+
let { allTabs: n } = g.get();
|
|
495
|
+
if (t && n.includes(t) && (t = null), !t) {
|
|
496
|
+
t = `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
497
|
+
try {
|
|
498
|
+
sessionStorage.setItem(d.current_tab, t);
|
|
499
|
+
} catch {}
|
|
500
|
+
}
|
|
488
501
|
let r = t;
|
|
489
502
|
Z.set(r), n.includes(r) || S({ allTabs: [...n, r] });
|
|
490
503
|
let i = () => {
|