🔧(backend) make PostHog event names configurable for transcript tracking

Add setting to customize PostHog event names when tracking transcript
results for flexible analytics configuration.
This commit is contained in:
lebaudantoine
2025-07-10 15:06:35 +02:00
committed by aleb_the_flash
parent cbabcb877b
commit 93e3f05348
2 changed files with 4 additions and 2 deletions

View File

@@ -148,7 +148,7 @@ def task_retry_handler(request=None, reason=None, einfo=None, **kwargs):
@signals.task_failure.connect
def task_failure_handler(task_id, exception=None, **kwargs):
"""Signal handler called when task execution fails permanently."""
tasks_tracker.capture(task_id, "task_failed")
tasks_tracker.capture(task_id, settings.posthog_event_failure)
@celery.task(max_retries=settings.celery_max_retries)
@@ -329,6 +329,6 @@ def process_audio_transcribe_summarize_v2(
logger.info("Webhook submitted successfully. Status: %s", response.status_code)
logger.debug("Response body: %s", response.text)
tasks_tracker.capture(task_id, "task_succeeded")
tasks_tracker.capture(task_id, settings.posthog_event_success)
# TODO - integrate summarize the transcript and create a new document.

View File

@@ -53,6 +53,8 @@ class Settings(BaseSettings):
posthog_enabled: bool = False
posthog_api_key: Optional[str] = None
posthog_api_host: Optional[str] = "https://eu.i.posthog.com"
posthog_event_failure: str = "transcript-failure"
posthog_event_success: str = "transcript-success"
# TaskTracker
task_tracker_redis_url: str = "redis://redis/0"