feat(webapp): add SENTRY_ENVIRONMENT to override the Sentry environment - #4078
feat(webapp): add SENTRY_ENVIRONMENT to override the Sentry environment#4078ericallam wants to merge 2 commits into
Conversation
The Sentry environment was hardcoded to APP_ENV. APP_ENV also drives other behavior, so it cannot be repurposed to give deployments that share another environment's config (for example preview deployments) their own Sentry environment. Add an optional SENTRY_ENVIRONMENT that takes precedence, falling back to APP_ENV when unset so existing deployments are unchanged.
|
WalkthroughAn optional 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| APP_ENV: z.string().default(process.env.NODE_ENV), | ||
| SERVICE_NAME: z.string().default("trigger.dev webapp"), | ||
| SENTRY_DSN: z.string().optional(), | ||
| SENTRY_ENVIRONMENT: z.string().optional(), |
There was a problem hiding this comment.
🟡 Server-only change ships without a release-notes entry
The change touches only webapp server code (SENTRY_ENVIRONMENT added at apps/webapp/app/env.server.ts:154) but the accompanying release-notes entry was removed in the final commit, so this change will be missing from the release notes.
Impact: Users reading the release notes won't see that the new Sentry environment override exists.
Repository rule: server-only PRs require a .server-changes file
CONTRIBUTING.md ("Adding server changes") requires that a PR changing only apps/webapp/ with no package changes adds a .server-changes/ markdown file with area and type frontmatter. The branch added .server-changes/sentry-environment-override.md in commit 44543d60e and then deleted it in the head commit fae374368, leaving the PR with no release-notes entry while modifying apps/webapp/app/env.server.ts and apps/webapp/sentry.server.ts.
Prompt for agents
This PR modifies only server components (apps/webapp), so per CONTRIBUTING.md it needs a .server-changes/ markdown file with `area: webapp` and `type: feature` frontmatter plus a one-line description. Such a file (.server-changes/sentry-environment-override.md) was added earlier in the branch but deleted in the head commit; it should be restored.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
The webapp's Sentry
environmentwas hardcoded toAPP_ENV. BecauseAPP_ENValso drives other behavior, it can't be repurposed to give deployments that share another environment's config (for example preview deployments) their own Sentry environment, so their errors are indistinguishable from the environment whose config they inherit.This adds an optional
SENTRY_ENVIRONMENTthat takes precedence overAPP_ENV:Unset by default, so existing deployments keep their
APP_ENV-derived Sentry environment with no change.