Commit 320bf64b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'id-track-git-write-operations' into 'master'

Include aggregated git-write usage counts

See merge request gitlab-org/gitlab!47511
parents 1136cbec 7d2dcdc9
---
title: Include aggregated git-write usage counts
merge_request: 47511
author:
type: added
...@@ -765,7 +765,8 @@ module Gitlab ...@@ -765,7 +765,8 @@ module Gitlab
data = { data = {
action_monthly_active_users_project_repo: Gitlab::UsageDataCounters::TrackUniqueEvents::PUSH_ACTION, action_monthly_active_users_project_repo: Gitlab::UsageDataCounters::TrackUniqueEvents::PUSH_ACTION,
action_monthly_active_users_design_management: Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION, action_monthly_active_users_design_management: Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION,
action_monthly_active_users_wiki_repo: Gitlab::UsageDataCounters::TrackUniqueEvents::WIKI_ACTION action_monthly_active_users_wiki_repo: Gitlab::UsageDataCounters::TrackUniqueEvents::WIKI_ACTION,
action_monthly_active_users_git_write: Gitlab::UsageDataCounters::TrackUniqueEvents::GIT_WRITE_ACTION
} }
data.each do |key, event| data.each do |key, event|
......
...@@ -121,6 +121,9 @@ ...@@ -121,6 +121,9 @@
- name: project_action - name: project_action
category: source_code category: source_code
aggregation: daily aggregation: daily
- name: git_write_action
category: source_code
aggregation: daily
- name: merge_request_action - name: merge_request_action
category: source_code category: source_code
aggregation: daily aggregation: daily
......
...@@ -8,6 +8,9 @@ module Gitlab ...@@ -8,6 +8,9 @@ module Gitlab
PUSH_ACTION = :project_action PUSH_ACTION = :project_action
MERGE_REQUEST_ACTION = :merge_request_action MERGE_REQUEST_ACTION = :merge_request_action
GIT_WRITE_ACTIONS = [WIKI_ACTION, DESIGN_ACTION, PUSH_ACTION].freeze
GIT_WRITE_ACTION = :git_write_action
ACTION_TRANSFORMATIONS = HashWithIndifferentAccess.new({ ACTION_TRANSFORMATIONS = HashWithIndifferentAccess.new({
wiki: { wiki: {
created: WIKI_ACTION, created: WIKI_ACTION,
...@@ -41,6 +44,8 @@ module Gitlab ...@@ -41,6 +44,8 @@ module Gitlab
return unless Gitlab::UsageDataCounters::HLLRedisCounter.known_event?(transformed_action.to_s) return unless Gitlab::UsageDataCounters::HLLRedisCounter.known_event?(transformed_action.to_s)
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(author_id, transformed_action.to_s, time) Gitlab::UsageDataCounters::HLLRedisCounter.track_event(author_id, transformed_action.to_s, time)
track_git_write_action(author_id, transformed_action, time)
end end
def count_unique_events(event_action:, date_from:, date_to:) def count_unique_events(event_action:, date_from:, date_to:)
...@@ -64,6 +69,12 @@ module Gitlab ...@@ -64,6 +69,12 @@ module Gitlab
def valid_action?(action) def valid_action?(action)
Event.actions.key?(action) Event.actions.key?(action)
end end
def track_git_write_action(author_id, transformed_action, time)
return unless GIT_WRITE_ACTIONS.include?(transformed_action)
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(author_id, GIT_WRITE_ACTION, time)
end
end end
end end
end end
......
...@@ -1085,6 +1085,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1085,6 +1085,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let(:user1) { build(:user, id: 1) } let(:user1) { build(:user, id: 1) }
let(:user2) { build(:user, id: 2) } let(:user2) { build(:user, id: 2) }
let(:user3) { build(:user, id: 3) } let(:user3) { build(:user, id: 3) }
let(:user4) { build(:user, id: 4) }
before do before do
counter = Gitlab::UsageDataCounters::TrackUniqueEvents counter = Gitlab::UsageDataCounters::TrackUniqueEvents
...@@ -1099,6 +1100,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1099,6 +1100,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
counter.track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days) counter.track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)
counter.track_event(event_action: :created, event_target: wiki, author_id: 3) counter.track_event(event_action: :created, event_target: wiki, author_id: 3)
counter.track_event(event_action: :created, event_target: design, author_id: 3) counter.track_event(event_action: :created, event_target: design, author_id: 3)
counter.track_event(event_action: :created, event_target: design, author_id: 4)
counter = Gitlab::UsageDataCounters::EditorUniqueCounter counter = Gitlab::UsageDataCounters::EditorUniqueCounter
...@@ -1118,9 +1120,10 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1118,9 +1120,10 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
it 'returns the distinct count of user actions within the specified time period' do 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( expect(described_class.action_monthly_active_users(time_period)).to eq(
{ {
action_monthly_active_users_design_management: 1, action_monthly_active_users_design_management: 2,
action_monthly_active_users_project_repo: 3, action_monthly_active_users_project_repo: 3,
action_monthly_active_users_wiki_repo: 1, action_monthly_active_users_wiki_repo: 1,
action_monthly_active_users_git_write: 4,
action_monthly_active_users_web_ide_edit: 2, action_monthly_active_users_web_ide_edit: 2,
action_monthly_active_users_sfe_edit: 2, action_monthly_active_users_sfe_edit: 2,
action_monthly_active_users_snippet_editor_edit: 2, action_monthly_active_users_snippet_editor_edit: 2,
......
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