Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG-14064: Make IdV event enhancement opt-out #11588

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
113 changes: 40 additions & 73 deletions app/services/idv/analytics_events_enhancer.rb
Original file line number Diff line number Diff line change
@@ -1,76 +1,53 @@
# frozen_string_literal: true

module Idv
# For events beginning with +idv_+, add additional information to the event
# when a User object is available:
# - +proofing_components+: User's current proofing components
# - +active_profile_idv_level+: ID verification level of user's active profile.
# - +pending_profile_idv_level+: ID verification level of user's pending profile.
# Generally, analytics events that are called in contexts where there is no expectation
# of an {Idv::Session} being present or may be excessively noisy are opted-out.
# (e.g., jobs, client-generated events, action scripts).
#
# Additionally, +profile_history+, the list of a User's profiles
# (sorted by creation date, oldest to newest), may be added to events, but this is opt-in only.
# See #METHODS_WITH_PROFILE_HISTORY for the list of included events.
module AnalyticsEventsEnhancer
IGNORED_METHODS = %i[
EXCLUDED_FRONTEND_EVENT_METHODS = %i[
idv_acuant_sdk_loaded
idv_address_submitted
idv_address_visit
idv_back_image_added
idv_back_image_clicked
idv_barcode_warning_continue_clicked
idv_barcode_warning_retake_photos_clicked
idv_capture_troubleshooting_dismissed
idv_consent_checkbox_toggled
idv_doc_auth_agreement_submitted
idv_doc_auth_agreement_visited
idv_doc_auth_capture_complete_visited
idv_doc_auth_document_capture_submitted
idv_doc_auth_document_capture_visited
idv_doc_auth_exception_visited
idv_doc_auth_failed_image_resubmitted
idv_doc_auth_how_to_verify_submitted
idv_doc_auth_how_to_verify_visited
idv_doc_auth_hybrid_handoff_submitted
idv_doc_auth_hybrid_handoff_visited
idv_doc_auth_link_sent_submitted
idv_doc_auth_link_sent_visited
idv_doc_auth_redo_ssn_submitted
idv_doc_auth_socure_webhook_received
idv_doc_auth_ssn_submitted
idv_doc_auth_ssn_visited
idv_doc_auth_submitted_image_upload_form
idv_doc_auth_submitted_image_upload_vendor
idv_socure_verification_data_requested
idv_doc_auth_submitted_pii_validation
idv_doc_auth_verify_proofing_results
idv_doc_auth_verify_submitted
idv_doc_auth_verify_visited
idv_doc_auth_warning_visited
idv_doc_auth_welcome_submitted
idv_doc_auth_welcome_visited
idv_front_image_added
idv_front_image_clicked
idv_gpo_confirm_start_over_before_letter_visited
idv_gpo_confirm_start_over_visited
idv_image_capture_failed
idv_in_person_location_submitted
idv_in_person_ready_to_verify_sp_link_clicked
idv_in_person_ready_to_verify_what_to_bring_link_clicked
idv_sdk_error_before_init
idv_sdk_selfie_image_capture_closed_without_photo
idv_sdk_selfie_image_capture_failed
idv_sdk_selfie_image_capture_initialized
idv_sdk_selfie_image_capture_opened
idv_sdk_selfie_image_re_taken
idv_sdk_selfie_image_taken
idv_selfie_image_added
idv_verify_in_person_troubleshooting_option_clicked
].freeze

EXCLUDED_JOB_EVENT_METHODS = %i[
idv_gpo_expired
idv_gpo_reminder_email_sent
idv_image_capture_failed
idv_in_person_email_reminder_job_email_initiated
idv_in_person_email_reminder_job_exception
idv_in_person_location_submitted
idv_in_person_location_visited
idv_in_person_locations_request_failure
idv_in_person_locations_searched
idv_in_person_prepare_submitted
idv_in_person_prepare_visited
idv_in_person_proofing_address_visited
idv_in_person_proofing_enrollments_ready_for_status_check_job_completed
idv_in_person_proofing_enrollments_ready_for_status_check_job_ingestion_error
idv_in_person_proofing_enrollments_ready_for_status_check_job_started
idv_in_person_proofing_nontransliterable_characters_submitted
idv_in_person_proofing_residential_address_submitted
idv_in_person_proofing_state_id_submitted
idv_in_person_proofing_state_id_visited
idv_in_person_ready_to_verify_sp_link_clicked
idv_in_person_ready_to_verify_what_to_bring_link_clicked
idv_in_person_send_proofing_notification_attempted
idv_in_person_send_proofing_notification_job_completed
idv_in_person_send_proofing_notification_job_exception
idv_in_person_send_proofing_notification_job_skipped
idv_in_person_send_proofing_notification_job_started
idv_in_person_switch_back_submitted
idv_in_person_switch_back_visited
idv_in_person_usps_proofing_enrollment_code_email_received
idv_in_person_usps_proofing_results_job_completed
idv_in_person_usps_proofing_results_job_deadline_passed_email_exception
Expand All @@ -83,30 +60,20 @@ module AnalyticsEventsEnhancer
idv_in_person_usps_proofing_results_job_started
idv_in_person_usps_proofing_results_job_unexpected_response
idv_in_person_usps_proofing_results_job_user_sent_to_fraud_review
idv_in_person_usps_request_enroll_exception
idv_ipp_deactivated_for_never_visiting_post_office
idv_link_sent_capture_doc_polling_complete
idv_link_sent_capture_doc_polling_started
idv_mail_only_warning_visited
idv_native_camera_forced
idv_not_verified_visited
idv_phone_use_different
idv_request_letter_visited
idv_sdk_selfie_image_capture_closed_without_photo
idv_sdk_selfie_image_capture_failed
idv_sdk_selfie_image_capture_opened
idv_selfie_image_added
idv_session_error_visited
idv_threatmetrix_response_body
idv_socure_reason_code_download
idv_socure_shadow_mode_proofing_result
idv_socure_shadow_mode_proofing_result_missing
idv_socure_verification_data_requested
idv_usps_auth_token_refresh_job_completed
idv_usps_auth_token_refresh_job_network_error
idv_usps_auth_token_refresh_job_started
idv_verify_by_mail_enter_code_submitted
idv_verify_by_mail_enter_code_visited
idv_verify_in_person_troubleshooting_option_clicked
idv_warning_action_triggered
idv_warning_shown
].to_set.freeze
].freeze

IGNORED_METHODS = [
*EXCLUDED_FRONTEND_EVENT_METHODS,
*EXCLUDED_JOB_EVENT_METHODS,
].uniq.freeze
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A/N: Using a Set causes some unexpected behaviors when doing collection comparisons as it behaves more like a Hash than an Array. Switched to using uniq since the const is immutable anyway.


STANDARD_ARGUMENTS = %i[
proofing_components
Expand All @@ -120,7 +87,7 @@ module AnalyticsEventsEnhancer
idv_final
idv_please_call_visited
idv_start_over
].to_set.freeze
].freeze

def self.included(_mod)
raise 'this mixin is intended to be prepended, not included'
Expand Down
4 changes: 4 additions & 0 deletions lib/analytics_events_documenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class AnalyticsEventsDocumenter

DOCUMENTATION_OPTIONAL_PARAMS = %w[
pii_like_keypaths
active_profile_idv_level
pending_profile_idv_level
proofing_components
profile_history
].freeze

attr_reader :database_path, :class_name
Expand Down
26 changes: 26 additions & 0 deletions spec/services/idv/analytics_events_enhancer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,30 @@ def track_event(_event, **kwargs)
end
end
end

describe 'valid configuration' do
let(:explicitly_ignored_methods) do
described_class.const_get(:IGNORED_METHODS).sort
end
let(:explicitly_enhanced_methods) do
described_class.const_get(:METHODS_WITH_PROFILE_HISTORY).sort
end
let(:explicitly_referenced_methods) do
[*explicitly_ignored_methods, *explicitly_enhanced_methods].sort
end
let(:idv_event_methods) do
AnalyticsEvents.instance_methods(false).
filter { |n| n.start_with?('idv_') }.
sort
end

it 'only references known AnalyticsEvents methods' do
found_methods = (idv_event_methods & explicitly_referenced_methods).sort
expect(found_methods).to eq(explicitly_referenced_methods)
end

it 'does not both ignore and enhance the same method' do
expect(explicitly_ignored_methods).to_not include(*explicitly_enhanced_methods)
end
end
end