Skip to content

fix(sentry): disable error tracking in dev and preview environments#510

Merged
saddlepaddle merged 1 commit into
mainfrom
famous-boar-8fbd7e
Dec 26, 2025
Merged

fix(sentry): disable error tracking in dev and preview environments#510
saddlepaddle merged 1 commit into
mainfrom
famous-boar-8fbd7e

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Dec 26, 2025

Summary

  • Disable Sentry in development and preview environments across all apps
  • Only enable error tracking in production to reduce noise
  • Simplify desktop Sentry config since it only runs in production now

Test plan

  • Verify Sentry is disabled when NEXT_PUBLIC_SENTRY_ENVIRONMENT !== "production"
  • Verify Sentry still works correctly in production
  • Confirm desktop app doesn't initialize Sentry in dev

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Updated error monitoring to activate only in production environments, ensuring tracking is consistently controlled by environment rather than configuration presence across all applications.

✏️ Tip: You can customize this high-level summary in your review settings.

Only enable Sentry in production to reduce noise from development and
preview environment errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 26, 2025

📝 Walkthrough

Walkthrough

Modifies Sentry initialization enablement across multiple applications to activate only in production environments, replacing the previous DSN-presence check. Additionally, standardizes tracesSampleRate values and enforces dual production environment gating in desktop clients.

Changes

Cohort / File(s) Summary
API configurations
apps/api/sentry.edge.config.ts, apps/api/sentry.server.config.ts
Changed enabled flag from DSN truthiness check to production environment check (env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production"). Traces sampling remains environment-based.
Desktop main process
apps/desktop/src/main/lib/sentry.ts
Added early-exit production-mode gating for both DSN presence and production environment. Replaced environment-dependent tracesSampleRate with constant 0.1.
Desktop renderer process
apps/desktop/src/renderer/lib/sentry.ts
Added production-only initialization requirement (DSN and NODE_ENV === "production"). Replaced environment-dependent tracesSampleRate with constant 0.1.
Docs configurations
apps/docs/sentry.edge.config.ts, apps/docs/sentry.server.config.ts, apps/docs/src/instrumentation-client.ts
Changed enabled flag from DSN check to production environment check. Traces sampling remains environment-based.
Marketing configurations
apps/marketing/sentry.edge.config.ts, apps/marketing/sentry.server.config.ts, apps/marketing/src/instrumentation-client.ts
Changed enabled flag from DSN presence to production environment check. Traces sampling remains environment-based.
Web configurations
apps/web/sentry.edge.config.ts, apps/web/sentry.server.config.ts, apps/web/src/instrumentation-client.ts
Changed enabled flag from DSN truthiness to production environment check. Traces sampling remains environment-based.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Poem

🐰 Hops of activation, now tightly bound,
DSN checks fade without a sound,
Production only, the new command,
Sentry serves with a careful hand! 🌱

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: disabling Sentry error tracking in dev and preview environments, enabling it only in production.
Description check ✅ Passed The description covers the main objective and includes a test plan, but lacks key template sections like Type of Change and Related Issues.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch famous-boar-8fbd7e

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/docs/src/instrumentation-client.ts (1)

26-34: Verify that NEXT_PUBLIC_SENTRY_DSN_DOCS is configured in production deployments.

The NEXT_PUBLIC_SENTRY_DSN_DOCS variable is optional per the environment schema, so Sentry could be enabled in production without a valid DSN. However, the environment-based gating pattern (enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production") is consistent with the approach used in apps/web, apps/marketing, and apps/api. Ensure production deployments always provide the DSN, or this will silently fail to send events.

🧹 Nitpick comments (4)
apps/docs/sentry.server.config.ts (1)

8-8: Consider adding DSN validation to the enabled check.

The change correctly implements production-only enablement. However, since NEXT_PUBLIC_SENTRY_DSN_DOCS is optional, Sentry could initialize in production without a valid DSN, leading to silent failure of error tracking.

🔎 Suggested defensive check
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_DOCS,

This ensures Sentry only initializes when both the environment is production AND a DSN is configured, preventing silent configuration errors.

apps/web/src/instrumentation-client.ts (1)

29-29: Consider adding DSN validation to the enabled check.

The production-only enablement aligns with the PR objectives. However, with NEXT_PUBLIC_SENTRY_DSN_WEB being optional, there's a risk of Sentry initializing in production without a valid DSN, resulting in no error tracking without any warnings.

🔎 Suggested defensive check
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_WEB,

This dual check ensures Sentry initializes only when properly configured.

apps/docs/sentry.edge.config.ts (1)

8-8: Consider adding DSN validation to the enabled check.

While the production-only gating correctly implements the PR objectives, the optional NEXT_PUBLIC_SENTRY_DSN_DOCS could lead to Sentry initializing in production without a DSN, causing silent error tracking failure.

🔎 Suggested defensive check
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_DOCS,

This prevents misconfiguration where production is set but DSN is forgotten.

apps/marketing/sentry.server.config.ts (1)

8-8: Consider adding DSN validation to the enabled check.

The change achieves the PR goal of production-only Sentry enablement. However, since NEXT_PUBLIC_SENTRY_DSN_MARKETING is optional, Sentry might initialize in production without a valid DSN, leading to undetected error tracking failures.

🔎 Suggested defensive check
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,

This dual condition guards against configuration mistakes in production.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de14fe1 and feb0dc4.

📒 Files selected for processing (13)
  • apps/api/sentry.edge.config.ts
  • apps/api/sentry.server.config.ts
  • apps/desktop/src/main/lib/sentry.ts
  • apps/desktop/src/renderer/lib/sentry.ts
  • apps/docs/sentry.edge.config.ts
  • apps/docs/sentry.server.config.ts
  • apps/docs/src/instrumentation-client.ts
  • apps/marketing/sentry.edge.config.ts
  • apps/marketing/sentry.server.config.ts
  • apps/marketing/src/instrumentation-client.ts
  • apps/web/sentry.edge.config.ts
  • apps/web/sentry.server.config.ts
  • apps/web/src/instrumentation-client.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid using any type in TypeScript - maintain type safety unless absolutely necessary

Files:

  • apps/marketing/src/instrumentation-client.ts
  • apps/marketing/sentry.server.config.ts
  • apps/web/sentry.server.config.ts
  • apps/docs/src/instrumentation-client.ts
  • apps/docs/sentry.server.config.ts
  • apps/web/src/instrumentation-client.ts
  • apps/docs/sentry.edge.config.ts
  • apps/desktop/src/renderer/lib/sentry.ts
  • apps/api/sentry.edge.config.ts
  • apps/api/sentry.server.config.ts
  • apps/marketing/sentry.edge.config.ts
  • apps/desktop/src/main/lib/sentry.ts
  • apps/web/sentry.edge.config.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Run Biome for formatting, linting, import organization, and safe fixes at the root level using bun run lint:fix

Files:

  • apps/marketing/src/instrumentation-client.ts
  • apps/marketing/sentry.server.config.ts
  • apps/web/sentry.server.config.ts
  • apps/docs/src/instrumentation-client.ts
  • apps/docs/sentry.server.config.ts
  • apps/web/src/instrumentation-client.ts
  • apps/docs/sentry.edge.config.ts
  • apps/desktop/src/renderer/lib/sentry.ts
  • apps/api/sentry.edge.config.ts
  • apps/api/sentry.server.config.ts
  • apps/marketing/sentry.edge.config.ts
  • apps/desktop/src/main/lib/sentry.ts
  • apps/web/sentry.edge.config.ts
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules in renderer process or shared code - use only in main process (src/main/)

Files:

  • apps/desktop/src/renderer/lib/sentry.ts
apps/desktop/src/{main,renderer,preload}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use type-safe IPC communication - define channel types in apps/desktop/src/shared/ipc-channels.ts before implementing handlers

Files:

  • apps/desktop/src/renderer/lib/sentry.ts
  • apps/desktop/src/main/lib/sentry.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc
Use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from @trpc/server/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/src/renderer/lib/sentry.ts
  • apps/desktop/src/main/lib/sentry.ts
apps/desktop/src/main/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Accept object parameters in IPC handlers - do not use positional parameters in ipcMain.handle()

Files:

  • apps/desktop/src/main/lib/sentry.ts
🧬 Code graph analysis (13)
apps/marketing/src/instrumentation-client.ts (1)
apps/marketing/src/env.ts (1)
  • env (5-42)
apps/marketing/sentry.server.config.ts (1)
apps/marketing/src/env.ts (1)
  • env (5-42)
apps/web/sentry.server.config.ts (3)
apps/docs/src/env.ts (1)
  • env (5-36)
apps/marketing/src/env.ts (1)
  • env (5-42)
apps/web/src/env.ts (1)
  • env (5-53)
apps/docs/src/instrumentation-client.ts (1)
apps/docs/src/env.ts (1)
  • env (5-36)
apps/docs/sentry.server.config.ts (1)
apps/docs/src/env.ts (1)
  • env (5-36)
apps/web/src/instrumentation-client.ts (1)
apps/web/src/env.ts (1)
  • env (5-53)
apps/docs/sentry.edge.config.ts (5)
apps/api/src/env.ts (1)
  • env (4-41)
apps/admin/src/env.ts (1)
  • env (5-48)
apps/docs/src/env.ts (1)
  • env (5-36)
apps/marketing/src/env.ts (1)
  • env (5-42)
apps/web/src/env.ts (1)
  • env (5-53)
apps/desktop/src/renderer/lib/sentry.ts (2)
apps/desktop/src/main/env.main.ts (1)
  • env (12-44)
apps/desktop/src/renderer/env.renderer.ts (1)
  • env (45-47)
apps/api/sentry.edge.config.ts (3)
apps/api/src/env.ts (1)
  • env (4-41)
apps/docs/src/env.ts (1)
  • env (5-36)
apps/web/src/env.ts (1)
  • env (5-53)
apps/api/sentry.server.config.ts (2)
apps/api/src/env.ts (1)
  • env (4-41)
apps/docs/src/env.ts (1)
  • env (5-36)
apps/marketing/sentry.edge.config.ts (1)
apps/marketing/src/env.ts (1)
  • env (5-42)
apps/desktop/src/main/lib/sentry.ts (2)
apps/desktop/src/main/env.main.ts (1)
  • env (12-44)
apps/desktop/src/renderer/env.renderer.ts (1)
  • env (45-47)
apps/web/sentry.edge.config.ts (3)
apps/docs/src/env.ts (1)
  • env (5-36)
apps/marketing/src/env.ts (1)
  • env (5-42)
apps/web/src/env.ts (1)
  • env (5-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Deploy API
  • GitHub Check: Deploy Web
  • GitHub Check: Deploy Marketing
  • GitHub Check: Deploy Docs
  • GitHub Check: Deploy Admin
  • GitHub Check: Build
🔇 Additional comments (4)
apps/desktop/src/main/lib/sentry.ts (2)

8-10: Good defensive gating for Sentry initialization.

The dual check ensures Sentry only initializes when both the DSN is present AND the environment is production. This is safer than checking environment alone, as it prevents initialization with missing credentials.


19-19: tracesSampleRate simplification is appropriate.

Since Sentry now only initializes in production (Line 8), the constant value of 0.1 is correct and eliminates unnecessary conditional logic. This aligns with the PR objective to simplify desktop configuration.

apps/desktop/src/renderer/lib/sentry.ts (2)

8-10: Good defensive gating for Sentry initialization.

Consistent with the main process, this dual check ensures Sentry only initializes when both the DSN is present AND the environment is production, preventing initialization issues in non-production or misconfigured environments.


19-19: tracesSampleRate simplification is appropriate.

Since initialization is now production-only (Line 8), the constant 0.1 value removes unnecessary branching logic while maintaining the intended production sampling rate.

dsn: env.NEXT_PUBLIC_SENTRY_DSN_API,
environment: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
enabled: !!env.NEXT_PUBLIC_SENTRY_DSN_API,
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
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.

⚠️ Potential issue | 🟠 Major

Consider defensive check: verify DSN presence before enabling.

The enabled flag should verify both the environment and DSN presence to prevent enabling Sentry without a valid DSN in production.

🔎 Suggested defensive fix
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_API,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_API,
🤖 Prompt for AI Agents
In apps/api/sentry.edge.config.ts around line 8, the enabled flag currently only
checks for production but can be true without a valid DSN; change the logic to
require both production environment and a non-empty Sentry DSN (e.g.
process.env.SENTRY_DSN or process.env.NEXT_PUBLIC_SENTRY_DSN as appropriate)
before enabling Sentry, performing a defensive truthiness check (trim/length) so
Sentry is only enabled when running in production AND a valid DSN exists.

dsn: env.NEXT_PUBLIC_SENTRY_DSN_API,
environment: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
enabled: !!env.NEXT_PUBLIC_SENTRY_DSN_API,
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
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.

⚠️ Potential issue | 🟠 Major

Consider defensive check: verify DSN presence before enabling.

The enabled flag should verify both the environment and DSN presence to prevent enabling Sentry without valid credentials in production.

🔎 Suggested defensive fix
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_API,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_API,
🤖 Prompt for AI Agents
In apps/api/sentry.server.config.ts around line 8, the enabled flag only checks
the environment and may enable Sentry in production even when no DSN is
provided; update the enabled calculation to require both production environment
AND a present, non-empty DSN (e.g., check process.env.SENTRY_DSN or
process.env.NEXT_PUBLIC_SENTRY_DSN with a trim() truthy check) so Sentry is only
enabled when credentials exist.

dsn: env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
environment: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
enabled: !!env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
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.

⚠️ Potential issue | 🟠 Major

Consider defensive check: verify DSN presence before enabling.

The enabled flag should verify both the environment and DSN presence to avoid runtime issues if the DSN is missing in production.

🔎 Suggested defensive fix
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
🤖 Prompt for AI Agents
In apps/marketing/sentry.edge.config.ts around line 8, the enabled flag
currently only checks the environment and should also verify that the Sentry DSN
is present; change the logic to enable Sentry only when
env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" AND a non-empty
env.NEXT_PUBLIC_SENTRY_DSN exists (e.g., check
Boolean(env.NEXT_PUBLIC_SENTRY_DSN) or trim and length > 0) so production
without a DSN does not try to initialize Sentry.

dsn: env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
environment: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
enabled: !!env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
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.

⚠️ Potential issue | 🟠 Major

Consider defensive check: verify DSN presence before enabling.

Similar to other configs, the enabled flag now depends only on the production environment. If NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" but NEXT_PUBLIC_SENTRY_DSN_MARKETING is undefined, Sentry will be enabled without a valid DSN.

🔎 Suggested defensive fix
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_MARKETING,
🤖 Prompt for AI Agents
In apps/marketing/src/instrumentation-client.ts around line 35, the Sentry
enabled flag currently checks only for production environment; update it so it
also verifies that process.env.NEXT_PUBLIC_SENTRY_DSN_MARKETING (or
env.NEXT_PUBLIC_SENTRY_DSN_MARKETING depending on how env is referenced in this
file) is defined and non-empty before enabling. Change the logic to set enabled
to true only when environment === "production" AND the DSN string exists
(trimmed and non-empty), otherwise set enabled false, and ensure any downstream
initialization respects this combined check.

dsn: env.NEXT_PUBLIC_SENTRY_DSN_WEB,
environment: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
enabled: !!env.NEXT_PUBLIC_SENTRY_DSN_WEB,
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
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.

⚠️ Potential issue | 🟠 Major

Consider defensive check: verify DSN presence before enabling.

The enabled flag now depends solely on the production environment, but the DSN is optional and may be undefined. If NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" but NEXT_PUBLIC_SENTRY_DSN_WEB is missing, Sentry will be enabled without a valid DSN, potentially causing runtime warnings or silent failures.

🔎 Suggested defensive fix
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_WEB,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_WEB,
🤖 Prompt for AI Agents
In apps/web/sentry.edge.config.ts around line 8, the enabled flag currently only
checks NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" which can enable Sentry
even when NEXT_PUBLIC_SENTRY_DSN_WEB is missing; update the logic to verify the
DSN exists too by checking env.NEXT_PUBLIC_SENTRY_DSN_WEB (or its proper config
key) alongside the environment before setting enabled, so Sentry is only enabled
when both environment === "production" and a non-empty DSN is present.

dsn: env.NEXT_PUBLIC_SENTRY_DSN_WEB,
environment: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
enabled: !!env.NEXT_PUBLIC_SENTRY_DSN_WEB,
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
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.

⚠️ Potential issue | 🟠 Major

Consider defensive check: verify DSN presence before enabling.

The enabled flag should verify both the environment and DSN presence to prevent enabling Sentry without a valid DSN.

🔎 Suggested defensive fix
-	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
+	enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_WEB,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production",
enabled: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" && !!env.NEXT_PUBLIC_SENTRY_DSN_WEB,
🤖 Prompt for AI Agents
In apps/web/sentry.server.config.ts around line 8, the enabled flag currently
only checks the environment; update it to also verify the Sentry DSN exists and
is non-empty before enabling. Change the logic so enabled is true only when
env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "production" AND a truthy
env.NEXT_PUBLIC_SENTRY_DSN (e.g., check for non-empty string or trim() length),
ensuring you read the correct env var name and treat missing/empty DSN as
disabled.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 26, 2025

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

Service Status
Neon Database (Neon)

Thank you for your contribution! 🎉


Preview resources have been processed for cleanup

@saddlepaddle saddlepaddle merged commit a4022cf into main Dec 26, 2025
12 checks passed
@Kitenite Kitenite deleted the famous-boar-8fbd7e branch December 28, 2025 20:10
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.

1 participant