: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
fix(conversations): offer email fallback on too-long support error (#93825)
posthog[bot]378718ebb9b9
diff --git a/frontend/src/lib/components/Support/supportLogic.test.ts b/frontend/src/lib/components/Support/supportLogic.test.tsindex bfda7b667b70..05c6e28372ec 100644--- a/frontend/src/lib/components/Support/supportLogic.test.ts+++ b/frontend/src/lib/components/Support/supportLogic.test.ts@@ -2,6 +2,8 @@ import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import posthog from 'posthog-js'+import { EMAIL_SUPPORT_BUTTON, lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'+import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'import { initKeaTests } from '~/test/init'import { AppContext, SidePanelTab } from '~/types'@@ -11,6 +13,7 @@ import {SUPPORT_MESSAGE_PREVIEW_MAX_LENGTH,SupportFormFields,supportLogic,+ warnIfMessageTooLong,} from './supportLogic'import * as SupportModal from './SupportModal'@@ -417,4 +420,18 @@ describe('supportLogic', () => {expect(sendFailures()[0][1]).toMatchObject({ reason: 'invalid_email' })})})++ describe('warnIfMessageTooLong', () => {+ it('offers the email fallback on the too-long toast, like the other send-failure paths', () => {+ const errorToast = jest.spyOn(lemonToast, 'error').mockReturnValue('' as never)++ const blocked = warnIfMessageTooLong('a'.repeat(CONVERSATIONS_MESSAGE_MAX_LENGTH + 1))++ expect(blocked).toBe(true)+ expect(errorToast).toHaveBeenCalledTimes(1)+ expect(errorToast.mock.calls[0][1]).toMatchObject({ button: EMAIL_SUPPORT_BUTTON })++ errorToast.mockRestore()+ })+ })})diff --git a/frontend/src/lib/components/Support/supportLogic.ts b/frontend/src/lib/components/Support/supportLogic.tsindex 04a2b4a3fe46..dace0d1b1c57 100644--- a/frontend/src/lib/components/Support/supportLogic.ts+++ b/frontend/src/lib/components/Support/supportLogic.ts@@ -155,11 +155,14 @@ export function captureSupportWidgetLoadFailed({}// Returns true when the message exceeds the cap the widget endpoint enforces, so callers can bail-// before the network. Callers report it: the customer pressed send and has no ticket.+// before the network. Callers report it: the customer pressed send and has no ticket. The toast+// offers the email fallback like the other send-failure paths, because a customer stuck at the cap+// otherwise has no way to find the support address.export function warnIfMessageTooLong(message: string): boolean {if (message.length > CONVERSATIONS_MESSAGE_MAX_LENGTH) {lemonToast.error(- `Your message is too long (max ${CONVERSATIONS_MESSAGE_MAX_LENGTH.toLocaleString()} characters). Please shorten it or send it in multiple messages.`+ `Your message is too long (max ${CONVERSATIONS_MESSAGE_MAX_LENGTH.toLocaleString()} characters). Please shorten it or send it in multiple messages.`,+ { button: EMAIL_SUPPORT_BUTTON })return true}