@scoova/monitor-web
v1.5.0
Published
Scoova Monitor Web SDK — Error tracking, analytics, performance, and logging for web apps
Maintainers
Readme
Scoova Monitor — Web SDK
Browser SDK for error tracking, analytics, page-view tracking, network performance, and Web Vitals. Pure TypeScript, no framework deps. ES2020.
Install
NPM (bundled)
npm install @scoova/monitor-webimport { ScoovaMonitor } from '@scoova/monitor-web'
ScoovaMonitor.init('sm_your_api_key')Script tag (CDN)
The published package is served from jsDelivr automatically — no build step:
<script src="https://cdn.jsdelivr.net/npm/@scoova/[email protected]/dist/monitor.js"></script>
<script>ScoovaMonitor.init('sm_your_api_key')</script>Prefer to self-host? Build it (npm run build) and serve dist/monitor.js
from your own domain.
Configuration
ScoovaMonitor.init('sm_your_api_key', {
endpoint: 'https://monitor.scoo-va.info', // self-hosted? change this
enableErrorTracking: true,
enablePerformance: true,
enablePageViews: true,
enableNetworkTracking: true,
enableConsoleErrors: true,
samplingRate: 1.0, // 0.0 – 1.0
flushIntervalMs: 300_000, // 5 minutes
maxBatchSize: 50,
})The Web SDK does not probe for third-party scripts and does not collect location — see the SDK documentation for the full collection inventory.
API
Identify the user
ScoovaMonitor.setUserId('user_123')The user ID is hashed before it leaves the browser. Without setUserId
the SDK falls back to an anonymous installation ID stored in
localStorage.
Track events
ScoovaMonitor.trackEvent('checkout_started', {
plan: 'annual',
amount: '29.99',
})Track page views
Auto-tracked when enablePageViews: true (the default). Manual:
ScoovaMonitor.trackPageView('/checkout')Capture errors
Uncaught errors and unhandled promise rejections are captured automatically
when enableErrorTracking: true. Manual:
try {
await riskyWork()
} catch (e) {
ScoovaMonitor.captureError(e as Error)
}Breadcrumbs
ScoovaMonitor.addBreadcrumb('Started photo upload', 'media')Tagged loggers
const log = ScoovaMonitor.logger('payment')
log.info('Started checkout', { amount: '29.99' })
log.error('Card declined', { code: 'card_declined' })Right-to-erasure (GDPR / CCPA)
ScoovaMonitor.clearLocalUserData()Wipes queued events from localStorage, pending crash payloads,
breadcrumbs, the anonymous installation ID, the session counter, and the
first-launch marker. Pair with a server-side
DELETE /v1/ingest/me/{userId}.
Manual flush
await ScoovaMonitor.flush()The SDK auto-flushes every 5 minutes, on visibilitychange → hidden
(via sendBeacon when available), and when the batch threshold is hit.
Manual flush is rarely needed.
Source maps
For de-obfuscated stack traces in the dashboard, upload your bundle's source maps after each release:
With the package installed, the scoova-upload-sourcemaps CLI is on your
project's path:
npx scoova-upload-sourcemaps \
--api-key sm_your_api_key \
--version 1.0.0 \
--dir ./distSee the SDK documentation for the full setup including CSP allowlists.
Building from source
npm install
npm run build # emits dist/monitor.js