Commit e04e9f32 authored by Dallas Reedy's avatar Dallas Reedy

Set up 1st iter. of "Contact sales" btn experiment

- Add a new experiment key for :contact_sales_btn_in_app
- Add ApplicationHelper#contact_sales_url
- Use experiment to determine if "Contact salse" button should be shown
- Use contact_sales_url + special query param for marketing on each btn
parent 85825fb1
......@@ -194,6 +194,10 @@ module ApplicationHelper
'https://' + promo_host
end
def contact_sales_url
promo_url + '/sales'
end
def support_url
Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/'
end
......
......@@ -56,6 +56,11 @@ module BillingPlansHelper
end
end
def show_contact_sales_button?(purchase_link_action)
experiment_enabled?(:contact_sales_btn_in_app) &&
purchase_link_action == 'upgrade'
end
def plan_feature_short_list(plan)
return [] unless plan.features
......
......@@ -34,6 +34,8 @@
- if purchase_link
.card-footer.p-3
.float-right{ class: ("invisible" unless purchase_link.action == 'upgrade' || is_current_plan) }
- if show_contact_sales_button?(purchase_link.action)
= link_to s_('BillingPlan|Contact sales'), "#{contact_sales_url}?test=inappcontactsales#{plan.code}", class: "btn btn-success btn-inverted"
- upgrade_button_class = "disabled" if is_current_plan && !namespace.trial_active?
- cta_class = '-new' if use_new_purchase_flow?(namespace)
= link_to s_('BillingPlan|Upgrade'), plan_purchase_or_upgrade_url(namespace, plan, current_plan), class: "btn btn-success #{upgrade_button_class} billing-cta-purchase#{cta_class}"
......@@ -18,6 +18,7 @@ RSpec.describe 'Billing plan pages', :feature do
end
before do
stub_experiment_for_user(contact_sales_btn_in_app: true)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=#{plan.name}")
.to_return(status: 200, body: plans_data.to_json)
stub_application_setting(check_namespace_plan: true)
......@@ -43,6 +44,20 @@ RSpec.describe 'Billing plan pages', :feature do
end
end
shared_examples 'can contact sales' do
before do
visit page_path
end
it 'displays the contact sales link' do
# see ApplicationHelper#contact_sales_url
contact_sales_url = 'https://about.gitlab.com/sales'
page.within('.content') do
expect(page).to have_link('Contact sales', href: %r{#{contact_sales_url}\?test=inappcontactsales(bronze|silver|gold)})
end
end
end
shared_examples 'non-upgradable plan' do
before do
visit page_path
......@@ -141,6 +156,7 @@ RSpec.describe 'Billing plan pages', :feature do
end
it_behaves_like 'plan with subscription table'
it_behaves_like 'can contact sales'
end
context 'on bronze plan' do
......@@ -153,6 +169,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'plan with header'
it_behaves_like 'downgradable plan'
it_behaves_like 'upgradable plan'
it_behaves_like 'can contact sales'
it_behaves_like 'plan with subscription table'
end
......@@ -166,6 +183,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'plan with header'
it_behaves_like 'downgradable plan'
it_behaves_like 'upgradable plan'
it_behaves_like 'can contact sales'
it_behaves_like 'plan with subscription table'
end
......@@ -231,6 +249,8 @@ RSpec.describe 'Billing plan pages', :feature do
end
end
end
it_behaves_like 'can contact sales'
end
context 'on bronze plan' do
......@@ -243,6 +263,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'plan with header'
it_behaves_like 'downgradable plan'
it_behaves_like 'upgradable plan'
it_behaves_like 'can contact sales'
end
context 'on gold plan' do
......@@ -319,6 +340,8 @@ RSpec.describe 'Billing plan pages', :feature do
it 'displays subscription table', :js do
expect(page).to have_selector('.js-subscription-table')
end
it_behaves_like 'can contact sales'
end
end
end
......
......@@ -87,4 +87,27 @@ RSpec.describe BillingPlansHelper do
end
end
end
describe '#show_contact_sales_button?' do
using RSpec::Parameterized::TableSyntax
where(:experiment_enabled, :link_action, :result) do
true | 'downgrade' | false
true | 'current' | false
true | 'upgrade' | true
false | 'downgrade' | false
false | 'current' | false
false | 'upgrade' | false
end
with_them do
before do
allow(helper).to receive(:experiment_enabled?).with(:contact_sales_btn_in_app).and_return(experiment_enabled)
end
subject { helper.show_contact_sales_button?(link_action) }
it { is_expected.to eq(result) }
end
end
end
......@@ -56,6 +56,9 @@ module Gitlab
},
terms_opt_in: {
tracking_category: 'Growth::Acquisition::Experiment::TermsOptIn'
},
contact_sales_btn_in_app: {
tracking_category: 'Growth::Conversion::Experiment::ContactSalesInApp'
}
}.freeze
......
......@@ -3827,6 +3827,9 @@ msgstr ""
msgid "BillingPlans|per user"
msgstr ""
msgid "BillingPlan|Contact sales"
msgstr ""
msgid "BillingPlan|Upgrade"
msgstr ""
......
......@@ -168,6 +168,19 @@ RSpec.describe ApplicationHelper do
it { expect(helper.active_when(false)).to eq(nil) }
end
describe '#contact_sales_url' do
subject { helper.contact_sales_url }
it 'passes a smoke test' do
is_expected.to eq('https://about.gitlab.com/sales')
end
it 'changes if promo_url changes' do
allow(helper).to receive(:promo_url).and_return('https://somewhere.else')
is_expected.to eq('https://somewhere.else/sales')
end
end
describe '#support_url' do
context 'when alternate support url is specified' do
let(:alternate_url) { 'http://company.example.com/getting-help' }
......
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