Agent setup: authorize Sight MCP and ask your agent to call get_tracking_setup. It configures this integration automatically.

Astro

Sight analytics component for Astro — wraps @sightapp/analytics.

Part of Sight — see sightapp/sight-backend SPEC.md and tasks/plan.md (Track B3).

Install

npm install @sightapp/astro

Until both packages are on npm, from sibling checkouts:

npm install file:../sight-js file:../sight-astro

Usage

Drop it once in your layout, inside <body>:

---
import SightAnalytics from "@sightapp/astro/SightAnalytics.astro";
---
<html>
  <body>
    <slot />
    <SightAnalytics apiKey="pk_..." />
  </body>
</html>

How navigation is tracked

  • Plain multi-page Astro site (no <ClientRouter />): every navigation is a full page load, so the component's init() call fires once per real navigation — no extra wiring needed.
  • With <ClientRouter /> (Astro's View Transitions router): Astro dispatches astro:page-load on every transition, including the initial load. This component's init() call already tracks that initial load, so the first astro:page-load firing is deliberately skipped to avoid double-counting page 1 — every transition after that is tracked.

Not independently re-verified this session against a live Astro app with View Transitions enabled — the guard logic is written directly from Astro's documented astro:page-load behavior. Worth a smoke test before depending on it for SPA-style navigation counts in production.

Verify

Serve a page with the component installed and confirm a pageview lands:

curl -s "https://api.usesight.dev/api/v1/query/timeseries?event_name=pageview&days=1" \
  -H "X-API-Key: YOUR_API_KEY"

Source repository