From 2f89c67ad3010cc3174f4d7cef6b71844baf9c29 Mon Sep 17 00:00:00 2001 From: svalexander Date: Fri, 3 Feb 2023 16:07:11 -0500 Subject: [PATCH 1/9] add analytics events for link clicks --- app/services/analytics_events.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index 21a348deb16..fc12716e727 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -707,6 +707,22 @@ def idv_in_person_ready_to_verify_visit(proofing_components: nil, **extra) ) end + # The user clicked the sp link on the "ready to verify" page + def idv_in_person_ready_to_verify_sp_link_clicked(**extra) + track_event( + 'IdV: user clicked the sp link on the ready to verify page', + **extra, + ) + end + + # The user clicked the what to bring link on the "ready to verify" page + def idv_in_person_ready_to_verify_what_to_bring_link_clicked(**extra) + track_event( + 'IdV: user clicked the what to bring link on the ready to verify page', + **extra, + ) + end + def idv_doc_auth_agreement_submitted(**extra) track_event('IdV: doc auth agreement submitted', **extra) end From 24f6cb70b5317e4a259f4d0f13f28d77390025c8 Mon Sep 17 00:00:00 2001 From: svalexander Date: Wed, 8 Feb 2023 10:03:29 -0500 Subject: [PATCH 2/9] add analytics events for links on ready to verify pg --- app/controllers/frontend_log_controller.rb | 2 + app/services/analytics_events.rb | 4 +- .../in_person/ready_to_verify/show.html.erb | 38 +++++++++++-------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/controllers/frontend_log_controller.rb b/app/controllers/frontend_log_controller.rb index b5110c0ed5e..5a7a5bf8163 100644 --- a/app/controllers/frontend_log_controller.rb +++ b/app/controllers/frontend_log_controller.rb @@ -18,6 +18,8 @@ class FrontendLogController < ApplicationController 'Multi-Factor Authentication: download backup code' => :multi_factor_auth_backup_code_download, 'Show Password button clicked' => :show_password_button_clicked, 'IdV: personal key acknowledgment toggled' => :idv_personal_key_acknowledgment_toggled, + 'IdV: user clicked sp link on ready to verify page' => :idv_in_person_ready_to_verify_sp_link_clicked, + 'IdV: user clicked what to bring link on ready to verify page' => :idv_in_person_ready_to_verify_what_to_bring_link_clicked, }.transform_values { |method| AnalyticsEvents.instance_method(method) }.freeze # rubocop:enable Layout/LineLength diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index fc12716e727..2a1881986bf 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -710,7 +710,7 @@ def idv_in_person_ready_to_verify_visit(proofing_components: nil, **extra) # The user clicked the sp link on the "ready to verify" page def idv_in_person_ready_to_verify_sp_link_clicked(**extra) track_event( - 'IdV: user clicked the sp link on the ready to verify page', + 'IdV: user clicked sp link on ready to verify page', **extra, ) end @@ -718,7 +718,7 @@ def idv_in_person_ready_to_verify_sp_link_clicked(**extra) # The user clicked the what to bring link on the "ready to verify" page def idv_in_person_ready_to_verify_what_to_bring_link_clicked(**extra) track_event( - 'IdV: user clicked the what to bring link on the ready to verify page', + 'IdV: user clicked what to bring link on ready to verify page', **extra, ) end diff --git a/app/views/idv/in_person/ready_to_verify/show.html.erb b/app/views/idv/in_person/ready_to_verify/show.html.erb index cc09feb91fd..9551c195b2f 100644 --- a/app/views/idv/in_person/ready_to_verify/show.html.erb +++ b/app/views/idv/in_person/ready_to_verify/show.html.erb @@ -30,16 +30,18 @@

<% if @presenter.service_provider_homepage_url.present? %> - <%= t( - 'in_person_proofing.body.barcode.return_to_partner_html', - link: link_to( - t( - 'in_person_proofing.body.barcode.return_to_partner_link', - sp_name: @presenter.sp_name, + <%= render ClickObserverComponent.new(event_name: 'IdV: user clicked sp link on ready to verify page') do %> + <%= t( + 'in_person_proofing.body.barcode.return_to_partner_html', + link: link_to( + t( + 'in_person_proofing.body.barcode.return_to_partner_link', + sp_name: @presenter.sp_name, + ), + @presenter.service_provider_homepage_url, ), - @presenter.service_provider_homepage_url, - ), - ) %> + ) %> + <% end %> <% else %> <%= t('in_person_proofing.body.barcode.close_window') %> <% end %> @@ -80,13 +82,17 @@ <% end %>

<%= t('in_person_proofing.body.barcode.questions') %> - <%= new_window_link_to( - t('in_person_proofing.body.barcode.learn_more'), - MarketingSite.help_center_article_url( - category: 'verify-your-identity', - article: 'verify-your-identity-in-person', - ), - ) %> + <%# add param to new_window_link_to for id, can be added to html options %> + <%= render ClickObserverComponent.new(event_name: 'IdV: user clicked what to bring link on ready to verify page') do %> + <%= new_window_link_to( + t('in_person_proofing.body.barcode.learn_more'), + MarketingSite.help_center_article_url( + category: 'verify-your-identity', + article: 'verify-your-identity-in-person', + ), + id: 'help_center_from_ready_to_verify', + ) %> + <% end %>

From f67441bedbd6270ec71ed15d025d14cada005e7e Mon Sep 17 00:00:00 2001 From: svalexander Date: Wed, 8 Feb 2023 15:28:57 -0500 Subject: [PATCH 3/9] update show.htm.erb_spec --- .../in_person/ready_to_verify/show.html.erb_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/views/idv/in_person/ready_to_verify/show.html.erb_spec.rb b/spec/views/idv/in_person/ready_to_verify/show.html.erb_spec.rb index 32431c94380..7598ec89385 100644 --- a/spec/views/idv/in_person/ready_to_verify/show.html.erb_spec.rb +++ b/spec/views/idv/in_person/ready_to_verify/show.html.erb_spec.rb @@ -24,6 +24,8 @@ end let(:presenter) { Idv::InPerson::ReadyToVerifyPresenter.new(enrollment: enrollment) } let(:step_indicator_steps) { Idv::Flows::InPersonFlow::STEP_INDICATOR_STEPS } + let(:sp_event_name) { 'IdV: user clicked sp link on ready to verify page' } + let(:help_event_name) { 'IdV: user clicked what to bring link on ready to verify page' } before do assign(:presenter, presenter) @@ -34,6 +36,14 @@ render expect(rendered).to have_content(service_provider.friendly_name) + expect(rendered).to have_css("lg-click-observer[event-name='#{sp_event_name}']") + end + + it 'displays a link back to the help center' do + render + + expect(rendered).to have_link(t('in_person_proofing.body.barcode.learn_more')) + expect(rendered).to have_css("lg-click-observer[event-name='#{help_event_name}']") end context 'when the user is not coming from a service provider' do From 51e3067d7291d0db15d9e566ce1191410f6db3de Mon Sep 17 00:00:00 2001 From: svalexander Date: Thu, 9 Feb 2023 14:02:44 -0500 Subject: [PATCH 4/9] wip tests --- .../components/review-issues-step.tsx | 5 ++++ spec/features/idv/analytics_spec.rb | 23 +++++++++++++++++++ spec/support/features/idv_step_helper.rb | 18 +++++++++++++++ spec/support/features/in_person_helper.rb | 2 +- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/app/javascript/packages/document-capture/components/review-issues-step.tsx b/app/javascript/packages/document-capture/components/review-issues-step.tsx index 6433a52ee68..4e05feeacc6 100644 --- a/app/javascript/packages/document-capture/components/review-issues-step.tsx +++ b/app/javascript/packages/document-capture/components/review-issues-step.tsx @@ -111,11 +111,16 @@ function ReviewIssuesStep({ } }, []); + // eslint-disable-next-line no-console + console.log('inPersonCtaVariantActive:', inPersonCtaVariantActive); if (!hasDismissed) { if (pii) { return ; } + // eslint-disable-next-line no-console + console.log('isFailedResult: ', isFailedResult); + // commenting out variants still fails test if (!inPersonURL || isFailedResult) { return ( { 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', 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' } }, + 'IdV: user clicked what to bring link on ready to verify page' => {}, + 'IdV: user clicked sp link on ready to verify page' => {}, } end # rubocop:enable Layout/LineLength @@ -185,18 +187,39 @@ before do allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + start_idv_from_sp sign_in_and_2fa_user(user) begin_in_person_proofing(user) complete_all_in_person_proofing_steps(user) complete_phone_step(user) complete_review_step(user) acknowledge_and_confirm_personal_key + visit_help_center + visit_sp end it 'records all of the events', allow_browser_log: true do + max_wait = Time.now + 5.seconds + wait_for_event("IdV: user clicked what to bring link on ready to verify page", max_wait) + # wait_for_event('IdV: user clicked sp link on ready to verify page') in_person_path_events.each do |event, attributes| expect(fake_analytics).to have_logged_event(event, attributes) end end + + # wait for event to happen + def wait_for_event(event, wait) + frequency = 0.1.seconds + loop do + expect(fake_analytics).to have_logged_event(event) + return + rescue RSpec::Expectations::ExpectationNotMetError => err + if wait - Time.now < frequency + raise err + end + sleep frequency + next + end + end end end diff --git a/spec/support/features/idv_step_helper.rb b/spec/support/features/idv_step_helper.rb index 9b1ddc652d1..7cb8208932f 100644 --- a/spec/support/features/idv_step_helper.rb +++ b/spec/support/features/idv_step_helper.rb @@ -55,6 +55,24 @@ def complete_idv_steps_with_phone_before_review_step(user = user_with_2fa) complete_phone_step(user) end + def visit_help_center + click_what_to_bring_link + end + + def click_what_to_bring_link + expect(page).to have_content(t('in_person_proofing.headings.barcode')) + click_link t('in_person_proofing.body.barcode.learn_more') + end + + def visit_sp + click_sp_link + end + + def click_sp_link + expect(page).to have_content(t('in_person_proofing.body.barcode.return_to_partner_html')) + click_link t('in_person_proofing.body.barcode.return_to_partner_link') + end + def complete_review_step(user = user_with_2fa) password = user.password || user_password fill_in 'Password', with: password diff --git a/spec/support/features/in_person_helper.rb b/spec/support/features/in_person_helper.rb index bccb12b833e..05e37546093 100644 --- a/spec/support/features/in_person_helper.rb +++ b/spec/support/features/in_person_helper.rb @@ -42,7 +42,7 @@ def begin_in_person_proofing(_user = nil) complete_doc_auth_steps_before_document_capture_step mock_doc_auth_attention_with_barcode attach_and_submit_images - + binding.pry click_link t('in_person_proofing.body.cta.button') end From 6ba5b0d77a69760f4c10c81b1f94e1f0e0c9ff29 Mon Sep 17 00:00:00 2001 From: svalexander Date: Fri, 10 Feb 2023 13:30:19 -0500 Subject: [PATCH 5/9] add click events to integration test --- .../components/review-issues-step.tsx | 5 ----- spec/features/idv/analytics_spec.rb | 14 ++++++++------ spec/support/features/idv_step_helper.rb | 9 +++++++-- spec/support/features/in_person_helper.rb | 1 - 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/javascript/packages/document-capture/components/review-issues-step.tsx b/app/javascript/packages/document-capture/components/review-issues-step.tsx index 4e05feeacc6..6433a52ee68 100644 --- a/app/javascript/packages/document-capture/components/review-issues-step.tsx +++ b/app/javascript/packages/document-capture/components/review-issues-step.tsx @@ -111,16 +111,11 @@ function ReviewIssuesStep({ } }, []); - // eslint-disable-next-line no-console - console.log('inPersonCtaVariantActive:', inPersonCtaVariantActive); if (!hasDismissed) { if (pii) { return ; } - // eslint-disable-next-line no-console - console.log('isFailedResult: ', isFailedResult); - // commenting out variants still fails test if (!inPersonURL || isFailedResult) { return ( err - if wait - Time.now < frequency - raise err - end + raise err if wait - Time.now < frequency sleep frequency next end diff --git a/spec/support/features/idv_step_helper.rb b/spec/support/features/idv_step_helper.rb index 7cb8208932f..f46e8f23566 100644 --- a/spec/support/features/idv_step_helper.rb +++ b/spec/support/features/idv_step_helper.rb @@ -69,8 +69,13 @@ def visit_sp end def click_sp_link - expect(page).to have_content(t('in_person_proofing.body.barcode.return_to_partner_html')) - click_link t('in_person_proofing.body.barcode.return_to_partner_link') + expect(page).to have_content(sp_text) + click_link('return to Test SP') + end + + def sp_text + 'You may now close this window or return to Test SP to complete any next steps' + + ' you can access until your identity has been verified.' end def complete_review_step(user = user_with_2fa) diff --git a/spec/support/features/in_person_helper.rb b/spec/support/features/in_person_helper.rb index 05e37546093..7284f873f71 100644 --- a/spec/support/features/in_person_helper.rb +++ b/spec/support/features/in_person_helper.rb @@ -42,7 +42,6 @@ def begin_in_person_proofing(_user = nil) complete_doc_auth_steps_before_document_capture_step mock_doc_auth_attention_with_barcode attach_and_submit_images - binding.pry click_link t('in_person_proofing.body.cta.button') end From 2dd0174f14ec14145f9d45be14fd7679865c5893 Mon Sep 17 00:00:00 2001 From: svalexander Date: Fri, 10 Feb 2023 13:36:25 -0500 Subject: [PATCH 6/9] lint fixes --- spec/features/idv/analytics_spec.rb | 4 ++-- spec/support/features/idv_step_helper.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/idv/analytics_spec.rb b/spec/features/idv/analytics_spec.rb index eb914c7a8a9..fafcf785429 100644 --- a/spec/features/idv/analytics_spec.rb +++ b/spec/features/idv/analytics_spec.rb @@ -203,7 +203,7 @@ end it 'records all of the events', allow_browser_log: true do - max_wait = Time.now + 5.seconds + max_wait = Time.zone.now + 5.seconds wait_for_event('IdV: user clicked what to bring link on ready to verify page', max_wait) wait_for_event('IdV: user clicked sp link on ready to verify page', max_wait) in_person_path_events.each do |event, attributes| @@ -218,7 +218,7 @@ def wait_for_event(event, wait) expect(fake_analytics).to have_logged_event(event) return rescue RSpec::Expectations::ExpectationNotMetError => err - raise err if wait - Time.now < frequency + raise err if wait - Time.zone.now < frequency sleep frequency next end diff --git a/spec/support/features/idv_step_helper.rb b/spec/support/features/idv_step_helper.rb index f46e8f23566..c9c09aab450 100644 --- a/spec/support/features/idv_step_helper.rb +++ b/spec/support/features/idv_step_helper.rb @@ -74,8 +74,8 @@ def click_sp_link end def sp_text - 'You may now close this window or return to Test SP to complete any next steps' + - ' you can access until your identity has been verified.' + 'You may now close this window or return to Test SP to complete any next steps' \ + ' you can access until your identity has been verified.' end def complete_review_step(user = user_with_2fa) From ced871895dd0af6fddc2c7d615503e08770b65f0 Mon Sep 17 00:00:00 2001 From: svalexander Date: Fri, 10 Feb 2023 13:48:23 -0500 Subject: [PATCH 7/9] =?UTF-8?q?changelog:=20Internal,=20Analytics=20Events?= =?UTF-8?q?,=20add=20analytics=20event=20for=20usps=20e=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 1483295a01991d78d26938eb0d6587647c8d17d1 Mon Sep 17 00:00:00 2001 From: svalexander Date: Fri, 10 Feb 2023 13:49:09 -0500 Subject: [PATCH 8/9] changelog: Internal, Analytics Events, add analytics events for links on ready to veryify page From d36505958beff8ee18995ea0e9ea1480057a115a Mon Sep 17 00:00:00 2001 From: svalexander Date: Fri, 10 Feb 2023 13:52:16 -0500 Subject: [PATCH 9/9] remove unused code and comment --- app/views/idv/in_person/ready_to_verify/show.html.erb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/idv/in_person/ready_to_verify/show.html.erb b/app/views/idv/in_person/ready_to_verify/show.html.erb index 9551c195b2f..858543541dd 100644 --- a/app/views/idv/in_person/ready_to_verify/show.html.erb +++ b/app/views/idv/in_person/ready_to_verify/show.html.erb @@ -82,7 +82,6 @@ <% end %>

<%= t('in_person_proofing.body.barcode.questions') %> - <%# add param to new_window_link_to for id, can be added to html options %> <%= render ClickObserverComponent.new(event_name: 'IdV: user clicked what to bring link on ready to verify page') do %> <%= new_window_link_to( t('in_person_proofing.body.barcode.learn_more'), @@ -90,7 +89,6 @@ category: 'verify-your-identity', article: 'verify-your-identity-in-person', ), - id: 'help_center_from_ready_to_verify', ) %> <% end %>