Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/idv/gpo_verify_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions app/services/irs_attempts_api/tracker_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,24 @@ def idv_document_upload_rate_limited
)
end

# param [Boolean] Success
# param [Hash<Key, Array<String>>] 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
Expand Down
11 changes: 10 additions & 1 deletion spec/controllers/idv/gpo_verify_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -68,7 +69,6 @@
end

it 'renders throttled page' do
stub_analytics
expect(@analytics).to receive(:track_event).with(
'IdV: GPO verification visited',
).once
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down