: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
import type { Meta, StoryObj } from '@storybook/react'
import { BindLogic } from 'kea'
import { AdvertisementCard, ProductPushDisplay } from './navPanelAdShared'
import { navPanelAdvertisementLogic } from './NavPanelAdvertisementLogic'
import { DEFAULT_PRODUCT_PUSH_DISPLAY, PRODUCT_PUSH_DISPLAY } from './navPanelProductPushDisplay'
const meta = {
title: 'Components/NavPanelProductPush',
parameters: { layout: 'padded' },
} satisfies Meta<typeof AdvertisementCard>
export default meta
type Story = StoryObj<typeof meta>
/**
* One product push card, labelled with the product key it renders for.
*/
const PushCard = ({
productKey,
title,
display,
}: {
productKey: string
title: string
display: ProductPushDisplay
}): JSX.Element => (
// The push card renders inside the (narrow) sidebar, so mirror that width here.
<div className="w-[232px]">
<div className="mb-1 font-mono text-xs text-muted">{productKey}</div>
<BindLogic logic={navPanelAdvertisementLogic} props={{ dismissKey: `story-${productKey}` }}>
<AdvertisementCard title={title} text={display.tagline} hero={display} />
</BindLogic>
</div>
)
// One card per pushable product, so a reviewer can eyeball every hoggie / brand color / tagline at once.
export const AllProducts: Story = {
render: (): JSX.Element => {
// 'session_replay' -> 'Session replay'. The live component titles the card with the product's
// catalog label; a story has no catalog to resolve against, so humanize the key instead.
const humanizeProductKey = (productKey: string): string => {
const spaced = productKey.replace(/_/g, ' ')
const sentence = spaced.charAt(0).toUpperCase() + spaced.slice(1)
return sentence.replace(/^(Llm|Mcp)\b/, (acronym) => acronym.toUpperCase())
}
return (
<div className="flex flex-wrap items-start gap-4">
{(Object.entries(PRODUCT_PUSH_DISPLAY) as [string, ProductPushDisplay][]).map(
([productKey, display]) => (
<PushCard
key={productKey}
productKey={productKey}
title={display.label ?? humanizeProductKey(productKey)}
display={display}
/>
)
)}
</div>
)
},
}
// What a product key with no bespoke entry falls back to (e.g. a TAM-scheduled push of an unlisted product).
export const DefaultFallback: Story = {
render: (): JSX.Element => (
<PushCard productKey="default_fallback" title="Any other product" display={DEFAULT_PRODUCT_PUSH_DISPLAY} />
),
}