Commit 8a56038a authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '34776-enable-group-ca-by-default' into 'master'

Enable Cycle Analytics Feature by default

Closes #34776

See merge request gitlab-org/gitlab!19484
parents 82f20dcb 0645f078
---
title: Enable Cycle Analytics Feature by default
merge_request: 19484
author:
type: changed
......@@ -3,9 +3,9 @@
namespace :analytics do
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
namespace :cycle_analytics do
resources :stages, only: [:index, :create, :update, :destroy] do
......
......@@ -16,7 +16,8 @@ module Gitlab
].freeze
FEATURE_FLAG_DEFAULTS = {
PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true
PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true,
CYCLE_ANALYTICS_FEATURE_FLAG => true
}.freeze
def self.any_features_enabled?
......@@ -28,15 +29,19 @@ module Gitlab
end
def self.cycle_analytics_enabled?
Feature.enabled?(CYCLE_ANALYTICS_FEATURE_FLAG)
feature_enabled?(CYCLE_ANALYTICS_FEATURE_FLAG)
end
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
def self.feature_enabled_by_default?(flag)
!!FEATURE_FLAG_DEFAULTS[flag]
end
def self.feature_enabled?(feature)
Feature.enabled?(feature, default_enabled: feature_enabled_by_default?(feature))
end
end
end
......@@ -25,6 +25,14 @@ describe 'Analytics' do
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
before do
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