-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refactor: analytics for EnrollmentFlow
#2379
base: main
Are you sure you want to change the base?
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
Preview url: https://benefits-2379--cal-itp-previews.netlify.app |
b3d0be1
to
bf2632a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes look good to me! Just left a suggestion on naming.
benefits/eligibility/analytics.py
Outdated
|
||
def __init__(self, request, eligibility_types): | ||
super().__init__(request, "selected eligibility verifier", eligibility_types) | ||
def __init__(self, request, enrollment_flows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably nitpicky, but I think when reading the code / following the inheritance chain, it would be helpful for this enrollment_flows
parameter to be named flow_name
instead since it goes with the flow_name
parameter on the parent EligibilityEvent
.
It makes it clearer that this is is not a list being passed in.
benefits/eligibility/analytics.py
Outdated
|
||
|
||
class StartedEligibilityEvent(EligibilityEvent): | ||
"""Analytics event representing the beginning of an eligibility verification check.""" | ||
|
||
def __init__(self, request, eligibility_types): | ||
super().__init__(request, "started eligibility", eligibility_types) | ||
def __init__(self, request, enrollment_flows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
benefits/eligibility/analytics.py
Outdated
|
||
|
||
class ReturnedEligibilityEvent(EligibilityEvent): | ||
"""Analytics event representing the end of an eligibility verification check.""" | ||
|
||
def __init__(self, request, eligibility_types, status, error=None): | ||
super().__init__(request, "returned eligibility", eligibility_types) | ||
def __init__(self, request, enrollment_flows, status, error=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
benefits/eligibility/analytics.py
Outdated
status = str(status).lower() | ||
if status in ("error", "fail", "success"): | ||
self.update_event_properties(status=status, error=error) | ||
if status == "success": | ||
self.update_user_properties(eligibility_types=eligibility_types) | ||
self.update_user_properties(enrollment_flows=enrollment_flows) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one would stay the same because it's using the assigned value from line 14
benefits/eligibility/analytics.py
Outdated
|
||
|
||
def selected_verifier(request, eligibility_types): | ||
def selected_verifier(request, enrollment_flows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above about renaming to flow_name
benefits/eligibility/analytics.py
Outdated
|
||
|
||
def started_eligibility(request, eligibility_types): | ||
def started_eligibility(request, enrollment_flows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above about renaming to flow_name
benefits/eligibility/analytics.py
Outdated
|
||
|
||
def returned_error(request, eligibility_types, error): | ||
def returned_error(request, enrollment_flows, error): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above about renaming to flow_name
benefits/eligibility/analytics.py
Outdated
|
||
|
||
def returned_fail(request, eligibility_types): | ||
def returned_fail(request, enrollment_flows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above about renaming to flow_name
benefits/eligibility/analytics.py
Outdated
|
||
|
||
def returned_success(request, eligibility_types): | ||
def returned_success(request, enrollment_flows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above about renaming to flow_name
this is a more accurate value, and matches the internal EnrollmentEvent
e3de3c5
to
455b011
Compare
hide the usage of flow.system_name from callers, this is an implementation detail of the analytics code
455b011
to
b7d9993
Compare
I refactored this in b7d9993, good call! The logic for getting the value for analytics is now in one place, and hidden away from callers. |
Part of #2248, update new events that are sent.
eligibility_types
toenrollment_flows
selected eligibility verifier
toselected enrollment flow
eligibility_verifier
to the same logic as from Model and capture local enrollment events #2267