@levo-so/insights 0.1.111 → 0.1.113
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,4 +1,4 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, T as d, _ as f, c as p, d as m, g as h, h as g, i as _, j as v, l as y, n as b, o as x, p as S, s as C, u as w, v as T, w as E, y as ee } from "./textSelection-
|
|
1
|
+
import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, T as d, _ as f, c as p, d as m, g as h, h as g, i as _, j as v, l as y, n as b, o as x, p as S, s as C, u as w, v as T, w as E, y as ee } from "./textSelection-Cwq6lqKg.js";
|
|
2
2
|
import { AnalyticsEvents as D, getLevoError as O } from "@levo-so/core";
|
|
3
3
|
import { getVisitorSource as k } from "@analytics/visitor-source";
|
|
4
4
|
import A from "get-user-locale";
|
package/dist/stores/events.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { ILevoAudience } from '../types/analytics';
|
|
2
2
|
/**
|
|
3
3
|
* An event pending delivery in the queue.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* track() captures every per-event field at track time (host/page/tab context,
|
|
6
|
+
* resource, identifier, timestamp), so they are all required here — flush trusts
|
|
7
|
+
* the queued event and does not re-default them. The only fields absent are the
|
|
8
|
+
* session/config ones, which {@link flushEventQueue} merges in at send time.
|
|
6
9
|
*/
|
|
7
|
-
type IQueuedEvent =
|
|
8
|
-
/** The event name (e.g. "page.view", "element.click"). */
|
|
9
|
-
event: string;
|
|
10
|
-
/** ISO 8601 timestamp when the event was recorded. */
|
|
11
|
-
created_at: string;
|
|
12
|
-
};
|
|
10
|
+
type IQueuedEvent = Omit<ILevoAudience.CollectInput, "workspace_id" | "site_id" | "session_id" | "device_id">;
|
|
13
11
|
declare const $eventQueue: import('nanostores').PreinitializedWritableAtom<IQueuedEvent[]> & object;
|
|
14
12
|
declare const $lifetimePageCount: import('nanostores').PreinitializedWritableAtom<number> & object;
|
|
15
13
|
declare const $totalEventCount: import('nanostores').ReadableAtom<number>;
|
package/dist/stores.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { $isIdentityContextReady } from './stores/readiness';
|
|
|
4
4
|
export { $session } from './stores/session';
|
|
5
5
|
export { $activity } from './tracking/activity';
|
|
6
6
|
export { $pageLifecycle } from './tracking/bounce';
|
|
7
|
-
export { $currentTab } from './tracking/currentTab';
|
|
7
|
+
export { $currentTab, getTabCount } from './tracking/currentTab';
|
|
8
8
|
export { $scrollBehavior } from './tracking/scrollBehavior';
|
|
9
9
|
export { $selectedText } from './tracking/textSelection';
|
package/dist/stores.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { P as e, S as t, _ as n, a as r, b as i, f as a, k as o, m as s, r as c,
|
|
2
|
-
export { s as $activity, e as $config, r as $currentTab, i as $eventQueue, n as $isIdentityContextReady,
|
|
1
|
+
import { P as e, S as t, _ as n, a as r, b as i, f as a, k as o, m as s, r as c, s as l, t as u, x as d } from "./textSelection-Cwq6lqKg.js";
|
|
2
|
+
export { s as $activity, e as $config, r as $currentTab, i as $eventQueue, n as $isIdentityContextReady, d as $lifetimePageCount, a as $pageLifecycle, c as $scrollBehavior, u as $selectedText, o as $session, t as $totalEventCount, l as getTabCount };
|
|
@@ -111,48 +111,37 @@ var b = () => g.get(), ee = (e) => {
|
|
|
111
111
|
...e
|
|
112
112
|
});
|
|
113
113
|
}, te = 10, ne = 2e3, x = 1e3, S = e([]), C = e(0), w = t(S, (e) => e.length ?? 0), T = e(null), E = () => S.get(), re = () => w.get(), D = (e) => {
|
|
114
|
-
let { workspace: t, debug: n, site_id: r
|
|
115
|
-
if (e.length === 0 || !
|
|
116
|
-
let
|
|
114
|
+
let { workspace: t, debug: n, site_id: r } = s(), { isIdentified: i, mode: a, sessionId: o, deviceId: c, sessionToken: l, deviceToken: d, insightsBaseUrl: f } = b();
|
|
115
|
+
if (e.length === 0 || !i || !f || !t) return;
|
|
116
|
+
let p = e.map((e) => ({
|
|
117
117
|
workspace_id: t,
|
|
118
118
|
site_id: r ?? void 0,
|
|
119
|
-
session_id:
|
|
120
|
-
device_id:
|
|
121
|
-
|
|
122
|
-
hostname: window.location.hostname,
|
|
123
|
-
pathname: window.location.pathname,
|
|
124
|
-
page_title: document.title,
|
|
125
|
-
url: window.location.href,
|
|
126
|
-
tab_id: "",
|
|
127
|
-
tab_count: 0,
|
|
128
|
-
...e,
|
|
129
|
-
event: e.event,
|
|
130
|
-
created_at: e.created_at,
|
|
131
|
-
resource: e.resource ?? "page",
|
|
132
|
-
properties: e.properties ?? {}
|
|
119
|
+
session_id: o ?? void 0,
|
|
120
|
+
device_id: c ?? void 0,
|
|
121
|
+
...e
|
|
133
122
|
}));
|
|
134
123
|
if (S.set([]), n) {
|
|
135
|
-
console.log("[@levo-so/insights] Debug mode enabled. Events batch:",
|
|
124
|
+
console.log("[@levo-so/insights] Debug mode enabled. Events batch:", p);
|
|
136
125
|
return;
|
|
137
126
|
}
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
let
|
|
141
|
-
if (navigator.sendBeacon && navigator.sendBeacon(
|
|
142
|
-
let
|
|
127
|
+
let m = new URLSearchParams({ workspace: t });
|
|
128
|
+
a === "direct" && (d && m.set("device_token", d), l && m.set("session_token", l));
|
|
129
|
+
let h = `${f}/v1/insights/event/bulk?${m.toString()}`;
|
|
130
|
+
if (navigator.sendBeacon && navigator.sendBeacon(h, JSON.stringify(p))) return;
|
|
131
|
+
let g = {
|
|
143
132
|
"Content-Type": "application/json",
|
|
144
133
|
...u({
|
|
145
|
-
deviceToken:
|
|
146
|
-
sessionToken:
|
|
147
|
-
mode:
|
|
134
|
+
deviceToken: d,
|
|
135
|
+
sessionToken: l,
|
|
136
|
+
mode: a
|
|
148
137
|
})
|
|
149
138
|
};
|
|
150
|
-
fetch(
|
|
139
|
+
fetch(h, {
|
|
151
140
|
method: "POST",
|
|
152
|
-
body: JSON.stringify(
|
|
153
|
-
headers:
|
|
141
|
+
body: JSON.stringify(p),
|
|
142
|
+
headers: g,
|
|
154
143
|
keepalive: !0,
|
|
155
|
-
credentials:
|
|
144
|
+
credentials: a === "proxy" ? "include" : "omit"
|
|
156
145
|
}).catch((e) => {
|
|
157
146
|
console.warn("[@levo-so/insights] Event flush failed, batch lost:", e);
|
|
158
147
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levo-so/insights",
|
|
3
3
|
"description": "Levo analytics",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.113",
|
|
5
5
|
"author": "Levo Engineering <devs@theinternetfolks.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@analytics/activity-utils": "0.2.2",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"typescript": "5.9.3",
|
|
18
18
|
"vite": "8.0.8",
|
|
19
19
|
"vite-plugin-dts": "4.5.4",
|
|
20
|
-
"@levo/
|
|
21
|
-
"@levo-
|
|
20
|
+
"@levo-so/core": "0.1.113",
|
|
21
|
+
"@levo/ts-config": "0.0.0"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"main": "./dist/index.js",
|
|
39
39
|
"module": "./dist/index.js",
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@levo-so/core": "0.1.
|
|
41
|
+
"@levo-so/core": "0.1.113"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|