Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The main Sentry configuration should happen as early as possible in your app's l

<PlatformContent
includePath="getting-started-config"
platform="javascript.cloudflare.workers"
platform="javascript.cloudflare.hono"
/>

### Migration from Community Middleware
Expand Down
Original file line number Diff line number Diff line change
@@ -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
);
```

Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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!");
},
}
Comment on lines +32 to +37
Copy link
Member

@s1gr1d s1gr1d Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now also used on this page: https://sentry-docs-git-fix-cloudflare-setup-snippet.sentry.dev/platforms/javascript/guides/cloudflare/frameworks/hono/

We should use a Hono-specific snippet on the Hono setup and we need the following imports and the app:

import { Env, Hono } from "hono";

const app = new Hono();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll double check where else that includes exists, but doesn't seem like it should be used on any of the other framework specific docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s1gr1d - updated. Let me know how it looks.

);
```
Loading