From 1b5891ee8ce8adc6877c462ea292eaee3c4ab30b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 15 Aug 2022 03:11:57 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- app/assets/stylesheets/pages/issues.scss | 2 +- app/services/notes/create_service.rb | 3 +- app/services/notes/destroy_service.rb | 3 +- app/services/notes/update_service.rb | 3 +- .../system_notes/issuables_service.rb | 4 +- ..._project_management_issue_changed_epic.yml | 20 ----- ...management_issue_health_status_changed.yml | 20 ----- ...ect_management_issue_iteration_changed.yml | 20 ----- ...ect_management_issue_removed_from_epic.yml | 20 ----- ...roject_management_issue_weight_changed.yml | 20 ----- ..._issue_actions_perform_issue_acitons_.yml} | 17 ++-- lib/gitlab/ci/templates/Dart.gitlab-ci.yml | 89 ++++++++++++++++--- .../issue_activity_unique_counter.rb | 34 ++++--- .../ide/stores/mutations/file_spec.js | 20 ++--- .../issue_activity_unique_counter_spec.rb | 21 +++-- spec/services/notes/create_service_spec.rb | 33 ++++--- spec/services/notes/destroy_service_spec.rb | 26 ++++-- spec/services/notes/update_service_spec.rb | 34 ++++--- .../system_notes/issuables_service_spec.rb | 9 +- .../issuable_activity_shared_examples.rb | 8 +- .../snowplow_tracking_shared_examples.rb | 11 +++ tooling/bin/qa/run_qa_check | 2 +- 22 files changed, 224 insertions(+), 195 deletions(-) delete mode 100644 config/events/1656555050_issues_edit_g_project_management_issue_changed_epic.yml delete mode 100644 config/events/1656555163_issues_edit_g_project_management_issue_health_status_changed.yml delete mode 100644 config/events/1656555272_issues_edit_g_project_management_issue_iteration_changed.yml delete mode 100644 config/events/1656555342_issues_edit_g_project_management_issue_removed_from_epic.yml delete mode 100644 config/events/1656555426_issues_edit_g_project_management_issue_weight_changed.yml rename config/events/{1656554755_issues_edit_g_project_management_issue_added_to_epic.yml => 1659067369_issue_actions_perform_issue_acitons_.yml} (57%) create mode 100644 spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb diff --git a/app/assets/stylesheets/pages/issues.scss b/app/assets/stylesheets/pages/issues.scss index c0a283ec643..a151c28fe93 100644 --- a/app/assets/stylesheets/pages/issues.scss +++ b/app/assets/stylesheets/pages/issues.scss @@ -318,7 +318,7 @@ ul.related-merge-requests > li gl-emoji { .issuable-header-slide-enter-active, .issuable-header-slide-leave-active { - @include gl-transition-slow; + @include gl-transition-medium; } .issuable-header-slide-enter, diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb index 90edeacf633..b7e6a50fa5c 100644 --- a/app/services/notes/create_service.rb +++ b/app/services/notes/create_service.rb @@ -147,7 +147,8 @@ module Notes end def track_note_creation_usage_for_issues(note) - Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_added_action(author: note.author) + Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_added_action(author: note.author, + project: project) end def track_note_creation_usage_for_merge_requests(note) diff --git a/app/services/notes/destroy_service.rb b/app/services/notes/destroy_service.rb index c25b1ab0379..eda8bbcbc2e 100644 --- a/app/services/notes/destroy_service.rb +++ b/app/services/notes/destroy_service.rb @@ -15,7 +15,8 @@ module Notes private def track_note_removal_usage_for_issues(note) - Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_removed_action(author: note.author) + Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_removed_action(author: note.author, + project: project) end def track_note_removal_usage_for_merge_requests(note) diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index 04fc4c7c944..2dae76feb0b 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -86,7 +86,8 @@ module Notes end def track_note_edit_usage_for_issues(note) - Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_edited_action(author: note.author) + Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_edited_action(author: note.author, + project: project) end def track_note_edit_usage_for_merge_requests(note) diff --git a/app/services/system_notes/issuables_service.rb b/app/services/system_notes/issuables_service.rb index d2c6e9890db..1c724df44da 100644 --- a/app/services/system_notes/issuables_service.rb +++ b/app/services/system_notes/issuables_service.rb @@ -327,7 +327,9 @@ module SystemNotes cross_reference = noteable_ref.to_reference(project) body = "cloned #{direction} #{cross_reference}" - issue_activity_counter.track_issue_cloned_action(author: author) if noteable.is_a?(Issue) && direction == :to + if noteable.is_a?(Issue) && direction == :to + issue_activity_counter.track_issue_cloned_action(author: author, project: project) + end create_note(NoteSummary.new(noteable, project, author, body, action: 'cloned', created_at: created_at)) end diff --git a/config/events/1656555050_issues_edit_g_project_management_issue_changed_epic.yml b/config/events/1656555050_issues_edit_g_project_management_issue_changed_epic.yml deleted file mode 100644 index b74054b4eb5..00000000000 --- a/config/events/1656555050_issues_edit_g_project_management_issue_changed_epic.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -description: Epic was changed on an issue -category: issues_edit -action: g_project_management_issue_changed_epic -identifiers: - - project - - user - - namespace -product_section: dev -product_stage: plan -product_group: project_management -product_category: issue_tracking -milestone: "15.2" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443 -distributions: - - ee -tiers: - - premium - - ultimate - diff --git a/config/events/1656555163_issues_edit_g_project_management_issue_health_status_changed.yml b/config/events/1656555163_issues_edit_g_project_management_issue_health_status_changed.yml deleted file mode 100644 index 00a375074f6..00000000000 --- a/config/events/1656555163_issues_edit_g_project_management_issue_health_status_changed.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -description: Health status was changed on an issue -category: issues_edit -action: g_project_management_issue_health_status_changed -identifiers: - - project - - user - - namespace -product_section: dev -product_stage: plan -product_group: project_management -product_category: issue_tracking -milestone: "15.2" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443 -distributions: - - ee -tiers: - - premium - - ultimate - diff --git a/config/events/1656555272_issues_edit_g_project_management_issue_iteration_changed.yml b/config/events/1656555272_issues_edit_g_project_management_issue_iteration_changed.yml deleted file mode 100644 index 7e755c6e0e9..00000000000 --- a/config/events/1656555272_issues_edit_g_project_management_issue_iteration_changed.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -description: Issue's iteration was changed -category: issues_edit -action: g_project_management_issue_iteration_changed -identifiers: - - project - - user - - namespace -product_section: dev -product_stage: plan -product_group: project_management -product_category: issue_tracking -milestone: "15.2" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443 -distributions: - - ee -tiers: - - premium - - ultimate - diff --git a/config/events/1656555342_issues_edit_g_project_management_issue_removed_from_epic.yml b/config/events/1656555342_issues_edit_g_project_management_issue_removed_from_epic.yml deleted file mode 100644 index 5241e48ee9f..00000000000 --- a/config/events/1656555342_issues_edit_g_project_management_issue_removed_from_epic.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -description: An issue was removed from an epic -category: issues_edit -action: g_project_management_issue_removed_from_epic -identifiers: - - project - - user - - namespace -product_section: dev -product_stage: plan -product_group: project_management -product_category: issue_tracking -milestone: "15.2" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443 -distributions: - - ee -tiers: - - premium - - ultimate - diff --git a/config/events/1656555426_issues_edit_g_project_management_issue_weight_changed.yml b/config/events/1656555426_issues_edit_g_project_management_issue_weight_changed.yml deleted file mode 100644 index 99492d50176..00000000000 --- a/config/events/1656555426_issues_edit_g_project_management_issue_weight_changed.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -description: Issue's weight was changed -category: issues_edit -action: g_project_management_issue_weight_changed -identifiers: - - project - - user - - namespace -product_section: dev -product_stage: plan -product_group: project_management -product_category: issue_tracking -milestone: "15.2" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443 -distributions: - - ee -tiers: - - premium - - ultimate - diff --git a/config/events/1656554755_issues_edit_g_project_management_issue_added_to_epic.yml b/config/events/1659067369_issue_actions_perform_issue_acitons_.yml similarity index 57% rename from config/events/1656554755_issues_edit_g_project_management_issue_added_to_epic.yml rename to config/events/1659067369_issue_actions_perform_issue_acitons_.yml index 0c1ea4584e1..77fabfa2d6a 100644 --- a/config/events/1656554755_issues_edit_g_project_management_issue_added_to_epic.yml +++ b/config/events/1659067369_issue_actions_perform_issue_acitons_.yml @@ -1,20 +1,25 @@ --- -description: Issue was added to an epic +description: Issue usage event category: issues_edit -action: g_project_management_issue_added_to_epic +action: perform_issue_action +label_description: +property_description: the name of the performed action +value_description: +extra_properties: identifiers: + - namespace - project - user - - namespace product_section: dev product_stage: plan product_group: project_management product_category: issue_tracking -milestone: "15.2" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443 +milestone: "15.3" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91659 distributions: + - ce - ee tiers: + - free - premium - ultimate - diff --git a/lib/gitlab/ci/templates/Dart.gitlab-ci.yml b/lib/gitlab/ci/templates/Dart.gitlab-ci.yml index 35401e62fe2..4e011bb325d 100644 --- a/lib/gitlab/ci/templates/Dart.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Dart.gitlab-ci.yml @@ -6,25 +6,86 @@ # This specific template is located at: # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Dart.gitlab-ci.yml -# https://hub.docker.com/r/google/dart -image: google/dart:2.8.4 +# https://hub.docker.com/_/dart +image: dart:2.17 variables: - # Use to learn more: - # pub run test --help + # To learn more go to https://dart.dev/tools/dart-test + # Or run `dart test --help` PUB_VARS: "--platform vm --timeout 30s --concurrency=6 --test-randomize-ordering-seed=random --reporter=expanded" +.use-pub-cache-bin: + # Define commands that need to be executed before each job. + before_script: + # Set PUB_CACHE either here or in the CI/CD Settings if you have multiple jobs that use dart commands. + # PUB_CACHE is used by the `dart pub` command, it needs to be set so package dependencies are stored at the project-level for CI/CD operations. + - export PUB_CACHE=".pub-cache" + - export PATH="$PATH:$HOME/$PUB_CACHE/bin" + +# Cache generated files and plugins between builds. +.upload-cache: + cache: + when: 'on_success' + paths: + - .pub-cache/bin/ + - .pub-cache/global_packages/ + - .pub-cache/hosted/ + - .dart_tool/ + - .packages + # Cache downloaded dependencies and plugins between builds. # To keep cache across branches add 'key: "$CI_JOB_NAME"' -cache: - paths: - - .pub-cache/global_packages +.download-cache: + cache: + paths: + - .dart_tool/ + - .packages + policy: pull -before_script: - - export PATH="$PATH:$HOME/.pub-cache/bin" - - pub get --no-precompile - -test: - stage: test +install-dependencies: + stage: .pre + extends: + - .use-pub-cache-bin + - .upload-cache script: - - pub run test $PUB_VARS + - dart pub get --no-precompile + +build: + stage: build + needs: + - install-dependencies + extends: + - .use-pub-cache-bin + - .upload-cache + script: + - dart pub get --offline --precompile + +unit-test: + stage: test + needs: + - build + extends: + - .use-pub-cache-bin + - .download-cache + script: + - dart test $PUB_VARS + +lint-test: + stage: test + needs: + - install-dependencies + extends: + - .use-pub-cache-bin + - .download-cache + script: + - dart analyze . + +format-test: + stage: test + needs: + - install-dependencies + extends: + - .use-pub-cache-bin + - .download-cache + script: + - dart format --set-exit-if-changed bin/ lib/ test/ diff --git a/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb b/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb index 9d463e11772..316d9bb3dc1 100644 --- a/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb +++ b/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb @@ -4,6 +4,8 @@ module Gitlab module UsageDataCounters module IssueActivityUniqueCounter ISSUE_CATEGORY = 'issues_edit' + ISSUE_ACTION = 'perform_issue_action' + ISSUE_LABEL = 'redis_hll_counters.issues_edit.issues_edit_total_unique_counts_monthly' ISSUE_ASSIGNEE_CHANGED = 'g_project_management_issue_assignee_changed' ISSUE_CREATED = 'g_project_management_issue_created' @@ -126,42 +128,48 @@ module Gitlab track_unique_action(ISSUE_TIME_SPENT_CHANGED, author) end - def track_issue_comment_added_action(author:) + def track_issue_comment_added_action(author:, project:) + track_snowplow_action(ISSUE_COMMENT_ADDED, author, project) track_unique_action(ISSUE_COMMENT_ADDED, author) end - def track_issue_comment_edited_action(author:) + def track_issue_comment_edited_action(author:, project:) + track_snowplow_action(ISSUE_COMMENT_EDITED, author, project) track_unique_action(ISSUE_COMMENT_EDITED, author) end - def track_issue_comment_removed_action(author:) + def track_issue_comment_removed_action(author:, project:) + track_snowplow_action(ISSUE_COMMENT_REMOVED, author, project) track_unique_action(ISSUE_COMMENT_REMOVED, author) end - def track_issue_cloned_action(author:) + def track_issue_cloned_action(author:, project:) + track_snowplow_action(ISSUE_CLONED, author, project) track_unique_action(ISSUE_CLONED, author) end private - def track_unique_action(action, author) - return unless author - - Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id) - end - def track_snowplow_action(action, author, project) - return unless Feature.enabled?(:route_hll_to_snowplow_phase2, project&.namespace) + return unless Feature.enabled?(:route_hll_to_snowplow_phase2, project.namespace) return unless author Gitlab::Tracking.event( ISSUE_CATEGORY, - action.to_s, + ISSUE_ACTION, + label: ISSUE_LABEL, + property: action, project: project, - namespace: project&.namespace, + namespace: project.namespace, user: author ) end + + def track_unique_action(action, author) + return unless author + + Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id) + end end end end diff --git a/spec/frontend/ide/stores/mutations/file_spec.js b/spec/frontend/ide/stores/mutations/file_spec.js index 1453f26c1d9..69ec2e7a6f5 100644 --- a/spec/frontend/ide/stores/mutations/file_spec.js +++ b/spec/frontend/ide/stores/mutations/file_spec.js @@ -22,7 +22,7 @@ describe('IDE store file mutations', () => { active: true, }); - expect(localFile.active).toBeTruthy(); + expect(localFile.active).toBe(true); }); it('sets pending tab as not active', () => { @@ -41,7 +41,7 @@ describe('IDE store file mutations', () => { it('adds into opened files', () => { mutations.TOGGLE_FILE_OPEN(localState, localFile.path); - expect(localFile.opened).toBeTruthy(); + expect(localFile.opened).toBe(true); expect(localState.openFiles.length).toBe(1); }); @@ -50,7 +50,7 @@ describe('IDE store file mutations', () => { mutations.TOGGLE_FILE_OPEN(localState, localFile.path); mutations.TOGGLE_FILE_OPEN(localState, localFile.path); - expect(localFile.opened).toBeFalsy(); + expect(localFile.opened).toBe(false); expect(localState.openFiles.length).toBe(0); }); }); @@ -162,7 +162,7 @@ describe('IDE store file mutations', () => { callMutationForFile(localFile); - expect(localFile.raw).toBeFalsy(); + expect(localFile.raw).toEqual(''); expect(localState.stagedFiles[0].raw).toBe('testing'); }); @@ -172,7 +172,7 @@ describe('IDE store file mutations', () => { callMutationForFile(localFile); - expect(localFile.raw).toBeFalsy(); + expect(localFile.raw).toEqual(''); expect(localFile.content).toBe('testing'); }); @@ -202,7 +202,7 @@ describe('IDE store file mutations', () => { callMutationForFile(localFile); - expect(localFile.raw).toBeFalsy(); + expect(localFile.raw).toEqual(''); expect(localState.stagedFiles[0].raw).toBe('testing'); }); }); @@ -239,7 +239,7 @@ describe('IDE store file mutations', () => { }); expect(localFile.content).toBe('testing'); - expect(localFile.changed).toBeTruthy(); + expect(localFile.changed).toBe(true); }); it('sets changed if file is a temp file', () => { @@ -250,7 +250,7 @@ describe('IDE store file mutations', () => { content: '', }); - expect(localFile.changed).toBeTruthy(); + expect(localFile.changed).toBe(true); }); }); @@ -329,7 +329,7 @@ describe('IDE store file mutations', () => { mutations.DISCARD_FILE_CHANGES(localState, localFile.path); expect(localFile.content).toBe(''); - expect(localFile.changed).toBeFalsy(); + expect(localFile.changed).toBe(false); }); it('adds to root tree if deleted', () => { @@ -527,7 +527,7 @@ describe('IDE store file mutations', () => { changed: true, }); - expect(localFile.changed).toBeTruthy(); + expect(localFile.changed).toBe(true); }); }); diff --git a/spec/lib/gitlab/usage_data_counters/issue_activity_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/issue_activity_unique_counter_spec.rb index 1b73e5269d7..84a6f338282 100644 --- a/spec/lib/gitlab/usage_data_counters/issue_activity_unique_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/issue_activity_unique_counter_spec.rb @@ -6,7 +6,12 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git let_it_be(:user1) { build(:user, id: 1) } let_it_be(:user2) { build(:user, id: 2) } let_it_be(:user3) { build(:user, id: 3) } + let_it_be(:project) { build(:project) } + let_it_be(:category) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_CATEGORY } + let_it_be(:event_action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_ACTION } + let_it_be(:event_label) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_LABEL } + let(:event_property) { action } let(:time) { Time.zone.now } context 'for Issue title edit actions' do @@ -120,8 +125,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git end context 'for Issue cloned actions' do - it_behaves_like 'a daily tracked issuable event' do - let(:action) { described_class::ISSUE_CLONED } + it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do + let_it_be(:action) { described_class::ISSUE_CLONED } def track_action(params) described_class.track_issue_cloned_action(**params) @@ -239,8 +244,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git end end - context 'for Issue comment added actions' do - it_behaves_like 'a daily tracked issuable event' do + context 'for Issue comment added actions', :snowplow do + it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do let(:action) { described_class::ISSUE_COMMENT_ADDED } def track_action(params) @@ -249,8 +254,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git end end - context 'for Issue comment edited actions' do - it_behaves_like 'a daily tracked issuable event' do + context 'for Issue comment edited actions', :snowplow do + it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do let(:action) { described_class::ISSUE_COMMENT_EDITED } def track_action(params) @@ -259,8 +264,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git end end - context 'for Issue comment removed actions' do - it_behaves_like 'a daily tracked issuable event' do + context 'for Issue comment removed actions', :snowplow do + it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do let(:action) { described_class::ISSUE_COMMENT_REMOVED } def track_action(params) diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 53b75a3c991..ed64663260e 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -69,20 +69,31 @@ RSpec.describe Notes::CreateService do end end - it 'tracks issue comment usage data', :clean_gitlab_redis_shared_state do - event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED - counter = Gitlab::UsageDataCounters::HLLRedisCounter + describe 'event tracking', :snowplow do + let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED } + let(:execute_create_service) { described_class.new(project, user, opts).execute } - expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_added_action).with(author: user).and_call_original - expect do - described_class.new(project, user, opts).execute - end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) - end + it 'tracks issue comment usage data', :clean_gitlab_redis_shared_state do + counter = Gitlab::UsageDataCounters::HLLRedisCounter - it 'does not track merge request usage data' do - expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_create_comment_action) + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_added_action) + .with(author: user, project: project) + .and_call_original + expect do + execute_create_service + end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) + end - described_class.new(project, user, opts).execute + it 'does not track merge request usage data' do + expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_create_comment_action) + + execute_create_service + end + + it_behaves_like 'issue_edit snowplow tracking' do + let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED } + subject(:service_action) { execute_create_service } + end end context 'in a merge request' do diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb index 55acdabef82..be95a4bb181 100644 --- a/spec/services/notes/destroy_service_spec.rb +++ b/spec/services/notes/destroy_service_spec.rb @@ -25,15 +25,25 @@ RSpec.describe Notes::DestroyService do .to change { user.todos_pending_count }.from(1).to(0) end - it 'tracks issue comment removal usage data', :clean_gitlab_redis_shared_state do - note = create(:note, project: project, noteable: issue) - event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED - counter = Gitlab::UsageDataCounters::HLLRedisCounter + describe 'comment removed event tracking', :snowplow do + let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED } + let(:note) { create(:note, project: project, noteable: issue) } + let(:service_action) { described_class.new(project, user).execute(note) } - expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_removed_action).with(author: user).and_call_original - expect do - described_class.new(project, user).execute(note) - end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) + it 'tracks issue comment removal usage data', :clean_gitlab_redis_shared_state do + counter = Gitlab::UsageDataCounters::HLLRedisCounter + + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_removed_action) + .with(author: user, project: project) + .and_call_original + expect do + service_action + end.to change { counter.unique_events(event_names: property, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) + end + + it_behaves_like 'issue_edit snowplow tracking' do + subject(:execute_service_action) { service_action } + end end it 'tracks merge request usage data' do diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index ae7bea30944..989ca7b8df1 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -47,21 +47,31 @@ RSpec.describe Notes::UpdateService do end end - it 'does not track usage data when params is blank' do - expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_comment_edited_action) - expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_edit_comment_action) + describe 'event tracking', :snowplow do + let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED } - update_note({}) - end + it 'does not track usage data when params is blank' do + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_comment_edited_action) + expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_edit_comment_action) - it 'tracks issue usage data', :clean_gitlab_redis_shared_state do - event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED - counter = Gitlab::UsageDataCounters::HLLRedisCounter + update_note({}) + end - expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_edited_action).with(author: user).and_call_original - expect do - update_note(note: 'new text') - end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) + it 'tracks issue usage data', :clean_gitlab_redis_shared_state do + counter = Gitlab::UsageDataCounters::HLLRedisCounter + + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_edited_action) + .with(author: user, project: project) + .and_call_original + expect do + update_note(note: 'new text') + end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) + end + + it_behaves_like 'issue_edit snowplow tracking' do + let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED } + subject(:service_action) { update_note(note: 'new text') } + end end context 'when note text was changed' do diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb index 70f6ce8926c..d0e68bf0ddb 100644 --- a/spec/services/system_notes/issuables_service_spec.rb +++ b/spec/services/system_notes/issuables_service_spec.rb @@ -712,15 +712,20 @@ RSpec.describe ::SystemNotes::IssuablesService do end end - context 'cloned to' do + context 'cloned to', :snowplow do let(:direction) { :to } it 'tracks usage' do expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter) - .to receive(:track_issue_cloned_action).with(author: author) + .to receive(:track_issue_cloned_action).with(author: author, project: project ) subject end + + it_behaves_like 'issue_edit snowplow tracking' do + let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_CLONED } + let(:user) { author } + end end end end diff --git a/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb index c2b26d4decd..481e11bcf0e 100644 --- a/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb @@ -74,12 +74,10 @@ RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events end end -RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events' do +RSpec.shared_examples 'daily tracked issuable snowplow and service ping events with project' do it_behaves_like 'a daily tracked issuable snowplow and service ping events for given event params' do - let_it_be(:track_params) { { project: project } } - let_it_be(:event_params) { track_params.merge(namespace: project.namespace) } - let_it_be(:category) { 'issues_edit' } - let_it_be(:event_action) { action } + let(:track_params) { { project: project } } + let(:event_params) { track_params.merge(label: event_label, property: event_property, namespace: project.namespace) } end end diff --git a/spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb b/spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb new file mode 100644 index 00000000000..0687be6f429 --- /dev/null +++ b/spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +shared_examples 'issue_edit snowplow tracking' do + let(:category) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_CATEGORY } + let(:action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_ACTION } + let(:label) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_LABEL } + let(:namespace) { project.namespace } + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + + it_behaves_like 'Snowplow event tracking' +end diff --git a/tooling/bin/qa/run_qa_check b/tooling/bin/qa/run_qa_check index fa26a64f004..5b8844ec4fd 100755 --- a/tooling/bin/qa/run_qa_check +++ b/tooling/bin/qa/run_qa_check @@ -32,7 +32,7 @@ diffs_dir.glob('**/*').each do |path| next unless path.to_s.end_with?('_spec.rb.diff') specs_count += 1 - quarantine_specs_count += 1 if path.read.match?(/^\+.*, quarantine:/) + quarantine_specs_count += 1 if path.read.match?(/^\+.*,? quarantine:/) end # Run QA tests if there are no specs. E.g., when the MR changes QA framework files.