Commit 6a3907f6 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'ali/add-user-to-standard-context' into 'master'

Add user to StandardContext

See merge request gitlab-org/gitlab!52534
parents 4b828727 354f43dc
...@@ -32,8 +32,10 @@ module Epics ...@@ -32,8 +32,10 @@ module Epics
end end
def track_event def track_event
context = ::Gitlab::Tracking::StandardContext.new(namespace: @parent_group, project: issue.project, user: current_user)
::Gitlab::Tracking.event('epics', 'promote', property: 'issue_id', value: original_entity.id, ::Gitlab::Tracking.event('epics', 'promote', property: 'issue_id', value: original_entity.id,
standard_context: ::Gitlab::Tracking::StandardContext.new(namespace: @parent_group, project: issue.project)) standard_context: context)
end end
def create_new_entity def create_new_entity
......
...@@ -65,7 +65,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do ...@@ -65,7 +65,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do
subject.execute(issue) subject.execute(issue)
expect_snowplow_event(category: 'epics', action: 'promote', property: 'issue_id', value: issue.id, expect_snowplow_event(category: 'epics', action: 'promote', property: 'issue_id', value: issue.id,
standard_context: { namespace: group, project: project }) standard_context: { namespace: group, project: project, user: user })
end end
it 'creates a new epic with correct attributes' do it 'creates a new epic with correct attributes' do
...@@ -201,7 +201,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do ...@@ -201,7 +201,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do
expect(epic.notes.where(discussion_id: discussion.discussion_id).count).to eq(0) expect(epic.notes.where(discussion_id: discussion.discussion_id).count).to eq(0)
expect(issue.notes.where(discussion_id: discussion.discussion_id).count).to eq(1) expect(issue.notes.where(discussion_id: discussion.discussion_id).count).to eq(1)
expect_snowplow_event(category: 'epics', action: 'promote', property: 'issue_id', value: issue.id, expect_snowplow_event(category: 'epics', action: 'promote', property: 'issue_id', value: issue.id,
standard_context: { namespace: group, project: project }) standard_context: { namespace: group, project: project, user: user })
end end
it 'copies note attachments' do it 'copies note attachments' do
...@@ -211,7 +211,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do ...@@ -211,7 +211,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do
expect(epic.notes.user.first.attachment).to be_kind_of(AttachmentUploader) expect(epic.notes.user.first.attachment).to be_kind_of(AttachmentUploader)
expect_snowplow_event(category: 'epics', action: 'promote', property: 'issue_id', value: issue.id, expect_snowplow_event(category: 'epics', action: 'promote', property: 'issue_id', value: issue.id,
standard_context: { namespace: group, project: project }) standard_context: { namespace: group, project: project, user: user })
end end
end end
......
...@@ -5,9 +5,7 @@ module Gitlab ...@@ -5,9 +5,7 @@ module Gitlab
class StandardContext class StandardContext
GITLAB_STANDARD_SCHEMA_URL = 'iglu:com.gitlab/gitlab_standard/jsonschema/1-0-2'.freeze GITLAB_STANDARD_SCHEMA_URL = 'iglu:com.gitlab/gitlab_standard/jsonschema/1-0-2'.freeze
def initialize(namespace: nil, project: nil, **data) def initialize(namespace: nil, project: nil, user: nil, **data)
@namespace = namespace
@project = project
@data = data @data = data
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