Commit 62329379 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'onboarding-experiment-tracking' into 'master'

Track events for onboarding issues experiment

See merge request gitlab-org/gitlab!34171
parents 4c22218a d9db9472
......@@ -57,6 +57,8 @@ class GroupsController < Groups::ApplicationController
@group = Groups::CreateService.new(current_user, group_params).execute
if @group.persisted?
track_experiment_event(:onboarding_issues, 'created_namespace')
notice = if @group.chat_team.present?
"Group '#{@group.name}' and its Mattermost team were successfully created."
else
......
......@@ -69,6 +69,7 @@ class RegistrationsController < Devise::RegistrationsController
if result[:status] == :success
track_experiment_event(:signup_flow, 'end') # We want this event to be tracked when the user is _in_ the experimental group
track_experiment_event(:onboarding_issues, 'signed_up') if ::Gitlab.com? && !helpers.in_subscription_flow? && !helpers.in_invitation_flow?
return redirect_to new_users_sign_up_group_path if experiment_enabled?(:onboarding_issues) && !helpers.in_subscription_flow? && !helpers.in_invitation_flow?
set_flash_message! :notice, :signed_up
......
......@@ -59,7 +59,7 @@ RSpec.describe RegistrationsController do
sign_in(create(:user))
end
subject { patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: false } } }
subject(:update_registration) { patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } } }
it { is_expected.to redirect_to dashboard_projects_path }
......@@ -86,5 +86,54 @@ RSpec.describe RegistrationsController do
it { is_expected.not_to redirect_to new_users_sign_up_group_path }
end
end
describe 'tracking for the onboarding issues experiment' do
using RSpec::Parameterized::TableSyntax
where(:on_gitlab_com, :experiment_enabled, :in_subscription_flow, :in_invitation_flow, :experiment_enabled_for_user, :expected_tracking) do
false | false | false | false | true | nil
false | false | false | true | true | nil
false | false | true | false | true | nil
false | false | true | true | true | nil
false | true | false | false | true | nil
false | true | false | true | true | nil
false | true | true | false | true | nil
false | true | true | true | true | nil
true | false | false | false | true | nil
true | false | false | true | true | nil
true | false | true | false | true | nil
true | false | true | true | true | nil
true | true | false | false | true | 'experimental_group'
true | true | false | false | false | 'control_group'
true | true | false | true | true | nil
true | true | true | false | true | nil
true | true | true | true | true | nil
end
with_them do
before do
allow(::Gitlab).to receive(:com?).and_return(on_gitlab_com)
stub_experiment(onboarding_issues: experiment_enabled)
allow(controller.helpers).to receive(:in_subscription_flow?).and_return(in_subscription_flow)
allow(controller.helpers).to receive(:in_invitation_flow?).and_return(in_invitation_flow)
stub_experiment_for_user(onboarding_issues: experiment_enabled_for_user)
end
it 'tracks when appropriate' do
if expected_tracking
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Conversion::Experiment::OnboardingIssues',
'signed_up',
label: anything,
property: expected_tracking
)
else
expect(Gitlab::Tracking).not_to receive(:event)
end
update_registration
end
end
end
end
end
......@@ -301,6 +301,66 @@ RSpec.describe GroupsController do
end
end
end
describe 'tracking group creation for onboarding issues experiment' do
before do
sign_in(user)
end
subject(:create_namespace) { post :create, params: { group: { name: 'new_group', path: 'new_group' } } }
context 'experiment disabled' do
before do
stub_experiment(onboarding_issues: false)
end
it 'does not track anything' do
expect(Gitlab::Tracking).not_to receive(:event)
create_namespace
end
end
context 'experiment enabled' do
before do
stub_experiment(onboarding_issues: true)
end
context 'and the user is part of the control group' do
before do
stub_experiment_for_user(onboarding_issues: false)
end
it 'tracks the event with the "created_namespace" action with the "control_group" property' do
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Conversion::Experiment::OnboardingIssues',
'created_namespace',
label: anything,
property: 'control_group'
)
create_namespace
end
end
context 'and the user is part of the experimental group' do
before do
stub_experiment_for_user(onboarding_issues: true)
end
it 'tracks the event with the "created_namespace" action with the "experimental_group" property' do
expect(Gitlab::Tracking).to receive(:event).with(
'Growth::Conversion::Experiment::OnboardingIssues',
'created_namespace',
label: anything,
property: 'experimental_group'
)
create_namespace
end
end
end
end
end
describe 'GET #index' do
......
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