diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx index aa9694271b2269..f4364bdbe918b1 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 00000000000000..c027e06802e60f --- /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 +); +``` + diff --git a/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx b/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx index 2314b6392489c6..8f5d20a26f5af5 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!"); + }, + } ); ```