Capture & report errors

Unexpected errors go through SvelteKit hooks. Use the server runtime to report handled errors and to flush events before short-lived work exits.

Unexpected errors

handleError on the server and the client reports unexpected failures. Event-handler and other non-load browser throws are reported via window error and unhandledrejection listeners that rasputinClientHooks installs by default. SvelteKit expected failures — error(), redirect(), and fail() — are not reported. Server handleError already calls observeError so runtime recorder evidence is attached when the recorder is on.

Capture exceptions

Keep the node() runtime and call captureException when you catch an error yourself but still want Rasputin to report it. Bare captureException(error) reports the exception only.

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

Send pending events before exit

adapter-node servers flush on shutdown. Call flush yourself before a script or other short-lived process exits.

await server.flush();

Client and server options

Server fields go to node(). Client fields go to rasputinClientHooks. Never pass a project API key to client hooks.

FieldWhereRequiredWhat it does
dsnBothRequiredPublic project DSN from project settings. Used only to send events.
projectApiKeyServerRequiredSecret project API key for deploy announcement and instrumentation manifest upload. Never pass this to client hooks.
environmentBothRequiredWhere the error happened, such as production or staging.
releaseBothRequiredThe Git commit SHA for this deployment. Use the same SHA on the Vite plugin.
enabledBothOptionalTurns reporting on or off. Defaults to true.
logSuccessBothOptionalPrints a configuration summary when setup succeeds. Defaults to true.
installGlobalHandlersBothOptionalOn the client, watch window error and unhandledrejection (default on). On the server, watch process failures (default off).
executionRecorderServerOptionalLimits and redaction for the runtime recorder. Recording is on once the Vite plugin and server hooks are in place.
moduleUrlServerOptionalHelps normalize local stack paths. Use import.meta.url.
sourceRootServerOptionalThe Git folder for a single-package service when automatic matching is ambiguous.
sourceRootsServerOptionalPackage-name to Git-folder mappings for an ambiguous monorepo.
apiUrlBothOptionalOverride the API origin from the DSN. Leave unset unless you self-host.