Skip to content

Commit f940420

Browse files
docs(cloudflare): several semantic and stylistic fixes in code examples for cloudflare workers (#12482)
* docs(cloudflare): several semantic and stylistic fixes in code examples for cloudflare workers * docs(cloudflare): adjust getting-started with json style wrangler config * fix(cloudflare): fixing typo * Update platform-includes/getting-started-config/javascript.cloudflare.mdx Co-authored-by: Matej Minar <[email protected]> --------- Co-authored-by: Matej Minar <[email protected]>
1 parent 5328a93 commit f940420

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

platform-includes/getting-started-config/javascript.cloudflare.mdx

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
To use the SDK, you'll need to set either the `nodejs_compat` or `nodejs_als` compatibility flags in your `wrangler.toml`. This is because the SDK
1+
To use the SDK, you'll need to set either the `nodejs_compat` or `nodejs_als` compatibility flags in your `wrangler.toml`/`wrangler.json`. This is because the SDK
22
needs access to the `AsyncLocalStorage` API to work correctly.
33

4-
```toml {filename:wrangler.toml}
4+
5+
```toml {tabTitle:Toml} {filename:wrangler.toml}
56
compatibility_flags = ["nodejs_compat"]
67
# compatibility_flags = ["nodejs_als"]
78
```
89

10+
```json {tabTitle:JSON} {filename:wrangler.json}
11+
{
12+
"compatibility_flags": [
13+
"nodejs_compat",
14+
// "nodejs_als"
15+
]
16+
}
17+
```
18+
919
Then you can install the SDK and add it to your project:
1020

1121
You can either setup up the SDK for [Cloudflare Pages](#setup-cloudflare-pages) or
@@ -40,10 +50,10 @@ export const onRequest = [
4050
To use this SDK, wrap your handler with the `withSentry` function. This will initialize the SDK and hook into the
4151
environment. Note that you can turn off almost all side effects using the respective options.
4252

43-
```javascript
44-
import * as Sentry from '@sentry/cloudflare';
53+
```typescript {filename:index.ts}
54+
import * as Sentry from "@sentry/cloudflare";
4555

46-
export default withSentry(
56+
export default Sentry.withSentry(
4757
env => ({
4858
dsn: "___PUBLIC_DSN___",
4959
// Set tracesSampleRate to 1.0 to capture 100% of spans for tracing.
@@ -53,7 +63,7 @@ export default withSentry(
5363
}),
5464
{
5565
async fetch(request, env, ctx) {
56-
return new Response('Hello World!');
66+
return new Response("Hello World!");
5767
},
5868
} satisfies ExportedHandler<Env>,
5969
);

platform-includes/performance/configure-sample-rate/javascript.cloudflare.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export const onRequest = [
1717

1818
## Cloudflare Workers
1919

20-
```javascript {filename:functions/_middleware.js}
21-
import * as Sentry from '@sentry/cloudflare';
20+
```typescript {filename:index.ts}
21+
import * as Sentry from "@sentry/cloudflare";
2222

23-
export default withSentry(
23+
export default Sentry.withSentry(
2424
env => ({
2525
dsn: "___PUBLIC_DSN___",
2626
// To set a uniform sample rate
@@ -31,7 +31,7 @@ export default withSentry(
3131
}),
3232
{
3333
async fetch(request, env, ctx) {
34-
return new Response('Hello World!');
34+
return new Response("Hello World!");
3535
},
3636
} satisfies ExportedHandler<Env>,
3737
);

0 commit comments

Comments
 (0)