Capture & report errors

Use the browser client to report handled errors and finish sending events when the tab hides.

Capture exceptions

Uncaught errors and unhandled rejections report automatically. Call captureException for errors you handle yourself.

try {
  await checkout();
} catch (error) {
  rasputin.captureException(error);
}

Flush pending events

Rasputin sends events in the background. Flush when the tab is hidden so a close or navigation does not drop the last batch. The client also flushes on its own during normal use.

document.addEventListener('visibilitychange', () => {
  if (document.visibilityState === 'hidden') {
    void rasputin.flush();
  }
});

Client options

These are the fields you pass to the browser RasputinInit client. The Vite plugin does not fill them in. Never pass a project API key here.

FieldRequiredWhat it does
dsnRequiredPublic project DSN from project settings. Safe to include in frontend env.
environmentRequiredWhere the error happened, such as production or staging.
releaseRequiredThe Git commit SHA for this build.
enabledOptionalTurns reporting on or off. Defaults to true.
logSuccessOptionalPrints a configuration summary when setup succeeds. Defaults to true.
scrubPIIOptionalWhen true, ingest also redacts personal data such as names, emails, and phone numbers from stored runtime state. Authentication secrets are always redacted. Set to false to keep personal data in captured values. Defaults to true.
installGlobalHandlersOptionalObserve window error and unhandledrejection. Defaults to true.
apiUrlOptionalOverride the API origin from the DSN. Leave unset unless you self-host.