Commit 7c44439f authored by Marc Shaw's avatar Marc Shaw Committed by Peter Leitzen

Remove the track_action feature flag

Issue: gitlab.com/gitlab-org/gitlab/-/issues/230481
MR: gitlab.com/gitlab-org/gitlab/-/merge_requests/39535
parent 86abb0af
...@@ -604,8 +604,6 @@ module Gitlab ...@@ -604,8 +604,6 @@ module Gitlab
end end
def action_monthly_active_users(time_period) def action_monthly_active_users(time_period)
return {} unless Feature.enabled?(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG)
counter = Gitlab::UsageDataCounters::TrackUniqueActions counter = Gitlab::UsageDataCounters::TrackUniqueActions
project_count = redis_usage_data do project_count = redis_usage_data do
......
...@@ -4,7 +4,6 @@ module Gitlab ...@@ -4,7 +4,6 @@ module Gitlab
module UsageDataCounters module UsageDataCounters
module TrackUniqueActions module TrackUniqueActions
KEY_EXPIRY_LENGTH = 29.days KEY_EXPIRY_LENGTH = 29.days
FEATURE_FLAG = :track_unique_actions
WIKI_ACTION = :wiki_action WIKI_ACTION = :wiki_action
DESIGN_ACTION = :design_action DESIGN_ACTION = :design_action
...@@ -29,7 +28,6 @@ module Gitlab ...@@ -29,7 +28,6 @@ module Gitlab
class << self class << self
def track_event(event_action:, event_target:, author_id:, time: Time.zone.now) def track_event(event_action:, event_target:, author_id:, time: Time.zone.now)
return unless Gitlab::CurrentSettings.usage_ping_enabled return unless Gitlab::CurrentSettings.usage_ping_enabled
return unless Feature.enabled?(FEATURE_FLAG)
return unless valid_target?(event_target) return unless valid_target?(event_target)
return unless valid_action?(event_action) return unless valid_action?(event_action)
......
...@@ -17,10 +17,9 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi ...@@ -17,10 +17,9 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi
context 'tracking an event' do context 'tracking an event' do
context 'when tracking successfully' do context 'when tracking successfully' do
context 'when the feature flag and the application setting is enabled' do context 'when the application setting is enabled' do
context 'when the target and the action is valid' do context 'when the target and the action is valid' do
before do before do
stub_feature_flags(described_class::FEATURE_FLAG => true)
stub_application_setting(usage_ping_enabled: true) stub_application_setting(usage_ping_enabled: true)
end end
...@@ -59,17 +58,15 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi ...@@ -59,17 +58,15 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi
context 'when tracking unsuccessfully' do context 'when tracking unsuccessfully' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:feature_flag, :application_setting, :target, :action) do where(:application_setting, :target, :action) do
true | true | Project | :invalid_action true | Project | :invalid_action
false | true | Project | :pushed false | Project | :pushed
true | false | Project | :pushed true | :invalid_target | :pushed
true | true | :invalid_target | :pushed
end end
with_them do with_them do
before do before do
stub_application_setting(usage_ping_enabled: application_setting) stub_application_setting(usage_ping_enabled: application_setting)
stub_feature_flags(described_class::FEATURE_FLAG => feature_flag)
end end
it 'returns the expected values' do it 'returns the expected values' do
......
...@@ -912,45 +912,29 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -912,45 +912,29 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let(:time) { Time.zone.now } let(:time) { Time.zone.now }
before do before do
stub_feature_flags(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG => feature_flag) counter = Gitlab::UsageDataCounters::TrackUniqueActions
end project = Event::TARGET_TYPES[:project]
wiki = Event::TARGET_TYPES[:wiki]
context 'when the feature flag is enabled' do design = Event::TARGET_TYPES[:design]
let(:feature_flag) { true }
counter.track_event(event_action: :pushed, event_target: project, author_id: 1)
before do counter.track_event(event_action: :pushed, event_target: project, author_id: 1)
counter = Gitlab::UsageDataCounters::TrackUniqueActions counter.track_event(event_action: :pushed, event_target: project, author_id: 2)
project = Event::TARGET_TYPES[:project] counter.track_event(event_action: :pushed, event_target: project, author_id: 3)
wiki = Event::TARGET_TYPES[:wiki] counter.track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)
design = Event::TARGET_TYPES[:design] counter.track_event(event_action: :created, event_target: project, author_id: 5, time: time - 3.days)
counter.track_event(event_action: :created, event_target: wiki, author_id: 3)
counter.track_event(event_action: :pushed, event_target: project, author_id: 1) counter.track_event(event_action: :created, event_target: design, author_id: 3)
counter.track_event(event_action: :pushed, event_target: project, author_id: 1) end
counter.track_event(event_action: :pushed, event_target: project, author_id: 2)
counter.track_event(event_action: :pushed, event_target: project, author_id: 3) it 'returns the distinct count of user actions within the specified time period' do
counter.track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days) expect(described_class.action_monthly_active_users(time_period)).to eq(
counter.track_event(event_action: :created, event_target: project, author_id: 5, time: time - 3.days) {
counter.track_event(event_action: :created, event_target: wiki, author_id: 3) action_monthly_active_users_design_management: 1,
counter.track_event(event_action: :created, event_target: design, author_id: 3) action_monthly_active_users_project_repo: 3,
end action_monthly_active_users_wiki_repo: 1
}
it 'returns the distinct count of user actions within the specified time period' do )
expect(described_class.action_monthly_active_users(time_period)).to eq(
{
action_monthly_active_users_design_management: 1,
action_monthly_active_users_project_repo: 3,
action_monthly_active_users_wiki_repo: 1
}
)
end
end
context 'when the feature flag is disabled' do
let(:feature_flag) { false }
it 'returns an empty hash' do
expect(described_class.action_monthly_active_users(time_period)).to eq({})
end
end end
end end
......
...@@ -202,7 +202,6 @@ RSpec.describe EventCreateService do ...@@ -202,7 +202,6 @@ RSpec.describe EventCreateService do
end end
it 'records the event in the event counter' do it 'records the event in the event counter' do
stub_feature_flags(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG => true)
counter_class = Gitlab::UsageDataCounters::TrackUniqueActions counter_class = Gitlab::UsageDataCounters::TrackUniqueActions
tracking_params = { event_action: counter_class::WIKI_ACTION, date_from: Date.yesterday, date_to: Date.today } tracking_params = { event_action: counter_class::WIKI_ACTION, date_from: Date.yesterday, date_to: Date.today }
...@@ -244,7 +243,6 @@ RSpec.describe EventCreateService do ...@@ -244,7 +243,6 @@ RSpec.describe EventCreateService do
it_behaves_like 'service for creating a push event', PushEventPayloadService it_behaves_like 'service for creating a push event', PushEventPayloadService
it 'records the event in the event counter' do it 'records the event in the event counter' do
stub_feature_flags(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG => true)
counter_class = Gitlab::UsageDataCounters::TrackUniqueActions counter_class = Gitlab::UsageDataCounters::TrackUniqueActions
tracking_params = { event_action: counter_class::PUSH_ACTION, date_from: Date.yesterday, date_to: Date.today } tracking_params = { event_action: counter_class::PUSH_ACTION, date_from: Date.yesterday, date_to: Date.today }
...@@ -268,7 +266,6 @@ RSpec.describe EventCreateService do ...@@ -268,7 +266,6 @@ RSpec.describe EventCreateService do
it_behaves_like 'service for creating a push event', BulkPushEventPayloadService it_behaves_like 'service for creating a push event', BulkPushEventPayloadService
it 'records the event in the event counter' do it 'records the event in the event counter' do
stub_feature_flags(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG => true)
counter_class = Gitlab::UsageDataCounters::TrackUniqueActions counter_class = Gitlab::UsageDataCounters::TrackUniqueActions
tracking_params = { event_action: counter_class::PUSH_ACTION, date_from: Date.yesterday, date_to: Date.today } tracking_params = { event_action: counter_class::PUSH_ACTION, date_from: Date.yesterday, date_to: Date.today }
...@@ -323,7 +320,6 @@ RSpec.describe EventCreateService do ...@@ -323,7 +320,6 @@ RSpec.describe EventCreateService do
end end
it 'records the event in the event counter' do it 'records the event in the event counter' do
stub_feature_flags(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG => true)
counter_class = Gitlab::UsageDataCounters::TrackUniqueActions counter_class = Gitlab::UsageDataCounters::TrackUniqueActions
tracking_params = { event_action: counter_class::DESIGN_ACTION, date_from: Date.yesterday, date_to: Date.today } tracking_params = { event_action: counter_class::DESIGN_ACTION, date_from: Date.yesterday, date_to: Date.today }
...@@ -351,7 +347,6 @@ RSpec.describe EventCreateService do ...@@ -351,7 +347,6 @@ RSpec.describe EventCreateService do
end end
it 'records the event in the event counter' do it 'records the event in the event counter' do
stub_feature_flags(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG => true)
counter_class = Gitlab::UsageDataCounters::TrackUniqueActions counter_class = Gitlab::UsageDataCounters::TrackUniqueActions
tracking_params = { event_action: counter_class::DESIGN_ACTION, date_from: Date.yesterday, date_to: Date.today } tracking_params = { event_action: counter_class::DESIGN_ACTION, date_from: Date.yesterday, date_to: Date.today }
......
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