diff --git a/app/controllers/two_factor_authentication/backup_code_verification_controller.rb b/app/controllers/two_factor_authentication/backup_code_verification_controller.rb index c3d97880c11..62bd3634e2b 100644 --- a/app/controllers/two_factor_authentication/backup_code_verification_controller.rb +++ b/app/controllers/two_factor_authentication/backup_code_verification_controller.rb @@ -6,9 +6,7 @@ class BackupCodeVerificationController < ApplicationController before_action :check_sp_required_mfa_bypass def show - analytics.track_event( - Analytics::MULTI_FACTOR_AUTH_ENTER_BACKUP_CODE_VISIT, context: context - ) + analytics.multi_factor_auth_enter_backup_code_visit(context: context) @presenter = TwoFactorAuthCode::BackupCodePresenter.new( view: view_context, data: { current_user: current_user }, diff --git a/app/controllers/two_factor_authentication/personal_key_verification_controller.rb b/app/controllers/two_factor_authentication/personal_key_verification_controller.rb index d46fd785c21..eb56cad8773 100644 --- a/app/controllers/two_factor_authentication/personal_key_verification_controller.rb +++ b/app/controllers/two_factor_authentication/personal_key_verification_controller.rb @@ -6,9 +6,7 @@ class PersonalKeyVerificationController < ApplicationController before_action :check_personal_key_enabled def show - analytics.track_event( - Analytics::MULTI_FACTOR_AUTH_ENTER_PERSONAL_KEY_VISIT, context: context - ) + analytics.multi_factor_auth_enter_personal_key_visit(context: context) @presenter = TwoFactorAuthCode::PersonalKeyPresenter.new @personal_key_form = PersonalKeyForm.new(current_user) end diff --git a/app/controllers/two_factor_authentication/piv_cac_verification_controller.rb b/app/controllers/two_factor_authentication/piv_cac_verification_controller.rb index 587e78a61f6..4ed00032819 100644 --- a/app/controllers/two_factor_authentication/piv_cac_verification_controller.rb +++ b/app/controllers/two_factor_authentication/piv_cac_verification_controller.rb @@ -7,7 +7,7 @@ class PivCacVerificationController < ApplicationController before_action :reset_attempt_count_if_user_no_longer_locked_out, only: :show def show - analytics.track_event(Analytics::MULTI_FACTOR_AUTH_ENTER_PIV_CAC, analytics_properties) + analytics.multi_factor_auth_enter_piv_cac(**analytics_properties) if params[:token] process_token else diff --git a/app/controllers/two_factor_authentication/totp_verification_controller.rb b/app/controllers/two_factor_authentication/totp_verification_controller.rb index f374b447c54..7dc2f3a87e9 100644 --- a/app/controllers/two_factor_authentication/totp_verification_controller.rb +++ b/app/controllers/two_factor_authentication/totp_verification_controller.rb @@ -8,7 +8,7 @@ def show @presenter = presenter_for_two_factor_authentication_method return unless FeatureManagement.prefill_otp_codes? @code = ROTP::TOTP.new(current_user.auth_app_configurations.first.otp_secret_key).now - analytics.track_event(Analytics::MULTI_FACTOR_AUTH_ENTER_TOTP_VISIT) + analytics.multi_factor_auth_enter_totp_visit end def create diff --git a/app/controllers/two_factor_authentication/webauthn_verification_controller.rb b/app/controllers/two_factor_authentication/webauthn_verification_controller.rb index 13a7e2faa8b..7d0df1f6adb 100644 --- a/app/controllers/two_factor_authentication/webauthn_verification_controller.rb +++ b/app/controllers/two_factor_authentication/webauthn_verification_controller.rb @@ -8,7 +8,7 @@ class WebauthnVerificationController < ApplicationController def show save_challenge_in_session - analytics.track_event(Analytics::MULTI_FACTOR_AUTH_ENTER_WEBAUTHN_VISIT, analytics_properties) + analytics.multi_factor_auth_enter_webauthn_visit(**analytics_properties) @presenter = presenter_for_two_factor_authentication_method end diff --git a/app/services/analytics.rb b/app/services/analytics.rb index 6b7d0724940..f2ceeb6eff8 100644 --- a/app/services/analytics.rb +++ b/app/services/analytics.rb @@ -143,11 +143,6 @@ def session_started_at LOGOUT_INITIATED = 'Logout Initiated' MULTI_FACTOR_AUTH = 'Multi-Factor Authentication' MULTI_FACTOR_AUTH_ENTER_OTP_VISIT = 'Multi-Factor Authentication: enter OTP visited' - MULTI_FACTOR_AUTH_ENTER_PIV_CAC = 'Multi-Factor Authentication: enter PIV CAC visited' - MULTI_FACTOR_AUTH_ENTER_TOTP_VISIT = 'Multi-Factor Authentication: enter TOTP visited' - MULTI_FACTOR_AUTH_ENTER_PERSONAL_KEY_VISIT = 'Multi-Factor Authentication: enter personal key visited' - MULTI_FACTOR_AUTH_ENTER_BACKUP_CODE_VISIT = 'Multi-Factor Authentication: enter backup code visited' - MULTI_FACTOR_AUTH_ENTER_WEBAUTHN_VISIT = 'Multi-Factor Authentication: enter webAuthn authentication visited' MULTI_FACTOR_AUTH_MAX_ATTEMPTS = 'Multi-Factor Authentication: max attempts reached' MULTI_FACTOR_AUTH_OPTION_LIST = 'Multi-Factor Authentication: option list' MULTI_FACTOR_AUTH_OPTION_LIST_VISIT = 'Multi-Factor Authentication: option list visited' diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index 90611dd2cf6..d3982602e01 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -921,6 +921,72 @@ def idv_start_over( ) end + # @param ["authentication","reauthentication","confirmation"] context user session context + # User visited the page to enter a backup code as their MFA + def multi_factor_auth_enter_backup_code_visit(context:, **extra) + track_event( + 'Multi-Factor Authentication: enter backup code visited', + context: context, + **extra, + ) + end + + # @param ["authentication","reauthentication","confirmation"] context user session context + # User visited the page to enter a personal key as their mfa (legacy flow) + def multi_factor_auth_enter_personal_key_visit(context:, **extra) + track_event( + 'Multi-Factor Authentication: enter personal key visited', + context: context, + **extra, + ) + end + + # @param ["authentication","reauthentication","confirmation"] context user session context + # @param ["piv_cac"] multi_factor_auth_method + # @param [Integer, nil] piv_cac_configuration_id PIV/CAC configuration database ID + # User used a PIV/CAC as their mfa + def multi_factor_auth_enter_piv_cac( + context:, + multi_factor_auth_method:, + piv_cac_configuration_id:, + **extra + ) + track_event( + 'Multi-Factor Authentication: enter PIV CAC visited', + context: context, + multi_factor_auth_method: multi_factor_auth_method, + piv_cac_configuration_id: piv_cac_configuration_id, + **extra, + ) + end + + # @param ["authentication","reauthentication","confirmation"] context user session context + # User visited the page to enter a TOTP as their mfa + def multi_factor_auth_enter_totp_visit(context:, **extra) + track_event('Multi-Factor Authentication: enter TOTP visited', context: context, **extra) + end + + # @param ["authentication","reauthentication","confirmation"] context user session context + # @param ["webauthn","webauthn_platform"] multi_factor_auth_method which webauthn method was used, + # webauthn means a roaming authenticator like a yubikey, webauthn_platform means a platform + # authenticator like face or touch ID + # @param [Integer, nil] webauthn_configuration_id webauthn database ID + # User visited the page to authenticate with webauthn (yubikey, face ID or touch ID) + def multi_factor_auth_enter_webauthn_visit( + context:, + multi_factor_auth_method:, + webauthn_configuration_id:, + **extra + ) + track_event( + 'Multi-Factor Authentication: enter webAuthn authentication visited', + context: context, + multi_factor_auth_method: multi_factor_auth_method, + webauthn_configuration_id: webauthn_configuration_id, + **extra, + ) + end + # User has visited the page that lets them confirm if they want a new personal key def profile_personal_key_visit track_event('Profile: Visited new personal key') diff --git a/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb index 88f80c4e0fb..b5654fd5cb1 100644 --- a/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb @@ -11,7 +11,7 @@ analytics_hash = { context: 'authentication' } expect(@analytics).to receive(:track_event). - with(Analytics::MULTI_FACTOR_AUTH_ENTER_BACKUP_CODE_VISIT, analytics_hash) + with('Multi-Factor Authentication: enter backup code visited', analytics_hash) get :show end diff --git a/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb index 192b5e6c36d..93fd44df368 100644 --- a/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb @@ -22,7 +22,7 @@ analytics_hash = { context: 'authentication' } expect(@analytics).to receive(:track_event). - with(Analytics::MULTI_FACTOR_AUTH_ENTER_PERSONAL_KEY_VISIT, analytics_hash) + with('Multi-Factor Authentication: enter personal key visited', analytics_hash) get :show end diff --git a/spec/controllers/two_factor_authentication/piv_cac_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/piv_cac_verification_controller_spec.rb index 8e758bef58c..0ba1f392468 100644 --- a/spec/controllers/two_factor_authentication/piv_cac_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/piv_cac_verification_controller_spec.rb @@ -98,7 +98,7 @@ } expect(@analytics).to receive(:track_event). - with(Analytics::MULTI_FACTOR_AUTH_ENTER_PIV_CAC, attributes) + with('Multi-Factor Authentication: enter PIV CAC visited', attributes) submit_attributes = { success: true, @@ -181,7 +181,7 @@ } expect(@analytics).to receive(:track_event). - with(Analytics::MULTI_FACTOR_AUTH_ENTER_PIV_CAC, attributes) + with('Multi-Factor Authentication: enter PIV CAC visited', attributes) submit_attributes = { success: false, diff --git a/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb index 46dec5bf0b7..81c5c6a25df 100644 --- a/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb @@ -44,7 +44,7 @@ result = { context: 'authentication', multi_factor_auth_method: 'webauthn_platform', webauthn_configuration_id: nil } expect(@analytics).to have_received(:track_event).with( - Analytics::MULTI_FACTOR_AUTH_ENTER_WEBAUTHN_VISIT, + 'Multi-Factor Authentication: enter webAuthn authentication visited', result, ) end