-
Notifications
You must be signed in to change notification settings - Fork 0
Context Management
This guide covers the context management system in the Flux Gate, which enables sophisticated feature targeting based on user attributes, device characteristics, and custom criteria.
Contexts define the criteria used for feature targeting and rollout decisions. They allow you to control which users see specific features based on attributes like user ID, device type, geographic location, or custom business logic.
Context management is available to users with appropriate team access:
- Team Members: Can manage contexts within their assigned teams
- Team Admin: Full context management for their teams
- Admin: System-wide context management
Contexts are reusable targeting criteria that define:
- User Attributes: User ID, email domain, subscription tier
- Device Properties: Device type, operating system, browser
- Geographic Data: Country, region, timezone
- Custom Criteria: Business-specific targeting rules
Each context has:
| Property | Description |
|---|---|
| Key | Unique identifier for the context (e.g., "user_id", "device_type") |
| Description | Human-readable description of the context |
| Team Scope | Contexts belong to specific teams |
- Navigation: Go to Contexts page
- Context Table: View all contexts for your teams
- Actions: Create, edit, and delete contexts
The contexts table displays:
| Column | Description |
|---|---|
| Key | Context identifier/key |
| Description | Context description or purpose |
| Actions | Edit and delete options |
- Navigate: Go to Contexts page
- Create Button: Click "Create New Context"
- Form: Fill out context creation form
| Field | Required | Description |
|---|---|---|
| Key | β | Unique context identifier (e.g., "user_id", "device_type") |
| Description | β | Optional description of the context usage |
Key: user_id
Description: Target specific users by their unique identifier
Key: device_type
Description: Target users based on device type (mobile, desktop, tablet)
Key: subscription_tier
Description: Target users based on their subscription level
Key: geographic_region
Description: Target users based on geographic location
- Context Key: Enter unique identifier (use snake_case or kebab-case)
- Description: Add helpful description for team members
- Submit: Create the context
- Verification: Context appears in the contexts list
- Context Table: Find context to edit
- Edit Action: Click "Edit" button
- Edit Form: Modify context details
- Save Changes: Update context information
- Key: Update context identifier (use with caution)
- Description: Modify context description
Contexts are used in Contextual Features to define targeting criteria:
- Feature Creation: Select "CONTEXTUAL" feature type
- Stage Configuration: Configure stage criteria using contexts
- Context Selection: Choose relevant contexts for targeting
- Criteria Definition: Define context key and rollout percentage
For each pipeline stage, you can define:
| Field | Description | Example |
|---|---|---|
| Context | The context to use for targeting | "user_id" |
| Context Key | Specific value or pattern to match | "premium_users" |
| Rollout Percentage | Percentage of matching users to target | 25% |
Context: device_type
Context Key: mobile
Rollout Percentage: 50%
This targets 50% of mobile users
Context: subscription_tier
Context Key: premium
Rollout Percentage: 100%
This targets 100% of premium subscribers
Target users based on their attributes:
| Context Key | Description | Example Values |
|---|---|---|
user_id |
Specific user targeting |
user_12345, premium_users
|
email_domain |
Target by email domain |
@company.com, @gmail.com
|
user_role |
Target by user role |
admin, member, guest
|
subscription_tier |
Target by subscription |
free, premium, enterprise
|
Target based on device characteristics:
| Context Key | Description | Example Values |
|---|---|---|
device_type |
Device category |
mobile, desktop, tablet
|
operating_system |
OS targeting |
ios, android, windows
|
browser |
Browser targeting |
chrome, firefox, safari
|
app_version |
Application version |
1.0.0, >=2.0.0
|
Target based on location:
| Context Key | Description | Example Values |
|---|---|---|
country |
Country-based targeting |
US, UK, CA
|
region |
Regional targeting |
north_america, europe
|
timezone |
Timezone targeting |
PST, EST, UTC
|
language |
Language preference |
en, es, fr
|
Custom business logic targeting:
| Context Key | Description | Example Values |
|---|---|---|
customer_segment |
Customer categorization |
enterprise, smb, startup
|
feature_flag |
Nested feature flags |
beta_program, early_access
|
experiment_group |
A/B testing groups |
control, variant_a, variant_b
|
account_age |
Account tenure |
new_user, veteran
|
Use contexts for gradual feature rollout:
Stage 1: Internal Testing
Context: user_role
Key: internal_user
Rollout: 100%
Stage 2: Beta Users
Context: subscription_tier
Key: premium
Rollout: 25%
Stage 3: General Availability
Context: user_id
Key: all_users
Rollout: 100%
Create contexts for experimentation:
Context: experiment_group
Keys: control, variant_a, variant_b
Usage: Split traffic for feature testing
Deploy features by region:
Stage 1: North America
Context: region
Key: na
Rollout: 100%
Stage 2: Europe
Context: region
Key: eu
Rollout: 100%
Stage 3: Global
Context: region
Key: global
Rollout: 100%
Your application needs to provide context values:
// Example context evaluation
const contextValues = {
user_id: getCurrentUserId(),
device_type: getDeviceType(),
subscription_tier: getUserSubscriptionTier(),
geographic_region: getUserRegion()
};
// Feature evaluation with contexts
const isFeatureEnabled = evaluateFeature('new-ui-feature', contextValues);Contexts can be evaluated on the server:
// Server-side context evaluation
const evaluateFeatureForUser = (featureKey, userId) => {
const userContext = {
user_id: userId,
subscription_tier: getUserTier(userId),
device_type: getRequestDeviceType(),
country: getRequestCountry()
};
return featureToggleService.evaluate(featureKey, userContext);
};- Descriptive Keys: Use clear, descriptive context keys
- Consistent Naming: Follow consistent naming conventions
- Team Alignment: Align contexts with team needs
- Documentation: Document context usage and expected values
Use consistent patterns:
# User contexts (prefix: user_)
user_id
user_role
user_subscription
# Device contexts (prefix: device_)
device_type
device_os
device_browser
# Geographic contexts (prefix: geo_)
geo_country
geo_region
geo_timezone
# Business contexts (prefix: business_)
business_segment
business_tier
business_category
Design consistent value patterns:
# Boolean contexts
is_premium_user: true/false
has_beta_access: true/false
# Categorical contexts
device_type: mobile|desktop|tablet
subscription_tier: free|premium|enterprise
# Numeric contexts
account_age_days: 0-365+
usage_score: 0-100
- Planning: Define contexts based on targeting needs
- Creation: Create contexts with clear documentation
- Usage: Apply contexts in feature configurations
- Monitoring: Track context usage and effectiveness
- Cleanup: Remove unused contexts periodically
Regular maintenance tasks:
- Review Usage: Identify unused contexts
- Update Documentation: Keep context descriptions current
- Value Validation: Ensure context values remain valid
- Team Alignment: Verify contexts meet team needs
Cannot Create Context
Error: Context key already exists
Solution: Choose a unique context key within your team.
Context Not Available in Features
Context not showing in feature configuration
Solution: Ensure you're creating a "CONTEXTUAL" feature type and the context belongs to your team.
Context Values Not Matching
Feature not targeting correctly
Solution: Verify context values in your application match the configured context keys.
If contexts aren't working properly:
- Check Context Keys: Verify context keys match between UI and application
- Validate Values: Ensure context values are provided correctly
- Test Scenarios: Test with different context value combinations
- Debug Logging: Add logging to see context evaluation
- Start Simple: Begin with basic user and device contexts
- Iterate: Add contexts as targeting needs become clear
- Document Usage: Maintain clear documentation of context purposes
- Team Coordination: Coordinate context definitions across teams
- Client Integration: Plan how your application will provide context values
- Data Sources: Identify where context data comes from
- Performance: Consider performance impact of context evaluation
- Fallback Strategy: Plan fallback behavior when context data is unavailable
- Monitor Usage: Track which contexts are most/least used
- Deprecation Strategy: Plan how to retire unused contexts
- Version Management: Consider versioning for context schemas
- Migration Planning: Plan context key changes carefully
- Feature Toggle Management - Using contexts in features
- Feature Toggle Types - Contextual vs Simple features
- Pipeline Management - Context usage in pipelines
- Team Management - Team-scoped context access
Need help? Check the Troubleshooting guide or create an issue in the project repository.