From 262a97b3be9cc5a64560c680f3c3592d605a31c5 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Wed, 13 May 2026 16:18:48 +0200 Subject: [PATCH] docs(astro): Document Astro 6 support on Cloudflare --- .../guides/cloudflare/frameworks/astro.mdx | 21 +++- .../javascript.astro.mdx | 103 ++++++++++-------- 2 files changed, 77 insertions(+), 47 deletions(-) diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx index e2b373e0463e4..e42bdc23f0242 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx @@ -9,14 +9,31 @@ You need: - A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) - Your application up and running -- Astro `3.0.0` or above -- `@astrojs/cloudflare` v12 +- Astro `6.0.0` or above +- `@astrojs/cloudflare` v13 or above - `@sentry/astro` v10.40.0 or above +- `@sentry/cloudflare` v10.40.0 or above If you're using Cloudflare Pages (not Workers), see the section below for setup instructions. We recommend migrating to Cloudflare Workers for better Sentry integration and full feature support. + + +For Astro 3-5 with `@astrojs/cloudflare` v12, the `@sentry/astro` integration automatically detects the Cloudflare adapter and wraps your Worker with the `@sentry/cloudflare` SDK for proper request isolation and async context. + +Follow the standard [Astro on Cloudflare setup](/platforms/javascript/guides/astro/#install) without the custom entry point configuration described below. The SDK handles server-side initialization automatically. + + + +With Astro 3-5 on Cloudflare, server-side SDK configuration only works via [environment variables](https://developers.cloudflare.com/workers/configuration/environment-variables/). The `sentry.server.config.(ts|js)` file is not supported. + +The SDK reads standard Sentry environment variables including `SENTRY_DSN`, `SENTRY_TRACES_SAMPLE_RATE`, `SENTRY_RELEASE`, `SENTRY_ENVIRONMENT`, and others. See the [SDK configuration spec](https://develop.sentry.dev/sdk/foundations/client/configuration/#environment-variables) for the full list. + + + + + diff --git a/platform-includes/getting-started-complete/javascript.astro.mdx b/platform-includes/getting-started-complete/javascript.astro.mdx index 2bbacf4c76d58..76b4bb4ca59fc 100644 --- a/platform-includes/getting-started-complete/javascript.astro.mdx +++ b/platform-includes/getting-started-complete/javascript.astro.mdx @@ -95,6 +95,63 @@ pnpm add @sentry/astro @sentry/cloudflare platform="javascript.cloudflare" /> +### Configure Custom Entry Point + + + + + +Astro 6 with `@astrojs/cloudflare` v13+ supports custom entry points directly from `wrangler.jsonc`. Update your wrangler configuration to point to a custom Sentry entry point: + + + + +```jsonc {filename:wrangler.jsonc} +{ + "main": "./sentry.server.config.ts", + // ... other configuration +} +``` + + + + + + + +Create a `sentry.server.config.ts` file in the root of your project that wraps the Astro Cloudflare handler with Sentry: + + + + +```typescript {filename:sentry.server.config.ts} +import * as Sentry from "@sentry/cloudflare"; +import handler from "@astrojs/cloudflare/entrypoints/server"; + +export default Sentry.withSentry( + (env) => ({ + dsn: env.SENTRY_DSN, + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/astro/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ performance + // Define how likely traces are sampled. Adjust this value in production, + // or use tracesSampler for greater control. + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs + }), + handler +); +``` + + + + + ### Register the Sentry Integration @@ -103,8 +160,6 @@ pnpm add @sentry/astro @sentry/cloudflare Follow [Astro's Cloudflare deployment guide](https://docs.astro.build/en/guides/deploy/cloudflare/) if you haven't already. Then add the Sentry integration to your `astro.config.mjs` alongside the Cloudflare adapter. -The `@sentry/astro` integration automatically detects the Cloudflare adapter and wraps your Worker with the `@sentry/cloudflare` SDK for proper request isolation and async context. - @@ -311,49 +366,7 @@ Sentry.init({ - - - - -Create a `sentry.server.config.(ts|js)` file in the root of your project. In this file, import and initialize Sentry for the server: - - - -The `sentry.server.config.(ts|js)` file only works during local development. In production on Cloudflare Workers, you must use [environment variables](https://developers.cloudflare.com/workers/configuration/environment-variables/) to configure Sentry. - -The SDK reads standard Sentry environment variables including `SENTRY_DSN`, `SENTRY_TRACES_SAMPLE_RATE`, `SENTRY_RELEASE`, `SENTRY_ENVIRONMENT`, and others. See the [SDK configuration spec](https://develop.sentry.dev/sdk/foundations/client/configuration/#environment-variables) for the full list. - - - - - - -```javascript {filename:sentry.server.config.(ts|js)} -import * as Sentry from "@sentry/astro"; - -Sentry.init({ - dsn: "___PUBLIC_DSN___", - - // Adds request headers and IP for users, for more info visit: - // https://docs.sentry.io/platforms/javascript/guides/astro/configuration/options/#sendDefaultPii - sendDefaultPii: true, - // ___PRODUCT_OPTION_START___ performance - - // Define how likely traces are sampled. Adjust this value in production, - // or use tracesSampler for greater control. - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - enableLogs: true, - // ___PRODUCT_OPTION_END___ logs -}); -``` - - - - +Server-side Sentry is already configured in your custom entry point file (`sentry.server.config.ts`) created in the previous step.