Skip to content

: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.

fix(conversations): record workflow replies that have no user (#130926)

Alex V433f6a1aea09
diff --git a/products/conversations/backend/api/tests/test_signals.py b/products/conversations/backend/api/tests/test_signals.py
index a36a1f9c4833..9aca7701e615 100644
--- a/products/conversations/backend/api/tests/test_signals.py
+++ b/products/conversations/backend/api/tests/test_signals.py
@@ -112,10 +112,11 @@ class TestTicketMessageSignals(BaseTest):
assert mock_capture.call_args.kwargs["properties"]["customer_email_verified"] is expected
+ @patch("products.conversations.backend.signals.report_team_action")
@patch("products.conversations.backend.signals.capture_message_received")
@patch("products.conversations.backend.signals.capture_message_sent")
def test_public_workflow_message_counts_without_emitting_a_trigger_event(
- self, mock_sent, mock_received, mock_on_commit
+ self, mock_sent, mock_received, mock_report_team, mock_on_commit
):
Comment.objects.create(
team=self.team,
@@ -131,6 +132,11 @@ class TestTicketMessageSignals(BaseTest):
assert self.ticket.unread_customer_count == 1
mock_sent.assert_not_called()
mock_received.assert_not_called()
+ mock_report_team.assert_called_once_with(
+ self.team,
+ "support message sent",
+ {"channel_source": self.ticket.channel_source},
+ )
def test_team_message_updates_stats_and_unread(self, mock_on_commit):
comment = self._create_team_message("Response from team")
diff --git a/products/conversations/backend/signals.py b/products/conversations/backend/signals.py
index 1da8304dcf17..d4276ac2526e 100644
--- a/products/conversations/backend/signals.py
+++ b/products/conversations/backend/signals.py
@@ -222,12 +222,13 @@ def update_ticket_on_message(sender, instance: Comment, created: bool, **kwargs)
except Exception as e:
capture_exception(e, {"ticket_id": item_id})
- # Customer-facing analytics (to customer's project)
+ # Customer-facing analytics (to customer's project). A workflow reply is a team
+ # message with no User, so author stays unset and the team-level report below still runs.
+ author = None
if is_team_message and author_type != WORKFLOW_AUTHOR_TYPE:
author = User.objects.filter(id=created_by_id).first() if created_by_id else None
capture_message_sent(ticket, comment_id, content or "", author=author)
elif not is_team_message:
- author = None
capture_message_received(
ticket,
comment_id,