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
super
track_event
new_entity
end
private
def track_event
::Gitlab::SnowplowTracker.track_event(
'epics', 'promote', property: 'issue_id', value: original_entity.id
)
end
def create_new_entity
@new_entity = Epics::CreateService.new(@group, current_user, params).execute
end
......
......@@ -8,9 +8,7 @@ module Gitlab
class << self
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
private
......
......@@ -8,7 +8,7 @@ describe Gitlab::SnowplowTracker do
Timecop.freeze(timestamp) { example.run }
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 'when Snowplow tracker is disabled' do
......@@ -20,10 +20,13 @@ describe Gitlab::SnowplowTracker do
end
context 'when Snowplow tracker is enabled' do
it 'tracks the event' do
before do
stub_application_setting(snowplow_enabled: true)
stub_application_setting(snowplow_site_id: 'awesome gitlab')
stub_application_setting(snowplow_collector_uri: 'url.com')
end
it 'tracks the event' do
tracker = double
expect(::SnowplowTracker::Tracker).to receive(:new)
......@@ -33,7 +36,7 @@ describe Gitlab::SnowplowTracker do
'cf', 'awesome gitlab'
).and_return(tracker)
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
end
......
......@@ -56,6 +56,8 @@ describe Epics::IssuePromoteService do
context 'when issue is promoted' do
before do
allow(Gitlab::SnowplowTracker).to receive(:track_event).with('epics', 'promote', an_instance_of(Hash))
subject.execute(issue)
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