Commit d358e6ae authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '219544-fix-experiment-viability' into 'master'

Fix experiment calculation for registration invites

See merge request gitlab-org/gitlab!55760
parents f85dc2a0 6dc02add
......@@ -15,7 +15,7 @@ module Registrations
result = Members::CreateService.new(current_user, invite_params).execute(group)
if result[:status] == :success
experiment(:registrations_group_invite, actor: :user)
experiment(:registrations_group_invite, actor: current_user)
.track(:invites_sent, property: group.id.to_s, value: group.members.invite.size)
end
......
......@@ -63,7 +63,7 @@ module Registrations
record_experiment_conversion_event(:trial_registration_with_social_signin)
record_experiment_conversion_event(:trial_onboarding_issues)
experiment(:registrations_group_invite, actor: :user) do |experiment_instance|
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true) } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
......@@ -79,7 +79,7 @@ module Registrations
if experiment_enabled?(:trial_during_signup)
trial_during_signup_flow
else
experiment(:registrations_group_invite, actor: :user) do |experiment_instance|
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { invite_on_create } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
......@@ -97,7 +97,7 @@ module Registrations
if helpers.in_trial_during_signup_flow?
create_lead_and_apply_trial_flow
else
experiment(:registrations_group_invite, actor: :user) do |experiment_instance|
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
......@@ -109,7 +109,7 @@ module Registrations
if create_lead && apply_trial
record_experiment_conversion_event(:trial_during_signup)
experiment(:registrations_group_invite, actor: :user) do |experiment_instance|
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
......
......@@ -25,6 +25,9 @@ module Registrations
if @project.saved?
learn_gitlab_project = create_learn_gitlab_project
experiment(:registrations_group_invite, actor: current_user)
.track(:signup_successful, property: @project.namespace_id.to_s)
if helpers.in_trial_onboarding_flow?
trial_onboarding_context = {
namespace_id: learn_gitlab_project.namespace_id,
......@@ -35,9 +38,6 @@ module Registrations
record_experiment_user(:trial_onboarding_issues, trial_onboarding_context)
record_experiment_conversion_event(:trial_onboarding_issues)
experiment(:registrations_group_invite, actor: @project.group)
.track(:signup_successful, property: @project.namespace_id)
redirect_to trial_getting_started_users_sign_up_welcome_path(learn_gitlab_project_id: learn_gitlab_project.id)
else
redirect_to users_sign_up_experience_level_path(namespace_path: @project.namespace)
......
......@@ -44,7 +44,7 @@
- if !in_trial_onboarding_flow? && experiment_enabled?(:trial_during_signup)
= render partial: 'shared/groups/trial_form'
- else
- experiment(:registrations_group_invite, actor: :user) do |experiment_instance|
- experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
- experiment_instance.use do
= render partial: 'shared/groups/invite_members'
- experiment_instance.try(:invite_page) {}
......
......@@ -259,7 +259,7 @@ RSpec.describe Registrations::GroupsController do
expect(experiment(:registrations_group_invite))
.to track(:created, { property: group.id.to_s })
.on_any_instance
.with_context(actor: :user)
.with_context(actor: user)
subject
end
......@@ -325,7 +325,7 @@ RSpec.describe Registrations::GroupsController do
expect(experiment(:registrations_group_invite))
.to track(:created, { property: group.id.to_s })
.on_any_instance
.with_context(actor: :user)
.with_context(actor: user)
subject
end
......@@ -361,7 +361,7 @@ RSpec.describe Registrations::GroupsController do
expect(experiment(:registrations_group_invite))
.to track(:created, { property: group.id.to_s })
.on_any_instance
.with_context(actor: :user)
.with_context(actor: user)
subject
end
......
......@@ -79,6 +79,15 @@ RSpec.describe Registrations::ProjectsController do
expect(namespace.projects.find_by_name(s_('Learn GitLab'))).to be_import_finished
end
it 'tracks the registrations_group_invite experiment as expected', :experiment do
expect(experiment(:registrations_group_invite))
.to track(:signup_successful, { property: namespace.id.to_s })
.on_any_instance
.with_context(actor: user)
subject
end
context 'learn gitlab project' do
using RSpec::Parameterized::TableSyntax
......
......@@ -83,7 +83,7 @@ RSpec.describe 'view group invites' do
expect(experiment(:registrations_group_invite))
.to track(:invites_sent, { property: group.id.to_s, value: valid_emails.size })
.on_any_instance
.with_context(actor: :user)
.with_context(actor: user)
post_request
end
......
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