Skip to content

Commit

Permalink
feat: add a posthog capture event when a proxy record is created (#26585
Browse files Browse the repository at this point in the history
)
  • Loading branch information
surbhi-posthog authored Dec 3, 2024
1 parent 4548c55 commit 7d03c37
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions posthog/api/proxy_record.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import asyncio
import hashlib
import posthoganalytics
from django.conf import settings
from rest_framework import serializers, status
from rest_framework.viewsets import ModelViewSet

from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.constants import GENERAL_PURPOSE_TASK_QUEUE
from posthog.event_usage import groups
from posthog.models import ProxyRecord
from posthog.models.organization import Organization
from posthog.permissions import OrganizationAdminWritePermissions
from posthog.temporal.common.client import sync_connect
from posthog.temporal.proxy_service import CreateManagedProxyInputs, DeleteManagedProxyInputs
Expand Down Expand Up @@ -76,6 +79,17 @@ def create(self, request, *args, **kwargs):
)

serializer = self.get_serializer(record)
organization = Organization.objects.get(id=record.organization_id)
posthoganalytics.capture(
request.user.distinct_id,
"managed reverse proxy created",
properties={
"proxy_record_id": record.id,
"domain": record.domain,
"target_cname": record.target_cname,
},
groups=groups(organization),
)
return Response(serializer.data)

def destroy(self, request, *args, pk=None, **kwargs):
Expand Down

0 comments on commit 7d03c37

Please sign in to comment.