Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding capture for when event verification is toggled #26740

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading