-
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
Feat: analytics for in-person eligibility/enrollment #2402
Conversation
802972c
to
579aeda
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
16fe317
to
abd62bb
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.
This is really good so far.
@@ -30,6 +32,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.started_eligibility(request, flow, enrollment_method=models.EnrollmentMethods.IN_PERSON) |
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.
I would think we also want to send the selected enrollment flow
event here, right? For consistency with the digital
side.
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.
Yep, good idea. Added it in 1595941
benefits/in_person/views.py
Outdated
sentry_sdk.capture_exception(exception) | ||
return redirect(routes.IN_PERSON_SERVER_ERROR) | ||
|
||
case Status.REENROLLMENT_ERROR: | ||
return redirect(routes.IN_PERSON_ENROLLMENT_REENROLLMENT_ERROR) | ||
# GET enrollment index | ||
else: | ||
flow = session.flow(request) | ||
eligibility_analytics.returned_success(request, flow, enrollment_method=models.EnrollmentMethods.IN_PERSON) |
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.
I think in general, we should move away from sending events in response to GET
requests where possible.
It becomes easier to spam the events if all you need to do is visit the URL. Especially for these types of events where we do already have a POST
-back, I think ideally the event should be sent there.
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.
Ah that makes sense! Moved it to the POST
section in e9f5ead
benefits/in_person/views.py
Outdated
@@ -137,6 +155,7 @@ def enrollment(request): | |||
|
|||
def reenrollment_error(request): | |||
"""View handler for a re-enrollment attempt that is not yet within the re-enrollment window.""" | |||
enrollment_analytics.returned_error(request, "Re-enrollment error.", enrollment_method=models.EnrollmentMethods.IN_PERSON) |
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.
Could be moved up into POST
-back
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.
Yep, moved it up in f5a376a
benefits/in_person/views.py
Outdated
@@ -147,6 +166,7 @@ def reenrollment_error(request): | |||
|
|||
def retry(request): | |||
"""View handler for card verification failure.""" | |||
enrollment_analytics.returned_retry(request, enrollment_method=models.EnrollmentMethods.IN_PERSON) |
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 can't be moved since the user is sent here from JavaScript.
Would could enforce that this route is POST
-only and make the from POST
back to here... that doesn't have to happen in this PR though.
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.
Right 👍
So it turns out that the form's (form_retry
) method is already POST
, so would it be enough to wrap the analytics call in an if request.method == "POST":
?
abd62bb
to
1595941
Compare
60b1401
to
0ca7d95
Compare
Closes #2245
This PR implements in-person analytics events for
started eligibility
returned eligibility
selected enrollment flow
started card tokenization
ended card tokenization
returned enrollment
failed access token request
Since the
started card tokenization
andended card tokenization
events use the Amplitude browser SDK (instead of the HTTP API used byClient
incore/analytics.py
), theenrollment
views andindex.html
template have been updated in aef5527 to include theenrollment_method
field.