-
Notifications
You must be signed in to change notification settings - Fork 6.5k
chore(open-next): add server-side sentry to open-next site #8830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dario-piotrowicz
merged 7 commits into
nodejs:main
from
dario-piotrowicz:dario/DEVX-2481/sentry-to-open-next-worker
Apr 22, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
32e4272
chore(open-next): add server-side sentry to open-next site
dario-piotrowicz 8a3e213
Update apps/site/cloudflare/worker-entrypoint.ts
dario-piotrowicz a8d799c
remove sentry * import
dario-piotrowicz 0629390
reduce `tracesSampleRate` to `0.05`
dario-piotrowicz af80823
use SENTRY_DSN from env
dario-piotrowicz 746a793
remove `sendDefaultPii` and use `setTags`
dario-piotrowicz 9b04e0f
Update lock file
dario-piotrowicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Note: this custom worker-entrypoint is used so that the worker can include sentry support | ||
| // and it has been written by following: | ||
| // - the official open-next docs: https://opennext.js.org/cloudflare/howtos/custom-worker | ||
| // - the official sentry docs: https://docs.sentry.io/platforms/javascript/guides/cloudflare | ||
|
|
||
| import { setTags, withSentry } from '@sentry/cloudflare'; | ||
|
|
||
| import type { | ||
| ExecutionContext, | ||
| Iso3166Alpha2Code, | ||
| Request, | ||
| } from '@cloudflare/workers-types'; | ||
|
|
||
| import { default as handler } from '../.open-next/worker.js'; | ||
|
|
||
| export default withSentry( | ||
| (env: { | ||
| /** | ||
| * Sentry DSN, used for error monitoring | ||
| * If missing, Sentry isn't used | ||
| */ | ||
| SENTRY_DSN?: string; | ||
| }) => ({ | ||
| dsn: env.SENTRY_DSN, | ||
|
flakey5 marked this conversation as resolved.
|
||
| // Enable logs to be sent to Sentry | ||
| enableLogs: true, | ||
| // Set tracesSampleRate to 0.05 to capture 5% of spans for tracing. | ||
| // Learn more at | ||
| // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate | ||
| tracesSampleRate: 0.05, | ||
| }), | ||
| { | ||
| async fetch( | ||
|
ovflowd marked this conversation as resolved.
|
||
| request: Request, | ||
| env: Record<string, unknown>, | ||
| ctx: ExecutionContext | ||
| ) { | ||
| setTags({ | ||
| request_id: crypto.randomUUID(), | ||
| user_agent: request.headers.get('user-agent'), | ||
| ray_id: request.headers.get('cf-ray'), | ||
|
|
||
| // Type casts needed to keep lsp happy | ||
| ip_country: request.cf?.country as Iso3166Alpha2Code | undefined, | ||
| colo: request.cf?.colo as string | undefined, | ||
| }); | ||
|
|
||
| return handler.fetch(request, env, ctx); | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| export { DOQueueHandler } from '../.open-next/worker.js'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.