🐛(summary) fix feature flag on summary job

Sadly, we used user db id as the posthog distinct id
of identified user, and not the sub.

Before this commit, we were only passing sub to the
summary microservice.

Add the owner's id. Please note we introduce a different
naming behavir, by prefixing the id with "owner". We didn't
for the sub and the email.

We cannot align sub and email with this new naming approach,
because external contributors have already started building
their own microservice.
This commit is contained in:
Martin Guitteny
2025-09-19 14:13:39 +02:00
committed by aleb_the_flash
parent 9cb9998384
commit c3eb877377
3 changed files with 5 additions and 2 deletions

View File

@@ -131,8 +131,8 @@ class NotificationService:
if not owner_access:
logger.error("No owner found for recording %s", recording.id)
return False
payload = {
"owner_id": str(owner_access.user.id),
"filename": recording.key,
"email": owner_access.user.email,
"sub": owner_access.user.sub,

View File

@@ -18,6 +18,7 @@ settings = get_settings()
class TaskCreation(BaseModel):
"""Task data."""
owner_id: str
filename: str
email: str
sub: str
@@ -35,6 +36,7 @@ async def create_task(request: TaskCreation):
"""Create a task."""
task = process_audio_transcribe_summarize_v2.apply_async(
args=[
request.owner_id,
request.filename,
request.email,
request.sub,

View File

@@ -204,6 +204,7 @@ def task_failure_handler(task_id, exception=None, **kwargs):
)
def process_audio_transcribe_summarize_v2(
self,
owner_id: str,
filename: str,
email: str,
sub: str,
@@ -320,7 +321,7 @@ def process_audio_transcribe_summarize_v2(
metadata_manager.capture(task_id, settings.posthog_event_success)
if (
analytics.is_feature_enabled("summary-enabled", distinct_id=sub)
analytics.is_feature_enabled("summary-enabled", distinct_id=owner_id)
and settings.is_summary_enabled
):
logger.info("Queuing summary generation task.")