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.

feat(conversations): add customer identity to ticket lifecycle events (#67457)

Abigail6304db9fde79
diff --git a/products/conversations/backend/api/tests/test_events.py b/products/conversations/backend/api/tests/test_events.py
index 8075a5a846b6..38006cb51add 100644
--- a/products/conversations/backend/api/tests/test_events.py
+++ b/products/conversations/backend/api/tests/test_events.py
@@ -69,6 +69,11 @@ class TestConversationEvents(BaseTest):
assert call_kwargs["properties"]["actor_type"] == "user"
assert call_kwargs["properties"]["actor_id"] == self.user.id
assert call_kwargs["properties"]["actor_email"] == self.user.email
+ # Customer identity travels alongside the actor so workflows can email the customer,
+ # not the team member the event's distinct_id is attributed to.
+ assert call_kwargs["properties"]["customer_name"] == "Test Customer"
+ assert call_kwargs["properties"]["customer_email"] == "[email protected]"
+ assert call_kwargs["properties"]["customer_distinct_id"] == self.ticket.distinct_id
@patch("products.conversations.backend.events.capture_internal")
def test_capture_ticket_priority_changed_uses_team_token(self, mock_capture):
@@ -85,6 +90,8 @@ class TestConversationEvents(BaseTest):
assert call_kwargs["properties"]["actor_type"] == "user"
assert call_kwargs["properties"]["actor_id"] == self.user.id
assert call_kwargs["properties"]["actor_email"] == self.user.email
+ assert call_kwargs["properties"]["customer_email"] == "[email protected]"
+ assert call_kwargs["properties"]["customer_distinct_id"] == self.ticket.distinct_id
@patch("products.conversations.backend.events.capture_internal")
def test_capture_ticket_assigned_uses_team_token(self, mock_capture):
@@ -101,6 +108,8 @@ class TestConversationEvents(BaseTest):
assert call_kwargs["properties"]["actor_type"] == "user"
assert call_kwargs["properties"]["actor_id"] == self.user.id
assert call_kwargs["properties"]["actor_email"] == self.user.email
+ assert call_kwargs["properties"]["customer_email"] == "[email protected]"
+ assert call_kwargs["properties"]["customer_distinct_id"] == self.ticket.distinct_id
@patch("products.conversations.backend.events.capture_internal")
def test_capture_message_sent_uses_team_token(self, mock_capture):
@@ -127,6 +136,9 @@ class TestConversationEvents(BaseTest):
("capture_ticket_created", capture_ticket_created, []),
("capture_message_received", capture_message_received, ["msg-id", "content"]),
("capture_message_sent", capture_message_sent, ["msg-id", "content"]),
+ ("capture_ticket_status_changed", capture_ticket_status_changed, ["new", "pending"]),
+ ("capture_ticket_priority_changed", capture_ticket_priority_changed, [None, "high"]),
+ ("capture_ticket_assigned", capture_ticket_assigned, ["user", "123"]),
]
)
@patch("products.conversations.backend.events.capture_internal")
diff --git a/products/conversations/backend/events.py b/products/conversations/backend/events.py
index 6f32a4b3fce3..a25a6501f355 100644
--- a/products/conversations/backend/events.py
+++ b/products/conversations/backend/events.py
@@ -280,6 +280,7 @@ def capture_ticket_status_changed(
properties["old_status"] = old_status
properties["new_status"] = new_status
properties.update(_get_actor_properties(actor, actor_type))
+ properties.update(_get_customer_properties(ticket, include_distinct_id=True))
capture_internal(
token=ticket.team.api_token,
@@ -302,6 +303,7 @@ def capture_ticket_priority_changed(
properties["old_priority"] = old_priority
properties["new_priority"] = new_priority
properties.update(_get_actor_properties(actor, actor_type))
+ properties.update(_get_customer_properties(ticket, include_distinct_id=True))
capture_internal(
token=ticket.team.api_token,
@@ -324,6 +326,7 @@ def capture_ticket_assigned(
properties["assignee_type"] = assignee_type
properties["assignee_id"] = assignee_id
properties.update(_get_actor_properties(actor, actor_type))
+ properties.update(_get_customer_properties(ticket, include_distinct_id=True))
capture_internal(
token=ticket.team.api_token,