Capture & report errors

Use the Bun client to report handled errors and finish sending events before short-lived work exits.

Capture exceptions

Uncaught errors are reported automatically. Call captureException for errors you handle yourself. To attach runtime recorder evidence, pass observation from scope.observeError(error).

try {
  await chargeCustomer();
} catch (error) {
  const observation = scope.observeError(error);
  rasputin.captureException(error, { observation });
}

Send pending events before exit

Events send in the background. Call flush before a short-lived process exits. Long-running servers flush on their own.

await rasputin.flush();

Client options

Options for RasputinInit. Source paths are usually inferred from your packages.

FieldRequiredWhat it does
dsnRequiredPublic project DSN from project settings. Used only to send events.
projectApiKeyRequiredSecret project API key for deploy announcement and instrumentation manifest upload.
environmentRequiredWhere the error happened, such as production or staging.
releaseRequiredThe Git commit SHA for this deployment.
moduleUrlOptionalHelps normalize local stack paths. Use import.meta.url.
repoRootOptionalA local filesystem display root. It does not control source identity.
sourceRootOptionalThe Git folder for a single-package service when automatic matching is ambiguous.
sourceRootsOptionalPackage-name to Git-folder mappings for an ambiguous monorepo.
enabledOptionalTurns reporting on or off. Defaults to true.
logSuccessOptionalPrints a configuration summary when setup succeeds. Defaults to true.
scrubPIIOptionalRedact common personal data from stored runtime state (default true). Secrets are always redacted.
executionRecorderOptionalTurns on the runtime recorder (arguments, returns, call history on errors).