@traqio/web 0.4.0 → 0.5.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.
- package/README.md +40 -3
- package/build/analytics.d.ts +74 -0
- package/build/index.cjs +885 -16
- package/build/index.cjs.map +4 -4
- package/build/index.d.ts +62 -7
- package/build/index.js +885 -16
- package/build/index.js.map +4 -4
- package/build/traqio.min.js +1 -1
- package/build/traqio.min.js.map +4 -4
- package/build/vitals.d.ts +58 -0
- package/package.json +2 -2
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface WebVitalsOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The share of page loads measured, 0–1. Default 0.5: half the loads is plenty for a
|
|
4
|
+
* stable p75 on a busy page and still readable on a small site; lower it on a site
|
|
5
|
+
* with millions of views, 1 to measure every load.
|
|
6
|
+
*/
|
|
7
|
+
sampleRate?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const DEFAULT_VITALS_SAMPLE_RATE = 0.5;
|
|
10
|
+
export interface VitalsSnapshot {
|
|
11
|
+
lcp?: number;
|
|
12
|
+
inp?: number;
|
|
13
|
+
cls?: number;
|
|
14
|
+
fcp?: number;
|
|
15
|
+
ttfb?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Whether this page load is measured. A rate outside 0–1 (or not a number) falls back to the default. */
|
|
18
|
+
export declare function sampled(rate: number | undefined, random?: () => number): boolean;
|
|
19
|
+
export declare class VitalsCollector {
|
|
20
|
+
private lcp;
|
|
21
|
+
private fcp;
|
|
22
|
+
private ttfb;
|
|
23
|
+
private clsMax;
|
|
24
|
+
private clsSeen;
|
|
25
|
+
private clsWindow;
|
|
26
|
+
/** The longest interactions, by interactionId: their longest entry. */
|
|
27
|
+
private longest;
|
|
28
|
+
private interactions;
|
|
29
|
+
private inpSeen;
|
|
30
|
+
/** A `largest-contentful-paint` entry: the latest one is the LCP. */
|
|
31
|
+
addLcp(startTime: number): void;
|
|
32
|
+
/** The `first-contentful-paint` paint entry. */
|
|
33
|
+
addFcp(startTime: number): void;
|
|
34
|
+
/** The navigation entry's `responseStart` (minus `activationStart` for a prerendered page). */
|
|
35
|
+
setTtfb(ms: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* A `layout-shift` entry. Shifts right after an input are expected and skipped; the
|
|
38
|
+
* rest are grouped in session windows and CLS is the largest window's sum.
|
|
39
|
+
*/
|
|
40
|
+
addShift(value: number, startTime: number, hadRecentInput: boolean): void;
|
|
41
|
+
/** The browser supports layout shifts: a page that never moved has a CLS of 0, not none. */
|
|
42
|
+
clsObserved(): void;
|
|
43
|
+
/** An `event` (or `first-input`) entry with an interactionId: one interaction's latency. */
|
|
44
|
+
addInteraction(interactionId: number, duration: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* INP: the longest interaction, ignoring one per 50 — the 98th percentile for a busy
|
|
47
|
+
* page, the worst one for an ordinary visit.
|
|
48
|
+
*/
|
|
49
|
+
private inp;
|
|
50
|
+
/** What was measured, rounded: ms for the timings, 4 decimals for CLS. Null when nothing was. */
|
|
51
|
+
snapshot(): VitalsSnapshot | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Wires the observers onto a collector. A page that loaded in the background (opened in a
|
|
55
|
+
* new tab) has no meaningful LCP or FCP — they would measure when the tab was looked at —
|
|
56
|
+
* so those two are only kept when the page started visible, as `web-vitals` does.
|
|
57
|
+
*/
|
|
58
|
+
export declare function watchVitals(c: VitalsCollector): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@traqio/web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Traqio browser SDK — keeps the ad click id (trackID) from the landing URL to the conversion in first-party storage, and sends web events. React, Vue, Angular, vanilla. No fingerprinting.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"esbuild": "^0.28.1",
|
|
46
46
|
"typescript": "^5",
|
|
47
47
|
"vitest": "^4.1.12",
|
|
48
|
-
"@traqio/core": "0.
|
|
48
|
+
"@traqio/core": "0.8.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsc -p tsconfig.build.json && node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/build.ts",
|