Bugshot Browser SDK - Real-time error monitoring and session replay
npm install @bugshot/browser-sdkOfficial BugShot SDK for JavaScript/TypeScript applications.


- ✅ Automatic Error Capture - Catches all JavaScript errors automatically
- ✅ Session Replay - Records user actions before errors occur
- ✅ Source Maps Support - De-minify production errors
- ✅ Breadcrumbs - Track user interactions leading to errors
- ✅ Custom Context - Add tags, user info, and metadata
- ✅ TypeScript Support - Full type definitions included
- ✅ Zero Dependencies - Lightweight and fast
- ✅ CDN Support - Use via CDN without npm
``bash`
npm install @bugshot/browser-sdk
`bash`
yarn add @bugshot/browser-sdk
`html`
`typescript
import BugShot from '@bugshot/browser-sdk';
BugShot.init({
apiKey: 'your-api-key-here',
environment: 'production',
release: '1.0.0'
});
`
`typescript
BugShot.init({
// Required
apiKey: 'your-api-key-here',
// Optional
endpoint: 'https://bugshot-api.log8.kr', // Default
environment: 'production', // 'development', 'staging', etc.
release: '1.0.0', // Your app version
enableSessionReplay: true, // Record user sessions
enableAutoCapture: true, // Auto-capture errors
sampleRate: 1.0, // 0.0 to 1.0 (100% = capture all errors)
debug: false, // Enable debug logs
// Hooks
beforeSend: (error) => {
// Modify or filter errors before sending
if (error.message.includes('ignore')) {
return null; // Don't send this error
}
return error;
},
// User info
user: {
id: '12345',
email: 'user@example.com',
username: 'john_doe'
}
});
`
`typescript`
try {
riskyOperation();
} catch (error) {
BugShot.captureError(error);
}
`typescript`
BugShot.captureMessage('User clicked checkout button', 'info');
BugShot.captureMessage('Payment failed', 'error');
`typescript`
BugShot.setUser({
id: '12345',
email: 'user@example.com',
username: 'john_doe',
plan: 'premium'
});
`typescript`
BugShot.setContext('purchase_id', 'order-123');
BugShot.setContext('cart_value', 99.99);
`html
`
Session replay is enabled by default and records:
- Click events
- Input changes (excluding passwords)
- Navigation events
- Page views
`typescript`
// Clear replay data
BugShot.clearReplay();
`typescript
BugShot.init({
beforeSend: (error) => {
// Ignore errors from extensions
if (error.file?.includes('chrome-extension://')) {
return null;
}
// Add extra context
error.customData = {
timestamp: Date.now(),
viewport: window.innerWidth + 'x' + window.innerHeight
};
return error;
}
});
`
Reduce data volume by sampling errors:
`typescript`
BugShot.init({
sampleRate: 0.5 // Only send 50% of errors
});
- React - Error Boundary and Hooks
- Vue - Coming soon
- Angular - Coming soon
- Next.js - Coming soon
Parameters:
- config (object): Configuration options
Returns: BugShotClient
Parameters:
- error (Error | string): Error object or messageadditionalInfo
- (object, optional): Extra context
Parameters:
- message (string): Message textlevel
- ('info' | 'warning' | 'error'): Severity level
Parameters:
- user (object): User data
Parameters:
- key (string): Context keyvalue
- (any): Context value
Enable debug mode to see SDK logs:
`typescript``
BugShot.init({
debug: true,
apiKey: 'your-api-key'
});
MIT © BugShot Team
- Documentation
- Dashboard
- GitHub
- NPM