Commit 904d3987 authored by Nicolas Dular's avatar Nicolas Dular

Record terms opt in experiment users

To have a better data quality, we want to also know which users
are part of the experiment. This should help us to filter out bots
from automatic sign up scripts.

We now also only track the end of the experiment phase only for
valid sign up data.
parent cad1d0b0
......@@ -26,12 +26,12 @@ class RegistrationsController < Devise::RegistrationsController
end
def create
track_experiment_event(:terms_opt_in, 'end')
accept_pending_invitations
super do |new_user|
persist_accepted_terms_if_required(new_user)
set_role_required(new_user)
track_terms_experiment(new_user)
yield new_user if block_given?
end
......@@ -201,6 +201,13 @@ class RegistrationsController < Devise::RegistrationsController
true
end
def track_terms_experiment(new_user)
return unless new_user.persisted?
track_experiment_event(:terms_opt_in, 'end')
record_experiment_user(:terms_opt_in)
end
def load_recaptcha
Gitlab::Recaptcha.load_configurations!
end
......
......@@ -316,6 +316,12 @@ RSpec.describe RegistrationsController do
stub_experiment(signup_flow: true, terms_opt_in: true)
end
it 'records user for the terms_opt_in experiment' do
expect(controller).to receive(:record_experiment_user).with(:terms_opt_in)
subject
end
context 'when user is not part of the experiment' do
before do
stub_experiment_for_user(signup_flow: true, terms_opt_in: false)
......
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