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
6 changes: 3 additions & 3 deletions app/controllers/idv/cancellations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ class CancellationsController < ApplicationController

def new
properties = ParseControllerFromReferer.new(request.referer).call
analytics.track_event(Analytics::IDV_CANCELLATION, properties.merge(step: params[:step]))
analytics.idv_cancellation_visited(step: params[:step], **properties)
self.session_go_back_path = go_back_path || idv_path
@hybrid_session = hybrid_session?
end

def update
if params.key?(:cancel)
analytics.track_event(Analytics::IDV_CANCELLATION_GO_BACK, step: params[:step])
analytics.idv_cancellation_go_back(step: params[:step])
redirect_to session_go_back_path || idv_path
else
render :new
end
end

def destroy
analytics.track_event(Analytics::IDV_CANCELLATION_CONFIRMED, step: params[:step])
analytics.idv_cancellation_confirmed(step: params[:step])
@return_to_sp_path = return_to_sp_failure_to_proof_path(location_params)
@hybrid_session = hybrid_session?
if hybrid_session?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/come_back_later_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ComeBackLaterController < ApplicationController
before_action :confirm_user_needs_gpo_confirmation

def show
analytics.track_event(Analytics::IDV_COME_BACK_LATER_VISIT)
analytics.idv_come_back_later_visit
end

private
Expand Down
5 changes: 0 additions & 5 deletions app/services/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ def session_started_at
# rubocop:disable Layout/LineLength
ACCOUNT_RESET_VISIT = 'Account deletion and reset visited'
DOC_AUTH = 'Doc Auth' # visited or submitted is appended
IDV_CANCELLATION = 'IdV: cancellation visited'
IDV_CANCELLATION_GO_BACK = 'IdV: cancellation go back'
IDV_CANCELLATION_CONFIRMED = 'IdV: cancellation confirmed'
IDV_COME_BACK_LATER_VISIT = 'IdV: come back later visited'
IDV_DOC_AUTH_EXCEPTION_VISITED = 'IdV: doc auth exception visited'
IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_FORM = 'IdV: doc auth image upload form submitted'
IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_VENDOR = 'IdV: doc auth image upload vendor submitted'
IDV_DOC_AUTH_SUBMITTED_PII_VALIDATION = 'IdV: doc auth image upload vendor pii validation'
Expand Down
47 changes: 47 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,53 @@ def idv_address_visit
track_event('IdV: address visited')
end

# @identity.idp.event_name IdV: cancellation visited
# @param [String] step the step that the user was on when they clicked cancel
# @param [String] request_came_from the controller and action from the
# source such as "users/sessions#new"
# The user clicked cancel during IDV (presented with an option to go back or confirm)
def idv_cancellation_visited(step:, request_came_from:, **extra)
track_event(
'IdV: cancellation visited',
step: step,
request_came_from: request_came_from,
**extra,
)
end

# @identity.idp.event_name IdV: cancellation confirmed
# @param [String] step the step that the user was on when they clicked cancel
# The user confirmed their choice to cancel going through IDV
def idv_cancellation_confirmed(step:, **extra)
track_event('IdV: cancellation confirmed', step: step, **extra)
end

# @identity.idp.event_name IdV: cancellation go back
# @param [String] step the step that the user was on when they clicked cancel
# The user chose to go back instead of cancel IDV
def idv_cancellation_go_back(step:, **extra)
track_event('IdV: cancellation go back', step: step, **extra)
end

# @identity.idp.event_name IdV: come back later visited
# The user visited the "come back later" page shown during the GPO mailing flow
def idv_come_back_later_visit
track_event('IdV: come back later visited')
end

# @identity.idp.event_name IdV: doc auth exception visited
# @param [String] step_name which step the user was on
# @param [Integer] remaining_attempts how many attempts the user has left before we throttle them
# The user visited an error page due to an encountering an exception talking to a proofing vendor
def idv_doc_auth_exception_visited(step_name:, remaining_attempts:, **extra)
track_event(
'IdV: doc auth exception visited',
step_name: step_name,
remaining_attempts: remaining_attempts,
**extra,
)
end

# @deprecated
# A user has downloaded their personal key. This event is no longer emitted.
# @identity.idp.event_name IdV: personal key downloaded
Expand Down
3 changes: 1 addition & 2 deletions app/services/idv/steps/doc_auth_base_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def idv_failure(result)
)
redirect_to idv_session_errors_failure_url
elsif result.extra.dig(:proofing_results, :exception).present?
@flow.analytics.track_event(
Analytics::IDV_DOC_AUTH_EXCEPTION_VISITED,
@flow.analytics.idv_doc_auth_exception_visited(
step_name: self.class.name,
remaining_attempts: throttle.remaining_count,
)
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/idv/cancellations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
stub_analytics
properties = { request_came_from: 'no referer', step: nil }

expect(@analytics).to receive(:track_event).with(Analytics::IDV_CANCELLATION, properties)
expect(@analytics).to receive(:track_event).with('IdV: cancellation visited', properties)

get :new
end
Expand All @@ -30,7 +30,7 @@
request.env['HTTP_REFERER'] = 'http://example.com/'
properties = { request_came_from: 'users/sessions#new', step: nil }

expect(@analytics).to receive(:track_event).with(Analytics::IDV_CANCELLATION, properties)
expect(@analytics).to receive(:track_event).with('IdV: cancellation visited', properties)

get :new
end
Expand All @@ -40,7 +40,7 @@
stub_analytics
properties = { request_came_from: 'no referer', step: 'first' }

expect(@analytics).to receive(:track_event).with(Analytics::IDV_CANCELLATION, properties)
expect(@analytics).to receive(:track_event).with('IdV: cancellation visited', properties)

get :new, params: { step: 'first' }
end
Expand Down Expand Up @@ -107,7 +107,7 @@
context 'with cancel param' do
it 'logs cancellation go back' do
expect(@analytics).to receive(:track_event).with(
Analytics::IDV_CANCELLATION_GO_BACK,
'IdV: cancellation go back',
step: 'first',
)

Expand Down Expand Up @@ -144,7 +144,7 @@
stub_analytics

expect(@analytics).to receive(:track_event).with(
Analytics::IDV_CANCELLATION_CONFIRMED,
'IdV: cancellation confirmed',
step: 'first',
)

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/idv/come_back_later_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
it 'renders the show template' do
stub_analytics

expect(@analytics).to receive(:track_event).with(Analytics::IDV_COME_BACK_LATER_VISIT)
expect(@analytics).to receive(:track_event).with('IdV: come back later visited')

get :show

Expand Down
4 changes: 2 additions & 2 deletions spec/features/idv/doc_auth/welcome_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def expect_doc_auth_upload_step

it 'logs events when returning to sp' do
click_on t('links.cancel')
expect(fake_analytics).to have_logged_event(Analytics::IDV_CANCELLATION, step: 'welcome')
expect(fake_analytics).to have_logged_event('IdV: cancellation visited', step: 'welcome')

click_on t('forms.buttons.cancel')
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION_CONFIRMED,
'IdV: cancellation confirmed',
step: 'welcome',
)

Expand Down
6 changes: 3 additions & 3 deletions spec/features/idv/doc_capture/document_capture_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@

expect(page).to have_text(t('idv.cancel.headings.prompt.hybrid'))
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION,
'IdV: cancellation visited',
step: 'document_capture',
)

click_on t('forms.buttons.cancel')

expect(page).to have_text(t('idv.cancel.headings.confirmation.hybrid'))
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION_CONFIRMED,
'IdV: cancellation confirmed',
step: 'document_capture',
)
end
Expand All @@ -54,7 +54,7 @@

expect(page).to have_current_path(idv_capture_doc_document_capture_step)
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION_GO_BACK,
'IdV: cancellation go back',
step: 'document_capture',
)
end
Expand Down
12 changes: 6 additions & 6 deletions spec/support/idv_examples/cancel_at_idv_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
expect(page).to have_content(t('headings.cancellations.prompt'))
expect(current_path).to eq(idv_cancel_path)
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION,
'IdV: cancellation visited',
step: step.to_s,
)

click_on t('links.go_back')

expect(current_path).to eq(original_path)
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION_GO_BACK,
'IdV: cancellation go back',
step: step.to_s,
)
end
Expand All @@ -40,14 +40,14 @@

expect(page).to have_content(t('headings.cancellations.prompt'))
expect(current_path).to eq(idv_cancel_path)
expect(fake_analytics).to have_logged_event(Analytics::IDV_CANCELLATION, step: step.to_s)
expect(fake_analytics).to have_logged_event('IdV: cancellation visited', step: step.to_s)

click_on t('forms.buttons.cancel')

expect(page).to have_content(t('headings.cancellations.confirmation', app_name: APP_NAME))
expect(current_path).to eq(idv_cancel_path)
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION_CONFIRMED,
'IdV: cancellation confirmed',
step: step.to_s,
)

Expand All @@ -69,7 +69,7 @@

expect(page).to have_content(t('headings.cancellations.prompt'))
expect(current_path).to eq(idv_cancel_path)
expect(fake_analytics).to have_logged_event(Analytics::IDV_CANCELLATION, step: step.to_s)
expect(fake_analytics).to have_logged_event('IdV: cancellation visited', step: step.to_s)

click_on t('forms.buttons.cancel')

Expand All @@ -80,7 +80,7 @@
href: account_url,
)
expect(fake_analytics).to have_logged_event(
Analytics::IDV_CANCELLATION_CONFIRMED,
'IdV: cancellation confirmed',
step: step.to_s,
)

Expand Down