@levo-so/insights 0.1.76 → 0.1.79

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.
@@ -0,0 +1,21 @@
1
+ const s = {
2
+ /** Legacy: Lock key for identify operation (no longer used internally) */
3
+ identify: "lock:lv_aud_identify",
4
+ /** Key for tracking open tab count */
5
+ open_tabs: "lv_insights_ot",
6
+ /** Key for current tab ID (sessionStorage) */
7
+ current_tab: "lv_insights_ct",
8
+ /** Key for all tabs registry */
9
+ all_tabs: "lv_insights_at",
10
+ /** Device JWT for direct mode (1yr expiry, rotated on /welcome, analytics-only scope) */
11
+ device_token: "lv_aud_device",
12
+ /** Session JWT for direct mode (1yr expiry, rotated on /welcome, analytics-only scope) */
13
+ session_token: "lv_aud_session",
14
+ /** Cached insights mode ('proxy' | 'direct') */
15
+ mode: "lv_aud_mode",
16
+ /** Key to store session data **/
17
+ session: "lv_insights_session"
18
+ };
19
+ export {
20
+ s as STORAGE_KEYS
21
+ };
package/dist/index.js CHANGED
@@ -1,664 +1,6 @@
1
- import { p as E, k as H, l as R, $ as U, e as q, m as P, n as C, o as z, u as T, q as G, r as $, s as K, t as W, v as j, w as Q, x as N, y as X, z as Y, d as Z, A as J, B as V, C as ee, D as te, E as ne, F as re } from "./DA6yh6E3HQLu.js";
2
- import { G as xe } from "./DA6yh6E3HQLu.js";
3
- import { getVisitorSource as ie } from "@analytics/visitor-source";
4
- import oe from "get-user-locale";
5
- import { Analytics as ae } from "analytics";
6
- const se = 30, ce = 1e3, le = 3;
7
- let S = [];
8
- const de = (a, i, e) => {
9
- const t = S[S.length - 1];
10
- if (t && Math.abs(a - t.x) + Math.abs(i - t.y) < se && e - t.timestamp < ce) {
11
- if (S.push({ x: a, y: i, timestamp: e }), S.length >= le)
12
- return !0;
13
- } else
14
- S = [{ x: a, y: i, timestamp: e }];
15
- return !1;
16
- }, ue = (a) => {
17
- let i = a, e = 0;
18
- for (; i && e < 10; ) {
19
- const t = i.getAttribute?.("href");
20
- if (t)
21
- return t;
22
- i = i.parentElement, e++;
23
- }
24
- return null;
25
- }, A = (a) => {
26
- const i = a.closest("a[href]"), e = i?.getAttribute("href") || ue(a);
27
- if (!e) return { type: null, href: null };
28
- if (i?.hasAttribute("download"))
29
- return { type: "download", href: e };
30
- if (e.startsWith("tel:")) return { type: "tel", href: e };
31
- if (e.startsWith("mailto:")) return { type: "mailto", href: e };
32
- if (e.startsWith("#")) return { type: "anchor", href: e };
33
- try {
34
- return {
35
- type: new URL(e, window.location.origin).origin === window.location.origin ? "internal" : "external",
36
- href: e
37
- };
38
- } catch (t) {
39
- return console.warn("[insights] Failed to classify link", E(t)), { type: "internal", href: e };
40
- }
41
- }, fe = (a) => {
42
- if (typeof window > "u") return () => {
43
- };
44
- let i = 0, e = null;
45
- const t = (s, o = !1) => {
46
- const l = s.target, h = "clientX" in s ? s.clientX : s.changedTouches?.[0]?.clientX ?? 0, y = "clientY" in s ? s.clientY : s.changedTouches?.[0]?.clientY ?? 0;
47
- let w = {
48
- hostname: window.location.hostname,
49
- pathname: window.location.pathname,
50
- page_title: document.title,
51
- url: window.location.href,
52
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
53
- event_type: o ? "dblclick" : "click",
54
- button_type: "button" in s ? s.button : 0
55
- };
56
- return l instanceof HTMLElement && (w.rage_click = de(h, y, Date.now()), w = {
57
- ...w,
58
- ...H(l)
59
- }), w;
60
- }, n = (s, o) => {
61
- try {
62
- if (Date.now() - i < 300) return;
63
- const l = t(s);
64
- a.track("page.click", {
65
- ...l,
66
- href: o.href || void 0,
67
- link_type: o.type,
68
- is_navigation: !0
69
- });
70
- } catch (l) {
71
- console.error("[insights] Failed to track navigation click", E(l));
72
- }
73
- }, c = (s, o = !1) => {
74
- try {
75
- if (!(s.target instanceof HTMLElement) || Date.now() - i < 300) return;
76
- const l = t(s, o), h = A(s.target);
77
- a.track("page.click", {
78
- ...l,
79
- href: h.href || void 0,
80
- link_type: h.type || void 0
81
- });
82
- } catch (l) {
83
- console.error("[insights] Failed to track click", E(l));
84
- }
85
- }, r = (s) => {
86
- if (!(s.target instanceof HTMLElement)) return;
87
- const o = A(s.target);
88
- if (o.type === "external" || o.type === "download") {
89
- n(s, o);
90
- return;
91
- }
92
- if (e) {
93
- clearTimeout(e), e = null;
94
- return;
95
- }
96
- e = setTimeout(() => {
97
- c(s, !1), e = null;
98
- }, 250);
99
- }, f = (s) => {
100
- e && (clearTimeout(e), e = null), c(s, !0);
101
- }, u = (s) => {
102
- try {
103
- if (!(s.target instanceof HTMLElement)) return;
104
- i = Date.now();
105
- const o = A(s.target);
106
- if (o.type === "external" || o.type === "download") {
107
- const h = t(s);
108
- a.track("page.click", {
109
- ...h,
110
- href: o.href || void 0,
111
- link_type: o.type,
112
- is_navigation: !0,
113
- is_touch: !0
114
- });
115
- return;
116
- }
117
- const l = t(s);
118
- a.track("page.click", {
119
- ...l,
120
- href: o.href || void 0,
121
- link_type: o.type || void 0,
122
- is_touch: !0
123
- });
124
- } catch (o) {
125
- console.error("[insights] Failed to track touch", E(o));
126
- }
127
- };
128
- return document.addEventListener("click", r), document.addEventListener("dblclick", f), document.addEventListener("touchend", u, { passive: !0 }), () => {
129
- document.removeEventListener("click", r), document.removeEventListener("dblclick", f), document.removeEventListener("touchend", u), e && clearTimeout(e);
130
- };
131
- }, pe = (a) => {
132
- if (typeof window > "u") return () => {
133
- };
134
- const i = (n) => (c) => {
135
- try {
136
- const r = R(c, n);
137
- r && a.track("page.copy", r);
138
- } catch (r) {
139
- console.error(`[insights] Failed to track clipboard ${n}`, E(r));
140
- }
141
- }, e = i("copy"), t = i("cut");
142
- return document.addEventListener("copy", e, { capture: !0 }), document.addEventListener("cut", t, { capture: !0 }), () => {
143
- document.removeEventListener("copy", e, { capture: !0 }), document.removeEventListener("cut", t, { capture: !0 });
144
- };
145
- }, ge = (a) => {
146
- if (typeof window > "u") return () => {
147
- };
148
- const i = (n) => (c) => {
149
- try {
150
- const r = R(c, n);
151
- if (r) {
152
- const f = n === "submit" ? "form.submit" : "form.change";
153
- a.track(f, r);
154
- }
155
- } catch (r) {
156
- console.error(`[insights] Failed to track form ${n}`, E(r));
157
- }
158
- }, e = i("change"), t = i("submit");
159
- return document.addEventListener("change", e, { capture: !0 }), document.addEventListener("submit", t, { capture: !0 }), () => {
160
- document.removeEventListener("change", e, { capture: !0 }), document.removeEventListener("submit", t, { capture: !0 });
161
- };
162
- }, me = (a) => {
163
- if (typeof window > "u") return () => {
164
- };
165
- const { page_id: i } = U.get();
166
- let e = i || "", t = typeof window < "u" ? window.location.href : "";
167
- const n = () => {
168
- const { isIdentified: c } = q.get();
169
- if (c)
170
- try {
171
- a.page({
172
- resource: "page"
173
- });
174
- } catch (r) {
175
- console.error("[insights] Failed to send page view", E(r));
176
- }
177
- };
178
- if (i) {
179
- const c = U.listen((r, f, u) => {
180
- const { page_id: s } = r;
181
- u === "page_id" && s && e !== s && (e = s, n());
182
- });
183
- return () => {
184
- c();
185
- };
186
- } else {
187
- const c = () => {
188
- if (typeof window > "u") return;
189
- const u = window.location.href;
190
- u !== t && (t = u, n());
191
- };
192
- window.addEventListener("popstate", c);
193
- const r = window.history.pushState, f = window.history.replaceState;
194
- return window.history.pushState = function(...u) {
195
- r.apply(this, u), c();
196
- }, window.history.replaceState = function(...u) {
197
- f.apply(this, u), c();
198
- }, () => {
199
- window.removeEventListener("popstate", c), window.history.pushState = r, window.history.replaceState = f;
200
- };
201
- }
202
- }, F = async (a, i) => {
203
- let e = null;
204
- try {
205
- const t = new AbortController();
206
- return e = setTimeout(() => t.abort(), i), (await fetch(a, {
207
- method: "GET",
208
- signal: t.signal,
209
- credentials: "omit"
210
- })).ok;
211
- } catch {
212
- return !1;
213
- } finally {
214
- e && clearTimeout(e);
215
- }
216
- }, he = async (a) => {
217
- const {
218
- mode: i = "auto",
219
- insightsUrl: e,
220
- directInsightsUrl: t,
221
- pingTimeout: n = 3e3,
222
- debug: c = !1
223
- } = a;
224
- if (c)
225
- return { mode: "proxy", url: e || "/debug-api" };
226
- const r = Number.isFinite(n) && n >= 0 ? n : 3e3;
227
- return i === "direct" ? { mode: "direct", url: t ?? null } : i === "proxy" || !t ? { mode: "proxy", url: e ?? null } : (e ? await F(`${e}/ping`, r) : !1) ? { mode: "proxy", url: e ?? null } : await F(`${t}/ping`, r) ? { mode: "direct", url: t } : { mode: "proxy", url: e ?? null };
228
- }, we = () => {
229
- if (typeof document > "u")
230
- return {};
231
- const {
232
- type: a,
233
- referrer: i,
234
- data: e = {}
235
- } = ie({
236
- referrer: document.referrer,
237
- currentUrl: window.location.href,
238
- mapper: null
239
- }), t = Object.keys(e);
240
- for (const n of t)
241
- e[n] && Array.isArray(e[n]) && e[n].length > 0 && (e[n] = e[n]?.[0]);
242
- return { type: a, referrer: i, data: e, raw: document.referrer };
243
- }, ve = () => new Promise((a, i) => {
244
- let e = "Unknown";
245
- function t(d) {
246
- a({
247
- isPrivate: d,
248
- browserName: e
249
- });
250
- }
251
- function n() {
252
- const d = navigator.userAgent;
253
- return d.match(/Chrome/) ? navigator.brave !== void 0 ? "Brave" : d.match(/Edg/) ? "Edge" : d.match(/OPR/) ? "Opera" : "Chrome" : "Chromium";
254
- }
255
- function c(d) {
256
- return d === eval.toString().length;
257
- }
258
- function r() {
259
- const d = navigator.vendor;
260
- return d !== void 0 && d.indexOf("Apple") === 0 && c(37);
261
- }
262
- function f() {
263
- const d = navigator.vendor;
264
- return d !== void 0 && d.indexOf("Google") === 0 && c(33);
265
- }
266
- function u() {
267
- return document.documentElement !== void 0 && document.documentElement.style.MozAppearance !== void 0 && c(37);
268
- }
269
- function s() {
270
- return navigator.msSaveBlob !== void 0 && c(39);
271
- }
272
- function o() {
273
- const d = String(Math.random());
274
- try {
275
- const g = window.indexedDB.open(d, 1);
276
- g.onupgradeneeded = (b) => {
277
- const v = b.target?.result;
278
- try {
279
- v.createObjectStore("test", {
280
- autoIncrement: !0
281
- }).put(new Blob()), t(!1);
282
- } catch (k) {
283
- let M = k;
284
- if (k instanceof Error && (M = k.message ?? k), typeof M != "string")
285
- return t(!1);
286
- const O = /BlobURLs are not yet supported/.test(M);
287
- return t(O);
288
- } finally {
289
- v.close(), window.indexedDB.deleteDatabase(d);
290
- }
291
- };
292
- } catch {
293
- return t(!1);
294
- }
295
- }
296
- function l() {
297
- const d = window.openDatabase, g = window.localStorage;
298
- try {
299
- d(null, null, null, null);
300
- } catch {
301
- return t(!0);
302
- }
303
- try {
304
- g.setItem("test", "1"), g.removeItem("test");
305
- } catch {
306
- return t(!0);
307
- }
308
- return t(!1);
309
- }
310
- function h() {
311
- navigator.maxTouchPoints !== void 0 ? o() : l();
312
- }
313
- function y() {
314
- const d = window;
315
- return d.performance !== void 0 && d.performance.memory !== void 0 && d.performance.memory.jsHeapSizeLimit !== void 0 ? performance.memory.jsHeapSizeLimit : 1073741824;
316
- }
317
- function w() {
318
- navigator.webkitTemporaryStorage.queryUsageAndQuota(
319
- (d, g) => {
320
- const b = Math.round(g / 1048576), v = Math.round(y() / (1024 * 1024)) * 2;
321
- t(b < v);
322
- },
323
- (d) => {
324
- i(new Error(`detectIncognito somehow failed to query storage quota: ${d.message}`));
325
- }
326
- );
327
- }
328
- function p() {
329
- const d = window.webkitRequestFileSystem;
330
- d(0, 1, () => {
331
- t(!1);
332
- }, () => {
333
- t(!0);
334
- });
335
- }
336
- function I() {
337
- self.Promise !== void 0 && self.Promise.allSettled !== void 0 ? w() : p();
338
- }
339
- function D() {
340
- t(navigator.serviceWorker === void 0);
341
- }
342
- function B() {
343
- t(window.indexedDB === void 0);
344
- }
345
- function L() {
346
- r() ? (e = "Safari", h()) : f() ? (e = n(), I()) : u() ? (e = "Firefox", D()) : s() ? (e = "Internet Explorer", B()) : i(new Error("detectIncognito cannot determine the browser"));
347
- }
348
- L();
349
- }), ye = () => {
350
- const a = document.createElement("canvas"), i = a?.getContext("webgl") || a?.getContext("experimental-webgl");
351
- if (!i)
352
- return null;
353
- const e = i?.getExtension("WEBGL_debug_renderer_info");
354
- return e ? i?.getParameter(e.UNMASKED_RENDERER_WEBGL) : null;
355
- }, ke = async () => {
356
- let a = "", i = "", e = !1, t = !1;
357
- const n = {};
358
- if (!window)
359
- return {
360
- locale: a,
361
- timezone: i,
362
- dark_mode: e,
363
- private_mode: t,
364
- properties: n
365
- };
366
- try {
367
- ({ isPrivate: t } = await ve());
368
- } catch (r) {
369
- console.error(r);
370
- }
371
- try {
372
- e = window.matchMedia?.("(prefers-color-scheme: dark)").matches;
373
- } catch (r) {
374
- console.error(r);
375
- }
376
- try {
377
- i = Intl.DateTimeFormat().resolvedOptions().timeZone;
378
- } catch (r) {
379
- console.error(r);
380
- }
381
- try {
382
- a = oe();
383
- } catch (r) {
384
- console.error(r);
385
- }
386
- if (navigator && "connection" in navigator) {
387
- const r = navigator.connection || navigator?.mozConnection || navigator.webkitConnection;
388
- n.network_type = r.effectiveType;
389
- }
390
- if (n.width = window?.innerWidth, n.height = window?.innerHeight, n.pixel_ratio = window?.devicePixelRatio, screen && (n.screen_width = screen?.width, n.screen_height = screen?.height, n.color_depth = screen?.colorDepth, n.orientation = screen?.orientation?.type), navigator && "getBattery" in navigator) {
391
- const r = await navigator?.getBattery();
392
- r && (n.battery_level = Number((r?.level * 100).toFixed(0)), n.battery_charging = r?.charging, n.battery_discharging_time = r?.dischargingTime, n.battery_full_charge_capacity = r?.fullChargeCapacity, n.battery_charging_time = r?.chargingTime);
393
- }
394
- navigator && "deviceMemory" in navigator && (n.device_memory = navigator?.deviceMemory);
395
- const c = "ontouchstart" in window || typeof navigator?.maxTouchPoints < "u" && navigator?.maxTouchPoints > 0;
396
- if (n.touch_supported = c, "hardwareConcurrency" in navigator && (n.hardware_concurrency = navigator?.hardwareConcurrency), navigator && "mediaDevices" in navigator) {
397
- const f = await navigator?.mediaDevices?.enumerateDevices(), u = f.some((o) => o?.kind === "videoinput");
398
- n.camera_supported = u;
399
- const s = f.some((o) => o?.kind === "audioinput");
400
- n.microphone_supported = s;
401
- }
402
- return n.gpu = ye(), {
403
- locale: a,
404
- timezone: i,
405
- dark_mode: e,
406
- private_mode: t,
407
- properties: n
408
- };
409
- }, be = (a, i, e) => {
410
- const { debug: t } = P();
411
- if (!a)
412
- return null;
413
- const n = {
414
- name: a.workspace,
415
- /**
416
- * Handle track events (custom events like clicks, scrolls, etc.)
417
- *
418
- * Enriches the event with:
419
- * - Session/device IDs
420
- * - Page metadata (URL, title, etc.)
421
- * - Tab information
422
- * - Timestamp
423
- *
424
- * Then queues for batched sending.
425
- */
426
- track: ({ payload: c }) => {
427
- if (!e()) return;
428
- const r = c?.properties || {};
429
- i(c.event, r);
430
- },
431
- /**
432
- * Handle page view events.
433
- *
434
- * Called when navigating to a new page (in SPAs) or on initial load.
435
- * Resets the rate limit counter and tracks a page.view event.
436
- */
437
- page: ({ payload: c }) => {
438
- if (!e()) return;
439
- $();
440
- const r = c?.properties || {};
441
- i("page.view", {
442
- ...r,
443
- resource: "page"
444
- });
445
- },
446
- /**
447
- * Handle identify events (session establishment).
448
- *
449
- * This is called when identify() is invoked. It:
450
- * 1. Reads identity from session store (set by init())
451
- * 2. Checks if already identified (via BroadcastChannel) - if so, skip
452
- * 3. Calls /welcome API to get session/device IDs
453
- * 4. On success, broadcasts session to other tabs
454
- *
455
- * The /welcome API uses HttpOnly cookies to maintain persistent
456
- * device identity across sessions.
457
- */
458
- identify: ({ payload: c }) => {
459
- if (!e()) return;
460
- const { workspace: r, site_id: f, debug: u } = P(), {
461
- mode: s,
462
- isIdentified: o,
463
- isIdentifying: l,
464
- sessionToken: h,
465
- deviceToken: y,
466
- insightsBaseUrl: w,
467
- identity: p
468
- } = C(), I = z(), D = C().allTabs.length;
469
- if (!w || !p)
470
- return;
471
- const L = {
472
- ...{
473
- private_mode: c.traits?.private_mode ?? p.privateMode ?? !1,
474
- dark_mode: c.traits?.dark_mode ?? p.darkMode ?? !1,
475
- timezone: c.traits?.timezone ?? p.timezone ?? "",
476
- locale: c.traits?.locale ?? p.locale ?? "",
477
- referrer: c.traits?.referrer ?? p.referrer ?? { type: "", referrer: {}, data: {} },
478
- properties: {
479
- ...p.properties
480
- }
481
- },
482
- workspace_id: r ?? "",
483
- site_id: f ?? void 0,
484
- hostname: window.location.hostname,
485
- pathname: window.location.pathname,
486
- page_title: document.title,
487
- url: window.location.href,
488
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
489
- tab_id: I ?? "",
490
- tab_count: D ?? 0
491
- };
492
- if (u && console.log("[@levo-so/insights] Identification triggered:", {
493
- isIdentified: o,
494
- isIdentifying: l,
495
- welcomeInput: L
496
- }), o || l)
497
- return;
498
- if (T({ isIdentifying: !0 }), u) {
499
- console.log("[@levo-so/insights] Debug mode enabled. Mocking session identification."), T({
500
- isIdentified: !0,
501
- isIdentifying: !1,
502
- sessionId: "debug-session",
503
- deviceId: "debug-device"
504
- });
505
- return;
506
- }
507
- const d = {
508
- Accept: "application/json",
509
- "Content-Type": "application/json",
510
- ...G({ sessionToken: h, deviceToken: y, mode: s })
511
- };
512
- a.fetch.url(w, !0).url("/v1/insights/event/welcome").options({
513
- keepAlive: !0,
514
- credentials: s === "proxy" ? "include" : "omit"
515
- }).headers(d).post(L).json().then((g) => {
516
- if (!e()) return;
517
- const { isIdentified: b } = C();
518
- if (!b) {
519
- const v = { isIdentified: !0 };
520
- if (g?.content?.data?.session && (v.sessionId = g?.content?.data?.session), g?.content?.data?.device && (v.deviceId = g?.content?.data?.device), s === "direct" && g?.content?.meta) {
521
- const k = g.content.meta;
522
- k.device_token && (v.deviceToken = k.device_token), k.session_token && (v.sessionToken = k.session_token);
523
- }
524
- T(v);
525
- }
526
- }).catch((g) => {
527
- console.log("/welcome failed with error", E(g));
528
- }).finally(() => {
529
- T({ isIdentifying: !1 });
530
- });
531
- }
532
- };
533
- return ae({
534
- app: a.workspace || "",
535
- debug: !!t,
536
- plugins: [n]
537
- });
538
- };
539
- let m = null, _ = !1;
540
- const x = [], Ie = (a, i) => {
541
- const { insightsUrl: e, debug: t = !1, site: n = null } = i;
542
- K({
543
- workspace: a.workspace,
544
- debug: t,
545
- site_id: n
546
- }), typeof window < "u" && Promise.all([ke(), we()]).then(([o, l]) => {
547
- const h = l?.type ? {
548
- type: l.type,
549
- referrer: l.referrer,
550
- data: l.data,
551
- raw: l.raw ?? ""
552
- } : null;
553
- T({
554
- identity: {
555
- locale: o.locale,
556
- timezone: o.timezone,
557
- darkMode: o.dark_mode,
558
- privateMode: o.private_mode,
559
- referrer: h,
560
- properties: o.properties
561
- }
562
- });
563
- }).catch(() => {
564
- T({
565
- identity: {
566
- locale: null,
567
- timezone: null,
568
- darkMode: null,
569
- privateMode: null,
570
- referrer: null,
571
- properties: null
572
- }
573
- });
574
- });
575
- const c = async (o, l) => {
576
- if (typeof window > "u")
577
- return;
578
- const { page_id: h } = P(), { allTabs: y } = C(), w = z(), p = y.length, I = {
579
- event: o,
580
- version: l?.version || 1,
581
- properties: {
582
- ...l,
583
- version: void 0,
584
- resource: void 0,
585
- identifier: void 0,
586
- hostname: void 0,
587
- pathname: void 0,
588
- url: void 0,
589
- page_title: void 0,
590
- created_at: void 0
591
- },
592
- hostname: window.location.hostname,
593
- pathname: window.location.pathname,
594
- url: l?.url ?? window.location.href,
595
- page_title: l?.page_title ?? document.title,
596
- resource: l?.resource ?? "page",
597
- identifier: l?.id ?? h ?? void 0,
598
- created_at: l?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
599
- tab_id: w ?? "",
600
- tab_count: p
601
- };
602
- W(I);
603
- }, r = (o) => {
604
- !m || !_ || m.identify("", { withLock: !0 });
605
- }, f = (o) => {
606
- const { page_id: l } = P();
607
- l !== o && j("page_id", o);
608
- };
609
- return {
610
- init: (o = {}) => {
611
- if (typeof window > "u")
612
- throw new Error("[@levo-so/insights] init() should only be called on the client side.");
613
- const { pageId: l } = o;
614
- if (l && f(l), !_ && !(a.NODE_ENV === "development" && !t)) {
615
- if (!e) {
616
- console.error(
617
- "[@levo-so/insights] The utility could not be initialized due to missing insights endpoint."
618
- );
619
- return;
620
- }
621
- _ = !0, Q(() => {
622
- if (!_) return;
623
- const { insightsBaseUrl: h } = C();
624
- h || he(i).then(({ mode: w, url: p }) => {
625
- _ && p && T({ mode: w, insightsBaseUrl: p });
626
- }).catch(() => {
627
- e && T({ mode: "proxy", insightsBaseUrl: e });
628
- });
629
- const y = Z.subscribe((w) => {
630
- if (!(!w || !_) && !m) {
631
- const p = be(a, c, () => m === p);
632
- m = p, C().insightsBaseUrl && m && (x.push(
633
- J(),
634
- V(m),
635
- ee(m),
636
- fe(m),
637
- pe(m),
638
- te(),
639
- ge(m),
640
- me(m),
641
- ne(m),
642
- re(m)
643
- ), r(), m.page({ resource: "page" }));
644
- }
645
- });
646
- x.push(y);
647
- });
648
- }
649
- },
650
- destroy: () => {
651
- _ && (N(X()), Y(), x.forEach((o) => {
652
- o();
653
- }), x.length = 0, m = null, _ = !1);
654
- },
655
- track: c,
656
- get instance() {
657
- return m;
658
- }
659
- };
660
- };
1
+ import { createLevoInsights as o } from "./lib/insights.js";
2
+ import { AnalyticsEvents as s } from "@levo-so/core";
661
3
  export {
662
- xe as AnalyticsEvents,
663
- Ie as createLevoInsights
4
+ s as AnalyticsEvents,
5
+ o as createLevoInsights
664
6
  };