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
2 changes: 1 addition & 1 deletion app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create
user_session[:need_personal_key_confirmation] = true
redirect_to next_step
analytics.track_event(Analytics::IDV_REVIEW_COMPLETE)
analytics.track_event(Analytics::IDV_FINAL, success: true)
analytics.idv_final(success: true)

return unless FeatureManagement.reveal_gpo_code?
session[:last_gpo_confirmation_code] = idv_session.gpo_otp
Expand Down
5 changes: 2 additions & 3 deletions app/forms/idv/api_document_verification_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ def submit
},
)

@analytics.track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_FORM,
response.to_h,
@analytics.idv_doc_auth_submitted_image_upload_form(
**response.to_h,
)

response
Expand Down
17 changes: 5 additions & 12 deletions app/forms/idv/api_image_upload_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ def validate_form
extra: extra_attributes,
)

track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_FORM,
response.to_h,
)
analytics.idv_doc_auth_submitted_image_upload_form(**response.to_h)

response
end
Expand Down Expand Up @@ -88,10 +85,8 @@ def validate_pii_from_doc(client_response)
response = Idv::DocPiiForm.new(client_response.pii_from_doc).submit
response.extra.merge!(extra_attributes)

track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_PII_VALIDATION,
response.to_h,
)
analytics.idv_doc_auth_submitted_pii_validation(**response.to_h)

store_pii(client_response) if client_response.success? && response.success?

response
Expand Down Expand Up @@ -219,12 +214,10 @@ def track_event(event, attributes = {})
def update_analytics(client_response)
add_costs(client_response)
update_funnel(client_response)
track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_VENDOR,
client_response.to_h.merge(
analytics.idv_doc_auth_submitted_image_upload_vendor(
**client_response.to_h.merge(
client_image_metrics: image_metadata,
async: false,
flow_path: params[:flow_path],
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.

why did we remove flow_path here?

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.

I believe we need to keep it/bring it back otherwise we lose data

),
)
end
Expand Down
5 changes: 2 additions & 3 deletions app/jobs/document_proofing_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ def perform(

throttle = Throttle.for(user: user, throttle_type: :idv_doc_auth)

analytics.track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_IMAGE_UPLOAD_VENDOR,
proofer_result.to_h.merge(
analytics.idv_doc_auth_submitted_image_upload_vendor(
**proofer_result.to_h.merge(
state: proofer_result.pii_from_doc[:state],
state_id_type: proofer_result.pii_from_doc[:state_id_type],
async: true,
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_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'
IDV_DOC_AUTH_WARNING_VISITED = 'IdV: doc auth warning visited'
IDV_FINAL = 'IdV: final resolution'
IDV_FORGOT_PASSWORD = 'IdV: forgot password visited'
IDV_FORGOT_PASSWORD_CONFIRMED = 'IdV: forgot password confirmed'
IDV_INTRO_VISIT = 'IdV: intro visited'
Expand Down
128 changes: 128 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,134 @@ def idv_doc_auth_exception_visited(step_name:, remaining_attempts:, **extra)
)
end

# @param [Boolean] success
# @param [Hash] errors
# @param [Integer] attempts
# @param [Integer] remaining_attempts
# @param [String] user_id
# @param [String] flow_path
# The document capture image uploaded was locally validated during the IDV process
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.

supernit... extra space

Suggested change
# The document capture image uploaded was locally validated during the IDV process
# The document capture image uploaded was locally validated during the IDV process

def idv_doc_auth_submitted_image_upload_form(
success:,
errors:,
remaining_attempts:, flow_path:, attempts: nil,
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.

let's break these on to separate lines for consistency

Suggested change
remaining_attempts:, flow_path:, attempts: nil,
remaining_attempts:,
flow_path:,
attempts: nil,

user_id: nil,
**extra
)
track_event(
'IdV: doc auth image upload form submitted',
success: success,
errors: errors,
attempts: attempts,
remaining_attempts: remaining_attempts,
user_id: user_id,
flow_path: flow_path,
**extra,
)
end

# @param [Boolean] success
# @param [Hash] errors
# @param [String] exception
# @param [Boolean] billed
# @param [String] doc_auth_result
# @param [String] state
# @param [String] state_id_type
# @param [Boolean] async
# @param [Integer] attempts
# @param [Integer] remaining_attempts
# @param [Hash] client_image_metrics
# @param [String] flow_path
# The document capture image was uploaded to vendor during the IDV process
def idv_doc_auth_submitted_image_upload_vendor(
success:,
errors:,
exception:,
state:,
state_id_type:,
async:, attempts:,
remaining_attempts:,
client_image_metrics:,
flow_path:,
billed: nil,
doc_auth_result: nil,
**extra
)
track_event(
'IdV: doc auth image upload vendor submitted',
success: success,
errors: errors,
exception: exception,
billed: billed,
doc_auth_result: doc_auth_result,
state: state,
state_id_type: state_id_type,
async: async,
attempts: attempts,
remaining_attempts: remaining_attempts,
client_image_metrics: client_image_metrics,
flow_path: flow_path,
**extra,
)
end

# @param [Boolean] success
# @param [Hash] errors
# @param [String] user_id
# @param [Integer] remaining_attempts
# @param [Hash] pii_like_keypaths
# @param [String] flow_path
# The PII that came back from the document capture vendor was validated
def idv_doc_auth_submitted_pii_validation(
success:,
errors:,
remaining_attempts:,
pii_like_keypaths:,
flow_path:,
user_id: nil,
**extra
)
track_event(
'IdV: doc auth image upload vendor pii validation',
success: success,
errors: errors,
user_id: user_id,
remaining_attempts: remaining_attempts,
pii_like_keypaths: pii_like_keypaths,
flow_path: flow_path,
**extra,
)
end

# @param [String] step_name
# @param [Integer] remaining_attempts
# The user was sent to a warning page during the IDV flow
def idv_doc_auth_warning_visited(
step_name:,
remaining_attempts:,
**extra
)
track_event(
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.

codeclimate is hinting that this is untested, which was my queue to look for the usage above of the string outside of specs

'IdV: doc auth warning visited',
step_name: step_name,
remaining_attempts: remaining_attempts,
**extra,
)
end

# @param [Boolean] success
# Tracks the last step of IDV, indicates the user successfully prooved
def idv_final(
success:,
**extra
)
track_event(
'IdV: final resolution',
success: success,
**extra,
)
end

# User visited IDV personal key page
def idv_personal_key_visited
track_event('IdV: personal key visited')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class RegisterStepFromAnalyticsViewEvent
ANALYTICS_EVENT_TO_DOC_AUTH_LOG_TOKEN = {
Analytics::IDV_PHONE_RECORD_VISIT => :verify_phone,
Analytics::IDV_REVIEW_VISIT => :encrypt,
Analytics::IDV_FINAL => :verified,
'IdV: final resolution' => :verified,
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.

Hmmmm this is an interesting case, it makes me rethink our position about constants... we should file a ticket to see if we can clean this up the new world of documented methods

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.

Yes, this seems a little off. I'll add a ticket in the backlog to revisit constants.

Analytics::IDV_GPO_ADDRESS_VISITED => :usps_address,
}.freeze

Expand Down
5 changes: 2 additions & 3 deletions app/services/idv/actions/verify_document_status_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def process_async_state(current_async_state)
def async_state_done(async_result)
doc_pii_form_result = Idv::DocPiiForm.new(async_result.pii).submit

@flow.analytics.track_event(
Analytics::IDV_DOC_AUTH_SUBMITTED_PII_VALIDATION,
doc_pii_form_result.to_h.merge(
@flow.analytics.idv_doc_auth_submitted_pii_validation(
**doc_pii_form_result.to_h.merge(
remaining_attempts: remaining_attempts,
flow_path: flow_path,
),
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 @@ -30,8 +30,7 @@ def idv_failure(result)
)
redirect_to idv_session_errors_exception_url
else
@flow.analytics.track_event(
Analytics::IDV_DOC_AUTH_WARNING_VISITED,
@flow.analytics.idv_doc_auth_warning_visited(
step_name: self.class.name,
remaining_attempts: throttle.remaining_count,
)
Expand Down
Loading