Commit 597df87e authored by charlie ablett's avatar charlie ablett

Merge branch '229918-track-additional-issue-change-events' into 'master'

Add tracking for more issue change events

See merge request gitlab-org/gitlab!43828
parents a49ab954 b48d67a4
...@@ -13,6 +13,8 @@ module SystemNotes ...@@ -13,6 +13,8 @@ module SystemNotes
def relate_issue(noteable_ref) def relate_issue(noteable_ref)
body = "marked this issue as related to #{noteable_ref.to_reference(noteable.project)}" body = "marked this issue as related to #{noteable_ref.to_reference(noteable.project)}"
issue_activity_counter.track_issue_related_action(author: author) if noteable.is_a?(Issue)
create_note(NoteSummary.new(noteable, project, author, body, action: 'relate')) create_note(NoteSummary.new(noteable, project, author, body, action: 'relate'))
end end
...@@ -27,6 +29,8 @@ module SystemNotes ...@@ -27,6 +29,8 @@ module SystemNotes
def unrelate_issue(noteable_ref) def unrelate_issue(noteable_ref)
body = "removed the relation with #{noteable_ref.to_reference(noteable.project)}" body = "removed the relation with #{noteable_ref.to_reference(noteable.project)}"
issue_activity_counter.track_issue_unrelated_action(author: author) if noteable.is_a?(Issue)
create_note(NoteSummary.new(noteable, project, author, body, action: 'unrelate')) create_note(NoteSummary.new(noteable, project, author, body, action: 'unrelate'))
end end
...@@ -174,6 +178,8 @@ module SystemNotes ...@@ -174,6 +178,8 @@ module SystemNotes
if noteable.is_a?(ExternalIssue) if noteable.is_a?(ExternalIssue)
noteable.project.external_issue_tracker.create_cross_reference_note(noteable, mentioner, author) noteable.project.external_issue_tracker.create_cross_reference_note(noteable, mentioner, author)
else else
issue_activity_counter.track_issue_cross_referenced_action(author: author) if noteable.is_a?(Issue)
create_note(NoteSummary.new(noteable, noteable.project, author, body, action: 'cross_reference')) create_note(NoteSummary.new(noteable, noteable.project, author, body, action: 'cross_reference'))
end end
end end
...@@ -208,6 +214,8 @@ module SystemNotes ...@@ -208,6 +214,8 @@ module SystemNotes
status_label = new_task.complete? ? Taskable::COMPLETED : Taskable::INCOMPLETE status_label = new_task.complete? ? Taskable::COMPLETED : Taskable::INCOMPLETE
body = "marked the task **#{new_task.source}** as #{status_label}" body = "marked the task **#{new_task.source}** as #{status_label}"
issue_activity_counter.track_issue_description_changed_action(author: author) if noteable.is_a?(Issue)
create_note(NoteSummary.new(noteable, project, author, body, action: 'task')) create_note(NoteSummary.new(noteable, project, author, body, action: 'task'))
end end
...@@ -229,6 +237,8 @@ module SystemNotes ...@@ -229,6 +237,8 @@ module SystemNotes
cross_reference = noteable_ref.to_reference(project) cross_reference = noteable_ref.to_reference(project)
body = "moved #{direction} #{cross_reference}" body = "moved #{direction} #{cross_reference}"
issue_activity_counter.track_issue_moved_action(author: author) if noteable.is_a?(Issue)
create_note(NoteSummary.new(noteable, project, author, body, action: 'moved')) create_note(NoteSummary.new(noteable, project, author, body, action: 'moved'))
end end
...@@ -299,6 +309,9 @@ module SystemNotes ...@@ -299,6 +309,9 @@ module SystemNotes
# Returns the created Note object # Returns the created Note object
def mark_duplicate_issue(canonical_issue) def mark_duplicate_issue(canonical_issue)
body = "marked this issue as a duplicate of #{canonical_issue.to_reference(project)}" body = "marked this issue as a duplicate of #{canonical_issue.to_reference(project)}"
issue_activity_counter.track_issue_marked_as_duplicate_action(author: author) if noteable.is_a?(Issue)
create_note(NoteSummary.new(noteable, project, author, body, action: 'duplicate')) create_note(NoteSummary.new(noteable, project, author, body, action: 'duplicate'))
end end
...@@ -322,6 +335,14 @@ module SystemNotes ...@@ -322,6 +335,14 @@ module SystemNotes
action = noteable.discussion_locked? ? 'locked' : 'unlocked' action = noteable.discussion_locked? ? 'locked' : 'unlocked'
body = "#{action} this #{noteable.class.to_s.titleize.downcase}" body = "#{action} this #{noteable.class.to_s.titleize.downcase}"
if noteable.is_a?(Issue)
if action == 'locked'
issue_activity_counter.track_issue_locked_action(author: author)
else
issue_activity_counter.track_issue_unlocked_action(author: author)
end
end
create_note(NoteSummary.new(noteable, project, author, body, action: action)) create_note(NoteSummary.new(noteable, project, author, body, action: action))
end end
......
---
title: Add more issue change events to usage ping
merge_request: 43828
author:
type: other
...@@ -17,6 +17,13 @@ module Gitlab ...@@ -17,6 +17,13 @@ module Gitlab
ISSUE_REOPENED = 'g_project_management_issue_reopened' ISSUE_REOPENED = 'g_project_management_issue_reopened'
ISSUE_TITLE_CHANGED = 'g_project_management_issue_title_changed' ISSUE_TITLE_CHANGED = 'g_project_management_issue_title_changed'
ISSUE_WEIGHT_CHANGED = 'g_project_management_issue_weight_changed' ISSUE_WEIGHT_CHANGED = 'g_project_management_issue_weight_changed'
ISSUE_CROSS_REFERENCED = 'g_project_management_issue_cross_referenced'
ISSUE_MOVED = 'g_project_management_issue_moved'
ISSUE_RELATED = 'g_project_management_issue_related'
ISSUE_UNRELATED = 'g_project_management_issue_unrelated'
ISSUE_MARKED_AS_DUPLICATE = 'g_project_management_issue_marked_as_duplicate'
ISSUE_LOCKED = 'g_project_management_issue_locked'
ISSUE_UNLOCKED = 'g_project_management_issue_unlocked'
class << self class << self
def track_issue_created_action(author:, time: Time.zone.now) def track_issue_created_action(author:, time: Time.zone.now)
...@@ -67,6 +74,34 @@ module Gitlab ...@@ -67,6 +74,34 @@ module Gitlab
track_unique_action(ISSUE_WEIGHT_CHANGED, author, time) track_unique_action(ISSUE_WEIGHT_CHANGED, author, time)
end end
def track_issue_cross_referenced_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_CROSS_REFERENCED, author, time)
end
def track_issue_moved_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_MOVED, author, time)
end
def track_issue_related_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_RELATED, author, time)
end
def track_issue_unrelated_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_UNRELATED, author, time)
end
def track_issue_marked_as_duplicate_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_MARKED_AS_DUPLICATE, author, time)
end
def track_issue_locked_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_LOCKED, author, time)
end
def track_issue_unlocked_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_UNLOCKED, author, time)
end
private private
def track_unique_action(action, author, time) def track_unique_action(action, author, time)
......
...@@ -234,3 +234,31 @@ ...@@ -234,3 +234,31 @@
category: issues_edit category: issues_edit
redis_slot: project_management redis_slot: project_management
aggregation: daily aggregation: daily
- name: g_project_management_issue_cross_referenced
category: issues_edit
redis_slot: project_management
aggregation: daily
- name: g_project_management_issue_moved
category: issues_edit
redis_slot: project_management
aggregation: daily
- name: g_project_management_issue_related
category: issues_edit
redis_slot: project_management
aggregation: daily
- name: g_project_management_issue_unrelated
category: issues_edit
redis_slot: project_management
aggregation: daily
- name: g_project_management_issue_marked_as_duplicate
category: issues_edit
redis_slot: project_management
aggregation: daily
- name: g_project_management_issue_locked
category: issues_edit
redis_slot: project_management
aggregation: daily
- name: g_project_management_issue_unlocked
category: issues_edit
redis_slot: project_management
aggregation: daily
...@@ -132,6 +132,76 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git ...@@ -132,6 +132,76 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end end
end end
context 'for Issue cross-referenced actions' do
it_behaves_like 'tracks and counts action' do
let(:action) { described_class::ISSUE_CROSS_REFERENCED }
def track_action(params)
described_class.track_issue_cross_referenced_action(**params)
end
end
end
context 'for Issue moved actions' do
it_behaves_like 'tracks and counts action' do
let(:action) { described_class::ISSUE_MOVED }
def track_action(params)
described_class.track_issue_moved_action(**params)
end
end
end
context 'for Issue relate actions' do
it_behaves_like 'tracks and counts action' do
let(:action) { described_class::ISSUE_RELATED }
def track_action(params)
described_class.track_issue_related_action(**params)
end
end
end
context 'for Issue unrelate actions' do
it_behaves_like 'tracks and counts action' do
let(:action) { described_class::ISSUE_UNRELATED }
def track_action(params)
described_class.track_issue_unrelated_action(**params)
end
end
end
context 'for Issue marked as duplicate actions' do
it_behaves_like 'tracks and counts action' do
let(:action) { described_class::ISSUE_MARKED_AS_DUPLICATE }
def track_action(params)
described_class.track_issue_marked_as_duplicate_action(**params)
end
end
end
context 'for Issue locked actions' do
it_behaves_like 'tracks and counts action' do
let(:action) { described_class::ISSUE_LOCKED }
def track_action(params)
described_class.track_issue_locked_action(**params)
end
end
end
context 'for Issue unlocked actions' do
it_behaves_like 'tracks and counts action' do
let(:action) { described_class::ISSUE_UNLOCKED }
def track_action(params)
described_class.track_issue_unlocked_action(**params)
end
end
end
it 'can return the count of actions per user deduplicated', :aggregate_failures do it 'can return the count of actions per user deduplicated', :aggregate_failures do
described_class.track_issue_title_changed_action(author: user1) described_class.track_issue_title_changed_action(author: user1)
described_class.track_issue_description_changed_action(author: user1) described_class.track_issue_description_changed_action(author: user1)
......
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