Commit f7f213bc authored by Nicolas Dular's avatar Nicolas Dular

Add default terms opt in experiment

As an experiment, we let users opt in to our terms and privacy
policy by default, by stating that they confirm them by
clicking "Register".
parent 2fbd4acc
...@@ -18,6 +18,8 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -18,6 +18,8 @@ class RegistrationsController < Devise::RegistrationsController
def new def new
if experiment_enabled?(:signup_flow) if experiment_enabled?(:signup_flow)
track_experiment_event(:signup_flow, 'start') # We want this event to be tracked when the user is _in_ the experimental group track_experiment_event(:signup_flow, 'start') # We want this event to be tracked when the user is _in_ the experimental group
track_experiment_event(:terms_opt_in, 'start')
@resource = build_resource @resource = build_resource
else else
redirect_to new_user_session_path(anchor: 'register-pane') redirect_to new_user_session_path(anchor: 'register-pane')
...@@ -26,6 +28,7 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -26,6 +28,7 @@ class RegistrationsController < Devise::RegistrationsController
def create def create
track_experiment_event(:signup_flow, 'end') unless experiment_enabled?(:signup_flow) # We want this event to be tracked when the user is _in_ the control group track_experiment_event(:signup_flow, 'end') unless experiment_enabled?(:signup_flow) # We want this event to be tracked when the user is _in_ the control group
track_experiment_event(:terms_opt_in, 'end')
accept_pending_invitations accept_pending_invitations
...@@ -178,6 +181,8 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -178,6 +181,8 @@ class RegistrationsController < Devise::RegistrationsController
end end
def terms_accepted? def terms_accepted?
return true if experiment_enabled?(:terms_opt_in)
Gitlab::Utils.to_boolean(params[:terms_opt_in]) Gitlab::Utils.to_boolean(params[:terms_opt_in])
end end
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
= f.label :password, class: 'label-bold' = f.label :password, class: 'label-bold'
= f.password_field :password, class: "form-control bottom", data: { qa_selector: 'new_user_password_field' }, required: true, pattern: ".{#{@minimum_password_length},}", title: _("Minimum length is %{minimum_password_length} characters.") % { minimum_password_length: @minimum_password_length } = f.password_field :password, class: "form-control bottom", data: { qa_selector: 'new_user_password_field' }, required: true, pattern: ".{#{@minimum_password_length},}", title: _("Minimum length is %{minimum_password_length} characters.") % { minimum_password_length: @minimum_password_length }
%p.gl-field-hint.text-secondary= _('Minimum length is %{minimum_password_length} characters') % { minimum_password_length: @minimum_password_length } %p.gl-field-hint.text-secondary= _('Minimum length is %{minimum_password_length} characters') % { minimum_password_length: @minimum_password_length }
- if Gitlab::CurrentSettings.current_application_settings.enforce_terms? - if Gitlab::CurrentSettings.current_application_settings.enforce_terms? && !experiment_enabled?(:terms_opt_in)
.form-group .form-group
= check_box_tag :terms_opt_in, '1', false, required: true, data: { qa_selector: 'new_user_accept_terms_checkbox' } = check_box_tag :terms_opt_in, '1', false, required: true, data: { qa_selector: 'new_user_accept_terms_checkbox' }
= label_tag :terms_opt_in do = label_tag :terms_opt_in do
...@@ -41,5 +41,8 @@ ...@@ -41,5 +41,8 @@
= recaptcha_tags = recaptcha_tags
.submit-container.mt-3 .submit-container.mt-3
= f.submit _("Register"), class: "btn-register btn btn-block btn-success mb-0 p-2", data: { qa_selector: 'new_user_register_button' } = f.submit _("Register"), class: "btn-register btn btn-block btn-success mb-0 p-2", data: { qa_selector: 'new_user_register_button' }
- if experiment_enabled?(:terms_opt_in)
%p.gl-text-gray-700.gl-mt-5.gl-mb-0
= html_escape(_("By clicking Register, I agree that I have read and accepted the GitLab %{linkStart}Terms of Use and Privacy Policy%{linkEnd}")) % { linkStart: "<a href='#{terms_path}' target='_blank' rel='noreferrer noopener'>".html_safe, linkEnd: '</a>'.html_safe }
- if omniauth_enabled? && button_based_providers_enabled? - if omniauth_enabled? && button_based_providers_enabled?
= render 'devise/shared/experimental_separate_sign_up_flow_omniauth_box' = render 'devise/shared/experimental_separate_sign_up_flow_omniauth_box'
...@@ -53,6 +53,9 @@ module Gitlab ...@@ -53,6 +53,9 @@ module Gitlab
}, },
new_create_project_ui: { new_create_project_ui: {
tracking_category: 'Manage::Import::Experiment::NewCreateProjectUi' tracking_category: 'Manage::Import::Experiment::NewCreateProjectUi'
},
terms_opt_in: {
tracking_category: 'Growth::Acquisition::Experiment::TermsOptIn'
} }
}.freeze }.freeze
......
...@@ -4086,6 +4086,9 @@ msgstr "" ...@@ -4086,6 +4086,9 @@ msgstr ""
msgid "By URL" msgid "By URL"
msgstr "" msgstr ""
msgid "By clicking Register, I agree that I have read and accepted the GitLab %{linkStart}Terms of Use and Privacy Policy%{linkEnd}"
msgstr ""
msgid "By default GitLab sends emails in HTML and plain text formats so mail clients can choose what format to use. Disable this option if you only want to send emails in plain text format." msgid "By default GitLab sends emails in HTML and plain text formats so mail clients can choose what format to use. Disable this option if you only want to send emails in plain text format."
msgstr "" msgstr ""
......
...@@ -52,6 +52,53 @@ RSpec.describe RegistrationsController do ...@@ -52,6 +52,53 @@ RSpec.describe RegistrationsController do
expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane')) expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane'))
end end
end end
context 'with sign up flow and terms_opt_in experiment being enabled' do
before do
stub_experiment(signup_flow: true, terms_opt_in: true)
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Acquisition::Experiment::SignUpFlow',
'start',
label: anything,
property: 'experimental_group'
)
end
context 'when user is not part of the experiment' do
before do
stub_experiment_for_user(signup_flow: true, terms_opt_in: false)
end
it 'tracks event with right parameters' do
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Acquisition::Experiment::TermsOptIn',
'start',
label: anything,
property: 'control_group'
)
subject
end
end
context 'when user is part of the experiment' do
before do
stub_experiment_for_user(signup_flow: true, terms_opt_in: true)
end
it 'tracks event with right parameters' do
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Acquisition::Experiment::TermsOptIn',
'start',
label: anything,
property: 'experimental_group'
)
subject
end
end
end
end end
describe '#create' do describe '#create' do
...@@ -250,6 +297,37 @@ RSpec.describe RegistrationsController do ...@@ -250,6 +297,37 @@ RSpec.describe RegistrationsController do
expect(subject.current_user).to be_present expect(subject.current_user).to be_present
expect(subject.current_user.terms_accepted?).to be(true) expect(subject.current_user.terms_accepted?).to be(true)
end end
context 'when experiment terms_opt_in is enabled' do
before do
stub_experiment(terms_opt_in: true)
end
context 'when user is part of the experiment' do
before do
stub_experiment_for_user(terms_opt_in: true)
end
it 'creates the user with accepted terms' do
post :create, params: user_params
expect(subject.current_user).to be_present
expect(subject.current_user.terms_accepted?).to be(true)
end
end
context 'when user is not part of the experiment' do
before do
stub_experiment_for_user(terms_opt_in: false)
end
it 'creates the user without accepted terms' do
post :create, params: user_params
expect(flash[:alert]).to eq(_('You must accept our Terms of Service and privacy policy in order to register an account'))
end
end
end
end end
describe 'tracking data' do describe 'tracking data' do
...@@ -281,6 +359,48 @@ RSpec.describe RegistrationsController do ...@@ -281,6 +359,48 @@ RSpec.describe RegistrationsController do
post :create, params: user_params post :create, params: user_params
end end
end end
context 'with sign up flow and terms_opt_in experiment being enabled' do
subject { post :create, params: user_params }
before do
stub_experiment(signup_flow: true, terms_opt_in: true)
end
context 'when user is not part of the experiment' do
before do
stub_experiment_for_user(signup_flow: true, terms_opt_in: false)
end
it 'tracks event with right parameters' do
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Acquisition::Experiment::TermsOptIn',
'end',
label: anything,
property: 'control_group'
)
subject
end
end
context 'when user is part of the experiment' do
before do
stub_experiment_for_user(signup_flow: true, terms_opt_in: true)
end
it 'tracks event with right parameters' do
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Acquisition::Experiment::TermsOptIn',
'end',
label: anything,
property: 'experimental_group'
)
subject
end
end
end
end end
it "logs a 'User Created' message" do it "logs a 'User Created' message" do
......
...@@ -509,4 +509,29 @@ RSpec.describe 'With experimental flow' do ...@@ -509,4 +509,29 @@ RSpec.describe 'With experimental flow' do
expect(page).to have_current_path(new_project_path) expect(page).to have_current_path(new_project_path)
end end
end end
context 'when terms_opt_in experimental is enabled' do
include TermsHelper
before do
enforce_terms
stub_experiment(signup_flow: true, terms_opt_in: true)
stub_experiment_for_user(signup_flow: true, terms_opt_in: true)
end
it 'terms are checked by default' do
new_user = build_stubbed(:user)
visit new_user_registration_path
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
fill_in 'new_user_first_name', with: new_user.first_name
fill_in 'new_user_last_name', with: new_user.last_name
fill_in 'new_user_password', with: new_user.password
click_button 'Register'
expect(current_path).to eq users_sign_up_welcome_path
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment