Skip to content

Commit 7796f42

Browse files
sfanahataShannon Anahata
andauthored
feat(cloudflare): Fixed snippet to be cloudflare specific (#15369)
## DESCRIBE YOUR PR A snippet was featuring Hono, but this is the cloudflare guide. Removed the reference and updated the snippet to be correct for cloudflare. Preview: https://sentry-docs-git-fix-cloudflare-setup-snippet.sentry.dev/platforms/javascript/guides/cloudflare/#setup-for-cloudflare-workers ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Shannon Anahata <[email protected]>
1 parent a7a1e87 commit 7796f42

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The main Sentry configuration should happen as early as possible in your app's l
4040

4141
<PlatformContent
4242
includePath="getting-started-config"
43-
platform="javascript.cloudflare.workers"
43+
platform="javascript.cloudflare.hono"
4444
/>
4545

4646
### Migration from Community Middleware
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
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:
2+
3+
```typescript {filename:index.ts}
4+
import { Env, Hono } from "hono";
5+
import * as Sentry from "@sentry/cloudflare";
6+
7+
const app = new Hono();
8+
9+
// Add your routes here
10+
// app.get('/your-route', (c) => c.text('Hello!'));
11+
12+
export default Sentry.withSentry(
13+
(env: Env) => {
14+
const { id: versionId } = env.CF_VERSION_METADATA;
15+
16+
return {
17+
dsn: "___PUBLIC_DSN___",
18+
19+
release: versionId,
20+
21+
// Adds request headers and IP for users, for more info visit:
22+
// https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii
23+
sendDefaultPii: true,
24+
// ___PRODUCT_OPTION_START___ logs
25+
26+
// Enable logs to be sent to Sentry
27+
enableLogs: true,
28+
// ___PRODUCT_OPTION_END___ logs
29+
// ___PRODUCT_OPTION_START___ performance
30+
31+
// Set tracesSampleRate to 1.0 to capture 100% of spans for tracing.
32+
// Learn more at
33+
// https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate
34+
tracesSampleRate: 1.0,
35+
// ___PRODUCT_OPTION_END___ performance
36+
};
37+
},
38+
app
39+
);
40+
```
41+

platform-includes/getting-started-config/javascript.cloudflare.workers.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
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:
22

33
```typescript {filename:index.ts}
4-
import { Hono, HTTPException } from "hono";
54
import * as Sentry from "@sentry/cloudflare";
65

76
export default Sentry.withSentry(
@@ -30,7 +29,11 @@ export default Sentry.withSentry(
3029
// ___PRODUCT_OPTION_END___ performance
3130
};
3231
},
33-
// your existing worker export
34-
app
32+
{
33+
async fetch(request, env, ctx) {
34+
// Your worker logic here
35+
return new Response("Hello World!");
36+
},
37+
}
3538
);
3639
```

0 commit comments

Comments
 (0)