trpcMiddleware

为 tRPC 处理程序捕获跨度和错误。

Import name: Sentry.trpcMiddleware

Sentry 的 tRPC 中间件会为您创建跨度,并改进对 tRPC 处理程序的错误捕获。

trpcMiddleware 并不是一个传统意义上的 SDK 集成,因此您不应该将其添加到 integrations 选项中。相反,应将其作为中间件添加到您的 tRPC 路由器中。

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

默认为 false。如果启用,RPC 输入将在报告的事件中被捕获。