-
Notifications
You must be signed in to change notification settings - Fork 463
Update sentry #1068
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
base: main
Are you sure you want to change the base?
Update sentry #1068
Conversation
4033fa2 to
8a1be9f
Compare
8a1be9f to
a27721f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates Sentry from v9 to v10 and modernizes the instrumentation approach by using the recommended node --import pattern for ESM projects. The update enables several new features including Spotlight for local development, distributed tracing between frontend and backend, console logging integration, and automated Sentry release creation via GitHub Actions.
Key Changes
- Migrates Sentry packages from v9.32.0 to v10.31.0
- Implements early instrumentation using
--importflag in package.json scripts - Adds new
instrument.server.tsfile for centralized server-side Sentry configuration - Integrates Spotlight for local debugging and removes production-only Sentry initialization checks
- Enables distributed tracing with
Sentry.getMetaTagTransformer()for client-server trace correlation
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updates Sentry packages to v10.31.0, adds @sentry/cli v3.0.1, and modifies scripts to use --import ./instrument.server.ts for early instrumentation |
| package-lock.json | Reflects dependency updates including Sentry v10 and updated OpenTelemetry instrumentation packages |
| instrument.server.ts | New file containing server-side Sentry initialization with Prisma, HTTP, profiling, and console logging integrations |
| vite.config.ts | Simplifies Sentry config by removing unstable_sentryVitePluginOptions and using new plugin configuration |
| server/index.ts | Removes manual Sentry initialization logic (moved to instrument.server.ts via --import) |
| server/utils/monitoring.ts | Deleted - functionality moved to instrument.server.ts |
| app/entry.server.tsx | Adds Sentry wrapper functions for request handling and error tracking, implements meta tag transformer for distributed tracing, and updates CSP for Spotlight |
| app/entry.client.tsx | Moves Sentry initialization inline with Spotlight support and updates integrations for v10 |
| app/utils/monitoring.client.tsx | Deleted - functionality moved to app/entry.client.tsx |
| .github/workflows/deploy.yml | Injects SENTRY_ENVIRONMENT and adds Sentry release creation step using getsentry/action-release@v3 |
| .env.example | Adds SENTRY_ENVIRONMENT variable for environment-specific configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The environment variables are all over the place in this PR. |
This PR updates Sentry, and I used the Sentry Wizard to configure the app for the latest best practices.
node --importattribute to instrument Sentry before the app starts, as recommended for ESM projects: https://docs.sentry.io/platforms/javascript/guides/node/install/esm/The SENTRY_ENVIRONMENT variable is passed to the production/staging fly app, so that you can filter for staging or production errors/traces in sentry. This variable is set to SENTRY_ENVIRONMENT=test in playwright. So that you can also debug sentry errors that occur in CI.
It adds Sentry.getMetaTagTransformer for distrubuted tracing between frontend and backend! 🔥
It enables spotlight in local development. In local development, errors are not send to Sentry server, but to the local Sentry spotlight app (if installed). This is useful for local debugging, but maybe even more important, this unlocks a lot of AI/MCP potential. If you install the Sentry MCP server, then this makes errors, network requests, db queries, logs, traces directly available to your agent.
I added the Sentry logging integration, as the epic stack has no logging solutions, and having logs next your error tool, can add a lot of context to why errors happened. And gives more context on what is actually going on the server:
Removed
unstable_sentryVitePluginOptionsas this is not needed anymore with the react router vite sentry plugin. It deletes sourcemaps automatically.I added a sentry example page (only available to admin users). So that users can easily test sentry errors in the deployed app.
Test Plan
I have tested all this locally and by deploying it myself.
Checklist
Screenshots