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
25 changes: 20 additions & 5 deletions app/controllers/idv/image_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ def create
liveness_checking_enabled: liveness_checking_enabled?,
)

add_costs(client_response)
analytics.track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_VENDOR,
client_response.to_h.merge(user_id: image_form.document_capture_session.user.uuid),
)
update_analytics(client_response)

store_pii(client_response) if client_response.success?
status = :bad_request unless client_response.success?
Expand Down Expand Up @@ -61,6 +57,25 @@ def doc_auth_client
@doc_auth_client ||= DocAuthRouter.client
end

def update_analytics(client_response)
add_costs(client_response)
update_funnel(client_response)
analytics.track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_VENDOR,
client_response.to_h.merge(user_id: image_form.document_capture_session.user.uuid),
)
end

def update_funnel(result)
user_id = image_form.document_capture_session.user.id
issuer = sp_session[:issuer]
steps = %i[front_image back_image]
steps << :selfie if liveness_checking_enabled?
steps.each do |step|
Funnel::DocAuth::RegisterStep.new(user_id, issuer).call(step.to_s, :update, result.success?)
Comment thread
aduth marked this conversation as resolved.
end
end

def add_costs(client_response)
Db::AddDocumentVerificationAndSelfieCosts.
new(user_id: image_form.document_capture_session.user.id,
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/idv/image_uploads_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
}
end

before do
Funnel::DocAuth::RegisterStep.new(user.id, '').call('welcome', :view, true)
end

context 'when document capture is not enabled' do
before do
allow(FeatureManagement).to receive(:document_capture_step_enabled?).and_return(false)
Expand Down Expand Up @@ -64,6 +68,8 @@
)

action

expect_funnel_update_counts(user, 0)
end
end

Expand Down Expand Up @@ -113,6 +119,8 @@
)

action

expect_funnel_update_counts(user, 0)
end
end

Expand Down Expand Up @@ -168,6 +176,8 @@
)

action

expect_funnel_update_counts(user, 0)
end
end

Expand Down Expand Up @@ -203,6 +213,8 @@
)

action

expect_funnel_update_counts(user, 1)
end
end

Expand Down Expand Up @@ -252,6 +264,8 @@
)

action

expect_funnel_update_counts(user, 1)
end
end

Expand Down Expand Up @@ -295,8 +309,16 @@
)

action

expect_funnel_update_counts(user, 1)
end
end
end
end

def expect_funnel_update_counts(user, count)
doc_auth_log = DocAuthLog.where(user_id: user.id).first
expect(doc_auth_log.back_image_submit_count).to eq(count)
expect(doc_auth_log.front_image_submit_count).to eq(count)
end
end