mirror of
https://github.com/suitenumerique/docs.git
synced 2026-09-11 12:17:55 +02:00
📈(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:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user