Skip to content
Snippets Groups Projects
Verified Commit 54a707f6 authored by Doug Stull's avatar Doug Stull :two: Committed by GitLab
Browse files

Merge branch '441988-add-subscription-tracking-label-for-sign-up' into 'master'

Add subscription tracking label for sign up

See merge request !147085



Merged-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Approved-by: default avatarAmmar Alakkad <aalakkad@gitlab.com>
Approved-by: default avatarSarah Yasonik <syasonik@gitlab.com>
Approved-by: default avatarIan Anderson <ianderson@gitlab.com>
Approved-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Reviewed-by: default avatarAndrew Evans <aevans@gitlab.com>
Reviewed-by: default avatarSarah Yasonik <syasonik@gitlab.com>
Reviewed-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Reviewed-by: default avatarIan Anderson <ianderson@gitlab.com>
Co-authored-by: default avatarSerhii Yarynovskyi <syarynovskyi@gitlab.com>
parents 27ee35de f649a1e7
No related branches found
No related tags found
1 merge request!147085Add subscription tracking label for sign up
Pipeline #1250778769 canceled
......@@ -163,11 +163,10 @@ def registration_path_params
{}
end
# overridden in EE
def track_successful_user_creation(user)
label = user_invited? ? 'invited' : 'signup'
Gitlab::Tracking.event(self.class.name, 'create_user', label: label, user: user)
Gitlab::Tracking.event(self.class.name, 'successfully_submitted_form', user: user)
end
def ensure_destroy_prerequisites_met
......
......@@ -20,6 +20,17 @@ module RegistrationsController
before_action :verify_arkose_labs_challenge!, only: :create
end
override :new
def new
super
::Gitlab::Tracking.event(
self.class.name,
'render_registration_page',
label: registration_tracking_label
)
end
override :destroy
def destroy
unless allow_account_deletion?
......@@ -144,6 +155,16 @@ def registration_path_params
glm_tracking_params.to_h
end
override :track_successful_user_creation
def track_successful_user_creation(user)
::Gitlab::Tracking.event(
self.class.name,
'successfully_submitted_form',
label: registration_tracking_label,
user: user
)
end
def record_arkose_data(user)
return unless arkose_labs_enabled?(user: user)
return unless arkose_labs_verify_response
......@@ -159,6 +180,13 @@ def arkose_labs_enabled?(user: nil)
::Arkose::Settings.enabled?(user: user, user_agent: request.user_agent)
end
def registration_tracking_label
return ::Onboarding::Status::TRACKING_LABEL[:trial] if onboarding_status.trial?
return ::Onboarding::Status::TRACKING_LABEL[:invite] if params[:invite_email].present?
onboarding_status.tracking_label
end
def allow_account_deletion?
!License.feature_available?(:disable_deleting_account_for_users) ||
::Gitlab::CurrentSettings.allow_account_deletion?
......
......@@ -21,6 +21,12 @@ class TrialRegistrationsController < RegistrationsController
override :new
def new
@resource = Users::AuthorizedBuildService.new(nil, {}).execute
::Gitlab::Tracking.event(
self.class.name,
'render_registration_page',
label: ::Onboarding::Status::TRACKING_LABEL[:trial]
)
end
private
......
= render 'devise/shared/signup_omniauth_provider_list',
providers: popular_enabled_button_based_providers,
trial: true,
tracking_label: registration_tracking_label(trial: true)
= render 'shared/divider', text: _("or")
......@@ -3,14 +3,66 @@
require 'spec_helper'
RSpec.describe RegistrationsController, type: :request, feature_category: :system_access do
include SessionHelpers
let_it_be(:user_attrs) do
build_stubbed(:user).slice(:first_name, :last_name, :username, :email, :password)
end
before do
allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(false)
allow(::Arkose::Settings).to receive(:enabled?).and_return(false)
end
describe 'POST #create' do
let_it_be(:user_attrs) { build_stubbed(:user).slice(:first_name, :last_name, :username, :email, :password) }
describe 'GET #new' do
let(:params) { { user: user_attrs } }
subject(:new_user) { get new_user_registration_path, params: params }
context 'with tracking' do
it 'tracks page render' do
new_user
expect_snowplow_event(
category: described_class.name,
action: 'render_registration_page',
label: 'free_registration'
)
end
context 'when invite' do
let(:params) { { user: user_attrs, invite_email: 'new@email.com' } }
it 'tracks page render' do
new_user
expect_snowplow_event(
category: described_class.name,
action: 'render_registration_page',
label: 'invite_registration'
)
end
end
context 'when subscription', :saas, :clean_gitlab_redis_sessions do
before do
stub_session(user_return_to: new_subscriptions_path)
end
it 'tracks successful form submission' do
new_user
expect_snowplow_event(
category: described_class.name,
action: 'render_registration_page',
label: 'subscription_registration'
)
end
end
end
end
describe 'POST #create' do
subject(:create_user) { post user_registration_path, params: { user: user_attrs } }
it_behaves_like 'creates a user with ArkoseLabs risk band on signup request' do
......@@ -227,5 +279,52 @@
end
end
end
context 'with tracking' do
it 'tracks successful form submission' do
create_user
expect_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form',
label: 'free_registration',
user: User.find_by(email: user_attrs[:email])
)
end
context 'when invite' do
subject(:create_user) do
post user_registration_path, params: { user: user_attrs, invite_email: 'new@email.com' }
end
it 'tracks successful form submission' do
create_user
expect_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form',
label: 'invite_registration',
user: User.find_by(email: user_attrs[:email])
)
end
end
context 'when subscription', :saas, :clean_gitlab_redis_sessions do
before do
stub_session(user_return_to: new_subscriptions_path)
end
it 'tracks successful form submission' do
create_user
expect_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form',
label: 'subscription_registration',
user: User.find_by(email: user_attrs[:email])
)
end
end
end
end
end
......@@ -8,7 +8,7 @@
describe 'GET new' do
let(:get_params) { {} }
subject do
subject(:get_new) do
get new_trial_registration_path, params: get_params
response
end
......@@ -23,6 +23,18 @@
context 'when user is not authenticated' do
it { is_expected.to have_gitlab_http_status(:ok) }
context 'with tracking' do
it 'tracks page render' do
get_new
expect_snowplow_event(
category: described_class.name,
action: 'render_registration_page',
label: 'trial_registration'
)
end
end
end
context 'when user is authenticated' do
......@@ -88,29 +100,15 @@
end
context 'with snowplow tracking', :snowplow do
context 'when the password is weak' do
let(:user_params) { super().merge(password: '1') }
it 'does not track failed form submission' do
post_create
expect_no_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form'
)
end
end
context 'when the password is not weak' do
it 'tracks successful form submission' do
post_create
it 'tracks successful form submission' do
post_create
expect_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form',
user: User.find_by(email: user_params[:email])
)
end
expect_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form',
label: 'trial_registration',
user: User.find_by(email: user_params[:email])
)
end
context 'with email confirmation' do
......
......@@ -212,13 +212,6 @@
property: member.id.to_s,
user: member.reload.user
)
expect_snowplow_event(
category: 'RegistrationsController',
action: 'create_user',
label: 'invited',
user: member.reload.user
)
end
end
......@@ -233,13 +226,6 @@
action: 'accepted',
label: 'invite_email'
)
expect_snowplow_event(
category: 'RegistrationsController',
action: 'create_user',
label: 'signup',
user: member.reload.user
)
end
end
end
......@@ -554,15 +540,6 @@
method: 'create'
)
end
it 'does not track failed form submission' do
post_create
expect_no_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form'
)
end
end
context 'when the password is not weak' do
......@@ -574,16 +551,6 @@
action: 'track_weak_password_error'
)
end
it 'tracks successful form submission' do
post_create
expect_snowplow_event(
category: described_class.name,
action: 'successfully_submitted_form',
user: User.find_by(email: base_user_params[:email])
)
end
end
context 'with preferred language' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment