Skip to content

Commit 4261611

Browse files
authored
fix(cloudflare): Move onRequest snippet to Cloudflare Pages (#15837)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR The snippet was in the wrong section as it is not relevant for Cloudflare Workers but for Cloudflare Pages instead. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [x] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent a204aac commit 4261611

File tree

1 file changed

+22
-22
lines changed
  • docs/platforms/javascript/guides/cloudflare

1 file changed

+22
-22
lines changed

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,6 @@ The main Sentry configuration should happen as early as possible in your app's l
5151
platform="javascript.cloudflare.workers"
5252
/>
5353

54-
<Expandable title="Don't have access to onRequest?">
55-
If you don't have access to the `onRequest` middleware API, you can use the `wrapRequestHandler` API instead. For example:
56-
57-
```javascript
58-
// hooks.server.js
59-
import * as Sentry from "@sentry/cloudflare";
60-
61-
export const handle = ({ event, resolve }) => {
62-
const requestHandlerOptions = {
63-
options: {
64-
dsn: event.platform.env.SENTRY_DSN,
65-
tracesSampleRate: 1.0,
66-
},
67-
request: event.request,
68-
context: event.platform.ctx,
69-
};
70-
return Sentry.wrapRequestHandler(requestHandlerOptions, () => resolve(event));
71-
};
72-
```
73-
74-
</Expandable>
75-
7654
### Setup for Cloudflare Pages
7755

7856
To use the Sentry SDK, add the `sentryPagesPlugin` as [middleware to your Cloudflare Pages application](https://developers.cloudflare.com/pages/functions/middleware/).
@@ -112,6 +90,28 @@ export const onRequest = [
11290
];
11391
```
11492

93+
<Expandable title="Don't have access to onRequest?">
94+
If you don't have access to the `onRequest` middleware API, you can use the `wrapRequestHandler` API instead. For example:
95+
96+
```javascript
97+
// hooks.server.js
98+
import * as Sentry from "@sentry/cloudflare";
99+
100+
export const handle = ({ event, resolve }) => {
101+
const requestHandlerOptions = {
102+
options: {
103+
dsn: event.platform.env.SENTRY_DSN,
104+
tracesSampleRate: 1.0,
105+
},
106+
request: event.request,
107+
context: event.platform.ctx,
108+
};
109+
return Sentry.wrapRequestHandler(requestHandlerOptions, () => resolve(event));
110+
};
111+
```
112+
113+
</Expandable>
114+
115115
## Step 3: Add Readable Stack Traces With Source Maps (Optional)
116116

117117
<PlatformContent includePath="getting-started-sourcemaps-short-version" />

0 commit comments

Comments
 (0)