: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
feat(today): rebuild the support panel in quill (#119074)
Adam Leithd356c22e5cd5
diff --git a/frontend/src/layout/today/TodayContextPanelContent.tsx b/frontend/src/layout/today/TodayContextPanelContent.tsxindex 60d322190e71..681e2045da21 100644--- a/frontend/src/layout/today/TodayContextPanelContent.tsx+++ b/frontend/src/layout/today/TodayContextPanelContent.tsx@@ -3,6 +3,7 @@ import { ComponentType, Suspense, memo, useState } from 'react'import { Spinner } from '@posthog/quill'+import { lazyWithRetry } from 'lib/utils/retryImport'import { ChunkLoadErrorBoundary } from 'scenes/ChunkLoadErrorBoundary'import { ErrorBoundary } from '~/layout/ErrorBoundary'@@ -12,9 +13,13 @@ import { SidePanelTab } from '~/types'import { TodayAiPanel } from './TodayAiPanel'import { todayContextPanelLogic } from './todayContextPanelLogic'-// The quill rebuilds of the side panel tabs. Every other tab keeps its own panel.+// The quill rebuilds of the side panel tabs. Every other tab keeps its own panel. Support is lazy because the ticket+// editor pulls in tiptap extensions and lowlight.const QUILL_TAB_PANELS: Partial<Record<SidePanelTab, ComponentType>> = {[SidePanelTab.Max]: TodayAiPanel,+ [SidePanelTab.Support]: lazyWithRetry(() =>+ import('./TodaySupportPanel').then((m) => ({ default: m.TodaySupportPanel }))+ ),}type SwitchDirection = 'forward' | 'backward'diff --git a/frontend/src/layout/today/TodaySupportPanel.tsx b/frontend/src/layout/today/TodaySupportPanel.tsxnew file mode 100644index 000000000000..c3f6efd6dab9--- /dev/null+++ b/frontend/src/layout/today/TodaySupportPanel.tsx@@ -0,0 +1,178 @@+import { useActions, useValues } from 'kea'++import { IconExternal, IconFeatures, IconHelmet, IconMap } from '@posthog/icons'+import { Button, Heading, Skeleton, Text, cn } from '@posthog/quill'++import { FEATURE_FLAGS } from 'lib/constants'+import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { billingLogic } from 'scenes/billing/billingLogic'+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'+import { urls } from 'scenes/urls'++import { ProductKey } from '~/queries/schema/schema-general'+import { BillingPlan, SidePanelTab } from '~/types'++import { QuillSupportTickets } from 'products/conversations/frontend/components/QuillSidePanel/QuillSupportTickets'+import { sidepanelTicketsLogic } from 'products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic'++import { todayContextPanelLogic } from './todayContextPanelLogic'+import { TodaySupportResponseTimes } from './TodaySupportResponseTimes'+import { TodaySupportStatusAlert } from './TodaySupportStatusAlert'++// Set through the `support-message-override` feature flag, for times like an offsite or the holidays.+const SUPPORT_MESSAGE_OVERRIDE_TITLE = "We're catching up on our support queue"+const SUPPORT_MESSAGE_OVERRIDE_BODY =+ 'Our support engineers recently attended an offsite to make long-term enhancements to our support process. As a result, our response times are slightly delayed for some inquiries. Thanks for your patience as we work to get caught up!'++const FEEDBACK_LINKS = [+ { label: "See what we're building", href: 'https://posthog.com/wip', Icon: IconHelmet },+ { label: 'Vote on our roadmap', href: 'https://posthog.com/roadmap', Icon: IconMap },+ { label: 'Request a feature', href: 'https://posthog.com/roadmap?idea=new', Icon: IconFeatures },+]++function ExternalLinkButton({ href, children }: { href: string; children: React.ReactNode }): JSX.Element {+ return (+ // eslint-disable-next-line react/forbid-elements+ <Button variant="outline" render={<a href={href} target="_blank" rel="noopener noreferrer" />}>+ {children}+ </Button>+ )+}++export function TodaySupportPanel(): JSX.Element {+ const { preflight } = useValues(preflightLogic)+ const { billing, billingLoading, billingPlan } = useValues(billingLogic)+ const { tickets, canCreateTicket, view } = useValues(sidepanelTicketsLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const { togglePanelTab } = useActions(todayContextPanelLogic)++ const isCloudOrDev = preflight?.cloud || process.env.NODE_ENV === 'development'+ const billingLoaded = !billingLoading && billing !== undefined+ // Free plans can't open new tickets, but tickets they already have stay readable and repliable.+ const showTickets = isCloudOrDev && (canCreateTicket || tickets.length > 0)++ // An open ticket, a new ticket or recovery fills the panel on its own, so the thread and composer get the room.+ // An open ticket scrolls its own thread. The forms scroll as a whole, so Submit stays reachable in a short panel.+ if (showTickets && view !== 'list') {+ return (+ <div className={cn('flex min-h-0 flex-1 flex-col p-3', view !== 'ticket' && 'overflow-y-auto')}>+ <QuillSupportTickets />+ </div>+ )+ }++ return (+ <div className="min-h-0 flex-1 overflow-y-auto scroll-mask-y-4 scroll-py-4">+ <div className="mx-auto flex w-full max-w-160 flex-col gap-6 p-4">+ {!billingLoaded ? (+ <div className="flex flex-col gap-2">+ <Skeleton className="h-5 w-1/3" />+ <Skeleton className="h-16" />+ </div>+ ) : (+ <>+ {isCloudOrDev && (+ <section className="flex flex-col gap-2">+ <Heading size="sm" render={<h3 className="m-0" />}>+ Ask PostHog AI+ </Heading>+ <Text size="xs" variant="muted">+ PostHog AI can answer most of the support questions we receive. It reads our docs+ for you, and writes SQL queries, expressions and regex patterns.+ </Text>+ <Button+ variant="primary"+ onClick={() => togglePanelTab(SidePanelTab.Max)}+ data-attr="support-panel-chat-with-ai"+ >+ Chat with PostHog AI+ </Button>+ </section>+ )}++ {showTickets ? (+ <section className="flex flex-col gap-2">+ <Heading size="sm" render={<h3 className="m-0" />}>+ {canCreateTicket ? 'Contact us' : 'Your tickets'}+ </Heading>+ <TodaySupportStatusAlert />+ {featureFlags[FEATURE_FLAGS.SUPPORT_MESSAGE_OVERRIDE] && (+ <div className="flex flex-col gap-1 rounded-md border border-border p-3">+ <Text size="xs" weight="semibold">+ {SUPPORT_MESSAGE_OVERRIDE_TITLE}+ </Text>+ <Text size="xs" variant="muted">+ {SUPPORT_MESSAGE_OVERRIDE_BODY}+ </Text>+ </div>+ )}+ <Text size="xs" variant="muted">+ {canCreateTicket+ ? "Can't find what you need, and PostHog AI couldn't help? Message our support engineers."+ : 'You can keep replying to tickets you already have open.'}+ </Text>+ <QuillSupportTickets />+ </section>+ ) : (+ <section className="flex flex-col gap-2">+ <Heading size="sm" render={<h3 className="m-0" />}>+ Can't find what you need in the docs?+ </Heading>+ <Text size="xs" variant="muted">+ With the free plan you can ask the community, or explore your upgrade choices to+ message our support engineers.+ </Text>+ </section>+ )}+ </>+ )}++ <section className="flex flex-col gap-2">+ <Heading size="sm" render={<h3 className="m-0" />}>+ Ask the community+ </Heading>+ <Text size="xs" variant="muted">+ Questions about features, how-tos, or use cases? There are thousands of discussions in our+ community forums.+ </Text>+ <ExternalLinkButton href="https://posthog.com/questions">+ Ask the community+ <IconExternal />+ </ExternalLinkButton>+ </section>++ <section className="flex flex-col gap-2">+ <Heading size="sm" render={<h3 className="m-0" />}>+ Support is open Monday to Friday+ </Heading>+ <TodaySupportResponseTimes />+ {billingPlan !== BillingPlan.Enterprise && (+ <Button+ variant="link"+ size="sm"+ className="self-end p-0"+ render={<LinkPrimitive to={urls.organizationBilling([ProductKey.PLATFORM_AND_SUPPORT])} />}+ >+ Upgrade support plan+ </Button>+ )}+ </section>++ <section className="flex flex-col gap-2">+ <Heading size="sm" render={<h3 className="m-0" />}>+ Share feedback+ </Heading>+ <div className="flex flex-col items-start gap-2">+ {FEEDBACK_LINKS.map(({ label, href, Icon }) => (+ <ExternalLinkButton key={href} href={href}>+ <Icon />+ {label}+ </ExternalLinkButton>+ ))}+ </div>+ </section>+ </div>+ </div>+ )+}diff --git a/frontend/src/layout/today/TodaySupportResponseTimes.tsx b/frontend/src/layout/today/TodaySupportResponseTimes.tsxnew file mode 100644index 000000000000..1345ae5386f2--- /dev/null+++ b/frontend/src/layout/today/TodaySupportResponseTimes.tsx@@ -0,0 +1,74 @@+import { useValues } from 'kea'++import { Table, TableBody, TableCell, TableRow, Text } from '@posthog/quill'++import { DEFAULT_PAID_RESPONSE_TIME, getSupportPlanRows } from 'lib/components/Support/supportResponseTime'+import { dayjs } from 'lib/dayjs'+import { billingLogic } from 'scenes/billing/billingLogic'+import { userLogic } from 'scenes/userLogic'++export function TodaySupportResponseTimes(): JSX.Element {+ const { billing, billingPlan, supportPlans } = useValues(billingLogic)+ const { user } = useValues(userLogic)++ const rows = getSupportPlanRows({ billing, billingPlan, supportPlans, organizationId: user?.organization?.id })+ const trial = billing?.trial+ const activeTrial = trial?.status === 'active' && ['boost', 'scale', 'enterprise'].includes(trial.target ?? '')++ return (+ <div className="flex flex-col gap-1">+ <Table size="sm" fullWidth className="rounded-md border border-border">+ <TableBody>+ {rows.map((row) => (+ <TableRow key={row.key}>+ <TableCell className={row.isCurrentPlan ? 'font-semibold' : undefined}>+ <span data-attr="support-plan-name">+ {row.name}+ {row.legacy && <span className="font-normal text-muted-foreground"> (legacy)</span>}+ {row.isCurrentPlan && (+ <span className="font-normal text-muted-foreground"> (your plan)</span>+ )}+ </span>+ </TableCell>+ <TableCell align="right" className={row.isCurrentPlan ? 'font-semibold' : undefined}>+ <span data-attr="support-response-time">+ {!row.responseTime && row.link ? (+ // eslint-disable-next-line react/forbid-elements+ <a+ href={row.link}+ target="_blank"+ rel="noopener noreferrer"+ className="underline"+ >+ Community forum+ </a>+ ) : (+ row.responseTime || 'Community support only'+ )}+ </span>+ </TableCell>+ </TableRow>+ ))}+ {activeTrial && (+ <TableRow>+ <TableCell className="font-semibold">Your trial</TableCell>+ <TableCell align="right" className="font-semibold">+ {DEFAULT_PAID_RESPONSE_TIME}+ </TableCell>+ </TableRow>+ )}+ </TableBody>+ </Table>+ {activeTrial && trial?.expires_at && (+ <Text size="xs" variant="muted">+ Trial expires {dayjs(trial.expires_at).format('MMMM D, YYYY')}+ </Text>+ )}+ {!activeTrial && trial?.status === 'expired' && (+ <Text size="xs" variant="muted">+ Trial expired+ </Text>+ )}+ </div>+ )+}diff --git a/frontend/src/layout/today/TodaySupportStatusAlert.tsx b/frontend/src/layout/today/TodaySupportStatusAlert.tsxnew file mode 100644index 000000000000..6b05ff0abd67--- /dev/null+++ b/frontend/src/layout/today/TodaySupportStatusAlert.tsx@@ -0,0 +1,40 @@+import { useValues } from 'kea'++import { IconWarning } from '@posthog/icons'+import { Button, Item, ItemContent, ItemDescription, ItemMedia, ItemTitle } from '@posthog/quill'++import { incidentStatusLogic } from 'lib/components/HelpMenu/incidentStatusLogic'++export function TodaySupportStatusAlert(): JSX.Element | null {+ const { status, statusDescription, statusPageUrl } = useValues(incidentStatusLogic)++ if (status === 'operational') {+ return null+ }++ return (+ <Item variant="outline" tone={status.includes('outage') ? 'destructive' : 'warning'}>+ <ItemMedia variant="icon">+ <IconWarning />+ </ItemMedia>+ <ItemContent>+ <ItemTitle>{statusDescription || 'Active incident'}</ItemTitle>+ <ItemDescription>+ We're aware of an issue that may be affecting your PostHog experience. You may wish to check our+ current status before contacting support.+ </ItemDescription>+ <Button+ variant="link"+ size="sm"+ className="self-start p-0"+ render={+ // eslint-disable-next-line react/forbid-elements+ <a href={statusPageUrl} target="_blank" rel="noopener noreferrer" />+ }+ >+ View current status+ </Button>+ </ItemContent>+ </Item>+ )+}diff --git a/frontend/src/layout/today/todayContextPanelLogic.ts b/frontend/src/layout/today/todayContextPanelLogic.tsindex c265a30c6ebe..ebe3122543c0 100644--- a/frontend/src/layout/today/todayContextPanelLogic.ts+++ b/frontend/src/layout/today/todayContextPanelLogic.ts@@ -8,6 +8,9 @@ import { CANVAS_SIDE_PANEL_TABS, sidePanelLogic } from '~/layout/navigation-3000import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'import { SidePanelTab } from '~/types'+import { sidepanelTicketsLogic } from 'products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic'+import { ConversationTicket, SidePanelViewState } from 'products/conversations/frontend/types'+import { todayShellLogic } from './todayShellLogic'export interface TodayContextPanelOffset {@@ -32,6 +35,10 @@ export interface todayContextPanelLogicValues {enabledTabs: SidePanelTab[] // sidePanelLogicselectedTab: SidePanelTab | null // sidePanelStateLogicsidePanelOpen: boolean // sidePanelStateLogic+ canCreateTicket: boolean // sidepanelTicketsLogic+ currentTicket: ConversationTicket | null // sidepanelTicketsLogic+ supportView: SidePanelViewState // sidepanelTicketsLogic+ tickets: ConversationTicket[] // sidepanelTicketsLogiconAiPage: boolean // todayShellLogicactiveTab: SidePanelTabcanUndock: boolean@@ -94,7 +101,14 @@ export interface todayContextPanelLogicMeta {floatingActiveTab: (floatingTab: SidePanelTab, enabledTabs: SidePanelTab[]) => SidePanelTabcanUndock: (activeTab: SidePanelTab, onAiPage: boolean) => booleanactiveTab: (docked: boolean, selectedTab: SidePanelTab | null, floatingActiveTab: SidePanelTab) => SidePanelTab- fullScreenUrl: (activeTab: SidePanelTab, selectedNotebook: string) => string | null+ fullScreenUrl: (+ activeTab: SidePanelTab,+ selectedNotebook: string,+ tickets: ConversationTicket[],+ canCreateTicket: boolean,+ supportView: SidePanelViewState,+ currentTicket: ConversationTicket | null+ ) => string | null}}@@ -119,6 +133,8 @@ export const todayContextPanelLogic = kea<todayContextPanelLogicType>([['enabledTabs'],notebookPanelLogic,['selectedNotebook'],+ sidepanelTicketsLogic,+ ['tickets', 'canCreateTicket', 'view as supportView', 'currentTicket'],todayShellLogic,['onAiPage'],],@@ -203,13 +219,25 @@ export const todayContextPanelLogic = kea<todayContextPanelLogicType>([],fullScreenUrl: [// PostHog AI's URL comes from the chat logic, which the header reads only while the panel is open.- (s) => [s.activeTab, s.selectedNotebook],- (activeTab: SidePanelTab, selectedNotebook: string): string | null => {+ (s) => [s.activeTab, s.selectedNotebook, s.tickets, s.canCreateTicket, s.supportView, s.currentTicket],+ (+ activeTab: SidePanelTab,+ selectedNotebook: string,+ tickets: ConversationTicket[],+ canCreateTicket: boolean,+ supportView: SidePanelViewState,+ currentTicket: ConversationTicket | null+ ): string | null => {switch (activeTab) {case SidePanelTab.Activity:return urls.advancedActivityLogs()case SidePanelTab.Notebooks:return urls.notebook(selectedNotebook)+ // Matches the support panel's own expand button: the tickets page, on the open ticket if any.+ case SidePanelTab.Support:+ return canCreateTicket || tickets.length > 0+ ? urls.myTickets(supportView === 'ticket' ? currentTicket?.id : undefined)+ : nulldefault:return null}