diff options
-rw-r--r-- | app/controllers/profiles_controller.rb | 10 | ||||
-rw-r--r-- | app/views/layouts/_individual_tracking.html.haml | 8 | ||||
-rw-r--r-- | app/views/layouts/_snowplow.html.haml | 2 | ||||
-rw-r--r-- | app/views/profiles/show.html.haml | 6 | ||||
-rw-r--r-- | db/migrate/20190806031802_add_tracking_consent_preference.rb | 20 | ||||
-rw-r--r-- | db/schema.rb | 1 |
6 files changed, 45 insertions, 2 deletions
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 1d16ddb1608..7c3c03adce1 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -87,7 +87,11 @@ class ProfilesController < Profiles::ApplicationController end def user_params - @user_params ||= params.require(:user).permit( + @user_params ||= params.require(:user).permit(user_params_attributes) + end + + def user_params_attributes + [ :avatar, :bio, :email, @@ -108,6 +112,8 @@ class ProfilesController < Profiles::ApplicationController :include_private_contributions, :timezone, status: [:emoji, :message] - ) + ] end end + +ProfilesController.prepend_if_ee('EE::ProfilesController') diff --git a/app/views/layouts/_individual_tracking.html.haml b/app/views/layouts/_individual_tracking.html.haml new file mode 100644 index 00000000000..a365705f1bd --- /dev/null +++ b/app/views/layouts/_individual_tracking.html.haml @@ -0,0 +1,8 @@ +- return unless Gitlab.com? +- return unless Feature.enabled?(:individual_tracking_consent, default_enabled: false) +- return unless current_user&.tracking_consent? + +:javascript + if (window.gon && window.gon.current_user_id) { + window.snowplow('setUserId', window.gon.current_user_id); + } diff --git a/app/views/layouts/_snowplow.html.haml b/app/views/layouts/_snowplow.html.haml index 5f5c5e984c5..4670094455c 100644 --- a/app/views/layouts/_snowplow.html.haml +++ b/app/views/layouts/_snowplow.html.haml @@ -21,6 +21,8 @@ window.snowplow('enableActivityTracking', 30, 30); window.snowplow('trackPageView'); += render 'layouts/individual_tracking' + - return unless Feature.enabled?(:additional_snowplow_tracking, @group) = javascript_tag nonce: true do diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index ffb90bbd354..5dae8b8d0e6 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -106,17 +106,23 @@ = f.text_field :location, label: s_('Profiles|Location'), class: 'input-lg', placeholder: s_("Profiles|City, country") = f.text_field :organization, label: s_('Profiles|Organization'), class: 'input-md', help: s_("Profiles|Who you represent or work for") = f.text_area :bio, label: s_('Profiles|Bio'), rows: 4, maxlength: 250, help: s_("Profiles|Tell us about yourself in fewer than 250 characters") + %hr + %h5= s_("Private profile") .checkbox-icon-inline-wrapper - private_profile_label = capture do = s_("Profiles|Don't display activity-related personal information on your profiles") = f.check_box :private_profile, label: private_profile_label, inline: true, wrapper_class: 'mr-0' = link_to icon('question-circle'), help_page_path('user/profile/index.md', anchor: 'private-profile') + %h5= s_("Profiles|Private contributions") = f.check_box :include_private_contributions, label: s_('Profiles|Include private contributions on my profile'), wrapper_class: 'mb-2', inline: true .help-block = s_("Profiles|Choose to show contributions of private projects on your public profile without any project, repository or organization information") + + = render_if_exists 'profiles/preferences/tracking_consent', f: f + .prepend-top-default.append-bottom-default = f.submit s_("Profiles|Update profile settings"), class: 'btn btn-success' = link_to _("Cancel"), user_path(current_user), class: 'btn btn-cancel' diff --git a/db/migrate/20190806031802_add_tracking_consent_preference.rb b/db/migrate/20190806031802_add_tracking_consent_preference.rb new file mode 100644 index 00000000000..11ff4112928 --- /dev/null +++ b/db/migrate/20190806031802_add_tracking_consent_preference.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddTrackingConsentPreference < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :user_preferences, :tracking_consent, :boolean, default: false + end + + def down + remove_column :user_preferences, :tracking_consent + end +end diff --git a/db/schema.rb b/db/schema.rb index 3f7917654cf..670e1b95670 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -3412,6 +3412,7 @@ ActiveRecord::Schema.define(version: 2019_08_15_093949) do t.integer "roadmap_epics_state" t.string "roadmaps_sort" t.string "projects_sort", limit: 64 + t.boolean "tracking_consent", default: false, null: false t.index ["user_id"], name: "index_user_preferences_on_user_id", unique: true end |