Web SDK
Browser-side analytics for Pug. Auto-captures page views, clicks, and form interactions; batches events efficiently; and manages identity and sessions.
Package: @poluruprvn/pug-web
Repo: cotton-web-sdk
Transport: Connect RPC over HTTPS
Features
| Feature | Description |
|---|---|
| Auto-tracking | Page views, clicks, scroll, forms, frustration signals |
| Batching | Queue + timer flush with localStorage persistence |
| Identity | identify(), reset(), cross-tab session sync |
| Well-known events | TypeScript types generated from protobuf schemas |
| SPA support | History API hooks for client-side routing |
Quick example
import { init, track, identify } from '@poluruprvn/pug-web'
init('YOUR_PROJECT_ID', {
apiKey: 'YOUR_SDK_API_KEY',
endpoint: 'https://api.pug.sh'
})
track('page_view')
// After sign-in
identify('user-123', { email: 'user@example.com', plan: 'pro' })Integration checklist
- Install package — Installation
- Call
init()at app startup — Initialization - Verify events in Live
- Add custom event tracking — Tracking events
- Wire up identify on sign-in/sign-out — Identity & sessions
- Review auto-trackers — Auto-tracking
Browser support
| Browser | Support |
|---|---|
| Chrome 90+ | Full |
| Firefox 90+ | Full |
| Safari 15+ | Full |
| Edge 90+ | Full |
Requires fetch, localStorage, and HTTPS in production.
Topics
- Installation — npm and framework setup
- Initialization — options, lifecycle, SPA
- Tracking events — custom and well-known events
- Identity & sessions — identify, reset, sessions
- Auto-tracking — automatic event capture
- API reference — full function list
Last updated on