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): only toast a failed tickets load on support surfaces (#126145)

Thomas Obermüller70a56795dbba
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
index d00a98272d7b..5e20651c12a9 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
@@ -449,6 +449,38 @@ describe('sidepanelTicketsLogic', () => {
errorToast.mockRestore()
})
+ // The unread badge keeps this logic polling on every page, so a failed background fetch must
+ // not toast over unrelated work. It is still captured so the failure rate stays visible.
+ it.each([
+ ['toasts on the support panel', true, 1],
+ ['stays quiet outside support surfaces', false, 0],
+ ])('when fetching tickets fails, %s', async (_case, onSupportPanel, expectedToasts) => {
+ const errorToast = jest.spyOn(lemonToast, 'error').mockReturnValue('' as never)
+ jest.spyOn(console, 'error').mockImplementation(() => {})
+ if (onSupportPanel) {
+ sidePanelStateLogic.mount()
+ sidePanelStateLogic.actions.openSidePanel(SidePanelTab.Support)
+ }
+ logic = sidepanelTicketsLogic.build()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ ;(posthog as any).conversations.getTickets = jest.fn().mockRejectedValue(new Error('429'))
+ ;(posthog.capture as jest.Mock).mockClear()
+
+ await expectLogic(logic, () => {
+ logic.actions.loadTickets()
+ }).toFinishAllListeners()
+
+ const loadFailures = (posthog.capture as jest.Mock).mock.calls.filter(
+ ([event]) => event === 'support widget load failed'
+ )
+ expect(loadFailures).toHaveLength(1)
+ expect(errorToast).toHaveBeenCalledTimes(expectedToasts)
+ errorToast.mockRestore()
+ ;(console.error as jest.Mock).mockRestore()
+ })
+
it('reports a missing widget instead of silently dropping the composed message', async () => {
logic = sidepanelTicketsLogic.build()
logic.mount()
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
index 809e7452f15f..6b7b6c1765f3 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
@@ -652,7 +652,11 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
error: e,
can_create_ticket: values.canCreateTicket,
})
- lemonToast.error('Failed to load tickets.')
+ // The background poll for the unread badge runs on every page, so a transient
+ // failure there would toast on surfaces that have nothing to do with support
+ if (isOnSupportSurface(values.sidePanelOpen, values.selectedTab)) {
+ lemonToast.error('Failed to load tickets.')
+ }
} finally {
actions.setTicketsLoading(false)
}