Commit 594fcf27 authored by Alper Akgun's avatar Alper Akgun Committed by Etienne Baqué

Display known fields as locked fields within trial sign up form

parent 076b96b6
...@@ -63,8 +63,8 @@ module Registrations ...@@ -63,8 +63,8 @@ module Registrations
def apply_trial_for_trial_onboarding_flow def apply_trial_for_trial_onboarding_flow
if apply_trial if apply_trial
record_experiment_user(:remove_known_trial_form_fields, namespace_id: @group.id) record_experiment_user(:remove_known_trial_form_fields_welcoming, namespace_id: @group.id)
record_experiment_conversion_event(:remove_known_trial_form_fields) record_experiment_conversion_event(:remove_known_trial_form_fields_welcoming)
redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true) redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true)
else else
......
...@@ -14,7 +14,7 @@ class TrialsController < ApplicationController ...@@ -14,7 +14,7 @@ class TrialsController < ApplicationController
feature_category :purchase feature_category :purchase
def new def new
record_experiment_user(:remove_known_trial_form_fields, remove_known_trial_form_fields_context) record_experiment_user(:remove_known_trial_form_fields_welcoming, remove_known_trial_form_fields_context)
end end
def select def select
...@@ -39,8 +39,8 @@ class TrialsController < ApplicationController ...@@ -39,8 +39,8 @@ class TrialsController < ApplicationController
@result = GitlabSubscriptions::ApplyTrialService.new.execute(apply_trial_params) @result = GitlabSubscriptions::ApplyTrialService.new.execute(apply_trial_params)
if @result&.dig(:success) if @result&.dig(:success)
record_experiment_user(:remove_known_trial_form_fields, namespace_id: @namespace.id) record_experiment_user(:remove_known_trial_form_fields_welcoming, namespace_id: @namespace.id)
record_experiment_conversion_event(:remove_known_trial_form_fields) record_experiment_conversion_event(:remove_known_trial_form_fields_welcoming)
experiment(:force_company_trial, user: current_user).track(:create_trial, namespace: @namespace, user: current_user, label: 'trials_controller') if @namespace.created_at > 24.hours.ago experiment(:force_company_trial, user: current_user).track(:create_trial, namespace: @namespace, user: current_user, label: 'trials_controller') if @namespace.created_at > 24.hours.ago
...@@ -177,7 +177,8 @@ class TrialsController < ApplicationController ...@@ -177,7 +177,8 @@ class TrialsController < ApplicationController
{ {
first_name_present: current_user.first_name.present?, first_name_present: current_user.first_name.present?,
last_name_present: current_user.last_name.present?, last_name_present: current_user.last_name.present?,
company_name_present: current_user.organization.present? company_name_present: current_user.organization.present?,
variant: helpers.remove_known_trial_form_fields_variant
} }
end end
......
...@@ -74,6 +74,16 @@ module EE ...@@ -74,6 +74,16 @@ module EE
} }
end end
def remove_known_trial_form_fields_variant
if experiment_enabled?(:remove_known_trial_form_fields_welcoming, subject: current_user)
:welcoming
elsif experiment_enabled?(:remove_known_trial_form_fields_noneditable, subject: current_user)
:noneditable
else
:control
end
end
private private
def trial_group_namespaces def trial_group_namespaces
......
...@@ -7,29 +7,37 @@ ...@@ -7,29 +7,37 @@
= _("Start your Free Ultimate Trial") = _("Start your Free Ultimate Trial")
%p.gl-text-center %p.gl-text-center
= _('Your GitLab Ultimate trial will last 30 days after which point you can keep your free GitLab account forever. We just need some additional information to activate your trial.') - if remove_known_trial_form_fields_variant == :welcoming
- salutation = current_user.first_name.present? ? " #{current_user.first_name}" : ''
- company = current_user.organization.present? ? current_user.organization : _('your company')
= _("Hi%{salutation}, your GitLab Ultimate trial lasts for 30 days, but you can keep your free GitLab account forever. We just need some additional information about %{company} to activate your trial.") % { salutation: salutation, company: company }
- else
= _('Your GitLab Ultimate trial lasts for 30 days, but you can keep your free GitLab account forever. We just need some additional information to activate your trial.')
= render 'errors' = render 'errors'
= form_tag create_lead_trials_path(glm_params), method: :post do |f| = form_tag create_lead_trials_path(glm_params), method: :post do |f|
- if experiment_enabled?(:remove_known_trial_form_fields) && current_user.first_name.present? - if remove_known_trial_form_fields_variant == :welcoming && current_user.first_name.present?
= hidden_field_tag :first_name, current_user.first_name = hidden_field_tag :first_name, current_user.first_name
- else - else
.form-group .form-group
= label_tag :first_name, _('First name'), for: :first_name, class: 'col-form-label' = label_tag :first_name, _('First name'), for: :first_name, class: 'col-form-label'
= text_field_tag :first_name, params[:first_name] || current_user.first_name, class: 'form-control gl-form-input', required: true, data: { qa_selector: 'first_name' } - readonly = remove_known_trial_form_fields_variant == :noneditable && current_user.first_name.present?
- if experiment_enabled?(:remove_known_trial_form_fields) && current_user.last_name.present? = text_field_tag :first_name, params[:first_name] || current_user.first_name, class: 'form-control gl-form-input', required: true, data: { qa_selector: 'first_name' }, readonly: readonly
- if remove_known_trial_form_fields_variant == :welcoming && current_user.last_name.present?
= hidden_field_tag :last_name, current_user.last_name = hidden_field_tag :last_name, current_user.last_name
- else - else
.form-group .form-group
= label_tag :last_name, _('Last name'), for: :last_name, class: 'col-form-label' = label_tag :last_name, _('Last name'), for: :last_name, class: 'col-form-label'
= text_field_tag :last_name, params[:last_name] || current_user.last_name, class: 'form-control gl-form-input', required: true, data: { qa_selector: 'last_name' } - readonly = remove_known_trial_form_fields_variant == :noneditable && current_user.last_name.present?
- if experiment_enabled?(:remove_known_trial_form_fields) && current_user.organization.present? = text_field_tag :last_name, params[:last_name] || current_user.last_name, class: 'form-control gl-form-input', required: true, data: { qa_selector: 'last_name' }, readonly: readonly
- if remove_known_trial_form_fields_variant == :welcoming && current_user.organization.present?
= hidden_field_tag :company_name, current_user.organization = hidden_field_tag :company_name, current_user.organization
- else - else
.form-group .form-group
= label_tag :company_name, _('Company name'), for: :company_name, class: 'col-form-label' = label_tag :company_name, _('Company name'), for: :company_name, class: 'col-form-label'
= text_field_tag :company_name, params[:company_name] || current_user.organization, class: 'form-control gl-form-input', required: true, data: { qa_selector: 'company_name' } - readonly = remove_known_trial_form_fields_variant == :noneditable && current_user.organization.present?
= text_field_tag :company_name, params[:company_name] || current_user.organization, class: 'form-control gl-form-input', required: true, data: { qa_selector: 'company_name' }, readonly: readonly
.form-group.gl-select2-html5-required-fix .form-group.gl-select2-html5-required-fix
= label_tag :company_size, _('Number of employees'), for: :company_size, class: 'col-form-label' = label_tag :company_size, _('Number of employees'), for: :company_size, class: 'col-form-label'
= select_tag :company_size, company_size_options_for_select(params[:company_size]), include_blank: true, class: 'select2', required: true, data: { qa_selector: 'number_of_employees' } = select_tag :company_size, company_size_options_for_select(params[:company_size]), include_blank: true, class: 'select2', required: true, data: { qa_selector: 'number_of_employees' }
......
---
name: remove_known_trial_form_fields_noneditable_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65493
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/337439
milestone: '14.2'
type: experiment
group: group::conversion
default_enabled: false
--- ---
name: remove_known_trial_form_fields_experiment_percentage name: remove_known_trial_form_fields_welcoming_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45634/ introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65493
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/281 rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/337439
milestone: '13.7' milestone: '14.2'
type: experiment type: experiment
group: group::conversion group: group::conversion
default_enabled: false default_enabled: false
...@@ -171,8 +171,8 @@ RSpec.describe Registrations::GroupsController do ...@@ -171,8 +171,8 @@ RSpec.describe Registrations::GroupsController do
expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service| expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service|
expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: true }) expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: true })
end end
expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields, namespace_id: group.id) expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields_welcoming, namespace_id: group.id)
expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields) expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields_welcoming)
end end
context 'with redirection to projects page' do context 'with redirection to projects page' do
......
...@@ -8,7 +8,8 @@ RSpec.describe TrialsController do ...@@ -8,7 +8,8 @@ RSpec.describe TrialsController do
{ {
first_name_present: user.first_name.present?, first_name_present: user.first_name.present?,
last_name_present: user.last_name.present?, last_name_present: user.last_name.present?,
company_name_present: user.organization.present? company_name_present: user.organization.present?,
variant: :control
} }
end end
...@@ -55,7 +56,7 @@ RSpec.describe TrialsController do ...@@ -55,7 +56,7 @@ RSpec.describe TrialsController do
end end
it 'calls record_experiment_user for the experiments' do it 'calls record_experiment_user for the experiments' do
expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields, remove_known_trial_form_fields_context) expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields_welcoming, remove_known_trial_form_fields_context)
subject subject
end end
...@@ -177,8 +178,8 @@ RSpec.describe TrialsController do ...@@ -177,8 +178,8 @@ RSpec.describe TrialsController do
it { is_expected.to redirect_to("/#{namespace.path}?trial=true") } it { is_expected.to redirect_to("/#{namespace.path}?trial=true") }
it 'calls the record conversion method for the experiments' do it 'calls the record conversion method for the experiments' do
expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields, namespace_id: namespace.id) expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields_welcoming, namespace_id: namespace.id)
expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields) expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields_welcoming)
expect(experiment(:force_company_trial)).to track(:create_trial, namespace: namespace, user: user, label: 'trials_controller').with_context(user: user).on_next_instance expect(experiment(:force_company_trial)).to track(:create_trial, namespace: namespace, user: user, label: 'trials_controller').with_context(user: user).on_next_instance
subject subject
...@@ -238,7 +239,7 @@ RSpec.describe TrialsController do ...@@ -238,7 +239,7 @@ RSpec.describe TrialsController do
it { is_expected.to render_template(:select) } it { is_expected.to render_template(:select) }
it 'does not call the record conversion method for the experiments' do it 'does not call the record conversion method for the experiments' do
expect(controller).not_to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields) expect(controller).not_to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields_welcoming)
subject subject
end end
......
...@@ -265,4 +265,27 @@ RSpec.describe EE::TrialHelper do ...@@ -265,4 +265,27 @@ RSpec.describe EE::TrialHelper do
it { is_expected.to eq({ namespace_id: 1, trial_plan_name: 'Ultimate', action: 'reactivate' }) } it { is_expected.to eq({ namespace_id: 1, trial_plan_name: 'Ultimate', action: 'reactivate' }) }
end end
end end
describe '#remove_known_trial_form_fields_variant' do
let_it_be(:user) { create(:user) }
subject { helper.remove_known_trial_form_fields_variant }
before do
helper.extend(Gitlab::Experimentation::ControllerConcern)
allow(helper).to receive(:current_user).and_return(user)
stub_experiment_for_subject(remove_known_trial_form_fields_welcoming: welcoming, remove_known_trial_form_fields_noneditable: noneditable)
end
where(:welcoming, :noneditable, :result) do
true | true | :welcoming
true | false | :welcoming
false | true | :noneditable
false | false | :control
end
with_them do
it { is_expected.to eq(result) }
end
end
end end
...@@ -4,40 +4,67 @@ require 'spec_helper' ...@@ -4,40 +4,67 @@ require 'spec_helper'
RSpec.describe 'trials/new.html.haml' do RSpec.describe 'trials/new.html.haml' do
include ApplicationHelper include ApplicationHelper
let_it_be(:remove_known_trial_form_fields_enabled) { false } let_it_be(:variant) { :control }
let_it_be(:user) { build(:user) } let_it_be(:user) { build(:user) }
before do before do
allow(view).to receive(:current_user) { user } allow(view).to receive(:current_user) { user }
allow(view).to receive(:experiment_enabled?).with(:remove_known_trial_form_fields).and_return(remove_known_trial_form_fields_enabled) allow(view).to receive(:remove_known_trial_form_fields_variant).and_return(variant)
render render
end end
subject { rendered } subject { rendered }
it 'has fields for first, last and company names' do it 'has fields for first, last and company names', :aggregate_failures do
is_expected.to have_field('first_name') is_expected.to have_field('first_name')
is_expected.to have_field('last_name') is_expected.to have_field('last_name')
is_expected.to have_field('company_name') is_expected.to have_field('company_name')
end end
context 'remove_known_trial_form_fields experiment is enabled' do context 'remove_known_trial_form_fields noneditable experiment is enabled' do
let_it_be(:remove_known_trial_form_fields_enabled) { true } let_it_be(:variant) { :noneditable }
it { is_expected.to have_content('Your GitLab Ultimate trial lasts for 30 days, but you can keep your free GitLab account forever. We just need some additional information to activate your trial.') }
context 'the user has already values in first, last and company names' do context 'the user has already values in first, last and company names' do
let_it_be(:user) { build(:user, first_name: 'John', last_name: 'Doe', organization: 'ACME') } let_it_be(:user) { build(:user, first_name: 'John', last_name: 'Doe', organization: 'ACME') }
it 'has readonly fields', :aggregate_failures do
is_expected.to have_field('first_name', readonly: true)
is_expected.to have_field('last_name', readonly: true)
is_expected.to have_field('company_name', readonly: true)
end
end
context 'the user empty values for first, last and company names' do
let_it_be(:user) { build(:user, first_name: '', last_name: '', organization: '') }
it 'has fields', :aggregate_failures do
is_expected.to have_field('first_name')
is_expected.to have_field('last_name')
is_expected.to have_field('company_name')
end
end
end
context 'remove_known_trial_form_fields welcoming experiment is enabled' do
let_it_be(:variant) { :welcoming }
context 'the user has already values in first, last and company names' do
let_it_be(:user) { build(:user, first_name: 'John', last_name: 'Doe', organization: 'ACME') }
it { is_expected.to have_content('Hi John, your GitLab Ultimate trial lasts for 30 days, but you can keep your free GitLab account forever. We just need some additional information about ACME to activate your trial.') }
it 'has hidden fields' do it 'has hidden fields' do
is_expected.to have_field('first_name', type: :hidden) is_expected.to have_field('first_name', type: :hidden)
is_expected.to have_field('last_name', type: :hidden) is_expected.to have_field('last_name', type: :hidden)
is_expected.to have_field('company_name', type: :hidden) is_expected.to have_field('company_name', type: :hidden)
end end
end end
context 'the user empty values for first, last and company names' do context 'the user empty values for first, last and company names' do
let_it_be(:user) { build(:user, first_name: '', last_name: '', organization: '') } let_it_be(:user) { build(:user, first_name: '', last_name: '', organization: '') }
it { is_expected.to have_content('Hi, your GitLab Ultimate trial lasts for 30 days, but you can keep your free GitLab account forever. We just need some additional information about your company to activate your trial.') }
it 'has fields' do it 'has fields' do
is_expected.to have_field('first_name') is_expected.to have_field('first_name')
is_expected.to have_field('last_name') is_expected.to have_field('last_name')
......
...@@ -42,8 +42,13 @@ module Gitlab ...@@ -42,8 +42,13 @@ module Gitlab
tracking_category: 'Growth::Conversion::Experiment::ContactSalesInApp', tracking_category: 'Growth::Conversion::Experiment::ContactSalesInApp',
use_backwards_compatible_subject_index: true use_backwards_compatible_subject_index: true
}, },
remove_known_trial_form_fields: { remove_known_trial_form_fields_welcoming: {
tracking_category: 'Growth::Conversion::Experiment::RemoveKnownTrialFormFields' tracking_category: 'Growth::Conversion::Experiment::RemoveKnownTrialFormFieldsWelcoming',
rollout_strategy: :user
},
remove_known_trial_form_fields_noneditable: {
tracking_category: 'Growth::Conversion::Experiment::RemoveKnownTrialFormFieldsNoneditable',
rollout_strategy: :user
}, },
invite_members_new_dropdown: { invite_members_new_dropdown: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersNewDropdown' tracking_category: 'Growth::Expansion::Experiment::InviteMembersNewDropdown'
......
...@@ -16337,6 +16337,9 @@ msgstr "" ...@@ -16337,6 +16337,9 @@ msgstr ""
msgid "Hi %{username}!" msgid "Hi %{username}!"
msgstr "" msgstr ""
msgid "Hi%{salutation}, your GitLab Ultimate trial lasts for 30 days, but you can keep your free GitLab account forever. We just need some additional information about %{company} to activate your trial."
msgstr ""
msgid "Hide" msgid "Hide"
msgstr "" msgstr ""
...@@ -38230,7 +38233,7 @@ msgstr "" ...@@ -38230,7 +38233,7 @@ msgstr ""
msgid "Your GPG keys (%{count})" msgid "Your GPG keys (%{count})"
msgstr "" msgstr ""
msgid "Your GitLab Ultimate trial will last 30 days after which point you can keep your free GitLab account forever. We just need some additional information to activate your trial." msgid "Your GitLab Ultimate trial lasts for 30 days, but you can keep your free GitLab account forever. We just need some additional information to activate your trial."
msgstr "" msgstr ""
msgid "Your GitLab account has been locked due to an excessive amount of unsuccessful sign in attempts. Your account will automatically unlock in %{duration} or you may click the link below to unlock now." msgid "Your GitLab account has been locked due to an excessive amount of unsuccessful sign in attempts. Your account will automatically unlock in %{duration} or you may click the link below to unlock now."
...@@ -40174,5 +40177,8 @@ msgstr "" ...@@ -40174,5 +40177,8 @@ msgstr ""
msgid "yaml invalid" msgid "yaml invalid"
msgstr "" msgstr ""
msgid "your company"
msgstr ""
msgid "your settings" msgid "your settings"
msgstr "" msgstr ""
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