trpcMiddleware

Capture spans & errors for tRPC handlers.

Import name: Sentry.trpcMiddleware

The Sentry tRPC middleware creates spans for your and improves error capturing for tRPC handlers.

The trpcMiddleware is not a traditional SDK integration in the sense that your are not supposed to add it to the integrations option. Instead, add it as a middleware to your tRPC router.

Copied
import * as Sentry from "@sentry/node";
import { initTRPC } from "@trpc/server";

const t = initTRPC.context().create();

const sentryMiddleware = t.middleware(
  Sentry.trpcMiddleware({
    attachRpcInput: true,
  }),
);

const sentrifiedProcedure = t.procedure.use(sentryMiddleware);

Type: boolean

Defaults to false. If enabled, the RPC input will be captured in reported events.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").