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
7 changes: 3 additions & 4 deletions app/controllers/idv/gpo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def index
current_async_state = async_state

if current_async_state.none?
analytics.track_event(
Analytics::IDV_GPO_ADDRESS_VISITED,
analytics.idv_gpo_address_visited(
letter_already_sent: @presenter.letter_already_sent?,
)
render :index
Expand Down Expand Up @@ -56,7 +55,7 @@ def gpo_mail_service
private

def update_tracking
analytics.track_event(Analytics::IDV_GPO_ADDRESS_LETTER_REQUESTED)
analytics.idv_gpo_address_letter_requested
create_user_event(:gpo_mail_sent, current_user)

ProofingComponent.create_or_find_by(user: current_user).update(address_check: 'gpo_letter')
Expand Down Expand Up @@ -251,7 +250,7 @@ def async_state_done(async_state)
end

def async_state_done_analytics(result)
analytics.track_event(Analytics::IDV_GPO_ADDRESS_SUBMITTED, result.to_h)
analytics.idv_gpo_address_submitted(**result.to_h)
Db::SpCost::AddSpCost.call(current_sp, 2, :lexis_nexis_resolution)
Db::ProofingCost::AddUserProofingCost.call(current_user.id, :lexis_nexis_resolution)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/gpo_verify_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create
render_throttled
else
result = @gpo_verify_form.submit
analytics.track_event(Analytics::IDV_GPO_VERIFICATION_SUBMITTED, result.to_h)
analytics.idv_gpo_verification_submitted(**result.to_h)

if result.success?
event = create_user_event_with_disavowal(:account_verified)
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/idv/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class SessionsController < ApplicationController

def destroy
cancel_verification_attempt_if_pending_profile
analytics.track_event(Analytics::IDV_START_OVER, **location_params)
analytics.idv_start_over(
step: location_params[:step],
location: location_params[:location],
)
user_session['idv/doc_auth'] = {}
idv_session.clear
Pii::Cacher.new(current_user, user_session).delete
Expand Down
5 changes: 0 additions & 5 deletions app/services/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ def session_started_at

# rubocop:disable Layout/LineLength
DOC_AUTH = 'Doc Auth' # visited or submitted is appended
IDV_START_OVER = 'IdV: start over'
IDV_GPO_ADDRESS_LETTER_REQUESTED = 'IdV: USPS address letter requested'
IDV_GPO_ADDRESS_SUBMITTED = 'IdV: USPS address submitted'
IDV_GPO_ADDRESS_VISITED = 'IdV: USPS address visited'
IDV_GPO_VERIFICATION_SUBMITTED = 'IdV: GPO verification submitted' # Previously: "Account verification submitted"
IDV_GPO_VERIFICATION_VISITED = 'IdV: GPO verification visited' # Previously: "Account verification visited"
INVALID_AUTHENTICITY_TOKEN = 'Invalid Authenticity Token'
LOGOUT_INITIATED = 'Logout Initiated'
Expand Down
70 changes: 70 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,60 @@ def idv_forgot_password_confirmed
track_event('IdV: forgot password confirmed')
end

# GPO address letter requested
def idv_gpo_address_letter_requested
track_event('IdV: USPS address letter requested')
end

# @param [Boolean] success
# @param [Hash] errors
# GPO address submitted
def idv_gpo_address_submitted(
success:,
errors:,
**extra
)
track_event(
'IdV: USPS address submitted',
success: success,
errors: errors,
**extra,
)
end

# @param [Boolean] letter_already_sent
# GPO address visited
def idv_gpo_address_visited(
letter_already_sent:,
**extra
)
track_event(
'IdV: USPS address visited',
letter_already_sent: letter_already_sent,
**extra,
)
end

# @identity.idp.previous_event_name Account verification submitted
# @param [Boolean] success
# @param [Hash] errors
# @param [Hash] pii_like_keypaths
# GPO verification submitted
def idv_gpo_verification_submitted(
Comment on lines 632 to 636
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This event had a # Previously: note...

  IDV_GPO_VERIFICATION_SUBMITTED = 'IdV: GPO verification submitted' # Previously: "Account verification submitted"

can we annotate that as well?

Suggested change
# @param [Boolean] success
# @param [Hash] errors
# @param [Hash] pii_like_keypaths
# GPO verification submitted
def idv_gpo_verification_submitted(
# @identity.idp.previous_event_name Account verification submitted
# @param [Boolean] success
# @param [Hash] errors
# @param [Hash] pii_like_keypaths
# GPO verification submitted
def idv_gpo_verification_submitted(

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.

Added to the annotation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please take a look at my suggested comment, we have a specific YARD tag for this, @identity.previous_event_name

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.

Oh I see it now. Suggested comment added.

success:,
errors:,
pii_like_keypaths:,
**extra
)
track_event(
'IdV: GPO verification submitted',
success: success,
errors: errors,
pii_like_keypaths: pii_like_keypaths,
**extra,
)
end

# User visits IdV
def idv_intro_visit
track_event('IdV: intro visited')
Expand Down Expand Up @@ -851,6 +905,22 @@ def idv_review_info_visited
track_event('IdV: review info visited')
end

# @param [String] step
# @param [String] location
# User started over idv
def idv_start_over(
step:,
location:,
**extra
)
track_event(
'IdV: start over',
step: step,
location: location,
**extra,
)
end

# User has visited the page that lets them confirm if they want a new personal key
def profile_personal_key_visit
track_event('Profile: Visited new personal key')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Funnel
module DocAuth
class RegisterStepFromAnalyticsSubmitEvent
ANALYTICS_EVENT_TO_DOC_AUTH_LOG_TOKEN = {
Analytics::IDV_GPO_ADDRESS_LETTER_REQUESTED => :usps_letter_sent,
'IdV: USPS address letter requested' => :usps_letter_sent,
'IdV: phone confirmation form' => :verify_phone,
}.freeze

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RegisterStepFromAnalyticsViewEvent
'IdV: phone of record visited' => :verify_phone,
'IdV: review info visited' => :encrypt,
'IdV: final resolution' => :verified,
Analytics::IDV_GPO_ADDRESS_VISITED => :usps_address,
'IdV: USPS address visited' => :usps_address,
}.freeze

def self.call(user_id, issuer, event, result)
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/idv/gpo_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

expect(response).to be_ok
expect(@analytics).to have_logged_event(
Analytics::IDV_GPO_ADDRESS_VISITED,
'IdV: USPS address visited',
letter_already_sent: false,
)
end
Expand Down Expand Up @@ -82,7 +82,7 @@
get :index

expect(@analytics).to have_logged_event(
Analytics::IDV_GPO_ADDRESS_VISITED,
'IdV: USPS address visited',
letter_already_sent: true,
)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/idv/gpo_verify_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

it 'redirects to the sign_up/completions page' do
expect(@analytics).to receive(:track_event).with(
Analytics::IDV_GPO_VERIFICATION_SUBMITTED,
'IdV: GPO verification submitted',
success: true,
errors: {},
pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]],
Expand All @@ -113,7 +113,7 @@

it 'redirects to the index page to show errors' do
expect(@analytics).to receive(:track_event).with(
Analytics::IDV_GPO_VERIFICATION_SUBMITTED,
'IdV: GPO verification submitted',
success: false,
errors: { otp: [t('errors.messages.confirmation_code_incorrect')] },
error_details: { otp: [:confirmation_code_incorrect] },
Expand All @@ -139,7 +139,7 @@
max_attempts = IdentityConfig.store.verify_gpo_key_max_attempts

expect(@analytics).to receive(:track_event).with(
Analytics::IDV_GPO_VERIFICATION_SUBMITTED,
'IdV: GPO verification submitted',
success: false,
errors: { otp: [t('errors.messages.confirmation_code_incorrect')] },
error_details: { otp: [:confirmation_code_incorrect] },
Expand Down
5 changes: 2 additions & 3 deletions spec/controllers/idv/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
delete :destroy, params: { step: 'first', location: 'get_help' }

expect(@analytics).to have_logged_event(
Analytics::IDV_START_OVER,
'IdV: start over',
step: 'first',
location: 'get_help',
)
Expand All @@ -59,9 +59,8 @@
expect(cancel).to receive(:call)

delete :destroy, params: { step: 'gpo_verify', location: 'clear_and_start_over' }

expect(@analytics).to have_logged_event(
Analytics::IDV_START_OVER,
'IdV: start over',
step: 'gpo_verify',
location: 'clear_and_start_over',
)
Expand Down