Repository navigation
Per-actor feature flags (#24)
Turn a flag on for particular users or groups without enabling it for everyone.
client.enable_actor("new_ui", "user:42") # or any object with a feature_gate_id attribute
client.disable_actor("new_ui", "org:7")
client.actors("new_ui") # ids in the order they were added
client.is_enabled("new_ui", user, user.org) # globally on, or on for any actor passed- Actors are namespaced strings (
"user:42","org:7") or objects with afeature_gate_idattribute. Bare integers are rejected so user 42 and org 42 can't collide.is_enabledskipsNoneactors. is_enabled(key, *actors)is true when the flag is on globally or for any actor passed. Pass a user together with their groups.disable()only turns off the global switch; actors keep the flag untildisable_actor().- PostgresAdapter: new
<prefix>feature_actorstable (migration0002_create_feature_actors). - PosthogAdapter: actors are stored as a
distinct_idrelease condition on the flag and evaluated by feature_gate. Other conditions you set up in PostHog are left alone, andenable_actorraisesValueErrorrather than activating an inactive flag that has them. Behavior without actors is unchanged. - See the Actors section of the README.
Upgrading
- PostgresAdapter users: run
feature-gate-migrateafter upgrading.is_enabled(key)without actors keeps working until you do, but the actor methods need the new table. - On PostHog,
disable()on a flag with actors keeps the flag active for those actors, so any other conditions on it keep running.
Full Changelog: v0.1.1...v0.2.0