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

Merged
merged 7 commits into from
Dec 18, 2024
Merged

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

merged 7 commits into from
Dec 18, 2024

Conversation

lmgeorge
Copy link
Contributor

@lmgeorge lmgeorge commented Dec 3, 2024

Why

  • When Idv::AnalyticsEventEnhancer was first introduced it was opt-in, but this no longer makes sense for our current analytics tracking needs.

  • While a better long-term strategy would be to eliminate the event enhancer, this should be addressed in future work given its complexity.

How

  • Broke up the IGNORED_METHODS constant into 3 buckets: 1) frontend events and 2) events solely used in jobs. Anything that doesn't fall neatly in either category should just be put in the IGNORED_METHODS constant and those additions should be minimal.

  • Added specs to ensure that the list of event methods referenced don't get out of sync with AnalyticsEvents and that there is no overlap between ignored and explicitly opted-in methods.

Non-Goals

  • Adding new tests to validate event coverage in spec/features/idv/analytics_spec.rb
  • Eliminating the event enhancer metaprogramming approach
  • Eliminating unused events

changelog: Internal, IdV Analytics, Make IdV event enhancement opt-out

🎫 Ticket

Link to the relevant ticket:
LG-14064

📜 Testing Plan

Minimal testing needed as no functionality is changing.

@lmgeorge lmgeorge added status - ready for review ruby Pull requests that update Ruby code area - analytics labels Dec 3, 2024
@lmgeorge lmgeorge requested review from aduth and a team December 3, 2024 23:46
@lmgeorge lmgeorge self-assigned this Dec 3, 2024
*EXCLUDED_FRONTEND_EVENT_METHODS,
*EXCLUDED_JOB_EVENT_METHODS,
*EXCLUDED_MISC_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.

@@ -120,7 +99,7 @@ module AnalyticsEventsEnhancer
idv_final
idv_please_call_visited
idv_start_over
].to_set.freeze
].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. (This uniq call is superfluous as the list is so short, but keeping it here for consistency in behavior.)

#
# Additionally, +profile_history+, the list of a User's profiles
# (sorted by creaton date, oldest to newest), may be added to events, but this is opt-in only.
# See {AnalyticsEventsEnhancer::METHODS_WITH_PROFILE_HISTORY} for the list of included events.
Copy link
Member

Choose a reason for hiding this comment

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

Yay comments ❤️

Copy link
Member

@n1zyy n1zyy left a comment

Choose a reason for hiding this comment

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

I'm going to approve this because it successfully implements what's asked in the story and is well-written.

I think it would be neat to do what Matt suggested in a comment and look for the presence of an IDV session, but the last day of the sprint is probably a bad time to completely rewrite your PR. 👼 Might be a neat followup later?

Tests appear to have gone off the rails (pun semi-intended) for reasons unrelated to your code.

app/services/idv/analytics_events_enhancer.rb Outdated Show resolved Hide resolved
Comment on lines +78 to +81
DOCUMENTATION_OPTIONAL_PARAMS = [
:user_id,
*AnalyticsEventsDocumenter::DOCUMENTATION_OPTIONAL_PARAMS.map(&:to_sym),
].uniq.freeze
Copy link
Contributor Author

@lmgeorge lmgeorge Dec 16, 2024

Choose a reason for hiding this comment

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

A/N: There is a mismatch between how UndocumentedParamsChecker and AnalyticsEventsDocumenter load method definitions for events.

The Idv::AnalyticsEventsEnhancer uses metaprogramming to redefine the method signature of some events to add additional data to the event. As these parameters are not defined on the original method declaration in analytics_events.rb, there is no good way to document these runtime parameters since AnalyticsEventsDocumenter does not use the same runtime method definitions that Analytics and FakeAnalytics define.

It is beyond the scope of this PR to fully fix these behavioral discrepancies, so this is a workaround until a better solution is found.

**Why**

* When Idv::AnalyticsEventEnhancer was first introduced it was opt-in,
  but this no longer makes sense for our current analytics tracking
  needs.

* While a better long-term strategy would be to eliminate the event
  enhancer, this should be addressed in future work given its complexity.

**How**

* Broke up the IGNORED_METHODS constant into 3 buckets:
    1) frontend events
    2) events solely used in jobs
    3) a miscellaneous bucket
  These contexts may not have access to the proofing session info. For
  the miscellaneous bucket, additions should be minimal.

* Added specs to ensure that the list of event methods referenced don't
  get out of sync with AnalyticsEvents and that there is no overlap
  between ignored and explicitly opted-in methods.

changelog: Internal, IdV Analytics, Make IdV event enhancement opt-out
…al params to be like AnalyticsEventsDocumenter
@lmgeorge lmgeorge merged commit 842401c into main Dec 18, 2024
2 checks passed
@lmgeorge lmgeorge deleted the lmgeorge/LG-14064 branch December 18, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area - analytics ruby Pull requests that update Ruby code status - ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants