Back to all reviewers

Simplify feature flag logic

getsentry/sentry
Based on 3 comments
TSX

When working with feature flags and configuration conditions, keep your logic clean and up-to-date: 1. **Simplify conditionals when flag states change**: When a feature flag becomes permanently enabled or disabled, update and simplify all conditionals that reference it.

Configurations TSX

Reviewer Prompt

When working with feature flags and configuration conditions, keep your logic clean and up-to-date:

  1. Simplify conditionals when flag states change: When a feature flag becomes permanently enabled or disabled, update and simplify all conditionals that reference it.

  2. Access feature flags directly: Prefer checking feature flags directly rather than through abstraction layers that may become deprecated.

  3. Track feature state changes accurately: When determining if a feature was newly activated, compare current state with previous state rather than relying only on current selections.

Example refactoring when a feature flag is now always true:

// Before: Complex condition with useEap feature flag
enabled: Boolean(webVital) && (useEap || isInp || (isSpansWebVital && useSpansWebVitals))

// After: Simplified condition since useEap is always true
enabled: Boolean(webVital) && (isInp || (isSpansWebVital && useSpansWebVitals))

Example for checking feature flags directly:

// Avoid using abstraction components for feature checking
<Feature features="organizations:user-feedback-ai-summaries">
  {/* Component content */}
</Feature>

// Prefer direct access to feature flags
{organization.features.includes('organizations:user-feedback-ai-summaries') && (
  /* Component content */
)}
3
Comments Analyzed
TSX
Primary Language
Configurations
Category

Source Discussions