diff --git a/app/controllers/account_reset/request_controller.rb b/app/controllers/account_reset/request_controller.rb index 0ecc00c604e..03c07fb65cb 100644 --- a/app/controllers/account_reset/request_controller.rb +++ b/app/controllers/account_reset/request_controller.rb @@ -11,6 +11,7 @@ def show def create create_account_reset_request flash[:email] = current_user.email_addresses.take.email + redirect_to account_reset_confirm_request_url end @@ -18,6 +19,9 @@ def create def create_account_reset_request response = AccountReset::CreateRequest.new(current_user).call + irs_attempts_api_tracker.account_reset_request_submitted( + success: response.success?, + ) analytics.account_reset_request(**response.to_h, **analytics_attributes) end diff --git a/app/services/irs_attempts_api/tracker_events.rb b/app/services/irs_attempts_api/tracker_events.rb index e6b06115cd0..68f2201ed91 100644 --- a/app/services/irs_attempts_api/tracker_events.rb +++ b/app/services/irs_attempts_api/tracker_events.rb @@ -1,5 +1,14 @@ module IrsAttemptsApi module TrackerEvents + # @param [Boolean] success True if the email and password matched + # account Reset Deletion Requested + def account_reset_request_submitted(success:) + track_event( + :account_reset_request_submitted, + success: success, + ) + end + # @param [String] email The submitted email address # @param [Boolean] success True if the email and password matched # A user has submitted an email address and password for authentication diff --git a/spec/controllers/account_reset/request_controller_spec.rb b/spec/controllers/account_reset/request_controller_spec.rb index cf4cd94dd66..cc43803f51a 100644 --- a/spec/controllers/account_reset/request_controller_spec.rb +++ b/spec/controllers/account_reset/request_controller_spec.rb @@ -90,6 +90,17 @@ post :create end + it 'logs the visit to attempts api' do + user = create(:user, :with_piv_or_cac, :with_backup_code) + stub_sign_in_before_2fa(user) + stub_attempts_tracker + + expect(@irs_attempts_api_tracker).to receive(:track_event). + with(:account_reset_request_submitted, success: true) + + get :create + end + it 'redirects to root if user not signed in' do post :create