Skip to content

Commit

Permalink
feat: Flush on celery posthog capture (#25308)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Oct 2, 2024
1 parent efdc026 commit b33cad6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions posthog/tasks/plugin_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional
from celery import shared_task
from django.conf import settings
import posthoganalytics

from posthog.event_usage import report_team_action
from posthog.tasks.email import send_hog_function_disabled, send_fatal_plugin_error
Expand Down Expand Up @@ -42,5 +43,8 @@ def hog_function_state_transition(hog_function_id: str, state: int) -> None:
},
)

# TRICKY: It seems like without this call the events don't get flushed, possibly due to celery worker threads exiting...
posthoganalytics.flush()

if state >= 2: # 2 and 3 are disabled
send_hog_function_disabled.delay(hog_function_id)

0 comments on commit b33cad6

Please sign in to comment.