Commit aff5fbaf authored by Niko Belokolodov's avatar Niko Belokolodov Committed by Mayra Cabrera

Move active_users_project_repo metric to Snowplow

parent 134eecdc
......@@ -184,6 +184,10 @@ class EventCreateService
track_event(event_action: :pushed, event_target: Project, author_id: current_user.id)
if Feature.enabled?(:route_hll_to_snowplow, project, default_enabled: :yaml)
Gitlab::Tracking.event(self.class.to_s, 'action_active_users_project_repo', namespace: project, user: current_user)
end
Users::LastPushEventService.new(current_user)
.cache_last_push_event(event)
......
......@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redis_shared_state do
include SnowplowHelpers
let(:service) { described_class.new }
let_it_be(:user, reload: true) { create :user }
......@@ -18,6 +20,27 @@ RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redi
end
end
shared_examples 'Snowplow event' do
it 'is not emitted if FF is disabled' do
stub_feature_flags(route_hll_to_snowplow: false)
subject
expect_no_snowplow_event
end
it 'is emitted' do
subject
expect_snowplow_event(
category: described_class.to_s,
action: 'action_active_users_project_repo',
namespace: project,
user: user
)
end
end
describe 'Issues' do
describe '#open_issue' do
let(:issue) { create(:issue) }
......@@ -247,7 +270,7 @@ RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redi
end
end
describe '#push' do
describe '#push', :snowplow do
let(:push_data) do
{
commits: [
......@@ -270,9 +293,11 @@ RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redi
it_behaves_like "it records the event in the event counter" do
let(:event_action) { Gitlab::UsageDataCounters::TrackUniqueEvents::PUSH_ACTION }
end
it_behaves_like 'Snowplow event'
end
describe '#bulk_push' do
describe '#bulk_push', :snowplow do
let(:push_data) do
{
action: :created,
......@@ -288,6 +313,8 @@ RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redi
it_behaves_like "it records the event in the event counter" do
let(:event_action) { Gitlab::UsageDataCounters::TrackUniqueEvents::PUSH_ACTION }
end
it_behaves_like 'Snowplow event'
end
describe 'Project' do
......
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