Skip to content

Commit 8548aeb

Browse files
author
Luca Forstner
authored
Add back tRPC middleware/integration (#10410)
1 parent 60ecf07 commit 8548aeb

File tree

10 files changed

+66
-0
lines changed

10 files changed

+66
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: trpcMiddleware
3+
description: "Capture spans & errors for tRPC handlers."
4+
supported:
5+
- javascript.node
6+
- javascript.aws-lambda
7+
- javascript.azure-functions
8+
- javascript.connect
9+
- javascript.express
10+
- javascript.fastify
11+
- javascript.gcp-functions
12+
- javascript.hapi
13+
- javascript.koa
14+
- javascript.nestjs
15+
- javascript.electron
16+
- javascript.nextjs
17+
- javascript.sveltekit
18+
- javascript.remix
19+
- javascript.astro
20+
- javascript.bun
21+
---
22+
23+
<Alert level="info">
24+
25+
This integration only works inside server environments (Node.js, Bun, Deno).
26+
27+
</Alert>
28+
29+
_Import name: `Sentry.trpcMiddleware`_
30+
31+
The Sentry tRPC middleware creates spans for your and improves error capturing for tRPC handlers.
32+
33+
The `trpcMiddleware` is not a traditional SDK integration in the sense that your are **not** supposed to add it to the `integrations` option.
34+
Instead, add it as a middleware to your tRPC router.
35+
36+
```javascript
37+
import * as Sentry from "@sentry/node";
38+
import { initTRPC } from "@trpc/server";
39+
40+
const t = initTRPC.context().create();
41+
42+
const sentryMiddleware = t.middleware(
43+
Sentry.trpcMiddleware({
44+
attachRpcInput: true,
45+
})
46+
);
47+
48+
const sentrifiedProcedure = t.procedure.use(sentryMiddleware);
49+
```
50+
51+
## Options
52+
53+
### `attachRpcInput`
54+
55+
_Type: `boolean`_
56+
57+
Defaults to `false`. If enabled, the RPC input will be captured in reported events.

platform-includes/configuration/integrations/javascript.astro.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ Depending on whether an integration enhances the functionality of a particular r
6161
| [`anrIntegration`](./anr) | || | |
6262
| [`localVariablesIntegration`](./localvariables) | || | |
6363
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
64+
| [`trpcMiddleware`](./trpc) | ||||

platform-includes/configuration/integrations/javascript.aws-lambda.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@
3333
| [`requestDataIntegration`](./requestdata) | | || |
3434
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
3535
| [`sessionTimingIntegration`](./sessiontiming) | | | ||
36+
| [`trpcMiddleware`](./trpc) | ||||

platform-includes/configuration/integrations/javascript.bun.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@
2929
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
3030
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
3131
| [`sessionTimingIntegration`](./sessiontiming) | | | ||
32+
| [`trpcMiddleware`](./trpc) | ||||

platform-includes/configuration/integrations/javascript.deno.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
| [`extraErrorDataIntegration`](./extraerrordata) | | | | ||
1717
| [`rewriteFramesIntegration`](./rewriteframes) | || | | |
1818
| [`sessionTimingIntegration`](./sessiontiming) | | | | ||
19+
| [`trpcMiddleware`](./trpc) | ||| ||

platform-includes/configuration/integrations/javascript.gcp-functions.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@
3333
| [`requestDataIntegration`](./requestdata) | | || |
3434
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
3535
| [`sessionTimingIntegration`](./sessiontiming) | | | ||
36+
| [`trpcMiddleware`](./trpc) | ||||

platform-includes/configuration/integrations/javascript.nextjs.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Depending on whether an integration enhances the functionality of a particular r
6767
| [`anrIntegration`](./anr) | || | |
6868
| [`localVariablesIntegration`](./localvariables) | || | |
6969
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
70+
| [`trpcMiddleware`](./trpc) | ||||
7071

7172
### Edge Integrations
7273

platform-includes/configuration/integrations/javascript.node.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
3232
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
3333
| [`sessionTimingIntegration`](./sessiontiming) | | | ||
34+
| [`trpcMiddleware`](./trpc) | ||||

platform-includes/configuration/integrations/javascript.remix.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ Depending on whether an integration enhances the functionality of a particular r
6161
| [`anrIntegration`](./anr) | || | |
6262
| [`localVariablesIntegration`](./localvariables) | || | |
6363
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
64+
| [`trpcMiddleware`](./trpc) | ||||

platform-includes/configuration/integrations/javascript.sveltekit.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ Depending on whether an integration enhances the functionality of a particular r
6161
| [`anrIntegration`](./anr) | || | |
6262
| [`localVariablesIntegration`](./localvariables) | || | |
6363
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
64+
| [`trpcMiddleware`](./trpc) | ||||

0 commit comments

Comments
 (0)