Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/sign_up/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class RegistrationsController < ApplicationController

def new
@register_user_email_form = RegisterUserEmailForm.new(analytics: analytics)
analytics.track_event(Analytics::USER_REGISTRATION_ENTER_EMAIL_VISIT)
analytics.user_registration_enter_email_visit
render :new, locals: { request_id: nil }, formats: :html
end

Expand Down
3 changes: 1 addition & 2 deletions app/controllers/users/phone_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def create

def track_phone_setup_visit
mfa_user = MfaContext.new(current_user)
analytics.track_event(
Analytics::USER_REGISTRATION_PHONE_SETUP_VISIT,
analytics.user_registration_phone_setup_visit(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
)
end
Expand Down
5 changes: 0 additions & 5 deletions app/services/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ def session_started_at
USER_REGISTRATION_EMAIL = 'User Registration: Email Submitted'
USER_REGISTRATION_EMAIL_CONFIRMATION = 'User Registration: Email Confirmation'
USER_REGISTRATION_EMAIL_CONFIRMATION_RESEND = 'User Registration: Email Confirmation requested due to invalid token'
USER_REGISTRATION_ENTER_EMAIL_VISIT = 'User Registration: enter email visited'
USER_REGISTRATION_INTRO_VISIT = 'User Registration: intro visited'
USER_REGISTRATION_2FA_SETUP = 'User Registration: 2FA Setup'
USER_REGISTRATION_2FA_SETUP_VISIT = 'User Registration: 2FA Setup visited'
USER_REGISTRATION_PHONE_SETUP_VISIT = 'User Registration: phone setup visited'
USER_REGISTRATION_PERSONAL_KEY_VISIT = 'User Registration: personal key visited'
USER_REGISTRATION_PIV_CAC_DISABLED = 'User Registration: piv cac disabled'
USER_REGISTRATION_PIV_CAC_SETUP_VISIT = 'User Registration: piv cac setup visited'
Expand Down
27 changes: 26 additions & 1 deletion app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1822,13 +1822,23 @@ def user_registration_2fa_additional_setup_visit

# @param [Boolean] success
# @param [Hash] errors
# @param [Integer] enabled_mfa_methods_count
# @param ['voice', 'auth_app'] selection
# Tracks when the the user has selected and submitted MFA auth methods on user registration
def user_registration_2fa_setup(success:, errors: nil, **extra)
def user_registration_2fa_setup(
success:,
errors: nil,
enabled_mfa_methods_count: nil,
selection: nil,
**extra
)
track_event(
'User Registration: 2FA Setup',
{
success: success,
errors: errors,
enabled_mfa_methods_count: enabled_mfa_methods_count,
selection: selection,
**extra,
}.compact,
)
Expand All @@ -1838,5 +1848,20 @@ def user_registration_2fa_setup(success:, errors: nil, **extra)
def user_registration_2fa_setup_visit
track_event('User Registration: 2FA Setup visited')
end

# Tracks when user visits enter email page
def user_registration_enter_email_visit
track_event('User Registration: enter email visited')
end

# @param [Integer] enabled_mfa_methods_count
# Tracks when user visits the phone setup step during registration
def user_registration_phone_setup_visit(enabled_mfa_methods_count:, **extra)
track_event(
'User Registration: phone setup visited',
enabled_mfa_methods_count: enabled_mfa_methods_count,
**extra,
)
end
end
# rubocop:enable Metrics/ModuleLength
2 changes: 1 addition & 1 deletion spec/controllers/users/phone_setup_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
stub_sign_in_before_2fa(user)

expect(@analytics).to receive(:track_event).
with(Analytics::USER_REGISTRATION_PHONE_SETUP_VISIT, enabled_mfa_methods_count: 0)
with('User Registration: phone setup visited', enabled_mfa_methods_count: 0)
expect(NewPhoneForm).to receive(:new).with(user)

get :index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
stub_analytics

expect(@analytics).to receive(:track_event).
with(Analytics::USER_REGISTRATION_2FA_SETUP_VISIT)
with('User Registration: 2FA Setup visited')

get :index
end
Expand Down Expand Up @@ -76,7 +76,7 @@

patch :create, params: voice_params

expect(@analytics).to have_logged_event(Analytics::USER_REGISTRATION_2FA_SETUP, response.to_h)
expect(@analytics).to have_logged_event('User Registration: 2FA Setup', response.to_h)
end

it 'tracks analytics event' do
Expand All @@ -91,7 +91,7 @@
}

expect(@analytics).to receive(:track_event).
with(Analytics::USER_REGISTRATION_2FA_SETUP, result)
with('User Registration: 2FA Setup', result)

patch :create, params: {
two_factor_options_form: {
Expand Down