: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): show existing tickets to free plans (#73498)
Christian Rafferty52462ea41668
diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsxindex 5b331400c613..00cb4efd5979 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx@@ -11,7 +11,6 @@ import { FEATURE_FLAGS } from 'lib/constants'import { dayjs } from 'lib/dayjs'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { billingLogic } from 'scenes/billing/billingLogic'-import { organizationLogic } from 'scenes/organizationLogic'import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'import { urls } from 'scenes/urls'import { userLogic } from 'scenes/userLogic'@@ -20,6 +19,7 @@ import { ProductKey } from '~/queries/schema/schema-general'import { AvailableFeature, BillingFeatureType, BillingPlan, BillingType, SidePanelTab } from '~/types'import { SidePanelTickets } from 'products/conversations/frontend/components/SidePanel/SidePanelTickets'+import { sidepanelTicketsLogic } from 'products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic'import { SidePanelPaneHeader } from '../../components/SidePanelPaneHeader'import { SidePanelContentContainer } from '../../SidePanelContentContainer'@@ -319,24 +319,20 @@ export function SidePanelSupport(): JSX.Element {const { closeEmailForm, openEmailForm, closeSupportForm, resetSendSupportRequest } = useActions(supportLogic)const { openSidePanel } = useActions(sidePanelStateLogic)const { billing, billingLoading, billingPlan } = useValues(billingLogic)- const { isCurrentOrganizationNew } = useValues(organizationLogic)+ const { tickets, canCreateTicket } = useValues(sidepanelTicketsLogic)const useProductSupportSidePanel = featureFlags[FEATURE_FLAGS.PRODUCT_SUPPORT_SIDE_PANEL]- const hasBoostTrial = billing?.trial?.status === 'active' && billing.trial?.target === 'boost'- const hasScaleTrial = billing?.trial?.status === 'active' && billing.trial?.target === 'scale'- const hasEnterpriseTrial = billing?.trial?.status === 'active' && billing.trial?.target === 'enterprise'- const hasActiveTrial = hasBoostTrial || hasScaleTrial || hasEnterpriseTrial-- const canEmail =- billing?.subscription_level === 'paid' ||- billing?.subscription_level === 'custom' ||- hasActiveTrial ||- targetArea === 'billing' ||- isCurrentOrganizationNew- const showEmailSupport = (preflight?.cloud || process.env.NODE_ENV === 'development') && canEmail- const showMaxAI = preflight?.cloud || process.env.NODE_ENV === 'development'+ // With the side panel on, a billing CTA grants an exemption that `canCreateTicket` already carries.+ // The `targetArea` arm is for the classic Zendesk form, which never reaches that listener.+ const canEmail = canCreateTicket || targetArea === 'billing'+ const isCloudOrDev = preflight?.cloud || process.env.NODE_ENV === 'development'+ const showEmailSupport = isCloudOrDev && canEmail+ const showMaxAI = isCloudOrDevconst isBillingLoaded = !billingLoading && billing !== undefined+ // Free plans can't open new tickets, but tickets they already have (billing questions, PostHog AI+ // bug reports) stay readable and repliable here+ const showTickets = isCloudOrDev && useProductSupportSidePanel && (canCreateTicket || tickets.length > 0)const handleOpenEmailForm = (): void => {if (showEmailSupport && isBillingLoaded) {@@ -385,13 +381,14 @@ export function SidePanelSupport(): JSX.Element {</Section>)}- {showEmailSupport && isBillingLoaded && useProductSupportSidePanel && (- <Section title="Contact us">+ {showTickets && isBillingLoaded && (+ <Section title={canCreateTicket ? 'Contact us' : 'Your tickets'}><StatusPageAlert /><SupportMessageOverride /><p>- Can't find what you need and PostHog AI unable to help? Message our support- engineers.+ {canCreateTicket+ ? "Can't find what you need and PostHog AI unable to help? Message our support engineers."+ : 'You can keep replying to tickets you already have open.'}</p><SidePanelTickets /></Section>diff --git a/products/conversations/frontend/components/SidePanel/TicketsList.tsx b/products/conversations/frontend/components/SidePanel/TicketsList.tsxindex 534df20eaeaa..90363400a414 100644--- a/products/conversations/frontend/components/SidePanel/TicketsList.tsx+++ b/products/conversations/frontend/components/SidePanel/TicketsList.tsx@@ -12,7 +12,7 @@ import type { ConversationTicket } from '../../types'import { sidepanelTicketsLogic } from './sidepanelTicketsLogic'export function TicketsList(): JSX.Element {- const { tickets, ticketsLoading } = useValues(sidepanelTicketsLogic)+ const { tickets, ticketsLoading, canCreateTicket } = useValues(sidepanelTicketsLogic)const { setCurrentTicket, setView } = useActions(sidepanelTicketsLogic)const hasIdentityMode = !!window.JS_POSTHOG_IDENTITY_DISTINCT_ID@@ -35,15 +35,17 @@ export function TicketsList(): JSX.Element {return (<div className="flex flex-col gap-2">- <LemonButton- type="primary"- fullWidth- center- onClick={() => setView('new')}- data-attr="sidebar-create-new-ticket"- >- Create new ticket- </LemonButton>+ {canCreateTicket && (+ <LemonButton+ type="primary"+ fullWidth+ center+ onClick={() => setView('new')}+ data-attr="sidebar-create-new-ticket"+ >+ Create new ticket+ </LemonButton>+ )}{!hasIdentityMode && (<p className="text-center text-xs text-muted-alt m-0">Switched browsers?{' '}@@ -59,7 +61,9 @@ export function TicketsList(): JSX.Element {{tickets.length === 0 ? (<div className="text-center text-muted-alt py-8"><p>No tickets yet.</p>- <p className="text-sm">Create a new ticket to get help from our support engineers.</p>+ {canCreateTicket && (+ <p className="text-sm">Create a new ticket to get help from our support engineers.</p>+ )}</div>) : (<div className="flex flex-col gap-1 mt-2">diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.tsindex 5f1ad950f3aa..beeab554f624 100644--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts@@ -4,14 +4,20 @@ import posthog from 'posthog-js'import { CONVERSATIONS_MESSAGE_MAX_LENGTH, supportLogic } from 'lib/components/Support/supportLogic'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { billingLogic } from 'scenes/billing/billingLogic'import { initKeaTests } from '~/test/init'+import { BillingType } from '~/types'import { sidepanelTicketsLogic } from './sidepanelTicketsLogic'describe('sidepanelTicketsLogic', () => {let logic: ReturnType<typeof sidepanelTicketsLogic.build>+ const setSubscriptionLevel = (subscriptionLevel: BillingType['subscription_level']): void => {+ billingLogic.actions.loadBillingSuccess({ subscription_level: subscriptionLevel } as BillingType)+ }+beforeEach(() => {initKeaTests();(posthog as any).conversations = {@@ -26,6 +32,10 @@ describe('sidepanelTicketsLogic', () => {featureFlagLogic.mount()featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.PRODUCT_SUPPORT_SIDE_PANEL]: true })supportLogic.mount()+ billingLogic.mount()+ // Tickets can be created unless a test drops the plan; set it up front, since the async+ // fixture load lands too late for the intent a test may already have queued+ setSubscriptionLevel('paid')})afterEach(() => {@@ -64,7 +74,7 @@ describe('sidepanelTicketsLogic', () => {await expectLogic(logic, () => {supportLogic.actions.openSupportForm({kind: 'support',- target_area: 'billing',+ target_area: 'analytics',isEmailFormOpen: true,target: 'sidePanel',})@@ -74,6 +84,78 @@ describe('sidepanelTicketsLogic', () => {expect(supportLogic.values.isEmailFormOpen).toBe(false)})+ it.each([+ ['analytics', 'list'],+ // Billing problems are answered on every plan+ ['billing', 'new'],+ ])('on a free plan, a %s support CTA lands on the %s view', async (targetArea, expectedView) => {+ logic = sidepanelTicketsLogic.build()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ // After the mount, so the fixture load doesn't put the paid plan back+ setSubscriptionLevel('free')++ await expectLogic(logic, () => {+ supportLogic.actions.openSupportForm({+ kind: 'bug',+ target_area: targetArea as 'analytics' | 'billing',+ isEmailFormOpen: true,+ message: 'It broke',+ target: 'sidePanel',+ })+ }).toFinishAllListeners()++ expect(logic.values.view).toBe(expectedView)+ // Either way the intent is consumed, so supportRouterLogic doesn't keep replaying it+ expect(supportLogic.values.isEmailFormOpen).toBe(false)+ })++ it('keeps the billing exemption after the support form resets, so backing out of the composer is not a dead end', async () => {+ logic = sidepanelTicketsLogic.build()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ setSubscriptionLevel('free')+ expect(logic.values.canCreateTicket).toBe(false)++ await expectLogic(logic, () => {+ supportLogic.actions.openSupportForm({+ kind: 'support',+ target_area: 'billing',+ isEmailFormOpen: true,+ target: 'sidePanel',+ })+ }).toFinishAllListeners()++ // supportLogic has already cleared target_area by now, so an exemption read off it would be gone+ expect(supportLogic.values.targetArea).toBeNull()+ expect(logic.values.canCreateTicket).toBe(true)++ logic.actions.setView('list')+ expect(logic.values.canCreateTicket).toBe(true)+ })++ it('opens the composer while entitlement is still unknown rather than discarding the request', async () => {+ logic = sidepanelTicketsLogic.build()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ // billing is lazily loaded, so a CTA can fire before it resolves — for a paid customer,+ // consuming the intent here would silently drop their message+ billingLogic.actions.loadBilling()+ expect(logic.values.isBillingResolved).toBe(false)++ supportLogic.actions.openSupportForm({+ kind: 'bug',+ target_area: 'analytics',+ isEmailFormOpen: true,+ message: 'It broke',+ target: 'sidePanel',+ })++ expect(logic.values.view).toBe('new')+ expect(JSON.stringify(logic.values.newTicketDraft)).toContain('It broke')+ })+it('opens the specific ticket thread when a submission toast "View" is clicked', async () => {logic = sidepanelTicketsLogic.build()logic.mount()diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.tsindex 5173b260a952..7d69f3c3068f 100644--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts@@ -19,10 +19,16 @@ import { appendExceptionToMessage, supportLogic, warnIfMessageTooLong } from 'liimport { FEATURE_FLAGS } from 'lib/constants'import { EMAIL_SUPPORT_BUTTON, lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { billingLogic } from 'scenes/billing/billingLogic'+import { organizationLogic } from 'scenes/organizationLogic'import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'+import type { BillingType } from '~/types'-import type { SupportFormFields } from '../../../../../frontend/src/lib/components/Support/supportLogic'+import type {+ SupportFormFields,+ SupportTicketTargetArea,+} from '../../../../../frontend/src/lib/components/Support/supportLogic'import type { FeatureFlagsSet } from '../../../../../frontend/src/lib/logic/featureFlagLogic'import type {ChatMessage,@@ -53,7 +59,10 @@ function messageToRichContent(message: string): JSONContent {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sidepanelTicketsLogicValues {+ billing: BillingType | null // billingLogic+ billingLoading: boolean // billingLogicfeatureFlags: FeatureFlagsSet // featureFlagLogic+ isCurrentOrganizationNew: boolean // organizationLogicsidePanelOpen: boolean // sidePanelStateLogicisEmailFormOpen: boolean // supportLogicpendingViewTicket: {@@ -62,8 +71,12 @@ export interface sidepanelTicketsLogicValues {status: string} | null // supportLogicsendSupportRequest: SupportFormFields // supportLogic+ targetArea: SupportTicketTargetArea | null // supportLogic+ canCreateTicket: booleancurrentTicket: ConversationTicket | null+ hasBillingExemption: booleanhasMoreMessages: boolean+ isBillingResolved: booleanisEnabled: booleanmessageSending: booleanmessages: ChatMessage[]@@ -80,6 +93,9 @@ export interface sidepanelTicketsLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sidepanelTicketsLogicActions {+ closeSidePanel: (tab?: import('~/types').SidePanelTab | undefined) => {+ tab: import('~/types').SidePanelTab | undefined+ } // sidePanelStateLogicclearPendingViewTicket: () => {value: true} // supportLogic@@ -92,6 +108,9 @@ export interface sidepanelTicketsLogicActions {resetSendSupportRequest: (values?: SupportFormFields | undefined) => {values?: SupportFormFields} // supportLogic+ grantBillingExemption: () => {+ value: true+ }initTickets: () => {value: true}@@ -169,6 +188,12 @@ export interface sidepanelTicketsLogicMeta {__keaTypeGenInternalSelectorTypes: {isEnabled: (featureFlags: FeatureFlagsSet) => booleantotalUnreadCount: (tickets: ConversationTicket[]) => number+ canCreateTicket: (+ billing: BillingType | null,+ isCurrentOrganizationNew: boolean,+ hasBillingExemption: boolean+ ) => boolean+ isBillingResolved: (billing: BillingType | null, billingLoading: boolean) => boolean}}@@ -188,14 +213,21 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([featureFlagLogic,['featureFlags'],supportLogic,- ['isEmailFormOpen', 'sendSupportRequest', 'pendingViewTicket'],+ ['isEmailFormOpen', 'sendSupportRequest', 'pendingViewTicket', 'targetArea'],+ billingLogic,+ ['billing', 'billingLoading'],+ organizationLogic,+ ['isCurrentOrganizationNew'],],actions: [supportLogic,['closeEmailForm', 'closeSupportForm', 'clearPendingViewTicket', 'resetSendSupportRequest'],+ sidePanelStateLogic,+ ['closeSidePanel'],],})),actions({+ grantBillingExemption: true,initTickets: true,loadTickets: true,startPolling: true,@@ -298,6 +330,16 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([setRestoreState: () => null,},],+ // Held for the life of the open panel rather than read off supportLogic's `targetArea`, which+ // resets the moment the intent is consumed — a plan that can't open tickets would otherwise+ // lose the exemption mid-compose, and with it the composer it was just granted+ hasBillingExemption: [+ false as boolean,+ {+ grantBillingExemption: () => true,+ closeSidePanel: () => false,+ },+ ],}),selectors({isEnabled: [@@ -309,6 +351,30 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([(s) => [s.tickets],(tickets: ConversationTicket[]) => tickets.reduce((sum, t) => sum + (t.unread_count ?? 0), 0),],+ // Opening a ticket is the paid part of support. Reading and replying to tickets already in+ // the account isn't — free plans can end up with tickets via billing questions or PostHog AI+ // bug reports, and abandoning those threads helps nobody.+ canCreateTicket: [+ (s) => [s.billing, s.isCurrentOrganizationNew, s.hasBillingExemption],+ (billing: BillingType | null, isCurrentOrganizationNew: boolean, hasBillingExemption: boolean): boolean => {+ const hasSupportTrial =+ billing?.trial?.status === 'active' &&+ ['boost', 'scale', 'enterprise'].includes(billing.trial?.target ?? '')+ return (+ billing?.subscription_level === 'paid' ||+ billing?.subscription_level === 'custom' ||+ hasSupportTrial ||+ isCurrentOrganizationNew ||+ hasBillingExemption+ )+ },+ ],+ // `billing` is lazily loaded, so a null value means "not fetched yet" just as often as it+ // means "no billing". Entitlement is only knowable once it settles.+ isBillingResolved: [+ (s) => [s.billing, s.billingLoading],+ (billing: BillingType | null, billingLoading: boolean): boolean => !billingLoading && billing !== null,+ ],}),listeners(({ actions, values, cache }) => ({initTickets: () => {@@ -505,6 +571,20 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([if (!values.isEnabled) {return}+ // Billing problems are answered on every plan, so that CTA earns an exemption even when+ // the plan itself doesn't include support+ if (values.targetArea === 'billing') {+ actions.grantBillingExemption()+ } else if (values.isBillingResolved && !values.canCreateTicket) {+ // Still consume the intent (see below), just without opening the composer — the panel+ // explains why and points at the community and upgrade options instead. Only ever on a+ // known-ineligible plan: consuming is irreversible, so while entitlement is still+ // unknown we open the composer rather than drop someone's message on the floor.+ actions.closeEmailForm()+ actions.closeSupportForm()+ actions.resetSendSupportRequest()+ return+ }const request = values.sendSupportRequestconst message = request?.messageif (message) {