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
26 changes: 26 additions & 0 deletions app/controllers/idv/gpo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ class GpoController < ApplicationController
def index
@presenter = GpoPresenter.new(current_user, url_options)
@step_indicator_current_step = step_indicator_current_step
# Funnel::DocAuth::RegisterStep.new(current_user.id, current_sp&.issuer).
# call(:usps_address, :view, true)
Comment on lines +14 to +15
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am open to dropping the commented out lines, but figured it was easier to leave them in. Could also have gone with a feature flags approach, but that seemed like a lot more temporary code and more complex testing

Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'proposed',
user_id: current_user.id,
issuer: current_sp&.issuer,
token: :usps_address,
action: :view,
success: true,
}.to_json,
)
analytics.idv_gpo_address_visited(
letter_already_sent: @presenter.resend_requested?,
)
Expand Down Expand Up @@ -45,6 +58,19 @@ def step_indicator_current_step
end

def update_tracking
# Funnel::DocAuth::RegisterStep.new(current_user.id, current_sp&.issuer).
# call(:usps_letter_sent, :update, true)
Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'proposed',
user_id: current_user.id,
issuer: current_sp&.issuer,
token: :usps_letter_sent,
action: :update,
success: true,
}.to_json,
)
analytics.idv_gpo_address_letter_requested(resend: resend_requested?)
irs_attempts_api_tracker.idv_gpo_letter_requested(resend: resend_requested?)
create_user_event(:gpo_mail_sent, current_user)
Expand Down
28 changes: 28 additions & 0 deletions app/controllers/idv/phone_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ def new

async_state = step.async_state
if async_state.none?
# Funnel::DocAuth::RegisterStep.new(current_user.id, current_sp&.issuer).
# call(:verify_phone, :view, true)
Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'proposed',
user_id: current_user.id,
issuer: current_sp&.issuer,
token: :verify_phone,
action: :view,
success: true,
}.to_json,
)

analytics.idv_phone_of_record_visited
render :new, locals: { gpo_letter_available: gpo_letter_available }
elsif async_state.in_progress?
Expand All @@ -33,6 +47,20 @@ def new

def create
result = idv_form.submit(step_params)
# Funnel::DocAuth::RegisterStep.new(current_user.id, current_sp&.issuer).
# call(:verify_phone, :update, result.success?)
Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'proposed',
user_id: current_user.id,
issuer: current_sp&.issuer,
token: :verify_phone,
action: :update,
success: result.success?,
}.to_json,
)

analytics.idv_phone_confirmation_form_submitted(**result.to_h)
irs_attempts_api_tracker.idv_phone_submitted(
success: result.success?,
Expand Down
26 changes: 26 additions & 0 deletions app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ def confirm_current_password

def new
@applicant = idv_session.applicant
# Funnel::DocAuth::RegisterStep.new(current_user.id, current_sp&.issuer).
# call(:encrypt, :view, true)
Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'proposed',
user_id: current_user.id,
issuer: current_sp&.issuer,
token: :encrypt,
action: :view,
success: true,
}.to_json,
)
analytics.idv_review_info_visited(address_verification_method: address_verification_method)

gpo_mail_service = Idv::GpoMail.new(current_user)
Expand All @@ -63,6 +76,19 @@ def create
success: true,
deactivation_reason: idv_session.profile.deactivation_reason,
)
# Funnel::DocAuth::RegisterStep.new(current_user.id, current_sp&.issuer).
# call(:verified, :view, true)
Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'proposed',
user_id: current_user.id,
issuer: current_sp&.issuer,
token: :verified,
action: :view,
success: true,
}.to_json,
)
analytics.idv_final(
success: true,
deactivation_reason: idv_session.profile.deactivation_reason,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ class RegisterStepFromAnalyticsSubmitEvent
def self.call(user_id, issuer, event, result)
token = ANALYTICS_EVENT_TO_DOC_AUTH_LOG_TOKEN[event]
return unless token
Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'original',
user_id: user_id,
issuer: issuer,
token: token,
action: :update,
success: result,
}.to_json,
)
Funnel::DocAuth::RegisterStep.new(user_id, issuer).call(token, :update, result)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ class RegisterStepFromAnalyticsViewEvent

def self.call(user_id, issuer, event, result)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is the file I missed entirely last time 😬 as far as I can tell it's just these 2! shouldn't be a mystery 3rd one

token = ANALYTICS_EVENT_TO_DOC_AUTH_LOG_TOKEN[event]
Funnel::DocAuth::RegisterStep.new(user_id, issuer).call(token, :view, result) if token
return unless token
Rails.logger.info(
{
name: 'event_to_doc_auth_log_token',
source: 'original',
user_id: user_id,
issuer: issuer,
token: token,
action: :view,
success: result,
}.to_json,
)
Funnel::DocAuth::RegisterStep.new(user_id, issuer).call(token, :view, result)
end
end
end
Expand Down
18 changes: 18 additions & 0 deletions spec/controllers/idv/gpo_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
)
end

it 'updates the doc auth log for the user for the usps_address_view event' do
unstub_analytics
doc_auth_log = DocAuthLog.create(user_id: user.id)

expect { get :index }.to(
change { doc_auth_log.reload.usps_address_view_count }.from(0).to(1),
)
end

it 'redirects if the user has sent too much mail' do
allow(controller.gpo_mail_service).to receive(:mail_spammed?).and_return(true)
allow(subject.idv_session).to receive(:address_mechanism_chosen?).
Expand Down Expand Up @@ -109,6 +118,15 @@

put :create
end

it 'updates the doc auth log for the user for the usps_letter_sent event' do
unstub_analytics
doc_auth_log = DocAuthLog.create(user_id: user.id)

expect { put :create }.to(
change { doc_auth_log.reload.usps_letter_sent_submit_count }.from(0).to(1),
)
end
end

context 'resending a letter' do
Expand Down
21 changes: 21 additions & 0 deletions spec/controllers/idv/phone_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
stub_verify_steps_one_and_two(user)
end

it 'updates the doc auth log for the user for the usps_letter_sent event' do
unstub_analytics
doc_auth_log = DocAuthLog.create(user_id: user.id)

expect { get :new }.to(
change { doc_auth_log.reload.verify_phone_view_count }.from(0).to(1),
)
end

context 'when the phone number has been confirmed as user 2FA phone' do
before do
subject.idv_session.user_phone_confirmation = true
Expand Down Expand Up @@ -269,6 +278,18 @@
)
end

it 'updates the doc auth log for the user with verify_phone_submit step' do
user = create(:user, :with_phone, with: { phone: good_phone, confirmed_at: Time.zone.now })
unstub_analytics
stub_verify_steps_one_and_two(user)

doc_auth_log = DocAuthLog.create(user_id: user.id)

expect { put :create, params: { idv_phone_form: { phone: good_phone } } }.to(
change { doc_auth_log.reload.verify_phone_submit_count }.from(0).to(1),
)
end

context 'when same as user phone' do
before do
user = build(
Expand Down
20 changes: 20 additions & 0 deletions spec/controllers/idv/review_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ def show
),
)
end

it 'updates the doc auth log for the user for the encrypt view event' do
unstub_analytics
doc_auth_log = DocAuthLog.create(user_id: user.id)

expect { get :new }.to(
change { doc_auth_log.reload.encrypt_view_count }.from(0).to(1),
)
end
end

context 'user has not requested too much mail' do
Expand Down Expand Up @@ -630,6 +639,17 @@ def show
deactivation_reason: 'threatmetrix_review_pending'
)
end

it 'updates the doc auth log for the user for the verified view event' do
unstub_analytics
doc_auth_log = DocAuthLog.create(user_id: user.id)

expect do
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }
end.to(
change { doc_auth_log.reload.verified_view_count }.from(0).to(1),
)
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/support/analytics_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ def stub_analytics
controller.analytics = FakeAnalytics.new
@analytics = controller.analytics
end

def unstub_analytics
controller.analytics = nil
@analytics = nil
end
end