Capture & report errors

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

Capture exceptions

Rasputin captures uncaught errors automatically. Use captureException when you catch an error yourself but still want Rasputin to report it. It accepts any thrown value and never throws. Bare captureException(error) reports the exception only. To attach runtime recorder evidence, pass observation from scope.observeError(error).

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

Send pending events before exit

Rasputin sends events in the background. A script or serverless function can finish before that happens, so call flush before it exits. Long-running servers flush automatically.

await rasputin.flush();

Client options

These are the fields you can pass to the RasputinInit client. Rasputin discovers source from package boundaries; root settings are optional.

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.
executionRecorderOptionalOptional. Does not change basic error reporting. Enables the runtime recorder so errors can include arguments, return values, and call history from the failing work.