Platform Overview
DarkFeature provides a comprehensive platform for feature flag management, user targeting, and analytics. This guide covers the core concepts and features available in the DarkFeature platform.
Core Components
Feature Flags
Feature flags are the foundation of the DarkFeature platform. They allow you to control feature availability and behavior without code deployments.
Key Features:
- Boolean flags for simple on/off control
- String flags for configuration values
- Number flags for numeric settings
- JSON flags for complex objects
- Real-time updates across all environments
Environments
Organize your feature flags across different environments for safe development and deployment.
Default Environments:
- Development - For local development and testing
- Staging - For pre-production validation
- Production - For live user traffic
Custom Environments:
- Create additional environments as needed
- Configure environment-specific settings
- Manage different API keys per environment
User Targeting
Target specific users or user segments based on attributes, behavior, or custom rules.
Targeting Options:
- User attributes (email, plan, location, etc.)
- Percentage rollouts
- Time-based targeting
- Geographic targeting
- Custom targeting rules
Analytics
Track feature usage, performance, and user behavior to make data-driven decisions.
Analytics Features:
- Real-time metrics
- User engagement tracking
- Performance monitoring
- Custom event tracking
- Export capabilities
Platform Architecture
┌─────────────────────────────────────┐
│ Your Application │
│ │
│ ┌─────────────┐ ┌─────────────────┐│
│ │ Frontend │ │ Backend ││
│ │ │ │ ││
│ │ ┌─────────┐ │ │ ┌─────────────┐ ││
│ │ │ DarkFeature │ │ │ DarkFeature │ ││
│ │ │ Code Example │ │ │ Code Example │ ││
│ │ └─────────┘ │ │ └─────────────┘ ││
│ └─────────────┘ └─────────────────┘│
└─────────────────────────────────────┘
│
┌─────────────────┐
│ DarkFeature │
│ API │
└─────────────────┘
│
┌─────────────────┐
│ Dashboard │
│ │
│ ┌─────────────┐ │
│ │ Feature │ │
│ │ Management │ │
│ └─────────────┘ │
│ ┌─────────────┐ │
│ │ Analytics │ │
│ │ Engine │ │
│ └─────────────┘ │
└─────────────────┘
Getting Started
1. Create Your First Project
- Sign up for DarkFeature
- Create a new project
- Configure your environments
- Set up your API keys
2. Create Feature Flags
- Navigate to the Features section
- Click “Create Feature”
- Configure your flag settings
- Set up targeting rules
3. Integrate Code Examples
Add DarkFeature to your application using one of our code examples:
- Client-Side Code Examples - Integrate with web applications
- Server-Side Code Examples - Backend integration
- Mobile Code Examples - Native mobile apps
4. Monitor and Iterate
- Track feature usage in the dashboard
- Analyze performance metrics
- Adjust targeting rules based on data
- Iterate on your features
Key Features
Feature Flag Management
- Create and Configure - Set up flags with targeting rules
- Environment Management - Different settings per environment
- Real-time Updates - Changes propagate instantly
- Version Control - Track changes and rollbacks
User Targeting
- Attribute-based Targeting - Target users by properties
- Percentage Rollouts - Gradually increase feature exposure
- Custom Rules - Complex conditional logic
- Segments - Predefined user groups
Analytics and Monitoring
- Real-time Metrics - Live feature usage data
- Performance Tracking - Monitor flag evaluation times
- User Engagement - Track how features affect behavior
- Custom Events - Track specific user actions
Security and Compliance
- API Key Management - Secure key rotation and management
- Access Control - Role-based permissions
- Audit Logs - Track all changes and decisions
- Compliance - GDPR and CCPA support
Best Practices
Feature Flag Lifecycle
- Development - Create and test flags locally
- Staging - Validate in pre-production
- Production - Roll out to live users
- Monitoring - Track usage and performance
- Cleanup - Remove unused flags
Naming Conventions
- Use descriptive, lowercase names
- Include feature and environment context
- Examples:
new-navigation
,beta-features
,dark-mode
Targeting Strategy
- Start with simple targeting rules
- Gradually add complexity as needed
- Test targeting rules thoroughly
- Monitor targeting effectiveness
Performance Optimization
- Use caching effectively
- Minimize API calls
- Monitor evaluation times
- Optimize for your use case
Integration Patterns
Web Applications
import { DarkFeatureClient } from '@darkfeature/sdk-javascript'
const client = new DarkFeatureClient({
apiKey: '1234567890abcdef1234567890abcdef',
context: { userId: '123' },
})
// Check feature flags
const isEnabled = await client.getFeature('new-feature', { fallback: false })
// Use in your application
if (isEnabled) {
showNewFeature()
} else {
showOldFeature()
}
React Applications
import { DarkFeatureProvider, useFeature } from '@darkfeature/sdk-react'
function App() {
return (
<DarkFeatureProvider
config={{
apiKey: '1234567890abcdef1234567890abcdef',
context: { userId: '123' },
}}>
<MyComponent />
</DarkFeatureProvider>
)
}
function MyComponent() {
const { feature: isEnabled } = useFeature('new-feature', { fallback: false })
return isEnabled ? <NewFeature /> : <OldFeature />
}
Server Applications
import { DarkFeatureClient } from '@darkfeature/sdk-javascript'
const client = new DarkFeatureClient({
apiKey: process.env.DARKFEATURE_API_KEY,
context: { userId: '123' },
})
// Evaluate flags with user context
const isEnabled = await client.getFeature('premium-feature', {
fallback: false,
context: { plan: 'premium' },
})
Express.js Middleware
import express from 'express'
import { DarkFeatureClient } from '@darkfeature/sdk-javascript'
const app = express()
const client = new DarkFeatureClient({
apiKey: process.env.DARKFEATURE_API_KEY,
})
// Middleware to add feature flags to requests
app.use(async (req, res, next) => {
const context = {
userId: req.user?.id,
email: req.user?.email,
userAgent: req.get('User-Agent'),
}
req.features = await client.getFeatures({
features: {
'new-navigation': false,
'premium-features': false,
},
context,
})
next()
})
app.get('/api/data', async (req, res) => {
if (req.features['new-navigation']) {
res.json({ data: 'enhanced-data', version: 'v2' })
} else {
res.json({ data: 'basic-data', version: 'v1' })
}
})
Advanced Usage
Multiple Features
// Get multiple features efficiently
const features = await client.getFeatures({
features: {
'new-navigation': false,
'dark-mode': false,
'premium-features': false,
},
context: { userId: '123' },
})
if (features['new-navigation']) {
applyNewNavigation()
}
if (features['dark-mode']) {
applyDarkTheme()
}
Context Management
// Set context for the current user
client.setContext({
userId: user.id,
email: user.email,
plan: user.plan,
country: user.country,
userAgent: navigator.userAgent,
})
// All subsequent feature evaluations will use this context
const isEnabled = await client.getFeature('premium-features', {
fallback: false,
})
Error Handling
try {
const isEnabled = await client.getFeature('new-feature', { fallback: false })
// Use feature
} catch (error) {
console.error('Feature flag error:', error)
// Fallback to default behavior
showDefaultFeature()
}
Next Steps
- Feature Flags - Learn about flag types and configuration
- Targeting - Advanced user targeting techniques
- Analytics - Track and analyze feature usage
- Environments - Manage multiple environments
- Best Practices - Follow proven patterns
Support
- Documentation - Comprehensive guides and examples
- Community - Connect with other users
- Support - Get help from our team
- API Reference - Detailed API documentation