mirror of
https://github.com/simple-login/app.git
synced 2024-11-18 09:50:38 +01:00
46 lines
1 KiB
Python
46 lines
1 KiB
Python
import newrelic.agent
|
|
|
|
from app.models import EnumE
|
|
|
|
|
|
class LoginEvent:
|
|
class ActionType(EnumE):
|
|
success = 0
|
|
failed = 1
|
|
disabled_login = 2
|
|
not_activated = 3
|
|
|
|
class Source(EnumE):
|
|
web = 0
|
|
api = 1
|
|
|
|
def __init__(self, action: ActionType, source: Source = Source.web):
|
|
self.action = action
|
|
self.source = source
|
|
|
|
def send(self):
|
|
newrelic.agent.record_custom_event(
|
|
"LoginEvent", {"action": self.action.name, "source": self.source.name}
|
|
)
|
|
|
|
|
|
class RegisterEvent:
|
|
class ActionType(EnumE):
|
|
success = 0
|
|
failed = 1
|
|
catpcha_failed = 2
|
|
email_in_use = 3
|
|
invalid_email = 4
|
|
|
|
class Source(EnumE):
|
|
web = 0
|
|
api = 1
|
|
|
|
def __init__(self, action: ActionType, source: Source = Source.web):
|
|
self.action = action
|
|
self.source = source
|
|
|
|
def send(self):
|
|
newrelic.agent.record_custom_event(
|
|
"RegisterEvent", {"action": self.action.name, "source": self.source.name}
|
|
)
|