* chore: posthog event for workspace invite * chore: updated event names, added all the existing events to workspace metrics group * chore: seperated workspace invite * fix: workspace invite accept event updated --------- Co-authored-by: Ramesh Kumar Chandra <rameshkumar2299@gmail.com>
50 lines
No EOL
1.5 KiB
Python
50 lines
No EOL
1.5 KiB
Python
import uuid
|
|
|
|
from posthog import Posthog
|
|
from django.conf import settings
|
|
|
|
#third party imports
|
|
from celery import shared_task
|
|
from sentry_sdk import capture_exception
|
|
|
|
|
|
@shared_task
|
|
def auth_events(user, email, user_agent, ip, event_name, medium, first_time):
|
|
try:
|
|
posthog = Posthog(settings.POSTHOG_API_KEY, host=settings.POSTHOG_HOST)
|
|
posthog.capture(
|
|
email,
|
|
event=event_name,
|
|
properties={
|
|
"event_id": uuid.uuid4().hex,
|
|
"user": {"email": email, "id": str(user)},
|
|
"device_ctx": {
|
|
"ip": ip,
|
|
"user_agent": user_agent,
|
|
},
|
|
"medium": medium,
|
|
"first_time": first_time
|
|
}
|
|
)
|
|
except Exception as e:
|
|
capture_exception(e)
|
|
|
|
@shared_task
|
|
def workspace_invite_event(user, email, user_agent, ip, event_name, accepted_from):
|
|
try:
|
|
posthog = Posthog(settings.POSTHOG_API_KEY, host=settings.POSTHOG_HOST)
|
|
posthog.capture(
|
|
email,
|
|
event=event_name,
|
|
properties={
|
|
"event_id": uuid.uuid4().hex,
|
|
"user": {"email": email, "id": str(user)},
|
|
"device_ctx": {
|
|
"ip": ip,
|
|
"user_agent": user_agent,
|
|
},
|
|
"accepted_from": accepted_from
|
|
}
|
|
)
|
|
except Exception as e:
|
|
capture_exception(e) |