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(support): capture event when support ticket submission fails (#73101)

Luke Beltona7dd167cbb08
diff --git a/frontend/src/lib/components/Support/supportLogic.ts b/frontend/src/lib/components/Support/supportLogic.ts
index b633a46824db..1e11fa024006 100644
--- a/frontend/src/lib/components/Support/supportLogic.ts
+++ b/frontend/src/lib/components/Support/supportLogic.ts
@@ -845,6 +845,14 @@ export const supportLogic = kea<supportLogicType>([
// The request may have reached the server even though the response failed, so
// don't fall back to Zendesk here — that could file the ticket twice
posthog.captureException(e)
+ posthog.capture('support ticket send failed', {
+ channel: 'conversations',
+ error: e instanceof Error ? e.message : String(e),
+ kind,
+ target_area,
+ message_length: message?.length,
+ current_url_length: window.location.href.length,
+ })
lemonToast.error("Oops, the message couldn't be sent. Please try again in a moment.", {
hideButton: true,
})
@@ -1058,6 +1066,15 @@ export const supportLogic = kea<supportLogicType>([
...extra,
...contexts,
})
+ posthog.capture('support ticket send failed', {
+ channel: 'zendesk',
+ error: error.message,
+ status_code: response.status,
+ kind,
+ target_area,
+ message_length: message?.length,
+ current_url_length: window.location.href.length,
+ })
lemonToast.error(
`Oops, the message couldn't be sent. Please change your browser's privacy level to the standard or default level, then try again. (E.g. In Firefox: Settings > Privacy & Security > Standard)`,
{ hideButton: true }
@@ -1089,6 +1106,14 @@ export const supportLogic = kea<supportLogicType>([
actions.resetSendSupportRequest()
} catch (e) {
posthog.captureException(e)
+ posthog.capture('support ticket send failed', {
+ channel: 'zendesk',
+ error: e instanceof Error ? e.message : String(e),
+ kind,
+ target_area,
+ message_length: message?.length,
+ current_url_length: window.location.href.length,
+ })
// More helpful error message
// Use the same error message regardless of browser
diff --git a/products/conversations/backend/api/widget.py b/products/conversations/backend/api/widget.py
index f15816b64f91..b84e4eb8f862 100644
--- a/products/conversations/backend/api/widget.py
+++ b/products/conversations/backend/api/widget.py
@@ -110,6 +110,34 @@ class WidgetMessageView(APIView):
serializer = WidgetMessageSerializer(data=request.data)
if not serializer.is_valid():
logger.warning("Validation error in WidgetMessageView", extra={"errors": serializer.errors})
+ try:
+ # Track rejected submissions server-side so they're queryable even when the
+ # client-side event is blocked (ad blockers, network drops). Field names and
+ # value lengths only — never message content. An over-long auto-captured
+ # session_context value (e.g. current_url) is a known rejection cause.
+ # This endpoint is public and unauthenticated, so session_context is
+ # attacker-controlled: bound both the number of fields and the key length we
+ # record so a request stuffed with many keys can't inflate the event payload.
+ raw_session_context = request.data.get("session_context")
+ session_context_field_count = len(raw_session_context) if isinstance(raw_session_context, dict) else 0
+ session_context_field_lengths = {}
+ if isinstance(raw_session_context, dict):
+ for key, value in list(raw_session_context.items())[:20]:
+ if isinstance(key, str) and isinstance(value, str):
+ session_context_field_lengths[key[:100]] = len(value)
+ report_team_action(
+ team,
+ "support ticket send failed",
+ {
+ "channel_source": "widget",
+ "reason": "validation_error",
+ "error_fields": sorted(serializer.errors.keys()),
+ "session_context_field_count": session_context_field_count,
+ "session_context_field_lengths": session_context_field_lengths,
+ },
+ )
+ except Exception as e:
+ capture_exception(e)
return Response(
{"error": "Invalid request data", "details": serializer.errors}, status=status.HTTP_400_BAD_REQUEST
)
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
index 2ece602c7122..96fe3a32d394 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
@@ -461,9 +461,21 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
actions.loadMessages(response.ticket_id)
lemonToast.success('Message sent!')
onSuccess()
+ } else {
+ // A null response means nothing was sent, so surface it instead of silently
+ // resetting. Server-rejected sends are captured server-side (widget endpoint),
+ // so we only warn the user here rather than emitting a duplicate failure event.
+ lemonToast.error('Failed to send message. Please try again.')
}
} catch (e) {
console.error('Failed to send message:', e)
+ posthog.capture('support ticket send failed', {
+ channel: 'conversations',
+ error: e instanceof Error ? e.message : String(e),
+ message_length: content.length,
+ current_url_length: window.location.href.length,
+ is_new_ticket: values.view === 'new',
+ })
lemonToast.error('Failed to send message. Please try again.')
} finally {
actions.setMessageSending(false)