From ed779fa1ec98bc1638ba8d96bbce61037445b4f9 Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 24 Sep 2024 22:35:33 +0000 Subject: [PATCH 1/3] refactor(analytics): update claims_provider property name update some variable naming as well --- benefits/oauth/analytics.py | 6 +++--- tests/pytest/oauth/test_analytics.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/benefits/oauth/analytics.py b/benefits/oauth/analytics.py index 23e9564152..54e4aea4da 100644 --- a/benefits/oauth/analytics.py +++ b/benefits/oauth/analytics.py @@ -10,9 +10,9 @@ class OAuthEvent(core.Event): def __init__(self, request, event_type): super().__init__(request, event_type) - verifier = session.flow(request) - if verifier and verifier.uses_claims_verification: - self.update_event_properties(auth_provider=verifier.claims_provider.client_name) + flow = session.flow(request) + if flow and flow.uses_claims_verification: + self.update_event_properties(claims_provider=flow.claims_provider.client_name) class OAuthErrorEvent(OAuthEvent): diff --git a/tests/pytest/oauth/test_analytics.py b/tests/pytest/oauth/test_analytics.py index d571b92f60..e6e094fd9d 100644 --- a/tests/pytest/oauth/test_analytics.py +++ b/tests/pytest/oauth/test_analytics.py @@ -10,8 +10,8 @@ def test_OAuthEvent_flow_client_name_when_uses_claims_verification(app_request, event = OAuthEvent(app_request, "event type") - assert "auth_provider" in event.event_properties - assert event.event_properties["auth_provider"] == mocked_flow.claims_provider.client_name + assert "claims_provider" in event.event_properties + assert event.event_properties["claims_provider"] == mocked_flow.claims_provider.client_name @pytest.mark.django_db @@ -19,7 +19,7 @@ def test_OAuthEvent_flow_client_name_when_uses_claims_verification(app_request, def test_OAuthEvent_flow_no_client_name_when_does_not_use_claims_verification(app_request): event = OAuthEvent(app_request, "event type") - assert "auth_provider" not in event.event_properties + assert "claims_provider" not in event.event_properties @pytest.mark.django_db From c35f6d4d6fe217af7bdaf20542ed60c2eb21594c Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 24 Sep 2024 22:41:20 +0000 Subject: [PATCH 2/3] chore(analytics): missed rename Verifier -> Flow --- benefits/eligibility/analytics.py | 8 ++++---- benefits/eligibility/views.py | 2 +- benefits/in_person/views.py | 2 +- docs/development/application-logic.md | 2 +- tests/pytest/eligibility/test_views.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/benefits/eligibility/analytics.py b/benefits/eligibility/analytics.py index 9cb62efad4..5011432073 100644 --- a/benefits/eligibility/analytics.py +++ b/benefits/eligibility/analytics.py @@ -14,7 +14,7 @@ def __init__(self, request, event_type, flow: models.EnrollmentFlow, enrollment_ self.update_enrollment_flows(flow) -class SelectedVerifierEvent(EligibilityEvent): +class SelectedFlowEvent(EligibilityEvent): """Analytics event representing the user selecting an enrollment flow.""" def __init__(self, request, flow: models.EnrollmentFlow, enrollment_method=models.EnrollmentMethods.DIGITAL): @@ -40,9 +40,9 @@ def __init__( self.update_event_properties(status=status, error=error) -def selected_verifier(request, flow: models.EnrollmentFlow, enrollment_method: str = models.EnrollmentMethods.DIGITAL): - """Send the "selected eligibility verifier" analytics event.""" - core.send_event(SelectedVerifierEvent(request, flow, enrollment_method=enrollment_method)) +def selected_flow(request, flow: models.EnrollmentFlow, enrollment_method: str = models.EnrollmentMethods.DIGITAL): + """Send the "selected enrollment flow" analytics event.""" + core.send_event(SelectedFlowEvent(request, flow, enrollment_method=enrollment_method)) def started_eligibility(request, flow: models.EnrollmentFlow, enrollment_method: str = models.EnrollmentMethods.DIGITAL): diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py index 8bbb78271a..1b495fa43a 100644 --- a/benefits/eligibility/views.py +++ b/benefits/eligibility/views.py @@ -38,7 +38,7 @@ def index(request): flow = EnrollmentFlow.objects.get(id=flow_id) session.update(request, flow=flow) - analytics.selected_verifier(request, flow) + analytics.selected_flow(request, flow) eligibility_start = reverse(routes.ELIGIBILITY_START) response = redirect(eligibility_start) diff --git a/benefits/in_person/views.py b/benefits/in_person/views.py index a10389e711..57e092a8b9 100644 --- a/benefits/in_person/views.py +++ b/benefits/in_person/views.py @@ -36,7 +36,7 @@ def eligibility(request): flow_id = form.cleaned_data.get("flow") flow = models.EnrollmentFlow.objects.get(id=flow_id) session.update(request, flow=flow) - eligibility_analytics.selected_verifier(request, flow, enrollment_method=models.EnrollmentMethods.IN_PERSON) + eligibility_analytics.selected_flow(request, flow, enrollment_method=models.EnrollmentMethods.IN_PERSON) eligibility_analytics.started_eligibility(request, flow, enrollment_method=models.EnrollmentMethods.IN_PERSON) in_person_enrollment = reverse(routes.IN_PERSON_ENROLLMENT) diff --git a/docs/development/application-logic.md b/docs/development/application-logic.md index bad9010d86..b9bc441fdc 100644 --- a/docs/development/application-logic.md +++ b/docs/development/application-logic.md @@ -120,7 +120,7 @@ flowchart LR agency -. update -.-o session eligibility -. update -.-o session - eligibility -. selected eligibility verifier -.-o analytics + eligibility -. selected enrollment flow -.-o analytics ``` Depending upon the choice of enrollment pathway, the _Next phase_ above may be: diff --git a/tests/pytest/eligibility/test_views.py b/tests/pytest/eligibility/test_views.py index 8aab99a453..fd4329df8c 100644 --- a/tests/pytest/eligibility/test_views.py +++ b/tests/pytest/eligibility/test_views.py @@ -147,7 +147,7 @@ def test_index_post_valid_form(client, model_EnrollmentFlow, mocked_session_upda assert response.status_code == 302 assert response.url == reverse(routes.ELIGIBILITY_START) assert mocked_session_update.call_args.kwargs["flow"] == model_EnrollmentFlow - mocked_analytics_module.selected_verifier.assert_called_once() + mocked_analytics_module.selected_flow.assert_called_once() @pytest.mark.django_db From 5f56d3d11af08e91a0d35b585b3acf17d3b6fdcc Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 24 Sep 2024 22:43:13 +0000 Subject: [PATCH 3/3] docs: correct event naming --- docs/product-and-design/analytics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/product-and-design/analytics.md b/docs/product-and-design/analytics.md index 6be856ebb0..6f4e440cc5 100644 --- a/docs/product-and-design/analytics.md +++ b/docs/product-and-design/analytics.md @@ -77,7 +77,7 @@ Read more on each of these events on the [Amplitude event documentation for Bene ### Eligibility events -These events track the progress of a user choosing an eligibility verifier and completing eligibility verification. +These events track the progress of a user choosing an enrollment flow and completing eligibility verification. - selected enrollment flow - started eligibility @@ -100,5 +100,5 @@ Read more on each of these events on the [Amplitude event documentation for Bene Various key metrics are collected and analyzed, including: - **Number of users who successfully completed authentication**: Users who `started sign in`, `finished sign in` -- **Number of users who successfully verified eligibility**: Users who completed the above and `selected eligibility verifier`, `started eligibility`, `returned eligibility` with a status of `True` +- **Number of users who successfully verified eligibility**: Users who completed the above and `selected enrollment flow`, `started eligibility`, `returned eligibility` with a status of `True` - **Numbers of users who successfully completed enrollment**: Users who completed all of the above and `started card tokenization`, `ended card tokenization` and `returned enrollment` with a status of `Success`