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
description: "Learn how to add Cloudflare instrumentation to your Astro app."
4
4
---
5
5
6
+
## Install
7
+
6
8
If you're running your Astro app on Cloudflare Pages, you can use the Sentry Astro SDK in combination with the Sentry Cloudflare SDK to add Sentry instrumentation.
7
9
8
10
First, install the Sentry Astro SDK in your application. We recommend [setting up the Astro SDK manually](/platforms/javascript/guides/astro/manual-setup/) and manually initializing the SDK. Make sure you have a `sentry.client.config.js` file created, but do not add a `sentry.server.config.js` file.
@@ -11,27 +13,9 @@ After installing the Sentry Astro SDK, you can now install the Sentry Cloudflare
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
15
-
needs access to the `AsyncLocalStorage` API to work correctly.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx
+5-65Lines changed: 5 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,75 +5,15 @@ description: "Learn how to add Cloudflare instrumentation to your Hono app."
5
5
6
6
This guide explains how to set up Sentry in your Hono application running on Cloudflare Workers.
7
7
8
-
## Setup
9
-
10
-
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
11
-
needs access to the `AsyncLocalStorage` API to work correctly.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/cloudflare/frameworks/remix.mdx
+3-18Lines changed: 3 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: "Learn how to add Cloudflare instrumentation to your Remix app."
5
5
6
6
If you're running your Remix app on Cloudflare Pages, you can use the Sentry Remix SDK in combination with the Sentry Cloudflare SDK to add Sentry instrumentation.
7
7
8
-
## 1. Installing Sentry Remix SDK
8
+
## Install
9
9
10
10
First, install the Sentry Remix SDK in your application. We recommend using the Sentry wizard to automatically install the SDK:
If the setup through the wizard doesn't work for you, you can also [set up the Remix SDK manually](/platforms/javascript/guides/remix/manual-setup/).
17
17
18
-
## 2. Installing Sentry Cloudflare SDK
19
-
20
18
After installing the Sentry Remix SDK, delete the newly generated `instrumentation.server.mjs` file. This instrumentation is not needed when using the Cloudflare SDK.
21
19
22
20
Now you can install the Sentry Cloudflare SDK. First, install the SDK with your package manager:
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
27
-
needs access to the `AsyncLocalStorage` API to work correctly.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/cloudflare/frameworks/sveltekit.mdx
+6-19Lines changed: 6 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: "Learn how to add Cloudflare instrumentation to your SvelteKit app.
5
5
6
6
If you're running your SvelteKit app on Cloudflare Pages, you need to configure the SDK a little differently to the default setup. This guide will show you how to set up the Sentry SvelteKit SDK for Cloudflare Pages.
7
7
8
-
## 1. Install the SDK
8
+
## Install
9
9
10
10
First, install the Sentry SvelteKit SDK in your application. We recommend using the Sentry wizard to automatically install the SDK:
11
11
@@ -21,28 +21,15 @@ If you installed the SDK before, make sure that `@sentry/sveltekit` version `9.2
21
21
22
22
</Alert>
23
23
24
-
## 2. Cloudflare configuration
24
+
Now you can install the Sentry Cloudflare SDK. First, install the SDK with your package manager:
25
25
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
27
-
needs access to the `AsyncLocalStorage` API to work correctly.
To use this SDK, update your `src/hooks.server.(ts|js)` file to use the `initCloudflareSentryHandle` method from the Sentry Cloudflare SDK and remove the `Sentry.init` call from `@sentry/sveltekit`.
32
+
Next, update your `src/hooks.server.(ts|js)` file to use the `initCloudflareSentryHandle` method from the Sentry Cloudflare SDK and remove the `Sentry.init` call from `@sentry/sveltekit`.
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
19
-
20
-
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
21
12
22
-
Sentry captures data by using an SDK within your application’s runtime.
23
-
24
-
```bash {tabTitle:npm}
25
-
npm install @sentry/cloudflare --save
26
-
```
27
-
28
-
```bash {tabTitle:yarn}
29
-
yarn add @sentry/cloudflare
30
-
```
31
-
32
-
```bash {tabTitle:pnpm}
33
-
pnpm add @sentry/cloudflare
34
-
```
35
-
36
-
## Configure
37
-
38
-
Configuration should happen as early as possible in your application's lifecycle.
39
-
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
41
-
needs access to the `AsyncLocalStorage` API to work correctly.
You can use the Sentry Cloudflare SDK with popular frameworks running on Cloudflare:
51
14
52
-
```toml {tabTitle:Toml} {filename:wrangler.toml}
53
-
compatibility_flags = ["nodejs_als"]
54
-
# compatibility_flags = ["nodejs_compat"]
55
-
```
15
+
-**[Astro](framesworks/astro/)**
16
+
-**[Hono](frameworks/hono/)**
17
+
-**[Remix](framesworks/remix/)**
18
+
-**[SvelteKit](framesworks/sveltekit/)**
56
19
57
-
Then you can install the SDK and add it to your project:
20
+
Take a look at your framework of choice, as there are likely additional instructions for setting up Sentry with it. For more framework-specific guidance, see the [frameworks section](frameworks/).
58
21
59
-
You can either setup up the SDK for [Cloudflare Pages](#setup-cloudflare-pages) or [Cloudflare Workers](#setup-cloudflare-workers).
22
+
If you're not using one of these frameworks, or are just looking for general instructions for Cloudflare usage, you're in the right place.
60
23
61
-
### Setup (Cloudflare Pages)
24
+
##Install
62
25
63
-
To use this SDK, add the `sentryPagesPlugin` as [middleware to your Cloudflare Pages application](https://developers.cloudflare.com/pages/functions/middleware/).
You can use the Sentry Cloudflare SDK with popular frameworks running on Cloudflare:
57
+
To use this SDK, add the `sentryPagesPlugin` as [middleware to your Cloudflare Pages application](https://developers.cloudflare.com/pages/functions/middleware/).
139
58
140
-
-**[Hono](frameworks/hono/)** - A lightweight web framework for Cloudflare Workers
59
+
We recommend adding a `functions/_middleware.js` for the middleware setup so that Sentry is initialized for your entire
60
+
app.
141
61
142
-
Take a look at your framework of choice, as there are likely additional instructions for setting up Sentry with it. For more framework-specific guidance, see the [frameworks section](frameworks/).
62
+
```javascript {filename:functions/_middleware.js}
63
+
import*asSentryfrom"@sentry/cloudflare";
64
+
65
+
exportconstonRequest= [
66
+
// Make sure Sentry is the first middleware
67
+
Sentry.sentryPagesPlugin((context) => {
68
+
const { id:versionId } =env.CF_VERSION_METADATA;
69
+
70
+
return {
71
+
dsn:"___PUBLIC_DSN___",
72
+
73
+
release: versionId,
74
+
75
+
// Adds request headers and IP for users, for more info visit:
0 commit comments