diff --git a/app/controllers/idv/gpo_verify_controller.rb b/app/controllers/idv/gpo_verify_controller.rb index eed5efd069f..2b0ec93fcd7 100644 --- a/app/controllers/idv/gpo_verify_controller.rb +++ b/app/controllers/idv/gpo_verify_controller.rb @@ -27,10 +27,15 @@ def create @gpo_verify_form = build_gpo_verify_form if throttle.throttled_else_increment? + irs_attempts_api_tracker.idv_gpo_verification_throttled render_throttled else result = @gpo_verify_form.submit analytics.idv_gpo_verification_submitted(**result.to_h) + irs_attempts_api_tracker.idv_gpo_verification_submitted( + success: result.success?, + failure_reason: result.errors.presence, + ) if result.success? if result.extra[:pending_in_person_enrollment] diff --git a/app/services/irs_attempts_api/tracker_events.rb b/app/services/irs_attempts_api/tracker_events.rb index d08b336f988..5b79e6e4364 100644 --- a/app/services/irs_attempts_api/tracker_events.rb +++ b/app/services/irs_attempts_api/tracker_events.rb @@ -150,6 +150,24 @@ def idv_document_upload_rate_limited ) end + # param [Boolean] Success + # param [Hash>] failure_reason displays GPO submission failed + # GPO verification submitted from Letter sent to verify address + def idv_gpo_verification_submitted(success:, failure_reason:) + track_event( + :idv_gpo_verification_submitted, + success: success, + failure_reason: failure_reason, + ) + end + + # GPO verification submission throttled, user entered in too many invalid gpo letter codes + def idv_gpo_verification_throttled + track_event( + :idv_gpo_verification_throttled, + ) + end + # @param [Boolean] success # @param [String] phone_number # The phone upload link was sent during the IDV process diff --git a/spec/controllers/idv/gpo_verify_controller_spec.rb b/spec/controllers/idv/gpo_verify_controller_spec.rb index e3b41bf776c..11ec5a249ae 100644 --- a/spec/controllers/idv/gpo_verify_controller_spec.rb +++ b/spec/controllers/idv/gpo_verify_controller_spec.rb @@ -18,6 +18,7 @@ before do stub_analytics + stub_attempts_tracker stub_sign_in(user) decorated_user = stub_decorated_user_with_pending_profile(user) create( @@ -68,7 +69,6 @@ end it 'renders throttled page' do - stub_analytics expect(@analytics).to receive(:track_event).with( 'IdV: GPO verification visited', ).once @@ -108,6 +108,8 @@ enqueued_at: user.pending_profile.gpo_confirmation_codes.last.code_sent_at, pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], ) + expect(@irs_attempts_api_tracker).to receive(:idv_gpo_verification_submitted). + with(success: true, failure_reason: nil) action @@ -143,6 +145,8 @@ enqueued_at: user.pending_profile.gpo_confirmation_codes.last.code_sent_at, pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], ) + expect(@irs_attempts_api_tracker).to receive(:idv_gpo_verification_submitted). + with(success: true, failure_reason: nil) action @@ -170,6 +174,9 @@ error_details: { otp: [:confirmation_code_incorrect] }, pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], ) + failure_reason = { otp: ['Incorrect code. Did you type it in correctly?'] } + expect(@irs_attempts_api_tracker).to receive(:idv_gpo_verification_submitted). + with(success: false, failure_reason: failure_reason) action @@ -204,6 +211,8 @@ throttle_type: :verify_gpo_key, ).once + expect(@irs_attempts_api_tracker).to receive(:idv_gpo_verification_throttled).once + (max_attempts + 1).times do |i| post( :create,