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.

chore(conversations): type the ticket unread count response (#104251)

Julian Bezc44868d129d8
diff --git a/products/conversations/backend/api/tickets.py b/products/conversations/backend/api/tickets.py
index 53a8bb234516..12a591273c80 100644
--- a/products/conversations/backend/api/tickets.py
+++ b/products/conversations/backend/api/tickets.py
@@ -550,6 +550,12 @@ class TicketUpdateRequestSerializer(TaggedItemSerializerMixin, serializers.Model
return super().update(instance, validated_data)
+class TicketUnreadCountResponseSerializer(serializers.Serializer):
+ count = serializers.IntegerField(
+ min_value=0, help_text="Unread messages across the non-resolved tickets the caller can see."
+ )
+
+
TICKET_ID_PARAM = OpenApiParameter(
name="id",
type=OpenApiTypes.STR,
@@ -1295,6 +1301,10 @@ class TicketViewSet(TaggedItemViewSetMixin, TeamAndOrgViewSetMixin, AccessContro
return Response({"updated": len(changed), "ids": [str(t.id) for t, _ in changed]})
+ @extend_schema(
+ summary="Count unread tickets",
+ responses={200: TicketUnreadCountResponseSerializer},
+ )
@action(detail=False, methods=["get"])
def unread_count(self, request, *args, **kwargs):
"""
diff --git a/products/conversations/frontend/generated/api.schemas.ts b/products/conversations/frontend/generated/api.schemas.ts
index 519be5018cc3..3c58b96531d9 100644
--- a/products/conversations/frontend/generated/api.schemas.ts
+++ b/products/conversations/frontend/generated/api.schemas.ts
@@ -635,6 +635,14 @@ export interface ComposeTicketResponseApi {
ticket_number: number
}
+export interface TicketUnreadCountResponseApi {
+ /**
+ * Unread messages across the non-resolved tickets the caller can see.
+ * @minimum 0
+ */
+ count: number
+}
+
/**
* * `widget` - widget
* * `email` - email
diff --git a/products/conversations/frontend/generated/api.ts b/products/conversations/frontend/generated/api.ts
index 55fc4f9e0bc1..48e3f7989aab 100644
--- a/products/conversations/frontend/generated/api.ts
+++ b/products/conversations/frontend/generated/api.ts
@@ -32,6 +32,7 @@ import type {
TicketFullEmailApi,
TicketMessageApi,
TicketReplyRequestApi,
+ TicketUnreadCountResponseApi,
TicketUpdateRequestApi,
TicketViewApi,
ZendeskImportJobApi,
@@ -468,12 +469,13 @@ export const getConversationsTicketsUnreadCountRetrieveUrl = (projectId: string)
* callers without object-level ticket restrictions, since it holds one unscoped total
* per team - serving it to a restricted member would leak counts for tickets they can't
* see.
+ * @summary Count unread tickets
*/
export const conversationsTicketsUnreadCountRetrieve = async (
projectId: string,
options?: RequestInit
-): Promise<TicketApi> => {
- return apiMutator<TicketApi>(getConversationsTicketsUnreadCountRetrieveUrl(projectId), {
+): Promise<TicketUnreadCountResponseApi> => {
+ return apiMutator<TicketUnreadCountResponseApi>(getConversationsTicketsUnreadCountRetrieveUrl(projectId), {
...options,
method: 'GET',
})
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index cc51ac11b318..2045207ded72 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -95770,6 +95770,14 @@ export namespace Schemas {
rich_content?: unknown;
}
+ export interface TicketUnreadCountResponse {
+ /**
+ * Unread messages across the non-resolved tickets the caller can see.
+ * @minimum 0
+ */
+ count: number;
+ }
+
/**
* Fields accepted when updating a ticket.
*/