feat: add posthog signup and signin events, enable backend posthog events for oss version (#249)

This commit is contained in:
Sabiha Khan 2026-04-24 12:02:52 +05:30 committed by GitHub
parent 9298116887
commit f7c1f63e1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 82 additions and 35 deletions

View file

@ -3,8 +3,10 @@ from loguru import logger
from api.db import db_client
from api.db.models import UserModel
from api.enums import PostHogEvent
from api.schemas.auth import AuthResponse, LoginRequest, SignupRequest, UserResponse
from api.services.auth.depends import create_user_configuration_with_mps_key, get_user
from api.services.posthog_client import capture_event
from api.utils.auth import create_jwt_token, hash_password, verify_password
router = APIRouter(
@ -53,6 +55,15 @@ async def signup(request: SignupRequest):
# Create JWT token
token = create_jwt_token(user.id, request.email)
capture_event(
distinct_id=str(user.provider_id),
event=PostHogEvent.SIGNED_UP,
properties={
"organization_id": organization.id,
"auth_provider": "local",
},
)
return AuthResponse(
token=token,
user=UserResponse(
@ -79,6 +90,15 @@ async def login(request: LoginRequest):
# Create JWT token
token = create_jwt_token(user.id, user.email)
capture_event(
distinct_id=str(user.provider_id),
event=PostHogEvent.SIGNED_IN,
properties={
"organization_id": user.selected_organization_id,
"auth_provider": "local",
},
)
return AuthResponse(
token=token,
user=UserResponse(