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-12657: Make Idv::AnalyticsEventsEnhancer opt-out #10230

Closed

Conversation

matthinz
Copy link
Member

@matthinz matthinz commented Mar 11, 2024

🎫 Ticket

Link to the relevant ticket:
LG-12657

🛠 Summary of changes

In working on #10216, I realized that the list of events that Idv::AnalyticsEventsEnhancer enhances has gotten a little stale. Specifically, we haven't been adding new events to it.

This PR:

  • Updates Idv::AnalyticsEventsEnhancer to "enhance" any method that starts with idv_ (note that this is the method name, not the event name, so old-style "IdV:" and new-style "idv_" events will be covered).
  • Allows "opting out" of enhancement for specific events.
  • Adds linter support for verifying "enhanced" method arguments are correctly passed to track_event

Initially, the list of "opted out" methods just includes any frontend events that were not previously "opted in". The net change of this PR is that all idv_* events logged by the backend will now have proofing_components added to them (this will be expanded to additional new properties in subsequent PRs).

📜 Testing Plan

Provide a checklist of steps to confirm the changes.

  • Go through identity verification
  • Verify that certain events like IdV: doc auth verify submitted now have proofing_components

@matthinz matthinz requested a review from a team March 11, 2024 21:53
@matthinz matthinz marked this pull request as draft March 12, 2024 21:45
kwrest = method.arguments.find { |a| a.kwrestarg_type? }
return if !kwrest

corrector.insert_before(kwrest, "#{arg_name}: nil, ")
Copy link
Contributor

Choose a reason for hiding this comment

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

omg major props, I don't think we have any other of our lints autocorrect

lib/linters/enhanced_idv_events_linter.rb Outdated Show resolved Hide resolved
@@ -624,7 +624,7 @@ def idv_acuant_sdk_loaded(
success:,
use_alternate_sdk:,
liveness_checking_required:,
**_extra
**extra
Copy link
Member Author

Choose a reason for hiding this comment

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

There were a few methods that accepted **extra but didn't pass it on to track_event. I've updated those to pass data properly.

module RuboCop
module Cop
module IdentityIdp
class EnhancedIdvEventsLinter < RuboCop::Cop::Base
Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly, here be dragons. But analytics_events.rb is long enough that automating large edits to it was worth the trouble.

line.is_a?(Parser::Source::Comment) && /@param/.match?(line.text)
end

comment = "# @param [Object] #{arg_name} TODO: Write doc comment"
Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted this autocorrect (adding doc comment) in place so I could get all the missing @param declarations in analytics_events.rb but would be happy to remove it if we want potentially avoid ending up with a mess of autogenerated "TODO" comments in the future

Copy link
Member Author

Choose a reason for hiding this comment

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

(if say, a developer had a git precommit hook that automatically ran rubocop -a and committed the results)

idv_please_call_visited
idv_start_over
].freeze
IGNORED_METHODS = %i[
Copy link
Member Author

Choose a reason for hiding this comment

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

Right now this list is just any frontend events that were not previously "opted in". Hopefully big changes to this list can come in as separate PRs.

It could be argued that many events before document_capture don't benefit from having proofing_components added automatically. However:

  • We have much better back button support than we did when this events enhancer was first written, so proofing_components could have data
  • I'm planning on using this events enhancer to add more properties in the future that would be relevant for those earlier events

@matthinz matthinz force-pushed the matthinz/12657-update-analytics-events-enchanter branch 3 times, most recently from 6e0d041 to ea9f2c1 Compare March 18, 2024 18:03
Update AnalyticsEventsEnhancer so that it augments any event where the _method name_ starts with `^idv_` UNLESS it has been told not to.

changelog: Internal, Analytics, Add additional data to IdV analytics events by default.
@matthinz matthinz force-pushed the matthinz/12657-update-analytics-events-enchanter branch from ea9f2c1 to 22d6978 Compare March 18, 2024 18:11
…nalyticsEvents

Check each method on AnalyticsEvents that is "enhanced" by AnalyticsEventsEnhancer:

1. Includes the enhancements in its args list
2. Passes those to track_event
Look for "@param" documentation for e.g. proofing_components.

Autocorrect to a "TODO"
@matthinz matthinz force-pushed the matthinz/12657-update-analytics-events-enchanter branch from 22d6978 to 88e00c8 Compare March 18, 2024 18:40
@matthinz
Copy link
Member Author

Closing for now -- going to try and get this in as a few smaller PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants