Skip to content

Commit

Permalink
feat: adding capture for when event verification is toggled (#26740)
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhi-posthog authored Dec 9, 2024
1 parent 4d7fd19 commit 8c9fb01
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ee/api/ee_event_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
)

from loginas.utils import is_impersonated_session
from typing import cast
import posthoganalytics
from posthog.event_usage import groups
from posthog.models import User


class EnterpriseEventDefinitionSerializer(TaggedItemSerializerMixin, serializers.ModelSerializer):
Expand Down Expand Up @@ -104,6 +108,23 @@ def update(self, event_definition: EnterpriseEventDefinition, validated_data):
detail=Detail(name=str(event_definition.name), changes=changes),
)

verified_old = event_definition.verified
verified_new = validated_data.get("verified", verified_old)

# If verified status has changed, track it
if "verified" in validated_data and verified_old != verified_new:
user = cast(User, self.context["request"].user)
posthoganalytics.capture(
str(user.distinct_id),
"event verification toggled",
properties={
"verified": verified_new,
"event_name": event_definition.name,
"is_custom_event": not event_definition.name.startswith("$"),
},
groups=groups(user.organization),
)

return super().update(event_definition, validated_data)

def to_representation(self, instance):
Expand Down

0 comments on commit 8c9fb01

Please sign in to comment.