Skip to content

Commit

Permalink
feat(analytics): add optional error_code event property
Browse files Browse the repository at this point in the history
  • Loading branch information
lalver1 committed May 29, 2024
1 parent 25da735 commit 3420fbb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions benefits/oauth/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ def __init__(self, request):
class FinishedSignInEvent(OAuthEvent):
"""Analytics event representing the end of the OAuth sign in flow."""

def __init__(self, request):
def __init__(self, request, error=None):
super().__init__(request, "finished sign in")
if error is not None:
self.update_event_properties(error_code=error)


class StartedSignOutEvent(OAuthEvent):
Expand Down Expand Up @@ -61,9 +63,12 @@ def canceled_sign_in(request):
core.send_event(CanceledSignInEvent(request))


def finished_sign_in(request):
def finished_sign_in(request, error=None):
"""Send the "finished sign in" analytics event."""
core.send_event(FinishedSignInEvent(request))
if error is not None:
core.send_event(FinishedSignInEvent(request, error))
else:
core.send_event(FinishedSignInEvent(request))


def started_sign_out(request):
Expand Down

0 comments on commit 3420fbb

Please sign in to comment.