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: 4 additions & 1 deletion app/controllers/idv/personal_key_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def show
def update
user_session[:need_personal_key_confirmation] = false

analytics.idv_personal_key_submitted(address_verification_method: address_verification_method)
analytics.idv_personal_key_submitted(
address_verification_method: address_verification_method,
deactivation_reason: idv_session.profile&.deactivation_reason,
)
redirect_to next_step
end

Expand Down
10 changes: 8 additions & 2 deletions app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ def create

redirect_to next_step

analytics.idv_review_complete(success: true)
analytics.idv_final(success: true)
analytics.idv_review_complete(
success: true,
deactivation_reason: idv_session.profile.deactivation_reason,
)
analytics.idv_final(
success: true,
deactivation_reason: idv_session.profile.deactivation_reason,
)

return unless FeatureManagement.reveal_gpo_code?
session[:last_gpo_confirmation_code] = idv_session.gpo_otp
Expand Down
11 changes: 9 additions & 2 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1050,16 +1050,19 @@ def idv_intro_visit
end

# @param [Boolean] success
# @param [String, nil] deactivation_reason Reason user's profile was deactivated, if any.
# @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components
# Tracks the last step of IDV, indicates the user successfully prooved
def idv_final(
success:,
deactivation_reason: nil,
proofing_components: nil,
**extra
)
track_event(
'IdV: final resolution',
success: success,
deactivation_reason: deactivation_reason,
proofing_components: proofing_components,
**extra,
)
Expand All @@ -1076,10 +1079,12 @@ def idv_personal_key_visited(proofing_components: nil, **extra)
end

# @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components
# @param [String, nil] deactivation_reason Reason profile was deactivated.
# User submitted IDV personal key page
def idv_personal_key_submitted(proofing_components: nil, **extra)
def idv_personal_key_submitted(proofing_components: nil, deactivation_reason: nil, **extra)
track_event(
'IdV: personal key submitted',
deactivation_reason: deactivation_reason,
proofing_components: proofing_components,
**extra,
)
Expand Down Expand Up @@ -1382,10 +1387,12 @@ def idv_proofing_resolution_result_missing(proofing_components: nil, **extra)
# User submitted IDV password confirm page
# @param [Boolean] success
# @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components
def idv_review_complete(success:, proofing_components: nil, **extra)
# @param [String, nil] deactivation_reason Reason user's profile was deactivated, if any.
def idv_review_complete(success:, deactivation_reason: nil, proofing_components: nil, **extra)
track_event(
'IdV: review complete',
success: success,
deactivation_reason: deactivation_reason,
proofing_components: proofing_components,
**extra,
)
Expand Down
99 changes: 88 additions & 11 deletions spec/controllers/idv/personal_key_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def stub_idv_session
)
end

before do
stub_analytics
end

describe 'before_actions' do
it 'includes before_actions from AccountStateChecker' do
expect(subject).to have_actions(
Expand Down Expand Up @@ -155,6 +159,16 @@ def index

expect(subject.user_session[:need_personal_key_confirmation]).to eq(false)
end

it 'logs key submitted event' do
patch :update

expect(@analytics).to have_logged_event(
'IdV: personal key submitted', address_verification_method: nil,
deactivation_reason: nil,
proofing_components: nil
)
end
end

context 'user selected gpo verification' do
Expand All @@ -181,6 +195,16 @@ def index
expect(response).to redirect_to idv_come_back_later_path
end
end
it 'logs key submitted event' do
patch :update

expect(@analytics).to have_logged_event(
'IdV: personal key submitted',
address_verification_method: nil,
deactivation_reason: 'gpo_verification_pending',
proofing_components: nil,
)
end
end

context 'with in person profile' do
Expand All @@ -196,6 +220,17 @@ def index

expect(response).to redirect_to idv_in_person_ready_to_verify_url
end

it 'logs key submitted event' do
patch :update

expect(@analytics).to have_logged_event(
'IdV: personal key submitted',
address_verification_method: nil,
deactivation_reason: nil,
proofing_components: nil,
)
end
end

context 'with device profiling decisioning enabled' do
Expand All @@ -205,24 +240,66 @@ def index
to receive(:lexisnexis_threatmetrix_required_to_verify).and_return(true)
end

it 'redirects to account path when threatmetrix review status is nil' do
patch :update
context 'threatmetrix review status is nil' do
it 'redirects to account path' do
patch :update

expect(response).to redirect_to account_path
expect(response).to redirect_to account_path
end
it 'logs key submitted event' do
patch :update

expect(@analytics).to have_logged_event(
'IdV: personal key submitted',
address_verification_method: nil,
deactivation_reason: nil,
proofing_components: nil,
)
end
end

it 'redirects to account path when device profiling passes' do
ProofingComponent.find_by(user: user).update(threatmetrix_review_status: 'pass')
patch :update
context 'device profiling passes' do
before do
ProofingComponent.find_by(user: user).update(threatmetrix_review_status: 'pass')
end
it 'redirects to account path' do
patch :update

expect(response).to redirect_to account_path
expect(response).to redirect_to account_path
end
it 'logs key submitted event' do
patch :update

expect(@analytics).to have_logged_event(
'IdV: personal key submitted',
address_verification_method: nil,
deactivation_reason: nil,
proofing_components: nil,
)
end
end

it 'redirects to come back later path when device profiling fails' do
ProofingComponent.find_by(user: user).update(threatmetrix_review_status: 'fail')
patch :update
context 'device profiling fails' do
before do
ProofingComponent.find_by(user: user).update(threatmetrix_review_status: 'reject')
profile.deactivation_reason = :threatmetrix_review_pending
end

it 'redirects to come back later path' do
patch :update
expect(response).to redirect_to idv_setup_errors_path
end

expect(response).to redirect_to idv_setup_errors_path
it 'logs key submitted event' do
patch :update

expect(@analytics).to have_logged_event(
'IdV: personal key submitted',
address_verification_method: nil,
deactivation_reason: 'threatmetrix_review_pending',
proofing_components: nil,
)
end
end
end
end
Expand Down
18 changes: 17 additions & 1 deletion spec/controllers/idv/review_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def show
'IdV: review complete',
success: false,
proofing_components: nil,
deactivation_reason: nil,
)
end
end
Expand All @@ -293,7 +294,8 @@ def show

expect(@analytics).to have_logged_event(
'IdV: review complete', success: true,
proofing_components: nil
proofing_components: nil,
deactivation_reason: anything
)
expect(@analytics).to have_logged_event(
'IdV: final resolution',
Expand Down Expand Up @@ -609,6 +611,20 @@ def show

expect(user.profiles.last.deactivation_reason).to eq('threatmetrix_review_pending')
end

it 'logs events' do
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }
expect(@analytics).to have_logged_event(
'IdV: review complete', success: true,
proofing_components: nil,
deactivation_reason: 'threatmetrix_review_pending'
)
expect(@analytics).to have_logged_event(
'IdV: final resolution', success: true,
proofing_components: nil,
deactivation_reason: 'threatmetrix_review_pending'
)
end
end
end

Expand Down
18 changes: 9 additions & 9 deletions spec/features/idv/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
'IdV: phone confirmation otp visited' => { proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: phone confirmation otp submitted' => { success: true, code_expired: false, code_matches: true, second_factor_attempts_count: 0, second_factor_locked_at: nil, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, errors: {} },
'IdV: review info visited' => { address_verification_method: 'phone', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: review complete' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: final resolution' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: review complete' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, deactivation_reason: nil },
'IdV: final resolution' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, deactivation_reason: nil },
'IdV: personal key visited' => { address_verification_method: 'phone', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: personal key acknowledgment toggled' => { checked: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: personal key submitted' => { address_verification_method: 'phone', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: personal key submitted' => { address_verification_method: 'phone', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, deactivation_reason: nil },
}
end

Expand Down Expand Up @@ -68,11 +68,11 @@
'IdV: USPS address letter requested' => { resend: false, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis' } },
'IdV: review info visited' => { address_verification_method: 'gpo', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
'IdV: USPS address letter enqueued' => { enqueued_at: Time.zone.now.utc, resend: false, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
'IdV: review complete' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
'IdV: final resolution' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
'IdV: review complete' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' }, deactivation_reason: 'gpo_verification_pending' },
'IdV: final resolution' => { success: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' }, deactivation_reason: 'gpo_verification_pending' },
'IdV: personal key visited' => { address_verification_method: 'gpo', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
'IdV: personal key acknowledgment toggled' => { checked: true, proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
'IdV: personal key submitted' => { address_verification_method: 'gpo', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
'IdV: personal key submitted' => { address_verification_method: 'gpo', proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' }, deactivation_reason: 'gpo_verification_pending' },
'IdV: come back later visited' => { proofing_components: { document_check: 'mock', document_type: 'state_id', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'gpo_letter' } },
}
end
Expand Down Expand Up @@ -110,11 +110,11 @@
'IdV: phone confirmation otp visited' => { proofing_components: { address_check: 'lexis_nexis_address', document_check: 'usps', resolution_check: 'lexis_nexis', source_check: 'aamva' } },
'IdV: phone confirmation otp submitted' => { success: true, code_expired: false, code_matches: true, second_factor_attempts_count: 0, second_factor_locked_at: nil, proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, errors: {} },
'IdV: review info visited' => { proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, address_verification_method: 'phone' },
'IdV: review complete' => { success: true, proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: final resolution' => { success: true, proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: review complete' => { success: true, proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, deactivation_reason: 'in_person_verification_pending' },
'IdV: final resolution' => { success: true, proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, deactivation_reason: 'in_person_verification_pending' },
'IdV: personal key visited' => { proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, address_verification_method: 'phone' },
'IdV: personal key acknowledgment toggled' => { checked: true, proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
'IdV: personal key submitted' => { proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, address_verification_method: 'phone' },
'IdV: personal key submitted' => { proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' }, address_verification_method: 'phone', deactivation_reason: 'in_person_verification_pending' },
'IdV: in person ready to verify visited' => { proofing_components: { document_check: 'usps', source_check: 'aamva', resolution_check: 'lexis_nexis', address_check: 'lexis_nexis_address' } },
}
end
Expand Down