Skip to content

Commit

Permalink
LG-13512 Log zip code in IPP analytics (#10915)
Browse files Browse the repository at this point in the history
changelog: Internal, In-person proofing, Add zipcode to Idv state id submitted
analytics and to current address submitted analytics
  • Loading branch information
jennyverdeyen authored Jul 9, 2024
1 parent d0077dc commit b331ac5
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
5 changes: 5 additions & 0 deletions app/forms/idv/in_person/address_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def submit(params)
FormResponse.new(
success: validation_success,
errors: cleaned_errors,
extra: extra_analytics_attributes(params),
)
end

Expand All @@ -41,6 +42,10 @@ def consume_params(params)
def raise_invalid_address_parameter_error(key)
raise ArgumentError, "#{key} is an invalid address attribute"
end

def extra_analytics_attributes(params)
{ current_address_zip_code: params.dig(:zipcode)&.slice(0, 5) }
end
end
end
end
9 changes: 5 additions & 4 deletions app/forms/idv/state_id_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ def consume_params(params)
end
end

def extra_analytics_attributes(params)
{ birth_year: params.dig(:dob, :year) }
end

def raise_invalid_state_id_parameter_error(key)
raise ArgumentError, "#{key} is an invalid state ID attribute"
end

def extra_analytics_attributes(params)
{ birth_year: params.dig(:dob, :year),
document_zip_code: params.dig(:identity_doc_zipcode)&.slice(0, 5) }
end
end
end
13 changes: 10 additions & 3 deletions spec/controllers/idv/in_person/address_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
let(:address1) { '1 FAKE RD' }
let(:address2) { 'APT 1B' }
let(:city) { 'GREAT FALLS' }
let(:zipcode) { '59010' }
let(:zipcode) { '59010-4444' }
let(:state) { 'Montana' }
let(:params) do
{ in_person_address: {
Expand All @@ -141,6 +141,7 @@
:state_id_jurisdiction]],
same_address_as_id: false,
skip_hybrid_handoff: nil,
current_address_zip_code: '59010',
}
end

Expand All @@ -156,7 +157,7 @@
)
end

it 'logs idv_in_person_proofing_address_visited' do
it 'logs idv_in_person_proofing_address_submitted with 5-digit zipcode' do
put :update, params: params

expect(@analytics).to have_received(
Expand Down Expand Up @@ -228,13 +229,19 @@
:state_id_jurisdiction]],
same_address_as_id: false,
skip_hybrid_handoff: nil,
current_address_zip_code: '59010',
}
end

it 'does not proceed to next page' do
before do
put :update, params: params
end

it 'does not proceed to next page' do
expect(response).to have_rendered(:show)
end

it 'logs idv_in_person_proofing_address_submitted without zipcode' do
expect(@analytics).to have_received(:track_event).with(analytics_name, analytics_args)
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/idv/in_person/state_id_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
:state_id_jurisdiction]],
same_address_as_id: true,
birth_year: dob[:year],
document_zip_code: identity_doc_zipcode&.slice(0, 5),
}.merge(ab_test_args)
end

Expand Down Expand Up @@ -227,6 +228,7 @@
expect(pii_from_user[:first_name]).to eq first_name
expect(pii_from_user[:last_name]).to eq last_name
expect(pii_from_user[:dob]).to eq formatted_dob
expect(pii_from_user[:identity_doc_zipcode]).to eq identity_doc_zipcode
expect(pii_from_user[:identity_doc_address_state]).to eq identity_doc_address_state
expect(pii_from_user[:state_id_number]).to eq state_id_number
end
Expand Down
4 changes: 2 additions & 2 deletions spec/features/idv/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,13 @@
step: 'state_id', flow_path: 'standard', step_count: 1, analytics_id: 'In Person Proofing', opted_in_to_in_person_proofing: nil
},
'IdV: in person proofing state_id submitted' => {
success: true, flow_path: 'standard', step: 'state_id', step_count: 1, analytics_id: 'In Person Proofing', errors: {}, error_details: nil, same_address_as_id: false, opted_in_to_in_person_proofing: nil, birth_year: '1938'
success: true, flow_path: 'standard', step: 'state_id', step_count: 1, analytics_id: 'In Person Proofing', errors: {}, error_details: nil, same_address_as_id: false, opted_in_to_in_person_proofing: nil, birth_year: '1938', document_zip_code: '12345'
},
'IdV: in person proofing address visited' => {
step: 'address', flow_path: 'standard', analytics_id: 'In Person Proofing', same_address_as_id: false, opted_in_to_in_person_proofing: nil, acuant_sdk_upgrade_ab_test_bucket: :default, skip_hybrid_handoff: nil
},
'IdV: in person proofing residential address submitted' => {
success: true, step: 'address', flow_path: 'standard', analytics_id: 'In Person Proofing', errors: {}, same_address_as_id: false, acuant_sdk_upgrade_ab_test_bucket: :default, skip_hybrid_handoff: nil
success: true, step: 'address', flow_path: 'standard', analytics_id: 'In Person Proofing', errors: {}, same_address_as_id: false, acuant_sdk_upgrade_ab_test_bucket: :default, skip_hybrid_handoff: nil, current_address_zip_code: '59010'
},
'IdV: doc auth ssn visited' => {
analytics_id: 'In Person Proofing', step: 'ssn', flow_path: 'standard', acuant_sdk_upgrade_ab_test_bucket: :default, skip_hybrid_handoff: nil, same_address_as_id: false
Expand Down
14 changes: 13 additions & 1 deletion spec/forms/idv/state_id_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,25 @@
FormResponse.new(
success: true,
errors: {},
extra: { birth_year: valid_dob[:year] },
extra: { birth_year: valid_dob[:year],
document_zip_code: good_params[:identity_doc_zipcode].slice(0, 5) },
)
end

it 'returns a successful form response' do
expect(subject.submit(good_params)).to eq(form_response)
end

it 'logs extra analytics attributes' do
result = subject.submit(good_params)

expect(result.extra).to eq(
{
birth_year: valid_dob[:year],
document_zip_code: good_params[:identity_doc_zipcode].slice(0, 5),
},
)
end
end

context 'when there is an error with name' do
Expand Down
3 changes: 3 additions & 0 deletions spec/services/idv/steps/in_person/state_id_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
let(:last_name) { 'Rostova' }
let(:identity_doc_address_state) { 'Nevada' }
let(:state_id_number) { 'ABC123234' }
let(:identity_doc_zipcode) { InPersonHelper::GOOD_IDENTITY_DOC_ZIPCODE }
let(:submitted_values) do
{
first_name: first_name,
last_name: last_name,
dob: dob,
identity_doc_address_state: identity_doc_address_state,
state_id_number: state_id_number,
identity_doc_zipcode: identity_doc_zipcode,
}
end

Expand All @@ -66,6 +68,7 @@
expect(pii_from_user[:dob]).to eq formatted_dob
expect(pii_from_user[:identity_doc_address_state]).to eq identity_doc_address_state
expect(pii_from_user[:state_id_number]).to eq state_id_number
expect(pii_from_user[:identity_doc_zipcode]).to eq identity_doc_zipcode
end
end

Expand Down

0 comments on commit b331ac5

Please sign in to comment.