📈(backend) capture an event when a thread is created

When a new thread is created, we capture an event related to this thread
creation.
This commit is contained in:
Manuel Raynaud
2026-06-01 17:47:27 +02:00
parent ab1708f6df
commit ba1a1d469e
3 changed files with 64 additions and 19 deletions
+10 -1
View File
@@ -3136,12 +3136,21 @@ class ThreadViewSet(
del serializer.validated_data["body"]
thread = serializer.save()
user = self.request.user if self.request.user.is_authenticated else None
models.Comment.objects.create(
thread=thread,
user=self.request.user if self.request.user.is_authenticated else None,
user=user,
body=body,
)
posthog_capture(
PosthogEventName.THREAD_CREATED,
user,
{"thread_id": str(thread.id)},
document=self.get_document_or_404(),
)
@drf.decorators.action(detail=True, methods=["post"], url_path="resolve")
def resolve(self, request, *args, **kwargs):
"""Resolve a thread."""