Commit 0645f078 authored by Adam Hegyi's avatar Adam Hegyi

Enable Cycle Analytics FF by default

This commit enables Cycle Analytics feature flag by default, so it will
show up on the /-/analytics workspace.
parent 91e1e5cb
---
title: Enable Cycle Analytics Feature by default
merge_request: 19484
author:
type: changed
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
namespace :analytics do namespace :analytics do
root to: 'analytics#index' root to: 'analytics#index'
resource :productivity_analytics, only: :show, constraints: lambda { |req| Gitlab::Analytics.productivity_analytics_enabled? } resource :productivity_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.productivity_analytics_enabled? }
constraints(::Constraints::FeatureConstrainer.new(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG)) do constraints(-> (req) { Gitlab::Analytics.cycle_analytics_enabled? }) do
resource :cycle_analytics, only: :show resource :cycle_analytics, only: :show
namespace :cycle_analytics do namespace :cycle_analytics do
resources :stages, only: [:index, :create, :update, :destroy] do resources :stages, only: [:index, :create, :update, :destroy] do
......
...@@ -16,7 +16,8 @@ module Gitlab ...@@ -16,7 +16,8 @@ module Gitlab
].freeze ].freeze
FEATURE_FLAG_DEFAULTS = { FEATURE_FLAG_DEFAULTS = {
PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true,
CYCLE_ANALYTICS_FEATURE_FLAG => true
}.freeze }.freeze
def self.any_features_enabled? def self.any_features_enabled?
...@@ -28,15 +29,19 @@ module Gitlab ...@@ -28,15 +29,19 @@ module Gitlab
end end
def self.cycle_analytics_enabled? def self.cycle_analytics_enabled?
Feature.enabled?(CYCLE_ANALYTICS_FEATURE_FLAG) feature_enabled?(CYCLE_ANALYTICS_FEATURE_FLAG)
end end
def self.productivity_analytics_enabled? def self.productivity_analytics_enabled?
Feature.enabled?(PRODUCTIVITY_ANALYTICS_FEATURE_FLAG, default_enabled: feature_enabled_by_default?(PRODUCTIVITY_ANALYTICS_FEATURE_FLAG)) feature_enabled?(PRODUCTIVITY_ANALYTICS_FEATURE_FLAG)
end end
def self.feature_enabled_by_default?(flag) def self.feature_enabled_by_default?(flag)
!!FEATURE_FLAG_DEFAULTS[flag] !!FEATURE_FLAG_DEFAULTS[flag]
end end
def self.feature_enabled?(feature)
Feature.enabled?(feature, default_enabled: feature_enabled_by_default?(feature))
end
end end
end end
...@@ -25,6 +25,14 @@ describe 'Analytics' do ...@@ -25,6 +25,14 @@ describe 'Analytics' do
end end
end end
context 'cycle_analytics feature flag is enabled by default' do
it 'succeeds' do
expect(Gitlab::Analytics).to receive(:cycle_analytics_enabled?).and_call_original
expect(get('/-/analytics/cycle_analytics')).to route_to('analytics/cycle_analytics#show')
end
end
context 'productivity_analytics feature flag is disabled' do context 'productivity_analytics feature flag is disabled' do
before do before do
stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => false) stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment