Commit 32cf914f authored by Robert Speicher's avatar Robert Speicher

Merge branch '8920-epics-track' into 'master'

Track issues to epics promotions

Closes #8920

See merge request gitlab-org/gitlab-ee!10537
parents 07f0b0a3 fc5a49eb
...@@ -17,11 +17,18 @@ module Epics ...@@ -17,11 +17,18 @@ module Epics
super super
track_event
new_entity new_entity
end end
private private
def track_event
::Gitlab::SnowplowTracker.track_event(
'epics', 'promote', property: 'issue_id', value: original_entity.id
)
end
def create_new_entity def create_new_entity
@new_entity = Epics::CreateService.new(@group, current_user, params).execute @new_entity = Epics::CreateService.new(@group, current_user, params).execute
end end
......
...@@ -8,9 +8,7 @@ module Gitlab ...@@ -8,9 +8,7 @@ module Gitlab
class << self class << self
def track_event(category, action, label: nil, property: nil, value: nil, context: nil) def track_event(category, action, label: nil, property: nil, value: nil, context: nil)
return unless enabled? tracker&.track_struct_event(category, action, label, property, value, context, Time.now.to_i)
tracker.track_struct_event(category, action, label, property, value, context, Time.now.to_i)
end end
private private
......
...@@ -8,7 +8,7 @@ describe Gitlab::SnowplowTracker do ...@@ -8,7 +8,7 @@ describe Gitlab::SnowplowTracker do
Timecop.freeze(timestamp) { example.run } Timecop.freeze(timestamp) { example.run }
end end
subject { described_class.track_event('category', 'action', property: 'what', value: 'doit') } subject { described_class.track_event('epics', 'action', property: 'what', value: 'doit') }
context '.track_event' do context '.track_event' do
context 'when Snowplow tracker is disabled' do context 'when Snowplow tracker is disabled' do
...@@ -20,10 +20,13 @@ describe Gitlab::SnowplowTracker do ...@@ -20,10 +20,13 @@ describe Gitlab::SnowplowTracker do
end end
context 'when Snowplow tracker is enabled' do context 'when Snowplow tracker is enabled' do
it 'tracks the event' do before do
stub_application_setting(snowplow_enabled: true) stub_application_setting(snowplow_enabled: true)
stub_application_setting(snowplow_site_id: 'awesome gitlab') stub_application_setting(snowplow_site_id: 'awesome gitlab')
stub_application_setting(snowplow_collector_uri: 'url.com') stub_application_setting(snowplow_collector_uri: 'url.com')
end
it 'tracks the event' do
tracker = double tracker = double
expect(::SnowplowTracker::Tracker).to receive(:new) expect(::SnowplowTracker::Tracker).to receive(:new)
...@@ -33,7 +36,7 @@ describe Gitlab::SnowplowTracker do ...@@ -33,7 +36,7 @@ describe Gitlab::SnowplowTracker do
'cf', 'awesome gitlab' 'cf', 'awesome gitlab'
).and_return(tracker) ).and_return(tracker)
expect(tracker).to receive(:track_struct_event) expect(tracker).to receive(:track_struct_event)
.with('category', 'action', nil, 'what', 'doit', nil, timestamp.to_i) .with('epics', 'action', nil, 'what', 'doit', nil, timestamp.to_i)
subject subject
end end
......
...@@ -56,6 +56,8 @@ describe Epics::IssuePromoteService do ...@@ -56,6 +56,8 @@ describe Epics::IssuePromoteService do
context 'when issue is promoted' do context 'when issue is promoted' do
before do before do
allow(Gitlab::SnowplowTracker).to receive(:track_event).with('epics', 'promote', an_instance_of(Hash))
subject.execute(issue) subject.execute(issue)
end 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