: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
chore(conversations): declare the response schemas the frontend reads (#104381)
Julian Bezcd19465ec5c5
diff --git a/products/conversations/backend/api/tickets.py b/products/conversations/backend/api/tickets.pyindex 73214c62208a..6e324afa3dbd 100644--- a/products/conversations/backend/api/tickets.py+++ b/products/conversations/backend/api/tickets.py@@ -346,10 +346,33 @@ class TicketPersonSerializer(serializers.Serializer):return get_person_name(team, person)+# An open map: the widget sends whatever it captured, and the sanitiser bounds the size and the+# value types rather than the key set. The two keys the ticket scene reads are named so a client+# knows they are the ones to expect, and `additionalProperties` keeps the rest honest.+_TICKET_SESSION_CONTEXT_SCHEMA = {+ "type": "object",+ "description": (+ "Context captured with the ticket. Values are strings, numbers or booleans. Keys are whatever "+ "the widget sent, commonly current_url, replay_url, browser, os and sdk_version."+ ),+ "additionalProperties": True,+ "properties": {+ "current_url": {"type": "string", "description": "Page the reporter was on."},+ "replay_url": {"type": "string", "description": "Replay of the session the ticket came from."},+ },+}+++@extend_schema_field(_TICKET_SESSION_CONTEXT_SCHEMA)+class TicketSessionContextField(serializers.JSONField):+ pass++class TicketSerializer(UserAccessControlSerializerMixin, TaggedItemSerializerMixin, serializers.ModelSerializer):assignee = TicketAssignmentSerializer(source="assignment", read_only=True)person = TicketPersonSerializer(read_only=True, allow_null=True)email_to = serializers.SerializerMethodField()+ session_context = TicketSessionContextField(read_only=True)class Meta:model = Ticketdiff --git a/products/conversations/frontend/generated/api.schemas.ts b/products/conversations/frontend/generated/api.schemas.tsindex 3c58b96531d9..717a6b6be136 100644--- a/products/conversations/frontend/generated/api.schemas.ts+++ b/products/conversations/frontend/generated/api.schemas.ts@@ -155,6 +155,17 @@ export interface TicketPersonApi {readonly is_identified: boolean}+/**+ * Context captured with the ticket. Values are strings, numbers or booleans. Keys are whatever the widget sent, commonly current_url, replay_url, browser, os and sdk_version.+ */+export type TicketApiSessionContext = {+ /** Page the reporter was on. */+ readonly current_url?: string+ /** Replay of the session the ticket came from. */+ readonly replay_url?: string+ [key: string]: unknown+}+/*** Mixin for serializers to add user access control fields*/@@ -203,7 +214,8 @@ export interface TicketApi {readonly unread_customer_count: number/** @nullable */readonly session_id: string | null- readonly session_context: unknown+ /** Context captured with the ticket. Values are strings, numbers or booleans. Keys are whatever the widget sent, commonly current_url, replay_url, browser, os and sdk_version. */+ readonly session_context: TicketApiSessionContext/*** SLA deadline set via workflows. Null means no SLA.* @nullablediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 6d947db7cf39..464271dd1f77 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -66720,6 +66720,17 @@ export namespace Schemas {readonly is_identified: boolean;}+ /**+ * Context captured with the ticket. Values are strings, numbers or booleans. Keys are whatever the widget sent, commonly current_url, replay_url, browser, os and sdk_version.+ */+ export type TicketSessionContext = {+ /** Page the reporter was on. */+ readonly current_url?: string;+ /** Replay of the session the ticket came from. */+ readonly replay_url?: string;+ [key: string]: unknown;+ };+/*** Mixin for serializers to add user access control fields*/@@ -66768,7 +66779,8 @@ export namespace Schemas {readonly unread_customer_count: number;/** @nullable */readonly session_id: string | null;- readonly session_context: unknown;+ /** Context captured with the ticket. Values are strings, numbers or booleans. Keys are whatever the widget sent, commonly current_url, replay_url, browser, os and sdk_version. */+ readonly session_context: TicketSessionContext;/*** SLA deadline set via workflows. Null means no SLA.* @nullable