@levo-so/insights 0.1.71 → 0.1.76

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.
@@ -93,18 +93,18 @@ const ee = () => b.get(), re = (e) => {
93
93
  }, Mt = de(
94
94
  b,
95
95
  (e) => e.insightsBaseUrl !== null && e.identity !== null
96
- ), Re = 10, Ne = 2e3, oe = 500, w = E([]), F = E(0), Le = de(w, (e) => e.length ?? 0), A = E(null), Pt = () => {
96
+ ), Re = 10, Ne = 2e3, oe = 500, T = E([]), F = E(0), Le = de(T, (e) => e.length ?? 0), A = E(null), Pt = () => {
97
97
  let e = !1;
98
98
  return b.subscribe((t) => {
99
99
  if (t.isIdentified && !e) {
100
100
  e = !0;
101
- const n = w.get();
101
+ const n = T.get();
102
102
  n.length > 0 && $(n);
103
103
  }
104
104
  });
105
- }, B = () => w.get(), Ie = () => Le.get(), $ = (e) => {
106
- const { workspace: t, debug: n, site_id: s, page_id: r } = Z(), { isIdentified: a, mode: c, sessionId: l, deviceId: o, sessionToken: i, deviceToken: f, insightsBaseUrl: d } = ee();
107
- if (e.length === 0 || !a || !d || !t)
105
+ }, B = () => T.get(), Ie = () => Le.get(), $ = (e) => {
106
+ const { workspace: t, debug: n, site_id: s, page_id: r } = Z(), { isIdentified: o, mode: c, sessionId: l, deviceId: a, sessionToken: i, deviceToken: f, insightsBaseUrl: d } = ee();
107
+ if (e.length === 0 || !o || !d || !t)
108
108
  return;
109
109
  const p = e.map(
110
110
  (m) => ({
@@ -112,7 +112,7 @@ const ee = () => b.get(), re = (e) => {
112
112
  workspace_id: t,
113
113
  site_id: s ?? void 0,
114
114
  session_id: l ?? void 0,
115
- device_id: o ?? void 0,
115
+ device_id: a ?? void 0,
116
116
  identifier: r ?? void 0,
117
117
  hostname: window.location.hostname,
118
118
  pathname: window.location.pathname,
@@ -129,7 +129,7 @@ const ee = () => b.get(), re = (e) => {
129
129
  properties: m.properties ?? {}
130
130
  })
131
131
  );
132
- if (w.set([]), n) {
132
+ if (T.set([]), n) {
133
133
  console.log("[@levo-so/insights] Debug mode enabled. Events batch:", p);
134
134
  return;
135
135
  }
@@ -161,12 +161,12 @@ const ee = () => b.get(), re = (e) => {
161
161
  return;
162
162
  }
163
163
  F.set(n + 1);
164
- const s = w.get();
165
- w.set([...s, e]);
164
+ const s = T.get();
165
+ T.set([...s, e]);
166
166
  const { isIdentified: r } = ee();
167
167
  Ie() >= Re ? (fe(), $(B())) : r && Oe();
168
168
  }, jt = () => F.set(0), Ft = () => {
169
- w.set([]), F.set(0), fe();
169
+ T.set([]), F.set(0), fe();
170
170
  }, O = X({
171
171
  status: "active",
172
172
  seconds: 0
@@ -176,17 +176,17 @@ const ee = () => b.get(), re = (e) => {
176
176
  const s = xe({
177
177
  timeout: 6e4,
178
178
  throttle: 1e3,
179
- onIdle: (a) => {
180
- O.set({ status: "idle", seconds: a });
179
+ onIdle: (o) => {
180
+ O.set({ status: "idle", seconds: o });
181
181
  },
182
- onWakeUp: (a) => {
183
- O.set({ status: "active", seconds: a });
182
+ onWakeUp: (o) => {
183
+ O.set({ status: "active", seconds: o });
184
184
  }
185
- }), r = O.listen((a) => {
186
- a.seconds > 0 && (a.status === "idle" ? e.track("user.idle", {
187
- seconds_active: a.seconds
185
+ }), r = O.listen((o) => {
186
+ o.seconds > 0 && (o.status === "idle" ? e.track("user.idle", {
187
+ seconds_active: o.seconds
188
188
  }) : e.track("user.active", {
189
- seconds_idle: a.seconds
189
+ seconds_idle: o.seconds
190
190
  }));
191
191
  });
192
192
  return () => {
@@ -417,8 +417,8 @@ const Ue = (e) => e.reduce((t, n) => (t[n] = n, t), {}), je = [
417
417
  );
418
418
  break;
419
419
  }
420
- }, a = ["pageshow", "pagehide", "focus", "blur", "visibilitychange", "resume", "freeze"];
421
- a.forEach((i) => {
420
+ }, o = ["pageshow", "pagehide", "focus", "blur", "visibilitychange", "resume", "freeze"];
421
+ o.forEach((i) => {
422
422
  window.addEventListener(i, r, { capture: !0 });
423
423
  }), window.addEventListener("beforeunload", s);
424
424
  const c = L.listen((i) => {
@@ -428,13 +428,13 @@ const Ue = (e) => e.reduce((t, n) => (t[n] = n, t), {}), je = [
428
428
  }) : i === "hidden" && $(B());
429
429
  });
430
430
  let l = W.get().page_id;
431
- const o = W.listen((i) => {
431
+ const a = W.listen((i) => {
432
432
  i.page_id !== l && (t = !1, l = i.page_id);
433
433
  });
434
434
  return () => {
435
- a.forEach((i) => {
435
+ o.forEach((i) => {
436
436
  window.removeEventListener(i, r, { capture: !0 });
437
- }), window.removeEventListener("beforeunload", s), c(), o(), t = !1, L.set(
437
+ }), window.removeEventListener("beforeunload", s), c(), a(), t = !1, L.set(
438
438
  "active"
439
439
  /* ACTIVE */
440
440
  );
@@ -542,9 +542,9 @@ function Je(e) {
542
542
  }
543
543
  const ye = "(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})", Xe = new RegExp(`^(?:${ye})$`), Ze = new RegExp(ye), ve = "\\d{3}-?\\d{2}-?\\d{4}", et = new RegExp(`^(${ve})$`), tt = new RegExp(`(${ve})`), ne = (e, t = !0) => !(me(e) || H(e) && (e = k(e), (t ? Xe : Ze).test((e || "").replace(/[- ]/g, "")) || (t ? et : tt).test(e))), nt = (e) => H(e) ? e.substring(0, 10) === "_ngcontent" || e.substring(0, 7) === "_nghost" : !1, st = (e) => {
544
544
  let t = te(e);
545
- return t = `${t} ${Te(e)}`.trim(), ne(t) ? t : "";
545
+ return t = `${t} ${we(e)}`.trim(), ne(t) ? t : "";
546
546
  };
547
- function Te(e) {
547
+ function we(e) {
548
548
  let t = "";
549
549
  if (e?.childNodes.length)
550
550
  for (const n of e.childNodes) {
@@ -552,7 +552,7 @@ function Te(e) {
552
552
  if (n && s && be.includes(s))
553
553
  try {
554
554
  const r = te(n);
555
- t = `${t} ${r}`.trim(), n?.childNodes.length && (t = `${t} ${Te(n)}`.trim());
555
+ t = `${t} ${r}`.trim(), n?.childNodes.length && (t = `${t} ${we(n)}`.trim());
556
556
  } catch {
557
557
  }
558
558
  }
@@ -565,19 +565,19 @@ const it = (e) => {
565
565
  if (s) return { text: g(s), source: "aria-label" };
566
566
  const r = e.getAttribute("title");
567
567
  if (r) return { text: g(r), source: "title" };
568
- const a = e.getAttribute("data-track-label");
569
- if (a) return { text: g(a), source: "data-track-label" };
568
+ const o = e.getAttribute("data-track-label");
569
+ if (o) return { text: g(o), source: "data-track-label" };
570
570
  const c = e.querySelector("img[alt], svg[aria-label]");
571
571
  if (c) {
572
- const o = c.getAttribute("alt") || c.getAttribute("aria-label");
573
- if (o) return { text: g(o), source: "alt" };
572
+ const a = c.getAttribute("alt") || c.getAttribute("aria-label");
573
+ if (a) return { text: g(a), source: "alt" };
574
574
  }
575
575
  const l = e.getAttribute("placeholder");
576
576
  if (l) return { text: g(l), source: "placeholder" };
577
577
  if (e instanceof HTMLElement && e.innerText) {
578
- const o = e.innerText.substring(0, 500);
579
- if (o.trim())
580
- return { text: g(o), source: "innerText" };
578
+ const a = e.innerText.substring(0, 500);
579
+ if (a.trim())
580
+ return { text: g(a), source: "innerText" };
581
581
  }
582
582
  return { text: "", source: "none" };
583
583
  }, rt = ["input", "textarea", "select"], ot = (e) => {
@@ -587,26 +587,26 @@ const it = (e) => {
587
587
  n.text = s.text, n.text_source = s.source;
588
588
  const r = e.getAttribute("aria-label");
589
589
  r && (n.aria_label = g(r));
590
- const a = e.getAttribute("role");
591
- a && (n.role = a);
590
+ const o = e.getAttribute("role");
591
+ o && (n.role = o);
592
592
  const c = {};
593
- for (const o of e.attributes)
594
- (o.name.startsWith("data-track-") || o.name.startsWith("data-analytics-")) && (c[o.name] = g(o.value));
593
+ for (const a of e.attributes)
594
+ (a.name.startsWith("data-track-") || a.name.startsWith("data-analytics-")) && (c[a.name] = g(a.value));
595
595
  Object.keys(c).length && (n.tracking_data = c);
596
596
  const l = Array.from(e.attributes).reduce(
597
- (o, i) => {
597
+ (a, i) => {
598
598
  if (ne(i.value) && !nt(i.name)) {
599
599
  if (i.name === "class" || i.name.startsWith("data-track-") || i.name.startsWith("data-analytics-"))
600
- return o;
601
- o[i.name] = typeof i?.value == "string" ? g(i.value) : i.value;
600
+ return a;
601
+ a[i.name] = typeof i?.value == "string" ? g(i.value) : i.value;
602
602
  }
603
- return o;
603
+ return a;
604
604
  },
605
605
  {}
606
606
  );
607
607
  if (n.attributes = l, rt.includes(t) || e?.getAttribute("contenteditable") === "true") {
608
- let o;
609
- e.matches('input[type="checkbox"], input[type="radio"]') ? o = e.checked : e.matches("input, select, textarea") && !e.matches('input[type="password"]') && (o = e.value), o !== void 0 && (n.value = typeof o == "string" || o === null ? g(o, 1024) : o);
608
+ let a;
609
+ e.matches('input[type="checkbox"], input[type="radio"]') ? a = e.checked : e.matches("input, select, textarea") && !e.matches('input[type="password"]') && (a = e.value), a !== void 0 && (n.value = typeof a == "string" || a === null ? g(a, 1024) : a);
610
610
  let i = "";
611
611
  n?.attributes.id && (i = g(
612
612
  document.querySelector(`label[for="${n?.attributes.id}"]`)?.textContent?.trim() || ""
@@ -622,8 +622,8 @@ const it = (e) => {
622
622
  if (n && (s || Qe(n, e))) {
623
623
  const r = ot(n);
624
624
  if (s) {
625
- const a = g(window?.getSelection()?.toString()), c = e?.type || "clipboard";
626
- r.copy_text = a ?? "", r.copy_type = c;
625
+ const o = g(window?.getSelection()?.toString()), c = e?.type || "clipboard";
626
+ r.copy_text = o ?? "", r.copy_type = c;
627
627
  }
628
628
  return r;
629
629
  }
@@ -638,9 +638,9 @@ const it = (e) => {
638
638
  K.set(s), n.includes(s) || re({ allTabs: [...n, s] });
639
639
  const r = () => {
640
640
  if (!s) return;
641
- const { allTabs: a } = b.get();
642
- if (a.includes(s)) {
643
- const c = a.filter((l) => l !== s);
641
+ const { allTabs: o } = b.get();
642
+ if (o.includes(s)) {
643
+ const c = o.filter((l) => l !== s);
644
644
  re({ allTabs: c });
645
645
  }
646
646
  };
@@ -652,8 +652,8 @@ function J(e) {
652
652
  var t = typeof e;
653
653
  return e != null && (t == "object" || t == "function");
654
654
  }
655
- var at = typeof global == "object" && global && global.Object === Object && global, ct = typeof self == "object" && self && self.Object === Object && self, we = at || ct || Function("return this")(), V = function() {
656
- return we.Date.now();
655
+ var at = typeof global == "object" && global && global.Object === Object && global, ct = typeof self == "object" && self && self.Object === Object && self, Te = at || ct || Function("return this")(), V = function() {
656
+ return Te.Date.now();
657
657
  }, lt = /\s/;
658
658
  function ut(e) {
659
659
  for (var t = e.length; t-- && lt.test(e.charAt(t)); )
@@ -664,7 +664,7 @@ var dt = /^\s+/;
664
664
  function ft(e) {
665
665
  return e && e.slice(0, ut(e) + 1).replace(dt, "");
666
666
  }
667
- var q = we.Symbol, Ee = Object.prototype, gt = Ee.hasOwnProperty, pt = Ee.toString, I = q ? q.toStringTag : void 0;
667
+ var q = Te.Symbol, Ee = Object.prototype, gt = Ee.hasOwnProperty, pt = Ee.toString, I = q ? q.toStringTag : void 0;
668
668
  function mt(e) {
669
669
  var t = gt.call(e, I), n = e[I];
670
670
  try {
@@ -679,16 +679,16 @@ var ht = Object.prototype, bt = ht.toString;
679
679
  function yt(e) {
680
680
  return bt.call(e);
681
681
  }
682
- var vt = "[object Null]", Tt = "[object Undefined]", ce = q ? q.toStringTag : void 0;
683
- function wt(e) {
684
- return e == null ? e === void 0 ? Tt : vt : ce && ce in Object(e) ? mt(e) : yt(e);
682
+ var vt = "[object Null]", wt = "[object Undefined]", ce = q ? q.toStringTag : void 0;
683
+ function Tt(e) {
684
+ return e == null ? e === void 0 ? wt : vt : ce && ce in Object(e) ? mt(e) : yt(e);
685
685
  }
686
686
  function Et(e) {
687
687
  return e != null && typeof e == "object";
688
688
  }
689
689
  var St = "[object Symbol]";
690
690
  function xt(e) {
691
- return typeof e == "symbol" || Et(e) && wt(e) == St;
691
+ return typeof e == "symbol" || Et(e) && Tt(e) == St;
692
692
  }
693
693
  var le = NaN, _t = /^[-+]0x[0-9a-f]+$/i, kt = /^0b[01]+$/i, Ct = /^0o[0-7]+$/i, Rt = parseInt;
694
694
  function ue(e) {
@@ -708,24 +708,24 @@ function ue(e) {
708
708
  }
709
709
  var Nt = "Expected a function", Lt = Math.max, It = Math.min;
710
710
  function Se(e, t, n) {
711
- var s, r, a, c, l, o, i = 0, f = !1, d = !1, p = !0;
711
+ var s, r, o, c, l, a, i = 0, f = !1, d = !1, p = !0;
712
712
  if (typeof e != "function")
713
713
  throw new TypeError(Nt);
714
- t = ue(t) || 0, J(n) && (f = !!n.leading, d = "maxWait" in n, a = d ? Lt(ue(n.maxWait) || 0, t) : a, p = "trailing" in n ? !!n.trailing : p);
714
+ t = ue(t) || 0, J(n) && (f = !!n.leading, d = "maxWait" in n, o = d ? Lt(ue(n.maxWait) || 0, t) : o, p = "trailing" in n ? !!n.trailing : p);
715
715
  function y(u) {
716
- var h = s, T = r;
717
- return s = r = void 0, i = u, c = e.apply(T, h), c;
716
+ var h = s, w = r;
717
+ return s = r = void 0, i = u, c = e.apply(w, h), c;
718
718
  }
719
719
  function C(u) {
720
720
  return i = u, l = setTimeout(S, t), f ? y(u) : c;
721
721
  }
722
722
  function m(u) {
723
- var h = u - o, T = u - i, se = t - h;
724
- return d ? It(se, a - T) : se;
723
+ var h = u - a, w = u - i, se = t - h;
724
+ return d ? It(se, o - w) : se;
725
725
  }
726
726
  function R(u) {
727
- var h = u - o, T = u - i;
728
- return o === void 0 || h >= t || h < 0 || d && T >= a;
727
+ var h = u - a, w = u - i;
728
+ return a === void 0 || h >= t || h < 0 || d && w >= o;
729
729
  }
730
730
  function S() {
731
731
  var u = V();
@@ -737,18 +737,18 @@ function Se(e, t, n) {
737
737
  return l = void 0, p && s ? y(u) : (s = r = void 0, c);
738
738
  }
739
739
  function M() {
740
- l !== void 0 && clearTimeout(l), i = 0, s = o = r = l = void 0;
740
+ l !== void 0 && clearTimeout(l), i = 0, s = a = r = l = void 0;
741
741
  }
742
742
  function P() {
743
743
  return l === void 0 ? c : D(V());
744
744
  }
745
745
  function N() {
746
746
  var u = V(), h = R(u);
747
- if (s = arguments, r = this, o = u, h) {
747
+ if (s = arguments, r = this, a = u, h) {
748
748
  if (l === void 0)
749
- return C(o);
749
+ return C(a);
750
750
  if (d)
751
- return clearTimeout(l), l = setTimeout(S, t), y(o);
751
+ return clearTimeout(l), l = setTimeout(S, t), y(a);
752
752
  }
753
753
  return l === void 0 && (l = setTimeout(S, t)), c;
754
754
  }
@@ -767,33 +767,33 @@ const Y = X({
767
767
  prevScrollY: 0,
768
768
  prevTime: Date.now()
769
769
  };
770
- const n = 5, s = 300, r = 250, a = () => {
770
+ const n = 5, s = 300, r = 250, o = () => {
771
771
  const i = window.scrollY, f = document.documentElement.scrollHeight, d = window.innerHeight, p = f - d;
772
772
  if (p <= 0) return;
773
773
  const y = Math.round(i / p * 100), C = Math.max(0, Math.min(100, y)), m = Math.floor(C / n) * n, { prevMilestone: R, prevScrollY: S, prevTime: D } = t;
774
774
  if (m === R) return;
775
- const M = Date.now(), P = (M - D) / 1e3, N = Math.abs(i - S), u = P > 0 ? N / P : 0, h = m > R ? "down" : "up", T = u > s ? "scan" : "read";
775
+ const M = Date.now(), P = (M - D) / 1e3, N = Math.abs(i - S), u = P > 0 ? N / P : 0, h = m > R ? "down" : "up", w = u > s ? "scan" : "read";
776
776
  Y.set({
777
777
  depth: m,
778
- speedCategory: T,
778
+ speedCategory: w,
779
779
  direction: h
780
780
  }), t = {
781
781
  prevMilestone: m,
782
782
  prevScrollY: i,
783
783
  prevTime: M
784
784
  };
785
- }, c = Se(a, r);
785
+ }, c = Se(o, r);
786
786
  window.addEventListener("scroll", c);
787
787
  let l = 0;
788
- const o = Y.listen((i) => {
788
+ const a = Y.listen((i) => {
789
789
  i.depth !== l && (l = i.depth, e.track("page.scroll", {
790
790
  depth: i.depth,
791
791
  speed_category: i.speedCategory,
792
792
  direction: i.direction
793
793
  }));
794
794
  });
795
- return a(), () => {
796
- window.removeEventListener("scroll", c), c.cancel(), o(), Y.set({
795
+ return typeof window.requestIdleCallback == "function" ? window.requestIdleCallback(() => o()) : setTimeout(o, 0), () => {
796
+ window.removeEventListener("scroll", c), c.cancel(), a(), Y.set({
797
797
  depth: 0,
798
798
  speedCategory: "read",
799
799
  direction: "down"
@@ -805,8 +805,8 @@ const Y = X({
805
805
  const n = Se(() => {
806
806
  const r = window.getSelection();
807
807
  if (r && r.rangeCount > 0) {
808
- const a = r.toString().trim();
809
- a && z.set(a);
808
+ const o = r.toString().trim();
809
+ o && z.set(o);
810
810
  }
811
811
  }, 1e3);
812
812
  document.addEventListener("selectionchange", n);
@@ -828,7 +828,7 @@ export {
828
828
  Gt as E,
829
829
  Qt as F,
830
830
  Ht as G,
831
- w as a,
831
+ T as a,
832
832
  F as b,
833
833
  Le as c,
834
834
  Mt as d,
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
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 "./S_TwsxGkG8z9.js";
2
- import { G as xe } from "./S_TwsxGkG8z9.js";
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
3
  import { getVisitorSource as ie } from "@analytics/visitor-source";
4
4
  import oe from "get-user-locale";
5
5
  import { Analytics as ae } from "analytics";
package/dist/stores.js CHANGED
@@ -1,4 +1,4 @@
1
- import { f as s, $ as t, h as $, a as i, d as o, b as c, g as n, i as l, j as r, e as f, c as u } from "./S_TwsxGkG8z9.js";
1
+ import { f as s, $ as t, h as $, a as i, d as o, b as c, g as n, i as l, j as r, e as f, c as u } from "./DA6yh6E3HQLu.js";
2
2
  export {
3
3
  s as $activity,
4
4
  t as $config,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/insights",
3
- "version": "0.1.71",
3
+ "version": "0.1.76",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo analytics",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  "nanostores": "0.11.4"
22
22
  },
23
23
  "peerDependencies": {
24
- "@levo-so/core": "0.1.71"
24
+ "@levo-so/core": "0.1.76"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@playwright/test": "1.58.2",