Add audit events for feature flag updates when actor is present
What does this MR do and why?
Creates audit events for feature flag changes initiated from Rails console or Ruby scripts.
How to set up and validate locally
- In Rails console, enable or disable any feature using
Feature.enable(feature, actor)
orFeature.enable(feature, actor)
.actor
is any User, Group or Project. - Check audit events in local instance for Rails Console record.
- Verify that calling enable/disable without passing an actor does not generate an audit event.
Database changes
Feature::FlipperGate find
explain SELECT "feature_gates".* FROM "feature_gates" WHERE "feature_gates"."feature_key" = 'test_feature' AND "feature_gates"."key" = 'actors' AND "feature_gates"."value" = 'User:42' LIMIT 1
Limit (cost=0.28..3.30 rows=1 width=65) (actual time=1.195..1.196 rows=0 loops=1)
Buffers: shared read=2
I/O Timings: read=1.170 write=0.000
-> Index Scan using index_feature_gates_on_feature_key_and_key_and_value on public.feature_gates (cost=0.28..3.30 rows=1 width=65) (actual time=1.193..1.193 rows=0 loops=1)
Index Cond: (((feature_gates.feature_key)::text = 'test_feature'::text) AND ((feature_gates.key)::text = 'actors'::text) AND ((feature_gates.value)::text = 'User:42'::text))
Buffers: shared read=2
I/O Timings: read=1.170 write=0.000
TODO
-
Add specs -
Update docs -
Fix broken test(s) -
Add query plan
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #378075
Edited by Aaron Huntsman