Skip to content
代码片段 群组 项目
提交 b8c80678 编辑于 作者: Piotr Skorupa's avatar Piotr Skorupa
浏览文件

Migrate commit_comment metric to Snowplow

上级 17410eed
No related branches found
No related tags found
无相关合并请求
......@@ -167,6 +167,20 @@ def track_event(note, user)
if Feature.enabled?(:notes_create_service_tracking, project)
Gitlab::Tracking.event('Notes::CreateService', 'execute', **tracking_data_for(note))
end
if Feature.enabled?(:route_hll_to_snowplow_phase4, project&.namespace) && note.for_commit?
metric_key_path = 'counts.commit_comment'
Gitlab::Tracking.event(
'Notes::CreateService',
'create_commit_comment',
project: project,
namespace: project&.namespace,
user: user,
label: metric_key_path,
context: [Gitlab::Tracking::ServicePingContext.new(data_source: :redis, key_path: metric_key_path).to_context]
)
end
end
def tracking_data_for(note)
......
---
description: Mirrored `counts.commit_comment` Service Ping metric as a Snowplow event. Emitted when a note for a commit is created.
category: Notes::CreateService
action: create_commit_comment
label_description: Mirrored Service Ping metric key path
property_description:
value_description:
extra_properties:
identifiers:
- project
- user
- namespace
product_section:
product_stage:
product_group:
product_category:
milestone: "15.8"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105148
distributions:
- ce
- ee
tiers:
- free
- premium
- ultimate
......@@ -116,6 +116,35 @@
end
end
context 'in a commit', :snowplow do
let_it_be(:commit) { create(:commit, project: project) }
let(:opts) { { note: 'Awesome comment', noteable_type: 'Commit', commit_id: commit.id } }
let(:counter) { Gitlab::UsageDataCounters::NoteCounter }
let(:execute_create_service) { described_class.new(project, user, opts).execute }
before do
stub_feature_flags(notes_create_service_tracking: false)
end
it 'tracks commit comment usage data', :clean_gitlab_redis_shared_state do
expect(counter).to receive(:count).with(:create, 'Commit').and_call_original
expect do
execute_create_service
end.to change { counter.read(:create, 'Commit') }.by(1)
end
it_behaves_like 'Snowplow event tracking with Redis context' do
let(:category) { described_class.name }
let(:action) { 'create_commit_comment' }
let(:label) { 'counts.commit_comment' }
let(:namespace) { project.namespace }
let(:feature_flag_name) { :route_hll_to_snowplow_phase4 }
end
end
describe 'event tracking', :snowplow do
let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED }
let(:execute_create_service) { described_class.new(project, user, opts).execute }
......
......@@ -52,3 +52,12 @@
end
end
end
RSpec.shared_examples 'Snowplow event tracking with Redis context' do |overrides: {}|
it_behaves_like 'Snowplow event tracking', overrides: overrides do
let(:context) do
key_path = try(:label) || action
[Gitlab::Tracking::ServicePingContext.new(data_source: :redis, key_path: key_path).to_context.to_json]
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册