feature flags

This commit is contained in:
2026-01-03 12:07:20 +01:00
parent 9a7efa496f
commit 213580511c
5 changed files with 289 additions and 26 deletions

View File

@@ -58,7 +58,13 @@ Visit `http://localhost:3000` to see the landing page.
| Variable | Description | Example |
|----------|-------------|---------|
| `NEXT_PUBLIC_GRIDPILOT_MODE` | Application mode (server & client) | `pre-launch` or `alpha` |
| `NEXT_PUBLIC_GRIDPILOT_MODE` | Application mode (pre-launch or full platform) | `pre-launch` or `alpha` |
### Optional Variables
| Variable | Description | Example |
|----------|-------------|---------|
| `FEATURE_FLAGS` | Feature override (comma-separated) | `driver_profiles,wallets` |
| `KV_REST_API_URL` | Vercel KV REST API endpoint | From Vercel Dashboard |
| `KV_REST_API_TOKEN` | Vercel KV authentication token | From Vercel Dashboard |
| `NEXT_PUBLIC_SITE_URL` | Public site URL | `https://gridpilot.com` |
@@ -71,31 +77,95 @@ Visit `http://localhost:3000` to see the landing page.
4. Copy the `KV_REST_API_URL` and `KV_REST_API_TOKEN` from the database settings
5. Add them to your environment variables
## Mode Switching
The application supports two modes:
## Application Modes
### Pre-Launch Mode (Default)
- Shows landing page with email capture
- Only `/` and `/api/signup` routes are accessible
- All other routes return 404
To activate:
```bash
NEXT_PUBLIC_GRIDPILOT_MODE=pre-launch
```
- Landing page only
- Email signup functionality
- No navigation or footer
- All platform features disabled
### Post-Launch Mode
- Full platform access
- All routes are accessible
- Landing page is still available at `/`
To activate:
### Alpha Mode (Full Platform)
```bash
NEXT_PUBLIC_GRIDPILOT_MODE=alpha
```
- Full platform access
- **All features automatically enabled**
- Navigation and footer visible
- Discovery section on landing page
### Available Feature Flags
When in alpha mode, these features are automatically enabled:
- `driver_profiles` - Driver profile pages and features
- `team_profiles` - Team profile pages and features
- `wallets` - All wallet functionality (driver/team/league/sponsor)
- `sponsors` - Sponsor management features
- `team_feature` - Complete team functionality
- `alpha_features` - Landing page discovery section
### Custom Feature Selection (Optional)
If you need fine-grained control, use `FEATURE_FLAGS`:
```bash
NEXT_PUBLIC_GRIDPILOT_MODE=alpha
FEATURE_FLAGS=driver_profiles,wallets
```
## Configuration Examples
### Basic Alpha Setup (Recommended)
```bash
# .env.local
NEXT_PUBLIC_GRIDPILOT_MODE=alpha
# All features enabled automatically - no FEATURE_FLAGS needed
```
### Pre-Launch Setup
```bash
# .env.local
NEXT_PUBLIC_GRIDPILOT_MODE=pre-launch
# Landing page only
```
### Custom Feature Selection
```bash
# .env.local
NEXT_PUBLIC_GRIDPILOT_MODE=alpha
FEATURE_FLAGS=driver_profiles,wallets
# Only driver profiles and wallets enabled
```
## How It Works
1. **Mode Detection**: `NEXT_PUBLIC_GRIDPILOT_MODE` sets overall platform access
2. **Feature Bundling**: Alpha mode automatically enables all features via `FeatureFlagService`
3. **Override**: `FEATURE_FLAGS` can selectively enable/disable features
4. **Component Usage**: Components check feature flags using `FeatureFlagService.fromEnv().isEnabled('feature_name')`
## Migration Guide
### From Manual Feature Flags
**Before**:
```bash
NEXT_PUBLIC_GRIDPILOT_MODE=alpha
FEATURE_FLAGS=alpha_features,driver_profiles,team_profiles,wallets,sponsors,team_feature
```
**After**:
```bash
NEXT_PUBLIC_GRIDPILOT_MODE=alpha
# FEATURE_FLAGS not needed - everything automatic!
```
### No Code Changes Required
Your existing code continues to work:
```typescript
const featureService = FeatureFlagService.fromEnv();
const isAlpha = featureService.isEnabled('alpha_features');
// Works in both old and new system
```
## Email Signup API