Skip to content

Commit 849c7f1

Browse files
authored
feat(cloudflare): Document wrapRequestHandler (#13317)
1 parent 9f664fa commit 849c7f1

File tree

1 file changed

+19
-0
lines changed
  • docs/platforms/javascript/guides/cloudflare

1 file changed

+19
-0
lines changed

docs/platforms/javascript/guides/cloudflare/index.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,25 @@ export default Sentry.withSentry(
105105
);
106106
```
107107

108+
If you do not have access to the `onRequest` middleware API, you can use the `wrapRequestHandler` API instead. For example:
109+
110+
```javascript
111+
// hooks.server.js
112+
import * as Sentry from '@sentry/cloudflare';
113+
114+
export const handle = ({ event, resolve }) => {
115+
const requestHandlerOptions = {
116+
options: {
117+
dsn: event.platform.env.SENTRY_DSN,
118+
tracesSampleRate: 1.0,
119+
},
120+
request: event.request,
121+
context: event.platform.ctx,
122+
};
123+
return Sentry.wrapRequestHandler(requestHandlerOptions, () => resolve(event));
124+
};
125+
```
126+
108127
## Add Readable Stack Traces to Errors
109128

110129
Depending on how you've set up your project, the stack traces in your Sentry errors probably don't look like your actual code.

0 commit comments

Comments
 (0)