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
16 changes: 10 additions & 6 deletions app/controllers/idv/hybrid_handoff_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def handle_phone_submission
return throttled_failure if throttle.throttled?
idv_session.phone_for_mobile_flow = params[:doc_auth][:phone]
flow_session[:phone_for_mobile_flow] = idv_session.phone_for_mobile_flow
flow_session[:flow_path] = 'hybrid'
telephony_result = send_link
telephony_form_response = build_telephony_form_response(telephony_result)

Expand All @@ -60,18 +61,18 @@ def handle_phone_submission
)

if !failure_reason
flow_session[:flow_path] = 'hybrid'
redirect_to idv_link_sent_url

# for the 50/50 state
flow_session['Idv::Steps::UploadStep'] = true
else
redirect_to idv_hybrid_handoff_url
flow_session[:flow_path] = nil
end

analytics_args = analytics_arguments.merge(form_response(destination: :link_sent).to_h)
analytics_args[:flow_path] = flow_session[:flow_path]
analytics.idv_doc_auth_upload_submitted(**analytics_args)
analytics.idv_doc_auth_upload_submitted(
**analytics_arguments.merge(telephony_form_response.to_h),
)
end

def send_link
Expand Down Expand Up @@ -103,6 +104,7 @@ def build_telephony_form_response(telephony_result)
extra: {
telephony_response: telephony_result.to_h,
destination: :link_sent,
flow_path: flow_session[:flow_path],
},
)
end
Expand All @@ -124,9 +126,10 @@ def bypass_send_link_steps
# for the 50/50 state
flow_session['Idv::Steps::UploadStep'] = true

response = form_response(destination: :document_capture)
analytics.idv_doc_auth_upload_submitted(
**analytics_arguments.merge(response.to_h),
**analytics_arguments.merge(
form_response(destination: :document_capture).to_h,
),
)
end

Expand Down Expand Up @@ -173,6 +176,7 @@ def form_response(destination:)
extra: {
destination: destination,
skip_upload_step: mobile_device?,
flow_path: flow_session[:flow_path],
},
)
end
Expand Down
49 changes: 37 additions & 12 deletions spec/controllers/idv/hybrid_handoff_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,46 @@

describe '#update' do
let(:analytics_name) { 'IdV: doc auth upload submitted' }
let(:analytics_args) do
{ success: true,
errors: {},
destination: :link_sent,
flow_path: 'hybrid',
step: 'upload',
analytics_id: 'Doc Auth',
irs_reproofing: false,
skip_upload_step: false }

context 'hybrid flow' do
let(:analytics_args) do
{ success: true,
errors: { message: nil },
destination: :link_sent,
flow_path: 'hybrid',
step: 'upload',
analytics_id: 'Doc Auth',
irs_reproofing: false,
telephony_response: { errors: {},
message_id: 'fake-message-id',
request_id: 'fake-message-request-id',
success: true } }
end

it 'sends analytics_submitted event for hybrid' do
put :update, params: { doc_auth: { phone: '202-555-5555' } }

expect(@analytics).to have_logged_event(analytics_name, analytics_args)
end
end

it 'sends analytics_submitted event' do
put :update, params: { doc_auth: { phone: '202-555-5555' } }
context 'desktop flow' do
let(:analytics_args) do
{ success: true,
errors: {},
destination: :document_capture,
flow_path: 'standard',
step: 'upload',
analytics_id: 'Doc Auth',
irs_reproofing: false,
skip_upload_step: false }
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicks:

  1. preserve the key order in analytics_args assignment for easier comparison across contexts.
  2. standardize the indentation:
{
  success: true,
  errors: { message: nil },
  analytics_id: 'Doc Auth',
  destination: :link_sent,
  flow_path: 'hybrid',
  irs_reproofing: false,
  step: 'upload',
  telephony_response: {
    errors: {},
    message_id: 'fake-message-id',
    request_id: 'fake-message-request-id',
    success: true
  }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Addressed in bf0985d


expect(@analytics).to have_logged_event(analytics_name, analytics_args)
it 'sends analytics_submitted event for desktop' do
put :update, params: { type: 'desktop' }

expect(@analytics).to have_logged_event(analytics_name, analytics_args)
end
end
end
end