From 43b63176d9204afe9636eafd123483c43a8c1cf6 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Wed, 21 Oct 2026 10:34:23 +0200 Subject: [PATCH 01/10] docs(js): Add Cloudflare quick starts to the Next.js and Nuxt guides The Next.js and Nuxt guides get a "Quick Start - Cloudflare" page below the default quick start. Both quick starts move into getting-started-node and getting-started-cloudflare includes per framework, so they share their content. The Next.js on Cloudflare quick start now also covers wrapping the Worker entry with withSentry. The Next.js and Nuxt pages under Cloudflare > Frameworks and the Next.js "Deploying on Cloudflare Workers" page redirect to the new pages. Co-Authored-By: Claude Opus 5.5 --- .../common/troubleshooting/index.mdx | 2 +- .../guides/cloudflare/frameworks/index.mdx | 2 + .../guides/cloudflare/frameworks/nextjs.mdx | 127 ------- .../guides/cloudflare/frameworks/nuxt.mdx | 11 - .../javascript/guides/cloudflare/index.mdx | 4 +- .../deploying-on-cloudflare.mdx | 7 - .../javascript/guides/nextjs/cloudflare.mdx | 8 + .../javascript/guides/nextjs/index.mdx | 250 +------------- .../javascript/guides/nuxt/cloudflare.mdx | 10 + .../features/nitro-deployment-presets.mdx | 2 +- .../javascript/guides/nuxt/index.mdx | 104 +----- .../javascript/guides/nuxt/install/index.mdx | 2 +- .../javascript.nextjs.mdx | 209 ++++++++++++ .../javascript.nuxt.mdx | 314 ++++++++++++++++++ .../javascript.nuxt.mdx | 97 ------ .../javascript.nextjs.mdx | 110 ++++++ .../getting-started-node/javascript.nuxt.mdx | 130 ++++++++ .../javascript.nextjs.mdx | 143 ++++++++ redirects.js | 11 +- 19 files changed, 943 insertions(+), 600 deletions(-) delete mode 100644 docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx delete mode 100644 docs/platforms/javascript/guides/cloudflare/frameworks/nuxt.mdx delete mode 100644 docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx create mode 100644 docs/platforms/javascript/guides/nextjs/cloudflare.mdx create mode 100644 docs/platforms/javascript/guides/nuxt/cloudflare.mdx create mode 100644 platform-includes/getting-started-cloudflare/javascript.nextjs.mdx create mode 100644 platform-includes/getting-started-cloudflare/javascript.nuxt.mdx create mode 100644 platform-includes/getting-started-node/javascript.nextjs.mdx create mode 100644 platform-includes/getting-started-node/javascript.nuxt.mdx create mode 100644 platform-includes/getting-started-wizard-files/javascript.nextjs.mdx diff --git a/docs/platforms/javascript/common/troubleshooting/index.mdx b/docs/platforms/javascript/common/troubleshooting/index.mdx index 1fb9a9adef7e9..e97f66b03a2b2 100644 --- a/docs/platforms/javascript/common/troubleshooting/index.mdx +++ b/docs/platforms/javascript/common/troubleshooting/index.mdx @@ -636,7 +636,7 @@ Learn more about fixing these caching issues in the diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx deleted file mode 100644 index 6d4f78393a76a..0000000000000 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx +++ /dev/null @@ -1,127 +0,0 @@ ---- -title: Next.js on Cloudflare -description: "Learn how to configure Sentry for your Next.js application deployed on Cloudflare Workers." ---- - -The Sentry Next.js SDK supports Next.js applications deployed on Cloudflare Workers, but requires additional configuration to run in this environment. - -## Prerequisites - -Before you begin, make sure you have: - -- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) -- A [Cloudflare Workers project](https://dash.cloudflare.com/workers/overview) -- A Next.js application configured for Cloudflare Workers with [OpenNext](https://opennext.js.org/cloudflare) or [vinext](https://github.com/cloudflare/vinext) -- The Sentry SDK [installed and configured](/platforms/javascript/guides/nextjs/) in your Next.js application - - - If you haven't deployed a Next.js app to Cloudflare Workers before, follow - Cloudflare's [Next.js deployment - guide](https://developers.cloudflare.com/workers/framework-guides/web-apps/nextjs/) - to get started. - - -## Configure Wrangler - -Once you've set up Sentry in your Next.js application following the [installation guide](/platforms/javascript/guides/nextjs/), you'll need to configure [Wrangler](https://developers.cloudflare.com/workers/wrangler/) with the required compatibility settings. - -First, add the `nodejs_compat` [compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs/) to configure the Cloudflare Workers runtime to provide the Node.js APIs required by the Sentry SDK. - -```json {tabTitle:wrangler.jsonc} -{ - "compatibility_flags": ["nodejs_compat"] -} -``` - -```toml {tabTitle:wrangler.toml} -compatibility_flags = ["nodejs_compat"] -``` - -Then, set the [compatibility date](https://developers.cloudflare.com/workers/configuration/compatibility-dates/) to `2025-08-16` or later. This is required to introduce `https.request` to the Cloudflare Workers runtime, which the Sentry SDK needs to send data. - -Your final configuration should look like this: - -```json {tabTitle:wrangler.jsonc} -{ - "compatibility_flags": ["nodejs_compat"], - "compatibility_date": "2025-08-16" -} -``` - -```toml {tabTitle:wrangler.toml} -compatibility_flags = ["nodejs_compat"] -compatibility_date = "2025-08-16" -``` - -## Wrap the Worker Entry - - - -If you build your app with vinext, skip to [Wrap the Worker Entry With vinext](#wrap-the-worker-entry-with-vinext). - -On Cloudflare Workers, your Next.js app runs inside the Worker entry that OpenNext generates (`.open-next/worker.js`). Wrap this entry with `withSentry` from `@sentry/nextjs/cloudflare` to get the same Next.js spans as on Node.js, plus Cloudflare data such as spans for D1 queries. Each request gets one `http.server` span with the name of the Next.js route, and the Next.js spans become its children. - -`@sentry/nextjs` depends on `@sentry/cloudflare`, so you don't need to install another package. - -First, create a [custom Worker](https://opennext.js.org/cloudflare/howtos/custom-worker) that imports the handler of OpenNext and wraps it with `withSentry`. Pass your Sentry options to `withSentry`: - -```typescript {filename:worker.ts} -import * as Sentry from "@sentry/nextjs/cloudflare"; -// @ts-ignore `.open-next/worker.js` is generated at build time -import handler from "./.open-next/worker.js"; - -// Re-export the Durable Objects your app uses, for example for the DO Queue and DO Tag Cache of OpenNext -// @ts-ignore `.open-next/worker.js` is generated at build time -export { DOQueueHandler, DOShardedTagCache } from "./.open-next/worker.js"; - -export default Sentry.withSentry( - () => ({ - dsn: "___PUBLIC_DSN___", - - // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. - // Learn more at - // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate - tracesSampleRate: 1.0, - }), - handler -); -``` - -Then, point `main` in your Wrangler configuration to this file: - -```json {tabTitle:wrangler.jsonc} -{ - "main": "./worker.ts" -} -``` - -```toml {tabTitle:wrangler.toml} -main = "./worker.ts" -``` - -### Wrap the Worker Entry With vinext - - - -With [vinext](https://github.com/cloudflare/vinext), you don't need a custom Worker. Add the Sentry Vite plugin to your Vite config, and it wraps your Worker entry with `withSentry` from `@sentry/nextjs/cloudflare` automatically. - -### Server and Edge Configuration in the Worker - -In the Worker, `withSentry` creates the Sentry client. `Sentry.init()` in `sentry.server.config.ts` and `sentry.edge.config.ts` still runs, but it creates no client and only applies the `release` option. Set all other options in `withSentry`. - -On Workers, these two files are optional. Keep them if you use `next dev`, which runs on Node.js and doesn't use the Worker entry. They also pass on the release that `withSentryConfig` sets at build time. - -Keep `instrumentation.ts`, because Next.js reports server errors, for example from Server Components and route handlers, through its `onRequestError` hook. - -The SDK takes the release from the first of these sources that has a value: - -1. The `release` option of `withSentry` -2. The `SENTRY_RELEASE` environment variable -3. The ID of the `CF_VERSION_METADATA` binding -4. The `release` option of `Sentry.init()` in `sentry.server.config.ts` or `sentry.edge.config.ts`, or else the release that `withSentryConfig` sets at build time - -On Node.js, the build release comes before `SENTRY_RELEASE`. - -## Deploy - -Build and deploy your Next.js application to Cloudflare Workers. You should start seeing error events, traces, and logs appear in Sentry. diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/nuxt.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/nuxt.mdx deleted file mode 100644 index 3b3444b1cf8a7..0000000000000 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/nuxt.mdx +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Nuxt on Cloudflare -description: "Learn how to instrument your Nuxt app on Cloudflare Workers and Pages and capture your first errors with Sentry." ---- - -This guide will show you how to set up the SDK with Nitro's `cloudflare_module` (or their deprecated `cloudflare-pages`) deployment preset. - - diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index 76049c2c54552..253d8fc3d59d9 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -17,8 +17,8 @@ If you're using any of the listed frameworks, follow their specific setup instru - **[Astro](/platforms/javascript/guides/cloudflare/frameworks/astro/)** - **[Hono](/platforms/javascript/guides/hono/)** (with @sentry/hono) - **[Hydrogen](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)** -- **[Next.js](/platforms/javascript/guides/cloudflare/frameworks/nextjs/)** -- **[Nuxt](/platforms/javascript/guides/cloudflare/frameworks/nuxt/)** +- **[Next.js](/platforms/javascript/guides/nextjs/cloudflare/)** +- **[Nuxt](/platforms/javascript/guides/nuxt/cloudflare/)** - **[Remix](/platforms/javascript/guides/cloudflare/frameworks/remix/)** - **[SvelteKit](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/)** - **[TanStack Start](/platforms/javascript/guides/cloudflare/frameworks/tanstack-start/)** diff --git a/docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx b/docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx deleted file mode 100644 index 2fc24a8629806..0000000000000 --- a/docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Deploying on Cloudflare Workers -description: "Learn how to configure Sentry for your Next.js application deployed on Cloudflare Workers." -sidebar_section: configuration ---- - -For instructions on deploying your Next.js application with Sentry on Cloudflare Workers, see the [Next.js on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/nextjs/) guide. diff --git a/docs/platforms/javascript/guides/nextjs/cloudflare.mdx b/docs/platforms/javascript/guides/nextjs/cloudflare.mdx new file mode 100644 index 0000000000000..47893645d530f --- /dev/null +++ b/docs/platforms/javascript/guides/nextjs/cloudflare.mdx @@ -0,0 +1,8 @@ +--- +title: Next.js on Cloudflare +sidebar_title: Quick Start - Cloudflare +sidebar_order: 0.5 +description: "Learn how to set up Sentry in your Next.js application deployed on Cloudflare Workers and capture your first errors." +--- + + diff --git a/docs/platforms/javascript/guides/nextjs/index.mdx b/docs/platforms/javascript/guides/nextjs/index.mdx index 71fff4aae652d..8b19eae36dd5d 100644 --- a/docs/platforms/javascript/guides/nextjs/index.mdx +++ b/docs/platforms/javascript/guides/nextjs/index.mdx @@ -9,252 +9,4 @@ categories: - - - - -## Install - -### Run the Installation Wizard - -Run the Sentry wizard to automatically install the SDK and configure Sentry in your Next.js application: - -```bash -npx @sentry/wizard@latest -i nextjs -``` - -The wizard asks whether you want to enable **Tracing** and **Session Replay**, route browser requests through your server to avoid ad blockers, and create an example page. To match the configuration in this guide, answer **Yes** to each. - -Prefer to set things up yourself? Check out the [Manual Setup](/platforms/javascript/guides/nextjs/manual-setup/) guide. - -## Configure - -**Error Monitoring** starts working as soon as you call `Sentry.init()`. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). -This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. - - - -### Initialize the SDK - -Next.js runs code in different environments, so the wizard creates a separate initialization file for each in your project's root directory (or `src` folder): - -- `instrumentation-client.ts`: runs in the browser -- `sentry.server.config.ts`: runs in the Node.js runtime -- `sentry.edge.config.ts`: runs in the Edge runtime - -Use the tabs in the code box below to view each file. - -The snippets also turn on: - -- Tracing: via `tracesSampleRate` in all three files -- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` -- User Feedback: via `feedbackIntegration()`. The wizard doesn't add this integration, so add it to `instrumentation-client.ts` yourself. - -Don't need a feature? Remove its integration and options from the snippets. - -```typescript {tabTitle:Client} {mdExpandTabs} {filename:instrumentation-client.ts} -import * as Sentry from "@sentry/nextjs"; - -Sentry.init({ - dsn: "___PUBLIC_DSN___", - integrations: [ - // enables Session Replay - Sentry.replayIntegration(), - // enables User Feedback - Sentry.feedbackIntegration({ - // Additional integration configuration goes in here - colorScheme: "system", - }), - ], - - // Enables Tracing. - // Set to 1.0 to capture 100% of spans for tracing. - // We recommend reducing this value in production. - tracesSampleRate: 1.0, - - // Capture replays for 10% of all sessions, - // plus for 100% of sessions with an error - // Requires Sentry.replayIntegration() - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, -}); - -// Instruments client-side navigations -export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; -``` - -```typescript {tabTitle:Server} {filename:sentry.server.config.ts} -import * as Sentry from "@sentry/nextjs"; - -Sentry.init({ - dsn: "___PUBLIC_DSN___", - - // Enables Tracing. - // Set to 1.0 to capture 100% of spans for tracing. - // We recommend reducing this value in production. - tracesSampleRate: 1.0, -}); -``` - -```typescript {tabTitle:Edge} {filename:sentry.edge.config.ts} -import * as Sentry from "@sentry/nextjs"; - -Sentry.init({ - dsn: "___PUBLIC_DSN___", - - // Enables Tracing. - // Set to 1.0 to capture 100% of spans for tracing. - // We recommend reducing this value in production. - tracesSampleRate: 1.0, -}); -``` - -### Register the Server-Side Configuration - -The wizard creates a [Next.js instrumentation file](https://nextjs.org/docs/app/guides/instrumentation) named `instrumentation.ts`. It loads your server and edge configurations, and exports `onRequestError` to capture errors from Server Components, route handlers, and middleware. - -```typescript {filename:instrumentation.ts} -import * as Sentry from "@sentry/nextjs"; - -export async function register() { - if (process.env.NEXT_RUNTIME === "nodejs") { - await import("./sentry.server.config"); - } - - if (process.env.NEXT_RUNTIME === "edge") { - await import("./sentry.edge.config"); - } -} - -export const onRequestError = Sentry.captureRequestError; -``` - -### Capture React Render Errors - -If you use the App Router, the wizard adds Sentry to `app/global-error.tsx` to capture React rendering errors. If you use the Pages Router, it adds Sentry to `pages/_error.tsx` instead. - - - -### Apply Instrumentation to Your App - -The wizard wraps your Next.js configuration with `withSentryConfig`. This instruments your app at build time, uploads source maps, and, if you said yes in the wizard, routes browser requests to Sentry through your server to avoid ad blockers. - -To forward only the request body to Sentry, add a tunnel route handler (SDK version `10.77.1` and later on v10, `11.9.0` and later on v11). Use the handler if Vercel Deployment Protection or another login protects your app. -Learn more about the [`tunnelRoute` option](/platforms/javascript/guides/nextjs/configuration/build/#tunnelRoute). - -```typescript {filename:next.config.ts} -import type { NextConfig } from "next"; -import { withSentryConfig } from "@sentry/nextjs/config"; - -const nextConfig: NextConfig = { - // Your existing Next.js configuration -}; - -export default withSentryConfig(nextConfig, { - org: "___ORG_SLUG___", - project: "___PROJECT_SLUG___", - - // Only print logs for uploading source maps in CI - silent: !process.env.CI, - - // Upload a larger set of source maps for prettier stack traces (increases build time) - widenClientFileUpload: true, - - // Route browser requests to Sentry through a Next.js rewrite to avoid ad blockers. - // This can increase your server load as well as your hosting bill. - tunnelRoute: "/monitoring", -}); -``` - -### Add Readable Stack Traces With Source Maps - -The wizard stores your auth token in `.env.sentry-build-plugin` and adds the file to `.gitignore`. The Sentry build plugin uses this token to upload source maps when you build your app locally. - -For CI/CD builds, set the `SENTRY_AUTH_TOKEN` environment variable in your build system instead. - - - -```bash {filename:.env.sentry-build-plugin} -SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ -``` - -### Control the Data You Send to Sentry - - - -## Send Logs - - - -If you're already logging with another library, use an integration to capture those logs as Sentry Logs automatically: - -- `consoleLoggingIntegration` for `console` calls -- Consola -- Pino -- Winston - -## Send Application Metrics - - - -In the Node.js runtime, `nodeRuntimeMetricsIntegration` also collects runtime health metrics automatically. - -## Verify Your Setup - -Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. - -The wizard created an example page that sends a test error from both your frontend and your backend: - -1. Start your development server: - - ```bash - npm run dev - ``` - -2. Open [localhost:3000/sentry-example-page](http://localhost:3000/sentry-example-page) in your browser. -3. Click **Throw Sample Error**. - -If you skipped the example page, add a test button to one of your pages instead. Clicking it will trigger an error for Sentry to capture. - -```tsx {filename:app/page.tsx} -"use client"; - -export default function Page() { - return ( - - ); -} -``` - - - -### View Captured Data in Sentry - -Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). - - - -## Next Steps - -At this point, you should have integrated Sentry into your Next.js application. Here's what to explore next: - -- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Set up Agent Tracing to monitor agents built with the Vercel AI SDK, LangChain, and more -- Set up tunneling to avoid ad blockers blocking Sentry events, if you didn't enable it in the wizard - - - -- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nextjs/manual-setup/) -- Find various topics in Troubleshooting -- [Get support](https://www.sentry.help/en/) - - - - + diff --git a/docs/platforms/javascript/guides/nuxt/cloudflare.mdx b/docs/platforms/javascript/guides/nuxt/cloudflare.mdx new file mode 100644 index 0000000000000..1815a55985dd4 --- /dev/null +++ b/docs/platforms/javascript/guides/nuxt/cloudflare.mdx @@ -0,0 +1,10 @@ +--- +title: Nuxt on Cloudflare +sidebar_title: Quick Start - Cloudflare +sidebar_order: 0.5 +description: "Learn how to instrument your Nuxt app on Cloudflare Workers and Pages and capture your first errors with Sentry." +--- + +This guide shows how to set up the SDK with Nitro's `cloudflare_module` deployment preset, or with the deprecated `cloudflare-pages` preset. + + diff --git a/docs/platforms/javascript/guides/nuxt/features/nitro-deployment-presets.mdx b/docs/platforms/javascript/guides/nuxt/features/nitro-deployment-presets.mdx index 945f878d90816..ca23844d62a0d 100644 --- a/docs/platforms/javascript/guides/nuxt/features/nitro-deployment-presets.mdx +++ b/docs/platforms/javascript/guides/nuxt/features/nitro-deployment-presets.mdx @@ -8,4 +8,4 @@ The Sentry Nuxt SDK provides support for different Nitro deployment presets, mos ## Cloudflare Pages -Using the Cloudflare Nitro plugin of Sentry enables Sentry monitoring on Cloudflare Workers and Pages. Go and see the [Cloudflare Nitro plugin documentation](/platforms/javascript/guides/cloudflare/frameworks/nuxt/). +Using the Cloudflare Nitro plugin of Sentry enables Sentry monitoring on Cloudflare Workers and Pages. Go and see the [Cloudflare Nitro plugin documentation](/platforms/javascript/guides/nuxt/cloudflare/). diff --git a/docs/platforms/javascript/guides/nuxt/index.mdx b/docs/platforms/javascript/guides/nuxt/index.mdx index 0fd2306ca119c..e6b332e27e391 100644 --- a/docs/platforms/javascript/guides/nuxt/index.mdx +++ b/docs/platforms/javascript/guides/nuxt/index.mdx @@ -7,106 +7,4 @@ categories: - server --- - - - - -## Install - - - - - - - - - -## Avoid Ad Blockers With Tunneling (Optional) - - - -## Control the Data You Send to Sentry (Optional) - - - -## Verify Your Setup - -The `sentry init` command checks the integration files it creates or modifies before it finishes. To confirm runtime events are reaching Sentry, start your Nuxt app, exercise the parts of your app that should send events, and then check your Sentry project. - -If you used the Nuxt installation wizard instead, you can also verify your setup with the example page or component it creates. - - -The wizard creates a `SentryErrorButton` component when it fails to add an example page to your project. This usually happens if you don't have a `app.vue` file or if that file does not contain the `NuxtPage` component. To verify your setup, follow these steps before continuing with the next section, "View Captured Data in Sentry": - -1. Add the `SentryErrorButton` component to a page and open it in your browser. For most Nuxt applications, this will be at localhost. -2. Click the "Throw Sample Error" button, which triggers an error and starts a performance trace on the client side. - -To test the server side as well, refer to the "Verify" section in the [Manual setup guide](/platforms/javascript/guides/nuxt/manual-setup/). - - - -To test Sentry, you can run your Nuxt application in either production or development mode. -We **recommend testing in production mode** as it most closely resembles your deployed application's environment. - -The SDK bundles `sentry.server.config.ts` into the Nitro server build and initializes Sentry when the server starts. To learn more, see Server-Side Installation. - -### Run in Production Mode (Recommended) - -Build your project with `nuxi build`, then start the server. - -```bash -# Start your app after building your project with `nuxi build` -node .output/server/index.mjs -``` - -### Run in Development Mode - -Sentry also monitors the server side during development. Start the dev server as usual. - -Spans from some libraries, such as database clients, can be missing in development mode. -Errors and request traces always work. To learn more, see Development Mode. - -```bash -nuxt dev -``` - -If you used the Nuxt installation wizard, after building and running your project: - -1. Open the example page `/sentry-example-page` in your browser. For most Nuxt applications, this will be at localhost. -2. Click the "Throw sample error" button. This triggers two errors: - - a frontend error - - an error within the API route - -Sentry captures both of these errors for you. Additionally, the button click starts a performance trace to measure the time it takes for the API request to complete. - - - -### View Captured Data in Sentry - -Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). - - - - - -## Next Steps - -At this point, you should have integrated Sentry into your Nuxt application and should already be sending error and performance data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: - -- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to [manually capture errors](/platforms/javascript/guides/nuxt/usage/) -- Continue to [customize your configuration](/platforms/javascript/guides/nuxt/configuration/) -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts -- Learn how to [track your Vue components or your Pinia store](/platforms/javascript/guides/nuxt/features/) -- Learn how to [add support for different Nitro deployment presets](/platforms/javascript/guides/nuxt/features/nitro-deployment-presets/) (like Cloudflare) - - - -- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nuxt/manual-setup/) -- [Get support](https://www.sentry.help/en/) - - - - + diff --git a/docs/platforms/javascript/guides/nuxt/install/index.mdx b/docs/platforms/javascript/guides/nuxt/install/index.mdx index 298c08d02db09..4f11e711aea48 100644 --- a/docs/platforms/javascript/guides/nuxt/install/index.mdx +++ b/docs/platforms/javascript/guides/nuxt/install/index.mdx @@ -38,7 +38,7 @@ The SDK doesn't initialize Sentry while Nitro prerenders your pages at build tim ### Cloudflare -With a Cloudflare Nitro preset, the SDK doesn't use `sentry.server.config.ts`. Set up the SDK with the [Cloudflare Nitro plugin](/platforms/javascript/guides/cloudflare/frameworks/nuxt/) instead. +With a Cloudflare Nitro preset, the SDK doesn't use `sentry.server.config.ts`. Set up the SDK with the [Cloudflare Nitro plugin](/platforms/javascript/guides/nuxt/cloudflare/) instead. ## Upgrade to SDK Version 11 diff --git a/platform-includes/getting-started-cloudflare/javascript.nextjs.mdx b/platform-includes/getting-started-cloudflare/javascript.nextjs.mdx new file mode 100644 index 0000000000000..ed8427c5febad --- /dev/null +++ b/platform-includes/getting-started-cloudflare/javascript.nextjs.mdx @@ -0,0 +1,209 @@ +## Prerequisites + +You need: + +- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) +- A Next.js application that runs on Cloudflare Workers with the [OpenNext Cloudflare adapter](https://opennext.js.org/cloudflare) or [vinext](https://github.com/cloudflare/vinext) + + + If you haven't deployed a Next.js app to Cloudflare Workers before, follow + Cloudflare's [Next.js deployment + guide](https://developers.cloudflare.com/workers/framework-guides/web-apps/nextjs/) + first. + + + + +## Install + +### Run the Installation Wizard + +Run the Sentry wizard to automatically install the SDK and configure Sentry in your Next.js application: + +```bash +npx @sentry/wizard@latest -i nextjs +``` + +The wizard asks whether you want to enable **Tracing** and **Session Replay**, route browser requests through your server to avoid ad blockers, and create an example page. To match the configuration in this guide, answer **Yes** to each. + +Prefer to set things up yourself? Check out the [Manual Setup](/platforms/javascript/guides/nextjs/manual-setup/) guide. + +## Configure + +**Error Monitoring** starts working as soon as you call `Sentry.init()`. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + +The wizard creates the files below. On Cloudflare Workers, you set the server options in the Worker entry instead, as the [Wrap the Worker Entry](#wrap-the-worker-entry) step shows. + + + +### Configure Wrangler + +The SDK uses Node.js APIs that the Workers runtime only provides with the `nodejs_compat` [compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs/). Set the [compatibility date](https://developers.cloudflare.com/workers/configuration/compatibility-dates/) to `2025-08-16` or later, which adds the `https.request` API that the SDK uses to send data: + +```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} +{ + "compatibility_flags": ["nodejs_compat"], + "compatibility_date": "2025-08-16", +} +``` + +```toml {tabTitle:Toml} {filename:wrangler.toml} +compatibility_flags = ["nodejs_compat"] +compatibility_date = "2025-08-16" +``` + +### Wrap the Worker Entry + + + +If you build your app with vinext, skip to [Wrap the Worker Entry With vinext](#wrap-the-worker-entry-with-vinext). + +On Cloudflare Workers, your Next.js app runs inside the Worker entry that OpenNext generates (`.open-next/worker.js`). Wrap this entry with `withSentry` from `@sentry/nextjs/cloudflare` to get the same Next.js spans as on Node.js, plus Cloudflare data such as spans for D1 queries. Each request gets one `http.server` span with the name of the Next.js route, and the Next.js spans become its children. + +`@sentry/nextjs` depends on `@sentry/cloudflare`, so you don't need to install another package. + +First, create a [custom Worker](https://opennext.js.org/cloudflare/howtos/custom-worker) that imports the handler of OpenNext and wraps it with `withSentry`. Pass your Sentry options to `withSentry`: + +```typescript {filename:worker.ts} +import * as Sentry from "@sentry/nextjs/cloudflare"; +// @ts-ignore `.open-next/worker.js` is generated at build time +import handler from "./.open-next/worker.js"; + +// Re-export the Durable Objects your app uses, for example for the DO Queue and DO Tag Cache of OpenNext +// @ts-ignore `.open-next/worker.js` is generated at build time +export { DOQueueHandler, DOShardedTagCache } from "./.open-next/worker.js"; + +export default Sentry.withSentry( + () => ({ + dsn: "___PUBLIC_DSN___", + + // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. + // Learn more at + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate + tracesSampleRate: 1.0, + }), + handler +); +``` + +Then, point `main` in your Wrangler configuration to this file: + +```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} +{ + "main": "./worker.ts", +} +``` + +```toml {tabTitle:Toml} {filename:wrangler.toml} +main = "./worker.ts" +``` + +#### Wrap the Worker Entry With vinext + +With [vinext](https://github.com/cloudflare/vinext), you don't need a custom Worker. Add the [Sentry Vite plugin](/platforms/javascript/guides/cloudflare/install/vite-plugin/) to your Vite config, and it wraps your Worker entry with `withSentry` from `@sentry/nextjs/cloudflare` automatically. + +#### Server and Edge Configuration in the Worker + +In the Worker, `withSentry` creates the Sentry client. `Sentry.init()` in `sentry.server.config.ts` and `sentry.edge.config.ts` still runs, but it creates no client and only applies the `release` option. Set all other options in `withSentry`. + +On Workers, these two files are optional. Keep them if you use `next dev`, which runs on Node.js and doesn't use the Worker entry. They also pass on the release that `withSentryConfig` sets at build time. + +Keep `instrumentation.ts`, because Next.js reports server errors, for example from Server Components and route handlers, through its `onRequestError` hook. + +The SDK takes the release from the first of these sources that has a value: + +1. The `release` option of `withSentry` +2. The `SENTRY_RELEASE` environment variable +3. The ID of the `CF_VERSION_METADATA` binding +4. The `release` option of `Sentry.init()` in `sentry.server.config.ts` or `sentry.edge.config.ts`, or else the release that `withSentryConfig` sets at build time + +On Node.js, the build release comes before `SENTRY_RELEASE`. + +### Control the Data You Send to Sentry + + + +## Send Logs + + + +If you're already logging with `console` or Consola, use an integration to capture those logs as Sentry Logs automatically: + +- `consoleLoggingIntegration` for `console` calls +- Consola + +## Send Application Metrics + + + +## Verify Your Setup + +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +The wizard created an example page that sends a test error from both your frontend and your backend: + +1. Build your app and run it in the Workers runtime on your machine: + + ```bash + npx opennextjs-cloudflare build && npx opennextjs-cloudflare preview + ``` + +2. Open `/sentry-example-page` on the URL that the preview command prints. +3. Click **Throw Sample Error**. + +If you skipped the example page, add a test button to one of your pages instead. Clicking it will trigger an error for Sentry to capture. + +```tsx {filename:app/page.tsx} +"use client"; + +export default function Page() { + return ( + + ); +} +``` + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). + + + +## Next Steps + +At this point, you should have integrated Sentry into your Next.js application on Cloudflare Workers. Here's what to explore next: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- [Distributed Tracing](/platforms/javascript/guides/nextjs/tracing/distributed-tracing/) to trace requests across services +- Set up tunneling to avoid ad blockers blocking Sentry events, if you didn't enable it in the wizard + + + +- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nextjs/manual-setup/) +- Find various topics in Troubleshooting +- [Get support](https://www.sentry.help/en/) + + + + diff --git a/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx b/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx new file mode 100644 index 0000000000000..b1d5b083fcdcb --- /dev/null +++ b/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx @@ -0,0 +1,314 @@ + + + + +## Install + +Choose the features you want to configure, and this guide will show you how: + + + + + +### Install the Sentry SDK + +Run the command for your preferred package manager to add the Sentry SDK to your application: + +```bash {tabTitle:npm} +npm install @sentry/nuxt --save +``` + +```bash {tabTitle:yarn} +yarn add @sentry/nuxt +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/nuxt +``` + +## Configure + +### Apply Instrumentation to Your App + +Add the Sentry Nuxt module to your `nuxt.config.ts` file: + +```javascript {filename:nuxt.config.ts} +export default defineNuxtConfig({ + modules: ["@sentry/nuxt/module"], +}); +``` + +### Configure Client-Side Sentry + +Add a `sentry.client.config.ts` file to the root of your project (this is probably the same level as the `package.json`). In this file, import and initialize Sentry, specifying any SDK options for the client: + +```javascript {filename:sentry.client.config.ts} +import * as Sentry from "@sentry/nuxt"; + +Sentry.init({ + // If set up, you can use the Nuxt runtime config here + // dsn: useRuntimeConfig().public.sentry.dsn + // modify depending on your custom runtime config + dsn: "___PUBLIC_DSN___", + + // ___PRODUCT_OPTION_START___ session-replay + + // Replay may only be enabled for the client-side + integrations: [ + Sentry.replayIntegration(), + // ___PRODUCT_OPTION_START___ user-feedback + Sentry.feedbackIntegration({ + // Additional SDK configuration goes in here, for example: + colorScheme: "system", + }), + // ___PRODUCT_OPTION_END___ user-feedback + ], + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ session-replay + + // Capture Replay for 10% of all sessions, + // plus for 100% of sessions with an error + // Learn more at + // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ session-replay +}); +``` + +We recommend you store your Sentry [Data Source Name](/concepts/key-terms/dsn-explainer/) (DSN) in an environment variable and configure it via the Nuxt runtime config. + +This allows you to access the DSN using `useRuntimeConfig().public.sentry.dsn`. + +```javascript {filename:nuxt.config.ts} +export default defineNuxtConfig({ + modules: ["@sentry/nuxt/module"], + runtimeConfig: { + public: { + sentry: { + dsn: process.env.NUXT_PUBLIC_SENTRY_DSN, // Use a public environment variable for the DSN + }, + }, + }, +}); +``` + +### Configure Cloudflare for Sentry + + + +#### Add the Nitro Plugin + + + If you have an existing `sentry.server.config.ts` file, delete it, as it will + conflict with the Cloudflare setup. + + +To enable Sentry for your Nuxt app on Cloudflare, create a new file in `server/plugins` and add the following code to it: + +```TypeScript {filename:server/plugins/sentry-cloudflare-plugin.ts} +import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins' + +export default defineNitroPlugin(sentryCloudflareNitroPlugin({ + dsn: '___PUBLIC_DSN___', + tracesSampleRate: 1.0, +})) +``` + +Or, if you need access to `nitroApp`: + +```TypeScript {filename:server/plugins/sentry-cloudflare-plugin.ts} +import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins' + +export default defineNitroPlugin(sentryCloudflareNitroPlugin((nitroApp: NitroApp) => { + // You can access `nitroApp` here if needed + return { + dsn: '___PUBLIC_DSN___', + tracesSampleRate: 1.0, + } +})) +``` + +### Add Readable Stack Traces With Source Maps (Optional) + +To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slugs in the `sentry` options inside your configuration file: + +These `sentry` options only affect the **build time** of the SDK. + +```javascript {filename:nuxt.config.ts} {3-10} +export default defineNuxtConfig({ + modules: ["@sentry/nuxt/module"], + sentry: { + org: "___ORG_SLUG___", + project: "___PROJECT_SLUG___", + // store your auth token in an environment variable + authToken: process.env.SENTRY_AUTH_TOKEN, + }, +}); +``` + +To keep your auth token secure, always store it in an environment variable instead of directly in your files: + + + +```bash {filename:.env} +SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ +``` + +#### Enable Client-Side Source Maps + +While Nuxt generates source maps on the server side by default, you need to explicitly enable client-side source maps in your Nuxt configuration. + +The `hidden` option enables source map generation while preventing source map reference comments that would normally appear at the end of each generated file in the build output. + +```javascript {filename:nuxt.config.ts} {2} +export default defineNuxtConfig({ + sourcemap: { client: "hidden" }, +}); +``` + +### Control the Data You Send to Sentry (Optional) + + + +## Verify Your Setup + +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +### Issues + +To verify that Sentry captures errors and creates issues in your Sentry project, create a test page with a button. + + + +```html {tabTitle:Vue} {filename:pages/example-error.vue} + + + +``` + + +### Tracing + +To test tracing, create a test API route `server/api/sentry-example.get.ts`: + +```js {tabTitle:Nitro} {filename:server/api/sentry-example.get.ts} +export default defineEventHandler((event) => { + throw new Error("Sentry Example API Route Error"); +}); +``` + +Then update the test page by including a new button that executes a function to fetch your API route: + +```html {tabTitle:Vue} {filename:pages/example-error.vue} + + + +``` + + + + + + + + + + + + + Once you have your test code in place, open the page in a browser and click + the button to trigger an error. + + + + +Once you have your test code in place, build and run your project. + +After running your project, open your test page in a browser and click the buttons. + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). + + + +## Next Steps + +At this point, you should have integrated Sentry into your Nuxt application and should already be sending data to your Sentry project. + +Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/javascript/guides/nuxt/usage/) +- Continue to [customize your configuration](/platforms/javascript/guides/nuxt/configuration/) +- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Learn how to [track your Vue components or your Pinia store](/platforms/javascript/guides/nuxt/features/) + + + +- Find various support topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) and [Nuxt troubleshooting](/platforms/javascript/guides/nuxt/troubleshooting/) +- [Get support](https://www.sentry.help/en/) + + + + diff --git a/platform-includes/getting-started-complete/javascript.nuxt.mdx b/platform-includes/getting-started-complete/javascript.nuxt.mdx index 8847328ac123f..ca94d38d99c5c 100644 --- a/platform-includes/getting-started-complete/javascript.nuxt.mdx +++ b/platform-includes/getting-started-complete/javascript.nuxt.mdx @@ -18,18 +18,8 @@ Choose the features you want to configure, and this guide will show you how: ]} /> - - - - - - - - - - ### Install the Sentry SDK Run the command for your preferred package manager to add the Sentry SDK to your application: @@ -122,7 +112,6 @@ export default defineNuxtConfig({ }); ``` - ### Configure Server-Side Sentry Add a `sentry.server.config.ts` file to the root of your project and initialize Sentry in it. @@ -177,51 +166,6 @@ To learn more, see [Server-Side Installation](/platforms/javascript/guides/nuxt/ node .output/server/index.mjs ``` - - - - -### Configure Cloudflare for Sentry - - - -#### Add the Nitro Plugin - - - If you have an existing `sentry.server.config.ts` file, delete it, as it will - conflict with the Cloudflare setup. - - -To enable Sentry for your Nuxt app on Cloudflare, create a new file in `server/plugins` and add the following code to it: - -```TypeScript {filename:server/plugins/sentry-cloudflare-plugin.ts} -import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins' - -export default defineNitroPlugin(sentryCloudflareNitroPlugin({ - dsn: '___PUBLIC_DSN___', - tracesSampleRate: 1.0, -})) -``` - -Or, if you need access to `nitroApp`: - -```TypeScript {filename:server/plugins/sentry-cloudflare-plugin.ts} -import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins' - -export default defineNitroPlugin(sentryCloudflareNitroPlugin((nitroApp: NitroApp) => { - // You can access `nitroApp` here if needed - return { - dsn: '___PUBLIC_DSN___', - tracesSampleRate: 1.0, - } -})) -``` - - - ### Add Readable Stack Traces With Source Maps (Optional) To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slugs in the `sentry` options inside your configuration file: @@ -260,14 +204,12 @@ export default defineNuxtConfig({ }); ``` - ### Avoid Ad Blockers With Tunneling (Optional) - ### Control the Data You Send to Sentry (Optional) @@ -354,18 +296,8 @@ Then update the test page by including a new button that executes a function to - - -Once you have your test code in place, build and run your project. - - - - - Once you have your test code in place, run your project in production mode (`nuxi build`, then `node .output/server/index.mjs`) or in development mode (`nuxt dev`). - - After running your project, open your test page in a browser and click the buttons. @@ -374,25 +306,14 @@ After running your project, open your test page in a browser and click the butto Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). - - - - - - - - - - ## Next Steps At this point, you should have integrated Sentry into your Nuxt application and should already be sending data to your Sentry project. Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: - - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup - Learn how to [manually capture errors](/platforms/javascript/guides/nuxt/usage/) - Continue to [customize your configuration](/platforms/javascript/guides/nuxt/configuration/) @@ -409,22 +330,4 @@ Now's a good time to customize your setup and look into more advanced topics. Ou - - - -- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to [manually capture errors](/platforms/javascript/guides/nuxt/usage/) -- Continue to [customize your configuration](/platforms/javascript/guides/nuxt/configuration/) -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts -- Learn how to [track your Vue components or your Pinia store](/platforms/javascript/guides/nuxt/features/) - - - -- Find various support topics in Cloudflare troubleshooting and [Nuxt troubleshooting](/platforms/javascript/guides/nuxt/troubleshooting/) -- [Get support](https://www.sentry.help/en/) - - - - - diff --git a/platform-includes/getting-started-node/javascript.nextjs.mdx b/platform-includes/getting-started-node/javascript.nextjs.mdx new file mode 100644 index 0000000000000..1ce1e7b97b13f --- /dev/null +++ b/platform-includes/getting-started-node/javascript.nextjs.mdx @@ -0,0 +1,110 @@ + + + + +## Install + +### Run the Installation Wizard + +Run the Sentry wizard to automatically install the SDK and configure Sentry in your Next.js application: + +```bash +npx @sentry/wizard@latest -i nextjs +``` + +The wizard asks whether you want to enable **Tracing** and **Session Replay**, route browser requests through your server to avoid ad blockers, and create an example page. To match the configuration in this guide, answer **Yes** to each. + +Prefer to set things up yourself? Check out the [Manual Setup](/platforms/javascript/guides/nextjs/manual-setup/) guide. + +## Configure + +**Error Monitoring** starts working as soon as you call `Sentry.init()`. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + + + +### Control the Data You Send to Sentry + + + +## Send Logs + + + +If you're already logging with another library, use an integration to capture those logs as Sentry Logs automatically: + +- `consoleLoggingIntegration` for `console` calls +- Consola +- Pino +- Winston + +## Send Application Metrics + + + +In the Node.js runtime, `nodeRuntimeMetricsIntegration` also collects runtime health metrics automatically. + +## Verify Your Setup + +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +The wizard created an example page that sends a test error from both your frontend and your backend: + +1. Start your development server: + + ```bash + npm run dev + ``` + +2. Open [localhost:3000/sentry-example-page](http://localhost:3000/sentry-example-page) in your browser. +3. Click **Throw Sample Error**. + +If you skipped the example page, add a test button to one of your pages instead. Clicking it will trigger an error for Sentry to capture. + +```tsx {filename:app/page.tsx} +"use client"; + +export default function Page() { + return ( + + ); +} +``` + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). + + + +## Next Steps + +At this point, you should have integrated Sentry into your Next.js application. Here's what to explore next: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Set up Agent Tracing to monitor agents built with the Vercel AI SDK, LangChain, and more +- Set up tunneling to avoid ad blockers blocking Sentry events, if you didn't enable it in the wizard + + + +- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nextjs/manual-setup/) +- Find various topics in Troubleshooting +- [Get support](https://www.sentry.help/en/) + + + + diff --git a/platform-includes/getting-started-node/javascript.nuxt.mdx b/platform-includes/getting-started-node/javascript.nuxt.mdx new file mode 100644 index 0000000000000..0e18577dbd2e5 --- /dev/null +++ b/platform-includes/getting-started-node/javascript.nuxt.mdx @@ -0,0 +1,130 @@ + + + + +## Install + + + + + + + + + +## Avoid Ad Blockers With Tunneling (Optional) + + + +## Control the Data You Send to Sentry (Optional) + + + +## Verify Your Setup + +The `sentry init` command checks the integration files it creates or modifies before it finishes. To confirm runtime events are reaching Sentry, start your Nuxt app, exercise the parts of your app that should send events, and then check your Sentry project. + +If you used the Nuxt installation wizard instead, you can also verify your setup with the example page or component it creates. + + +The wizard creates a `SentryErrorButton` component when it fails to add an example page to your project. This usually happens if you don't have a `app.vue` file or if that file does not contain the `NuxtPage` component. To verify your setup, follow these steps before continuing with the next section, "View Captured Data in Sentry": + +1. Add the `SentryErrorButton` component to a page and open it in your browser. For most Nuxt applications, this will be at localhost. +2. Click the "Throw Sample Error" button, which triggers an error and starts a performance trace on the client side. + +To test the server side as well, refer to the "Verify" section in the [Manual setup guide](/platforms/javascript/guides/nuxt/manual-setup/). + + + +To test Sentry, you can run your Nuxt application in either production or development mode. +We **recommend testing in production mode** as it most closely resembles your deployed application's environment. + +The SDK bundles `sentry.server.config.ts` into the Nitro server build and initializes Sentry when the server starts. To learn more, see [Server-Side Installation](/platforms/javascript/guides/nuxt/install/). + +### Run in Production Mode (Recommended) + +Build your project with `nuxi build`, then start the server. + +```bash +# Start your app after building your project with `nuxi build` +node .output/server/index.mjs +``` + +### Run in Development Mode + +Sentry also monitors the server side during development. Start the dev server as usual. + +Spans from some libraries, such as database clients, can be missing in development mode. +Errors and request traces always work. To learn more, see [Development Mode](/platforms/javascript/guides/nuxt/install/#development-mode). + +```bash +nuxt dev +``` + +If you used the Nuxt installation wizard, after building and running your project: + +1. Open the example page `/sentry-example-page` in your browser. For most Nuxt applications, this will be at localhost. +2. Click the "Throw sample error" button. This triggers two errors: + - a frontend error + - an error within the API route + +Sentry captures both of these errors for you. Additionally, the button click starts a performance trace to measure the time it takes for the API request to complete. + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). + + + + + +## Next Steps + +At this point, you should have integrated Sentry into your Nuxt application and should already be sending error and performance data to your Sentry project. + +Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/javascript/guides/nuxt/usage/) +- Continue to [customize your configuration](/platforms/javascript/guides/nuxt/configuration/) +- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Learn how to [track your Vue components or your Pinia store](/platforms/javascript/guides/nuxt/features/) +- Learn how to [add support for different Nitro deployment presets](/platforms/javascript/guides/nuxt/features/nitro-deployment-presets/) (like Cloudflare) + + + +- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nuxt/manual-setup/) +- [Get support](https://www.sentry.help/en/) + + + + diff --git a/platform-includes/getting-started-wizard-files/javascript.nextjs.mdx b/platform-includes/getting-started-wizard-files/javascript.nextjs.mdx new file mode 100644 index 0000000000000..d3b92a08b86ab --- /dev/null +++ b/platform-includes/getting-started-wizard-files/javascript.nextjs.mdx @@ -0,0 +1,143 @@ +### Initialize the SDK + +Next.js runs code in different environments, so the wizard creates a separate initialization file for each in your project's root directory (or `src` folder): + +- `instrumentation-client.ts`: runs in the browser +- `sentry.server.config.ts`: runs in the Node.js runtime +- `sentry.edge.config.ts`: runs in the Edge runtime + +Use the tabs in the code box below to view each file. + +The snippets also turn on: + +- Tracing: via `tracesSampleRate` in all three files +- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` +- User Feedback: via `feedbackIntegration()`. The wizard doesn't add this integration, so add it to `instrumentation-client.ts` yourself. + +Don't need a feature? Remove its integration and options from the snippets. + +```typescript {tabTitle:Client} {mdExpandTabs} {filename:instrumentation-client.ts} +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + integrations: [ + // enables Session Replay + Sentry.replayIntegration(), + // enables User Feedback + Sentry.feedbackIntegration({ + // Additional integration configuration goes in here + colorScheme: "system", + }), + ], + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + tracesSampleRate: 1.0, + + // Capture replays for 10% of all sessions, + // plus for 100% of sessions with an error + // Requires Sentry.replayIntegration() + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, +}); + +// Instruments client-side navigations +export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; +``` + +```typescript {tabTitle:Server} {filename:sentry.server.config.ts} +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + tracesSampleRate: 1.0, +}); +``` + +```typescript {tabTitle:Edge} {filename:sentry.edge.config.ts} +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + tracesSampleRate: 1.0, +}); +``` + +### Register the Server-Side Configuration + +The wizard creates a [Next.js instrumentation file](https://nextjs.org/docs/app/guides/instrumentation) named `instrumentation.ts`. It loads your server and edge configurations, and exports `onRequestError` to capture errors from Server Components, route handlers, and middleware. + +```typescript {filename:instrumentation.ts} +import * as Sentry from "@sentry/nextjs"; + +export async function register() { + if (process.env.NEXT_RUNTIME === "nodejs") { + await import("./sentry.server.config"); + } + + if (process.env.NEXT_RUNTIME === "edge") { + await import("./sentry.edge.config"); + } +} + +export const onRequestError = Sentry.captureRequestError; +``` + +### Capture React Render Errors + +If you use the App Router, the wizard adds Sentry to `app/global-error.tsx` to capture React rendering errors. If you use the Pages Router, it adds Sentry to `pages/_error.tsx` instead. + + + +### Apply Instrumentation to Your App + +The wizard wraps your Next.js configuration with `withSentryConfig`. This instruments your app at build time, uploads source maps, and, if you said yes in the wizard, routes browser requests to Sentry through your server to avoid ad blockers. + +To forward only the request body to Sentry, add a tunnel route handler (SDK version `10.77.1` and later on v10, `11.9.0` and later on v11). Use the handler if Vercel Deployment Protection or another login protects your app. +Learn more about the [`tunnelRoute` option](/platforms/javascript/guides/nextjs/configuration/build/#tunnelRoute). + +```typescript {filename:next.config.ts} +import type { NextConfig } from "next"; +import { withSentryConfig } from "@sentry/nextjs/config"; + +const nextConfig: NextConfig = { + // Your existing Next.js configuration +}; + +export default withSentryConfig(nextConfig, { + org: "___ORG_SLUG___", + project: "___PROJECT_SLUG___", + + // Only print logs for uploading source maps in CI + silent: !process.env.CI, + + // Upload a larger set of source maps for prettier stack traces (increases build time) + widenClientFileUpload: true, + + // Route browser requests to Sentry through a Next.js rewrite to avoid ad blockers. + // This can increase your server load as well as your hosting bill. + tunnelRoute: "/monitoring", +}); +``` + +### Add Readable Stack Traces With Source Maps + +The wizard stores your auth token in `.env.sentry-build-plugin` and adds the file to `.gitignore`. The Sentry build plugin uses this token to upload source maps when you build your app locally. + +For CI/CD builds, set the `SENTRY_AUTH_TOKEN` environment variable in your build system instead. + + + +```bash {filename:.env.sentry-build-plugin} +SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ +``` diff --git a/redirects.js b/redirects.js index 5d7fecaad69f5..474de531042a6 100644 --- a/redirects.js +++ b/redirects.js @@ -1051,7 +1051,16 @@ const userDocsRedirects = [ { // The Nuxt SDK links to this path in its Cloudflare build warning source: '/platforms/javascript/guides/nuxt/install/cloudflare-workers/', - destination: '/platforms/javascript/guides/cloudflare/frameworks/nuxt/', + destination: '/platforms/javascript/guides/nuxt/cloudflare/', + }, + // The Cloudflare quick starts of Next.js and Nuxt moved from the Cloudflare guide into the framework guides. + { + source: '/platforms/javascript/guides/cloudflare/frameworks/:framework(nextjs|nuxt)/', + destination: '/platforms/javascript/guides/:framework/cloudflare/', + }, + { + source: '/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare/', + destination: '/platforms/javascript/guides/nextjs/cloudflare/', }, { source: '/platforms/javascript/guides/connect/', From 82e907c3a9b89d23ecb8995f03e810bd7241a4e8 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Mon, 26 Oct 2026 14:38:33 -0600 Subject: [PATCH 02/10] docs(js): Use the new quick start template on the Nuxt Cloudflare page The Nuxt Cloudflare quick start now follows the template from the other JavaScript quick starts: no feature checkboxes, every feature on in the snippets, separate Send Logs and Send Application Metrics steps, and one test error in Verify. The release configuration in the shared Wrangler include is now an h4 without "(Optional)", because every page shows it under a Wrangler h3. Co-Authored-By: Claude Opus 5.5 --- .../javascript.nuxt.mdx | 181 ++++++------------ .../javascript.cloudflare.mdx | 2 +- 2 files changed, 63 insertions(+), 120 deletions(-) diff --git a/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx b/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx index b1d5b083fcdcb..c5b416237741d 100644 --- a/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx +++ b/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx @@ -7,19 +7,6 @@ ## Install -Choose the features you want to configure, and this guide will show you how: - - - - - ### Install the Sentry SDK Run the command for your preferred package manager to add the Sentry SDK to your application: @@ -38,6 +25,11 @@ pnpm add @sentry/nuxt ## Configure +**Error Monitoring** starts working as soon as you configure Sentry. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + ### Apply Instrumentation to Your App Add the Sentry Nuxt module to your `nuxt.config.ts` file: @@ -50,7 +42,15 @@ export default defineNuxtConfig({ ### Configure Client-Side Sentry -Add a `sentry.client.config.ts` file to the root of your project (this is probably the same level as the `package.json`). In this file, import and initialize Sentry, specifying any SDK options for the client: +Add a `sentry.client.config.ts` file to the root of your project (this is probably the same level as the `package.json`). In this file, import and initialize Sentry, specifying any SDK options for the client. + +The snippet also turns on: + +- Tracing: via `tracesSampleRate` +- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` +- User Feedback: via `feedbackIntegration()` + +Don't need a feature? Remove its integration and options from the snippet. ```javascript {filename:sentry.client.config.ts} import * as Sentry from "@sentry/nuxt"; @@ -60,38 +60,26 @@ Sentry.init({ // dsn: useRuntimeConfig().public.sentry.dsn // modify depending on your custom runtime config dsn: "___PUBLIC_DSN___", - - // ___PRODUCT_OPTION_START___ session-replay - - // Replay may only be enabled for the client-side integrations: [ + // enables Session Replay Sentry.replayIntegration(), - // ___PRODUCT_OPTION_START___ user-feedback + // enables User Feedback Sentry.feedbackIntegration({ - // Additional SDK configuration goes in here, for example: + // Additional integration configuration goes in here colorScheme: "system", }), - // ___PRODUCT_OPTION_END___ user-feedback ], - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ session-replay - // Capture Replay for 10% of all sessions, + // Capture replays for 10% of all sessions, // plus for 100% of sessions with an error - // Learn more at - // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration + // Requires Sentry.replayIntegration() replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ session-replay }); ``` @@ -112,27 +100,37 @@ export default defineNuxtConfig({ }); ``` -### Configure Cloudflare for Sentry +### Configure Wrangler -#### Add the Nitro Plugin +### Add the Nitro Plugin If you have an existing `sentry.server.config.ts` file, delete it, as it will conflict with the Cloudflare setup. -To enable Sentry for your Nuxt app on Cloudflare, create a new file in `server/plugins` and add the following code to it: +To enable Sentry for your Nuxt app on Cloudflare, create a new file in `server/plugins` and add the following code to it. + +The snippet also turns on: + +- Tracing: via `tracesSampleRate` + +Don't need a feature? Remove its integration and options from the snippet. ```TypeScript {filename:server/plugins/sentry-cloudflare-plugin.ts} import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins' export default defineNitroPlugin(sentryCloudflareNitroPlugin({ dsn: '___PUBLIC_DSN___', + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, })) ``` @@ -146,12 +144,16 @@ export default defineNitroPlugin(sentryCloudflareNitroPlugin((nitroApp: NitroApp // You can access `nitroApp` here if needed return { dsn: '___PUBLIC_DSN___', + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, } })) ``` -### Add Readable Stack Traces With Source Maps (Optional) +### Add Readable Stack Traces With Source Maps To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slugs in the `sentry` options inside your configuration file: @@ -189,119 +191,60 @@ export default defineNuxtConfig({ }); ``` -### Control the Data You Send to Sentry (Optional) +### Control the Data You Send to Sentry - -## Verify Your Setup - -Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. - -### Issues - -To verify that Sentry captures errors and creates issues in your Sentry project, create a test page with a button. - - -```html {tabTitle:Vue} {filename:pages/example-error.vue} - + - -``` +If you're already logging with `console` or Consola, you can capture those logs with our console integrations. - -### Tracing +## Send Application Metrics -To test tracing, create a test API route `server/api/sentry-example.get.ts`: + -```js {tabTitle:Nitro} {filename:server/api/sentry-example.get.ts} -export default defineEventHandler((event) => { - throw new Error("Sentry Example API Route Error"); -}); -``` +## Verify Your Setup -Then update the test page by including a new button that executes a function to fetch your API route: +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. -```html {tabTitle:Vue} {filename:pages/example-error.vue} - ``` - - - - - - - - - - - - Once you have your test code in place, open the page in a browser and click - the button to trigger an error. - - - +Build and deploy your app, open the page in a browser, and click the button to trigger an error. -Once you have your test code in place, build and run your project. - -After running your project, open your test page in a browser and click the buttons. - - + ### View Captured Data in Sentry -Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). ## Next Steps -At this point, you should have integrated Sentry into your Nuxt application and should already be sending data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: +At this point, you should have integrated Sentry into your Nuxt application on Cloudflare. Here's what to explore next: - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to [manually capture errors](/platforms/javascript/guides/nuxt/usage/) -- Continue to [customize your configuration](/platforms/javascript/guides/nuxt/configuration/) -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Set up tunneling to avoid ad blockers blocking Sentry events - Learn how to [track your Vue components or your Pinia store](/platforms/javascript/guides/nuxt/features/) diff --git a/platform-includes/getting-started-config/javascript.cloudflare.mdx b/platform-includes/getting-started-config/javascript.cloudflare.mdx index 3b1a97eed8908..3e0ef0a3166c4 100644 --- a/platform-includes/getting-started-config/javascript.cloudflare.mdx +++ b/platform-includes/getting-started-config/javascript.cloudflare.mdx @@ -14,7 +14,7 @@ compatibility_date = "{{@inject new Date().toISOString().slice(0, 10) }}" compatibility_flags = ["nodejs_compat"] ``` -### Release Configuration (Optional) +#### Release Configuration If you don't set the `release` option manually, the SDK automatically detects it from these sources (in order of priority): From 318585f7431ed99bff64d9a7c1a704958057847d Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Fri, 30 Oct 2026 13:38:11 -0600 Subject: [PATCH 03/10] docs(js): Show the Cloudflare quick starts as "Quick Start (Cloudflare)" The label reads as a variant of the Quick Start above it, without a spaced hyphen that looks like a dash. Co-Authored-By: Claude Opus 5.5 --- docs/platforms/javascript/guides/nextjs/cloudflare.mdx | 2 +- docs/platforms/javascript/guides/nuxt/cloudflare.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/platforms/javascript/guides/nextjs/cloudflare.mdx b/docs/platforms/javascript/guides/nextjs/cloudflare.mdx index 47893645d530f..05b04e8fd71b2 100644 --- a/docs/platforms/javascript/guides/nextjs/cloudflare.mdx +++ b/docs/platforms/javascript/guides/nextjs/cloudflare.mdx @@ -1,6 +1,6 @@ --- title: Next.js on Cloudflare -sidebar_title: Quick Start - Cloudflare +sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to set up Sentry in your Next.js application deployed on Cloudflare Workers and capture your first errors." --- diff --git a/docs/platforms/javascript/guides/nuxt/cloudflare.mdx b/docs/platforms/javascript/guides/nuxt/cloudflare.mdx index 1815a55985dd4..cc57cea92c072 100644 --- a/docs/platforms/javascript/guides/nuxt/cloudflare.mdx +++ b/docs/platforms/javascript/guides/nuxt/cloudflare.mdx @@ -1,6 +1,6 @@ --- title: Nuxt on Cloudflare -sidebar_title: Quick Start - Cloudflare +sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your Nuxt app on Cloudflare Workers and Pages and capture your first errors with Sentry." --- From e70cba94c6912eda54ad53d38196c89dd8743db5 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Wed, 21 Oct 2026 11:40:34 +0200 Subject: [PATCH 04/10] docs(js): Move the Cloudflare framework quick starts into the framework guides The Astro, Remix, SvelteKit and TanStack Start pages under Cloudflare > Frameworks move into their framework guides as "Quick Start - Cloudflare", like Next.js and Nuxt. The Cloudflare parts of the Astro, Remix and SvelteKit includes move into getting-started-cloudflare includes, because PlatformSection only shows them on pages in the Cloudflare guide. The framework list on the Cloudflare quick start links to the new pages, and the old URLs redirect. The TanStack Start page now installs @sentry/tanstackstart-react, which its code imports, and its Wrangler and source maps sections render again. Co-Authored-By: Claude Opus 5.5 --- .../astro.mdx => astro/cloudflare.mdx} | 7 +- .../javascript/guides/astro/index.mdx | 2 +- .../cloudflare/frameworks/hydrogen-remix.mdx | 2 +- .../guides/cloudflare/frameworks/index.mdx | 9 +- .../javascript/guides/cloudflare/index.mdx | 8 +- .../remix.mdx => remix/cloudflare.mdx} | 12 +- .../guides/remix/frameworks/index.mdx | 2 +- .../cloudflare.mdx} | 7 +- .../javascript/guides/sveltekit/index.mdx | 2 +- .../sveltekit/manual-setup__v10.7.0.mdx | 4 +- .../cloudflare.mdx} | 26 +- .../javascript.astro.mdx | 258 ++++++++++++ .../javascript.remix.mdx | 388 ++++++++++++++++++ .../javascript.sveltekit.mdx | 358 ++++++++++++++++ .../javascript.astro.mdx | 153 +------ .../javascript.remix.mdx | 182 -------- .../javascript.sveltekit.mdx | 120 +----- .../javascript.sveltekit.mdx | 2 +- redirects.js | 9 +- 19 files changed, 1062 insertions(+), 489 deletions(-) rename docs/platforms/javascript/guides/{cloudflare/frameworks/astro.mdx => astro/cloudflare.mdx} (96%) rename docs/platforms/javascript/guides/{cloudflare/frameworks/remix.mdx => remix/cloudflare.mdx} (85%) rename docs/platforms/javascript/guides/{cloudflare/frameworks/sveltekit.mdx => sveltekit/cloudflare.mdx} (59%) rename docs/platforms/javascript/guides/{cloudflare/frameworks/tanstack-start.mdx => tanstackstart-react/cloudflare.mdx} (91%) create mode 100644 platform-includes/getting-started-cloudflare/javascript.astro.mdx create mode 100644 platform-includes/getting-started-cloudflare/javascript.remix.mdx create mode 100644 platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx b/docs/platforms/javascript/guides/astro/cloudflare.mdx similarity index 96% rename from docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx rename to docs/platforms/javascript/guides/astro/cloudflare.mdx index bd7fec2cc7944..6791c8cb354aa 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx +++ b/docs/platforms/javascript/guides/astro/cloudflare.mdx @@ -1,5 +1,7 @@ --- title: Astro on Cloudflare +sidebar_title: Quick Start - Cloudflare +sidebar_order: 0.5 description: "Learn how to instrument your Astro app on Cloudflare Workers and capture your first errors." --- @@ -99,9 +101,6 @@ export const onRequest = [ - + diff --git a/docs/platforms/javascript/guides/astro/index.mdx b/docs/platforms/javascript/guides/astro/index.mdx index 85729298541b1..a967e92fbf388 100644 --- a/docs/platforms/javascript/guides/astro/index.mdx +++ b/docs/platforms/javascript/guides/astro/index.mdx @@ -18,7 +18,7 @@ You need: -This SDK currently only works on Node runtimes, such as Node adapter or Vercel with Lambda functions. If you use Cloudflare Workers or Cloudflare Pages, refer to our [Astro on Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/astro/). Other non-Node runtimes, like Vercel's Edge runtime, are currently **not supported**. +This SDK currently only works on Node runtimes, such as Node adapter or Vercel with Lambda functions. If you use Cloudflare Workers or Cloudflare Pages, refer to our [Astro on Cloudflare guide](/platforms/javascript/guides/astro/cloudflare/). Other non-Node runtimes, like Vercel's Edge runtime, are currently **not supported**. diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix.mdx index ef88672d0ed44..8821348ed2fc0 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix.mdx @@ -39,7 +39,7 @@ On Shopify Oxygen, never import anything directly from `@sentry/cloudflare`. Onl -`wrapRequestHandler` doesn't isolate requests from each other. Scope data you set during a request, for example with `setTag` or `setUser`, can show up on events from other concurrent or later requests in the same isolate. Use `wrapRequestHandler` only on runtimes that can't enable `nodejs_compat`, such as Shopify Oxygen. For Remix on Cloudflare Workers, follow the [Remix on Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/remix/) instead. +`wrapRequestHandler` doesn't isolate requests from each other. Scope data you set during a request, for example with `setTag` or `setUser`, can show up on events from other concurrent or later requests in the same isolate. Use `wrapRequestHandler` only on runtimes that can't enable `nodejs_compat`, such as Shopify Oxygen. For Remix on Cloudflare Workers, follow the [Remix on Cloudflare guide](/platforms/javascript/guides/remix/cloudflare/) instead. diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx index a8f33f59d06cc..8e9ab81adf73d 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx @@ -5,6 +5,13 @@ description: "Learn how to set up the Cloudflare SDK with popular frameworks lik You can use the Sentry Cloudflare SDK in combination with Sentry meta-framework SDKs like SvelteKit or Remix to instrument your Cloudflare Pages applications that use these frameworks. -For Next.js and Nuxt, follow the Cloudflare quick start in the framework guide: [Next.js on Cloudflare](/platforms/javascript/guides/nextjs/cloudflare/) or [Nuxt on Cloudflare](/platforms/javascript/guides/nuxt/cloudflare/). +For these frameworks, follow the Cloudflare quick start in the framework guide: + +- [Astro on Cloudflare](/platforms/javascript/guides/astro/cloudflare/) +- [Next.js on Cloudflare](/platforms/javascript/guides/nextjs/cloudflare/) +- [Nuxt on Cloudflare](/platforms/javascript/guides/nuxt/cloudflare/) +- [Remix on Cloudflare](/platforms/javascript/guides/remix/cloudflare/) +- [SvelteKit on Cloudflare](/platforms/javascript/guides/sveltekit/cloudflare/) +- [TanStack Start React on Cloudflare](/platforms/javascript/guides/tanstackstart-react/cloudflare/) diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index 253d8fc3d59d9..f2dbf0485b22d 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -14,14 +14,14 @@ This guide covers Cloudflare Workers. If you're deploying a Cloudflare Pages app If you're using any of the listed frameworks, follow their specific setup instructions: -- **[Astro](/platforms/javascript/guides/cloudflare/frameworks/astro/)** +- **[Astro](/platforms/javascript/guides/astro/cloudflare/)** - **[Hono](/platforms/javascript/guides/hono/)** (with @sentry/hono) - **[Hydrogen](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)** - **[Next.js](/platforms/javascript/guides/nextjs/cloudflare/)** - **[Nuxt](/platforms/javascript/guides/nuxt/cloudflare/)** -- **[Remix](/platforms/javascript/guides/cloudflare/frameworks/remix/)** -- **[SvelteKit](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/)** -- **[TanStack Start](/platforms/javascript/guides/cloudflare/frameworks/tanstack-start/)** +- **[Remix](/platforms/javascript/guides/remix/cloudflare/)** +- **[SvelteKit](/platforms/javascript/guides/sveltekit/cloudflare/)** +- **[TanStack Start](/platforms/javascript/guides/tanstackstart-react/cloudflare/)** The Cloudflare Workers runtime has some platform-specific limitations that diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/remix.mdx b/docs/platforms/javascript/guides/remix/cloudflare.mdx similarity index 85% rename from docs/platforms/javascript/guides/cloudflare/frameworks/remix.mdx rename to docs/platforms/javascript/guides/remix/cloudflare.mdx index dc987930018ab..2115efc0d45c6 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/remix.mdx +++ b/docs/platforms/javascript/guides/remix/cloudflare.mdx @@ -1,12 +1,11 @@ --- title: Remix on Cloudflare +sidebar_title: Quick Start - Cloudflare +sidebar_order: 0.5 description: "Learn how to instrument your Remix app on Cloudflare Workers and Pages and capture your first errors with Sentry." --- - + @@ -43,9 +42,6 @@ yarn add @sentry/remix @sentry/cloudflare pnpm add @sentry/remix @sentry/cloudflare ``` - + diff --git a/docs/platforms/javascript/guides/remix/frameworks/index.mdx b/docs/platforms/javascript/guides/remix/frameworks/index.mdx index a72e5adcc00f7..79e13cc3c9f20 100644 --- a/docs/platforms/javascript/guides/remix/frameworks/index.mdx +++ b/docs/platforms/javascript/guides/remix/frameworks/index.mdx @@ -5,5 +5,5 @@ description: "Learn how to set up the Remix SDK or Hydrogen with Cloudflare." You can use the Sentry Remix SDK to set up Sentry with frameworks like Shopify's Hydrogen. The following guides will help you get started with the Sentry Remix SDK on Cloudflare: -- **[Remix on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/remix/)** +- **[Remix on Cloudflare](/platforms/javascript/guides/remix/cloudflare/)** - **[Hydrogen on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)** diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/sveltekit.mdx b/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx similarity index 59% rename from docs/platforms/javascript/guides/cloudflare/frameworks/sveltekit.mdx rename to docs/platforms/javascript/guides/sveltekit/cloudflare.mdx index 340bf50fa9f29..d946bc4fd65c8 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/sveltekit.mdx +++ b/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx @@ -1,9 +1,8 @@ --- title: SvelteKit on Cloudflare +sidebar_title: Quick Start - Cloudflare +sidebar_order: 0.5 description: "Learn how to instrument your SvelteKit app on Cloudflare Workers and Pages and capture your first errors with Sentry." --- - + diff --git a/docs/platforms/javascript/guides/sveltekit/index.mdx b/docs/platforms/javascript/guides/sveltekit/index.mdx index 02bb0201d9913..36000b46d9bd3 100644 --- a/docs/platforms/javascript/guides/sveltekit/index.mdx +++ b/docs/platforms/javascript/guides/sveltekit/index.mdx @@ -70,7 +70,7 @@ Our next recommended steps for you are: - Learn how to [manually capture errors](/platforms/javascript/guides/sveltekit/usage/) - Continue to [customize your configuration](/platforms/javascript/guides/sveltekit/configuration/) - Learn how to [manually instrument](/platforms/javascript/guides/sveltekit/apis/#load-function-instrumentation) SvelteKit-specific features -- Learn more about [deploying SvelteKit apps to Cloudflare Pages](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/) +- Learn more about [deploying SvelteKit apps to Cloudflare Pages](/platforms/javascript/guides/sveltekit/cloudflare/) - Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts diff --git a/docs/platforms/javascript/guides/sveltekit/manual-setup__v10.7.0.mdx b/docs/platforms/javascript/guides/sveltekit/manual-setup__v10.7.0.mdx index 11ff9ddc7ae5f..f83502f74828c 100644 --- a/docs/platforms/javascript/guides/sveltekit/manual-setup__v10.7.0.mdx +++ b/docs/platforms/javascript/guides/sveltekit/manual-setup__v10.7.0.mdx @@ -27,7 +27,7 @@ Here's an overview of the current support: - [Adapter-vercel](https://kit.svelte.dev/docs/adapter-vercel) when used with Vercel's Node.js Lambda runtime - [Adapter-node](https://kit.svelte.dev/docs/adapter-node) - **Supported non-Node.js runtimes** - - [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) requires [additional setup](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/) + - [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) requires [additional setup](/platforms/javascript/guides/sveltekit/cloudflare/) - **Currently not supported** - Non-Node.js server runtimes, such as Vercel's edge runtime, are not yet supported. - **Other adapters** @@ -326,7 +326,7 @@ Our next recommended steps for you are: - Learn how to [manually capture errors](/platforms/javascript/guides/sveltekit/usage/) - Continue to [customize your configuration](/platforms/javascript/guides/sveltekit/configuration/) - Learn how to [manually instrument](/platforms/javascript/guides/sveltekit/apis/#load-function-instrumentation) SvelteKit-specific features -- Learn more about [deploying SvelteKit apps to Cloudflare Pages](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/) +- Learn more about [deploying SvelteKit apps to Cloudflare Pages](/platforms/javascript/guides/sveltekit/cloudflare/) - Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/tanstack-start.mdx b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx similarity index 91% rename from docs/platforms/javascript/guides/cloudflare/frameworks/tanstack-start.mdx rename to docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx index 11fb6d6d40330..5db55b6a7d377 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/tanstack-start.mdx +++ b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx @@ -1,5 +1,7 @@ --- -title: TanStack Start on Cloudflare +title: TanStack Start React on Cloudflare +sidebar_title: Quick Start - Cloudflare +sidebar_order: 0.5 description: "Learn how to instrument your TanStack Start app on Cloudflare Workers and capture your first errors with Sentry." --- @@ -30,9 +32,19 @@ Choose the features you want to configure, and this guide will show you how: ### Install the Sentry SDK -Run the command for your preferred package manager to add the Sentry SDK to your application: +Run the command for your preferred package manager to add the Sentry TanStack Start and Cloudflare SDKs to your application: - +```bash {tabTitle:npm} +npm install @sentry/tanstackstart-react @sentry/cloudflare --save +``` + +```bash {tabTitle:yarn} +yarn add @sentry/tanstackstart-react @sentry/cloudflare +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/tanstackstart-react @sentry/cloudflare +``` ## Configure @@ -42,7 +54,7 @@ When deploying TanStack Start to Cloudflare Workers, you need to wrap the server ### Create a Custom Server Entry @@ -166,8 +178,8 @@ export const startInstance = createStart(() => { ### Add Readable Stack Traces With Source Maps (Optional) ### Control the Data You Send to Sentry (Optional) @@ -224,7 +236,7 @@ Now's a good time to customize your setup and look into more advanced topics. Ou - Check out setup instructions for other popular [frameworks on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/) -- Find various support topics in troubleshooting +- Find various support topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) - [Get support](https://www.sentry.help/en/) diff --git a/platform-includes/getting-started-cloudflare/javascript.astro.mdx b/platform-includes/getting-started-cloudflare/javascript.astro.mdx new file mode 100644 index 0000000000000..d28113db03d3f --- /dev/null +++ b/platform-includes/getting-started-cloudflare/javascript.astro.mdx @@ -0,0 +1,258 @@ +### Install the Sentry SDKs + +Install both `@sentry/astro` and `@sentry/cloudflare`: + +```bash {tabTitle:npm} +npm install @sentry/astro @sentry/cloudflare +``` + +```bash {tabTitle:yarn} +yarn add @sentry/astro @sentry/cloudflare +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/astro @sentry/cloudflare +``` + +## Configure + +### Wrangler Configuration + + + +### 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, + // ___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 + }), + handler +); +``` + +### Register the Sentry Integration + +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. + +```javascript {filename:astro.config.mjs} +import { defineConfig } from "astro/config"; +import cloudflare from "@astrojs/cloudflare"; +import sentry from "@sentry/astro"; + +export default defineConfig({ + adapter: cloudflare(), + integrations: [sentry()], +}); +``` + +### Configure Client-side Sentry + +Create a `sentry.client.config.(ts|js)` file in the root of your project. In this file, import and initialize Sentry for the client: + +```javascript {filename:sentry.client.config.(ts|js)} +import * as Sentry from "@sentry/astro"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + integrations: [ + // ___PRODUCT_OPTION_START___ performance + Sentry.browserTracingIntegration(), + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ session-replay + Sentry.replayIntegration(), + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ user-feedback + Sentry.feedbackIntegration({ + // Additional SDK configuration goes in here, for example: + colorScheme: "system", + }), + // ___PRODUCT_OPTION_END___ user-feedback + ], + // ___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___ session-replay + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ session-replay +}); +``` + +### Configure Server-side Sentry + +Server-side Sentry is already configured in your custom entry point file (`sentry.server.config.ts`) created in the previous step. + +### Add Readable Stack Traces With Source Maps + +To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slugs in the `sentry` options inside `astro.config.mjs`: + +```javascript {filename:astro.config.mjs} +import { defineConfig } from "astro/config"; +import cloudflare from "@astrojs/cloudflare"; +import sentry from "@sentry/astro"; + +export default defineConfig({ + adapter: cloudflare(), + integrations: [ + sentry({ + org: "___ORG_SLUG___", + project: "___PROJECT_SLUG___", + // store your auth token in an environment variable + authToken: process.env.SENTRY_AUTH_TOKEN, + }), + ], +}); +``` + +To keep your auth token secure, set the `SENTRY_AUTH_TOKEN` environment variable in your build environment: + + + +```bash {filename:.env.sentry-build-plugin} +SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ +``` + + + +### Control the Data You Send to Sentry (Optional) + + + +## Verify Your Setup + +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +### Issues + + +To verify that Sentry captures errors and creates issues in your Sentry project, +create a test page, for example, at `src/pages/test.astro` with two buttons. + +```html {filename: test.astro} + + + + +``` + +Then also create the route we're calling in our test page, like `src/pages/api/test-error.(js|ts)`: + +Next, open your test page in a browser and click the buttons to trigger a frontend error and an error in the API route. + +```javascript {filename: test-error.(js|ts)} +export async function GET() { + throw new Error("Sentry Example API Route Error"); +} +``` + + + +### Tracing + +To test tracing, create a custom span to measure the time it takes for the API request to complete: + +```html {filename: test.astro} + + + +``` + + + + + + + + + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). + + + +## Next Steps + +At this point, you should have integrated Sentry into your Astro application and should already be sending data to your Sentry project. + +Now's a good time to customize your setup and look into more advanced topics. +Our next recommended steps for you are: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Continue to customize your configuration +- Learn how to manually capture errors +- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts + + + +- Find various topics in Troubleshooting +- [Get support](https://www.sentry.help/en/) + + diff --git a/platform-includes/getting-started-cloudflare/javascript.remix.mdx b/platform-includes/getting-started-cloudflare/javascript.remix.mdx new file mode 100644 index 0000000000000..ee817b2c68666 --- /dev/null +++ b/platform-includes/getting-started-cloudflare/javascript.remix.mdx @@ -0,0 +1,388 @@ +## Configure + +### Configure Client-Side Sentry + +Create a client file `entry.client.tsx` in the `app` folder of your project if you don't have one already. In this file, import and initialize the Sentry SDK: + +```typescript {tabTitle:Client} {filename: entry.client.tsx} +import { useLocation, useMatches } from "@remix-run/react"; +import * as Sentry from "@sentry/remix"; +import { useEffect } from "react"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + integrations: [ + // ___PRODUCT_OPTION_START___ performance + Sentry.browserTracingIntegration({ + useEffect, + useLocation, + useMatches, + }), + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ session-replay + // Replay is only available in the client + Sentry.replayIntegration(), + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ user-feedback + Sentry.feedbackIntegration({ + // Additional SDK configuration goes in here, for example: + colorScheme: "system", + }), + // ___PRODUCT_OPTION_END___ user-feedback + ], + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + tracesSampleRate: 1.0, + + // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ session-replay + + // Capture Replay for 10% of all sessions, + // plus for 100% of sessions with an error + // Learn more at + // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ session-replay +}); +``` + +#### Remix ErrorBoundary + +To capture errors from your [ErrorBoundary](https://remix.run/docs/en/main/route/error-boundary), define it in `root.tsx` to act as a fallback for all routes or create route-specific error boundaries in your route components. + +In your `ErrorBoundary` component, use `Sentry.captureRemixErrorBoundaryError` to send the captured error to Sentry: + +```tsx {filename: root.tsx} +import { captureRemixErrorBoundaryError } from "@sentry/remix"; + +export const ErrorBoundary = () => { + const error = useRouteError(); + + captureRemixErrorBoundaryError(error); + + return
...
; +}; +``` + +#### Performance Monitoring + +Wrap your Remix root component with `withSentry` to capture performance data: + +```tsx {filename: root.tsx} +import { + Links, + LiveReload, + Meta, + Outlet, + Scripts, + ScrollRestoration, +} from "@remix-run/react"; + +import { withSentry } from "@sentry/remix"; + +function App() { + return ( + + + + + + + + + + + + + ); +} + +export default withSentry(App); +``` + +### Configure Server-Side Sentry + +Create a Worker entry file, for example `server.ts` in your project's root folder, and set it as `main` in your wrangler config. + +In this file, instrument your Remix server build with `instrumentBuild` from `@sentry/remix/cloudflare`, pass it to `createRequestHandler`, and wrap the exported handler with `Sentry.withSentry()` from `@sentry/cloudflare`. `withSentry` isolates each request, so scope data like tags and users stays on the request that set it. + + + +Don't also wrap `createRequestHandler` with `makeWrappedCreateRequestHandler`. Combined with `withSentry`, it reports every request twice, as two `http.server` transactions in two different traces. + + + +```typescript {filename:server.ts} +import { createRequestHandler } from "@remix-run/cloudflare"; +import * as Sentry from "@sentry/cloudflare"; +import { instrumentBuild } from "@sentry/remix/cloudflare"; +// The server build produced by `remix vite:build` +import * as remixBuild from "./build/server/index.js"; + +const handleRequest = createRequestHandler(instrumentBuild(remixBuild)); + +export default Sentry.withSentry( + (env) => ({ + dsn: "___PUBLIC_DSN___", + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + }), + { + async fetch(request, env, ctx) { + return handleRequest(request, { env, ctx }); + }, + } +); +``` + + + + + +```javascript {filename:functions/_middleware.js} +import * as Sentry from "@sentry/cloudflare"; + +export const onRequest = [ + // Make sure Sentry is the first middleware + Sentry.sentryPagesPlugin((context) => ({ + dsn: "___PUBLIC_DSN___", + + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + + // Optionally limit which action formData fields are captured. + // Without this option, all fields are captured. + captureActionFormDataKeys: { + key_x: true, + key_y: true, + }, + })), + // Add more middlewares here +]; +``` + + + +### Capture Server-Side Errors + +To automatically capture server-side errors, export `sentryHandleError` as the [`handleError`](https://remix.run/docs/en/main/file-conventions/entry.server#handleerror) function from your server entry point (`entry.server.tsx`). Without this export, Remix handles errors thrown in loaders and actions itself, and Sentry doesn't receive them. + + + +Import from `@sentry/remix/cloudflare`, not from `@sentry/remix`. In a Cloudflare server build, `sentryHandleError` from `@sentry/remix` is `undefined`, and no errors are captured. + + + +```typescript {filename: entry.server.tsx} +import { sentryHandleError } from "@sentry/remix/cloudflare"; + +export const handleError = sentryHandleError; +``` + +### Configure Cloudflare for Sentry + + + +### Configure Vite + +Add two Sentry plugins to your `vite.config.ts`, next to the Remix plugin: + +- `sentryRemixVitePlugin` from `@sentry/remix/vite` parameterizes transaction names with your route patterns, for example `/users/:id`. +- `sentryCloudflareVitePlugin` from `@sentry/cloudflare/vite` instruments supported bundled dependencies at build time, so you get spans for database clients like `mysql`. Without it, database calls produce no spans and no warning. + +Set `ssr.target` to `webworker` and bundle the Sentry packages and any database client you want traced with `ssr.noExternal`. Setting `noExternal: true` bundles every dependency, which works too. + +```typescript {filename:vite.config.ts} {2-3, 11-12, 14-17} +import { vitePlugin as remix } from "@remix-run/dev"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { sentryRemixVitePlugin } from "@sentry/remix/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [ + remix({ + // ... your Remix plugin options + }), + sentryRemixVitePlugin(), + sentryCloudflareVitePlugin(), + ], + ssr: { + target: "webworker", + noExternal: ["mysql", /^@sentry\//, "@opentelemetry/api"], + }, +}); +``` + +Build your app with `remix vite:build`. Under Vite 6, a plain `vite build` only builds the client and skips `build/server`, without an error. + +```bash +npx remix vite:build +``` + +### Add Readable Stack Traces With Source Maps (Optional) + +To upload source maps for clear error stack traces, pass your Sentry organization, project, and auth token to `sentryRemixVitePlugin` from the previous step. It injects debug IDs, uploads the source maps during your production build, and deletes them from your build output afterwards. + +The plugin also turns on hidden source maps for you, unless you set `build.sourcemap` yourself. + + + +Check our [Source Maps documentation](/platforms/javascript/guides/remix/sourcemaps/) for +alternative setup options. + + + +```javascript {filename:vite.config.ts} {10-16} +import { vitePlugin as remix } from "@remix-run/dev"; +import { sentryRemixVitePlugin } from "@sentry/remix/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [ + remix({ + // ... your Remix plugin options + }), + sentryRemixVitePlugin({ + // If you use environment variables, + // you don't need to specify these options + org: "___ORG_SLUG___", + project: "___PROJECT_SLUG___", + // store your auth token in an environment variable + authToken: process.env.SENTRY_AUTH_TOKEN, + }), + // ... other plugins + ], +}); +``` + +To keep your auth token secure, always store it in an environment variable instead of directly in your files: + + + +```bash {filename:.env} +SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ +``` + + + +### Control the Data You Send to Sentry (Optional) + + + +## Verify Your Setup + +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +### Issues + + + +To verify that Sentry captures errors and creates issues in your Sentry project, add a test button to one of your pages. + + + +Open the page in a browser and click the button to trigger a frontend error. + + + +```javascript + +``` + + + +### Tracing + +To test your tracing configuration, update the previous code snippet by calling a non-existing route and starting a trace to measure the time it takes for the execution of your code. + +Open the page in a browser and click the button to trigger the frontend error and a trace. + +```javascript + +``` + + + + + + + + + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). + + + +## Next Steps + +At this point, you should have integrated Sentry into your Remix application and should already be sending error and performance data to your Sentry project. + +Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to manually capture errors +- Continue to customize your configuration +- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts + + + +- If you encountered issues with the manual setup, try our installation wizard +- Find various support topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) and [Remix troubleshooting](/platforms/javascript/guides/remix/troubleshooting/) +- [Get support](https://www.sentry.help/en/) + + diff --git a/platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx b/platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx new file mode 100644 index 0000000000000..e5f5b3efe3bdd --- /dev/null +++ b/platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx @@ -0,0 +1,358 @@ +## Prerequisites + +You need: + +- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) +- Your application up and running +- SvelteKit version `2.0.0+` (we recommend `2.31.0` or higher for best support) +- Vite version `4.2` or newer + + + +Version `2.31.0` of SvelteKit introduces [official support for observability and tracing](https://svelte.dev/docs/kit/observability). +This means that Sentry can now follow the official best practice for how the SDK should be set up: + +- The Sentry SDK will be initialized at the correct, earliest possible time on the server, allowing for all its auto-instrumentation to work correctly. + This means, you will now get spans from auto instrumentation (e.g. database queries) automatically. +- The Sentry SDK picks up spans emitted from SvelteKit directly. + You'll get more accurate insights into the performance of your handlers, server actions, `load`, and remote functions. + +SvelteKit observability is still an experimental feature in SvelteKit 2.x, but we recommend giving it a try. +The Sentry wizard, as well as this guide, will use it as the default way of setting up the SDK. + + + + + +## Install + +Choose the features you want to configure, and this guide will show you how: + + + + + +### Install the Sentry SDK + +Run the command for your preferred package manager to add the Sentry SDK to your application: + +If you're updating your Sentry SDK to the latest version, check out our migration guide to learn more about breaking changes. + +```bash {tabTitle:npm} +npm install @sentry/sveltekit --save +``` + +```bash {tabTitle:yarn} +yarn add @sentry/sveltekit +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/sveltekit +``` + +## Configure + +You need to initialize and configure the Sentry SDK in three places: the client side, the server side, and your Vite config. + +### Configure Client-Side Sentry + +Create a client hooks file `src/hooks.client.(js|ts)` in your project if you don't have one already. In this file, import and initialize the Sentry SDK and add the `handleErrorWithSentry` function to the [`handleError` hook](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError). + +```javascript {filename:src/hooks.client.(js|ts)} {1, 3-37, 43} +import * as Sentry from "@sentry/sveltekit"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + integrations: [ + // ___PRODUCT_OPTION_START___ session-replay + Sentry.replayIntegration(), + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ user-feedback + Sentry.feedbackIntegration({ + // Additional SDK configuration goes in here, for example: + colorScheme: "system", + }), + // ___PRODUCT_OPTION_END___ user-feedback + ], + + // ___PRODUCT_OPTION_START___ session-replay + // Capture Replay for 10% of all sessions, + // plus for 100% of sessions with an error + // Learn more at + // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ session-replay +}); + +const myErrorHandler = ({ error, event }) => { + console.error("An error occurred on the client side:", error, event); +}; + +export const handleError = Sentry.handleErrorWithSentry(myErrorHandler); + +// or alternatively, if you don't have a custom error handler: +// export const handleError = handleErrorWithSentry(); +``` + +### Configure Server-Side Sentry + +_Requires SvelteKit `2.31.0` or higher and `@sentry/sveltekit` `10.8.0` or higher._ + +Configure server-side instrumentation and tracing. Where this config lives depends on your SvelteKit version — SvelteKit 2 uses `svelte.config.js`, while SvelteKit 3 moved it into the `sveltekit()` Vite plugin options in `vite.config.(js|ts)` instead (see [Configure Vite](#configure-vite) below). SvelteKit 3 no longer needs an instrumentation flag, so the only option to set there is `tracing`. + +```js {tabTitle:SvelteKit 2} {mdExpandTabs} {filename:svelte.config.js} {3-12} +const config = { + kit: { + experimental: { + instrumentation: { + server: true, + }, + // ___PRODUCT_OPTION_START___ performance + tracing: { + server: true, + }, + // ___PRODUCT_OPTION_END___ performance + }, + }, +}; + +export default config; +``` + +```js {tabTitle:SvelteKit 3} {filename:vite.config.(js|ts)} +import { sveltekit } from "@sveltejs/kit/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [ + sveltekit({ + // ___PRODUCT_OPTION_START___ performance + tracing: { + server: true, + }, + // ___PRODUCT_OPTION_END___ performance + // ... rest of your SvelteKit config + }), + ], + // ... rest of your Vite config +}); +``` + +Create a server hooks file `src/hooks.server.(js|ts)` in your project if you don't have one already. In this file, import and initialize the Sentry SDK and add the `handleErrorWithSentry` function to the [`handleError` hook](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) and Sentry's Cloudflare request handler to the [`handle` hook](https://kit.svelte.dev/docs/hooks#server-hooks-handle). + +```javascript {filename:src/hooks.server.(js|ts)} +import { + handleErrorWithSentry, + sentryHandle, + initCloudflareSentryHandle, +} from "@sentry/sveltekit"; +import { sequence } from "@sveltejs/kit/hooks"; +import * as Sentry from "@sentry/sveltekit"; + +export const handle = sequence( + initCloudflareSentryHandle({ + dsn: "___PUBLIC_DSN___", + + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + }), + sentryHandle() +); + +const myErrorHandler = ({ error, event }) => { + console.error("An error occurred on the server side:", error, event); +}; + +export const handleError = Sentry.handleErrorWithSentry(myErrorHandler); +// or alternatively, if you don't have a custom error handler: +// export const handleError = handleErrorWithSentry(); +``` + +### Configure Vite + +Add the `sentrySvelteKit` plugin **before** `sveltekit` in your `vite.config.(js|ts)` file to automatically upload source maps to Sentry and instrument `load` functions for tracing if it's configured. + +```javascript {filename:vite.config.(js|ts)} {2,6} +import { sveltekit } from "@sveltejs/kit/vite"; +import { sentrySvelteKit } from "@sentry/sveltekit/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [sentrySvelteKit(), sveltekit()], + // ... rest of your Vite config +}); +``` + +### Configure Cloudflare for Sentry + + + +### Add Readable Stack Traces With Source Maps (Optional) + +To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slug in your `vite.config.(js|ts)` file: + +```javascript {filename:vite.config.(js|ts)} {6-13} +import { sveltekit } from "@sveltejs/kit/vite"; +import { sentrySvelteKit } from "@sentry/sveltekit/vite"; + +export default { + plugins: [ + sentrySvelteKit({ + org: "___ORG_SLUG___", + project: "___PROJECT_SLUG___", + // store your auth token in an environment variable + authToken: process.env.SENTRY_AUTH_TOKEN, + }), + sveltekit(), + ], + // ... rest of your Vite config +}; +``` + +To keep your auth token secure, always store it in an environment variable instead of directly in your files: + + + +```bash {filename:.env} +SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ +``` + + + +### Control the Data You Send to Sentry (Optional) + + + +## Verify Your Setup + +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +### Issues + +To verify that Sentry captures errors and creates issues in your Sentry project, create a test page, for example, at `src/routes/sentry-example/+page.svelte` with a button that throws an error when clicked. + + + Open the page `sentry-example` in a browser and click the button to trigger a + frontend error. + + + + +```html {filename:+page.svelte} + + + +``` + + +### Tracing + +To test tracing, create a test API route like `src/routes/sentry-example/+server.(js|ts)`. + +```javascript {filename:+server.(js|ts)} +export const GET = async () => { + throw new Error("Sentry Example API Route Error"); +}; +``` + +Next, update your test button to call this route and throw an error if the response isn't `ok`. + +Open the page `sentry-example` in a browser and click the button to trigger two errors: + +- a frontend error +- an error within the API route + +Additionally, this starts a trace to measure the time it takes for the API request to complete. + +```html {filename:+page.svelte} + + + +``` + + + + + + + + + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). + + + +## Next Steps + +At this point, you should have integrated Sentry into your SvelteKit application and should already be sending data to your Sentry project. + +Now's a good time to customize your setup and look into more advanced topics. +Our next recommended steps for you are: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/javascript/guides/cloudflare/usage/) +- Continue to [customize your configuration](/platforms/javascript/guides/cloudflare/configuration/) +- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Learn how to [manually instrument](/platforms/javascript/guides/sveltekit/apis/#load-function-instrumentation) SvelteKit-specific features + + + +- Find various support topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) and [SvelteKit troubleshooting](/platforms/javascript/guides/sveltekit/troubleshooting/) +- [Get support](https://www.sentry.help/en/) + + + + diff --git a/platform-includes/getting-started-complete/javascript.astro.mdx b/platform-includes/getting-started-complete/javascript.astro.mdx index 064dff9974b45..fb3cac04de9db 100644 --- a/platform-includes/getting-started-complete/javascript.astro.mdx +++ b/platform-includes/getting-started-complete/javascript.astro.mdx @@ -1,5 +1,3 @@ - - ### Install the Sentry SDK Install and add the Sentry integration using the `astro` CLI: @@ -34,88 +32,8 @@ pnpm add @sentry/profiling-node - - - - -### Install the Sentry SDKs - -Install both `@sentry/astro` and `@sentry/cloudflare`: - -```bash {tabTitle:npm} -npm install @sentry/astro @sentry/cloudflare -``` - -```bash {tabTitle:yarn} -yarn add @sentry/astro @sentry/cloudflare -``` - -```bash {tabTitle:pnpm} -pnpm add @sentry/astro @sentry/cloudflare -``` - - - ## Configure - - -### Wrangler Configuration - - - -### 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, - // ___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 - }), - handler -); -``` - -### Register the Sentry Integration - -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. - -```javascript {filename:astro.config.mjs} -import { defineConfig } from "astro/config"; -import cloudflare from "@astrojs/cloudflare"; -import sentry from "@sentry/astro"; - -export default defineConfig({ - adapter: cloudflare(), - integrations: [sentry()], -}); -``` - - - - - ### Apply Instrumentation to Your App Register the Sentry integration in your `astro.config.mjs` file: @@ -129,8 +47,6 @@ export default defineConfig({ }); ``` - - ### Configure Client-side Sentry Create a `sentry.client.config.(ts|js)` file in the root of your project. In this file, import and initialize Sentry for the client: @@ -174,8 +90,6 @@ Sentry.init({ }); ``` - - Sentry automatically detects configuration files named `sentry.(client|server).config.(ts|js)` in the root of your project. You can rename these files or move them to a custom folder within your project. @@ -195,12 +109,8 @@ export default defineConfig({ - - ### Configure Server-side Sentry - - Create a `sentry.server.config.(ts|js)` file in the root of your project. In this file, import and initialize Sentry for the server: ```javascript {filename:sentry.server.config.(ts|js)} @@ -233,27 +143,15 @@ Sentry.init({ }); ``` - - - - -Server-side Sentry is already configured in your custom entry point file (`sentry.server.config.ts`) created in the previous step. - - - ### Add Readable Stack Traces With Source Maps To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slugs in the `sentry` options inside `astro.config.mjs`: - - ```javascript {filename:astro.config.mjs} import { defineConfig } from "astro/config"; -import cloudflare from "@astrojs/cloudflare"; import sentry from "@sentry/astro"; export default defineConfig({ - adapter: cloudflare(), integrations: [ sentry({ org: "___ORG_SLUG___", @@ -265,28 +163,6 @@ export default defineConfig({ }); ``` - - - - -```javascript {filename:astro.config.mjs} -import { defineConfig } from "astro/config"; -import sentry from "@sentry/astro"; - -export default defineConfig({ - integrations: [ - sentry({ - org: "___ORG_SLUG___", - project: "___PROJECT_SLUG___", - // store your auth token in an environment variable - authToken: process.env.SENTRY_AUTH_TOKEN, - }), - ], -}); -``` - - - To keep your auth token secure, set the `SENTRY_AUTH_TOKEN` environment variable in your build environment: @@ -297,14 +173,10 @@ SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ - - ### Avoid Ad Blockers With Tunneling (Optional) - - ### Control the Data You Send to Sentry (Optional) @@ -394,18 +266,8 @@ To test tracing, create a custom span to measure the time it takes for the API r Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). - - - - - - - - - - ## Next Steps At this point, you should have integrated Sentry into your Astro application and should already be sending data to your Sentry project. @@ -413,25 +275,12 @@ At this point, you should have integrated Sentry into your Astro application and Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: - - -- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Continue to customize your configuration -- Learn how to manually capture errors -- Learn more about [deploying Astro apps to Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/astro/) -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts - - - - - - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup - Continue to customize your configuration - Learn how to manually capture errors +- Learn more about [deploying Astro apps to Cloudflare](/platforms/javascript/guides/astro/cloudflare/) - Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts - - - Find various topics in Troubleshooting diff --git a/platform-includes/getting-started-complete/javascript.remix.mdx b/platform-includes/getting-started-complete/javascript.remix.mdx index d3507e2ad8fa6..db074eb1a0887 100644 --- a/platform-includes/getting-started-complete/javascript.remix.mdx +++ b/platform-includes/getting-started-complete/javascript.remix.mdx @@ -111,8 +111,6 @@ export default withSentry(App); ### Configure Server-Side Sentry - - Create an instrumentation file `instrument.server.mjs` in your project's root folder and initialize the Sentry SDK within it: ```typescript {tabTitle:Server} {filename: instrument.server.mjs} @@ -178,91 +176,8 @@ const app = express(); - - - - -Create a Worker entry file, for example `server.ts` in your project's root folder, and set it as `main` in your wrangler config. - -In this file, instrument your Remix server build with `instrumentBuild` from `@sentry/remix/cloudflare`, pass it to `createRequestHandler`, and wrap the exported handler with `Sentry.withSentry()` from `@sentry/cloudflare`. `withSentry` isolates each request, so scope data like tags and users stays on the request that set it. - - - -Don't also wrap `createRequestHandler` with `makeWrappedCreateRequestHandler`. Combined with `withSentry`, it reports every request twice, as two `http.server` transactions in two different traces. - - - -```typescript {filename:server.ts} -import { createRequestHandler } from "@remix-run/cloudflare"; -import * as Sentry from "@sentry/cloudflare"; -import { instrumentBuild } from "@sentry/remix/cloudflare"; -// The server build produced by `remix vite:build` -import * as remixBuild from "./build/server/index.js"; - -const handleRequest = createRequestHandler(instrumentBuild(remixBuild)); - -export default Sentry.withSentry( - (env) => ({ - dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - }), - { - async fetch(request, env, ctx) { - return handleRequest(request, { env, ctx }); - }, - } -); -``` - - - - - -```javascript {filename:functions/_middleware.js} -import * as Sentry from "@sentry/cloudflare"; - -export const onRequest = [ - // Make sure Sentry is the first middleware - Sentry.sentryPagesPlugin((context) => ({ - dsn: "___PUBLIC_DSN___", - - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - - // Optionally limit which action formData fields are captured. - // Without this option, all fields are captured. - captureActionFormDataKeys: { - key_x: true, - key_y: true, - }, - })), - // Add more middlewares here -]; -``` - - - - - ### Capture Server-Side Errors - - To automatically capture server-side errors, export a [`handleError`](https://remix.run/docs/en/main/file-conventions/entry.server#handleerror) function from your server entry point (`entry.server.tsx`). Choose one of the two options: - Wrap your custom error handler with `wrapHandleErrorWithSentry`. @@ -290,41 +205,8 @@ import * as Sentry from "@sentry/remix"; export const handleError = Sentry.sentryHandleError; ``` - - - - -To automatically capture server-side errors, export `sentryHandleError` as the [`handleError`](https://remix.run/docs/en/main/file-conventions/entry.server#handleerror) function from your server entry point (`entry.server.tsx`). Without this export, Remix handles errors thrown in loaders and actions itself, and Sentry doesn't receive them. - - - -Import from `@sentry/remix/cloudflare`, not from `@sentry/remix`. In a Cloudflare server build, `sentryHandleError` from `@sentry/remix` is `undefined`, and no errors are captured. - - - -```typescript {filename: entry.server.tsx} -import { sentryHandleError } from "@sentry/remix/cloudflare"; - -export const handleError = sentryHandleError; -``` - - - - - -### Configure Cloudflare for Sentry - - - - - ### Configure Vite - - Add `sentryRemixVitePlugin` from `@sentry/remix/vite` to your `vite.config.ts`. The plugin: - Parameterizes client-side transaction names with your route patterns, for example `/users/:id`. @@ -351,46 +233,6 @@ export default defineConfig({ }); ``` - - - - -Add two Sentry plugins to your `vite.config.ts`, next to the Remix plugin: - -- `sentryRemixVitePlugin` from `@sentry/remix/vite` parameterizes transaction names with your route patterns, for example `/users/:id`. -- `sentryCloudflareVitePlugin` from `@sentry/cloudflare/vite` instruments supported bundled dependencies at build time, so you get spans for database clients like `mysql`. Without it, database calls produce no spans and no warning. - -Set `ssr.target` to `webworker` and bundle the Sentry packages and any database client you want traced with `ssr.noExternal`. Setting `noExternal: true` bundles every dependency, which works too. - -```typescript {filename:vite.config.ts} {2-3, 11-12, 14-17} -import { vitePlugin as remix } from "@remix-run/dev"; -import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; -import { sentryRemixVitePlugin } from "@sentry/remix/vite"; -import { defineConfig } from "vite"; - -export default defineConfig({ - plugins: [ - remix({ - // ... your Remix plugin options - }), - sentryRemixVitePlugin(), - sentryCloudflareVitePlugin(), - ], - ssr: { - target: "webworker", - noExternal: ["mysql", /^@sentry\//, "@opentelemetry/api"], - }, -}); -``` - -Build your app with `remix vite:build`. Under Vite 6, a plain `vite build` only builds the client and skips `build/server`, without an error. - -```bash -npx remix vite:build -``` - - - ### Add Readable Stack Traces With Source Maps (Optional) To upload source maps for clear error stack traces, pass your Sentry organization, project, and auth token to `sentryRemixVitePlugin` from the previous step. It injects debug IDs, uploads the source maps during your production build, and deletes them from your build output afterwards. @@ -437,13 +279,10 @@ SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ - ### Avoid Ad Blockers With Tunneling (Optional) - - ### Control the Data You Send to Sentry (Optional) @@ -519,17 +358,8 @@ Open the page in a browser and click the button to trigger the frontend error an Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). - - - - - - - - - ## Next Steps At this point, you should have integrated Sentry into your Remix application and should already be sending error and performance data to your Sentry project. @@ -541,7 +371,6 @@ Now's a good time to customize your setup and look into more advanced topics. Ou - Continue to customize your configuration - Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts - - If you encountered issues with the manual setup, try our installation wizard @@ -549,14 +378,3 @@ Now's a good time to customize your setup and look into more advanced topics. Ou - [Get support](https://www.sentry.help/en/) - - - - - -- If you encountered issues with the manual setup, try our installation wizard -- Find various support topics in Cloudflare troubleshooting and [Remix troubleshooting](/platforms/javascript/guides/remix/troubleshooting/) -- [Get support](https://www.sentry.help/en/) - - - diff --git a/platform-includes/getting-started-complete/javascript.sveltekit.mdx b/platform-includes/getting-started-complete/javascript.sveltekit.mdx index c37251053054d..52fc145582743 100644 --- a/platform-includes/getting-started-complete/javascript.sveltekit.mdx +++ b/platform-includes/getting-started-complete/javascript.sveltekit.mdx @@ -20,18 +20,12 @@ This means that Sentry can now follow the official best practice for how the SDK SvelteKit observability is still an experimental feature in SvelteKit 2.x, but we recommend giving it a try. The Sentry wizard, as well as this guide, will use it as the default way of setting up the SDK. - - If you've already set up the SDK and don't want to migrate to the new setup, or don't want to upgrade to SvelteKit `2.31.0` or higher, that's fine too. Just follow this guide instead. However, note that auto instrumentation (e.g. for database queries) will not work. - -
- - The SvelteKit Sentry SDK is designed to work out of the box with several SvelteKit adapters and their underlying server runtimes. Here's an overview of the current support: @@ -41,7 +35,7 @@ Here's an overview of the current support: - [Adapter-vercel](https://kit.svelte.dev/docs/adapter-vercel) when used with Vercel's Node.js Lambda runtime - [Adapter-node](https://kit.svelte.dev/docs/adapter-node) - **Supported non-Node.js runtimes** - - [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) requires [additional setup](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/) + - [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) requires [additional setup](/platforms/javascript/guides/sveltekit/cloudflare/) - **Currently not supported** - Non-Node.js server runtimes, such as Vercel's edge runtime, are not yet supported. - **Other adapters** @@ -49,8 +43,6 @@ Here's an overview of the current support: - - ## Install @@ -66,17 +58,8 @@ Choose the features you want to configure, and this guide will show you how: ]} /> - - - - - - - - - ### Install the Sentry SDK Run the command for your preferred package manager to add the Sentry SDK to your application: @@ -152,18 +135,8 @@ export const handleError = Sentry.handleErrorWithSentry(myErrorHandler); ### Configure Server-Side Sentry - - _Requires SvelteKit `2.31.0` or higher and `@sentry/sveltekit` `10.8.0` or higher._ If you're using older versions, check out [this guide](../manual-setup__v10.7.0#configure-server-side-sentry) instead. - - - - -_Requires SvelteKit `2.31.0` or higher and `@sentry/sveltekit` `10.8.0` or higher._ - - - Configure server-side instrumentation and tracing. Where this config lives depends on your SvelteKit version — SvelteKit 2 uses `svelte.config.js`, while SvelteKit 3 moved it into the `sveltekit()` Vite plugin options in `vite.config.(js|ts)` instead (see [Configure Vite](#configure-vite) below). SvelteKit 3 no longer needs an instrumentation flag, so the only option to set there is `tracing`. ```js {tabTitle:SvelteKit 2} {mdExpandTabs} {filename:svelte.config.js} {3-12} @@ -204,8 +177,6 @@ export default defineConfig({ }); ``` - - Create a `src/instrumentation.server.(js|ts)` file (if you don't have one already) to initialize the server-side SDK: ```js {filename:src/instrumentation.server.(js|ts)} {1, 3-15} @@ -250,49 +221,6 @@ If you're using SvelteKit versions older than `2.16.0` and encounter Content Sec
- - - - -Create a server hooks file `src/hooks.server.(js|ts)` in your project if you don't have one already. In this file, import and initialize the Sentry SDK and add the `handleErrorWithSentry` function to the [`handleError` hook](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) and Sentry's Cloudflare request handler to the [`handle` hook](https://kit.svelte.dev/docs/hooks#server-hooks-handle). - -```javascript {filename:src/hooks.server.(js|ts)} -import { - handleErrorWithSentry, - sentryHandle, - initCloudflareSentryHandle, -} from "@sentry/sveltekit"; -import { sequence } from "@sveltejs/kit/hooks"; -import * as Sentry from "@sentry/sveltekit"; - -export const handle = sequence( - initCloudflareSentryHandle({ - dsn: "___PUBLIC_DSN___", - - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - }), - sentryHandle() -); - -const myErrorHandler = ({ error, event }) => { - console.error("An error occurred on the server side:", error, event); -}; - -export const handleError = Sentry.handleErrorWithSentry(myErrorHandler); -// or alternatively, if you don't have a custom error handler: -// export const handleError = handleErrorWithSentry(); -``` - - - ### Configure Vite Add the `sentrySvelteKit` plugin **before** `sveltekit` in your `vite.config.(js|ts)` file to automatically upload source maps to Sentry and instrument `load` functions for tracing if it's configured. @@ -308,17 +236,6 @@ export default defineConfig({ }); ``` - - -### Configure Cloudflare for Sentry - - - - - ### Add Readable Stack Traces With Source Maps (Optional) To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slug in your `vite.config.(js|ts)` file: @@ -351,7 +268,6 @@ SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ - ### Override Adapter Detection `sentrySvelteKit` tries to auto-detect your SvelteKit adapter to configure source maps upload correctly. If you're using an unsupported adapter or the wrong one is detected, set it using the `adapter` option: @@ -371,15 +287,10 @@ export default { }; ``` - - - ### Avoid Ad Blockers With Tunneling (Optional) - - ### Control the Data You Send to Sentry (Optional) @@ -466,17 +377,8 @@ Additionally, this starts a trace to measure the time it takes for the API reque Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). - - - - - - - - - ## Next Steps At this point, you should have integrated Sentry into your SvelteKit application and should already be sending data to your Sentry project. @@ -484,12 +386,11 @@ At this point, you should have integrated Sentry into your SvelteKit application Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: - - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup - Learn how to [manually capture errors](/platforms/javascript/guides/sveltekit/usage/) - Continue to [customize your configuration](/platforms/javascript/guides/sveltekit/configuration/) - Learn how to [manually instrument](/platforms/javascript/guides/sveltekit/apis/#load-function-instrumentation) SvelteKit-specific features -- Learn more about [deploying SvelteKit apps to Cloudflare Workers and Pages](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/) +- Learn more about [deploying SvelteKit apps to Cloudflare Workers and Pages](/platforms/javascript/guides/sveltekit/cloudflare/) - Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts @@ -500,21 +401,4 @@ Our next recommended steps for you are: - - - -- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to [manually capture errors](/platforms/javascript/guides/cloudflare/usage/) -- Continue to [customize your configuration](/platforms/javascript/guides/cloudflare/configuration/) -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts -- Learn how to [manually instrument](/platforms/javascript/guides/sveltekit/apis/#load-function-instrumentation) SvelteKit-specific features - - - -- Find various support topics in Cloudflare troubleshooting and [SvelteKit troubleshooting](/platforms/javascript/guides/sveltekit/troubleshooting/) -- [Get support](https://www.sentry.help/en/) - - - - diff --git a/platform-includes/getting-started-prerequisites/javascript.sveltekit.mdx b/platform-includes/getting-started-prerequisites/javascript.sveltekit.mdx index d042a382ab607..8d099e46eb8d6 100644 --- a/platform-includes/getting-started-prerequisites/javascript.sveltekit.mdx +++ b/platform-includes/getting-started-prerequisites/javascript.sveltekit.mdx @@ -36,7 +36,7 @@ Here's an overview of the current support: - [Adapter-vercel](https://kit.svelte.dev/docs/adapter-vercel) when used with Vercel's Node.js Lambda runtime - [Adapter-node](https://kit.svelte.dev/docs/adapter-node) - **Supported non-Node.js runtimes** - - [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) requires [additional setup](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/) + - [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) requires [additional setup](/platforms/javascript/guides/sveltekit/cloudflare/) - **Currently not supported** - Non-Node.js server runtimes, such as Vercel's edge runtime, are not yet supported. - **Other adapters** diff --git a/redirects.js b/redirects.js index 474de531042a6..b1de73e6b8936 100644 --- a/redirects.js +++ b/redirects.js @@ -1053,11 +1053,16 @@ const userDocsRedirects = [ source: '/platforms/javascript/guides/nuxt/install/cloudflare-workers/', destination: '/platforms/javascript/guides/nuxt/cloudflare/', }, - // The Cloudflare quick starts of Next.js and Nuxt moved from the Cloudflare guide into the framework guides. + // The Cloudflare quick starts of these frameworks moved from the Cloudflare guide into the framework guides. { - source: '/platforms/javascript/guides/cloudflare/frameworks/:framework(nextjs|nuxt)/', + source: + '/platforms/javascript/guides/cloudflare/frameworks/:framework(astro|nextjs|nuxt|remix|sveltekit)/', destination: '/platforms/javascript/guides/:framework/cloudflare/', }, + { + source: '/platforms/javascript/guides/cloudflare/frameworks/tanstack-start/', + destination: '/platforms/javascript/guides/tanstackstart-react/cloudflare/', + }, { source: '/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare/', destination: '/platforms/javascript/guides/nextjs/cloudflare/', From 14edd96ebcd9566c35c36edb67f5fe89db38a0cd Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Wed, 21 Oct 2026 13:52:20 +0200 Subject: [PATCH 05/10] docs(js): Move the Hono Cloudflare page into the Hono guide The Hono page under Cloudflare > Frameworks moves into the Hono guide as "Quick Start - Cloudflare", with the full quick start steps. The Remix "Cloudflare SDK Guide" page only linked to the Remix Cloudflare quick start and to Hydrogen, so it redirects to the Remix Cloudflare quick start, which now links to the Hydrogen guides. Co-Authored-By: Claude Opus 5.5 --- .../guides/cloudflare/frameworks/hono.mdx | 70 --------- .../guides/cloudflare/frameworks/index.mdx | 1 + .../javascript/guides/cloudflare/index.mdx | 2 +- .../javascript/guides/hono/cloudflare.mdx | 147 ++++++++++++++++++ .../javascript/guides/remix/cloudflare.mdx | 6 + .../guides/remix/frameworks/index.mdx | 9 -- redirects.js | 6 +- 7 files changed, 160 insertions(+), 81 deletions(-) delete mode 100644 docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx create mode 100644 docs/platforms/javascript/guides/hono/cloudflare.mdx delete mode 100644 docs/platforms/javascript/guides/remix/frameworks/index.mdx diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx deleted file mode 100644 index 6a7df59814d50..0000000000000 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: Hono on Cloudflare -description: "Learn how to instrument your Hono app on Cloudflare Workers with Sentry." ---- - -Hono has its own dedicated SDK (`@sentry/hono`) with first-class support for Cloudflare Workers, Node.js, Bun, and Deno. It works as Hono middleware, so you can drop it into an existing app. - -## Install - -Install `@sentry/hono` together with `@sentry/cloudflare`. The runtime package is a peer dependency that you never import directly, but it must be present and its version must match `@sentry/hono`. - -```bash {tabTitle:npm} -npm install @sentry/hono @sentry/cloudflare -``` - -```bash {tabTitle:yarn} -yarn add @sentry/hono @sentry/cloudflare -``` - -```bash {tabTitle:pnpm} -pnpm add @sentry/hono @sentry/cloudflare -``` - -## Configure - -The SDK needs `AsyncLocalStorage`, so set the `nodejs_compat` compatibility flag and a `compatibility_date` of `2024-09-23` or later in your Wrangler configuration: - -```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} -{ - // Set this to today's date - "compatibility_date": "{{@inject new Date().toISOString().slice(0, 10) }}", - "compatibility_flags": ["nodejs_compat"], -} -``` - -```toml {tabTitle:Toml} {filename:wrangler.toml} -# Set this to today's date -compatibility_date = "{{@inject new Date().toISOString().slice(0, 10) }}" -compatibility_flags = ["nodejs_compat"] -``` - -Add the `sentry()` middleware as early as possible in your Hono app, before any route that you want covered: - -```typescript {filename:index.ts} -import { Hono } from "hono"; -import { sentry } from "@sentry/hono/cloudflare"; - -const app = new Hono(); - -app.use( - sentry(app, { - dsn: "___PUBLIC_DSN___", - - // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. - tracesSampleRate: 1.0, - }) -); - -// Your routes here - -export default app; -``` - -To read the DSN from a Worker binding, pass a callback instead of a plain options object. The callback receives the Worker `env`: - -```typescript {filename:index.ts} -app.use(sentry(app, (env) => ({ dsn: env.SENTRY_DSN }))); -``` - -For the full setup, including verification and the other runtimes, see the **[Hono Quick Start Guide](/platforms/javascript/guides/hono/)**. diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx index 8e9ab81adf73d..ce28841fd1f4b 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx @@ -8,6 +8,7 @@ You can use the Sentry Cloudflare SDK in combination with Sentry meta-framework For these frameworks, follow the Cloudflare quick start in the framework guide: - [Astro on Cloudflare](/platforms/javascript/guides/astro/cloudflare/) +- [Hono on Cloudflare](/platforms/javascript/guides/hono/cloudflare/) - [Next.js on Cloudflare](/platforms/javascript/guides/nextjs/cloudflare/) - [Nuxt on Cloudflare](/platforms/javascript/guides/nuxt/cloudflare/) - [Remix on Cloudflare](/platforms/javascript/guides/remix/cloudflare/) diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index f2dbf0485b22d..67577f8cbf01c 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -15,7 +15,7 @@ This guide covers Cloudflare Workers. If you're deploying a Cloudflare Pages app If you're using any of the listed frameworks, follow their specific setup instructions: - **[Astro](/platforms/javascript/guides/astro/cloudflare/)** -- **[Hono](/platforms/javascript/guides/hono/)** (with @sentry/hono) +- **[Hono](/platforms/javascript/guides/hono/cloudflare/)** (with @sentry/hono) - **[Hydrogen](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)** - **[Next.js](/platforms/javascript/guides/nextjs/cloudflare/)** - **[Nuxt](/platforms/javascript/guides/nuxt/cloudflare/)** diff --git a/docs/platforms/javascript/guides/hono/cloudflare.mdx b/docs/platforms/javascript/guides/hono/cloudflare.mdx new file mode 100644 index 0000000000000..d38c443f61e01 --- /dev/null +++ b/docs/platforms/javascript/guides/hono/cloudflare.mdx @@ -0,0 +1,147 @@ +--- +title: Hono on Cloudflare +sidebar_title: Quick Start - Cloudflare +sidebar_order: 0.5 +description: "Learn how to set up Sentry in your Hono app on Cloudflare Workers and capture your first errors." +--- + +The `@sentry/hono` SDK works as Hono middleware, so you can drop it into your existing Cloudflare Workers app. For Node.js, Bun, and Deno, see the [Hono quick start](/platforms/javascript/guides/hono/). + + + + + +## Install + +Choose the features you want to configure, and this guide will show you how: + + + + + +### Install the Sentry SDK + +Install `@sentry/hono` together with `@sentry/cloudflare`. The runtime package is a peer dependency that you never import directly, but it must be present and its version must match `@sentry/hono`. + +```bash {tabTitle:npm} +npm install @sentry/hono @sentry/cloudflare +``` + +```bash {tabTitle:yarn} +yarn add @sentry/hono @sentry/cloudflare +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/hono @sentry/cloudflare +``` + +## Configure + +### Configure Wrangler + +The SDK needs `AsyncLocalStorage`, so set the `nodejs_compat` compatibility flag and a `compatibility_date` of `2024-09-23` or later in your Wrangler configuration: + +```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} +{ + // Set this to today's date + "compatibility_date": "{{@inject new Date().toISOString().slice(0, 10) }}", + "compatibility_flags": ["nodejs_compat"], +} +``` + +```toml {tabTitle:Toml} {filename:wrangler.toml} +# Set this to today's date +compatibility_date = "{{@inject new Date().toISOString().slice(0, 10) }}" +compatibility_flags = ["nodejs_compat"] +``` + +### Add the Sentry Middleware + +Add the `sentry()` middleware as early as possible in your Hono app, before any route that you want covered: + +```typescript {filename:index.ts} +import { Hono } from "hono"; +import { sentry } from "@sentry/hono/cloudflare"; + +const app = new Hono(); + +app.use( + sentry(app, { + dsn: "___PUBLIC_DSN___", + + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of spans for tracing. + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + }) +); + +// Your routes here + +export default app; +``` + +To read the DSN from a Worker binding, for example a secret, pass a callback instead of a plain options object. The callback receives the Worker `env`: + +```typescript {filename:index.ts} +import { Hono } from "hono"; +import { sentry } from "@sentry/hono/cloudflare"; + +type Bindings = { SENTRY_DSN: string }; + +const app = new Hono<{ Bindings: Bindings }>(); + +app.use(sentry(app, (env) => ({ dsn: env.SENTRY_DSN }))); + +export default app; +``` + +### Report Unhandled Exceptions + +By default, Sentry captures exceptions from Hono's `onError` handler, excluding errors with 3xx or 4xx status codes. No additional configuration is needed for this. + +To control which errors are captured, use the `shouldHandleError` option. + +### Add Readable Stack Traces With Source Maps (Optional) + + + +### Control the Data You Send to Sentry (Optional) + + + +## Verify Your Setup + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). + + + +## Next Steps + +At this point, you should have Sentry integrated into your Hono application on Cloudflare Workers and already be sending data to your Sentry project. + +Now's a good time to customize your setup and look into more advanced topics: + +- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to manually capture errors +- Explore Hono-specific features like custom error filtering +- Continue to customize your configuration +- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts + + + +- Find various topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) +- [Get support](https://www.sentry.help/en/) + + + + diff --git a/docs/platforms/javascript/guides/remix/cloudflare.mdx b/docs/platforms/javascript/guides/remix/cloudflare.mdx index 2115efc0d45c6..9f7bbd5274a04 100644 --- a/docs/platforms/javascript/guides/remix/cloudflare.mdx +++ b/docs/platforms/javascript/guides/remix/cloudflare.mdx @@ -5,6 +5,12 @@ sidebar_order: 0.5 description: "Learn how to instrument your Remix app on Cloudflare Workers and Pages and capture your first errors with Sentry." --- + + +Using Shopify Hydrogen? Follow the [Hydrogen with React Router](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/) guide for Hydrogen 2025.5.0 and later, or the [Hydrogen with Remix](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix/) guide for older versions. + + + diff --git a/docs/platforms/javascript/guides/remix/frameworks/index.mdx b/docs/platforms/javascript/guides/remix/frameworks/index.mdx deleted file mode 100644 index 79e13cc3c9f20..0000000000000 --- a/docs/platforms/javascript/guides/remix/frameworks/index.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Cloudflare SDK Guide -description: "Learn how to set up the Remix SDK or Hydrogen with Cloudflare." ---- - -You can use the Sentry Remix SDK to set up Sentry with frameworks like Shopify's Hydrogen. The following guides will help you get started with the Sentry Remix SDK on Cloudflare: - -- **[Remix on Cloudflare](/platforms/javascript/guides/remix/cloudflare/)** -- **[Hydrogen on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)** diff --git a/redirects.js b/redirects.js index b1de73e6b8936..49ea533e86e64 100644 --- a/redirects.js +++ b/redirects.js @@ -1056,13 +1056,17 @@ const userDocsRedirects = [ // The Cloudflare quick starts of these frameworks moved from the Cloudflare guide into the framework guides. { source: - '/platforms/javascript/guides/cloudflare/frameworks/:framework(astro|nextjs|nuxt|remix|sveltekit)/', + '/platforms/javascript/guides/cloudflare/frameworks/:framework(astro|hono|nextjs|nuxt|remix|sveltekit)/', destination: '/platforms/javascript/guides/:framework/cloudflare/', }, { source: '/platforms/javascript/guides/cloudflare/frameworks/tanstack-start/', destination: '/platforms/javascript/guides/tanstackstart-react/cloudflare/', }, + { + source: '/platforms/javascript/guides/remix/frameworks/', + destination: '/platforms/javascript/guides/remix/cloudflare/', + }, { source: '/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare/', destination: '/platforms/javascript/guides/nextjs/cloudflare/', From 8f2c283a719f47e9656f923863149bd2afe5f43a Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Sun, 25 Oct 2026 18:42:18 -0600 Subject: [PATCH 06/10] docs(js): Move the Hydrogen guides into the React Router and Remix guides The Hydrogen with React Router guide moves into the React Router guide as "Quick Start - Hydrogen", and the legacy Hydrogen with Remix guide moves into the Remix guide. They were the last pages under Cloudflare > Frameworks. The framework list on the Cloudflare quick start links to the new page, and the old URLs redirect. Co-Authored-By: Claude Opus 5.5 --- .../guides/cloudflare/frameworks/index.mdx | 2 +- .../javascript/guides/cloudflare/index.mdx | 2 +- .../hydrogen.mdx} | 7 +++++-- .../javascript/guides/remix/cloudflare.mdx | 2 +- .../hydrogen-remix.mdx => remix/hydrogen.mdx} | 4 +++- .../how-to-use/javascript.remix.mdx | 2 +- redirects.js | 14 ++++++++++---- 7 files changed, 22 insertions(+), 11 deletions(-) rename docs/platforms/javascript/guides/{cloudflare/frameworks/hydrogen-react-router.mdx => react-router/hydrogen.mdx} (97%) rename docs/platforms/javascript/guides/{cloudflare/frameworks/hydrogen-remix.mdx => remix/hydrogen.mdx} (97%) diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx index ce28841fd1f4b..0b358a6ffbaea 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx @@ -15,4 +15,4 @@ For these frameworks, follow the Cloudflare quick start in the framework guide: - [SvelteKit on Cloudflare](/platforms/javascript/guides/sveltekit/cloudflare/) - [TanStack Start React on Cloudflare](/platforms/javascript/guides/tanstackstart-react/cloudflare/) - +For Shopify Hydrogen on Oxygen, follow the [Hydrogen quick start](/platforms/javascript/guides/react-router/hydrogen/) in the React Router guide. diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index 67577f8cbf01c..340acb94f03bf 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -16,7 +16,7 @@ If you're using any of the listed frameworks, follow their specific setup instru - **[Astro](/platforms/javascript/guides/astro/cloudflare/)** - **[Hono](/platforms/javascript/guides/hono/cloudflare/)** (with @sentry/hono) -- **[Hydrogen](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)** +- **[Hydrogen](/platforms/javascript/guides/react-router/hydrogen/)** - **[Next.js](/platforms/javascript/guides/nextjs/cloudflare/)** - **[Nuxt](/platforms/javascript/guides/nuxt/cloudflare/)** - **[Remix](/platforms/javascript/guides/remix/cloudflare/)** diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router.mdx b/docs/platforms/javascript/guides/react-router/hydrogen.mdx similarity index 97% rename from docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router.mdx rename to docs/platforms/javascript/guides/react-router/hydrogen.mdx index fad55e7a83325..cc9f3873240ad 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router.mdx +++ b/docs/platforms/javascript/guides/react-router/hydrogen.mdx @@ -1,11 +1,14 @@ --- title: Hydrogen with React Router +h1_title: Hydrogen with React Router +sidebar_title: Quick Start - Hydrogen +sidebar_order: 0.5 description: Learn how to instrument your Hydrogen app on Shopify Oxygen and capture your first errors and traces. --- -This guide applies to Hydrogen versions **2025.5.0 and later** that use React Router 7 (framework mode). For older versions of Hydrogen that use Remix v2, see our [Remix on Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix/). +This guide applies to Hydrogen versions **2025.5.0 and later** that use React Router 7 (framework mode). For older versions of Hydrogen that use Remix v2, see the [Hydrogen with Remix guide](/platforms/javascript/guides/remix/hydrogen/). @@ -363,7 +366,7 @@ Now, head over to your project on [Sentry.io](https://sentry.io) to view the col ## Next Steps -At this point, you should have integrated Sentry into your React Router Framework application and should already be sending data to your Sentry project. +At this point, you should have integrated Sentry into your Hydrogen application and should already be sending data to your Sentry project. Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: diff --git a/docs/platforms/javascript/guides/remix/cloudflare.mdx b/docs/platforms/javascript/guides/remix/cloudflare.mdx index 9f7bbd5274a04..c99b9538e92ba 100644 --- a/docs/platforms/javascript/guides/remix/cloudflare.mdx +++ b/docs/platforms/javascript/guides/remix/cloudflare.mdx @@ -7,7 +7,7 @@ description: "Learn how to instrument your Remix app on Cloudflare Workers and P -Using Shopify Hydrogen? Follow the [Hydrogen with React Router](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/) guide for Hydrogen 2025.5.0 and later, or the [Hydrogen with Remix](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix/) guide for older versions. +Using Shopify Hydrogen? Follow the [Hydrogen with React Router](/platforms/javascript/guides/react-router/hydrogen/) guide for Hydrogen 2025.5.0 and later, or the [Hydrogen with Remix](/platforms/javascript/guides/remix/hydrogen/) guide for older versions. diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix.mdx b/docs/platforms/javascript/guides/remix/hydrogen.mdx similarity index 97% rename from docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix.mdx rename to docs/platforms/javascript/guides/remix/hydrogen.mdx index 8821348ed2fc0..a39495a7fd23d 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix.mdx +++ b/docs/platforms/javascript/guides/remix/hydrogen.mdx @@ -1,11 +1,13 @@ --- title: Hydrogen with Remix (Legacy) +sidebar_title: Hydrogen (Legacy) +sidebar_order: 1.5 description: Learn how to use the Sentry Remix SDK to instrument your Hydrogen app (versions before 2025.5.0). --- -This guide applies to Hydrogen versions **before 2025.5.0** that use Remix v2. For newer versions of Hydrogen (2025.5.0+) that use React Router 7, see the [React Router guide](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/). +This guide applies to Hydrogen versions **before 2025.5.0** that use Remix v2. For newer versions of Hydrogen (2025.5.0+) that use React Router 7, see the [Hydrogen with React Router guide](/platforms/javascript/guides/react-router/hydrogen/). diff --git a/platform-includes/distributed-tracing/how-to-use/javascript.remix.mdx b/platform-includes/distributed-tracing/how-to-use/javascript.remix.mdx index 41f2df3b033b6..ca6db1c7d0af6 100644 --- a/platform-includes/distributed-tracing/how-to-use/javascript.remix.mdx +++ b/platform-includes/distributed-tracing/how-to-use/javascript.remix.mdx @@ -25,7 +25,7 @@ if (serverTimingValue) { return response; ``` -See the [Hydrogen on Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix/#trace-propagation) for a complete example. +See the [Hydrogen with Remix guide](/platforms/javascript/guides/remix/hydrogen/#trace-propagation) for a complete example.
diff --git a/redirects.js b/redirects.js index 49ea533e86e64..d3f9b22351682 100644 --- a/redirects.js +++ b/redirects.js @@ -1067,6 +1067,14 @@ const userDocsRedirects = [ source: '/platforms/javascript/guides/remix/frameworks/', destination: '/platforms/javascript/guides/remix/cloudflare/', }, + { + source: '/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/', + destination: '/platforms/javascript/guides/react-router/hydrogen/', + }, + { + source: '/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix/', + destination: '/platforms/javascript/guides/remix/hydrogen/', + }, { source: '/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare/', destination: '/platforms/javascript/guides/nextjs/cloudflare/', @@ -2141,13 +2149,11 @@ const userDocsRedirects = [ }, { source: '/platforms/javascript/guides/remix/frameworks/hydrogen/', - destination: - '/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/', + destination: '/platforms/javascript/guides/react-router/hydrogen/', }, { source: '/platforms/javascript/guides/cloudflare/frameworks/hydrogen/', - destination: - '/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/', + destination: '/platforms/javascript/guides/react-router/hydrogen/', }, // Removed /product/onboarding/ section (content was orphaned and duplicated elsewhere) { From 4b274a962062a72f4bb1d9cf9aae6b8cff1f5c5c Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Mon, 26 Oct 2026 12:53:45 -0600 Subject: [PATCH 07/10] docs(js): Redirect Cloudflare > Frameworks to the Cloudflare quick start All framework pages moved into their framework guides, so the Cloudflare > Frameworks page only listed links. The Cloudflare quick start already links to every framework page, so the old URL now redirects there. Co-Authored-By: Claude Opus 5.5 --- .../guides/cloudflare/frameworks/index.mdx | 18 ------------------ .../javascript/guides/cloudflare/index.mdx | 2 +- .../guides/tanstackstart-react/cloudflare.mdx | 2 +- redirects.js | 5 +++++ 4 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx deleted file mode 100644 index 0b358a6ffbaea..0000000000000 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Frameworks on Cloudflare -description: "Learn how to set up the Cloudflare SDK with popular frameworks like Astro, SvelteKit, and Remix." ---- - -You can use the Sentry Cloudflare SDK in combination with Sentry meta-framework SDKs like SvelteKit or Remix to instrument your Cloudflare Pages applications that use these frameworks. - -For these frameworks, follow the Cloudflare quick start in the framework guide: - -- [Astro on Cloudflare](/platforms/javascript/guides/astro/cloudflare/) -- [Hono on Cloudflare](/platforms/javascript/guides/hono/cloudflare/) -- [Next.js on Cloudflare](/platforms/javascript/guides/nextjs/cloudflare/) -- [Nuxt on Cloudflare](/platforms/javascript/guides/nuxt/cloudflare/) -- [Remix on Cloudflare](/platforms/javascript/guides/remix/cloudflare/) -- [SvelteKit on Cloudflare](/platforms/javascript/guides/sveltekit/cloudflare/) -- [TanStack Start React on Cloudflare](/platforms/javascript/guides/tanstackstart-react/cloudflare/) - -For Shopify Hydrogen on Oxygen, follow the [Hydrogen quick start](/platforms/javascript/guides/react-router/hydrogen/) in the React Router guide. diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index 340acb94f03bf..51632e610ec6b 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -178,7 +178,7 @@ At this point, you should have integrated Sentry into your Cloudflare Worker. He -- Check out setup instructions for popular [frameworks on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/) +- Using a framework? Follow its setup instructions, linked at the top of this page - Find various support topics in troubleshooting - [Get support](https://www.sentry.help/en/) diff --git a/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx index 5db55b6a7d377..b50b2eb31f41f 100644 --- a/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx +++ b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx @@ -235,7 +235,7 @@ Now's a good time to customize your setup and look into more advanced topics. Ou -- Check out setup instructions for other popular [frameworks on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/) +- Check out setup instructions for other popular [frameworks on Cloudflare](/platforms/javascript/guides/cloudflare/#framework-selector) - Find various support topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) - [Get support](https://www.sentry.help/en/) diff --git a/redirects.js b/redirects.js index d3f9b22351682..a67dc6afc4dc9 100644 --- a/redirects.js +++ b/redirects.js @@ -1075,6 +1075,11 @@ const userDocsRedirects = [ source: '/platforms/javascript/guides/cloudflare/frameworks/hydrogen-remix/', destination: '/platforms/javascript/guides/remix/hydrogen/', }, + { + // The Cloudflare quick start links to every framework page. + source: '/platforms/javascript/guides/cloudflare/frameworks/', + destination: '/platforms/javascript/guides/cloudflare/', + }, { source: '/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare/', destination: '/platforms/javascript/guides/nextjs/cloudflare/', From 4bc7b510169c446a2cdb7097bb20b2ca3c858aa3 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Mon, 26 Oct 2026 14:38:33 -0600 Subject: [PATCH 08/10] docs(js): Use the new quick start template on the Cloudflare framework pages The Astro, Hono, Remix, SvelteKit and TanStack Start Cloudflare quick starts and the Hydrogen quick start now follow the template from the other JavaScript quick starts: no feature checkboxes, every feature on in the snippets, separate Send Logs and Send Application Metrics steps, and one test error in Verify. The Wrangler steps use the shared include again. The Hono Cloudflare page gets its own feature expandables, because it supports neither Profiling nor the browser features. The legacy Hydrogen with Remix guide only loses the "(Optional)" heading and gets the DSN placeholder. Co-Authored-By: Claude Opus 5.5 --- .../javascript/guides/astro/cloudflare.mdx | 11 -- .../javascript/guides/hono/cloudflare.mdx | 64 +++--- .../guides/react-router/hydrogen.mdx | 165 ++++++---------- .../javascript/guides/remix/cloudflare.mdx | 13 -- .../javascript/guides/remix/hydrogen.mdx | 6 +- .../guides/tanstackstart-react/cloudflare.mdx | 166 ++++++++-------- ...-features-expandable-cloudflare-server.mdx | 7 + ...cate-data-expandable-cloudflare-server.mdx | 7 + .../javascript.astro.mdx | 169 ++++++---------- .../javascript.remix.mdx | 167 ++++++---------- .../javascript.sveltekit.mdx | 184 ++++++------------ 11 files changed, 375 insertions(+), 584 deletions(-) create mode 100644 includes/quick-start-features-expandable-cloudflare-server.mdx create mode 100644 includes/quick-start-locate-data-expandable-cloudflare-server.mdx diff --git a/docs/platforms/javascript/guides/astro/cloudflare.mdx b/docs/platforms/javascript/guides/astro/cloudflare.mdx index 6791c8cb354aa..622984183413d 100644 --- a/docs/platforms/javascript/guides/astro/cloudflare.mdx +++ b/docs/platforms/javascript/guides/astro/cloudflare.mdx @@ -90,17 +90,6 @@ export const onRequest = [ ## Install - - - - diff --git a/docs/platforms/javascript/guides/hono/cloudflare.mdx b/docs/platforms/javascript/guides/hono/cloudflare.mdx index d38c443f61e01..e4caf02a6efa5 100644 --- a/docs/platforms/javascript/guides/hono/cloudflare.mdx +++ b/docs/platforms/javascript/guides/hono/cloudflare.mdx @@ -13,12 +13,6 @@ The `@sentry/hono` SDK works as Hono middleware, so you can drop it into your ex ## Install -Choose the features you want to configure, and this guide will show you how: - - - - - ### Install the Sentry SDK Install `@sentry/hono` together with `@sentry/cloudflare`. The runtime package is a peer dependency that you never import directly, but it must be present and its version must match `@sentry/hono`. @@ -37,6 +31,11 @@ pnpm add @sentry/hono @sentry/cloudflare ## Configure +**Error Monitoring** starts working as soon as you add the `sentry()` middleware. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**. + + + ### Configure Wrangler The SDK needs `AsyncLocalStorage`, so set the `nodejs_compat` compatibility flag and a `compatibility_date` of `2024-09-23` or later in your Wrangler configuration: @@ -57,7 +56,13 @@ compatibility_flags = ["nodejs_compat"] ### Add the Sentry Middleware -Add the `sentry()` middleware as early as possible in your Hono app, before any route that you want covered: +Add the `sentry()` middleware as early as possible in your Hono app, before any route that you want covered. + +The snippet also turns on: + +- Tracing: via `tracesSampleRate` + +Don't need a feature? Remove its integration and options from the snippet. ```typescript {filename:index.ts} import { Hono } from "hono"; @@ -69,12 +74,10 @@ app.use( sentry(app, { dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of spans for tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance }) ); @@ -83,6 +86,8 @@ app.use( export default app; ``` + + To read the DSN from a Worker binding, for example a secret, pass a callback instead of a plain options object. The callback receives the Worker `env`: ```typescript {filename:index.ts} @@ -98,44 +103,59 @@ app.use(sentry(app, (env) => ({ dsn: env.SENTRY_DSN }))); export default app; ``` + + ### Report Unhandled Exceptions By default, Sentry captures exceptions from Hono's `onError` handler, excluding errors with 3xx or 4xx status codes. No additional configuration is needed for this. To control which errors are captured, use the `shouldHandleError` option. -### Add Readable Stack Traces With Source Maps (Optional) +### Add Readable Stack Traces With Source Maps -### Control the Data You Send to Sentry (Optional) +### Control the Data You Send to Sentry +## Send Logs + + + +If you already use `console`, capture those calls as Sentry Logs with `consoleLoggingIntegration`. + +## Send Application Metrics + + + ## Verify Your Setup - +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +Add a test route to your Hono app that throws an error, then request `/debug-sentry` to trigger it: + +```typescript +app.get("/debug-sentry", () => { + throw new Error("Sentry Test Error"); +}); +``` ### View Captured Data in Sentry Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). - + ## Next Steps -At this point, you should have Sentry integrated into your Hono application on Cloudflare Workers and already be sending data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics: +At this point, you should have integrated Sentry into your Hono application on Cloudflare Workers. Here's what to explore next: - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to manually capture errors - Explore Hono-specific features like custom error filtering -- Continue to customize your configuration -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts diff --git a/docs/platforms/javascript/guides/react-router/hydrogen.mdx b/docs/platforms/javascript/guides/react-router/hydrogen.mdx index cc9f3873240ad..a8d8cb0f24eaa 100644 --- a/docs/platforms/javascript/guides/react-router/hydrogen.mdx +++ b/docs/platforms/javascript/guides/react-router/hydrogen.mdx @@ -23,19 +23,6 @@ You need: ## Install -Choose the features you want to configure, and this guide will show you how: - - - - - ### Install the Sentry SDK Run the command for your preferred package manager to add the React Router and Cloudflare SDK: @@ -54,10 +41,23 @@ pnpm add @sentry/react-router @sentry/cloudflare ## Configure -### Configure Client-side Sentry +**Error Monitoring** starts working as soon as you call `Sentry.init()`. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + +### Configure Client-Side Sentry Initialize Sentry in your `entry.client.tsx` file. +The snippet also turns on: + +- Tracing: via `tracesSampleRate` and `reactRouterTracingIntegration()` +- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` +- User Feedback: via `feedbackIntegration()` + +Don't need a feature? Remove its integration and options from the snippet. + The `sentryOnError` handler integrates with React Router's [`onError` hook](https://reactrouter.com/how-to/error-reporting) to automatically capture and report client-side errors to Sentry. ```tsx {filename: app/entry.client.tsx} @@ -70,42 +70,27 @@ Sentry.init({ dsn: "___PUBLIC_DSN___", integrations: [ - // ___PRODUCT_OPTION_START___ performance - // Registers and configures the Tracing integration, - // which automatically instruments your application to monitor its - // performance, including custom React Router routing instrumentation + // enables automatic instrumentation, including React Router navigations Sentry.reactRouterTracingIntegration(), - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ session-replay - // Registers the Replay integration, - // which automatically captures Session Replays + // enables Session Replay Sentry.replayIntegration(), - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ user-feedback + // enables User Feedback Sentry.feedbackIntegration({ - // Additional SDK configuration goes in here, for example: + // Additional integration configuration goes in here colorScheme: "system", }), - // ___PRODUCT_OPTION_END___ user-feedback ], - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/guides/react-router/configuration/options/#traces-sample-rate + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ session-replay - // Capture Replay for 10% of all sessions, - // plus 100% of sessions with an error - // Learn more at - // https://docs.sentry.io/platforms/javascript/guides/react-router/session-replay/configuration/#general-integration-configuration + // Capture replays for 10% of all sessions, + // plus for 100% of sessions with an error + // Requires Sentry.replayIntegration() replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ session-replay }); startTransition(() => { @@ -118,9 +103,15 @@ startTransition(() => { }); ``` -### Configure Server-side Sentry +### Configure Server-Side Sentry + +First, create an `instrument.server.mjs` file to initialize Sentry on the server. -First, create an `instrument.server.mjs` file to initialize Sentry on the server: +The snippets in this step also turn on: + +- Tracing: via `tracesSampleRate` + +Don't need a feature? Remove its options from the snippets. ```js {filename:instrument.server.mjs} import * as Sentry from "@sentry/react-router"; @@ -128,15 +119,10 @@ import * as Sentry from "@sentry/react-router"; Sentry.init({ dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/guides/react-router/configuration/options/#tracesSampleRate + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance }); ``` @@ -144,7 +130,7 @@ Next, update your `server.ts` file to use the `wrapRequestHandler` method from t -On Shopify Oxygen, never import anything directly from `@sentry/cloudflare`. Only use the `@sentry/cloudflare/request` subpath import shown below. All other imports (for example, `import * as Sentry from "@sentry/cloudflare"`) will break your app on Oxygen — use `@sentry/react-router/cloudflare` for everything else. +On Shopify Oxygen, never import anything directly from `@sentry/cloudflare`. Only use the `@sentry/cloudflare/request` subpath import shown below. All other imports (for example, `import * as Sentry from "@sentry/cloudflare"`) will break your app on Oxygen. Use `@sentry/react-router/cloudflare` for everything else. @@ -171,9 +157,11 @@ export default { { options: { dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance }, request: request as any, context: executionContext, @@ -196,8 +184,6 @@ export default { }; ``` - - ### Enable Distributed Tracing Update your `entry.server.tsx` file to inject trace meta tags: @@ -243,9 +229,7 @@ export const handleError: HandleErrorFunction = (error, { request }) => { export default Sentry.wrapSentryHandleRequest(handleRequest); ``` - - -### Add Readable Stack Traces With Source Maps (Optional) +### Add Readable Stack Traces With Source Maps The stack traces in your Sentry errors probably won't look like your actual code without unminifying them. To fix this, upload your source maps to Sentry. @@ -288,7 +272,7 @@ sentry-cli sourcemaps inject /path/to/build/dir sentry-cli sourcemaps upload /path/to/build/dir ``` -### Control the Data You Send to Sentry (Optional) +### Control the Data You Send to Sentry -## Verify Your Setup - -Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. - -### Issues +## Send Logs - - -To verify that Sentry captures errors and creates issues in your Sentry project, throw an error in a loader. + -Next, open the `/sentry-test` route in your browser, and you should trigger an error. +If you're already logging with `console` or Consola, you can capture those logs with our console integrations. -```tsx {filename: app/routes/sentry-test.tsx} -import type { Route } from "./+types/sentry-test"; +## Send Application Metrics -export async function loader() { - throw new Error("My first Sentry error!"); -} + -export default function SentryTestPage() { - return
Loading this page will throw an error
; -} -``` - - -### Tracing +## Verify Your Setup -To test your tracing configuration, update the previous code snippet by starting a trace to measure the time it takes for the execution of your code. +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. -Open the `/sentry-test` route in your browser. You should start a trace and trigger an error. +Add a route with a loader that throws an error, then open `/sentry-test` in your browser to trigger it: ```tsx {filename: app/routes/sentry-test.tsx} -import * as Sentry from "@sentry/react-router/cloudflare"; -import type { Route } from "./+types/sentry-test"; - export async function loader() { - return Sentry.startSpan( - { - op: "test", - name: "My First Test Trace", - }, - () => { - throw new Error("My first Sentry error!"); - } - ); + throw new Error("Sentry Test Error"); } export default function SentryTestPage() { @@ -348,33 +306,20 @@ export default function SentryTestPage() { } ``` - - - - - - - - - + ### View Captured Data in Sentry -Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). ## Next Steps -At this point, you should have integrated Sentry into your Hydrogen application and should already be sending data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics. -Our next recommended steps for you are: +At this point, you should have integrated Sentry into your Hydrogen application. Here's what to explore next: - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to manually capture errors -- Continue to customize your configuration -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Set up tunneling to avoid ad blockers blocking Sentry events diff --git a/docs/platforms/javascript/guides/remix/cloudflare.mdx b/docs/platforms/javascript/guides/remix/cloudflare.mdx index c99b9538e92ba..230767d5a9bb5 100644 --- a/docs/platforms/javascript/guides/remix/cloudflare.mdx +++ b/docs/platforms/javascript/guides/remix/cloudflare.mdx @@ -17,19 +17,6 @@ Using Shopify Hydrogen? Follow the [Hydrogen with React Router](/platforms/javas ## Install -Choose the features you want to configure, and this guide will show you how: - - - - - ### Install the Sentry SDK Run the command for your preferred package manager to add the Sentry Remix and Cloudflare SDKs to your application. diff --git a/docs/platforms/javascript/guides/remix/hydrogen.mdx b/docs/platforms/javascript/guides/remix/hydrogen.mdx index a39495a7fd23d..829cf6ab13a54 100644 --- a/docs/platforms/javascript/guides/remix/hydrogen.mdx +++ b/docs/platforms/javascript/guides/remix/hydrogen.mdx @@ -35,7 +35,7 @@ Update your `server.ts` file to use the `wrapRequestHandler` method from `@sentr -On Shopify Oxygen, never import anything directly from `@sentry/cloudflare`. Only use the `@sentry/cloudflare/request` subpath import shown below. All other imports (for example, `import * as Sentry from "@sentry/cloudflare"`) will break your app on Oxygen — use `@sentry/remix/cloudflare` for everything else. +On Shopify Oxygen, never import anything directly from `@sentry/cloudflare`. Only use the `@sentry/cloudflare/request` subpath import shown below. All other imports (for example, `import * as Sentry from "@sentry/cloudflare"`) will break your app on Oxygen. Use `@sentry/remix/cloudflare` for everything else. @@ -64,7 +64,7 @@ export default { return wrapRequestHandler( { options: { - dsn: "YOUR_DSN_HERE", + dsn: "___PUBLIC_DSN___", tracesSampleRate: 1.0, }, // Need to cast to any because this is not on cloudflare @@ -148,7 +148,7 @@ Sentry.init({ }); ``` -## Control the Data You Send to Sentry (Optional) +## Control the Data You Send to Sentry - This guide is for TanStack Start deployed to **Cloudflare Workers** using the `@cloudflare/vite-plugin`. For Node.js-based deployments, see our [TanStack Start guide](/platforms/javascript/guides/tanstackstart-react/). - +## Prerequisites -## Install +You need: -Choose the features you want to configure, and this guide will show you how: +- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) +- A TanStack Start application that runs on Cloudflare Workers with the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/) - + - +## Install ### Install the Sentry SDK @@ -48,9 +40,14 @@ pnpm add @sentry/tanstackstart-react @sentry/cloudflare ## Configure +**Error Monitoring** starts working as soon as you configure Sentry. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + When deploying TanStack Start to Cloudflare Workers, you need to wrap the server entry point with `Sentry.withSentry` from `@sentry/cloudflare`. TanStack Start allows you to create a custom server entry file for this purpose. -### Wrangler Configuration +### Configure Wrangler `tracesSampleRate`
+ +Don't need a feature? Remove its integration and options from the snippet. + Due to type differences between TanStack Start and Cloudflare Workers, you'll need to add a `// @ts-expect-error` comment as shown in the example. This is expected and doesn't affect functionality. @@ -78,75 +81,75 @@ export default Sentry.withSentry( () => ({ dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance }), // @ts-expect-error - handler is not typed as a Cloudflare handler wrapFetchWithSentry(handler) ); ``` -### Update Wrangler Configuration - -Update your `wrangler.jsonc` (or `wrangler.toml`) to use your custom server entry: +Then, point `main` in your Wrangler configuration to this file: ```json {diff} {filename:wrangler.jsonc} { "name": "my-tanstack-app", -+ "main": "src/server.ts", ++ "main": "src/server.ts", // ... rest of config } ``` ### Configure Client-Side Sentry -Initialize Sentry in your `src/router.tsx` file for client-side error tracking: +Initialize Sentry in your `src/router.tsx` file for client-side error tracking. + +The snippet also turns on: + +- Tracing: via `tanstackRouterBrowserTracingIntegration()` and `tracesSampleRate` +- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` +- User Feedback: via `feedbackIntegration()` + +Don't need a feature? Remove its integration and options from the snippet. ```tsx {diff} {filename:src/router.tsx} +import * as Sentry from "@sentry/tanstackstart-react"; import { createRouter } from '@tanstack/react-router' -export const getRouter = () => { - const router = createRouter(); - -+ if (!router.isServer) { -+ Sentry.init({ -+ dsn: "___PUBLIC_DSN___", -+ -+ integrations: [ -+ // ___PRODUCT_OPTION_START___ performance -+ Sentry.tanstackRouterBrowserTracingIntegration(router), -+ // ___PRODUCT_OPTION_END___ performance -+ // ___PRODUCT_OPTION_START___ session-replay -+ Sentry.replayIntegration(), -+ // ___PRODUCT_OPTION_END___ session-replay -+ // ___PRODUCT_OPTION_START___ user-feedback -+ Sentry.feedbackIntegration({ -+ // Additional SDK configuration goes in here, for example: -+ colorScheme: "system", -+ }), -+ // ___PRODUCT_OPTION_END___ user-feedback -+ ], -+ // ___PRODUCT_OPTION_START___ performance + export const getRouter = () => { + const router = createRouter(); + ++ if (!router.isServer) { ++ Sentry.init({ ++ dsn: "___PUBLIC_DSN___", ++ integrations: [ ++ // enables automatic instrumentation of TanStack Router navigations ++ Sentry.tanstackRouterBrowserTracingIntegration(router), ++ // enables Session Replay ++ Sentry.replayIntegration(), ++ // enables User Feedback ++ Sentry.feedbackIntegration({ ++ // Additional integration configuration goes in here ++ colorScheme: "system", ++ }), ++ ], + -+ // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. -+ tracesSampleRate: 1.0, -+ // ___PRODUCT_OPTION_END___ performance -+ // ___PRODUCT_OPTION_START___ session-replay ++ // Enables Tracing. ++ // Set to 1.0 to capture 100% of spans for tracing. ++ // We recommend reducing this value in production. ++ tracesSampleRate: 1.0, + -+ // Capture Replay for 10% of all sessions, -+ // plus for 100% of sessions with an error. -+ replaysSessionSampleRate: 0.1, -+ replaysOnErrorSampleRate: 1.0, -+ // ___PRODUCT_OPTION_END___ session-replay -+ }); -+ } - - return router; -} ++ // Capture replays for 10% of all sessions, ++ // plus for 100% of sessions with an error ++ // Requires Sentry.replayIntegration() ++ replaysSessionSampleRate: 0.1, ++ replaysOnErrorSampleRate: 1.0, ++ }); ++ } + + return router; + } ``` ### Capture Server-Side Errors @@ -175,14 +178,14 @@ export const startInstance = createStart(() => { }); ``` -### Add Readable Stack Traces With Source Maps (Optional) +### Add Readable Stack Traces With Source Maps -### Control the Data You Send to Sentry (Optional) +### Control the Data You Send to Sentry { noGuides /> +## Send Logs + + + +If you're already logging with `console` or Consola, you can capture those logs with our console integrations. + +## Send Application Metrics + + + ## Verify Your Setup -To verify Sentry is capturing errors, add a test button to one of your pages: +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + +Add a test button to one of your pages. Clicking it will trigger an error for Sentry to capture. ```tsx ``` -Run your app with `wrangler dev` (or through your Vite build with Cloudflare plugin), click the button, and check your Sentry project for the error. - - +Run your app with `wrangler dev` (or through your Vite build with the Cloudflare plugin), and click the button. - - - - - + ### View Captured Data in Sentry Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). - + ## Next Steps -At this point, you should have integrated Sentry and should already be sending data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: +At this point, you should have integrated Sentry into your TanStack Start application on Cloudflare. Here's what to explore next: - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to [manually capture errors](/platforms/javascript/guides/cloudflare/usage/) -- Continue to [customize your configuration](/platforms/javascript/guides/cloudflare/configuration/) +- Set up tunneling to avoid ad blockers blocking Sentry events - Make use of [Cloudflare-specific features](/platforms/javascript/guides/cloudflare/features/) -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts -- Check out setup instructions for other popular [frameworks on Cloudflare](/platforms/javascript/guides/cloudflare/#framework-selector) -- Find various support topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) +- Find various topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) - [Get support](https://www.sentry.help/en/) diff --git a/includes/quick-start-features-expandable-cloudflare-server.mdx b/includes/quick-start-features-expandable-cloudflare-server.mdx new file mode 100644 index 0000000000000..c70a694ccfaf5 --- /dev/null +++ b/includes/quick-start-features-expandable-cloudflare-server.mdx @@ -0,0 +1,7 @@ +import { FeatureInfo } from "sentry-docs/components/featureInfo"; + + + + + + diff --git a/includes/quick-start-locate-data-expandable-cloudflare-server.mdx b/includes/quick-start-locate-data-expandable-cloudflare-server.mdx new file mode 100644 index 0000000000000..0e4a5929aa4ac --- /dev/null +++ b/includes/quick-start-locate-data-expandable-cloudflare-server.mdx @@ -0,0 +1,7 @@ +import { FeatureInfo } from "sentry-docs/components/featureInfo"; + + + + + + diff --git a/platform-includes/getting-started-cloudflare/javascript.astro.mdx b/platform-includes/getting-started-cloudflare/javascript.astro.mdx index d28113db03d3f..fa5da647cfb5d 100644 --- a/platform-includes/getting-started-cloudflare/javascript.astro.mdx +++ b/platform-includes/getting-started-cloudflare/javascript.astro.mdx @@ -1,4 +1,4 @@ -### Install the Sentry SDKs +### Install the Sentry SDK Install both `@sentry/astro` and `@sentry/cloudflare`: @@ -16,14 +16,19 @@ pnpm add @sentry/astro @sentry/cloudflare ## Configure -### Wrangler Configuration +**Error Monitoring** starts working as soon as you configure Sentry. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + +### Configure Wrangler -### Configure Custom Entry Point +### Configure Server-Side Sentry 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: @@ -34,7 +39,13 @@ Astro 6 with `@astrojs/cloudflare` v13+ supports custom entry points directly fr } ``` -Create a `sentry.server.config.ts` file in the root of your project that wraps the Astro Cloudflare handler with Sentry: +Create a `sentry.server.config.ts` file in the root of your project that wraps the Astro Cloudflare handler with Sentry. + +The snippet also turns on: + +- Tracing: via `tracesSampleRate` + +Don't need a feature? Remove its integration and options from the snippet. ```typescript {filename:sentry.server.config.ts} import * as Sentry from "@sentry/cloudflare"; @@ -43,11 +54,11 @@ import handler from "@astrojs/cloudflare/entrypoints/server"; export default Sentry.withSentry( (env) => ({ dsn: env.SENTRY_DSN, - // ___PRODUCT_OPTION_START___ performance - // Define how likely traces are sampled. Adjust this value in production, - // or use tracesSampler for greater control. + + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance }), handler ); @@ -68,53 +79,45 @@ export default defineConfig({ }); ``` -### Configure Client-side Sentry +### Configure Client-Side Sentry + +Create a `sentry.client.config.(ts|js)` file in the root of your project. In this file, import and initialize Sentry for the client. + +The snippet also turns on: -Create a `sentry.client.config.(ts|js)` file in the root of your project. In this file, import and initialize Sentry for the client: +- Tracing: via `tracesSampleRate` +- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` +- User Feedback: via `feedbackIntegration()` + +Don't need a feature? Remove its integration and options from the snippet. ```javascript {filename:sentry.client.config.(ts|js)} import * as Sentry from "@sentry/astro"; Sentry.init({ dsn: "___PUBLIC_DSN___", - integrations: [ - // ___PRODUCT_OPTION_START___ performance + // enables automatic instrumentation Sentry.browserTracingIntegration(), - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ session-replay + // enables Session Replay Sentry.replayIntegration(), - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ user-feedback - Sentry.feedbackIntegration({ - // Additional SDK configuration goes in here, for example: - colorScheme: "system", - }), - // ___PRODUCT_OPTION_END___ user-feedback + // enables User Feedback + Sentry.feedbackIntegration({ colorScheme: "system" }), ], - // ___PRODUCT_OPTION_START___ performance - // Define how likely traces are sampled. Adjust this value in production, - // or use tracesSampler for greater control. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ session-replay - // This sets the sample rate to be 10%. You may want this to be 100% while - // in development and sample at a lower rate in production + // Capture replays for 10% of all sessions, + // plus for 100% of sessions with an error + // Requires Sentry.replayIntegration() replaysSessionSampleRate: 0.1, - - // If the entire session is not sampled, use the below sample rate to sample - // sessions when an error occurs. replaysOnErrorSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ session-replay }); ``` -### Configure Server-side Sentry - -Server-side Sentry is already configured in your custom entry point file (`sentry.server.config.ts`) created in the previous step. - ### Add Readable Stack Traces With Source Maps To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slugs in the `sentry` options inside `astro.config.mjs`: @@ -147,108 +150,50 @@ SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ -### Control the Data You Send to Sentry (Optional) +### Control the Data You Send to Sentry -## Verify Your Setup +## Send Logs -Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. - -### Issues + - -To verify that Sentry captures errors and creates issues in your Sentry project, -create a test page, for example, at `src/pages/test.astro` with two buttons. +If you're already logging with `console` or Consola, you can capture those logs with our console integrations. -```html {filename: test.astro} - - - - -``` - -Then also create the route we're calling in our test page, like `src/pages/api/test-error.(js|ts)`: - -Next, open your test page in a browser and click the buttons to trigger a frontend error and an error in the API route. - -```javascript {filename: test-error.(js|ts)} -export async function GET() { - throw new Error("Sentry Example API Route Error"); -} -``` +## Verify Your Setup - +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. -### Tracing +Add this button to a page in your Astro app and click it to send a test error: -To test tracing, create a custom span to measure the time it takes for the API request to complete: +```astro + -```html {filename: test.astro} - - ``` - - - - - - - - - + ### View Captured Data in Sentry -Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). ## Next Steps -At this point, you should have integrated Sentry into your Astro application and should already be sending data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics. -Our next recommended steps for you are: +At this point, you should have integrated Sentry into your Astro application on Cloudflare. Here's what to explore next: - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Continue to customize your configuration -- Learn how to manually capture errors -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Set up tunneling to avoid ad blockers blocking Sentry events diff --git a/platform-includes/getting-started-cloudflare/javascript.remix.mdx b/platform-includes/getting-started-cloudflare/javascript.remix.mdx index ee817b2c68666..37340e5dc69a8 100644 --- a/platform-includes/getting-started-cloudflare/javascript.remix.mdx +++ b/platform-includes/getting-started-cloudflare/javascript.remix.mdx @@ -1,67 +1,68 @@ ## Configure +**Error Monitoring** starts working as soon as you call `Sentry.init()`. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + ### Configure Client-Side Sentry -Create a client file `entry.client.tsx` in the `app` folder of your project if you don't have one already. In this file, import and initialize the Sentry SDK: +Create a client file `entry.client.tsx` in the `app` folder of your project if you don't have one already. In this file, import and initialize the Sentry SDK. + +The snippet also turns on: + +- Tracing: via `browserTracingIntegration()` and `tracesSampleRate`; `tracePropagationTargets` controls which API requests receive trace headers +- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` +- User Feedback: via `feedbackIntegration()` -```typescript {tabTitle:Client} {filename: entry.client.tsx} +Don't need a feature? Remove its integration and options from the snippet. + +```typescript {filename:app/entry.client.tsx} import { useLocation, useMatches } from "@remix-run/react"; import * as Sentry from "@sentry/remix"; import { useEffect } from "react"; Sentry.init({ dsn: "___PUBLIC_DSN___", - integrations: [ - // ___PRODUCT_OPTION_START___ performance + // enables automatic instrumentation Sentry.browserTracingIntegration({ useEffect, useLocation, useMatches, }), - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ session-replay - // Replay is only available in the client + // enables Session Replay Sentry.replayIntegration(), - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ user-feedback + // enables User Feedback Sentry.feedbackIntegration({ - // Additional SDK configuration goes in here, for example: + // Additional integration configuration goes in here colorScheme: "system", }), - // ___PRODUCT_OPTION_END___ user-feedback ], - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled + // Set trace propagation targets for your API requests tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ session-replay - // Capture Replay for 10% of all sessions, + // Capture replays for 10% of all sessions, // plus for 100% of sessions with an error - // Learn more at - // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration + // Requires Sentry.replayIntegration() replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ session-replay }); ``` -#### Remix ErrorBoundary +### Capture Errors From Your ErrorBoundary To capture errors from your [ErrorBoundary](https://remix.run/docs/en/main/route/error-boundary), define it in `root.tsx` to act as a fallback for all routes or create route-specific error boundaries in your route components. In your `ErrorBoundary` component, use `Sentry.captureRemixErrorBoundaryError` to send the captured error to Sentry: -```tsx {filename: root.tsx} +```tsx {filename:app/root.tsx} import { captureRemixErrorBoundaryError } from "@sentry/remix"; export const ErrorBoundary = () => { @@ -73,11 +74,11 @@ export const ErrorBoundary = () => { }; ``` -#### Performance Monitoring +### Wrap Your Root Component Wrap your Remix root component with `withSentry` to capture performance data: -```tsx {filename: root.tsx} +```tsx {filename:app/root.tsx} import { Links, LiveReload, @@ -121,6 +122,12 @@ Don't also wrap `createRequestHandler` with `makeWrappedCreateRequestHandler`. C +The snippet also turns on: + +- Tracing: via `tracesSampleRate` + +Don't need a feature? Remove its integration and options from the snippet. + ```typescript {filename:server.ts} import { createRequestHandler } from "@remix-run/cloudflare"; import * as Sentry from "@sentry/cloudflare"; @@ -133,15 +140,11 @@ const handleRequest = createRequestHandler(instrumentBuild(remixBuild)); export default Sentry.withSentry( (env) => ({ dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance }), { async fetch(request, env, ctx) { @@ -163,15 +166,10 @@ export const onRequest = [ Sentry.sentryPagesPlugin((context) => ({ dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance // Optionally limit which action formData fields are captured. // Without this option, all fields are captured. @@ -196,13 +194,13 @@ Import from `@sentry/remix/cloudflare`, not from `@sentry/remix`. In a Cloudflar -```typescript {filename: entry.server.tsx} +```typescript {filename:app/entry.server.tsx} import { sentryHandleError } from "@sentry/remix/cloudflare"; export const handleError = sentryHandleError; ``` -### Configure Cloudflare for Sentry +### Configure Wrangler -### Control the Data You Send to Sentry (Optional) +### Control the Data You Send to Sentry -## Verify Your Setup +## Send Logs -Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + -### Issues +If you're already logging with `console` or Consola, you can capture those logs with our console integrations. - +## Send Application Metrics -To verify that Sentry captures errors and creates issues in your Sentry project, add a test button to one of your pages. + - +## Verify Your Setup -Open the page in a browser and click the button to trigger a frontend error. +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. - +Add a test button to one of your pages. Open the page in a browser and click the button to trigger an error for Sentry to capture. -```javascript +```tsx -``` - - - -### Tracing - -To test your tracing configuration, update the previous code snippet by calling a non-existing route and starting a trace to measure the time it takes for the execution of your code. - -Open the page in a browser and click the button to trigger the frontend error and a trace. - -```javascript - ``` - - - - - - - - - + ### View Captured Data in Sentry -Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). ## Next Steps -At this point, you should have integrated Sentry into your Remix application and should already be sending error and performance data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are: +At this point, you should have integrated Sentry into your Remix application on Cloudflare. Here's what to explore next: - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to manually capture errors -- Continue to customize your configuration -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Set up tunneling to avoid ad blockers blocking Sentry events -- If you encountered issues with the manual setup, try our installation wizard -- Find various support topics in [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) and [Remix troubleshooting](/platforms/javascript/guides/remix/troubleshooting/) +- Find various topics in [Remix troubleshooting](/platforms/javascript/guides/remix/troubleshooting/) and [Cloudflare troubleshooting](/platforms/javascript/guides/cloudflare/troubleshooting/) - [Get support](https://www.sentry.help/en/) diff --git a/platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx b/platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx index e5f5b3efe3bdd..3754bb05c0dcf 100644 --- a/platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx +++ b/platform-includes/getting-started-cloudflare/javascript.sveltekit.mdx @@ -22,29 +22,14 @@ The Sentry wizard, as well as this guide, will use it as the default way of sett - + ## Install -Choose the features you want to configure, and this guide will show you how: - - - - - ### Install the Sentry SDK Run the command for your preferred package manager to add the Sentry SDK to your application: -If you're updating your Sentry SDK to the latest version, check out our migration guide to learn more about breaking changes. - ```bash {tabTitle:npm} npm install @sentry/sveltekit --save ``` @@ -59,47 +44,50 @@ pnpm add @sentry/sveltekit ## Configure +**Error Monitoring** starts working as soon as you call `Sentry.init()`. **Logs** and **Application Metrics** need no extra configuration, and you'll learn how to send them in steps [#3](#send-logs) and [#4](#send-application-metrics-). +This guide also enables **Tracing**, **Session Replay**, and **User Feedback**. + + + You need to initialize and configure the Sentry SDK in three places: the client side, the server side, and your Vite config. ### Configure Client-Side Sentry Create a client hooks file `src/hooks.client.(js|ts)` in your project if you don't have one already. In this file, import and initialize the Sentry SDK and add the `handleErrorWithSentry` function to the [`handleError` hook](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError). -```javascript {filename:src/hooks.client.(js|ts)} {1, 3-37, 43} +The snippet also turns on: + +- Tracing: via `tracesSampleRate` +- Session Replay: via `replayIntegration()`, sampled with `replaysSessionSampleRate` and `replaysOnErrorSampleRate` +- User Feedback: via `feedbackIntegration()` + +Don't need a feature? Remove its integration and options from the snippet. + +```javascript {filename:src/hooks.client.(js|ts)} import * as Sentry from "@sentry/sveltekit"; Sentry.init({ dsn: "___PUBLIC_DSN___", - - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance integrations: [ - // ___PRODUCT_OPTION_START___ session-replay + // enables Session Replay Sentry.replayIntegration(), - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ user-feedback + // enables User Feedback Sentry.feedbackIntegration({ - // Additional SDK configuration goes in here, for example: + // Additional integration configuration goes in here colorScheme: "system", }), - // ___PRODUCT_OPTION_END___ user-feedback ], - // ___PRODUCT_OPTION_START___ session-replay - // Capture Replay for 10% of all sessions, + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + tracesSampleRate: 1.0, + + // Capture replays for 10% of all sessions, // plus for 100% of sessions with an error - // Learn more at - // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration + // Requires Sentry.replayIntegration() replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ session-replay }); const myErrorHandler = ({ error, event }) => { @@ -116,20 +104,18 @@ export const handleError = Sentry.handleErrorWithSentry(myErrorHandler); _Requires SvelteKit `2.31.0` or higher and `@sentry/sveltekit` `10.8.0` or higher._ -Configure server-side instrumentation and tracing. Where this config lives depends on your SvelteKit version — SvelteKit 2 uses `svelte.config.js`, while SvelteKit 3 moved it into the `sveltekit()` Vite plugin options in `vite.config.(js|ts)` instead (see [Configure Vite](#configure-vite) below). SvelteKit 3 no longer needs an instrumentation flag, so the only option to set there is `tracing`. +Configure server-side instrumentation and tracing. Where this config lives depends on your SvelteKit version: SvelteKit 2 uses `svelte.config.js`, while SvelteKit 3 moved it into the `sveltekit()` Vite plugin options in `vite.config.(js|ts)` instead (see [Configure Vite](#configure-vite) below). SvelteKit 3 no longer needs an instrumentation flag, so the only option to set there is `tracing`. -```js {tabTitle:SvelteKit 2} {mdExpandTabs} {filename:svelte.config.js} {3-12} +```js {tabTitle:SvelteKit 2} {mdExpandTabs} {filename:svelte.config.js} {3-10} const config = { kit: { experimental: { instrumentation: { server: true, }, - // ___PRODUCT_OPTION_START___ performance tracing: { server: true, }, - // ___PRODUCT_OPTION_END___ performance }, }, }; @@ -144,11 +130,9 @@ import { defineConfig } from "vite"; export default defineConfig({ plugins: [ sveltekit({ - // ___PRODUCT_OPTION_START___ performance tracing: { server: true, }, - // ___PRODUCT_OPTION_END___ performance // ... rest of your SvelteKit config }), ], @@ -158,6 +142,12 @@ export default defineConfig({ Create a server hooks file `src/hooks.server.(js|ts)` in your project if you don't have one already. In this file, import and initialize the Sentry SDK and add the `handleErrorWithSentry` function to the [`handleError` hook](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) and Sentry's Cloudflare request handler to the [`handle` hook](https://kit.svelte.dev/docs/hooks#server-hooks-handle). +The snippet also turns on: + +- Tracing: via `tracesSampleRate` + +Don't need a feature? Remove its integration and options from the snippet. + ```javascript {filename:src/hooks.server.(js|ts)} import { handleErrorWithSentry, @@ -171,15 +161,10 @@ export const handle = sequence( initCloudflareSentryHandle({ dsn: "___PUBLIC_DSN___", - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - // Learn more at - // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance }), sentryHandle() ); @@ -195,7 +180,7 @@ export const handleError = Sentry.handleErrorWithSentry(myErrorHandler); ### Configure Vite -Add the `sentrySvelteKit` plugin **before** `sveltekit` in your `vite.config.(js|ts)` file to automatically upload source maps to Sentry and instrument `load` functions for tracing if it's configured. +Add the `sentrySvelteKit` plugin **before** `sveltekit` in your `vite.config.(js|ts)` file to automatically upload source maps to Sentry and instrument `load` functions for tracing. ```javascript {filename:vite.config.(js|ts)} {2,6} import { sveltekit } from "@sveltejs/kit/vite"; @@ -208,18 +193,18 @@ export default defineConfig({ }); ``` -### Configure Cloudflare for Sentry +### Configure Wrangler -### Add Readable Stack Traces With Source Maps (Optional) +### Add Readable Stack Traces With Source Maps To upload source maps for clear error stack traces, add your Sentry auth token, organization, and project slug in your `vite.config.(js|ts)` file: -```javascript {filename:vite.config.(js|ts)} {6-13} +```javascript {filename:vite.config.(js|ts)} {6-11} import { sveltekit } from "@sveltejs/kit/vite"; import { sentrySvelteKit } from "@sentry/sveltekit/vite"; @@ -247,105 +232,52 @@ SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ -### Control the Data You Send to Sentry (Optional) +### Control the Data You Send to Sentry -## Verify Your Setup +## Send Logs -Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. + -### Issues +If you're already logging with `console` or Consola, you can capture those logs with our console integrations. -To verify that Sentry captures errors and creates issues in your Sentry project, create a test page, for example, at `src/routes/sentry-example/+page.svelte` with a button that throws an error when clicked. +## Send Application Metrics - - Open the page `sentry-example` in a browser and click the button to trigger a - frontend error. - + - - -```html {filename:+page.svelte} - - - -``` - - -### Tracing - -To test tracing, create a test API route like `src/routes/sentry-example/+server.(js|ts)`. - -```javascript {filename:+server.(js|ts)} -export const GET = async () => { - throw new Error("Sentry Example API Route Error"); -}; -``` - -Next, update your test button to call this route and throw an error if the response isn't `ok`. - -Open the page `sentry-example` in a browser and click the button to trigger two errors: +## Verify Your Setup -- a frontend error -- an error within the API route +Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project. -Additionally, this starts a trace to measure the time it takes for the API request to complete. +Create a test page, for example at `src/routes/sentry-example/+page.svelte`, with a button that throws an error when you click it: -```html {filename:+page.svelte} +```html {filename:src/routes/sentry-example/+page.svelte} - + ``` - +Open the `/sentry-example` page in your browser and click the button. - - - - - - - + ### View Captured Data in Sentry -Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). +Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear). ## Next Steps -At this point, you should have integrated Sentry into your SvelteKit application and should already be sending data to your Sentry project. - -Now's a good time to customize your setup and look into more advanced topics. -Our next recommended steps for you are: +At this point, you should have integrated Sentry into your SvelteKit application on Cloudflare. Here's what to explore next: - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup -- Learn how to [manually capture errors](/platforms/javascript/guides/cloudflare/usage/) -- Continue to [customize your configuration](/platforms/javascript/guides/cloudflare/configuration/) -- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts +- Set up tunneling to avoid ad blockers blocking Sentry events - Learn how to [manually instrument](/platforms/javascript/guides/sveltekit/apis/#load-function-instrumentation) SvelteKit-specific features @@ -355,4 +287,4 @@ Our next recommended steps for you are: - + From b91b19e1b536e6f6c79a76ed3aab3c1226418f9a Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Fri, 30 Oct 2026 13:38:26 -0600 Subject: [PATCH 09/10] docs(js): Show the moved quick starts as "Quick Start (Cloudflare)" Use the same label as the Next.js and Nuxt Cloudflare quick starts. The Hydrogen quick start in the React Router guide becomes "Quick Start (Hydrogen)". Co-Authored-By: Claude Opus 5.5 --- docs/platforms/javascript/guides/astro/cloudflare.mdx | 2 +- docs/platforms/javascript/guides/hono/cloudflare.mdx | 2 +- docs/platforms/javascript/guides/react-router/hydrogen.mdx | 2 +- docs/platforms/javascript/guides/remix/cloudflare.mdx | 2 +- docs/platforms/javascript/guides/sveltekit/cloudflare.mdx | 2 +- .../javascript/guides/tanstackstart-react/cloudflare.mdx | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/platforms/javascript/guides/astro/cloudflare.mdx b/docs/platforms/javascript/guides/astro/cloudflare.mdx index 622984183413d..0f58183518523 100644 --- a/docs/platforms/javascript/guides/astro/cloudflare.mdx +++ b/docs/platforms/javascript/guides/astro/cloudflare.mdx @@ -1,6 +1,6 @@ --- title: Astro on Cloudflare -sidebar_title: Quick Start - Cloudflare +sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your Astro app on Cloudflare Workers and capture your first errors." --- diff --git a/docs/platforms/javascript/guides/hono/cloudflare.mdx b/docs/platforms/javascript/guides/hono/cloudflare.mdx index e4caf02a6efa5..29aaf718583a4 100644 --- a/docs/platforms/javascript/guides/hono/cloudflare.mdx +++ b/docs/platforms/javascript/guides/hono/cloudflare.mdx @@ -1,6 +1,6 @@ --- title: Hono on Cloudflare -sidebar_title: Quick Start - Cloudflare +sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to set up Sentry in your Hono app on Cloudflare Workers and capture your first errors." --- diff --git a/docs/platforms/javascript/guides/react-router/hydrogen.mdx b/docs/platforms/javascript/guides/react-router/hydrogen.mdx index a8d8cb0f24eaa..152bdb9b09459 100644 --- a/docs/platforms/javascript/guides/react-router/hydrogen.mdx +++ b/docs/platforms/javascript/guides/react-router/hydrogen.mdx @@ -1,7 +1,7 @@ --- title: Hydrogen with React Router h1_title: Hydrogen with React Router -sidebar_title: Quick Start - Hydrogen +sidebar_title: Quick Start (Hydrogen) sidebar_order: 0.5 description: Learn how to instrument your Hydrogen app on Shopify Oxygen and capture your first errors and traces. --- diff --git a/docs/platforms/javascript/guides/remix/cloudflare.mdx b/docs/platforms/javascript/guides/remix/cloudflare.mdx index 230767d5a9bb5..5ed65b8541964 100644 --- a/docs/platforms/javascript/guides/remix/cloudflare.mdx +++ b/docs/platforms/javascript/guides/remix/cloudflare.mdx @@ -1,6 +1,6 @@ --- title: Remix on Cloudflare -sidebar_title: Quick Start - Cloudflare +sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your Remix app on Cloudflare Workers and Pages and capture your first errors with Sentry." --- diff --git a/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx b/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx index d946bc4fd65c8..d83893451749e 100644 --- a/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx +++ b/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx @@ -1,6 +1,6 @@ --- title: SvelteKit on Cloudflare -sidebar_title: Quick Start - Cloudflare +sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your SvelteKit app on Cloudflare Workers and Pages and capture your first errors with Sentry." --- diff --git a/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx index 3158b299b723e..7b5dc302358b1 100644 --- a/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx +++ b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx @@ -1,6 +1,6 @@ --- title: TanStack Start React on Cloudflare -sidebar_title: Quick Start - Cloudflare +sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your TanStack Start app on Cloudflare Workers and capture your first errors with Sentry." --- From af8ed48bda4f97f91a069f2b4b9d12c94a348a30 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Sat, 31 Oct 2026 15:15:10 -0600 Subject: [PATCH 10/10] feat(js): Link the Node.js and Cloudflare quick starts of a framework Each framework guide now has a Node.js and a Cloudflare quick start, so quick starts set `runtime` in their frontmatter. at the top of a quick start links the guide page and its child pages that set `runtime`. The links are plain anchors, so they are also in the Markdown export. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 1 + .../javascript/guides/astro/cloudflare.mdx | 3 + .../javascript/guides/astro/index.mdx | 3 + .../javascript/guides/hono/cloudflare.mdx | 1 + .../javascript/guides/nextjs/cloudflare.mdx | 3 + .../javascript/guides/nextjs/index.mdx | 3 + .../javascript/guides/nuxt/cloudflare.mdx | 3 + .../javascript/guides/nuxt/index.mdx | 3 + .../javascript/guides/remix/cloudflare.mdx | 3 + .../javascript/guides/remix/index.mdx | 3 + .../guides/sveltekit/cloudflare.mdx | 3 + .../javascript/guides/sveltekit/index.mdx | 3 + .../guides/tanstackstart-react/cloudflare.mdx | 5 +- .../guides/tanstackstart-react/index.mdx | 3 + src/components/runtimeLinks.spec.ts | 50 ++++++++++++++++ src/components/runtimeLinks.ts | 49 ++++++++++++++++ src/components/runtimeSelector.tsx | 58 +++++++++++++++++++ src/mdxComponents.ts | 2 + src/types/frontmatter.ts | 6 ++ 19 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/components/runtimeLinks.spec.ts create mode 100644 src/components/runtimeLinks.ts create mode 100644 src/components/runtimeSelector.tsx diff --git a/AGENTS.md b/AGENTS.md index 0c692c1be4f92..59c476228384a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -98,6 +98,7 @@ When writing requirements in `develop-docs/`: - **ALWAYS** run `/brand-guidelines` to audit any user-facing content before committing. See `.agents/skills/brand-guidelines/SKILL.md` - Use `docs-review` skill for Sentry style and voice review. See `.claude/skills/docs-review/SKILL.md` - Use `technical-docs` skill when writing or reviewing SDK documentation. See `.claude/skills/technical-docs/SKILL.md` +- Quick starts set `runtime` (for example `node` or `cloudflare`) in their frontmatter. Add `` to a quick start to link the quick starts of the same guide for the other runtimes ## LLM-Friendly MD Exports diff --git a/docs/platforms/javascript/guides/astro/cloudflare.mdx b/docs/platforms/javascript/guides/astro/cloudflare.mdx index 0f58183518523..5e048ec211e0a 100644 --- a/docs/platforms/javascript/guides/astro/cloudflare.mdx +++ b/docs/platforms/javascript/guides/astro/cloudflare.mdx @@ -3,8 +3,11 @@ title: Astro on Cloudflare sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your Astro app on Cloudflare Workers and capture your first errors." +runtime: cloudflare --- + + ## Prerequisites You need: diff --git a/docs/platforms/javascript/guides/astro/index.mdx b/docs/platforms/javascript/guides/astro/index.mdx index a967e92fbf388..d66ae5d89c858 100644 --- a/docs/platforms/javascript/guides/astro/index.mdx +++ b/docs/platforms/javascript/guides/astro/index.mdx @@ -5,8 +5,11 @@ sdk: sentry.javascript.astro categories: - browser - server +runtime: node --- + + ## Prerequisites You need: diff --git a/docs/platforms/javascript/guides/hono/cloudflare.mdx b/docs/platforms/javascript/guides/hono/cloudflare.mdx index 29aaf718583a4..4837d98606290 100644 --- a/docs/platforms/javascript/guides/hono/cloudflare.mdx +++ b/docs/platforms/javascript/guides/hono/cloudflare.mdx @@ -3,6 +3,7 @@ title: Hono on Cloudflare sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to set up Sentry in your Hono app on Cloudflare Workers and capture your first errors." +runtime: cloudflare --- The `@sentry/hono` SDK works as Hono middleware, so you can drop it into your existing Cloudflare Workers app. For Node.js, Bun, and Deno, see the [Hono quick start](/platforms/javascript/guides/hono/). diff --git a/docs/platforms/javascript/guides/nextjs/cloudflare.mdx b/docs/platforms/javascript/guides/nextjs/cloudflare.mdx index 05b04e8fd71b2..1b267492b90e0 100644 --- a/docs/platforms/javascript/guides/nextjs/cloudflare.mdx +++ b/docs/platforms/javascript/guides/nextjs/cloudflare.mdx @@ -3,6 +3,9 @@ title: Next.js on Cloudflare sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to set up Sentry in your Next.js application deployed on Cloudflare Workers and capture your first errors." +runtime: cloudflare --- + + diff --git a/docs/platforms/javascript/guides/nextjs/index.mdx b/docs/platforms/javascript/guides/nextjs/index.mdx index 8b19eae36dd5d..e39aa72da0fa8 100644 --- a/docs/platforms/javascript/guides/nextjs/index.mdx +++ b/docs/platforms/javascript/guides/nextjs/index.mdx @@ -5,8 +5,11 @@ sdk: sentry.javascript.nextjs categories: - browser - server +runtime: node --- + + diff --git a/docs/platforms/javascript/guides/nuxt/cloudflare.mdx b/docs/platforms/javascript/guides/nuxt/cloudflare.mdx index cc57cea92c072..bbfaf817636e2 100644 --- a/docs/platforms/javascript/guides/nuxt/cloudflare.mdx +++ b/docs/platforms/javascript/guides/nuxt/cloudflare.mdx @@ -3,8 +3,11 @@ title: Nuxt on Cloudflare sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your Nuxt app on Cloudflare Workers and Pages and capture your first errors with Sentry." +runtime: cloudflare --- This guide shows how to set up the SDK with Nitro's `cloudflare_module` deployment preset, or with the deprecated `cloudflare-pages` preset. + + diff --git a/docs/platforms/javascript/guides/nuxt/index.mdx b/docs/platforms/javascript/guides/nuxt/index.mdx index e6b332e27e391..ae2dadcedf2cc 100644 --- a/docs/platforms/javascript/guides/nuxt/index.mdx +++ b/docs/platforms/javascript/guides/nuxt/index.mdx @@ -5,6 +5,9 @@ sdk: sentry.javascript.nuxt categories: - browser - server +runtime: node --- + + diff --git a/docs/platforms/javascript/guides/remix/cloudflare.mdx b/docs/platforms/javascript/guides/remix/cloudflare.mdx index 5ed65b8541964..a0a069e317e86 100644 --- a/docs/platforms/javascript/guides/remix/cloudflare.mdx +++ b/docs/platforms/javascript/guides/remix/cloudflare.mdx @@ -3,6 +3,7 @@ title: Remix on Cloudflare sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your Remix app on Cloudflare Workers and Pages and capture your first errors with Sentry." +runtime: cloudflare --- @@ -11,6 +12,8 @@ Using Shopify Hydrogen? Follow the [Hydrogen with React Router](/platforms/javas + + diff --git a/docs/platforms/javascript/guides/remix/index.mdx b/docs/platforms/javascript/guides/remix/index.mdx index cd0ddc7968c5e..bf99dce2aeb4f 100644 --- a/docs/platforms/javascript/guides/remix/index.mdx +++ b/docs/platforms/javascript/guides/remix/index.mdx @@ -5,6 +5,7 @@ sdk: sentry.javascript.remix categories: - browser - server +runtime: node --- @@ -13,6 +14,8 @@ This guide covers Remix 2. Support for [Remix 3](https://remix.run/blog/remix-3- + + diff --git a/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx b/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx index d83893451749e..e49819349ac07 100644 --- a/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx +++ b/docs/platforms/javascript/guides/sveltekit/cloudflare.mdx @@ -3,6 +3,9 @@ title: SvelteKit on Cloudflare sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your SvelteKit app on Cloudflare Workers and Pages and capture your first errors with Sentry." +runtime: cloudflare --- + + diff --git a/docs/platforms/javascript/guides/sveltekit/index.mdx b/docs/platforms/javascript/guides/sveltekit/index.mdx index 36000b46d9bd3..7036f074c30eb 100644 --- a/docs/platforms/javascript/guides/sveltekit/index.mdx +++ b/docs/platforms/javascript/guides/sveltekit/index.mdx @@ -5,10 +5,13 @@ sdk: sentry.javascript.sveltekit categories: - browser - server +runtime: node --- + + diff --git a/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx index 7b5dc302358b1..7ecae0805d761 100644 --- a/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx +++ b/docs/platforms/javascript/guides/tanstackstart-react/cloudflare.mdx @@ -3,14 +3,17 @@ title: TanStack Start React on Cloudflare sidebar_title: Quick Start (Cloudflare) sidebar_order: 0.5 description: "Learn how to instrument your TanStack Start app on Cloudflare Workers and capture your first errors with Sentry." +runtime: cloudflare --- -This guide is for TanStack Start deployed to **Cloudflare Workers** using the `@cloudflare/vite-plugin`. For Node.js-based deployments, see our [TanStack Start guide](/platforms/javascript/guides/tanstackstart-react/). +This guide is for TanStack Start deployed to **Cloudflare Workers** using the `@cloudflare/vite-plugin`. + + ## Prerequisites You need: diff --git a/docs/platforms/javascript/guides/tanstackstart-react/index.mdx b/docs/platforms/javascript/guides/tanstackstart-react/index.mdx index 88566aa84c18e..ae3d2ff041690 100644 --- a/docs/platforms/javascript/guides/tanstackstart-react/index.mdx +++ b/docs/platforms/javascript/guides/tanstackstart-react/index.mdx @@ -5,6 +5,7 @@ sdk: sentry.javascript.tanstackstart-react categories: - server - browser +runtime: node --- @@ -16,6 +17,8 @@ Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issu + + diff --git a/src/components/runtimeLinks.spec.ts b/src/components/runtimeLinks.spec.ts new file mode 100644 index 0000000000000..8d871ddfcc1fd --- /dev/null +++ b/src/components/runtimeLinks.spec.ts @@ -0,0 +1,50 @@ +import {describe, expect, it} from 'vitest'; + +import {getRuntimeLinks} from './runtimeLinks'; + +const G = 'platforms/javascript/guides'; + +type Page = {children: Page[]; frontmatter: {runtime?: string}; path: string}; + +const page = (path: string, runtime?: string, children: Page[] = []): Page => ({ + path, + frontmatter: runtime ? {runtime} : {}, + children, +}); + +const piDurable = page(`${G}/pi-durable`, 'node', [ + page(`${G}/pi-durable/cloudflare`, 'cloudflare'), + page(`${G}/pi-durable/deno`, 'deno'), + page(`${G}/pi-durable/bun`, 'bun'), + page(`${G}/pi-durable/configuration`), +]); + +const path = (p: string) => p.split('/'); + +describe('getRuntimeLinks', () => { + it('links the guide page and its child pages with a runtime, in doc tree order', () => { + expect(getRuntimeLinks(piDurable, path(`${G}/pi-durable`))?.map(l => l.url)).toEqual([ + `/${G}/pi-durable/`, + `/${G}/pi-durable/cloudflare/`, + `/${G}/pi-durable/deno/`, + `/${G}/pi-durable/bun/`, + ]); + }); + + it('selects the runtime of the current page', () => { + const selected = (p: string) => + getRuntimeLinks(piDurable, path(p)) + ?.filter(l => l.selected) + .map(l => l.runtime); + + expect(selected(`${G}/pi-durable`)).toEqual(['node']); + expect(selected(`${G}/pi-durable/deno`)).toEqual(['deno']); + expect(selected(`${G}/pi-durable/configuration/options`)).toEqual([]); + }); + + it('returns null for a guide with quick starts for fewer than two runtimes', () => { + expect(getRuntimeLinks(page(`${G}/node`, 'node'), path(`${G}/node`))).toBeNull(); + expect(getRuntimeLinks(page(`${G}/eve`), path(`${G}/eve`))).toBeNull(); + expect(getRuntimeLinks(undefined, path('product/agents'))).toBeNull(); + }); +}); diff --git a/src/components/runtimeLinks.ts b/src/components/runtimeLinks.ts new file mode 100644 index 0000000000000..ef440398e15f2 --- /dev/null +++ b/src/components/runtimeLinks.ts @@ -0,0 +1,49 @@ +const RUNTIME_TITLES: Record = { + node: 'Node.js', + cloudflare: 'Cloudflare', + deno: 'Deno', + bun: 'Bun', +}; + +export type RuntimeLink = { + runtime: string; + selected: boolean; + title: string; + url: string; +}; + +type QuickStartNode = { + frontmatter: {runtime?: string}; + path: string; + children?: QuickStartNode[]; +}; + +/** + * Returns the links to the quick starts of `guide`: the guide page and its child pages that + * set `runtime` in their frontmatter, in doc tree order. The page at `path` is selected. + * Returns `null` if the guide has quick starts for fewer than two runtimes. + */ +export function getRuntimeLinks( + guide: QuickStartNode | undefined, + path: string[] +): RuntimeLink[] | null { + if (!guide) { + return null; + } + + const current = path.join('/'); + const links = [guide, ...(guide.children ?? [])].flatMap(page => { + const runtime = page.frontmatter.runtime; + return runtime + ? [ + { + runtime, + selected: page.path === current, + title: RUNTIME_TITLES[runtime] ?? runtime, + url: `/${page.path}/`, + }, + ] + : []; + }); + return links.length < 2 ? null : links; +} diff --git a/src/components/runtimeSelector.tsx b/src/components/runtimeSelector.tsx new file mode 100644 index 0000000000000..5e28ffb6dcace --- /dev/null +++ b/src/components/runtimeSelector.tsx @@ -0,0 +1,58 @@ +import {Button} from '@radix-ui/themes'; +import Link from 'next/link'; +import {nodeForPath} from 'sentry-docs/docTree'; +import {serverContext} from 'sentry-docs/serverContext'; + +import {PlatformIcon} from './platformIcon'; +import {getRuntimeLinks} from './runtimeLinks'; + +/** + * Links the quick starts of the current guide for each runtime: the guide page and its child + * pages that set `runtime` in their frontmatter. The links are plain anchors, so they are also + * in the page's Markdown export for AI agents. + */ +export function RuntimeSelector() { + const {rootNode, path} = serverContext(); + const links = getRuntimeLinks(nodeForPath(rootNode, path.slice(0, 4)), path); + if (!links) { + return null; + } + + return ( + + ); +} diff --git a/src/mdxComponents.ts b/src/mdxComponents.ts index 13d823b180d63..94b41d1cdb72e 100644 --- a/src/mdxComponents.ts +++ b/src/mdxComponents.ts @@ -51,6 +51,7 @@ import {PlatformOrGuideName} from './components/platformOrGuideName'; import {PlatformSdkPackageName} from './components/platformSdkPackageName'; import {PlatformSection} from './components/platformSection'; import {RelayMetrics} from './components/relayMetrics'; +import {RuntimeSelector} from './components/runtimeSelector'; import {SandboxLink} from './components/sandboxLink'; import {SdkApi} from './components/sdkApi'; import {SdkOption} from './components/sdkOption'; @@ -124,6 +125,7 @@ export function mdxComponents( OnboardingOptionButtons, OnboardingSteps, RelayMetrics, + RuntimeSelector, SandboxLink, CopyableCard, SignInNote, diff --git a/src/types/frontmatter.ts b/src/types/frontmatter.ts index fd9a5557eef19..7d5685fbafaca 100644 --- a/src/types/frontmatter.ts +++ b/src/types/frontmatter.ts @@ -97,6 +97,12 @@ export interface FrontMatter { */ previousPage?: PaginationNavNode; + /** + * The runtime of a quick start, for example `node` or `cloudflare`. `` + * links the quick starts of the same guide for the other runtimes. + */ + runtime?: string; + /** * Set this to true to show a separator/divider below this item in the sidebar * @deprecated Use sidebar_section instead