You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cloudflare): Add plugin for cloudflare pages (#13123)
Before reviewing this change, I recommend reading through a GH discussion I
wrote up that explains the reasoning behind the API surface of the
cloudflare SDK:
#13007
This PR adds support for [Cloudflare
Pages](https://developers.cloudflare.com/pages/), Cloudflare's fullstack
development deployment platform that is powered by Cloudflare Workers
under the hood. Think of this platform having very similar capabilities
(and constraints) as Vercel.
To set the plugin up, you do something like so:
```javascript
// functions/_middleware.js
import * as Sentry from '@sentry/cloudflare';
export const onRequest = Sentry.sentryPagesPlugin({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
});
```
We have to use the middleware instead of a global init because we need
to call `init` for every single new incoming request to make sure the
sentry instance does not get stale with redeployments.
While implementing `sentryPagesPlugin`, I noticed that there was a logic
that was redundant between it and `withSentry`, the API for cloudflare
workers.
This led me to refactor this into a common helper, `wrapRequestHandler`,
which is contained in `packages/cloudflare/src/request.ts`. That is why
there is diffs in this PR for `packages/cloudflare/src/handler.ts`.
0 commit comments