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

Refactor: analytics for EnrollmentFlow #2379

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

thekaveman
Copy link
Member

@thekaveman thekaveman commented Sep 19, 2024

Part of #2248, update new events that are sent.

  • Renames event/user property eligibility_types to enrollment_flows
  • Renames event selected eligibility verifier to selected enrollment flow
  • Updates the value sent for event/user property eligibility_verifier to the same logic as from Model and capture local enrollment events #2267

@thekaveman thekaveman self-assigned this Sep 19, 2024
@thekaveman thekaveman added this to the Admin tool: agency users milestone Sep 19, 2024
@github-actions github-actions bot added deployment-dev [auto] Changes that will trigger a deploy if merged to dev back-end Django views, sessions, middleware, models, migrations etc. tests Related to automated testing (unit, UI, integration, etc.) documentation [auto] Improvements or additions to documentation and removed tests Related to automated testing (unit, UI, integration, etc.) labels Sep 19, 2024
Copy link

github-actions bot commented Sep 19, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  benefits/core
  analytics.py
  models.py
  benefits/eligibility
  analytics.py 21, 43, 53, 58
  views.py
  benefits/enrollment
  views.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link

@thekaveman thekaveman marked this pull request as ready for review September 19, 2024 21:49
@thekaveman thekaveman requested a review from a team as a code owner September 19, 2024 21:49
@thekaveman thekaveman force-pushed the refactor/analytics-enrollmentflow branch 2 times, most recently from b3d0be1 to bf2632a Compare September 19, 2024 22:30
Copy link
Member

@angela-tran angela-tran left a 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.


def __init__(self, request, eligibility_types):
super().__init__(request, "selected eligibility verifier", eligibility_types)
def __init__(self, request, enrollment_flows):
Copy link
Member

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.



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):
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above



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):
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above

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)
Copy link
Member

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



def selected_verifier(request, eligibility_types):
def selected_verifier(request, enrollment_flows):
Copy link
Member

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



def started_eligibility(request, eligibility_types):
def started_eligibility(request, enrollment_flows):
Copy link
Member

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



def returned_error(request, eligibility_types, error):
def returned_error(request, enrollment_flows, error):
Copy link
Member

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



def returned_fail(request, eligibility_types):
def returned_fail(request, enrollment_flows):
Copy link
Member

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



def returned_success(request, eligibility_types):
def returned_success(request, enrollment_flows):
Copy link
Member

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

@thekaveman thekaveman force-pushed the refactor/analytics-enrollmentflow branch from e3de3c5 to 455b011 Compare September 21, 2024 00:23
hide the usage of flow.system_name from callers, this is an
implementation detail of the analytics code
@thekaveman thekaveman force-pushed the refactor/analytics-enrollmentflow branch from 455b011 to b7d9993 Compare September 21, 2024 00:58
@thekaveman
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev documentation [auto] Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants