Commit eb4bee4a authored by Dmitry Gruzd's avatar Dmitry Gruzd Committed by Mark Chao

Restore feature flag for track_advanced_search

parent 8691c13a
......@@ -5,7 +5,7 @@ module EE
extend ActiveSupport::Concern
prepended do
before_action :track_advanced_search, only: :show, if: -> { request.format.html? && request.headers['DNT'] != '1' }
before_action :track_advanced_search, only: :show, if: -> { ::Feature.enabled?(:search_track_unique_users) && request.format.html? && request.headers['DNT'] != '1' }
end
private
......@@ -15,7 +15,8 @@ module EE
track_unique_redis_hll_event("i_search_advanced", :search_track_unique_users) if search_service.use_elasticsearch?
# track unique users who search against paid groups/projects
track_unique_redis_hll_event("i_search_paid", :search_track_unique_users) if (search_service.project || search_service.group)&.feature_available?(:elastic_search)
# this line is commented out because of https://gitlab.com/gitlab-org/gitlab/-/issues/243486
# track_unique_redis_hll_event("i_search_paid", :search_track_unique_users) if (search_service.project || search_service.group)&.feature_available?(:elastic_search)
end
end
end
......@@ -17,24 +17,38 @@ RSpec.describe SearchController do
end
context 'i_search_advanced' do
it_behaves_like 'tracking unique hll events', :show do
let(:request_params) { { scope: 'projects', search: 'term' } }
let(:target_id) { 'i_search_advanced' }
end
end
let(:target_id) { 'i_search_advanced' }
let(:request_params) { { scope: 'projects', search: 'term' } }
context 'i_search_paid' do
let(:group) { create(:group) }
it_behaves_like 'tracking unique hll events', :show
before do
allow(group).to receive(:feature_available?).with(:elastic_search).and_return(true)
end
it 'does not track if feature flag is disabled' do
stub_feature_flags(search_track_unique_users: false)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with(instance_of(String), target_id)
it_behaves_like 'tracking unique hll events', :show do
let(:request_params) { { group_id: group.id, scope: 'blobs', search: 'term' } }
let(:target_id) { 'i_search_paid' }
get :show, params: request_params, format: :html
end
end
# i_search_paid is commented out because of https://gitlab.com/gitlab-org/gitlab/-/issues/243486
# context 'i_search_paid' do
# let(:group) { create(:group) }
# let(:request_params) { { group_id: group.id, scope: 'blobs', search: 'term' } }
# let(:target_id) { 'i_search_paid' }
# before do
# allow(group).to receive(:feature_available?).with(:elastic_search).and_return(true)
# end
# it_behaves_like 'tracking unique hll events', :show
# it 'does not track if feature flag is disabled' do
# stub_feature_flags(search_track_unique_users: false)
# expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with(instance_of(String), target_id)
# get :show, params: request_params, format: :html
# end
# end
end
end
end
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