astro-webvitalsv0.4.9

Diagnostics

Opt-in attribution, Long Tasks and a retry queue for failed reports.

All enhanced collection features are opt-in.

Diagnostic attribution

attribution adds a compact diagnostic object to LCP, CLS and INP reports: an associated target selector, LCP resource URL, or largest layout-shift details when the browser provides them. It loads the attribution build of web-vitals instead of the standard one.

<WebVitals endpoint="/api/vitals" attribution={true} />

Treat selectors and URLs as telemetry data. Do not enable this blindly on pages that expose personal data in attributes or URLs.

Long Tasks

<WebVitals endpoint="/api/vitals" trackLongTasks={true} />

Supported browsers report individual main-thread tasks of at least 50ms as LongTask entries. This is diagnostic data, not a Core Web Vital.

Reliable delivery

<WebVitals
  endpoint="/api/vitals"
  batchReporting={true}
  batchInterval={5000}
  maxBatchSize={20}
  retryFailedMetrics={true}
/>

The component flushes on visibilitychange and pagehide and prefers sendBeacon. The optional retry queue keeps at most 50 failed entries in localStorage and sends them on a later page load; it only applies to fetch requests and is disabled by default.

Soft navigations

trackSoftNavigations includes soft navigations reported by the browser, an experimental feature of web-vitals. Leave it off unless you are testing it.

Consent and Do Not Track are covered in Privacy.

Edit this page on GitHub · Docs for v0.4.9