Skip to content

Commit 200939e

Browse files
committed
add request handler logic
1 parent 4074413 commit 200939e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/cloudflare/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@ export const onRequest = Sentry.sentryPagesPlugin(context => ({
8282
}));
8383
```
8484

85+
If you do not have access to the `onRequest` middleware API, you can use the `wrapRequestHandler` API instead.
86+
87+
Here is an example with SvelteKit:
88+
89+
```javascript
90+
// hooks.server.js
91+
import * as Sentry from '@sentry/cloudflare';
92+
93+
export const handle = ({ event, resolve }) => {
94+
const requestHandlerOptions = {
95+
options: {
96+
dsn: event.platform.env.SENTRY_DSN,
97+
tracesSampleRate: 1.0,
98+
},
99+
request: event.request,
100+
context: event.platform.ctx,
101+
}
102+
return Sentry.wrapRequestHandler(requestHandlerOptions, () => resolve(event));
103+
};
104+
```
105+
85106
## Setup (Cloudflare Workers)
86107

87108
To use this SDK, wrap your handler with the `withSentry` function. This will initialize the SDK and hook into the

packages/cloudflare/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export {
8888
export { withSentry } from './handler';
8989
export { sentryPagesPlugin } from './pages-plugin';
9090

91+
export { wrapRequestHandler } from './request';
92+
9193
export { CloudflareClient } from './client';
9294
export { getDefaultIntegrations } from './sdk';
9395

0 commit comments

Comments
 (0)