:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from typing import Any
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from posthog.models.user import User
from products.customer_analytics.backend.facade.enums import AccountViewVisibility
from products.customer_analytics.backend.models.account_view import AccountView
@receiver(pre_delete, sender=User)
def delete_private_account_views_for_deleted_user(
sender: type[User], instance: User, using: str, **kwargs: Any
) -> None:
AccountView.objects.unscoped().filter(
created_by_id=instance.id,
visibility=AccountViewVisibility.PRIVATE,
).delete()