Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
430c1ca
changelog: Internal Fixes, Authentication, set up logging to differen…
mdiarra3 Aug 31, 2023
64127b7
changelog: Internal, Authentication, update logging for clearer disti…
mdiarra3 Sep 1, 2023
04363a3
update analytic events
mdiarra3 Sep 1, 2023
63c7212
fix spec and analytic event description length
mdiarra3 Sep 1, 2023
ce2b246
move password session setting after user session created
mdiarra3 Sep 5, 2023
e57e711
fix webauthn visit form
mdiarra3 Sep 5, 2023
b8fb954
analytic properties
mdiarra3 Sep 5, 2023
a2131ed
dont remove user registration method yet
mdiarra3 Sep 5, 2023
0e4b0c8
update to ensure it returns false
mdiarra3 Sep 6, 2023
27dabb7
fix to redirect
mdiarra3 Sep 7, 2023
822e623
Merge remote-tracking branch 'origin/main' into LG-10769-differentiat…
mdiarra3 Sep 7, 2023
977f0a5
in account creation flow specs fixed
mdiarra3 Sep 7, 2023
8f6ae97
make sure to only delete session when at mfa_setup step
mdiarra3 Sep 11, 2023
8e12b82
after skip path
mdiarra3 Sep 11, 2023
5e7bc0b
add spec
mdiarra3 Sep 11, 2023
80941db
Leverage to use completions controller
mdiarra3 Sep 14, 2023
56ed9b1
add new event params to completions event
mdiarra3 Sep 14, 2023
d6825ea
Merge remote-tracking branch 'origin/main' into LG-10769-differentiat…
mdiarra3 Sep 14, 2023
f7ae96d
remove pii
mdiarra3 Sep 14, 2023
28dbfb1
after sign in path
mdiarra3 Sep 14, 2023
dc3ed79
Merge remote-tracking branch 'origin/main' into LG-10769-differentiat…
mdiarra3 Sep 14, 2023
64d0164
address comments, move helper method to concern
mdiarra3 Sep 15, 2023
61e4d63
move back setup concern
mdiarra3 Sep 15, 2023
7719562
include helper method through concern
mdiarra3 Sep 15, 2023
4c8284c
change back to setup mfa concern
mdiarra3 Sep 15, 2023
b09402d
fix completions controller
mdiarra3 Sep 18, 2023
93023c4
Merge remote-tracking branch 'origin/main' into LG-10769-differentiat…
mdiarra3 Sep 18, 2023
ee0518f
fix specs
mdiarra3 Sep 18, 2023
1803911
relocate method to setup concern
mdiarra3 Sep 18, 2023
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
5 changes: 5 additions & 0 deletions app/controllers/concerns/mfa_setup_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def next_setup_path
if user_session[:mfa_selections]
analytics.user_registration_mfa_setup_complete(
mfa_method_counts: mfa_context.enabled_two_factor_configuration_counts_hash,
in_account_creation_flow: user_session[:in_account_creation_flow] || false,
enabled_mfa_methods_count: mfa_context.enabled_mfa_methods_count,
pii_like_keypaths: [[:mfa_method_counts, :phone]],
second_mfa_reminder_conversion: user_session.delete(:second_mfa_reminder_conversion),
Expand Down Expand Up @@ -60,6 +61,10 @@ def suggest_second_mfa?
mfa_selection_count < 2 && mfa_context.enabled_mfa_methods_count < 2
end

def in_account_creation_flow?
user_session[:in_account_creation_flow] || false
end

def mfa_selection_count
user_session[:mfa_selections]&.count || 0
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/sign_up/completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ def analytics_attributes(page_occurence)
sp_session_requested_attributes: sp_session[:requested_attributes],
sp_request_requested_attributes: service_provider_request.requested_attributes,
page_occurence: page_occurence,
in_account_creation_flow: user_session[:in_account_creation_flow] || false,
needs_completion_screen_reason: needs_completion_screen_reason }
end

def track_completion_event(last_page)
analytics.user_registration_complete(**analytics_attributes(last_page))
user_session.delete(:in_account_creation_flow)
end

def pii
Expand Down
1 change: 1 addition & 0 deletions app/controllers/sign_up/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def process_unsuccessful_password_creation

def sign_in_and_redirect_user
sign_in @user
user_session[:in_account_creation_flow] = true
if current_user.accepted_rules_of_use_still_valid?
redirect_to authentication_methods_setup_url
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def redirect_if_blank_phone
def track_mfa_added
analytics.multi_factor_auth_added_phone(
enabled_mfa_methods_count: MfaContext.new(current_user).enabled_mfa_methods_count,
in_account_creation_flow: user_session[:in_account_creation_flow] || false,
)
Funnel::Registration::AddMfa.call(current_user.id, 'phone', analytics)
end
Expand Down Expand Up @@ -158,7 +159,7 @@ def analytics_properties
country_code: parsed_phone.country,
phone_fingerprint: Pii::Fingerprinter.fingerprint(parsed_phone.e164),
phone_configuration_id: phone_configuration&.id,
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: user_session[:in_account_creation_flow] || false,
enabled_mfa_methods_count: mfa_context.enabled_mfa_methods_count,
}
end
Expand Down
11 changes: 6 additions & 5 deletions app/controllers/users/backup_code_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def index
def create
generate_codes
result = BackupCodeSetupForm.new(current_user).submit
analytics_properties = result.to_h.merge(analytics_properties_for_visit)
analytics.backup_code_setup_visit(**analytics_properties)
visit_result = result.to_h.merge(analytics_properties_for_visit)
analytics.backup_code_setup_visit(**visit_result)
irs_attempts_api_tracker.mfa_enroll_backup_code(success: result.success?)

save_backup_codes
Expand Down Expand Up @@ -65,12 +65,13 @@ def confirm_backup_codes; end
private

def analytics_properties_for_visit
{ in_multi_mfa_selection_flow: in_multi_mfa_selection_flow? }
{ in_account_creation_flow: in_account_creation_flow? }
end

def track_backup_codes_created
analytics.backup_code_created(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
in_account_creation_flow: in_account_creation_flow?,
)
Funnel::Registration::AddMfa.call(current_user.id, 'backup_codes', analytics)
end
Expand All @@ -82,7 +83,7 @@ def mfa_user
def track_backup_codes_confirmation_setup_visit
analytics.multi_factor_auth_enter_backup_code_confirmation_visit(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: in_account_creation_flow?,
)
end

Expand Down Expand Up @@ -128,7 +129,7 @@ def analytics_properties
{
success: true,
multi_factor_auth_method: 'backup_codes',
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: in_account_creation_flow?,
enabled_mfa_methods_count: mfa_context.enabled_mfa_methods_count,
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/phone_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def recaptcha_enabled?

def track_phone_setup_visit
mfa_user = MfaContext.new(current_user)
if in_multi_mfa_selection_flow?
if user_session[:in_account_creation_flow]
analytics.user_registration_phone_setup_visit(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
)
Expand Down
17 changes: 4 additions & 13 deletions app/controllers/users/piv_cac_authentication_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def submit_new_piv_cac
private

def track_piv_cac_setup_visit
mfa_user = MfaContext.new(current_user)
Comment thread
mdiarra3 marked this conversation as resolved.
analytics.piv_cac_setup_visit(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
)
analytics.piv_cac_setup_visit(**analytics_properties)
end

def remove_piv_cac
Expand Down Expand Up @@ -124,16 +120,11 @@ def process_valid_submission
create_user_event(:piv_cac_enabled)
track_mfa_method_added
session[:needs_to_setup_piv_cac_after_sign_in] = false
final_path = after_sign_in_path_for(current_user)
redirect_to next_setup_path || final_path
redirect_to next_setup_path || after_sign_in_path_for(current_user)
end

def track_mfa_method_added
mfa_user = MfaContext.new(current_user)
analytics.multi_factor_auth_added_piv_cac(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
)
analytics.multi_factor_auth_added_piv_cac(**analytics_properties)
Funnel::Registration::AddMfa.call(current_user.id, 'piv_cac', analytics)
end

Expand Down Expand Up @@ -163,7 +154,7 @@ def good_nickname

def analytics_properties
{
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: user_session[:in_account_creation_flow] || false,
enabled_mfa_methods_count: mfa_context.enabled_mfa_methods_count,
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/piv_cac_login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def error
private

def render_prompt
analytics.piv_cac_setup_visit(in_multi_mfa_selection_flow: false)
analytics.piv_cac_setup_visit(in_account_creation_flow: false)
@presenter = PivCacAuthenticationLoginPresenter.new(piv_cac_login_form, url_options)
render :new
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def decline
private

def render_prompt
analytics.piv_cac_setup_visit(in_multi_mfa_selection_flow: false)
analytics.piv_cac_setup_visit(in_account_creation_flow: false)
render :prompt
end

Expand Down Expand Up @@ -81,7 +81,7 @@ def process_valid_submission

def analytics_properties
{
in_multi_mfa_selection_flow: false,
in_account_creation_flow: false,
enabled_mfa_methods_count: MfaContext.new(current_user).enabled_mfa_methods_count,
}
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/users/totp_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def track_event
user_signed_up: MfaPolicy.new(current_user).two_factor_enabled?,
totp_secret_present: new_totp_secret.present?,
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: in_account_creation_flow?,
)
end

Expand All @@ -97,7 +97,7 @@ def create_events
mfa_user = MfaContext.new(current_user)
analytics.multi_factor_auth_added_totp(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: in_account_creation_flow?,
)
Funnel::Registration::AddMfa.call(current_user.id, 'auth_app', analytics)
end
Expand Down Expand Up @@ -141,7 +141,7 @@ def current_auth_app_count

def analytics_properties
{
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: in_account_creation_flow?,
pii_like_keypaths: [[:mfa_method_counts, :phone]],
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/webauthn_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def process_valid_webauthn(form)

def analytics_properties
{
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow?,
in_account_creation_flow: user_session[:in_account_creation_flow] || false,
}
end

Expand Down
42 changes: 21 additions & 21 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def backup_code_created(enabled_mfa_methods_count:, **extra)
end

# Tracks when the user visits the Backup Code Regenerate page.
# @param [Boolean] in_multi_mfa_selection_flow whether user is going through MFA selection Flow
def backup_code_regenerate_visit(in_multi_mfa_selection_flow:, **extra)
track_event('Backup Code Regenerate Visited', in_multi_mfa_selection_flow:, **extra)
# @param [Boolean] in_account_creation_flow whether user is going through creation flow
def backup_code_regenerate_visit(in_account_creation_flow:, **extra)
track_event('Backup Code Regenerate Visited', in_account_creation_flow:, **extra)
end

# Track user creating new BackupCodeSetupForm, record form submission Hash
Expand Down Expand Up @@ -2635,30 +2635,30 @@ def multi_factor_auth_added_phone(enabled_mfa_methods_count:, **extra)

# Tracks when the user has added the MFA method piv_cac to their account
# @param [Integer] enabled_mfa_methods_count number of registered mfa methods for the user
# @param [Boolean] in_multi_mfa_selection_flow whether user is going through MFA selection Flow
def multi_factor_auth_added_piv_cac(enabled_mfa_methods_count:, in_multi_mfa_selection_flow:,
# @param [Boolean] in_account_creation_flow whether user is going through creation flow
def multi_factor_auth_added_piv_cac(enabled_mfa_methods_count:, in_account_creation_flow:,
**extra)
track_event(
'Multi-Factor Authentication: Added PIV_CAC',
{
method_name: :piv_cac,
enabled_mfa_methods_count:,
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
**extra,
}.compact,
)
end

# Tracks when the user has added the MFA method TOTP to their account
# @param [Integer] enabled_mfa_methods_count number of registered mfa methods for the user
# @param [Boolean] in_multi_mfa_selection_flow whether user is going through MFA selection Flow
def multi_factor_auth_added_totp(enabled_mfa_methods_count:, in_multi_mfa_selection_flow:,
# @param [Boolean] in_account_creation_flow whether user is going through creation flow
def multi_factor_auth_added_totp(enabled_mfa_methods_count:, in_account_creation_flow:,
**extra)
track_event(
'Multi-Factor Authentication: Added TOTP',
{
method_name: :totp,
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
enabled_mfa_methods_count:,
**extra,
}.compact,
Expand Down Expand Up @@ -2690,17 +2690,17 @@ def multi_factor_auth_backup_code_download

# Tracks when the user visits the backup code confirmation setup page
# @param [Integer] enabled_mfa_methods_count number of registered mfa methods for the user
# @param [Boolean] in_multi_mfa_selection_flow tell whether its in MFA selection flow or not
# @param [Boolean] in_account_creation_flow whether user is going through creation flow
def multi_factor_auth_enter_backup_code_confirmation_visit(
enabled_mfa_methods_count:,
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
**extra
)
track_event(
'Multi-Factor Authentication: enter backup code confirmation visited',
{
enabled_mfa_methods_count:,
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
**extra,
}.compact,
)
Expand Down Expand Up @@ -2859,13 +2859,13 @@ def multi_factor_auth_phone_setup(success:,
# @param [Boolean] success Whether authenticator setup was successful
# @param [Hash] errors Authenticator setup error reasons, if unsuccessful
# @param [String] multi_factor_auth_method
# @param [Boolean] in_multi_mfa_selection_flow
# @param [Boolean] in_account_creation_flow whether user is going through account creation flow
# @param [integer] enabled_mfa_methods_count
def multi_factor_auth_setup(
success:,
multi_factor_auth_method:,
enabled_mfa_methods_count:,
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
errors: nil,
**extra
)
Expand All @@ -2874,7 +2874,7 @@ def multi_factor_auth_setup(
success: success,
errors: errors,
multi_factor_auth_method: multi_factor_auth_method,
in_multi_mfa_selection_flow: in_multi_mfa_selection_flow,
in_account_creation_flow: in_account_creation_flow,
enabled_mfa_methods_count: enabled_mfa_methods_count,
**extra,
)
Expand Down Expand Up @@ -3386,11 +3386,11 @@ def piv_cac_login(success:, errors:, **extra)

# @identity.idp.previous_event_name User Registration: piv cac setup visited
# Tracks when user's piv cac setup
# @param [Boolean] in_multi_mfa_selection_flow
def piv_cac_setup_visit(in_multi_mfa_selection_flow:, **extra)
# @param [Boolean] in_account_creation_flow
def piv_cac_setup_visit(in_account_creation_flow:, **extra)
track_event(
'PIV CAC setup visited',
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
**extra,
)
end
Expand Down Expand Up @@ -3892,20 +3892,20 @@ def telephony_otp_sent(
# @param [Boolean] user_signed_up
# @param [Boolean] totp_secret_present
# @param [Integer] enabled_mfa_methods_count
# @param [Boolean] in_multi_mfa_selection_flow
# @param [Boolean] in_account_creation_flow
def totp_setup_visit(
user_signed_up:,
totp_secret_present:,
enabled_mfa_methods_count:,
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
**extra
)
track_event(
'TOTP Setup Visited',
user_signed_up:,
totp_secret_present:,
enabled_mfa_methods_count:,
in_multi_mfa_selection_flow:,
in_account_creation_flow:,
**extra,
)
end
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/concerns/mfa_setup_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
mfa_method_counts: { phone: 1, backup_codes: 10 },
enabled_mfa_methods_count: 2,
second_mfa_reminder_conversion: true,
in_account_creation_flow: false,
)
end
end
Expand Down
Loading