diff --git a/app/controllers/two_factor_authentication/totp_verification_controller.rb b/app/controllers/two_factor_authentication/totp_verification_controller.rb index e7cdd499a03..b4c92f7b78d 100644 --- a/app/controllers/two_factor_authentication/totp_verification_controller.rb +++ b/app/controllers/two_factor_authentication/totp_verification_controller.rb @@ -19,6 +19,7 @@ def create result = TotpVerificationForm.new(current_user, params.require(:code).strip).submit analytics.track_mfa_submit_event(result.to_h) + irs_attempts_api_tracker.multi_factor_auth_verify_totp(success: result.success?) if result.success? handle_valid_otp diff --git a/app/services/irs_attempts_api/tracker_events.rb b/app/services/irs_attempts_api/tracker_events.rb index 6a916c3e7f3..3f7b89731f4 100644 --- a/app/services/irs_attempts_api/tracker_events.rb +++ b/app/services/irs_attempts_api/tracker_events.rb @@ -31,6 +31,15 @@ def multi_factor_auth_enroll_totp(success:) ) end + # Tracks when the user has attempted to verify via the TOTP MFA method to access their account + # @param [Boolean] success + def multi_factor_auth_verify_totp(success:) + track_event( + :totp_verify, + success: success, + ) + end + # Tracks when user confirms registration email # @param [Boolean] success # @param [String] email diff --git a/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb index bb1a77afe68..12276e1401b 100644 --- a/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb @@ -3,6 +3,7 @@ describe TwoFactorAuthentication::TotpVerificationController do before do stub_analytics + stub_attempts_tracker end describe '#create' do @@ -46,6 +47,8 @@ with(attributes) expect(@analytics).to receive(:track_event). with('User marked authenticated', authentication_type: :valid_2fa) + expect(@irs_attempts_api_tracker).to receive(:track_event). + with(:totp_verify, success: true) post :create, params: { code: generate_totp_code(@secret) } end @@ -92,6 +95,8 @@ with(attributes) expect(@analytics).to receive(:track_event). with('Multi-Factor Authentication: max attempts reached') + expect(@irs_attempts_api_tracker).to receive(:track_event). + with(:totp_verify, success: false) expect(PushNotification::HttpPush).to receive(:deliver). with(PushNotification::MfaLimitAccountLockedEvent.new(user: subject.current_user))