Skip to content

Commit ebe3a6d

Browse files
committed
docs(js): Move tunneling docs to their own configuration page
Add a Tunneling page under Extended Configuration and move the tunnel content there from Troubleshooting, which now only links to it. Point existing tunneling links at the new page. Also address review feedback on the managed tunnel docs: list serveTunnelIntegration in the server integration tables, add a Fastify example, and tighten the tunnel option wording.
1 parent 3574e32 commit ebe3a6d

39 files changed

Lines changed: 568 additions & 483 deletions

File tree

‎docs/platforms/android/troubleshooting/index.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ If you set up the Sentry SDK and it's not sending any data to Sentry:
199199

200200
- Check that you have configured a DSN and that you are passing it to the `dsn` option in `SentryAndroid.init()` or `AndroidManifest`.
201201
- When a crash happens or the app closes, the system allows only a short time to handle it before terminating the process. The SDK might not have enough time to send the event, spans, profile, or replay data. In these cases, simply relaunching the app should allow the SDK to send the remaining data.
202-
- An ad-blocker (e.g. [DuckDuckGo's App Tracking Protection](https://duckduckgo.com/duckduckgo-help-pages/p-app-tracking-protection/what-is-app-tracking-protection)) or network restrictions might be preventing the SDK from reaching Sentry's servers. As a workaround, you can use [tunneling](/platforms/javascript/troubleshooting/#using-the-tunnel-option) to proxy Sentry events through your own server. Then you can add the [proxy option](/platforms/android/configuration/options/#proxy) to your SDK configuration.
202+
- An ad-blocker (e.g. [DuckDuckGo's App Tracking Protection](https://duckduckgo.com/duckduckgo-help-pages/p-app-tracking-protection/what-is-app-tracking-protection)) or network restrictions might be preventing the SDK from reaching Sentry's servers. As a workaround, you can use [tunneling](/platforms/javascript/configuration/tunneling/) to proxy Sentry events through your own server. Then you can add the [proxy option](/platforms/android/configuration/options/#proxy) to your SDK configuration.
203203
- Set `debug: true` in the `SentryAndroid.init()` or the manifest options and observe your Logcat output when you start your application. The SDK may tell you why it is not sending any data.
204204
- Check the [Stats](https://sentry.io/orgredirect/organizations/:orgslug/stats/) and [Subscription](https://sentry.io/orgredirect/organizations/:orgslug/settings/billing/overview/) pages in Sentry. You may be out of quota.
205205

‎docs/platforms/dotnet/guides/aspnetcore/index.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Opt-in to capture values from [System.Diagnostic.Activity](https://github.com/do
260260

261261
### Tunnel
262262

263-
If events are being logged to Sentry from the client-side, then you should use a [tunnel](/platforms/javascript/troubleshooting/#using-the-tunnel-option).
263+
If events are being logged to Sentry from the client-side, then you should use a [tunnel](/platforms/javascript/configuration/tunneling/).
264264

265265
A tunnel is an HTTP endpoint that acts as a proxy between Sentry and your application. Because you control this server, there is no risk of any requests sent to it being blocked.
266266

docs/platforms/javascript/common/troubleshooting/img/tunnel.png renamed to docs/platforms/javascript/common/configuration/img/tunnel.png

File renamed without changes.

‎docs/platforms/javascript/common/configuration/integrations/servetunnel.mdx‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: ServeTunnel
3-
description: "Serves a tunnel on your server so browser events reach Sentry through your own origin, past ad blockers."
3+
description: "Serves a tunnel on your server so Sentry browser SDK events reach Sentry through your own origin, past ad blockers."
44
supportedCategories:
55
- server
66
notSupported:
@@ -14,6 +14,8 @@ _Import name: `Sentry.serveTunnelIntegration`_
1414

1515
Ad blockers often drop requests to `*.ingest.sentry.io`. With a tunnel on your own origin, the browser SDK sends its events to your server instead, and your server forwards them to Sentry. This integration configures that tunnel on the server.
1616

17+
For an overview of tunneling, including how to set up your own tunnel endpoint, see <PlatformLink to="/configuration/tunneling/">Tunneling</PlatformLink>.
18+
1719
Set it up on both sides. Add the integration to your server `Sentry.init`, and set `tunnel: true` in your browser `Sentry.init`:
1820

1921
```javascript {tabTitle:Server}
@@ -46,13 +48,13 @@ In framework mode, the SDK serves the tunnel from its request hooks, so this is
4648

4749
<PlatformSection supported={["javascript.remix"]}>
4850

49-
On Remix 3, the SDK serves the tunnel from its request hooks, so this is all the setup you need. On earlier versions, [serve it yourself](#serving-the-tunnel-yourself).
51+
On Remix 3, the SDK serves the tunnel from its request hooks, so this is all the setup you need. On earlier versions, you also need to [mount the tunnel handler](#mounting-the-tunnel-handler).
5052

5153
</PlatformSection>
5254

5355
<PlatformSection notSupported={["javascript.sveltekit", "javascript.nuxt", "javascript.nitro", "javascript.astro", "javascript.tanstackstart-react", "javascript.react-router", "javascript.remix"]}>
5456

55-
The integration doesn't handle requests by itself, so you need to [serve the tunnel yourself](#serving-the-tunnel-yourself).
57+
The integration doesn't handle requests by itself, so you also need to [mount the tunnel handler](#mounting-the-tunnel-handler).
5658

5759
</PlatformSection>
5860

@@ -83,7 +85,7 @@ export default Sentry.withSentry(
8385
8486
## How It Works
8587
86-
- Framework SDKs answer tunnel requests before your app's own middleware, so auth or CSRF middleware doesn't block them. When you serve the tunnel yourself, mount it before that middleware too.
88+
- Framework SDKs answer tunnel requests before your app's own middleware, so auth or CSRF middleware doesn't block them. When you mount the tunnel handler yourself, put it before that middleware too.
8789
- It only forwards envelopes whose DSN is allowed. By default, that's the server's own DSN. Other envelopes get a `403`, so the tunnel can't be used as an open proxy.
8890
- It forwards only the user agent, client hint, `Origin`, and `Referer` headers. Cookies and auth headers never reach Sentry. The visitor's IP address is forwarded from the `cf-connecting-ip`, `x-vercel-forwarded-for`, or `x-forwarded-for` header.
8991
- Tunnel requests don't create server spans.
@@ -130,7 +132,7 @@ _Type: `string`_
130132
131133
The path prefix your app is served under, for example `/docs`. The SDK reads it from your framework config, so you only need this option when it can't. Set the same value in the browser `tunnel` option.
132134
133-
## Serving the Tunnel Yourself
135+
## Mounting the Tunnel Handler
134136
135137
On servers without a framework SDK hook, mount `handleTunnelRequestIfMatched` before your routes and body parsers. It forwards tunnel requests and returns `undefined` for everything else:
136138
@@ -145,6 +147,24 @@ app.use(
145147
);
146148
```
147149
150+
```javascript {tabTitle:Fastify}
151+
const Fastify = require("fastify");
152+
const Sentry = require("@sentry/node");
153+
154+
const app = Fastify();
155+
156+
app.addHook("onRequest", async (request, reply) => {
157+
const tunnelResponse = Sentry.handleTunnelRequestIfMatched(
158+
request.raw,
159+
reply.raw
160+
);
161+
if (tunnelResponse) {
162+
await tunnelResponse;
163+
return reply;
164+
}
165+
});
166+
```
167+
148168
```javascript {tabTitle:Fetch API}
149169
export default {
150170
fetch(request) {
@@ -155,9 +175,7 @@ export default {
155175
};
156176
```
157177
158-
`handleTunnelRequestIfMatched` takes a fetch `Request`, or Node's `req` and `res` (in Fastify, `request.raw` and `reply.raw`). It takes the same options as the integration.
159-
160-
Without options, it uses the options of `serveTunnelIntegration`, or the server's own DSN if the integration isn't set up. To check a request without reading its body, use `isTunnelRequest(request)`.
178+
`handleTunnelRequestIfMatched` takes a fetch `Request`, or Node's `req` and `res`, and the same options as the integration. Without options, `handleTunnelRequestIfMatched` uses the options of `serveTunnelIntegration`, or the server's own DSN if the integration isn't set up. To check a request without reading its body, use `isTunnelRequest(request)`.
161179
162180
If you'd rather use a fixed path, register it as a route with `handleTunnelRequest`. Pass the same path to the integration, so tunnel requests don't create server spans:
163181

0 commit comments

Comments
 (0)