mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-22 08:38:13 +02:00
feat: add posthog events (#231)
* feat: add posthog events * fix: workflow_duplicated event * chore: add events to enum
This commit is contained in:
parent
bb5f56bfb7
commit
3f19a16e7f
24 changed files with 450 additions and 93 deletions
|
|
@ -9,7 +9,9 @@ from pydantic import BaseModel
|
|||
from api.constants import BACKEND_API_ENDPOINT, ENVIRONMENT, UI_APP_URL
|
||||
from api.db import db_client
|
||||
from api.db.models import EmbedTokenModel, UserModel
|
||||
from api.enums import PostHogEvent
|
||||
from api.services.auth.depends import get_user
|
||||
from api.services.posthog_client import capture_event
|
||||
|
||||
router = APIRouter(prefix="/workflow")
|
||||
|
||||
|
|
@ -103,6 +105,17 @@ async def create_or_update_embed_token(
|
|||
expires_at=expires_at,
|
||||
)
|
||||
|
||||
capture_event(
|
||||
distinct_id=str(user.provider_id),
|
||||
event=PostHogEvent.AGENT_EMBEDDED,
|
||||
properties={
|
||||
"workflow_id": workflow_id,
|
||||
"is_new_token": len(existing_tokens) == 0,
|
||||
"has_domain_restriction": bool(embed_request.allowed_domains),
|
||||
"organization_id": user.selected_organization_id,
|
||||
},
|
||||
)
|
||||
|
||||
# Generate embed script
|
||||
embed_script = generate_embed_script(token)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue