Skip to main content
Proliferate provides both automatic and manual error capture to ensure you never miss critical issues in your application.

Automatic Error Capture

Once the SDK is initialized, unhandled errors are automatically captured without any additional code.
The JavaScript SDK automatically captures:
  • Uncaught exceptions via window.onerror
  • Unhandled promise rejections via window.onunhandledrejection
import Proliferate from '@proliferate/sdk';

Proliferate.init({
  endpoint: 'https://api.proliferate.com/api/v1/errors',
  apiKey: 'pk_your_api_key',
  environment: 'production',
});

// These will be automatically captured:
throw new Error('This error is caught automatically');

Promise.reject(new Error('Unhandled rejection'));

Manual Error Capture

For errors you catch and handle yourself, use the manual capture methods.
import Proliferate from '@proliferate/sdk';

try {
  await riskyOperation();
} catch (error) {
  // Capture the error with optional extra context
  const eventId = Proliferate.captureException(error, {
    extra: {
      operation: 'riskyOperation',
      userId: currentUser.id,
    },
  });

  console.log(`Error reported with ID: ${eventId}`);
}

Capturing Messages

Sometimes you want to report an issue that isn’t an exception. Use message capture for these cases.
import Proliferate from '@proliferate/sdk';

// Report a warning
Proliferate.captureMessage('Payment gateway timeout', {
  level: 'warning',
  extra: {
    gateway: 'stripe',
    timeout_ms: 5000,
  },
});

// Report an informational event
Proliferate.captureMessage('User upgraded to premium', {
  level: 'info',
  extra: {
    plan: 'premium',
    previous_plan: 'free',
  },
});
Available levels: error, warning, info

Event IDs

Both captureException() and captureMessage() return a unique event ID (UUID). This is useful for:
  • Customer support: Include in error messages so users can reference specific issues
  • Logging: Correlate your logs with Proliferate events
  • Debugging: Quickly find specific errors in the dashboard
try {
  await processPayment(order);
} catch (error) {
  const eventId = Proliferate.captureException(error);

  // Show to the user
  showError(`Payment failed. Reference: ${eventId}`);

  // Log for your records
  console.error(`Payment error ${eventId}:`, error);
}

Extra Context

Add arbitrary data to individual error captures using the extra option:
Proliferate.captureException(error, {
  extra: {
    orderId: order.id,
    cartItems: cart.items.length,
    paymentMethod: 'card',
    userAgent: navigator.userAgent,
    viewport: {
      width: window.innerWidth,
      height: window.innerHeight,
    },
  },
});
This extra context appears in the error detail view, helping you understand the exact state when the error occurred.

Re-entrancy Protection

The JavaScript SDK includes built-in protection against infinite loops. If an error occurs while the SDK is already processing an error (e.g., a network failure while sending an error report), it will be silently ignored to prevent cascading failures.

Best Practices

Let automatic capture handle unhandled errors. Only manually capture errors you explicitly handle.
Include relevant business data (order IDs, user IDs, feature flags) that will help you debug.
Use error for actual errors, warning for concerning but non-critical issues, and info for notable events.
Store event IDs in your logs or show them to users for support reference.
Call setUser() and setAccount() to automatically include user information with every error. See the Context documentation.