Proliferate browser SDK for exception monitoring
npm install @proliferate_ai/browserMinimal, production-grade browser SDK for exception monitoring. Zero dependencies, TypeScript-first, crash-proof.
``bash`
npm install @proliferate_ai/browseror
yarn add @proliferate_ai/browseror
pnpm add @proliferate_ai/browser
The build plugin automatically injects the release ID from your git SHA:
`bash`
npm install @proliferate_ai/build-plugins --save-dev
See @proliferate_ai/build-plugins for setup instructions.
`typescript
import { init } from '@proliferate_ai/browser';
init({
dsn: 'https://api.proliferate.dev/v1/errors',
apiKey: 'pk_live_your_api_key_here',
// release is auto-detected if using @proliferate_ai/build-plugins
});
`
Or with manual release ID:
`typescript`
init({
dsn: 'https://api.proliferate.dev/v1/errors',
apiKey: 'pk_live_your_api_key_here',
release: 'v1.2.3', // or git SHA
});
- Automatic error capture: Catches uncaught exceptions and unhandled promise rejections
- Manual capture: Report caught errors from try/catch blocks
- User context: Associate errors with users
- Tags: Categorize errors with custom tags
- Crash-proof: SDK errors never crash your application
- SSR-safe: Works with Next.js, Remix, and other SSR frameworks
- Tiny bundle: < 5KB gzipped, zero dependencies
Initialize the SDK. Call this once at application startup.
`typescript`
interface InitOptions {
/* API endpoint for sending error events. /
dsn: string;
/* API key for authentication (starts with pk_live_ or pk_test_). /
apiKey: string;
/* Release ID for source map resolution. Auto-detected if using build plugins. /
release?: string;
/* Environment name (e.g., 'production', 'staging'). Defaults to 'production'. /
environment?: string;
}
Manually capture an exception.
`typescript
import { captureException } from '@proliferate_ai/browser';
try {
await riskyOperation();
} catch (error) {
captureException(error, {
tags: { feature: 'checkout' },
});
}
`
Set user context for all future error reports.
`typescript
import { setUser } from '@proliferate_ai/browser';
// After login
setUser({
id: 'user_123',
email: 'user@example.com',
});
// After logout
setUser(null);
`
Set a tag for all future error reports.
`typescript
import { setTag } from '@proliferate_ai/browser';
setTag('feature', 'checkout');
setTag('env', 'production');
`
Remove a previously set tag.
`typescript
import { removeTag } from '@proliferate_ai/browser';
removeTag('feature');
`
The SDK provides React components for easy integration with React and Next.js apps.
`tsx
// app/layout.tsx
import { Proliferate, ErrorBoundary } from '@proliferate_ai/browser/react';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
$3
Initializes the SDK. Handles client-side initialization automatically (includes
"use client" directive).`tsx
import { Proliferate } from '@proliferate_ai/browser/react'; dsn="https://api.proliferate.dev/v1/errors"
apiKey="pk_live_..."
environment="production" // optional
release="v1.2.3" // optional, auto-detected with build plugins
/>
`$3
Catches React render errors and reports them to Proliferate.
`tsx
import { ErrorBoundary } from '@proliferate_ai/browser/react'; fallback={ }
onError={(error, info) => console.error('Caught:', error)} // optional
captureContext={{ tags: { component: 'checkout' } }} // optional
>
`$3
If you're not using React, or need manual control:
`typescript
import { init } from '@proliferate_ai/browser';init({
dsn: 'https://api.proliferate.dev/v1/errors',
apiKey: 'pk_live_your_api_key_here',
});
`Source Maps
For stack traces to be readable, you need to:
1. Use a build plugin to inject the release ID
2. Upload source maps with the same release ID
$3
Install the build plugin package:
`bash
npm install @proliferate_ai/build-plugins --save-dev
`Configure your bundler (see @proliferate_ai/build-plugins):
`javascript
// vite.config.js
import { proliferateVite } from '@proliferate_ai/build-plugins/vite';export default {
plugins: [proliferateVite()],
};
`The plugin automatically:
- Extracts the git SHA
- Injects
__PROLIFERATE_RELEASE__ global
- Logs the release ID during build$3
After building, upload your source maps:
`bash
proliferate sourcemaps upload \
--release $(git rev-parse --short HEAD) \
--path ./dist
``MIT