: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
feat: send notificaions from all channels (#58839)
Alex V36eff79f8901
diff --git a/products/conversations/backend/api/widget.py b/products/conversations/backend/api/widget.pyindex a374c4879888..1e68a7cd263e 100644--- a/products/conversations/backend/api/widget.py+++ b/products/conversations/backend/api/widget.py@@ -29,7 +29,6 @@ from posthog.exceptions_capture import capture_exceptionfrom posthog.models import Teamfrom posthog.models.comment import Commentfrom posthog.rate_limit import WidgetTeamThrottle, WidgetUserBurstThrottle-from posthog.tasks.email import send_new_ticket_notificationfrom products.conversations.backend.api.serializers import (WidgetMarkReadSerializer,@@ -228,16 +227,6 @@ class WidgetMessageView(APIView):# explicit invalidation here since the signal doesn't cover it.invalidate_unread_count_cache(team.id)- # Send email notification for new tickets- if not ticket_id:- conversations_settings = team.conversations_settings or {}- if conversations_settings.get("notification_recipients"):- send_new_ticket_notification.delay(- ticket_id=str(ticket.id),- team_id=team.id,- first_message_content=message_content,- )-return Response({"ticket_id": str(ticket.id),diff --git a/products/conversations/backend/signals.py b/products/conversations/backend/signals.pyindex f13669bca008..75aa3c54c3b5 100644--- a/products/conversations/backend/signals.py+++ b/products/conversations/backend/signals.py@@ -12,6 +12,7 @@ from posthog.event_usage import report_team_action, report_user_actionfrom posthog.exceptions_capture import capture_exceptionfrom posthog.models import Userfrom posthog.models.comment import Comment+from posthog.tasks.email import send_new_ticket_notificationfrom .cache import invalidate_messages_cache, invalidate_tickets_cachefrom .events import capture_message_received, capture_message_sent, capture_ticket_created@@ -136,6 +137,18 @@ def update_ticket_on_message(sender, instance: Comment, created: bool, **kwargs)report_user_action(user, "support message sent", props, team=ticket.team)else:report_team_action(ticket.team, "support message received", props)+ # Send email notification on first customer message (i.e. new ticket)+ if ticket.message_count == 1 and not is_team_message:+ try:+ conversations_settings = ticket.team.conversations_settings or {}+ if conversations_settings.get("notification_recipients"):+ send_new_ticket_notification.delay(+ ticket_id=item_id,+ team_id=team_id,+ first_message_content=(content or "")[:500],+ )+ except Exception as e:+ capture_exception(e, {"ticket_id": item_id})except Ticket.DoesNotExist:passexcept Exception as e: