Commit 26781e43 authored by Jay Swain's avatar Jay Swain

Promote jobs_to_be_done experiment

The jobs_to_be_done is being promoted, it asks the user when signing up
what the objective of registering is.

part of:
https://gitlab.com/gitlab-org/gitlab/-/issues/338226

Changelog: added
parent 2e412bd9
// This file only applies to use of experiments through https://gitlab.com/gitlab-org/gitlab-experiment // This file only applies to use of experiments through https://gitlab.com/gitlab-org/gitlab-experiment
import { get, pick } from 'lodash'; import { get } from 'lodash';
import { DEFAULT_VARIANT, CANDIDATE_VARIANT, TRACKING_CONTEXT_SCHEMA } from './constants'; import { DEFAULT_VARIANT, CANDIDATE_VARIANT, TRACKING_CONTEXT_SCHEMA } from './constants';
function getExperimentsData() { function getExperimentsData() {
...@@ -14,12 +14,6 @@ export function getExperimentData(experimentName) { ...@@ -14,12 +14,6 @@ export function getExperimentData(experimentName) {
return getExperimentsData()[experimentName]; return getExperimentsData()[experimentName];
} }
export function getExperimentContexts(...experimentNames) {
return Object.values(pick(getExperimentsData(), experimentNames)).map(
convertExperimentDataToExperimentContext,
);
}
export function getAllExperimentContexts() { export function getAllExperimentContexts() {
return Object.values(getExperimentsData()).map(convertExperimentDataToExperimentContext); return Object.values(getExperimentsData()).map(convertExperimentDataToExperimentContext);
} }
......
---
name: jobs_to_be_done
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60038
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/285564
milestone: '13.12'
type: experiment
group: group::adoption
default_enabled: false
import { getExperimentContexts } from '~/experimentation/utils';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
const select = document.querySelector('.js-jobs-to-be-done-dropdown'); const select = document.querySelector('.js-jobs-to-be-done-dropdown');
if (select) { if (select) {
Tracking.enableFormTracking( Tracking.enableFormTracking({ fields: { allow: ['jobs_to_be_done_other'] } });
{ fields: { allow: ['jobs_to_be_done_other'] } },
getExperimentContexts('jobs_to_be_done'),
);
select.addEventListener('change', () => { select.addEventListener('change', () => {
const otherSelected = select.value === 'other'; const otherSelected = select.value === 'other';
......
...@@ -20,9 +20,6 @@ module Registrations ...@@ -20,9 +20,6 @@ module Registrations
@group = Groups::CreateService.new(current_user, group_params).execute @group = Groups::CreateService.new(current_user, group_params).execute
if @group.persisted? if @group.persisted?
experiment(:jobs_to_be_done, user: current_user)
.track(:create_group, namespace: @group)
experiment(:combined_registration, user: current_user).track(:create_group, namespace: @group) experiment(:combined_registration, user: current_user).track(:create_group, namespace: @group)
force_company_trial_experiment.track(:create_group, namespace: @group, user: current_user) force_company_trial_experiment.track(:create_group, namespace: @group, user: current_user)
......
...@@ -28,7 +28,6 @@ module Registrations ...@@ -28,7 +28,6 @@ module Registrations
if @group.persisted? if @group.persisted?
if @group.previously_new_record? if @group.previously_new_record?
combined_registration_experiment.track(:create_group, namespace: @group) combined_registration_experiment.track(:create_group, namespace: @group)
experiment(:jobs_to_be_done, user: current_user).track(:create_group, namespace: @group)
end end
@project = ::Projects::CreateService.new(current_user, project_params).execute @project = ::Projects::CreateService.new(current_user, project_params).execute
...@@ -36,8 +35,6 @@ module Registrations ...@@ -36,8 +35,6 @@ module Registrations
combined_registration_experiment.track(:create_project, namespace: @project.namespace) combined_registration_experiment.track(:create_project, namespace: @project.namespace)
learn_gitlab_project = create_learn_gitlab_project learn_gitlab_project = create_learn_gitlab_project
experiment(:jobs_to_be_done, user: current_user)
.track(:create_project, project: @project)
if helpers.in_trial_onboarding_flow? if helpers.in_trial_onboarding_flow?
record_experiment_user(:remove_known_trial_form_fields_welcoming, namespace_id: @group.id) record_experiment_user(:remove_known_trial_form_fields_welcoming, namespace_id: @group.id)
...@@ -62,7 +59,6 @@ module Registrations ...@@ -62,7 +59,6 @@ module Registrations
@group = Groups::CreateService.new(current_user, group_params).execute @group = Groups::CreateService.new(current_user, group_params).execute
if @group.persisted? if @group.persisted?
combined_registration_experiment.track(:create_group, namespace: @group) combined_registration_experiment.track(:create_group, namespace: @group)
experiment(:jobs_to_be_done, user: current_user).track(:create_group, namespace: @group)
import_url = URI.join(root_url, params[:import_url], "?namespace_id=#{@group.id}").to_s import_url = URI.join(root_url, params[:import_url], "?namespace_id=#{@group.id}").to_s
redirect_to import_url redirect_to import_url
......
...@@ -26,9 +26,6 @@ module Registrations ...@@ -26,9 +26,6 @@ module Registrations
learn_gitlab_project = create_learn_gitlab_project learn_gitlab_project = create_learn_gitlab_project
experiment(:jobs_to_be_done, user: current_user)
.track(:create_project, project: @project)
experiment(:force_company_trial, user: current_user) experiment(:force_company_trial, user: current_user)
.track(:create_project, namespace: @project.namespace, project: @project, user: current_user) .track(:create_project, namespace: @project.namespace, project: @project, user: current_user)
......
- experiment(:jobs_to_be_done, user: current_user) do |e| .row
- e.try do
.row
.form-group.col-sm-12 .form-group.col-sm-12
= label_tag :user_registration_objective, _("I'm signing up for GitLab because:") = label_tag :user_registration_objective, _("I'm signing up for GitLab because:")
= f.select :registration_objective, shuffled_registration_objective_options, { include_blank: _('Please select...') }, class: 'form-control js-jobs-to-be-done-dropdown' = f.select :registration_objective, shuffled_registration_objective_options, { include_blank: _('Please select...') }, class: 'form-control js-jobs-to-be-done-dropdown'
.row .row
.form-group.col-sm-12.js-jobs-to-be-done-other-group.hidden .form-group.col-sm-12.js-jobs-to-be-done-other-group.hidden
= label_tag :jobs_to_be_done_other, _('Why are you signing up? (Optional)') = label_tag :jobs_to_be_done_other, _('Why are you signing up? (Optional)')
= text_field_tag :jobs_to_be_done_other, '', class: 'form-control' = text_field_tag :jobs_to_be_done_other, '', class: 'form-control'
...@@ -40,17 +40,6 @@ RSpec.describe Registrations::GroupsController do ...@@ -40,17 +40,6 @@ RSpec.describe Registrations::GroupsController do
expect { post_create }.to change { Group.count }.by(1) expect { post_create }.to change { Group.count }.by(1)
end end
it 'tracks an event for the jobs_to_be_done experiment', :experiment do
stub_experiments(jobs_to_be_done: :candidate)
expect(experiment(:jobs_to_be_done)).to track(:create_group, namespace: an_instance_of(Group))
.on_next_instance
.for(:candidate)
.with_context(user: user)
post_create
end
context 'when in trial onboarding - apply_trial_for_trial_onboarding_flow' do context 'when in trial onboarding - apply_trial_for_trial_onboarding_flow' do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:trial_onboarding_flow_params) { { trial_onboarding_flow: true, glm_source: 'about.gitlab.com', glm_content: 'content' } } let_it_be(:trial_onboarding_flow_params) { { trial_onboarding_flow: true, glm_source: 'about.gitlab.com', glm_content: 'content' } }
......
...@@ -69,17 +69,6 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do ...@@ -69,17 +69,6 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
expect { subject }.to change { Group.count }.by(1) expect { subject }.to change { Group.count }.by(1)
end end
it 'tracks an event for the jobs_to_be_done experiment' do
stub_experiments(jobs_to_be_done: :candidate)
expect(experiment(:jobs_to_be_done)).to track(:create_group, namespace: an_instance_of(Group))
.on_next_instance
.for(:candidate)
.with_context(user: user)
subject
end
it 'tracks create events for the combined_registration experiment' do it 'tracks create events for the combined_registration experiment' do
allow_next_instance_of(::Projects::CreateService) do |service| allow_next_instance_of(::Projects::CreateService) do |service|
allow(service).to receive(:after_create_actions) allow(service).to receive(:after_create_actions)
...@@ -257,17 +246,6 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do ...@@ -257,17 +246,6 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
expect { subject }.to change { Group.count }.by(1) expect { subject }.to change { Group.count }.by(1)
end end
it 'tracks an event for the jobs_to_be_done experiment' do
stub_experiments(jobs_to_be_done: :candidate)
expect(experiment(:jobs_to_be_done)).to track(:create_group, namespace: an_instance_of(Group))
.on_next_instance
.for(:candidate)
.with_context(user: user)
subject
end
it 'tracks an event for the combined_registration experiment' do it 'tracks an event for the combined_registration experiment' do
expect(experiment(:combined_registration)).to track(:create_group, namespace: an_instance_of(Group)) expect(experiment(:combined_registration)).to track(:create_group, namespace: an_instance_of(Group))
.on_next_instance .on_next_instance
......
...@@ -5,15 +5,12 @@ require 'spec_helper' ...@@ -5,15 +5,12 @@ require 'spec_helper'
RSpec.describe 'Welcome screen', :js do RSpec.describe 'Welcome screen', :js do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:experiments) { {} }
context 'when on GitLab.com' do context 'when on GitLab.com' do
let(:user_has_memberships) { false } let(:user_has_memberships) { false }
let(:in_subscription_flow) { false } let(:in_subscription_flow) { false }
let(:in_trial_flow) { false } let(:in_trial_flow) { false }
before do before do
stub_experiments(experiments)
allow(Gitlab).to receive(:com?).and_return(true) allow(Gitlab).to receive(:com?).and_return(true)
gitlab_sign_in(user) gitlab_sign_in(user)
allow_any_instance_of(EE::WelcomeHelper).to receive(:user_has_memberships?).and_return(user_has_memberships) allow_any_instance_of(EE::WelcomeHelper).to receive(:user_has_memberships?).and_return(user_has_memberships)
...@@ -53,10 +50,7 @@ RSpec.describe 'Welcome screen', :js do ...@@ -53,10 +50,7 @@ RSpec.describe 'Welcome screen', :js do
end end
end end
context 'with the jobs_to_be_done experiment' do it 'allows specifying other for jobs_to_be_done' do
let(:experiments) { { jobs_to_be_done: :candidate } }
it 'allows specifying other for the jobs_to_be_done experiment', :experiment do
expect(page).not_to have_content('Why are you signing up? (Optional)') expect(page).not_to have_content('Why are you signing up? (Optional)')
select 'A different reason', from: 'user_registration_objective' select 'A different reason', from: 'user_registration_objective'
...@@ -65,7 +59,6 @@ RSpec.describe 'Welcome screen', :js do ...@@ -65,7 +59,6 @@ RSpec.describe 'Welcome screen', :js do
fill_in 'jobs_to_be_done_other', with: 'My reason' fill_in 'jobs_to_be_done_other', with: 'My reason'
end end
end
context 'email opt in' do context 'email opt in' do
it 'does not show the email opt in checkbox when setting up for a company' do it 'does not show the email opt in checkbox when setting up for a company' do
......
...@@ -39,19 +39,6 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do ...@@ -39,19 +39,6 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do
expect(subject).to redirect_to(success_path || continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: first_project.id)) expect(subject).to redirect_to(success_path || continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: first_project.id))
end end
context 'jobs_to_be_done experiment' do
let(:jobs_to_be_done_experiment) { experiment(:jobs_to_be_done_experiment) }
it 'tracks an event for the jobs_to_be_done experiment', :experiment do
allow(controller).to receive(:experiment).with(:jobs_to_be_done, user: user).and_return(jobs_to_be_done_experiment)
allow(jobs_to_be_done_experiment).to receive(:track).and_call_original
expect(jobs_to_be_done_experiment).to receive(:track).with(:create_project, project: an_instance_of(Project))
subject
end
end
context 'learn gitlab project' do context 'learn gitlab project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
......
...@@ -14,13 +14,11 @@ RSpec.describe 'registrations/welcome/show' do ...@@ -14,13 +14,11 @@ RSpec.describe 'registrations/welcome/show' do
describe 'forms and progress bar' do describe 'forms and progress bar' do
let_it_be(:user_other_role_details_enabled) { false } let_it_be(:user_other_role_details_enabled) { false }
let_it_be(:stubbed_experiments) { {} }
before do before do
allow(view).to receive(:redirect_path).and_return(redirect_path) allow(view).to receive(:redirect_path).and_return(redirect_path)
allow(view).to receive(:signup_onboarding_enabled?).and_return(signup_onboarding_enabled) allow(view).to receive(:signup_onboarding_enabled?).and_return(signup_onboarding_enabled)
stub_feature_flags(user_other_role_details: user_other_role_details_enabled) stub_feature_flags(user_other_role_details: user_other_role_details_enabled)
stub_experiments(stubbed_experiments)
render render
end end
...@@ -62,16 +60,12 @@ RSpec.describe 'registrations/welcome/show' do ...@@ -62,16 +60,12 @@ RSpec.describe 'registrations/welcome/show' do
end end
end end
context 'experiment(:jobs_to_be_done)' do
let_it_be(:stubbed_experiments) { { jobs_to_be_done: :candidate } }
it 'renders a select and text field for additional information' do it 'renders a select and text field for additional information' do
is_expected.to have_selector('select[name="user[registration_objective]"]') is_expected.to have_selector('select[name="user[registration_objective]"]')
is_expected.to have_selector('input[name="jobs_to_be_done_other"]', visible: false) is_expected.to have_selector('input[name="jobs_to_be_done_other"]', visible: false)
end end
end end
end end
end
def is_expected_to_have_progress_bar(status: true) def is_expected_to_have_progress_bar(status: true)
allow(view).to receive(:show_signup_flow_progress_bar?).and_return(status) allow(view).to receive(:show_signup_flow_progress_bar?).and_return(status)
......
...@@ -23,20 +23,6 @@ describe('experiment Utilities', () => { ...@@ -23,20 +23,6 @@ describe('experiment Utilities', () => {
}); });
}); });
describe('getExperimentContexts', () => {
describe.each`
gon | input | output
${[TEST_KEY, '_data_']} | ${[TEST_KEY]} | ${[{ schema: TRACKING_CONTEXT_SCHEMA, data: { variant: '_data_' } }]}
${[]} | ${[TEST_KEY]} | ${[]}
`('with input=$input and gon=$gon', ({ gon, input, output }) => {
assignGitlabExperiment(...gon);
it(`returns ${output}`, () => {
expect(experimentUtils.getExperimentContexts(...input)).toEqual(output);
});
});
});
describe('getAllExperimentContexts', () => { describe('getAllExperimentContexts', () => {
const schema = TRACKING_CONTEXT_SCHEMA; const schema = TRACKING_CONTEXT_SCHEMA;
let origGon; let origGon;
......
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