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

JavaScript

Framework-agnostic tracker for Sight — pageviews, custom events, SPA navigation. Ports the inline <script src=".../script.js?k=..."> collector into a real npm package for apps that would rather npm install than paste a <script> tag. Same wire format, same /api/v1/track endpoint on the backend — this is a thin client, not a second implementation of the tracking logic.

Part of Sight, split across repos under the sightapp org — see sightapp/sight-backend's SPEC.md for the full picture. This package is the foundation the framework-specific wrappers (Next.js, Vue, Astro, etc. — see that repo's tasks/plan.md, Track B) build on.

Install

npm install @sightapp/analytics

Usage

import { init, track } from "@sightapp/analytics";

// Call once, as early as possible (app entrypoint / root layout).
// Records the first pageview and patches history.pushState so SPA
// navigations count as pageviews too.
init("pk_your_project_api_key");

// Custom events, anywhere in your app:
track("signup");

Build

npm install
npm run build       # emits dist/{index.js,index.cjs,index.global.js,index.d.ts}
npm run typecheck

Ships ESM, CJS, and an IIFE (dist/index.global.js, global Sight) for plain <script> use without a bundler.

Verified

Smoke-tested against a running sightapp/sight-backend: the built IIFE bundle recorded a real pageview and a custom track() event, both confirmed via GET /api/v1/query/timeseries.

Source repository