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

When a new comment is created, we capture an event related to this comment
creation.
This commit is contained in:
Manuel Raynaud
2026-06-01 17:47:28 +02:00
parent ba1a1d469e
commit 0df2d753c4
3 changed files with 39 additions and 9 deletions
+8 -1
View File
@@ -3206,7 +3206,14 @@ class CommentViewSet(
def perform_create(self, serializer):
"""Attach the request user as the comment author."""
user = self.request.user if self.request.user.is_authenticated else None
serializer.save(user=user)
comment = serializer.save(user=user)
posthog_capture(
PosthogEventName.COMMENT_CREATED,
user,
{"comment_id": str(comment.id), "thread_id": str(comment.thread_id)},
document=self.get_document_or_404(),
)
@drf.decorators.action(
detail=True,