Commit a6c81bdd authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '232844-fj-add-ide-actions-usage-data' into 'master'

Add IDE edit actions to Usage Data

See merge request gitlab-org/gitlab!40939
parents 47d801b1 43921022
---
title: Add IDE edit actions to Usage Data
merge_request: 40939
author:
type: changed
......@@ -650,41 +650,37 @@ module Gitlab
end
def action_monthly_active_users(time_period)
counter = Gitlab::UsageDataCounters::TrackUniqueEvents
date_range = { date_from: time_period[:created_at].first, date_to: time_period[:created_at].last }
project_count = redis_usage_data do
counter.count_unique_events(
event_action: Gitlab::UsageDataCounters::TrackUniqueEvents::PUSH_ACTION,
date_from: time_period[:created_at].first,
date_to: time_period[:created_at].last
)
end
event_monthly_active_users(date_range)
.merge!(ide_monthly_active_users(date_range))
end
design_count = redis_usage_data do
counter.count_unique_events(
event_action: Gitlab::UsageDataCounters::TrackUniqueEvents::DESIGN_ACTION,
date_from: time_period[:created_at].first,
date_to: time_period[:created_at].last
)
end
private
wiki_count = redis_usage_data do
counter.count_unique_events(
event_action: Gitlab::UsageDataCounters::TrackUniqueEvents::WIKI_ACTION,
date_from: time_period[:created_at].first,
date_to: time_period[:created_at].last
)
def event_monthly_active_users(date_range)
data = {
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_wiki_repo: Gitlab::UsageDataCounters::TrackUniqueEvents::WIKI_ACTION
}
data.each do |key, event|
data[key] = redis_usage_data { Gitlab::UsageDataCounters::TrackUniqueEvents.count_unique_events(event_action: event, **date_range) }
end
end
def ide_monthly_active_users(date_range)
counter = Gitlab::UsageDataCounters::EditorUniqueCounter
{
action_monthly_active_users_project_repo: project_count,
action_monthly_active_users_design_management: design_count,
action_monthly_active_users_wiki_repo: wiki_count
action_monthly_active_users_web_ide_edit: redis_usage_data { counter.count_web_ide_edit_actions(date_range) },
action_monthly_active_users_sfe_edit: redis_usage_data { counter.count_sfe_edit_actions(date_range) },
action_monthly_active_users_snippet_editor_edit: redis_usage_data { counter.count_snippet_editor_edit_actions(date_range) },
action_monthly_active_users_ide_edit: redis_usage_data { counter.count_edit_using_editor(date_range) }
}
end
private
def distinct_count_service_desk_enabled_projects(time_period)
project_creator_id_start = user_minimum_id
project_creator_id_finish = user_maximum_id
......
......@@ -999,6 +999,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
describe '#action_monthly_active_users', :clean_gitlab_redis_shared_state do
let(:time_period) { { created_at: 2.days.ago..time } }
let(:time) { Time.zone.now }
let(:user1) { build(:user, id: 1) }
let(:user2) { build(:user, id: 2) }
let(:user3) { build(:user, id: 3) }
before do
counter = Gitlab::UsageDataCounters::TrackUniqueEvents
......@@ -1014,6 +1017,20 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
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: :created, event_target: design, author_id: 3)
counter = Gitlab::UsageDataCounters::EditorUniqueCounter
counter.track_web_ide_edit_action(author: user1)
counter.track_web_ide_edit_action(author: user1)
counter.track_sfe_edit_action(author: user1)
counter.track_snippet_editor_edit_action(author: user1)
counter.track_snippet_editor_edit_action(author: user1, time: time - 3.days)
counter.track_web_ide_edit_action(author: user2)
counter.track_sfe_edit_action(author: user2)
counter.track_web_ide_edit_action(author: user3, time: time - 3.days)
counter.track_snippet_editor_edit_action(author: user3)
end
it 'returns the distinct count of user actions within the specified time period' do
......@@ -1021,7 +1038,11 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
{
action_monthly_active_users_design_management: 1,
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_web_ide_edit: 2,
action_monthly_active_users_sfe_edit: 2,
action_monthly_active_users_snippet_editor_edit: 2,
action_monthly_active_users_ide_edit: 3
}
)
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