Capture & report errors

Unexpected errors go through SvelteKit hooks. Use the server runtime to report handled errors.

Unexpected errors

Server and client handleError report unexpected failures. Browser hooks also catch window errors and unhandled rejections. error(), redirect(), and fail() are not reported. Server handleError attaches runtime recorder evidence when the recorder is on.

Capture exceptions

Call captureException on the server runtime for handled errors. Pass observation from scope.observeError(error) to attach recorder evidence.

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

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 false; set to true to enable.
scrubPIIBothOptionalRedact common personal data from stored runtime state (default false). Set to true to enable; secrets are always redacted.
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 (on after install).
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.