feat: add posthog events (#231)

* feat: add posthog events

* fix: workflow_duplicated event

* chore: add events to enum
This commit is contained in:
Sabiha Khan 2026-04-10 17:52:21 +05:30 committed by GitHub
parent bb5f56bfb7
commit 3f19a16e7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 450 additions and 93 deletions

View file

@ -7,6 +7,7 @@ from fastapi import APIRouter, Depends, HTTPException, Query
from loguru import logger
from api.db import db_client
from api.enums import PostHogEvent
from api.schemas.knowledge_base import (
ChunkSearchRequestSchema,
ChunkSearchResponseSchema,
@ -17,6 +18,7 @@ from api.schemas.knowledge_base import (
ProcessDocumentRequestSchema,
)
from api.services.auth.depends import get_user
from api.services.posthog_client import capture_event
from api.services.storage import storage_fs
from api.tasks.arq import enqueue_job
from api.tasks.function_names import FunctionNames
@ -142,6 +144,18 @@ async def process_document(
f"with OpenAI embeddings, org {user.selected_organization_id}"
)
capture_event(
distinct_id=str(user.provider_id),
event=PostHogEvent.KNOWLEDGE_BASE_CREATED,
properties={
"document_id": document.id,
"document_uuid": str(request.document_uuid),
"filename": filename,
"retrieval_mode": request.retrieval_mode,
"organization_id": user.selected_organization_id,
},
)
return DocumentResponseSchema(
id=document.id,
document_uuid=request.document_uuid,