From e095d1e1c4df539fb3a1f61221a99338ee7e7d49 Mon Sep 17 00:00:00 2001 From: "ankit.panchal" Date: Mon, 7 Apr 2025 10:44:52 +0530 Subject: [PATCH 1/4] Add banner to inform customers of the option to pre-opt out Add banner to inform customers of the option to pre-opt out Add unit test cases add event_data file worked on reviewer feedback Fixed prettier formatting Update index.md file Update text to use turn off instead of disable Worked on reviewer feedback Add shared example test case Added event data file contents Fixing errors in event data file Add specs for issues, projects and todos update shared example --- .../javascripts/persistent_user_callouts.js | 1 + app/helpers/users/callouts_helper.rb | 9 +++ app/models/users/callout.rb | 3 +- app/views/dashboard/activity.html.haml | 1 + app/views/dashboard/groups/index.html.haml | 2 + app/views/dashboard/issues.html.haml | 2 + app/views/dashboard/merge_requests.html.haml | 2 + app/views/dashboard/projects/index.html.haml | 1 + app/views/dashboard/todos/index.html.haml | 1 + app/views/explore/groups/index.html.haml | 1 + app/views/explore/projects/_head.html.haml | 1 + app/views/explore/projects/topic.html.haml | 1 + app/views/explore/projects/topics.html.haml | 1 + ..._data_collection_changes_callout.html.haml | 10 +++ doc/administration/settings/event_data.md | 65 +++++++++++++++++++ doc/api/graphql/reference/_index.md | 1 + locale/gitlab.pot | 9 +++ spec/features/dashboard/activity_spec.rb | 2 + spec/features/dashboard/group_spec.rb | 3 + spec/features/dashboard/issues_spec.rb | 4 ++ .../features/dashboard/merge_requests_spec.rb | 3 + spec/features/dashboard/projects_spec.rb | 3 + spec/features/dashboard/todos/todos_spec.rb | 4 ++ spec/helpers/users/callouts_helper_spec.rb | 58 +++++++++++++++++ ...t_usage_data_collection_shared_examples.rb | 18 +++++ 25 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 app/views/shared/_product_usage_data_collection_changes_callout.html.haml create mode 100644 doc/administration/settings/event_data.md create mode 100644 spec/support/shared_examples/product_usage_data_collection_shared_examples.rb diff --git a/app/assets/javascripts/persistent_user_callouts.js b/app/assets/javascripts/persistent_user_callouts.js index fe6073e8d56004..2fb0458227facf 100644 --- a/app/assets/javascripts/persistent_user_callouts.js +++ b/app/assets/javascripts/persistent_user_callouts.js @@ -33,6 +33,7 @@ const PERSISTENT_USER_CALLOUTS = [ '.gcp-signup-offer', '.js-gold-trial-callout', '.js-namespace-user-cap-reached-alert', + '.js-data-collection-callout', ]; const initCallouts = () => { diff --git a/app/helpers/users/callouts_helper.rb b/app/helpers/users/callouts_helper.rb index f060f3cefa2f5c..c0782de15dff48 100644 --- a/app/helpers/users/callouts_helper.rb +++ b/app/helpers/users/callouts_helper.rb @@ -19,6 +19,15 @@ module CalloutsHelper TRANSITION_TO_JIHU_CALLOUT = 'transition_to_jihu_callout' PERIOD_IN_TERRAFORM_STATE_NAME_ALERT = 'period_in_terraform_state_name_alert' NEW_MR_DASHBOARD_BANNER = 'new_mr_dashboard_banner' + PRODUCT_USAGE_DATA_COLLECTION_CHANGES = 'product_usage_data_collection_changes' + + def render_product_usage_data_collection_changes(current_user) + return unless current_user && + current_user.can_admin_all_resources? && + !user_dismissed?(PRODUCT_USAGE_DATA_COLLECTION_CHANGES) + + render 'shared/product_usage_data_collection_changes_callout' + end def show_gke_cluster_integration_callout?(project) active_nav_link?(controller: sidebar_operations_paths) && diff --git a/app/models/users/callout.rb b/app/models/users/callout.rb index 2b0c0cb828daa7..a10a9023b5b99d 100644 --- a/app/models/users/callout.rb +++ b/app/models/users/callout.rb @@ -103,7 +103,8 @@ class Callout < ApplicationRecord new_merge_request_dashboard_welcome: 99, pipeline_inputs_announcement_banner: 100, pipeline_new_inputs_adoption_banner: 101, - pipeline_schedules_inputs_adoption_banner: 102 + pipeline_schedules_inputs_adoption_banner: 102, + product_usage_data_collection_changes: 103 } validates :feature_name, diff --git a/app/views/dashboard/activity.html.haml b/app/views/dashboard/activity.html.haml index ff9f13ba2de4ec..5013bff6e0441b 100644 --- a/app/views/dashboard/activity.html.haml +++ b/app/views/dashboard/activity.html.haml @@ -2,6 +2,7 @@ = auto_discovery_link_tag(:atom, dashboard_projects_url(rss_url_options), title: "All activity") = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) - page_title _("Activity") diff --git a/app/views/dashboard/groups/index.html.haml b/app/views/dashboard/groups/index.html.haml index 9af1ae21b07770..bd109c2771ca82 100644 --- a/app/views/dashboard/groups/index.html.haml +++ b/app/views/dashboard/groups/index.html.haml @@ -1,6 +1,8 @@ - page_title _("Groups") = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) + - if Feature.enabled?(:your_work_groups_vue, current_user) = render 'dashboard/groups_head' #js-your-work-groups-app{ data: { app_data: groups_list_with_filtered_search_app_data(dashboard_groups_path(format: :json)) } } diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index cae3d58abacaa2..64d2544f77ebba 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -6,6 +6,8 @@ = auto_discovery_link_tag(:atom, safe_params.merge(rss_url_options).to_h, title: "#{current_user.name} issues") = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) + = render_if_exists 'shared/dashboard/saml_reauth_notice', groups_requiring_saml_reauth: user_groups_requiring_reauth diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml index 34ec2cc8104fa8..c8c9feffb026ef 100644 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -5,6 +5,8 @@ add_page_specific_style 'page_bundles/issuable_list' = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) + = render_if_exists 'shared/dashboard/saml_reauth_notice', groups_requiring_saml_reauth: user_groups_requiring_reauth diff --git a/app/views/dashboard/projects/index.html.haml b/app/views/dashboard/projects/index.html.haml index ecdb2d1e79319c..1ee57245546e1e 100644 --- a/app/views/dashboard/projects/index.html.haml +++ b/app/views/dashboard/projects/index.html.haml @@ -2,6 +2,7 @@ = auto_discovery_link_tag(:atom, dashboard_projects_url(rss_url_options), title: "All activity") = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) - page_title _("Projects") - add_page_specific_style 'page_bundles/dashboard_projects' diff --git a/app/views/dashboard/todos/index.html.haml b/app/views/dashboard/todos/index.html.haml index 6b89ba5507b4f9..bdcbeacd16a5e5 100644 --- a/app/views/dashboard/todos/index.html.haml +++ b/app/views/dashboard/todos/index.html.haml @@ -3,6 +3,7 @@ = render_two_factor_auth_recovery_settings_check = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) - if current_user.todos.any? = render ::Layouts::PageHeadingComponent.new(_('To-Do List')) diff --git a/app/views/explore/groups/index.html.haml b/app/views/explore/groups/index.html.haml index 41c4048bf39690..0c9ce670657c94 100644 --- a/app/views/explore/groups/index.html.haml +++ b/app/views/explore/groups/index.html.haml @@ -3,6 +3,7 @@ - header_title _("Groups"), dashboard_groups_path = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) .page-title-holder.gl-flex.gl-align-items %div diff --git a/app/views/explore/projects/_head.html.haml b/app/views/explore/projects/_head.html.haml index 16825d9648d236..e0c23fac5f45fd 100644 --- a/app/views/explore/projects/_head.html.haml +++ b/app/views/explore/projects/_head.html.haml @@ -2,6 +2,7 @@ - page_title _("Explore projects") = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) .page-title-holder.gl-flex.gl-items-center{ data: { testid: 'explore-projects-title' } } %h1.page-title.gl-text-size-h-display= page_title diff --git a/app/views/explore/projects/topic.html.haml b/app/views/explore/projects/topic.html.haml index 224b6530f2e288..9907f617ca487b 100644 --- a/app/views/explore/projects/topic.html.haml +++ b/app/views/explore/projects/topic.html.haml @@ -4,6 +4,7 @@ - max_topic_title_length = 50 = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) %div{ class: container_class } = render ::Layouts::PageHeadingComponent.new(_('Topics')) do |c| diff --git a/app/views/explore/projects/topics.html.haml b/app/views/explore/projects/topics.html.haml index 05253c1b4eeb1c..27d45d87148d05 100644 --- a/app/views/explore/projects/topics.html.haml +++ b/app/views/explore/projects/topics.html.haml @@ -5,6 +5,7 @@ - show_empty_state = @topics.empty? && !search = render_dashboard_ultimate_trial(current_user) += render_product_usage_data_collection_changes(current_user) - if show_empty_state = render 'shared/empty_states/topics' diff --git a/app/views/shared/_product_usage_data_collection_changes_callout.html.haml b/app/views/shared/_product_usage_data_collection_changes_callout.html.haml new file mode 100644 index 00000000000000..b9e8612f5cf76d --- /dev/null +++ b/app/views/shared/_product_usage_data_collection_changes_callout.html.haml @@ -0,0 +1,10 @@ +- callout = Users::CalloutsHelper::PRODUCT_USAGE_DATA_COLLECTION_CHANGES +- documentation_link = link_to '', help_page_path('administration/settings/usage_statistics.md'), target: '_blank', rel: 'noopener noreferrer', data: { track_action: 'click_link', track_label: 'documentation', track_property: 'product_usage_data_collection_banner' } + += render Pajamas::BannerComponent.new(svg_path: 'illustrations/gitlab_logo.svg', banner_options: { class: 'gl-mt-6 js-data-collection-callout', data: { track_action: 'render', track_label: 'product_usage_data_collection_banner', uid: 'product_usage_data_collection_dismissed', feature_id: callout, dismiss_endpoint: callouts_path, testid: 'product-usage-data-collection-banner' } }, close_options: { class: 'js-close', data: { track_action: 'dismiss_banner', track_label: 'product_usage_data_collection_banner' }, 'aria-label': s_('ProductUsageData|Dismiss product usage data collection notice') }) do |c| + - c.with_title do + = s_('ProductUsageData|Review data collection changes coming in GitLab 18.0') + - c.with_primary_action do + = nil + %p + = safe_format(s_('ProductUsageData|Starting with 18.0, GitLab will collect event-level product usage data from Self-Managed and Dedicated instances — while ensuring privacy, transparency, and customer control. GitLab administrators can turn off the data collection toggle before any data is collected in version 18.0. For more information about this change and how you can opt out, see the %{link_start}documentation%{link_end}'), tag_pair(documentation_link, :link_start, :link_end)) diff --git a/doc/administration/settings/event_data.md b/doc/administration/settings/event_data.md new file mode 100644 index 00000000000000..33060b22b59f9f --- /dev/null +++ b/doc/administration/settings/event_data.md @@ -0,0 +1,65 @@ +--- +stage: Monitor +group: Analytics Instrumentation +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments +title: Event data +--- + +{{< details >}} + +- Tier: Free, Premium, Ultimate +- Offering: GitLab Self-Managed, GitLab Dedicated + +{{< /details >}} + +{{< history >}} + +- Toggle [enabled](https://gitlab.com/gitlab-org/gitlab/-/issues/510333) in GitLab 17.11. + +{{< /history >}} + +## Data tracking for product usage at event level + +For more information about changes to product usage data collection, read the blog post +[More granular product usage insights for GitLab Self-Managed and Dedicated](https://about.gitlab.com/blog/2025/03/26/more-granular-product-usage-insights-for-gitlab-self-managed-and-dedicated/). + +### Event data + +Event data tracks interactions (or actions) within the GitLab platform. +These interactions or actions could be user initiated such as initiating CI/CD pipelines, merging a merge request, triggering a webhook, or creating an issue. +Actions can also result from background system processing like scheduled pipeline succeeding. +The focus of event data collection is on the users' actions and the metadata associated with those actions. + +User IDs are pseudonymized to protect privacy, and GitLab does not undertake any processes to re-identify or associate the metrics with individual users. +Event data does not include source code or other customer-created content stored within GitLab. + +For more information, see also: + +- [Internal events payload samples](../../development/internal_analytics/internal_event_instrumentation/internal_events_payload.md) +- [Metrics dictionary](https://metrics.gitlab.com/?status=active) for a list of events and metrics +- [Customer product usage information](https://handbook.gitlab.com/handbook/legal/privacy/customer-product-usage-information/) for data privacy policy + +### Benefits of event data + +Event-level data enhances several benefits of Service Ping by offering more granular insights without identifying users. + +- Proactive support: Granular data allows our Customer Success Managers (CSMs) and support teams to access more detailed information, enabling them to drill down and create custom metrics tailored to your organization's unique needs, rather than relying on more generic, aggregated metrics. +- Targeted guidance: Event-level data provides a deeper understanding of how features are used, helping us uncover opportunities for optimization and improvement. The depth of data allows us to offer more precise, actionable recommendations to help you maximize the value of GitLab and enhance your workflows. +- Anonymized benchmarking reports: Granular event data enables more accurate and relevant performance comparisons with similar organizations by focusing on detailed usage patterns, rather than just high-level aggregated data. + +### Enable or disable event-level data collection + +{{< alert type="note" >}} + +If Snowplow tracking is enabled, it will be automatically disabled when you enable product usage tracking. Only one data collection method can be active at a time. + +{{< /alert >}} + +To enable or disable event-level data collection: + +1. Sign in as a user with administrator access. +1. On the left sidebar, at the bottom, select **Admin**. +1. Select **Settings > Metrics and Profiling**. +1. Expand **Event tracking**. +1. To enable the setting, select the checkbox **Enable event tracking**. To disable the setting, clear the checkbox. +1. Select **Save changes**. diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index 98ce5d074f6fe3..cdde9a78718dc6 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -44946,6 +44946,7 @@ Name of the feature that the callout is for. | `PLANNER_ROLE_CALLOUT` | Callout feature name for planner_role_callout. | | `PREVIEW_USER_OVER_LIMIT_FREE_PLAN_ALERT` | Callout feature name for preview_user_over_limit_free_plan_alert. | | `PRODUCT_ANALYTICS_DASHBOARD_FEEDBACK` | Callout feature name for product_analytics_dashboard_feedback. | +| `PRODUCT_USAGE_DATA_COLLECTION_CHANGES` | Callout feature name for product_usage_data_collection_changes. | | `PROFILE_PERSONAL_ACCESS_TOKEN_EXPIRY` | Callout feature name for profile_personal_access_token_expiry. | | `PROJECT_QUALITY_SUMMARY_FEEDBACK` | Callout feature name for project_quality_summary_feedback. | | `PROJECT_REPOSITORY_LIMIT_ALERT_WARNING_THRESHOLD` | Callout feature name for project_repository_limit_alert_warning_threshold. | diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 69607247caaa7c..5f2bc02ff3d2e4 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -45779,6 +45779,15 @@ msgstr "" msgid "ProductAnalytics|Your instance will be created on this provider:" msgstr "" +msgid "ProductUsageData|Dismiss product usage data collection notice" +msgstr "" + +msgid "ProductUsageData|Review data collection changes coming in GitLab 18.0" +msgstr "" + +msgid "ProductUsageData|Starting with 18.0, GitLab will collect event-level product usage data from Self-Managed and Dedicated instances — while ensuring privacy, transparency, and customer control. GitLab administrators can turn off the data collection toggle before any data is collected in version 18.0. For more information about this change and how you can opt out, see the %{link_start}documentation%{link_end}" +msgstr "" + msgid "Productivity" msgstr "" diff --git a/spec/features/dashboard/activity_spec.rb b/spec/features/dashboard/activity_spec.rb index fd1e5a34f05329..a27e574217607c 100644 --- a/spec/features/dashboard/activity_spec.rb +++ b/spec/features/dashboard/activity_spec.rb @@ -4,11 +4,13 @@ RSpec.describe 'Dashboard > Activity', :js, feature_category: :user_profile do let(:user) { create(:user) } + let(:page_path) { activity_dashboard_path } before do sign_in(user) end + it_behaves_like 'page with product usage data collection banner' it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :activity_dashboard_path, :activity context 'tabs' do diff --git a/spec/features/dashboard/group_spec.rb b/spec/features/dashboard/group_spec.rb index 06922565d5372f..594cb6a4869736 100644 --- a/spec/features/dashboard/group_spec.rb +++ b/spec/features/dashboard/group_spec.rb @@ -5,11 +5,14 @@ RSpec.describe 'Dashboard Group', :with_current_organization, :js, feature_category: :groups_and_projects do let(:user) { create(:user) } let(:group) { create(:group) } + let(:page_path) { dashboard_groups_path } before do current_organization.users << user end + it_behaves_like 'page with product usage data collection banner' + context 'when user has no groups' do before do sign_in(user) diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 60b1a7d78fb0a8..c6ee67e9601223 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -23,6 +23,10 @@ it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :issues_dashboard_path, :issues + it_behaves_like 'page with product usage data collection banner' do + let(:page_path) { issues_dashboard_path } + end + context 'for accessibility testing' do let_it_be(:detailed_assigned_issue) do create :issue, diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb index f69ef2b1dfc83c..0756907fbc4db2 100644 --- a/spec/features/dashboard/merge_requests_spec.rb +++ b/spec/features/dashboard/merge_requests_spec.rb @@ -13,12 +13,15 @@ let(:public_project) { create(:project, :public, :repository) } let(:forked_project) { fork_project(public_project, current_user, repository: true) } + let(:page_path) { merge_requests_dashboard_path(assignee_username: [user.username]) } before do project.add_maintainer(current_user) sign_in(current_user) end + it_behaves_like 'page with product usage data collection banner' + describe 'sidebar' do it 'has nav items for assigned MRs and review requests' do visit merge_requests_dashboard_path(assignee_username: user) diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 14e443cbf4684d..aa5d23d3220f15 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -31,6 +31,9 @@ end it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_projects_path, :projects + it_behaves_like 'page with product usage data collection banner' do + let(:page_path) { dashboard_projects_path } + end it 'links to the "Explore projects" page' do visit dashboard_projects_path diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb index e8ad39a31292a2..cf1ff984ca486f 100644 --- a/spec/features/dashboard/todos/todos_spec.rb +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -21,6 +21,10 @@ it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_todos_path, :todos + it_behaves_like 'dashboard product usage data collection changes callout' do + let(:page_path) { dashboard_todos_path } + end + context 'when the todo references a merge request' do let(:referenced_mr) { create(:merge_request, source_project: project) } let(:note) { create(:note, project: project, note: "Check out #{referenced_mr.to_reference}", noteable: create(:issue, project: project)) } diff --git a/spec/helpers/users/callouts_helper_spec.rb b/spec/helpers/users/callouts_helper_spec.rb index f84c2f1609d329..4a976b63f000a1 100644 --- a/spec/helpers/users/callouts_helper_spec.rb +++ b/spec/helpers/users/callouts_helper_spec.rb @@ -304,4 +304,62 @@ it { is_expected.to be false } end end + + describe '.render_product_usage_data_collection_changes', :do_not_mock_admin_mode_setting do + let_it_be(:admin) { create(:user, :admin) } + + subject(:render_callout) { helper.render_product_usage_data_collection_changes(current_user) } + + context 'when current_user is nil' do + let(:current_user) { nil } + + it 'does not render the callout' do + expect(helper).not_to receive(:render) + render_callout + end + end + + context 'when current_user is not an admin' do + let(:current_user) { user } + + before do + allow(user).to receive(:can_admin_all_resources?).and_return(false) + end + + it 'does not render the callout' do + expect(helper).not_to receive(:render) + render_callout + end + end + + context 'when current_user is admin but has dismissed the callout' do + let(:current_user) { admin } + + before do + allow(admin).to receive(:can_admin_all_resources?).and_return(true) + allow(helper).to receive(:user_dismissed?) + .with(described_class::PRODUCT_USAGE_DATA_COLLECTION_CHANGES).and_return(true) + end + + it 'does not render the callout' do + expect(helper).not_to receive(:render) + render_callout + end + end + + context 'when current_user is admin and has not dismissed the callout' do + let(:current_user) { admin } + + before do + allow(admin).to receive(:can_admin_all_resources?).and_return(true) + allow(helper).to receive(:user_dismissed?) + .with(described_class::PRODUCT_USAGE_DATA_COLLECTION_CHANGES).and_return(false) + end + + it 'renders the callout' do + expect(helper).to receive(:render).with('shared/product_usage_data_collection_changes_callout') + render_callout + end + end + end end diff --git a/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb b/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb new file mode 100644 index 00000000000000..d29e8930aab0aa --- /dev/null +++ b/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'page with product usage data collection banner' do + before do + sign_in(user) + end + + it 'hides product usage data collection callout if user has dismissed it' do + allow(user).to receive(:dismissed_callout?).with( + feature_name: Users::CalloutsHelper::PRODUCT_USAGE_DATA_COLLECTION_CHANGES, + ignore_dismissal_earlier_than: nil + ).and_return(true) + + visit page_path + + expect(page).not_to have_selector '[data-testid="product-usage-data-collection-banner"]' + end +end -- GitLab From f8efa7f1ac27ca472d71a1daa8a0bf27f22b0060 Mon Sep 17 00:00:00 2001 From: "ankit.panchal" Date: Wed, 9 Apr 2025 13:51:23 +0530 Subject: [PATCH 2/4] added todos spec and updated shared example --- spec/features/dashboard/todos/todos_spec.rb | 2 +- ...t_usage_data_collection_shared_examples.rb | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb index cf1ff984ca486f..a60ec9f90f60d3 100644 --- a/spec/features/dashboard/todos/todos_spec.rb +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -21,7 +21,7 @@ it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_todos_path, :todos - it_behaves_like 'dashboard product usage data collection changes callout' do + it_behaves_like 'page with product usage data collection banner' do let(:page_path) { dashboard_todos_path } end diff --git a/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb b/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb index d29e8930aab0aa..ae1fb941a99305 100644 --- a/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb +++ b/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb @@ -3,16 +3,31 @@ RSpec.shared_examples 'page with product usage data collection banner' do before do sign_in(user) + allow(user).to receive(:can_admin_all_resources?).and_return(true) end it 'hides product usage data collection callout if user has dismissed it' do - allow(user).to receive(:dismissed_callout?).with( - feature_name: Users::CalloutsHelper::PRODUCT_USAGE_DATA_COLLECTION_CHANGES, - ignore_dismissal_earlier_than: nil - ).and_return(true) + allow(user).to receive(:dismissed_callout?).and_return(true) # <<< CHANGE HERE visit page_path expect(page).not_to have_selector '[data-testid="product-usage-data-collection-banner"]' end + + it 'shows dismissable product usage data collection callout if not dismissed yet', :js do + allow(user).to receive(:dismissed_callout?).and_return(false) # <<< CHANGE HERE + + visit page_path + + expect(page).to have_selector '[data-testid="product-usage-data-collection-banner"]' + + page.within('[data-testid="product-usage-data-collection-banner"]') do + expect(page).to have_selector('[data-track-action=dismiss_banner]') + expect(page).to have_selector('[data-track-label=product_usage_data_collection_banner]') + + click_button "Dismiss product usage data collection notice" + end + + expect(page).not_to have_selector '[data-testid="product-usage-data-collection-banner"]' + end end -- GitLab From 09a1410fd1fbe6e22a298acda73519d8f2a282a8 Mon Sep 17 00:00:00 2001 From: "ankit.panchal" Date: Wed, 9 Apr 2025 14:39:33 +0530 Subject: [PATCH 3/4] Worked on failing test case issues_spec --- spec/features/dashboard/issues_spec.rb | 17 ++++++++++++++++- ...uct_usage_data_collection_shared_examples.rb | 7 ++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index c6ee67e9601223..b8f74255ef90a6 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -18,16 +18,23 @@ before do [project, project_with_issues_disabled].each { |project| project.add_maintainer(current_user) } sign_in(current_user) + end + + def visit_dashboard_issues visit issues_dashboard_path(assignee_username: current_user.username) end it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :issues_dashboard_path, :issues it_behaves_like 'page with product usage data collection banner' do - let(:page_path) { issues_dashboard_path } + let(:page_path) { issues_dashboard_path(assignee_username: user.username) } end context 'for accessibility testing' do + before do + visit_dashboard_issues + end + let_it_be(:detailed_assigned_issue) do create :issue, :closed, @@ -43,6 +50,10 @@ end describe 'issues' do + before do + visit_dashboard_issues + end + it 'shows issues assigned to current user' do expect(page).to have_content(assigned_issue.title) expect(page).not_to have_content(authored_issue.title) @@ -78,6 +89,10 @@ end describe 'new issue dropdown' do + before do + visit_dashboard_issues + end + it 'shows projects only with issues feature enabled' do click_button _('Select project to create issue') diff --git a/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb b/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb index ae1fb941a99305..703279371c9b30 100644 --- a/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb +++ b/spec/support/shared_examples/product_usage_data_collection_shared_examples.rb @@ -7,24 +7,21 @@ end it 'hides product usage data collection callout if user has dismissed it' do - allow(user).to receive(:dismissed_callout?).and_return(true) # <<< CHANGE HERE + allow(user).to receive(:dismissed_callout?).and_return(true) visit page_path - expect(page).not_to have_selector '[data-testid="product-usage-data-collection-banner"]' end it 'shows dismissable product usage data collection callout if not dismissed yet', :js do - allow(user).to receive(:dismissed_callout?).and_return(false) # <<< CHANGE HERE + allow(user).to receive(:dismissed_callout?).and_return(false) visit page_path - expect(page).to have_selector '[data-testid="product-usage-data-collection-banner"]' page.within('[data-testid="product-usage-data-collection-banner"]') do expect(page).to have_selector('[data-track-action=dismiss_banner]') expect(page).to have_selector('[data-track-label=product_usage_data_collection_banner]') - click_button "Dismiss product usage data collection notice" end -- GitLab From fa653c7c88724c4fa8f6ca833eba3182ee4423fa Mon Sep 17 00:00:00 2001 From: "ankit.panchal" Date: Wed, 9 Apr 2025 14:55:28 +0530 Subject: [PATCH 4/4] Updated link to event data --- .../_product_usage_data_collection_changes_callout.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_product_usage_data_collection_changes_callout.html.haml b/app/views/shared/_product_usage_data_collection_changes_callout.html.haml index b9e8612f5cf76d..9e675d1f65973f 100644 --- a/app/views/shared/_product_usage_data_collection_changes_callout.html.haml +++ b/app/views/shared/_product_usage_data_collection_changes_callout.html.haml @@ -1,5 +1,5 @@ - callout = Users::CalloutsHelper::PRODUCT_USAGE_DATA_COLLECTION_CHANGES -- documentation_link = link_to '', help_page_path('administration/settings/usage_statistics.md'), target: '_blank', rel: 'noopener noreferrer', data: { track_action: 'click_link', track_label: 'documentation', track_property: 'product_usage_data_collection_banner' } +- documentation_link = link_to '', help_page_path('administration/settings/event_data.md'), target: '_blank', rel: 'noopener noreferrer', data: { track_action: 'click_link', track_label: 'documentation', track_property: 'product_usage_data_collection_banner' } = render Pajamas::BannerComponent.new(svg_path: 'illustrations/gitlab_logo.svg', banner_options: { class: 'gl-mt-6 js-data-collection-callout', data: { track_action: 'render', track_label: 'product_usage_data_collection_banner', uid: 'product_usage_data_collection_dismissed', feature_id: callout, dismiss_endpoint: callouts_path, testid: 'product-usage-data-collection-banner' } }, close_options: { class: 'js-close', data: { track_action: 'dismiss_banner', track_label: 'product_usage_data_collection_banner' }, 'aria-label': s_('ProductUsageData|Dismiss product usage data collection notice') }) do |c| - c.with_title do -- GitLab