diff --git a/app/views/devise/shared/_signup_box_form.html.haml b/app/views/devise/shared/_signup_box_form.html.haml index 33b364965db0852b503d9444fdab73e6a2b39d7a..af5ec45687268daae919a3bed33ce8befd8f8331 100644 --- a/app/views/devise/shared/_signup_box_form.html.haml +++ b/app/views/devise/shared/_signup_box_form.html.haml @@ -20,10 +20,14 @@ .form-group = label_tag :signup_intent, s_('SignUp|I want to...') = select_tag :signup_intent, - options_for_select([[s_('SignUp|Set up a new team'), :new_team], - [s_('SignUp|Set up a new personal account'), :new_personal_account], - [s_('SignUp|Join an existing team'), :join_existing_team], - [s_('SignUp|Contribute to a public project on GitLab'), :contribute_public_project]]), + options_for_select([[s_('SignUp|Set up a new team'), + :select_signup_intent_dropdown_new_team_registration_step_one], + [s_('SignUp|Set up a new personal account'), + :select_signup_intent_dropdown_new_personal_account_registration_step_one], + [s_('SignUp|Join an existing team'), + :select_signup_intent_dropdown_join_existing_team_registration_step_one], + [s_('SignUp|Contribute to a public project on GitLab'), + :select_signup_intent_dropdown_contribute_public_project_registration_step_one]]), prompt: s_('SignUp|Please select an option...'), class: 'gl-form-select custom-select', required: true diff --git a/ee/app/controllers/ee/registrations_controller.rb b/ee/app/controllers/ee/registrations_controller.rb index b1dfc2d9bd3162118447384a3727f875a5a77a76..35da0c32c9ba30cef135f1746a1f77460ce22bc4 100644 --- a/ee/app/controllers/ee/registrations_controller.rb +++ b/ee/app/controllers/ee/registrations_controller.rb @@ -110,6 +110,11 @@ def after_successful_create_hook(user) .new(onboarding_status_params, session, resource, onboarding_first_step_path).execute log_audit_event(user) + + return unless params[:signup_intent].present? + + experiment(:signup_intent_step_one, actor: user) + .track(params[:signup_intent], label: registration_tracking_label) end override :set_resource_fields diff --git a/ee/app/controllers/registrations/welcome_controller.rb b/ee/app/controllers/registrations/welcome_controller.rb index 30d826abf77e494d2472bc4c34644fbdda27a640..0202d2f8b1f4498285bd5cf553ea1246e126d666 100644 --- a/ee/app/controllers/registrations/welcome_controller.rb +++ b/ee/app/controllers/registrations/welcome_controller.rb @@ -25,7 +25,9 @@ def show # calling this in the controller layer gives us access to request where the # signed cookie exist with the info we need for migration. experiment(:signup_intent_step_one, actor: current_user).run - experiment(:signup_intent_step_one, actor: current_user).track(:show, label: :welcome) + + experiment(:signup_intent_step_one, actor: current_user) + .track(:render_welcome, label: onboarding_status.tracking_label) track_event('render') end diff --git a/ee/app/controllers/trial_registrations_controller.rb b/ee/app/controllers/trial_registrations_controller.rb index 223abf135e0a0395f2269d819d79142701dcbae6..e967cb501ab86615ad1f888c71f4230727e5365a 100644 --- a/ee/app/controllers/trial_registrations_controller.rb +++ b/ee/app/controllers/trial_registrations_controller.rb @@ -62,16 +62,6 @@ def resource @resource ||= Users::AuthorizedBuildService.new(current_user, sign_up_params).execute end - override :after_successful_create_hook - def after_successful_create_hook(user) - super - - return unless params[:signup_intent].present? - - experiment(:signup_intent_step_one, actor: user).track(:submitted_intent, label: :signup_intent, - property: params[:signup_intent]) - end - override :registration_tracking_label def registration_tracking_label ::Onboarding::Status::TRACKING_LABEL[:trial] diff --git a/ee/app/controllers/users/base_identity_verification_controller.rb b/ee/app/controllers/users/base_identity_verification_controller.rb index 36a0c4be7f8fe1e29c548632aa6c3b412ce7d104..5d4e07acce8cc545999923e7ef541a7432947a11 100644 --- a/ee/app/controllers/users/base_identity_verification_controller.rb +++ b/ee/app/controllers/users/base_identity_verification_controller.rb @@ -24,12 +24,6 @@ class BaseIdentityVerificationController < ApplicationController def show push_frontend_feature_flag(:auto_request_phone_number_verification_exemption, @user, type: :gitlab_com_derisk) - - # We need to perform cookie migration for tracking from logged out to log in - # calling this before tracking gives us access to request where the - # signed cookie exist with the info we need for migration. - experiment(:signup_intent_step_one, actor: @user).run - experiment(:signup_intent_step_one, actor: @user).track(:show, label: :identity_verification) end def restricted diff --git a/ee/app/controllers/users/registrations_identity_verification_controller.rb b/ee/app/controllers/users/registrations_identity_verification_controller.rb index e9bab84cf371ad5a5427b77ebbd38194bca21407..1caaf08a5181982472f18a66714b7ebfcf1fdb64 100644 --- a/ee/app/controllers/users/registrations_identity_verification_controller.rb +++ b/ee/app/controllers/users/registrations_identity_verification_controller.rb @@ -13,6 +13,18 @@ class RegistrationsIdentityVerificationController < BaseIdentityVerificationCont before_action :require_arkose_verification!, except: [:arkose_labs_challenge, :verify_arkose_labs_session, :restricted] + def show + super + + # We need to perform cookie migration for tracking from logged out to log in + # calling this before tracking gives us access to request where the + # signed cookie exist with the info we need for migration. + experiment(:signup_intent_step_one, actor: @user).run + + experiment(:signup_intent_step_one, actor: @user) + .track(:render_identity_verification, label: onboarding_status.tracking_label) + end + def arkose_labs_challenge; end def verify_arkose_labs_session diff --git a/ee/spec/controllers/registrations/welcome_controller_spec.rb b/ee/spec/controllers/registrations/welcome_controller_spec.rb index 75b050a477b398c5374c5791c941317746920d8d..78f84832973e1cc3c08e3f52d81d1d3f1c0bf1a1 100644 --- a/ee/spec/controllers/registrations/welcome_controller_spec.rb +++ b/ee/spec/controllers/registrations/welcome_controller_spec.rb @@ -39,7 +39,7 @@ .and_return(experiment) expect(experiment).to receive(:run) - expect(experiment).to receive(:track).with(:show, label: :welcome) + expect(experiment).to receive(:track).with(:render_welcome, label: 'free_registration') get_show end diff --git a/ee/spec/requests/ee/registrations_controller_spec.rb b/ee/spec/requests/ee/registrations_controller_spec.rb index 6ca09bdf3a4a55cc84dab79f1d26e0cb275d5dc0..10ea0849ddee72bd70d4d19aec53536350ec5c68 100644 --- a/ee/spec/requests/ee/registrations_controller_spec.rb +++ b/ee/spec/requests/ee/registrations_controller_spec.rb @@ -326,5 +326,46 @@ end end end + + context 'for signup_intent_step_one experiment' do + let(:experiment) { instance_double(ApplicationExperiment) } + + before do + allow_next_instance_of(described_class) do |controller| + allow(controller) + .to receive(:experiment) + .with(:signup_intent_step_one, actor: instance_of(User)) + .and_return(experiment) + end + end + + context 'when signup_intent is not provided' do + it 'does not tracks signup_intent_step_one experiment event' do + expect(experiment).not_to receive(:track) + + create_user + end + end + + context 'when signup intent is provided' do + let(:params) do + { + user: user_attrs, + signup_intent: 'select_signup_intent_dropdown_new_team_registration_step_one' + } + end + + subject(:create_user) { post user_registration_path, params: params } + + it 'tracks signup_intent_step_one experiment events' do + expect(experiment).to receive(:track).with( + 'select_signup_intent_dropdown_new_team_registration_step_one', + label: 'free_registration' + ) + + create_user + end + end + end end end diff --git a/ee/spec/requests/trial_registrations_controller_spec.rb b/ee/spec/requests/trial_registrations_controller_spec.rb index a457aa4f419f6840a8285e80e3aa68b2486f058c..07d354e3f6bc5d8d41b3e57bd54a85665670f2c3 100644 --- a/ee/spec/requests/trial_registrations_controller_spec.rb +++ b/ee/spec/requests/trial_registrations_controller_spec.rb @@ -189,24 +189,32 @@ allow_next_instance_of(described_class) do |controller| allow(controller) .to receive(:experiment) - .with(:signup_intent_step_one, actor: instance_of(User)) - .and_return(experiment) + .with(:signup_intent_step_one, actor: instance_of(User)) + .and_return(experiment) end end context 'when signup_intent is not provided' do it 'does not tracks signup_intent_step_one experiment event' do - expect(experiment).not_to receive(:track).with(:submitted_intent) + expect(experiment).not_to receive(:track) post_create end end context 'when signup intent is provided' do - let(:params) { { user: user_params, signup_intent: "new_team" } } + let(:params) do + { + user: user_params, + signup_intent: 'select_signup_intent_dropdown_new_team_registration_step_one' + } + end it 'tracks signup_intent_step_one experiment events' do - expect(experiment).to receive(:track).with(:submitted_intent, label: :signup_intent, property: "new_team") + expect(experiment).to receive(:track).with( + 'select_signup_intent_dropdown_new_team_registration_step_one', + label: 'trial_registration' + ) post_create end diff --git a/ee/spec/requests/users/registrations_identity_verification_controller_spec.rb b/ee/spec/requests/users/registrations_identity_verification_controller_spec.rb index bc7dfb447f1fc21de52570318e8023d5a1c5ae92..e0c1c15de537de9003e276310fd71114cb7738ce 100644 --- a/ee/spec/requests/users/registrations_identity_verification_controller_spec.rb +++ b/ee/spec/requests/users/registrations_identity_verification_controller_spec.rb @@ -408,7 +408,7 @@ end expect(experiment).to receive(:run) - expect(experiment).to receive(:track).with(:show, label: :identity_verification) + expect(experiment).to receive(:track).with(:render_identity_verification, label: 'free_registration') do_request end diff --git a/spec/views/devise/shared/_signup_box.html.haml_spec.rb b/spec/views/devise/shared/_signup_box.html.haml_spec.rb index e4ca48f16231ff645b43a3260b020a260db8b4d2..d620449672d3ade0df884bdde9e13ccc29c844b4 100644 --- a/spec/views/devise/shared/_signup_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signup_box.html.haml_spec.rb @@ -110,10 +110,22 @@ def text(translation) expect(rendered).to include(s_('SignUp|Contribute to a public project on GitLab')) expect(rendered).to have_css('select[name="signup_intent"]') - expect(rendered).to have_css('option[value="new_team"]') - expect(rendered).to have_css('option[value="new_personal_account"]') - expect(rendered).to have_css('option[value="join_existing_team"]') - expect(rendered).to have_css('option[value="contribute_public_project"]') + + expect(rendered).to have_css( + 'option[value="select_signup_intent_dropdown_new_team_registration_step_one"]' + ) + + expect(rendered).to have_css( + 'option[value="select_signup_intent_dropdown_new_personal_account_registration_step_one"]' + ) + + expect(rendered).to have_css( + 'option[value="select_signup_intent_dropdown_join_existing_team_registration_step_one"]' + ) + + expect(rendered).to have_css( + 'option[value="select_signup_intent_dropdown_contribute_public_project_registration_step_one"]' + ) end end