: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(support): show support pane before zendesk on person profile (#67303)
Abigail45b0e4d0edce
diff --git a/frontend/src/scenes/data-pipelines/ZendeskSourceSetupPrompt.tsx b/frontend/src/scenes/data-pipelines/ZendeskSourceSetupPrompt.tsxdeleted file mode 100644index 5ef3e6d3db22..000000000000--- a/frontend/src/scenes/data-pipelines/ZendeskSourceSetupPrompt.tsx+++ /dev/null@@ -1,63 +0,0 @@-import { BuiltLogic, LogicWrapper, useValues } from 'kea'--import { IconPlusSmall } from '@posthog/icons'-import { LemonButton, Spinner } from '@posthog/lemon-ui'--import { SupportHeroHog } from 'lib/components/hedgehogs'-import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'-import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'-import { urls } from 'scenes/urls'--import { ProductKey } from '~/queries/schema/schema-general'--import { sourceManagementLogic } from 'products/data_warehouse/frontend/shared/logics/sourceManagementLogic'--interface ZendeskSourceSetupPromptProps {- children: React.ReactNode- className?: string- attachTo?: BuiltLogic | LogicWrapper-}--export function ZendeskSourceSetupPrompt({- children,- className,- attachTo,-}: ZendeskSourceSetupPromptProps): JSX.Element {- const builtDataWarehouseSettingsLogic = sourceManagementLogic()- const { hasZendeskSource, dataWarehouseSourcesLoading } = useValues(builtDataWarehouseSettingsLogic)- useAttachedLogic(builtDataWarehouseSettingsLogic, attachTo)-- return dataWarehouseSourcesLoading ? (- <div className="flex justify-center">- <Spinner />- </div>- ) : !hasZendeskSource ? (- <SetupPrompt className={className} />- ) : (- <>{children}</>- )-}--function SetupPrompt({ className }: Pick<ZendeskSourceSetupPromptProps, 'className'>): JSX.Element {- return (- <ProductIntroduction- customHog={SupportHeroHog}- productName="Data Warehouse Source"- titleOverride="Bring your data from Zendesk"- productKey={ProductKey.DATA_WAREHOUSE}- thingName="data source"- className={className}- description="Use data warehouse sources to import data from Zendesk into PostHog."- isEmpty={true}- docsURL="https://posthog.com/docs/data-warehouse"- actionElementOverride={- <LemonButton- icon={<IconPlusSmall />}- type="primary"- to={urls.dataWarehouseSourceNew('Zendesk')}- children="Create Zendesk source"- />- }- />- )-}diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.stories.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.stories.tsxindex 9cb6571d20ef..6c7433833882 100644--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.stories.tsx+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.stories.tsx@@ -1,3 +1,5 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'+import { Meta, StoryObj } from '@storybook/react'import { BindLogic } from 'kea'import { useMemo } from 'react'@@ -157,6 +159,22 @@ const meta: Meta = {},}),],+ // The support node renders its tickets table only when the team has support enabled; otherwise+ // it shows the "set up support" banner (no .LemonTable to snapshot). teamLogic seeds currentTeam+ // from getAppContext().current_team (not an API call), so enable it in the app context here.+ // beforeEach runs before Kea mounts teamLogic; the cleanup restores it for other stories.+ beforeEach: () => {+ const appContext = window.POSTHOG_APP_CONTEXT+ const originalTeam = appContext?.current_team+ if (appContext) {+ appContext.current_team = { ...MOCK_DEFAULT_TEAM, conversations_enabled: true }+ }+ return () => {+ if (appContext) {+ appContext.current_team = originalTeam ?? null+ }+ }+ },}export default metadiff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.tsxindex b2fc63908525..3abc1a750ad9 100644--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.tsx+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeSupportTickets.tsx@@ -2,7 +2,9 @@ import { BindLogic, useActions, useValues } from 'kea'import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'+import { teamLogic } from 'scenes/teamLogic'+import { ConversationsDisabledBanner } from 'products/conversations/frontend/components/ConversationsDisabledBanner'import {SupportTicketsTable,SupportTicketsTableFilters,@@ -21,6 +23,7 @@ const Component = ({ attributes }: NotebookNodeProps<NotebookNodeSupportTicketsAconst logicProps = { key: nodeId, distinctIds }const mountedLogic = supportTicketsSceneLogic(logicProps)useAttachedLogic(mountedLogic, notebookLogic)+ const { currentTeam } = useValues(teamLogic)useOnMountEffect(() => {const removeMenuItem = getCustomerProfileRemoveMenuItem(NotebookNodeType.SupportTickets)@@ -33,6 +36,13 @@ const Component = ({ attributes }: NotebookNodeProps<NotebookNodeSupportTicketsAreturn null}+ // When support is off, never query the disabled product — show the "set up support"+ // prompt instead. (The panel is hidden entirely for teams that use Zendesk but not+ // support; that visibility decision lives in customerProfileLogic's content filter.)+ if (!currentTeam?.conversations_enabled) {+ return <ConversationsDisabledBanner />+ }+return (<BindLogic logic={supportTicketsSceneLogic} props={logicProps}><SupportTicketsTable embedded />diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeZendeskTickets.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodeZendeskTickets.tsxindex a1790933e5c7..03549a3c25f4 100644--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeZendeskTickets.tsx+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeZendeskTickets.tsx@@ -4,7 +4,6 @@ import { LemonInput } from '@posthog/lemon-ui'import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'-import { ZendeskSourceSetupPrompt } from 'scenes/data-pipelines/ZendeskSourceSetupPrompt'import { Query } from '~/queries/Query/Query'import type { DataTableNode } from '~/queries/schema/schema-general'@@ -48,11 +47,7 @@ const Component = ({ attributes }: NotebookNodeProps<NotebookNodeZendeskTicketsAreturn <ZendeskTicketsMissingTarget />}- return (- <ZendeskSourceSetupPrompt className="border-none" attachTo={notebookLogic}>- <Query query={{ ...query, embedded: true }} context={context} attachTo={notebookLogic} />- </ZendeskSourceSetupPrompt>- )+ return <Query query={{ ...query, embedded: true }} context={context} attachTo={notebookLogic} />}function ZendeskTicketsMissingTarget(): JSX.Element {diff --git a/products/customer_analytics/frontend/customerProfileLogic.ts b/products/customer_analytics/frontend/customerProfileLogic.tsindex 4e36883b5f20..dd6baddbaee8 100644--- a/products/customer_analytics/frontend/customerProfileLogic.ts+++ b/products/customer_analytics/frontend/customerProfileLogic.ts@@ -6,9 +6,12 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { DEFAULT_QUERY } from 'scenes/notebooks/Nodes/NotebookNodeQuery'import { notebookLogic } from 'scenes/notebooks/Notebook/notebookLogic'import { NotebookNodeType } from 'scenes/notebooks/types'+import { teamLogic } from 'scenes/teamLogic'import { CustomerProfileScope, GroupTypeIndex } from '~/types'+import { sourceManagementLogic } from 'products/data_warehouse/frontend/shared/logics/sourceManagementLogic'+import { customerProfileConfigLogic } from './customerProfileConfigLogic'import type { customerProfileLogicType } from './customerProfileLogicType'@@ -25,9 +28,9 @@ export const DEFAULT_PERSON_PROFILE_CONTENT: JSONContent[] = [{ type: NotebookNodeType.CustomerJourney, index: 1, attrs: { title: 'Customer journey' } },{ type: NotebookNodeType.PersonFeed, index: 2, attrs: { title: 'Session feed' } },{ type: NotebookNodeType.LLMTrace, index: 3, attrs: { title: 'LLM traces' } },- { type: NotebookNodeType.ZendeskTickets, index: 4, attrs: { title: 'Zendesk tickets' } },- { type: NotebookNodeType.Issues, index: 5, attrs: { title: 'Issues' } },- { type: NotebookNodeType.SupportTickets, index: 6, attrs: { title: 'Support tickets' } },+ { type: NotebookNodeType.SupportTickets, index: 4, attrs: { title: 'Support tickets' } },+ { type: NotebookNodeType.ZendeskTickets, index: 5, attrs: { title: 'Zendesk tickets' } },+ { type: NotebookNodeType.Issues, index: 6, attrs: { title: 'Issues' } },]export const DEFAULT_GROUP_PROFILE_SIDEBAR: JSONContent[] = [@@ -45,6 +48,40 @@ export const DEFAULT_GROUP_PROFILE_CONTENT: JSONContent[] = [{ type: NotebookNodeType.Issues, index: 5, attrs: { title: 'Issues' } },]+interface PanelAvailability {+ isJourneysEnabled: boolean+ isSupportEnabled: boolean+ hasZendeskSource: boolean+ dataWarehouseSourcesLoading: boolean+}++// Panels backed by a product or warehouse source that may not be set up must be filtered out of+// *every* content path — defaults and saved configs alike — so we never render a live query+// against tables that don't exist (e.g. the Zendesk panel with no Zendesk warehouse source).+// Keeping this in one helper means any future entry point that builds profile content stays safe.+function filterAvailablePanels(+ nodes: JSONContent[],+ { isJourneysEnabled, isSupportEnabled, hasZendeskSource, dataWarehouseSourcesLoading }: PanelAvailability+): JSONContent[] {+ return (+ nodes+ .filter((node) => node.type !== NotebookNodeType.CustomerJourney || isJourneysEnabled)+ // Hide the Zendesk panel unless a Zendesk warehouse source exists — without one its+ // query targets non-existent zendesk_* tables.+ .filter((node) => node.type !== NotebookNodeType.ZendeskTickets || hasZendeskSource)+ // Support panel: show the table when support is on; when it's off, show the "set up+ // support" prompt only if there's no Zendesk either (don't nag teams that already use+ // Zendesk). Wait for sources to load before deciding, so we never flash the prompt at+ // a Zendesk team.+ .filter(+ (node) =>+ node.type !== NotebookNodeType.SupportTickets ||+ isSupportEnabled ||+ (!hasZendeskSource && !dataWarehouseSourcesLoading)+ )+ )+}+export type CustomerProfileAttrs = {personId?: string | undefineddistinctIds?: string[]@@ -70,12 +107,18 @@ export const customerProfileLogic = kea<customerProfileLogicType>([['customerProfileConfig'],featureFlagLogic,['featureFlags'],+ sourceManagementLogic,+ ['hasZendeskSource', 'dataWarehouseSourcesLoading'],+ teamLogic,+ ['currentTeam'],],actions: [customerProfileConfigLogic({ scope: props.scope }),['createConfig', 'updateConfig', 'loadConfigsSuccess', 'updateConfigSuccess', 'createConfigSuccess'],notebookLogic({ shortId: props.canvasShortId, mode: 'canvas' }),['setLocalContent'],+ sourceManagementLogic,+ ['loadSourcesSuccess'],],})),@@ -140,16 +183,33 @@ export const customerProfileLogic = kea<customerProfileLogicType>([s.scopedSidebarContent,s.scopedAddAttrFunction,s.featureFlags,+ s.hasZendeskSource,+ s.dataWarehouseSourcesLoading,+ s.currentTeam,(_, props) => props.scope,(_, props) => props.attrs,],- (scopedSidebarContent, scopedAddAttrFunction, featureFlags, scope, attrs) => {- const isJourneysEnabled = !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS_JOURNEYS]- const scopedDefaultContent = (+ (+ scopedSidebarContent,+ scopedAddAttrFunction,+ featureFlags,+ hasZendeskSource,+ dataWarehouseSourcesLoading,+ currentTeam,+ scope,+ attrs+ ) => {+ const scopedDefaultContent = filterAvailablePanels(scope === CustomerProfileScope.PERSON? DEFAULT_PERSON_PROFILE_CONTENT- : DEFAULT_GROUP_PROFILE_CONTENT- ).filter((node) => node.type !== NotebookNodeType.CustomerJourney || isJourneysEnabled)+ : DEFAULT_GROUP_PROFILE_CONTENT,+ {+ isJourneysEnabled: !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS_JOURNEYS],+ isSupportEnabled: !!currentTeam?.conversations_enabled,+ hasZendeskSource,+ dataWarehouseSourcesLoading,+ }+ )const sidebar = scopedSidebarContent.map((node) => scopedAddAttrFunction({ attrs, node }))return scopedDefaultContent.map((node, index) => {@@ -164,18 +224,41 @@ export const customerProfileLogic = kea<customerProfileLogicType>([(s) => [s.customerProfileConfig,s.scopedAddAttrFunction,+ s.featureFlags,+ s.hasZendeskSource,+ s.dataWarehouseSourcesLoading,+ s.currentTeam,(_, props) => props.attrs,- (_, props) => props.scope,],- (customerProfileConfig, scopedAddAttrFunction, attrs): JSONContent[] | null => {+ (+ customerProfileConfig,+ scopedAddAttrFunction,+ featureFlags,+ hasZendeskSource,+ dataWarehouseSourcesLoading,+ currentTeam,+ attrs+ ): JSONContent[] | null => {if (!customerProfileConfig) {return null}+ // Saved configs bypass defaultContent, so apply the same availability filter here —+ // otherwise a previously-saved Zendesk/support panel would render against a product+ // or source that is no longer set up.+ // `content` is declared as Record<string, any> on the config type but is stored as a+ // node array; cast to its real shape for the shared filter.+ const availableContent = filterAvailablePanels(customerProfileConfig.content as JSONContent[], {+ isJourneysEnabled: !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS_JOURNEYS],+ isSupportEnabled: !!currentTeam?.conversations_enabled,+ hasZendeskSource,+ dataWarehouseSourcesLoading,+ })+const sidebar = customerProfileConfig.sidebar.map((node: JSONContent) =>scopedAddAttrFunction({ attrs, node }))- return customerProfileConfig.content.map((node: JSONContent, index: number) => {+ return availableContent.map((node: JSONContent, index: number) => {if (index === 0) {return scopedAddAttrFunction({ attrs, node, children: sidebar })}@@ -258,6 +341,12 @@ export const customerProfileLogic = kea<customerProfileLogicType>([loadConfigsSuccess: () => {actions.setLocalContent(values.content, true)},+ // The source list loads asynchronously, so the initial mount sync can run before we+ // know whether a Zendesk source exists. Re-sync once it resolves so the Zendesk and+ // Support panels appear/disappear to match the actual source and support state.+ loadSourcesSuccess: () => {+ actions.setLocalContent(values.content, true)+ },})),afterMount(({ actions, values }) => {