Commit 4ef38b5e authored by Stan Hu's avatar Stan Hu

Merge branch '219944-track-billings-page-view' into 'master'

Track views of the {profiles,groups}/billings page

See merge request gitlab-org/gitlab!38843
parents 7b222329 9e65d413
...@@ -10,6 +10,7 @@ class Groups::BillingsController < Groups::ApplicationController ...@@ -10,6 +10,7 @@ class Groups::BillingsController < Groups::ApplicationController
@top_most_group = @group.root_ancestor if @group.has_parent? @top_most_group = @group.root_ancestor if @group.has_parent?
current_plan = (@top_most_group || @group).plan_name_for_upgrading current_plan = (@top_most_group || @group).plan_name_for_upgrading
@plans_data = FetchSubscriptionPlansService.new(plan: current_plan).execute @plans_data = FetchSubscriptionPlansService.new(plan: current_plan).execute
track_experiment_event(:contact_sales_btn_in_app, 'page_view:billing_plans:group')
record_experiment_user(:contact_sales_btn_in_app) record_experiment_user(:contact_sales_btn_in_app)
end end
end end
...@@ -7,6 +7,7 @@ class Profiles::BillingsController < Profiles::ApplicationController ...@@ -7,6 +7,7 @@ class Profiles::BillingsController < Profiles::ApplicationController
@plans_data = FetchSubscriptionPlansService @plans_data = FetchSubscriptionPlansService
.new(plan: current_user.namespace.plan_name_for_upgrading) .new(plan: current_user.namespace.plan_name_for_upgrading)
.execute .execute
track_experiment_event(:contact_sales_btn_in_app, 'page_view:billing_plans:profile')
record_experiment_user(:contact_sales_btn_in_app) record_experiment_user(:contact_sales_btn_in_app)
end end
end end
...@@ -29,6 +29,7 @@ RSpec.describe Groups::BillingsController do ...@@ -29,6 +29,7 @@ RSpec.describe Groups::BillingsController do
allow_next_instance_of(FetchSubscriptionPlansService) do |instance| allow_next_instance_of(FetchSubscriptionPlansService) do |instance|
allow(instance).to receive(:execute) allow(instance).to receive(:execute)
end end
allow(controller).to receive(:track_experiment_event)
end end
it 'renders index with 200 status code' do it 'renders index with 200 status code' do
...@@ -49,6 +50,12 @@ RSpec.describe Groups::BillingsController do ...@@ -49,6 +50,12 @@ RSpec.describe Groups::BillingsController do
expect(assigns(:plans_data)).to eq(data) expect(assigns(:plans_data)).to eq(data)
end end
it 'tracks the page view for the contact_sales_btn_in_app experiment' do
expect(controller).to receive(:track_experiment_event).with(:contact_sales_btn_in_app, 'page_view:billing_plans:group')
get_index
end
it 'records user for the contact_sales_btn_in_app experiment' do it 'records user for the contact_sales_btn_in_app experiment' do
expect(controller).to receive(:record_experiment_user).with(:contact_sales_btn_in_app) expect(controller).to receive(:record_experiment_user).with(:contact_sales_btn_in_app)
......
...@@ -13,6 +13,7 @@ RSpec.describe Profiles::BillingsController do ...@@ -13,6 +13,7 @@ RSpec.describe Profiles::BillingsController do
allow_next_instance_of(FetchSubscriptionPlansService) do |instance| allow_next_instance_of(FetchSubscriptionPlansService) do |instance|
allow(instance).to receive(:execute) allow(instance).to receive(:execute)
end end
allow(controller).to receive(:track_experiment_event)
end end
def get_index def get_index
...@@ -39,6 +40,12 @@ RSpec.describe Profiles::BillingsController do ...@@ -39,6 +40,12 @@ RSpec.describe Profiles::BillingsController do
expect(assigns(:plans_data)).to eq(data) expect(assigns(:plans_data)).to eq(data)
end end
it 'tracks the page view for the contact_sales_btn_in_app experiment' do
expect(controller).to receive(:track_experiment_event).with(:contact_sales_btn_in_app, 'page_view:billing_plans:profile')
get_index
end
it 'records user for the contact_sales_btn_in_app experiment' do it 'records user for the contact_sales_btn_in_app experiment' do
expect(controller).to receive(:record_experiment_user).with(:contact_sales_btn_in_app) expect(controller).to receive(:record_experiment_user).with(:contact_sales_btn_in_app)
......
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