Commit cfe0859a authored by Mario de la Ossa's avatar Mario de la Ossa

Add metrics for Clone quick_action

Usage metrics for the new clone issue quickaction
parent 2d7d9ef3
...@@ -260,6 +260,8 @@ module SystemNotes ...@@ -260,6 +260,8 @@ module SystemNotes
cross_reference = noteable_ref.to_reference(project) cross_reference = noteable_ref.to_reference(project)
body = "cloned #{direction} #{cross_reference}" body = "cloned #{direction} #{cross_reference}"
issue_activity_counter.track_issue_cloned_action(author: author) if noteable.is_a?(Issue) && direction == :to
create_note(NoteSummary.new(noteable, project, author, body, action: 'cloned')) create_note(NoteSummary.new(noteable, project, author, body, action: 'cloned'))
end end
......
---
title: Add usage metrics for issue clone
merge_request: 48537
author:
type: added
...@@ -18,6 +18,7 @@ module Gitlab ...@@ -18,6 +18,7 @@ module Gitlab
ISSUE_CROSS_REFERENCED = 'g_project_management_issue_cross_referenced' ISSUE_CROSS_REFERENCED = 'g_project_management_issue_cross_referenced'
ISSUE_MOVED = 'g_project_management_issue_moved' ISSUE_MOVED = 'g_project_management_issue_moved'
ISSUE_RELATED = 'g_project_management_issue_related' ISSUE_RELATED = 'g_project_management_issue_related'
ISSUE_CLONED = 'g_project_management_issue_cloned'
ISSUE_UNRELATED = 'g_project_management_issue_unrelated' ISSUE_UNRELATED = 'g_project_management_issue_unrelated'
ISSUE_MARKED_AS_DUPLICATE = 'g_project_management_issue_marked_as_duplicate' ISSUE_MARKED_AS_DUPLICATE = 'g_project_management_issue_marked_as_duplicate'
ISSUE_LOCKED = 'g_project_management_issue_locked' ISSUE_LOCKED = 'g_project_management_issue_locked'
...@@ -137,6 +138,10 @@ module Gitlab ...@@ -137,6 +138,10 @@ module Gitlab
track_unique_action(ISSUE_COMMENT_REMOVED, author, time) track_unique_action(ISSUE_COMMENT_REMOVED, author, time)
end end
def track_issue_cloned_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_CLONED, author, time)
end
private private
def track_unique_action(action, author, time) def track_unique_action(action, author, time)
......
...@@ -408,6 +408,11 @@ ...@@ -408,6 +408,11 @@
redis_slot: project_management redis_slot: project_management
aggregation: daily aggregation: daily
feature_flag: track_issue_activity_actions feature_flag: track_issue_activity_actions
- name: g_project_management_issue_cloned
category: issues_edit
redis_slot: project_management
aggregation: daily
feature_flag: track_issue_activity_actions
# Secrets Management # Secrets Management
- name: i_ci_secrets_management_vault_build_created - name: i_ci_secrets_management_vault_build_created
category: ci_secrets_management category: ci_secrets_management
......
...@@ -118,6 +118,16 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git ...@@ -118,6 +118,16 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end end
end end
context 'for Issue cloned actions' do
it_behaves_like 'a tracked issue edit event' do
let(:action) { described_class::ISSUE_CLONED }
def track_action(params)
described_class.track_issue_cloned_action(**params)
end
end
end
context 'for Issue relate actions' do context 'for Issue relate actions' do
it_behaves_like 'a tracked issue edit event' do it_behaves_like 'a tracked issue edit event' do
let(:action) { described_class::ISSUE_RELATED } let(:action) { described_class::ISSUE_RELATED }
......
...@@ -581,6 +581,30 @@ RSpec.describe ::SystemNotes::IssuablesService do ...@@ -581,6 +581,30 @@ RSpec.describe ::SystemNotes::IssuablesService do
expect { subject }.to raise_error StandardError, /Invalid direction/ expect { subject }.to raise_error StandardError, /Invalid direction/
end end
end end
context 'metrics' do
context 'cloned from' do
let(:direction) { :from }
it 'does not tracks usage' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter)
.not_to receive(:track_issue_cloned_action).with(author: author)
subject
end
end
context 'cloned to' do
let(:direction) { :to }
it 'tracks usage' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter)
.to receive(:track_issue_cloned_action).with(author: author)
subject
end
end
end
end end
describe '#mark_duplicate_issue' do describe '#mark_duplicate_issue' 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