Proliferate Error Monitoring SDK for JavaScript with Session Replay
npm install @proliferateai/sdkJavaScript SDK for Proliferate Error Monitoring.
``bash`
npm install @proliferate/sdk
`typescript
import Proliferate from '@proliferate/sdk';
// Initialize the SDK
Proliferate.init({
endpoint: 'https://your-api.com/api/v1/errors',
apiKey: 'pk_your_api_key',
environment: 'production',
release: '1.0.0',
});
// Set user context (optional)
Proliferate.setUser({
id: 'user_123',
email: 'user@example.com',
});
// Set account context (optional)
Proliferate.setAccount({
id: 'acct_456',
name: 'Acme Corp',
});
`
After initialization, the SDK automatically captures:
- Uncaught exceptions (window.onerror)window.onunhandledrejection
- Unhandled promise rejections ()
`typescript
// Capture an exception
try {
riskyOperation();
} catch (error) {
Proliferate.captureException(error, {
extra: { orderId: 'order_789' },
});
}
// Capture a message
Proliferate.captureMessage('User attempted invalid action', {
level: 'warning',
extra: { action: 'delete_admin' },
});
`
Initialize the SDK.
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| endpoint | string | Yes | API endpoint URL |apiKey
| | string | Yes | Project API key (format: pk_{project_slug}_{random}) |environment
| | string | No | Environment name |release
| | string | No | Release version |
API Key Notes:
- API keys are project-scoped. Each project can have multiple API keys.
- Keys follow the format pk_{project_slug}_{random_hex} (e.g., pk_my-app-default_a1b2c3d4e5f6)401 Unauthorized
- Revoked keys will return a error with message "API key has been revoked"
- You can manage API keys from the dashboard under Project Settings > API Keys
Set user context for error reports.
`typescript`
Proliferate.setUser({ id: 'user_123', email: 'user@example.com' });
Proliferate.setUser(null); // Clear user context
Set account context for error reports.
`typescript`
Proliferate.setAccount({ id: 'acct_456', name: 'Acme Corp' });
Proliferate.setAccount(null); // Clear account context
Manually capture an exception.
`typescript`
Proliferate.captureException(new Error('Something went wrong'), {
extra: { additionalData: 'value' },
});
Capture a message (not an exception).
`typescript`
Proliferate.captureMessage('Something happened', {
level: 'warning', // 'error' | 'warning' | 'info'
extra: { context: 'value' },
});
- Chrome, Firefox, Safari, Edge (modern versions)
- Uses fetch with keepalive for reliable deliverynavigator.sendBeacon` if needed
- Falls back to