From f2ecbfc9db3534f0cf3aea063e888cb1efe30d91 Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Fri, 31 Oct 2025 10:23:45 -0700 Subject: [PATCH 1/2] fixed snippet to be cloudflare specific --- .../javascript.cloudflare.workers.mdx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx b/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx index 2314b6392489c..8f5d20a26f5af 100644 --- a/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx +++ b/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx @@ -1,7 +1,6 @@ Wrap your worker handler with the `withSentry` function, for example, in your `index.ts` file, to initialize the Sentry SDK and hook into the environment: ```typescript {filename:index.ts} -import { Hono, HTTPException } from "hono"; import * as Sentry from "@sentry/cloudflare"; export default Sentry.withSentry( @@ -30,7 +29,11 @@ export default Sentry.withSentry( // ___PRODUCT_OPTION_END___ performance }; }, - // your existing worker export - app + { + async fetch(request, env, ctx) { + // Your worker logic here + return new Response("Hello World!"); + }, + } ); ``` From 8080f6768290f5f88bce175437cd54ade958631d Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Tue, 4 Nov 2025 10:02:47 -0800 Subject: [PATCH 2/2] updating hono to have proper snippets --- .../guides/cloudflare/frameworks/hono.mdx | 2 +- .../javascript.cloudflare.hono.mdx | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 platform-includes/getting-started-config/javascript.cloudflare.hono.mdx diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx index aa9694271b226..f4364bdbe918b 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx @@ -40,7 +40,7 @@ The main Sentry configuration should happen as early as possible in your app's l ### Migration from Community Middleware diff --git a/platform-includes/getting-started-config/javascript.cloudflare.hono.mdx b/platform-includes/getting-started-config/javascript.cloudflare.hono.mdx new file mode 100644 index 0000000000000..c027e06802e60 --- /dev/null +++ b/platform-includes/getting-started-config/javascript.cloudflare.hono.mdx @@ -0,0 +1,41 @@ +Wrap your Hono app with the `withSentry` function, for example, in your `index.ts` file, to initialize the Sentry SDK and hook into the environment: + +```typescript {filename:index.ts} +import { Env, Hono } from "hono"; +import * as Sentry from "@sentry/cloudflare"; + +const app = new Hono(); + +// Add your routes here +// app.get('/your-route', (c) => c.text('Hello!')); + +export default Sentry.withSentry( + (env: Env) => { + const { id: versionId } = env.CF_VERSION_METADATA; + + return { + dsn: "___PUBLIC_DSN___", + + release: versionId, + + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs + // ___PRODUCT_OPTION_START___ performance + + // 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, + // ___PRODUCT_OPTION_END___ performance + }; + }, + app +); +``` +