Skip to content

feat(webapp): add SENTRY_ENVIRONMENT to override the Sentry environment - #4078

Open
ericallam wants to merge 2 commits into
mainfrom
feat/webapp-sentry-environment-override
Open

feat(webapp): add SENTRY_ENVIRONMENT to override the Sentry environment#4078
ericallam wants to merge 2 commits into
mainfrom
feat/webapp-sentry-environment-override

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

The webapp's Sentry environment was hardcoded to APP_ENV. Because APP_ENV also 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_ENVIRONMENT that takes precedence over APP_ENV:

environment: process.env.SENTRY_ENVIRONMENT ?? process.env.APP_ENV,

Unset by default, so existing deployments keep their APP_ENV-derived Sentry environment with no change.

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.
@changeset-bot

changeset-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fae3743

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ericallam
ericallam marked this pull request as ready for review June 29, 2026 22:12
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

An optional SENTRY_ENVIRONMENT environment variable is added to EnvironmentSchema in env.server.ts. In sentry.server.ts, the Sentry init call's environment field is updated to use process.env.SENTRY_ENVIRONMENT ?? process.env.APP_ENV, falling back to APP_ENV when the new variable is absent. A changelog entry documents this behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary, but it omits most required template sections such as Closes #issue, checklist, testing, changelog, and screenshots. Fill in the full template with the issue reference, checklist, testing steps, changelog entry, and screenshots section.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and matches the main change: adding SENTRY_ENVIRONMENT to override the Sentry environment.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/webapp-sentry-environment-override

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

coderabbitai[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Open in Devin Review

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(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants