Skip to content

feat(billing): gate billing page behind feature flag#915

Merged
saddlepaddle merged 2 commits intomainfrom
stripe-clean
Jan 23, 2026
Merged

feat(billing): gate billing page behind feature flag#915
saddlepaddle merged 2 commits intomainfrom
stripe-clean

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Jan 23, 2026

Hide billing page from users without @superset.sh email until Stripe account is fully configured.

Uses PostHog feature flag billing-enabled (defined in FEATURE_FLAGS.BILLING_ENABLED) which is set to only allow users with @superset.sh emails.

Changes:

  • Add BILLING_ENABLED to shared constants
  • Hide billing from sidebar when flag is disabled
  • Redirect to account settings if user navigates directly to billing routes

Summary by CodeRabbit

  • New Features

    • Billing is now governed by a feature flag: when disabled, billing pages redirect to account settings and the billing option is hidden in Settings.
  • Chores

    • Marketing app received non-functional formatting updates and a dependency added; no visible behavior changes.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

Added a BILLING_ENABLED feature flag and used it to gate billing UI: routes now await the flag, redirect to /settings/account when disabled, and the settings sidebar filters out billing when the flag is off.

Changes

Cohort / File(s) Summary
Feature flag definition
packages/shared/src/constants.ts
Added BILLING_ENABLED to exported FEATURE_FLAGS.
Billing pages (route guards)
apps/desktop/src/renderer/routes/_authenticated/settings/billing/page.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/billing/plans/page.tsx
Both pages use useFeatureFlagEnabled(FEATURE_FLAGS.BILLING_ENABLED). Return null while undefined, Navigate to /settings/account when false, otherwise render existing components.
Settings sidebar filtering
apps/desktop/src/renderer/routes/_authenticated/settings/components/SettingsSidebar/GeneralSettings.tsx
Adds feature-flag check and excludes the "billing" section from filtered results when BILLING_ENABLED is false; existing matchCounts filtering preserved.
Marketing formatting & minor exports
apps/marketing/src/.../AppMockup.tsx, apps/marketing/src/.../AppMockup/index.ts, apps/marketing/src/.../ProductDemo.tsx, apps/marketing/src/components/ui/*
Mostly formatting, export order tweak, and minor whitespace/type adjustments. No behavioral changes.
Marketing dependency
apps/marketing/package.json
Added simplex-noise@^4.0.3 to dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hopped through code with a twitch and a grin,
A new little flag to tuck billing in.
If turned off, routes skip and the sidebar hides,
If turned on, all the billing delights abide. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: adding feature flag gating to the billing page functionality.
Description check ✅ Passed The PR description covers the main objectives, context, and specific changes made, though it does not follow the provided template structure with all sections filled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 23, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ✅ Electric Fly.io app

Thank you for your contribution! 🎉

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: 2

🤖 Fix all issues with AI agents
In `@apps/desktop/src/renderer/routes/_authenticated/settings/billing/page.tsx`:
- Around line 24-26: The redirect runs too early because useFeatureFlagEnabled
returns undefined while loading; change the guard so you only redirect when the
flag is explicitly false and not while it's undefined — e.g., in the component
that calls useFeatureFlagEnabled(billingFlag) check for billingEnabled ===
undefined and return a loading/null placeholder, and only do the Navigate
redirect when billingEnabled === false; reference the hook useFeatureFlagEnabled
and the billingEnabled variable and the existing Navigate usage when making the
change.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/billing/plans/page.tsx`:
- Around line 15-17: The current redirect uses the truthiness of billingEnabled
(from useFeatureFlagEnabled) and fires while the flag is still loading
(undefined); change the check to only redirect when the flag has explicitly
resolved to false and handle the loading case separately: update the conditional
around billingEnabled in the component (the variable from useFeatureFlagEnabled)
to something like if (billingEnabled === undefined) return null or a loader, and
only return <Navigate to="/settings/account" /> when billingEnabled === false so
you don't redirect prematurely.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/settings/components/SettingsSidebar/GeneralSettings.tsx (1)

100-107: Consider handling the loading state for consistency.

Similar to the billing route pages, useFeatureFlagEnabled returns undefined while loading. This causes the billing section to briefly disappear from the sidebar before the flag resolves—even for users who have access.

The impact here is less severe than the route redirects (just a visual flicker), but for a consistent user experience, consider handling the undefined state:

Proposed fix
 	// When searching, only show sections that have matches
 	// Also hide billing section if feature flag is disabled
 	const filteredSections = (
 		matchCounts
 			? GENERAL_SECTIONS.filter(
 					(section) => (matchCounts[section.section] ?? 0) > 0,
 				)
 			: GENERAL_SECTIONS
-	).filter((section) => section.section !== "billing" || billingEnabled);
+	).filter((section) => section.section !== "billing" || billingEnabled !== false);

This treats undefined (loading) the same as true, showing billing until we know definitively that it should be hidden.

Comment thread apps/desktop/src/renderer/routes/_authenticated/settings/billing/page.tsx Outdated
Comment thread apps/desktop/src/renderer/routes/_authenticated/settings/billing/plans/page.tsx Outdated
Hide billing settings from users who don't have the billing-enabled
feature flag. Uses centralized FEATURE_FLAGS constant from shared.
Fix lint issues from PR #910:
- Add biome-ignore for useEffect in wave animation
- Format code to pass biome checks
@saddlepaddle saddlepaddle merged commit 938f0e1 into main Jan 23, 2026
13 checks passed
@Kitenite Kitenite deleted the stripe-clean branch January 25, 2026 07:41
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