Databuddy’s feature flags let you control feature visibility, run A/B tests, and gradually roll out changes without deploying new code. All flag evaluations happen client-side with privacy-first design.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/databuddy-analytics/Databuddy/llms.txt
Use this file to discover all available pages before exploring further.
What are Feature Flags?
Feature flags (also called feature toggles) let you enable or disable features for specific users or percentages of your audience. Use them to:- Gradual rollouts: Release to 5%, then 25%, then 100% of users
- A/B testing: Test variants and measure impact
- Kill switches: Disable features instantly if issues arise
- User targeting: Show features to specific user segments
- Development: Test features in production before full release
Flag Manager Architecture
Databuddy’s flag system is built for performance:- Stale-while-revalidate caching: Instant flag checks with background updates
- Request batching: Multiple flag checks = single API request
- Request deduplication: Eliminates redundant network calls
- Visibility API awareness: Pauses updates when tab is hidden
- Anonymous ID support: Deterministic rollouts without user accounts
Cache Behavior
- Cache TTL: Flags cached for 60 seconds (configurable)
- Stale Time: Revalidation after 30 seconds (configurable)
- Storage: Persisted to localStorage for instant hydration
- Background refresh: Updates happen without blocking UI
Flags are cached client-side for performance. Changes may take up to 60 seconds to propagate to users.
SDK Integration
React
Use the React SDK for flag management:Vue
Use the Vue plugin:Node.js
Use the Node SDK for server-side flags:Flag Evaluation
Anonymous IDs
For deterministic rollouts without user accounts:- Databuddy automatically generates a random anonymous ID
- Stored in localStorage as
did(same key as tracker) - Used for consistent flag evaluation across sessions
- Format:
anon_<uuid>
User Context
Target flags based on user attributes:Evaluation Priority
- User ID (if provided)
- Email (if provided)
- Anonymous ID (auto-generated)
Flag Configuration
Manager Options
Disabling Flags
Temporarily disable all flags:Flag State
TheisEnabled() method returns detailed state:
Boolean Flags
Multivariate Flags
Advanced Features
Request Batching
Multiple simultaneous flag checks are batched:Updating User Context
Change user context dynamically:Manual Refresh
Force flag refresh:Fetching All Flags
Get all flags at once:Visibility Awareness
The flag manager respects browser visibility:- Tab visible: Normal revalidation behavior
- Tab hidden: Pauses background updates to save battery/bandwidth
- Tab becomes visible: Revalidates stale flags
Best Practices
Naming Conventions
Use kebab-case for flag keys:- Good:
new-checkout-flow,dark-mode,premium-features - Bad:
NewCheckoutFlow,DARK_MODE,premium_features
Flag Lifecycle
- Development: Test flag in dev environment
- Gradual rollout: Start at 5-10% of users
- Monitor metrics: Watch for errors, performance issues
- Increase rollout: Gradually increase to 100%
- Clean up: Remove flag code once at 100% for >30 days
Error Handling
Handle loading and error states:Default Values
Always provide defaults for multivariate flags:Testing
Test both flag states:Privacy & Security
Client-Side Evaluation
Flags are evaluated in the browser/client:- No server-side state required
- Reduced latency
- Works offline (uses cached values)
No Personal Data
Flag evaluation uses:- Anonymous IDs (random UUIDs)
- Hashed user IDs (if provided)
- No personal information transmitted
GDPR Compliance
Anonymous IDs are:- Randomly generated
- Not linked to personal data
- Stored locally (not sent to servers)
- Not considered personal identifiers under GDPR
Cleanup
Clean up resources when done:Next Steps
Analytics
Track feature usage with analytics
Goals
Measure feature impact with goals
A/B Testing Guide
Run experiments with feature flags
SDK Reference
Full SDK documentation