Skip to content

Commit 901895d

Browse files
authored
Update cloudflare config snippets to use jsonc (#13257)
* Update cloudflare config snippets to use jsonc * use jsonc everywhere * more re-ordering
1 parent 55e27a2 commit 901895d

File tree

7 files changed

+93
-48
lines changed

7 files changed

+93
-48
lines changed

docs/platforms/javascript/guides/cloudflare/features/d1.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Cloudflare's serverless SQL database with Sentry.
99
```javascript
1010
import * as Sentry from "@sentry/cloudflare";
1111

12-
// env.DB is the D1 DB binding configured in your `wrangler.toml`
12+
// env.DB is the D1 DB binding configured in your `wrangler.jsonc`/`wrangler.toml` config
1313
const db = Sentry.instrumentD1WithSentry(env.DB);
1414
// Now you can use the database as usual
1515
await db.prepare("SELECT * FROM table WHERE id = ?").bind(1).run();

docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,24 @@ After installing the Sentry Astro SDK, you can now install the Sentry Cloudflare
1111

1212
<PlatformContent includePath="getting-started-install" />
1313

14-
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
14+
To use the SDK, you'll need to set either the `nodejs_als` or `nodejs_compat` compatibility flags in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK
1515
needs access to the `AsyncLocalStorage` API to work correctly.
1616

17-
```toml {filename:wrangler.toml}
17+
```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
18+
{
19+
"compatibility_flags": [
20+
"nodejs_als",
21+
// "nodejs_compat"
22+
],
23+
}
24+
```
25+
26+
```toml {tabTitle:Toml} {filename:wrangler.toml}
27+
compatibility_flags = ["nodejs_als"]
28+
# compatibility_flags = ["nodejs_compat"]
29+
```
30+
31+
```toml {tabTitle:Toml} {filename:wrangler.toml}
1832
compatibility_flags = ["nodejs_compat"]
1933
# compatibility_flags = ["nodejs_als"]
2034
```
@@ -30,7 +44,7 @@ export const onRequest = [
3044
dsn: "___PUBLIC_DSN___",
3145
// Set tracesSampleRate to 1.0 to capture 100% of spans for tracing.
3246
// Learn more at
33-
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
47+
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
3448
tracesSampleRate: 1.0,
3549
})),
3650
// Add more middlewares here

docs/platforms/javascript/guides/cloudflare/frameworks/remix.mdx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ Now you can install the Sentry Cloudflare SDK. First, install the SDK with your
2323

2424
<PlatformContent includePath="getting-started-install" />
2525

26-
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
26+
To use the SDK, you'll need to set either the `nodejs_als` or `nodejs_compat` compatibility flags in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK
2727
needs access to the `AsyncLocalStorage` API to work correctly.
2828

29-
```toml {filename:wrangler.toml}
30-
compatibility_flags = ["nodejs_compat"]
31-
# compatibility_flags = ["nodejs_als"]
29+
```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
30+
{
31+
"compatibility_flags": [
32+
"nodejs_als",
33+
// "nodejs_compat"
34+
],
35+
}
36+
```
37+
38+
```toml {tabTitle:Toml} {filename:wrangler.toml}
39+
compatibility_flags = ["nodejs_als"]
40+
# compatibility_flags = ["nodejs_compat"]
3241
```
3342

3443
Then create a `_middleware.js` file in your `functions` directory and add the following code:

docs/platforms/javascript/guides/cloudflare/frameworks/sveltekit.mdx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ If you installed the SDK before, make sure that `@sentry/sveltekit` version `9.2
2323

2424
## 2. Cloudflare configuration
2525

26-
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
26+
To use the SDK, you'll need to set either the `nodejs_als` or `nodejs_compat` compatibility flags in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK
2727
needs access to the `AsyncLocalStorage` API to work correctly.
2828

29-
```toml {filename:wrangler.toml}
30-
compatibility_flags = ["nodejs_compat"]
31-
# compatibility_flags = ["nodejs_als"]
29+
```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
30+
{
31+
"compatibility_flags": [
32+
"nodejs_als",
33+
// "nodejs_compat"
34+
],
35+
}
36+
```
37+
38+
```toml {tabTitle:Toml} {filename:wrangler.toml}
39+
compatibility_flags = ["nodejs_als"]
40+
# compatibility_flags = ["nodejs_compat"]
3241
```
3342

3443
## 3. Update Your Server Hooks File

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Cloudflare
3-
description: 'Official Sentry SDK for Cloudflare Workers and Cloudflare Pages.'
3+
description: "Official Sentry SDK for Cloudflare Workers and Cloudflare Pages."
44
sdk: sentry.javascript.cloudflare
55
categories:
66
- javascript
@@ -11,7 +11,9 @@ categories:
1111

1212
## Install
1313

14-
<OnboardingOptionButtons options={["error-monitoring", "performance", "profiling"]} />
14+
<OnboardingOptionButtons
15+
options={["error-monitoring", "performance", "profiling"]}
16+
/>
1517

1618
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
1719

@@ -35,24 +37,23 @@ pnpm add @sentry/cloudflare
3537

3638
Configuration should happen as early as possible in your application's lifecycle.
3739

38-
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
40+
To use the SDK, you'll need to set either the `nodejs_compat` or `nodejs_als` compatibility flags in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK
3941
needs access to the `AsyncLocalStorage` API to work correctly.
4042

41-
42-
```toml {tabTitle:Toml} {filename:wrangler.toml}
43-
compatibility_flags = ["nodejs_compat"]
44-
# compatibility_flags = ["nodejs_als"]
45-
```
46-
47-
```json {tabTitle:JSON} {filename:wrangler.json}
43+
```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
4844
{
4945
"compatibility_flags": [
50-
"nodejs_compat",
51-
// "nodejs_als"
52-
]
46+
"nodejs_als",
47+
// "nodejs_compat"
48+
],
5349
}
5450
```
5551

52+
```toml {tabTitle:Toml} {filename:wrangler.toml}
53+
compatibility_flags = ["nodejs_als"]
54+
# compatibility_flags = ["nodejs_compat"]
55+
```
56+
5657
Then you can install the SDK and add it to your project:
5758

5859
You can either setup up the SDK for [Cloudflare Pages](#setup-cloudflare-pages) or [Cloudflare Workers](#setup-cloudflare-workers).
@@ -89,7 +90,7 @@ environment. Note that you can turn off almost all side effects using the respec
8990
import * as Sentry from "@sentry/cloudflare";
9091

9192
export default Sentry.withSentry(
92-
env => ({
93+
(env) => ({
9394
dsn: "___PUBLIC_DSN___",
9495
// Set tracesSampleRate to 1.0 to capture 100% of spans for tracing.
9596
// Learn more at
@@ -100,7 +101,7 @@ export default Sentry.withSentry(
100101
async fetch(request, env, ctx) {
101102
return new Response("Hello World!");
102103
},
103-
} satisfies ExportedHandler<Env>,
104+
} satisfies ExportedHandler<Env>
104105
);
105106
```
106107

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

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ In addition to capturing errors, you can monitor interactions between multiple s
2020

2121
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
2222

23-
<OnboardingOptionButtons options={["error-monitoring", "performance", "profiling"]} />
23+
<OnboardingOptionButtons
24+
options={["error-monitoring", "performance", "profiling"]}
25+
/>
2426

2527
## Setup
2628

@@ -40,23 +42,23 @@ yarn add @sentry/cloudflare
4042
pnpm add @sentry/cloudflare
4143
```
4244

43-
To use the SDK, you'll need to set either the `nodejs_compat` or `nodejs_als` compatibility flags in your `wrangler.toml`/`wrangler.json`.
44-
This is because the SDK needs access to the `AsyncLocalStorage` API to work correctly.
45+
To use the SDK, you'll need to set either the `nodejs_als` or `nodejs_compat` compatibility flags in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK
46+
needs access to the `AsyncLocalStorage` API to work correctly.
4547

46-
```toml {tabTitle:Toml} {filename:wrangler.toml}
47-
compatibility_flags = ["nodejs_compat"]
48-
# compatibility_flags = ["nodejs_als"]
49-
```
50-
51-
```json {tabTitle:JSON} {filename:wrangler.json}
48+
```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
5249
{
5350
"compatibility_flags": [
54-
"nodejs_compat"
55-
// "nodejs_als"
56-
]
51+
"nodejs_als",
52+
// "nodejs_compat"
53+
],
5754
}
5855
```
5956

57+
```toml {tabTitle:Toml} {filename:wrangler.toml}
58+
compatibility_flags = ["nodejs_als"]
59+
# compatibility_flags = ["nodejs_compat"]
60+
```
61+
6062
Next, wrap your handler with the `withSentry` function. This will initialize the SDK and hook into the
6163
environment. Note that you can turn off almost all side effects using the respective options.
6264

@@ -101,20 +103,20 @@ pnpm add @sentry/cloudflare
101103
To use the SDK, you'll need to set either the `nodejs_compat` or `nodejs_als` compatibility flags in your `wrangler.toml`/`wrangler.json`.
102104
This is because the SDK needs access to the `AsyncLocalStorage` API to work correctly.
103105

104-
```toml {tabTitle:Toml} {filename:wrangler.toml}
105-
compatibility_flags = ["nodejs_compat"]
106-
# compatibility_flags = ["nodejs_als"]
107-
```
108-
109-
```json {tabTitle:JSON} {filename:wrangler.json}
106+
```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
110107
{
111108
"compatibility_flags": [
112-
"nodejs_compat"
109+
"nodejs_compat",
113110
// "nodejs_als"
114-
]
111+
],
115112
}
116113
```
117114

115+
```toml {tabTitle:Toml} {filename:wrangler.toml}
116+
compatibility_flags = ["nodejs_compat"]
117+
# compatibility_flags = ["nodejs_als"]
118+
```
119+
118120
Next, add the `sentryPagesPlugin` as
119121
[middleware to your Cloudflare Pages application](https://developers.cloudflare.com/pages/functions/middleware/).
120122

platform-includes/sourcemaps/primer/javascript.cloudflare.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@ Learn how to unminify your JavaScript code by watching this video or reading the
33

44
<VimeoEmbed id="956055420?h=f428eeda43" />
55

6-
If you are using plain Cloudflare Workers, set `upload_source_maps = true` to your `wrangler.toml` file to enable source map generation.
6+
If you are using plain Cloudflare Workers, set `upload_source_maps = true` in your `wrangler.jsonc`/`wrangler.toml` config file to enable source map generation.
7+
8+
```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
9+
{
10+
"upload_source_maps": true,
11+
}
12+
```
13+
14+
```toml {tabTitle:Toml} {filename:wrangler.toml}
15+
upload_source_maps = true
16+
```

0 commit comments

Comments
 (0)