mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-22 08:38:13 +02:00
Merge branch 'main' into feat/audio_recording_in_tool_calls
This commit is contained in:
commit
5efcccf204
24 changed files with 450 additions and 93 deletions
|
|
@ -60,6 +60,7 @@ async def signup(request: SignupRequest):
|
|||
email=user.email,
|
||||
name=request.name,
|
||||
organization_id=organization.id,
|
||||
provider_id=user.provider_id,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -84,6 +85,7 @@ async def login(request: LoginRequest):
|
|||
id=user.id,
|
||||
email=user.email,
|
||||
organization_id=user.selected_organization_id,
|
||||
provider_id=user.provider_id,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -94,4 +96,5 @@ async def get_current_user(user: UserModel = Depends(get_user)):
|
|||
id=user.id,
|
||||
email=user.email,
|
||||
organization_id=user.selected_organization_id,
|
||||
provider_id=user.provider_id,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from pydantic import BaseModel
|
|||
from api.constants import DEFAULT_CAMPAIGN_RETRY_CONFIG, DEFAULT_ORG_CONCURRENCY_LIMIT
|
||||
from api.db import db_client
|
||||
from api.db.models import UserModel
|
||||
from api.enums import OrganizationConfigurationKey
|
||||
from api.enums import OrganizationConfigurationKey, PostHogEvent
|
||||
from api.schemas.telephony_config import (
|
||||
ARIConfigurationRequest,
|
||||
ARIConfigurationResponse,
|
||||
|
|
@ -24,6 +24,7 @@ from api.schemas.telephony_config import (
|
|||
)
|
||||
from api.services.auth.depends import get_user
|
||||
from api.services.configuration.masking import is_mask_of, mask_key
|
||||
from api.services.posthog_client import capture_event
|
||||
from api.services.worker_sync.manager import get_worker_sync_manager
|
||||
from api.services.worker_sync.protocol import WorkerSyncEventType
|
||||
|
||||
|
|
@ -257,6 +258,16 @@ async def save_telephony_configuration(
|
|||
config_value,
|
||||
)
|
||||
|
||||
capture_event(
|
||||
distinct_id=str(user.provider_id),
|
||||
event=PostHogEvent.TELEPHONY_CONFIGURED,
|
||||
properties={
|
||||
"provider": request.provider,
|
||||
"phone_number_count": len(request.from_numbers),
|
||||
"organization_id": user.selected_organization_id,
|
||||
},
|
||||
)
|
||||
|
||||
return {"message": "Telephony configuration saved successfully"}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ from pydantic import BaseModel, Field, field_validator
|
|||
|
||||
from api.db import db_client
|
||||
from api.db.models import UserModel
|
||||
from api.enums import ToolCategory, ToolStatus
|
||||
from api.enums import PostHogEvent, ToolCategory, ToolStatus
|
||||
from api.services.auth.depends import get_user
|
||||
from api.services.posthog_client import capture_event
|
||||
|
||||
router = APIRouter(prefix="/tools")
|
||||
|
||||
|
|
@ -342,6 +343,16 @@ async def create_tool(
|
|||
icon_color=request.icon_color,
|
||||
)
|
||||
|
||||
capture_event(
|
||||
distinct_id=str(user.provider_id),
|
||||
event=PostHogEvent.TOOL_CREATED,
|
||||
properties={
|
||||
"tool_name": request.name,
|
||||
"tool_category": request.category,
|
||||
"organization_id": user.selected_organization_id,
|
||||
},
|
||||
)
|
||||
|
||||
return build_tool_response(tool)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,12 @@ class SignalingManager:
|
|||
# Start pipeline in background
|
||||
asyncio.create_task(
|
||||
run_pipeline_smallwebrtc(
|
||||
pc, workflow_id, workflow_run_id, user.id, call_context_vars
|
||||
pc,
|
||||
workflow_id,
|
||||
workflow_run_id,
|
||||
user.id,
|
||||
call_context_vars,
|
||||
user_provider_id=str(user.provider_id),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from api.constants import DEPLOYMENT_MODE
|
|||
from api.db import db_client
|
||||
from api.db.models import UserModel
|
||||
from api.db.workflow_template_client import WorkflowTemplateClient
|
||||
from api.enums import CallType, StorageBackend
|
||||
from api.enums import CallType, PostHogEvent, StorageBackend
|
||||
from api.schemas.workflow import WorkflowRunResponseSchema
|
||||
from api.services.auth.depends import get_user
|
||||
from api.services.configuration.check_validity import UserConfigurationValidator
|
||||
|
|
@ -23,6 +23,7 @@ from api.services.configuration.masking import (
|
|||
)
|
||||
from api.services.configuration.resolve import resolve_effective_config
|
||||
from api.services.mps_service_key_client import mps_service_key_client
|
||||
from api.services.posthog_client import capture_event
|
||||
from api.services.storage import storage_fs
|
||||
from api.services.workflow.dto import ReactFlowDTO
|
||||
from api.services.workflow.duplicate import duplicate_workflow
|
||||
|
|
@ -287,6 +288,17 @@ async def create_workflow(
|
|||
user.selected_organization_id,
|
||||
)
|
||||
|
||||
capture_event(
|
||||
distinct_id=str(user.provider_id),
|
||||
event=PostHogEvent.WORKFLOW_CREATED,
|
||||
properties={
|
||||
"workflow_id": workflow.id,
|
||||
"workflow_name": workflow.name,
|
||||
"source": "direct",
|
||||
"organization_id": user.selected_organization_id,
|
||||
},
|
||||
)
|
||||
|
||||
# Sync agent triggers if workflow definition contains any
|
||||
if request.workflow_definition:
|
||||
trigger_paths = extract_trigger_paths(request.workflow_definition)
|
||||
|
|
@ -365,6 +377,19 @@ async def create_workflow_from_template(
|
|||
organization_id=user.selected_organization_id,
|
||||
)
|
||||
|
||||
capture_event(
|
||||
distinct_id=str(user.provider_id),
|
||||
event=PostHogEvent.WORKFLOW_CREATED,
|
||||
properties={
|
||||
"workflow_id": workflow.id,
|
||||
"workflow_name": workflow.name,
|
||||
"source": "template",
|
||||
"call_type": request.call_type,
|
||||
"use_case": request.use_case,
|
||||
"organization_id": user.selected_organization_id,
|
||||
},
|
||||
)
|
||||
|
||||
# Sync agent triggers if workflow definition contains any
|
||||
if workflow_def:
|
||||
trigger_paths = extract_trigger_paths(workflow_def)
|
||||
|
|
@ -569,6 +594,16 @@ async def publish_workflow(
|
|||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
capture_event(
|
||||
distinct_id=str(user.provider_id),
|
||||
event=PostHogEvent.WORKFLOW_PUBLISHED,
|
||||
properties={
|
||||
"workflow_id": workflow_id,
|
||||
"version_number": published.version_number,
|
||||
"organization_id": user.selected_organization_id,
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
"id": published.id,
|
||||
"version_number": published.version_number,
|
||||
|
|
@ -787,6 +822,18 @@ async def duplicate_workflow_endpoint(
|
|||
organization_id=user.selected_organization_id,
|
||||
user_id=user.id,
|
||||
)
|
||||
|
||||
capture_event(
|
||||
distinct_id=str(user.provider_id),
|
||||
event=PostHogEvent.WORKFLOW_DUPLICATED,
|
||||
properties={
|
||||
"workflow_id": workflow.id,
|
||||
"workflow_name": workflow.name,
|
||||
"source_workflow_id": workflow_id,
|
||||
"organization_id": user.selected_organization_id,
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
"id": workflow.id,
|
||||
"name": workflow.name,
|
||||
|
|
|
|||
|
|
@ -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