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
import { get, pick } from 'lodash';
import { get } from 'lodash';
import { DEFAULT_VARIANT, CANDIDATE_VARIANT, TRACKING_CONTEXT_SCHEMA } from './constants';
function getExperimentsData() {
......@@ -14,12 +14,6 @@ export function getExperimentData(experimentName) {
return getExperimentsData()[experimentName];
}
export function getExperimentContexts(...experimentNames) {
return Object.values(pick(getExperimentsData(), experimentNames)).map(
convertExperimentDataToExperimentContext,
);
}
export function getAllExperimentContexts() {
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';
const select = document.querySelector('.js-jobs-to-be-done-dropdown');
if (select) {
Tracking.enableFormTracking(
{ fields: { allow: ['jobs_to_be_done_other'] } },
getExperimentContexts('jobs_to_be_done'),
);
Tracking.enableFormTracking({ fields: { allow: ['jobs_to_be_done_other'] } });
select.addEventListener('change', () => {
const otherSelected = select.value === 'other';
......
......@@ -20,9 +20,6 @@ module Registrations
@group = Groups::CreateService.new(current_user, group_params).execute
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)
force_company_trial_experiment.track(:create_group, namespace: @group, user: current_user)
......
......@@ -28,7 +28,6 @@ module Registrations
if @group.persisted?
if @group.previously_new_record?
combined_registration_experiment.track(:create_group, namespace: @group)
experiment(:jobs_to_be_done, user: current_user).track(:create_group, namespace: @group)
end
@project = ::Projects::CreateService.new(current_user, project_params).execute
......@@ -36,8 +35,6 @@ module Registrations
combined_registration_experiment.track(:create_project, namespace: @project.namespace)
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?
record_experiment_user(:remove_known_trial_form_fields_welcoming, namespace_id: @group.id)
......@@ -62,7 +59,6 @@ module Registrations
@group = Groups::CreateService.new(current_user, group_params).execute
if @group.persisted?
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
redirect_to import_url
......
......@@ -26,9 +26,6 @@ module Registrations
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)
.track(:create_project, namespace: @project.namespace, project: @project, user: current_user)
......
- experiment(:jobs_to_be_done, user: current_user) do |e|
- e.try do
.row
.form-group.col-sm-12
= 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'
.row
.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)')
= text_field_tag :jobs_to_be_done_other, '', class: 'form-control'
.row
.form-group.col-sm-12
= 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'
.row
.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)')
= text_field_tag :jobs_to_be_done_other, '', class: 'form-control'
......@@ -40,17 +40,6 @@ RSpec.describe Registrations::GroupsController do
expect { post_create }.to change { Group.count }.by(1)
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
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' } }
......
......@@ -69,17 +69,6 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
expect { subject }.to change { Group.count }.by(1)
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
allow_next_instance_of(::Projects::CreateService) do |service|
allow(service).to receive(:after_create_actions)
......@@ -257,17 +246,6 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
expect { subject }.to change { Group.count }.by(1)
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
expect(experiment(:combined_registration)).to track(:create_group, namespace: an_instance_of(Group))
.on_next_instance
......
......@@ -5,15 +5,12 @@ require 'spec_helper'
RSpec.describe 'Welcome screen', :js do
let_it_be(:user) { create(:user) }
let(:experiments) { {} }
context 'when on GitLab.com' do
let(:user_has_memberships) { false }
let(:in_subscription_flow) { false }
let(:in_trial_flow) { false }
before do
stub_experiments(experiments)
allow(Gitlab).to receive(:com?).and_return(true)
gitlab_sign_in(user)
allow_any_instance_of(EE::WelcomeHelper).to receive(:user_has_memberships?).and_return(user_has_memberships)
......@@ -53,18 +50,14 @@ RSpec.describe 'Welcome screen', :js do
end
end
context 'with the jobs_to_be_done experiment' 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)')
it 'allows specifying other for jobs_to_be_done' do
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'
expect(page).to have_content('Why are you signing up? (Optional)')
expect(page).to have_content('Why are you signing up? (Optional)')
fill_in 'jobs_to_be_done_other', with: 'My reason'
end
fill_in 'jobs_to_be_done_other', with: 'My reason'
end
context 'email opt in' 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))
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
using RSpec::Parameterized::TableSyntax
......
......@@ -14,13 +14,11 @@ RSpec.describe 'registrations/welcome/show' do
describe 'forms and progress bar' do
let_it_be(:user_other_role_details_enabled) { false }
let_it_be(:stubbed_experiments) { {} }
before do
allow(view).to receive(:redirect_path).and_return(redirect_path)
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_experiments(stubbed_experiments)
render
end
......@@ -62,13 +60,9 @@ RSpec.describe 'registrations/welcome/show' do
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
is_expected.to have_selector('select[name="user[registration_objective]"]')
is_expected.to have_selector('input[name="jobs_to_be_done_other"]', visible: false)
end
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('input[name="jobs_to_be_done_other"]', visible: false)
end
end
end
......
......@@ -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', () => {
const schema = TRACKING_CONTEXT_SCHEMA;
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