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
1 change: 1 addition & 0 deletions app/services/flow/flow_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def update
increment_step_name_counts
analytics.track_event(analytics_submitted, result.to_h.merge(analytics_properties))
end

register_update_step(step, result)
if flow.json
render json: flow.json, status: flow.http_status
Expand Down
11 changes: 10 additions & 1 deletion app/services/idv/steps/ipp/ssn_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ class SsnStep < DocAuthBaseStep
STEP_INDICATOR_STEP = :verify_info

def call
flow_session[:pii_from_user][:ssn] = flow_params[:ssn]
flow_session[:pii_from_user][:ssn] = ssn

@flow.irs_attempts_api_tracker.idv_ssn_submitted(
success: true,
ssn: ssn,
)

idv_session.delete('applicant')
end
Expand All @@ -18,6 +23,10 @@ def extra_view_variables

private

def ssn
flow_params[:ssn]
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This is one of those little cleanups that makes a way bigger impact than one might expect. 👍


def form_submit
Idv::SsnFormatForm.new(current_user).submit(permit(:ssn))
end
Expand Down
10 changes: 9 additions & 1 deletion app/services/idv/steps/ssn_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ class SsnStep < DocAuthBaseStep
def call
return invalid_state_response if invalid_state?

flow_session[:pii_from_doc][:ssn] = flow_params[:ssn]
flow_session[:pii_from_doc][:ssn] = ssn
@flow.irs_attempts_api_tracker.idv_ssn_submitted(
success: true,
ssn: ssn,
)

idv_session.delete('applicant')
end
Expand All @@ -24,6 +28,10 @@ def form_submit
Idv::SsnFormatForm.new(current_user).submit(permit(:ssn))
end

def ssn
flow_params[:ssn]
end

def invalid_state?
flow_session[:pii_from_doc].nil?
end
Expand Down
11 changes: 11 additions & 0 deletions app/services/irs_attempts_api/tracker_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ def idv_phone_upload_link_sent(
)
end

# @param [Boolean] success
# @param [String] ssn
# User entered in SSN number during Identity verification
def idv_ssn_submitted(success:, ssn:)
track_event(
:idv_ssn_submitted,
success: success,
ssn: ssn,
)
end

# @param [Boolean] success True if the email and password matched
# A user has initiated a logout event
def logout_initiated(success:)
Expand Down
3 changes: 3 additions & 0 deletions spec/services/idv/steps/ipp/ssn_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
let(:session) { { sp: { issuer: service_provider.issuer } } }
let(:user) { build(:user) }
let(:service_provider) { create(:service_provider) }
let(:attempts_api) { IrsAttemptsApiTrackingHelper::FakeAttemptsTracker.new }
let(:threatmetrix_session_id) { nil }
let(:controller) do
instance_double(
'controller',
session: session,
params: params,
current_user: user,
analytics: FakeAnalytics.new,
irs_attempts_api_tracker: attempts_api,
)
end

Expand Down
10 changes: 10 additions & 0 deletions spec/services/idv/steps/ssn_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
let(:user) { build(:user) }
let(:params) { { doc_auth: {} } }
let(:session) { { sp: { issuer: service_provider.issuer } } }
let(:attempts_api) { IrsAttemptsApiTrackingHelper::FakeAttemptsTracker.new }
let(:service_provider) do
create(
:service_provider,
Expand All @@ -20,6 +21,7 @@
current_user: user,
params: params,
analytics: FakeAnalytics.new,
irs_attempts_api_tracker: attempts_api,
url_options: {},
request: double(
'request',
Expand Down Expand Up @@ -60,6 +62,14 @@
expect(flow.flow_session[:pii_from_doc][:ssn]).to eq(ssn)
end

it 'logs attempts api event' do
expect(attempts_api).to receive(:idv_ssn_submitted).with(
success: true,
ssn: ssn,
)
step.call
end

context 'with existing session applicant' do
let(:session) { super().merge(idv: { 'applicant' => {} }) }

Expand Down