open-index/open-npm huggingface dataset:
npm package: @proliferateai/sdk
Description: Proliferate Error Monitoring SDK for JavaScript with Session Replay
Latest version: 0.2.5

# @proliferate/sdk

JavaScript SDK for Proliferate Error Monitoring.

## Installation

```bash
npm install @proliferate/sdk
```

## Quick Start

```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',
});
```

## Automatic Error Capture

After initialization, the SDK automatically captures:
- Uncaught exceptions (`window.onerror`)
- Unhandled promise rejections (`window.onunhandledrejection`)

## Manual Error Capture

```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' },
});
```

## API

### `Proliferate.init(options)`

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`)
- Revoked keys will return a `401 Unauthorized` error with message "API key has been revoked"
- You can manage API keys from the dashboard under Project Settings > API Keys

### `Proliferate.setUser(user)`

Set user context for error reports.

```typescript
Proliferate.setUser({ id: 'user_123', email: 'user@example.com' });
Proliferate.setUser(null); // Clear user context
```

### `Proliferate.setAccount(account)`

Set account context for error reports.

```typescript
Proliferate.setAccount({ id: 'acct_456', name: 'Acme Corp' });
Proliferate.setAccount(null); // Clear account context
```

### `Proliferate.captureException(error, options?)`

Manually capture an exception.

```typescript
Proliferate.captureException(new Error('Something went wrong'), {
  extra: { additionalData: 'value' },
});
```

### `Proliferate.captureMessage(message, options?)`

Capture a message (not an exception).

```typescript
Proliferate.captureMessage('Something happened', {
  level: 'warning', // 'error' | 'warning' | 'info'
  extra: { context: 'value' },
});
```

## Browser Support

- Chrome, Firefox, Safari, Edge (modern versions)
- Uses `fetch` with `keepalive` for reliable delivery
- Falls back to `navigator.sendBeacon` if needed