featurely-error-tracker
Automatic error tracking with breadcrumbs, device info, session replay, and toast notifications.
featurely-error-tracker
Installation
npm install featurely-error-trackerFeatures
- Automatic error tracking with global handlers
- Breadcrumb tracking — records last 50 user actions
- Session replay — rrweb recording of the last 60 seconds, linked to the captured error
- Device and browser information collection
- Network conditions tracking
- User context association
- Toast notifications
- Performance monitoring — page load, Web Vitals (LCP, FCP)
- Offline queue — store errors when offline, send when reconnected
- PII scrubbing — automatically remove sensitive data (emails, cards, SSNs)
- Framework integrations: React Error Boundary, Vue
app.config.errorHandler, AngularErrorHandler - TypeScript support
Configuration options
| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | API key with errors:write permission |
environment | "development" | "staging" | "production" | No | Environment tag attached to every error |
appVersion | string | No | Application version string |
releaseId | string | No | Release ID (e.g. git commit hash) |
apiUrl | string | No | Custom API endpoint (default: https://www.featurely.no/api/public/v1/errors) |
maxBreadcrumbs | number | No | Max breadcrumbs retained per session. Default: 50 |
enabled | boolean | No | Master on/off switch. Default: true |
sampleRate | number | No | Fraction of errors to send (0.0–1.0). Default: 1.0 |
beforeSend | (event: ErrorPayload) => ErrorPayload | null | No | Mutate or drop any event before sending |
toast | ToastConfig | No | In-page toast notifications (enabled, position, duration, showOnAutoCapture) |
performance | PerformanceConfig | No | Web Vitals and page load tracking |
offline | OfflineConfig | No | Queue errors when offline (enabled, maxQueueSize, storage) |
privacy | PrivacyConfig | No | PII scrubbing and query param redaction |
onError | (error: Error) => void | No | Called when the SDK itself fails |
projectId | string | No | Your project ID — required when enableSessionReplay is true |
enableSessionReplay | boolean | No | Record rrweb session replay and attach it to captured errors. Default: false |
Basic usage
import { ErrorTracker } from 'featurely-error-tracker';
const tracker = new ErrorTracker({
apiKey: 'ft_live_your_api_key_here',
environment: 'production',
appVersion: '1.0.0',
sampleRate: 0.1,
beforeSend: (event) => {
if (event.url?.includes('/healthcheck')) return null;
return event;
},
privacy: {
scrubPII: true,
scrubQueryParams: ['token', 'apiKey', 'password'],
},
});
tracker.install();
tracker.setUser(user.id, user.email);Manual error reporting
try {
await riskyOperation();
} catch (error) {
await tracker.reportError(error, 'high', {
userId: user.id,
action: 'risky_operation'
});
}Toast notifications
Toast notifications can appear in the page when an error is captured. Configure the toast option:
const tracker = new ErrorTracker({
apiKey: 'ft_live_your_api_key_here',
toast: {
enabled: true,
position: 'bottom-right',
duration: 5000,
showOnAutoCapture: true,
},
});Available positions: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right
Toast styles: error (red), warning (orange), success (green), info (blue)
Environment support
| Environment | Support | Notes |
|---|---|---|
| Browser | Full | window.onerror, unhandledrejection, Web Vitals, toast UI |
| Node.js | Partial | Manual reportError() and breadcrumbs; no DOM features or Web Vitals |
| React Server Components | Partial | Use reportError() server-side; skip install() |
| Edge / Workers | Manual only | Manual reporting only; no global handlers |
Server-side error filtering
In addition to the SDK-side beforeSend hook and sampleRate, Featurely supports server-side filter rules that drop noisy errors before they are stored. Errors matching a filter rule are silently discarded at ingestion — they are never counted, never stored, and never trigger notifications or webhooks.
Configure rules in the dashboard under Errors → Settings. Each rule has:
| Field | Description |
|---|---|
| Match type | equals (exact match), contains (substring), or regex |
| Value | The string or pattern to match against the error message |
| Stack contains | Optional — only drop if the stack trace also contains this string |
| Require no stack | Optional — only drop if the error has no stack trace |
Sixteen default rules are pre-loaded to suppress common noise such as browser extension errors, ResizeObserver loop warnings, Script error. (cross-origin), and network-related fetch failures. You can toggle any rule on or off and add custom rules for your specific application.
Session replay
When enableSessionReplay: true is set, the SDK uses rrweb to continuously record a rolling 60-second window of DOM mutations and user interactions. When an error is successfully reported to Featurely, the buffer is flushed immediately and linked directly to that specific error by its ID.
The recording appears in the Timeline → Session Replay tab of the error detail view in your dashboard.
import { ErrorTracker } from 'featurely-error-tracker';
const tracker = new ErrorTracker({
apiKey: 'ft_live_your_api_key_here',
projectId: 'your-project-id', // required for session replay
environment: 'production',
enableSessionReplay: true,
});
tracker.install();Privacy controls — wrap any element in the ft-no-record CSS class to prevent it from being captured. Password inputs are masked automatically.
<div class="ft-no-record">
<!-- sensitive content — never recorded -->
</div>Performance — rrweb is loaded lazily via a dynamic import, so it does not increase your initial bundle size. Mousemove events are sampled at 50 ms intervals and scroll events at 150 ms to reduce recording volume.
TypeScript exports
ErrorTrackerConfig, ToastConfig, PerformanceConfig, OfflineConfig, PrivacyConfig, ToastOptions, ErrorPayload, ToastPosition, ToastStyle