@ogygia/insights 0.0.0 → 0.15.0

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,124 @@
1
+ import { RuntimeHookName, RuntimeHooks } from "@ogygia/core/plugin/client";
2
+ type HookPayload<K extends RuntimeHookName> = Parameters<RuntimeHooks[K]>[0];
3
+ /** One runtime hook call as the readers keep it: which hook, when it was called (`at`, page time,
4
+ * ms), its payload without the server markup, and the region its element names (`fp`, `entry`,
5
+ * `endpoint`): the element is held weakly and a saved session part drops it, so the names carry
6
+ * the region past the page. */
7
+ export type HookEntry = { [K in RuntimeHookName]: {
8
+ readonly hook: K;
9
+ readonly at: number;
10
+ readonly fp?: string;
11
+ readonly entry?: string;
12
+ readonly endpoint?: string;
13
+ /** held weakly (a region the page left can go); gone in a saved part */
14
+ readonly el?: WeakRef<Element>;
15
+ } & Omit<HookPayload<K>, "el" | "ssrHtml">; }[RuntimeHookName];
16
+ export interface SessionInteraction {
17
+ t: number;
18
+ name: string;
19
+ duration: number;
20
+ input_delay: number;
21
+ processing: number;
22
+ presentation: number;
23
+ id: number;
24
+ target: string;
25
+ fp: string | null;
26
+ el: WeakRef<Element> | null;
27
+ }
28
+ export interface SessionClick {
29
+ t: number;
30
+ target: string;
31
+ fp: string | null;
32
+ el: WeakRef<Element> | null;
33
+ /** it looked like it does something (a control, a link, a clickable role, a pointer cursor): a
34
+ * click on text or a blank stretch that changes nothing is no dead click */
35
+ clickable?: true;
36
+ }
37
+ export interface SessionShift {
38
+ t: number;
39
+ value: number;
40
+ input: boolean;
41
+ fp: string | null;
42
+ el: WeakRef<Element> | null;
43
+ }
44
+ export interface SessionRequest {
45
+ url: string;
46
+ type: string;
47
+ t: number;
48
+ ms: number;
49
+ bytes: number;
50
+ status: number | null;
51
+ /** the server's own account (`Server-Timing`: ogygia's profiler sends ssr / cpu / net / up1-3) */
52
+ server?: {
53
+ name: string;
54
+ ms: number;
55
+ desc: string;
56
+ }[];
57
+ }
58
+ export interface SessionFrame {
59
+ t: number;
60
+ ms: number;
61
+ blocking: number;
62
+ scripts: {
63
+ source: string;
64
+ fn: string;
65
+ invoker: string;
66
+ ms: number;
67
+ }[];
68
+ }
69
+ /** A navigation as it started: where to, when, and the element that started it (the link or form, or
70
+ * the input being handled then) with its island. */
71
+ export interface SessionNav {
72
+ url: string;
73
+ t: number;
74
+ type: string;
75
+ source: string | null;
76
+ fp: string | null;
77
+ }
78
+ export interface SessionData {
79
+ from: number;
80
+ to: number;
81
+ interactions: SessionInteraction[];
82
+ longtasks: {
83
+ t: number;
84
+ ms: number;
85
+ }[];
86
+ frames: SessionFrame[];
87
+ shifts: SessionShift[];
88
+ requests: SessionRequest[];
89
+ mutations: {
90
+ fp: string | null;
91
+ count: number;
92
+ el: WeakRef<Element> | null;
93
+ }[];
94
+ /** when the DOM changed, and where (one stamp per island per batch of changes) */
95
+ mut_log: {
96
+ t: number;
97
+ fp: string | null;
98
+ }[];
99
+ /** every click, fast ones too */
100
+ clicks: SessionClick[];
101
+ errors: {
102
+ t: number;
103
+ message: string;
104
+ }[];
105
+ /** navigations as they started, with what started them (absent in a part saved before this field) */
106
+ navs?: SessionNav[];
107
+ heap: {
108
+ from: number;
109
+ to: number;
110
+ } | null;
111
+ /** the runtime hooks the page called while it recorded */
112
+ hooks: HookEntry[];
113
+ cpu: unknown;
114
+ cpu_off: string | null;
115
+ page: string;
116
+ /** the documents the session crossed (a full page load mid-session), each with when it began */
117
+ pages: {
118
+ url: string;
119
+ t: number;
120
+ }[];
121
+ /** island fingerprint → component name, taken on each page (its islands are gone after it) */
122
+ names: Record<string, string>;
123
+ }
124
+ export {};
File without changes
@@ -0,0 +1,121 @@
1
+ import { CpuSummary } from "./cpu.js";
2
+ import { SessionData } from "./session-data.js";
3
+ export type Ref = {
4
+ kind: "interaction";
5
+ i: number;
6
+ } | {
7
+ kind: "click";
8
+ i: number;
9
+ } | {
10
+ kind: "shift";
11
+ i: number;
12
+ } | {
13
+ kind: "island";
14
+ fp: string;
15
+ };
16
+ export interface SessionFinding {
17
+ code: string;
18
+ severity: "error" | "warn" | "info";
19
+ message: string;
20
+ fix?: string;
21
+ refs: Ref[];
22
+ /** a same-origin GET the tab can profile on the server in one click (server-time findings) */
23
+ url?: string;
24
+ }
25
+ /** One island's part of the session: what was done to it, and what it asked the server. */
26
+ export interface IslandSession {
27
+ clicks: number;
28
+ /** its interactions over 100 ms */
29
+ slow: {
30
+ target: string;
31
+ duration: number;
32
+ processing: number;
33
+ }[];
34
+ /** requests that started within 3 s after a click on it, with the server's split */
35
+ requests: {
36
+ url: string;
37
+ ms: number;
38
+ server_ms: number | null;
39
+ net_ms: number | null;
40
+ up: string | null;
41
+ status: number | null;
42
+ }[];
43
+ mutations: number;
44
+ }
45
+ /** One item on the session's one-clock timeline (ms from the session start). */
46
+ export interface TimelineItem {
47
+ t0: number;
48
+ t1: number;
49
+ label: string;
50
+ tone: "ok" | "warn" | "bad" | "info";
51
+ /** a request: the server's part and, inside it, the upstream wait (ms) */
52
+ server?: {
53
+ ms: number;
54
+ up: number;
55
+ };
56
+ ref?: Ref;
57
+ }
58
+ export interface TimelineLane {
59
+ key: "input" | "main" | "net" | "islands" | "layout" | "errors";
60
+ label: string;
61
+ items: TimelineItem[];
62
+ }
63
+ /** The session on one clock, lane by lane (the Record tab draws it). Capped per lane. */
64
+ export declare function session_timeline(s: SessionData, names: (fp: string) => string): TimelineLane[];
65
+ export interface SessionReport {
66
+ duration_ms: number;
67
+ /** `shifts` and `cls`: the layout moving with no input (the shifts the session's CLS counts) */
68
+ counts: {
69
+ interactions: number;
70
+ slow: number;
71
+ longtasks: number;
72
+ longtask_ms: number;
73
+ requests: number;
74
+ request_bytes: number;
75
+ errors: number;
76
+ shifts: number;
77
+ cls: number;
78
+ mutations: number;
79
+ pages: number;
80
+ };
81
+ findings: SessionFinding[];
82
+ /** the slowest interactions, for the timeline */
83
+ interactions: {
84
+ i: number;
85
+ t: number;
86
+ name: string;
87
+ duration: number;
88
+ target: string;
89
+ fp: string | null;
90
+ }[];
91
+ /** each island's part: clicks, slow interactions, the requests its clicks caused (server split) */
92
+ by_island: Record<string, IslandSession>;
93
+ /** the slowest requests, with the server's own split when it sent one */
94
+ requests: {
95
+ url: string;
96
+ ms: number;
97
+ status: number | null;
98
+ server_ms: number | null;
99
+ cpu_ms: number | null;
100
+ net_ms: number | null;
101
+ up: string | null;
102
+ }[];
103
+ /** every request that answered an error status (`type`: the browser's initiator type) */
104
+ failed: {
105
+ url: string;
106
+ status: number;
107
+ type: string;
108
+ t: number;
109
+ }[];
110
+ /** the slowest interaction on each element the session touched, however quick (0: a click the
111
+ * browser did not time, under its 16 ms floor) */
112
+ by_element: {
113
+ target: string;
114
+ duration: number;
115
+ processing: number;
116
+ t: number;
117
+ fp: string | null;
118
+ }[];
119
+ cpu: CpuSummary | null;
120
+ }
121
+ export declare function analyze_session(s: SessionData, names: (fp: string) => string, page_url: string): SessionReport;