Overview
hitIntegration is a lightweight page-view counter. It sends a hit event as soon as it's registered, then another one on every SPA navigation — each history.pushState() call and each popstate (back/forward). history.replaceState() is intentionally not counted: routers use it to normalize URLs in place, which isn't a new visit.
Every hit carries a session id that groups hits into visits. It's kept in localStorage, so it survives reloads and new tabs, and rolls over after 30 minutes of inactivity. If storage is unavailable (private mode, blocked cookies) each hit gets a fresh, unpersisted id.
Usage
ts
import { use } from '@buglapse/browser'
import { hitIntegration } from '@buglapse/browser/integrations'
use(hitIntegration())The integration takes no options.
Custom hits
To count something other than a page view — opening a dialog, starting checkout — send a named hit yourself. It uses the same session id and works whether or not hitIntegration is enabled:
ts
import { hit } from '@buglapse/browser'
hit('checkout-opened')