webrec-sdk
v1.0.4
Published
WebRec - Session recording SDK
Downloads
38
Readme
webrec-sdk
Session recording, frustration detection, product analytics, heatmaps, and in-app surveys — in a single, privacy-first SDK.
webrec.app · Documentation · Dashboard
Install
npm install webrec-sdkQuick start
import { WebRec } from 'webrec-sdk';
WebRec.init({
apiKey: 'wr_your_project_key',
});That's it. Sessions appear in your Webrec dashboard within seconds.
Identify users
Link sessions to logged-in users:
WebRec.identify('user-123', {
name: 'Jane Doe',
email: '[email protected]',
plan: 'pro',
});Group users by organization
Associate users with a company or team for organization-level analytics:
WebRec.group('org-456', {
name: 'Acme Corp',
domain: 'acme.com',
plan: 'enterprise',
mrr: 15000,
industry: 'SaaS',
});Track custom events
WebRec.track('checkout_completed', {
value: 99.00,
currency: 'USD',
});Script tag
If you're not using a bundler, load the SDK via a script tag:
<script src="https://api.webrec.app/v1/webrec.min.js"></script>
<script>
WebRec.init({ apiKey: 'wr_your_project_key' });
</script>API
| Method | Description |
|---|---|
| WebRec.init(config) | Initialize recording |
| WebRec.identify(userId, traits?) | Link session to a user |
| WebRec.group(groupId, traits?) | Associate user with an organization |
| WebRec.track(event, properties?) | Send a custom event |
| WebRec.stop() | Pause recording |
| WebRec.start() | Resume recording |
| WebRec.destroy() | Full teardown (allows re-init) |
| WebRec.getSessionId() | Get the current session ID |
Configuration
WebRec.init({
apiKey: 'wr_your_project_key',
// Privacy (all inputs masked by default)
maskAllInputs: true,
respectDoNotTrack: true,
// Network & console capture
captureNetwork: true,
captureConsole: true,
captureErrors: true,
// Sampling
sampleRate: 100, // 0-100, percentage of traffic to record
// Session control
sessionTimeout: 1800000, // 30 min inactivity timeout (ms)
minSessionDuration: 0, // Discard sessions shorter than N seconds
// URL filtering
ignoreUrls: ['/admin.*'], // Skip recording on matching URLs
allowUrls: [], // Only record matching URLs (if set)
// Performance
batchSize: 50,
flushInterval: 5000,
// Privacy selectors
blockClass: 'wr-block', // Elements with this class are excluded
ignoreClass: 'wr-ignore', // Elements with this class are not recorded
});Privacy
- All form inputs are masked by default
- Add
wr-blockordata-wr-blockto any element to exclude it from recordings - Respects the browser Do Not Track setting by default
- Call
WebRec.stop()to wait for consent, thenWebRec.start()when granted - GDPR compliant — data hosted in EU (GCP europe-west2)
SDK size
147 KB gzipped. < 1% CPU overhead.
License
MIT
