diff --git a/docs/platforms/javascript/common/install/index.mdx b/docs/platforms/javascript/common/install/index.mdx index 77f725f7f98cc..d716b77f1ecb9 100644 --- a/docs/platforms/javascript/common/install/index.mdx +++ b/docs/platforms/javascript/common/install/index.mdx @@ -13,6 +13,7 @@ notSupported: - javascript.ember - javascript.firebase - javascript.gatsby + - javascript.hono - javascript.nextjs - javascript.nuxt - javascript.react diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx index 14d12779b6180..819c08c3b07bc 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx @@ -1,134 +1,8 @@ --- title: Hono on Cloudflare -description: "Learn how to instrument your Hono app on Cloudflare Workers and capture your first errors with Sentry." +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, and Bun. - - The community-maintained `@hono/sentry` middleware that uses `toucan-js` has - been deprecated in favor of using `@sentry/cloudflare` directly. If you're - currently using the `@hono/sentry` middleware with `toucan-js`, you should - migrate to `@sentry/cloudflare` directly as shown in this guide. - - - - -## 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: - - - - - - - - - - -## Configure - -The main Sentry configuration should happen as early as possible in your app's lifecycle. - -### Wrangler Configuration - - - -### Initialize the Sentry SDK - - - -### Migration from Community Middleware - - - - - -If you're currently using the `@hono/sentry` middleware, migrate to the official `@sentry/cloudflare` middleware: - - - - -```javascript -// New approach using official Sentry SDK -import { Hono } from 'hono'; -import * as Sentry from '@sentry/cloudflare'; - -const app = new Hono(); - -// Wrap your app with Sentry -export default Sentry.withSentry( - (env: Env) => ({ - dsn: '___PUBLIC_DSN___', - tracesSampleRate: 1.0, - }), - app -); -``` - - - - - - - -### Add Readable Stack Traces With Source Maps (Optional) - - - -## Verify Your Setup - - - - - -## 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: - -- Learn how to [manually capture errors](/platforms/javascript/guides/cloudflare/usage/) -- Continue to [customize your configuration](/platforms/javascript/guides/cloudflare/configuration/) -- 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/frameworks/) -- Find various support topics in troubleshooting -- [Get support](https://sentry.zendesk.com/hc/en-us/) - - - - +For setup instructions, 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 60832d19f8eab..91bb3bbe66db2 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/index.mdx @@ -1,8 +1,8 @@ --- title: Frameworks on Cloudflare -description: "Learn how to set up the Cloudflare SDK with popular Frameworks like Astro, SvelteKit, Remix, and Hono." +description: "Learn how to set up the Cloudflare SDK with popular frameworks like Astro, SvelteKit, and Remix." --- -You can use the Sentry Cloudlare SDK in combination with Sentry meta-framework SDKs like SvelteKit or Remix to instrument your Cloudflare Pages applications that use these frameworks. +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. diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index 91b792cbd2e87..4bfb956d37296 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -12,7 +12,7 @@ categories: Use this guide for general instructions on using the Sentry SDK with Cloudflare. If you're using any of the listed frameworks, follow their specific setup instructions: - **[Astro](/platforms/javascript/guides/cloudflare/frameworks/astro/)** -- **[Hono](/platforms/javascript/guides/cloudflare/frameworks/hono/)** +- **[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/)** diff --git a/docs/platforms/javascript/guides/hono/index.mdx b/docs/platforms/javascript/guides/hono/index.mdx index 1c24eb254fdd2..e80fff3247942 100644 --- a/docs/platforms/javascript/guides/hono/index.mdx +++ b/docs/platforms/javascript/guides/hono/index.mdx @@ -1,6 +1,6 @@ --- title: Hono -description: Learn how to manually set up Sentry in your Hono app and capture your first errors. +description: "Learn how to set up Sentry in your Hono app and capture your first errors." sdk: sentry.javascript.hono fallbackGuide: javascript.node categories: @@ -9,27 +9,390 @@ categories: - server-node --- - + + +This SDK is currently in **alpha**. Alpha features may have bugs and include breaking changes. +Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) with any feedback or concerns. - - This guide focuses on the **Node.js runtime** for Hono. For other runtimes, - see the links below. -## Runtime Support +The `@sentry/hono` SDK supports Hono 4+ across multiple runtimes: Cloudflare Workers, Node.js, and Bun. It works as Hono middleware, so you can drop it into your existing app with minimal setup. -Hono works across multiple JavaScript runtimes. Choose the appropriate Sentry SDK for your environment: + -- **Node.js**: Use `@sentry/node` (this guide) -- **Cloudflare Workers**: Use `@sentry/cloudflare` – see our [Hono on Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/hono/) -- **Deno**: Use `@sentry/deno` – see our [Deno guide](/platforms/javascript/guides/deno/) (Beta) -- **Bun**: Use `@sentry/bun` – see our [Bun guide](/platforms/javascript/guides/bun/) +The community middleware `@hono/sentry` has been deprecated in favor of `@sentry/hono`, which provides better performance and more features. To migrate: - - The community middleware `@hono/sentry` has been deprecated in favor of using - Sentry's official packages, which provide better performance and more - features. If you're currently using `@hono/sentry` middleware, you'll need to - migrate to `@sentry/cloudflare`. - +1. Uninstall `@hono/sentry` and `toucan-js` +2. Follow the install and configure steps below for your runtime +3. Replace the old middleware with the new `sentry()` middleware + + + + + + + +## Install + +Choose the features you want to configure, and this guide will show you how: + + + + + +### Install the Sentry SDK + + + + + +Install the `@sentry/hono` package: + + + + +```bash {tabTitle:npm} +npm install @sentry/hono +``` + +```bash {tabTitle:yarn} +yarn add @sentry/hono +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/hono +``` + + + + + +### Install the Peer Dependency for Your Runtime + + + + + +The SDK needs a runtime-specific peer dependency. Install the one that matches your environment and keep its version in sync with `@sentry/hono`. You won't import it directly, but it must be present in your project. + + + + +```bash {tabTitle:Cloudflare Workers} +npm install @sentry/cloudflare +``` + +```bash {tabTitle:Node.js} +npm install @sentry/node +``` + +```bash {tabTitle:Bun} +npm install @sentry/bun +``` + + + + + + + +### Install the Profiling Package (Node.js Only) + + + + + +Profiling is only available for the Node.js runtime. Install the `@sentry/profiling-node` package: + + + + +```bash {tabTitle:npm} +npm install @sentry/profiling-node --save +``` + +```bash {tabTitle:yarn} +yarn add @sentry/profiling-node +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/profiling-node +``` + + + + + + + +## Configure + + + + + + + +If you're deploying to Cloudflare Workers, set the `nodejs_compat` compatibility flag. The SDK needs `AsyncLocalStorage`, which requires this flag. + + + + +```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} +{ + "compatibility_flags": ["nodejs_compat"] +} +``` + +```toml {tabTitle:Toml} {filename:wrangler.toml} +compatibility_flags = ["nodejs_compat"] +``` + + + + + + + + + + + + + +Node.js requires Sentry to initialize before your application loads so it can instrument third-party libraries (like database clients). Create a separate initialization file: + + + + +```typescript {filename:instrument.mjs} +import * as Sentry from "@sentry/hono/node"; +// ___PRODUCT_OPTION_START___ profiling +import { nodeProfilingIntegration } from "@sentry/profiling-node"; +// ___PRODUCT_OPTION_END___ profiling + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/hono/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ profiling + + integrations: [nodeProfilingIntegration()], + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of spans for tracing. + // We recommend adjusting this value in production + // Learn more at + // https://docs.sentry.io/platforms/javascript/guides/hono/configuration/options/#tracesSampleRate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + // Set profilesSampleRate relative to tracesSampleRate + // Learn more at + // https://docs.sentry.io/platforms/javascript/configuration/options/#profileSessionSampleRate + profileSessionSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs +}); +``` + + + + + + + + + +Load this file with the `--import` flag when starting your app. You can also set this as an environment variable instead: + + + + +```bash {tabTitle:CLI Option} +node --import ./instrument.mjs app.js +``` + +```bash {tabTitle:ENV Variable} +NODE_OPTIONS="--import ./instrument.mjs" +``` + + + + + + + +### Add the Sentry Middleware + + + + + +Add the `sentry()` middleware as early as possible in your Hono app. + +Before continuing, make sure you've completed the runtime-specific steps above: **Cloudflare Workers** users need to enable Node.js compatibility, and **Node.js** users need to create the instrument file. Since Node.js initializes Sentry in that file, the middleware doesn't take any options. + + + + +```typescript {tabTitle:Cloudflare Workers} {filename:index.ts} +import { Hono } from "hono"; +import { sentry } from "@sentry/hono/cloudflare"; + +const app = new Hono(); + +app.use( + sentry(app, { + dsn: "___PUBLIC_DSN___", + + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/hono/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of spans for tracing. + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs + }), +); + +// Your routes here + +export default app; +``` + +```typescript {tabTitle:Node.js} {filename:app.ts} +import { Hono } from "hono"; +import { serve } from "@hono/node-server"; +import { sentry } from "@sentry/hono/node"; + +const app = new Hono(); + +app.use(sentry(app)); + +// Your routes here + +serve(app); +``` + +```typescript {tabTitle:Bun} {filename:index.ts} +import { Hono } from "hono"; +import { sentry } from "@sentry/hono/bun"; + +const app = new Hono(); + +app.use( + sentry(app, { + dsn: "___PUBLIC_DSN___", + + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/hono/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% + // of spans for tracing. + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs + }), +); + +// Your routes here + +export default app; +``` + + + + + + + + + + + +To access environment variables from your Cloudflare Worker bindings (for example, to store the DSN as a secret), pass a callback instead of a plain options object. The function 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. + +### Add Readable Stack Traces With Source Maps (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 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](/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 + + + +- Find various topics in Troubleshooting +- [Get support](https://sentry.zendesk.com/hc/en-us/) + + - + diff --git a/platform-includes/capture-error/javascript.hono.mdx b/platform-includes/capture-error/javascript.hono.mdx new file mode 100644 index 0000000000000..2eeab8e774f7a --- /dev/null +++ b/platform-includes/capture-error/javascript.hono.mdx @@ -0,0 +1,31 @@ +You can pass an `Error` object to `captureException()` to have it captured as event. It's also possible to pass non-`Error` objects and strings, but be aware that the resulting events in Sentry may be missing a stack trace. + +```javascript {tabTitle:Cloudflare Workers} +import * as Sentry from "@sentry/hono/cloudflare"; + +try { + aFunctionThatMightFail(); +} catch (e) { + Sentry.captureException(e); +} +``` + +```javascript {tabTitle:Node.js} +import * as Sentry from "@sentry/hono/node"; + +try { + aFunctionThatMightFail(); +} catch (e) { + Sentry.captureException(e); +} +``` + +```javascript {tabTitle:Bun} +import * as Sentry from "@sentry/hono/bun"; + +try { + aFunctionThatMightFail(); +} catch (e) { + Sentry.captureException(e); +} +``` diff --git a/platform-includes/enriching-events/import/javascript.hono.mdx b/platform-includes/enriching-events/import/javascript.hono.mdx new file mode 100644 index 0000000000000..c8caa965a2026 --- /dev/null +++ b/platform-includes/enriching-events/import/javascript.hono.mdx @@ -0,0 +1,11 @@ +```javascript {tabTitle:Cloudflare Workers} +import * as Sentry from "@sentry/hono/cloudflare"; +``` + +```javascript {tabTitle:Node.js} +import * as Sentry from "@sentry/hono/node"; +``` + +```javascript {tabTitle:Bun} +import * as Sentry from "@sentry/hono/bun"; +``` diff --git a/platform-includes/enriching-events/set-user-middleware/javascript.hono.mdx b/platform-includes/enriching-events/set-user-middleware/javascript.hono.mdx new file mode 100644 index 0000000000000..c39f990e7bf81 --- /dev/null +++ b/platform-includes/enriching-events/set-user-middleware/javascript.hono.mdx @@ -0,0 +1,59 @@ +```javascript {tabTitle:Cloudflare Workers} +import * as Sentry from "@sentry/hono/cloudflare"; + +app.use(async (c, next) => { + const user = c.get("user"); + + if (user) { + Sentry.setUser({ + id: user.id, + email: user.email, + username: user.username, + }); + } else { + Sentry.setUser(null); + } + + await next(); +}); +``` + +```javascript {tabTitle:Node.js} +import * as Sentry from "@sentry/hono/node"; + +app.use(async (c, next) => { + const user = c.get("user"); + + if (user) { + Sentry.setUser({ + id: user.id, + email: user.email, + username: user.username, + }); + } else { + Sentry.setUser(null); + } + + await next(); +}); +``` + +```javascript {tabTitle:Bun} +import * as Sentry from "@sentry/hono/bun"; + +app.use(async (c, next) => { + const user = c.get("user"); + + if (user) { + Sentry.setUser({ + id: user.id, + email: user.email, + username: user.username, + }); + } else { + Sentry.setUser(null); + } + + await next(); +}); +``` diff --git a/platform-includes/enriching-events/set-user-request/javascript.hono.mdx b/platform-includes/enriching-events/set-user-request/javascript.hono.mdx new file mode 100644 index 0000000000000..23806245f637a --- /dev/null +++ b/platform-includes/enriching-events/set-user-request/javascript.hono.mdx @@ -0,0 +1,47 @@ +```javascript {tabTitle:Cloudflare Workers} +import * as Sentry from "@sentry/hono/cloudflare"; + +app.get("/my-route", (c) => { + const user = c.get("user"); + + Sentry.setUser({ + id: user.id, + email: user.email, + username: user.username, + }); + + return c.text("Hello World"); +}); +``` + +```javascript {tabTitle:Node.js} +import * as Sentry from "@sentry/hono/node"; + +app.get("/my-route", (c) => { + const user = c.get("user"); + + Sentry.setUser({ + id: user.id, + email: user.email, + username: user.username, + }); + + return c.text("Hello World"); +}); +``` + +```javascript {tabTitle:Bun} +import * as Sentry from "@sentry/hono/bun"; + +app.get("/my-route", (c) => { + const user = c.get("user"); + + Sentry.setUser({ + id: user.id, + email: user.email, + username: user.username, + }); + + return c.text("Hello World"); +}); +``` diff --git a/platform-includes/enriching-events/set-user/javascript.hono.mdx b/platform-includes/enriching-events/set-user/javascript.hono.mdx new file mode 100644 index 0000000000000..57383d42c4912 --- /dev/null +++ b/platform-includes/enriching-events/set-user/javascript.hono.mdx @@ -0,0 +1,17 @@ +```javascript {tabTitle:Cloudflare Workers} +import * as Sentry from "@sentry/hono/cloudflare"; + +Sentry.setUser({ email: "john.doe@example.com" }); +``` + +```javascript {tabTitle:Node.js} +import * as Sentry from "@sentry/hono/node"; + +Sentry.setUser({ email: "john.doe@example.com" }); +``` + +```javascript {tabTitle:Bun} +import * as Sentry from "@sentry/hono/bun"; + +Sentry.setUser({ email: "john.doe@example.com" }); +``` diff --git a/platform-includes/getting-started-capture-errors/javascript.hono.mdx b/platform-includes/getting-started-capture-errors/javascript.hono.mdx index d7674a29a4a3c..806df42b477ef 100644 --- a/platform-includes/getting-started-capture-errors/javascript.hono.mdx +++ b/platform-includes/getting-started-capture-errors/javascript.hono.mdx @@ -1,5 +1,3 @@ ### Report Unhandled Exceptions -By default, Sentry reports exceptions reported by the `onError` function from Hono. In case the error comes with a status code, it captures all errors except for the ones with a 3xx or 4xx status code. - -To learn how to customize this behavior, see the [`honoIntegration` documentation](/platforms/javascript/guides/cloudflare/configuration/integrations/hono/). +By default, Sentry captures exceptions from Hono's `onError` handler. Errors with a 3xx or 4xx status code are excluded. You can customize this behavior through the `honoIntegration`'s `shouldHandleError` option. diff --git a/platform-includes/getting-started-prerequisites/javascript.hono.mdx b/platform-includes/getting-started-prerequisites/javascript.hono.mdx new file mode 100644 index 0000000000000..76c93a2ca7d66 --- /dev/null +++ b/platform-includes/getting-started-prerequisites/javascript.hono.mdx @@ -0,0 +1,7 @@ +## Prerequisites + +You need: + +- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) +- Your application up and running +- Hono version `4.0.0` or above diff --git a/platform-includes/performance/configure-sample-rate/javascript.hono.mdx b/platform-includes/performance/configure-sample-rate/javascript.hono.mdx index c3958c3babb52..e9cc753b6c298 100644 --- a/platform-includes/performance/configure-sample-rate/javascript.hono.mdx +++ b/platform-includes/performance/configure-sample-rate/javascript.hono.mdx @@ -1,5 +1,22 @@ -```javascript -import * as Sentry from "@sentry/node" +```javascript {tabTitle:Cloudflare Workers} +import { sentry } from "@sentry/hono/cloudflare"; + +app.use( + sentry(app, { + dsn: "___PUBLIC_DSN___", + + // We recommend adjusting this value in production, or using tracesSampler + // for finer control + tracesSampleRate: 1.0, + + // Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], + }), +); +``` + +```javascript {tabTitle:Node.js} {filename: instrument.mjs} +import * as Sentry from "@sentry/hono/node"; Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -8,10 +25,24 @@ Sentry.init({ // for finer control tracesSampleRate: 1.0, - // Enhanced tracing options - environment: process.env.NODE_ENV || 'development', - // Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], }); ``` + +```javascript {tabTitle:Bun} +import { sentry } from "@sentry/hono/bun"; + +app.use( + sentry(app, { + dsn: "___PUBLIC_DSN___", + + // We recommend adjusting this value in production, or using tracesSampler + // for finer control + tracesSampleRate: 1.0, + + // Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], + }), +); +``` diff --git a/platform-includes/performance/enable-tracing/javascript.hono.mdx b/platform-includes/performance/enable-tracing/javascript.hono.mdx new file mode 100644 index 0000000000000..8688406742463 --- /dev/null +++ b/platform-includes/performance/enable-tracing/javascript.hono.mdx @@ -0,0 +1 @@ +`@sentry/hono` has tracing enabled by default. diff --git a/platform-includes/set-environment/javascript.hono.mdx b/platform-includes/set-environment/javascript.hono.mdx new file mode 100644 index 0000000000000..11152509ca335 --- /dev/null +++ b/platform-includes/set-environment/javascript.hono.mdx @@ -0,0 +1,32 @@ +```javascript {tabTitle:Cloudflare Workers} +import { sentry } from "@sentry/hono/cloudflare"; + +// Pass environment in the sentry() middleware options +app.use( + sentry(app, { + dsn: "___PUBLIC_DSN___", + environment: "production", + }), +); +``` + +```javascript {tabTitle:Node.js} {filename: instrument.mjs} +import * as Sentry from "@sentry/hono/node"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + environment: "production", +}); +``` + +```javascript {tabTitle:Bun} +import { sentry } from "@sentry/hono/bun"; + +// Pass environment in the sentry() middleware options +app.use( + sentry(app, { + dsn: "___PUBLIC_DSN___", + environment: "production", + }), +); +```