Feature flags with FunWithFlags

Integrates FunWithFlags for dynamic feature management in your Phoenix application. Enables runtime feature toggling without deployments, supporting gradual rollouts and emergency feature disabling through a web-based admin interface.

Key Benefits

  • Toggle features on/off without code deployments or application restarts
  • Use app-owned wrapper APIs instead of spreading provider calls throughout the application
  • Evaluate flags for the current user and, when teams are installed, the active team
  • Persistent storage and PubSub cache notifications for multi-node deployments

Implementation Details Sets up FunWithFlags with Ecto persistence and Phoenix PubSub, adds MyApp.Feature as the domain-level API, and adds MyAppWeb.FeatureFlags for maps of assigns, conns, and LiveView sockets. Actor protocol modules are generated when authentication or teams are installed.

Usage Example

if MyAppWeb.FeatureFlags.enabled?(:new_dashboard, socket) do
show_new_dashboard()
end
if MyApp.Feature.enabled?(:beta_feature, current_scope) do
show_beta_feature()
end

Configuration Persistence uses your existing Repo and PubSub configuration. Database migration creates the fun_with_flags_toggles table with the configured primary key type.