Analytics dashboards - Add optional `feature_flag` setting to visualization config
This issue was created to solve the problem presented in this thread
Problem
When developing new analytics dashboard visualizations, we don't have a good way to toggle visibility based on a feature flag.
Proposed solution
Add a new feature_flag
option to the visualization schema that allows showing/hiding the visualization based on a given feature flag.
---
version: 1
type: NewDashboardPanel
+feature_flag: new_dashboard_panel
data:
type: value_stream
query: {}
options: {}
In the backend we can do a check:
diff --git a/ee/app/models/product_analytics/visualization.rb b/ee/app/models/product_analytics/visualization.rb
index 763d70d85a33..f7b5499d9d60 100644
--- a/ee/app/models/product_analytics/visualization.rb
+++ b/ee/app/models/product_analytics/visualization.rb
@@ -132,6 +132,7 @@ def self.visualization_config_path(data)
def self.load_visualizations(visualization_names, directory)
visualization_names.map do |name|
config = File.read(Rails.root.join(directory, "#{name}.yaml"))
+ begin
+ next if config['feature_flag'] && Feature.disabled?(sanitise_somehow(config['feature_flag']), current_group)
+ rescue => Feature::InvalidFeatureFlagError
+ # handle and show error
new(config: config, slug: name)
end
- If the feature flag can't be found (e.g. no longer exists, typo, etc), an alert should be shown (see #448542 (comment 1858338677))
Edited by charlie ablett