Skip to content

: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.

feat(aio): add setup empty states for datasets, evaluations, clusters, and business knowledge (#94568)

Marco Gancitanob43dcf6bd696
diff --git a/.agents/skills/building-product-empty-states/SKILL.md b/.agents/skills/building-product-empty-states/SKILL.md
index aa82617a8d55..ba57d3969cba 100644
--- a/.agents/skills/building-product-empty-states/SKILL.md
+++ b/.agents/skills/building-product-empty-states/SKILL.md
@@ -70,6 +70,7 @@ Statuses: `loading` (not yet known - the gate holds a spinner, never flashes the
- **Scene modules that serve more than one surface**: `scenes` narrows where the gate applies, and omitting it gates everything the module serves. A plain scene id covers that whole scene (web analytics gates only `Scene.WebAnalyticsWebVitals`). When one scene id serves several tabs, pass `{ scene, tabs }` and list every value of the `tab` route param you gate, including `undefined` for the URL with no tab segment - `products/workflows/frontend/emptyState/workflowsEmptyState.tsx` gates its workflow list while channels, opt-outs, suppression, and reputation stay reachable with no workflows yet. Gating the scene instead would take those tabs down with it.
- **Hedgehog**: a `pngHoggie(...)`-wrapped module — import only inside the product chunk (eager-graph guard: `frontend/bin/check-eager-graph.mjs`). Never hardcode image URLs (e.g. Cloudinary) — `@posthog/brand` assets only.
- **`text` is keyed by mode**: provide the `needs-setup` base; add a `waiting-for-data` entry only if your product has that middle state (missing fields fall back to the base). Sentence case, benefit-first, no AI tells (see "User-facing copy" in `CLAUDE.md`).
+- **Key `wizard` by mode when the install command stops applying**: a product whose `waiting-for-data` means "events are flowing, a scheduled job hasn't run yet" has nothing left to install, so pass `wizard: { 'needs-setup': { slug } }` and the terminal, the manual link, and the hint leave the waiting screen (clusters). Leave it flat when re-running setup still makes sense there (MCP analytics: "Instrumenting another server?").
- **Key `primaryAction` by mode when it only fits one**: a one-click opt-in ("Enable session recording") is done once the status is `waiting-for-data`, and clicking it again re-sends the same team update. Pass `primaryAction: { 'needs-setup': { ... } }` and the button, along with the `hint` that introduces it, leaves the waiting screen. A single flat action still covers both modes - keep that when it reads correctly either way (support's "Open support settings").
- **Product header**: the gate keeps the product header (name, description, icon) above the empty state automatically, sourced from the scene's `SceneConfig` in your product manifest — make sure your manifest's scene entry has `name`, `description`, and `iconType` set.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f89d93922f6d..747552377adf 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1760,6 +1760,18 @@ snapshots:
hash: v1.k794b7964.375eb5c484baae36185d43a8b1ae04a6ec0915405be7f4f4a05887816dfde456.L2szPOMNE0IT-m3Dxbt1SKmvgfc9bT1pvlF13-L4doI
components-product-empty-state--annotations-needs-setup--light:
hash: v1.k794b7964.56dbdea2b6fb8aaf02bf4ff304ba2d4bff2df277d11255585ceb5c58453a9ceb.jmML3vhPE30ZAvN7k5Fr8gC0RDKY3GusMz-_osZ5o-I
+ components-product-empty-state--business-knowledge-needs-setup--dark:
+ hash: v1.k794b7964.821fd6f4f4b44c031534220f8ea657b5d8cb4839b2c1a92384740ddcfcdbf609.ZS3c9kBrLeu0aclLNMZNBNaUk6KLbOKFgFkB4KrQQZc
+ components-product-empty-state--business-knowledge-needs-setup--light:
+ hash: v1.k794b7964.ae6f46310f1951eb56d74f61222e3f48586585170be86fd18cedb4ec6e53b431.rgzkhE0Nr-GJuwhQAcEg-Ydf24sR21A7Xa9D-WtvOkc
+ components-product-empty-state--clusters-needs-setup--dark:
+ hash: v1.k794b7964.faa055314518c1586c7206158a3781a2fb1a4856a22f362319cf803d1f66a7aa.dMZbPs6mdTPaZb3k8eBWBWCb5IpQKzC6YRppnzZ1kxc
+ components-product-empty-state--clusters-needs-setup--light:
+ hash: v1.k794b7964.5b930dfde7322e8de0b7a2ef4dcbce4a0d5d235f26715a713e568cd199cd68e3.QFQtZlRiKsgrsrOPAS-Ku2FAxKEexsJRe6_mlZonrHI
+ components-product-empty-state--clusters-waiting-for-data--dark:
+ hash: v1.k794b7964.f59a25bce82516d5ca71cab99ed1ec37df01973e3bae1973d4bb7ff2743f293c.0pGxZ3xX-nNDzww09MVlzglAtL2b63HxD0auDl8zIcY
+ components-product-empty-state--clusters-waiting-for-data--light:
+ hash: v1.k794b7964.9073ef14994645a0b8bad9bc18af76d0f542ada523b3c08e8cc16946b71ac50d.Bm86guaVb4P4Bvj1jR1TfhOD65cOdE9XvhJxGpBSWew
components-product-empty-state--cohorts-needs-setup--dark:
hash: v1.k794b7964.83b26d21c2c1d191e3c7f6aa34bd3d8d24e9d6002d3e1369bf5b6a049f757758.PhaOyvOdwWsqT3HArkFs-5X-Bcgx3hwAnlhBFYnJUQo
components-product-empty-state--cohorts-needs-setup--light:
@@ -1776,6 +1788,10 @@ snapshots:
hash: v1.k794b7964.3d7df6ce8c56af7c0c5200d0a381d5f28c885ad380cb370ea0e250266882d608.vwwreN_qibegkh3R21znmwi-Sp9TfdStRZyRxa-g69A
components-product-empty-state--data-warehouse-needs-setup--light:
hash: v1.k794b7964.5bdb2d34c7084ea2351b074cd03275e3558be2b79d0e8a7769d57bdb38e87faa.xNdrkZ0mjoEiJ5DAwDJn1W2x8biEG3DKPcO9wAzRM8c
+ components-product-empty-state--datasets-needs-setup--dark:
+ hash: v1.k794b7964.01f60a890684cbe8ce2e6710438881a14cea589f0329a0c7bb81e6ba3c7d705c.RDQRVZbNasaNJAmELuFQwrgwmPHFLSDnpqwMR65kwLc
+ components-product-empty-state--datasets-needs-setup--light:
+ hash: v1.k794b7964.7822854706ae6666084d7fc87da5c4fcdd8203bf699cff091e4127311c0d36c6.THvugQSJkiPaI4f_IXmCG5wi_pP4W2uFYHeqWhBzZ9k
components-product-empty-state--early-access-features-needs-setup--dark:
hash: v1.k794b7964.ce612c03290780c1098886d9e2e0f9d920bfa899c591fadfecabf969b1897fe6.RlwNrGim39bhZH0hO39-bt6bWPUPJU-5XgIq2smDxSk
components-product-empty-state--early-access-features-needs-setup--light:
@@ -1800,6 +1816,10 @@ snapshots:
hash: v1.k794b7964.574cdf4564785073be5f6199e47f8818070a50b52fc03eefc96c56f40ae51f06.T9kHDbgsBiwQgDUbvF_6K4FP5S4Ku_OAPM1X901Xslk
components-product-empty-state--error-tracking-waiting-for-data--light:
hash: v1.k794b7964.eff072a6e6de72483eb81c9f78e1582f0f5765038832e15dde0437c579af8a6c.MxorCvxObSX63Sd1i7-cam8gtY401euSXUpUrYtC1ko
+ components-product-empty-state--evaluations-needs-setup--dark:
+ hash: v1.k794b7964.a8a278b2693519ebf1783f4062be3f6c1d6235bc9e2497b75c18cc94f82de6cf.Up4GSsLrtmP_2OaDnpbgyytBv3JZyzvehnNKGQkPsI8
+ components-product-empty-state--evaluations-needs-setup--light:
+ hash: v1.k794b7964.10a5bc122e1e17fbbd2f025f29624ad5eccac123560a54274966acf9e2971c51.HyJZax1MznN0JPYKMFadCn3l9qDQ2_JbxFgO9CXEotg
components-product-empty-state--experiments-needs-setup--dark:
hash: v1.k794b7964.4963f41af44c16dbfdacc188339ff9c4f5ca4aada2f5848ad4f195b52c1cc81d.SiIn79B-XFAK4ZwxeLxdLgGNGPbtraECPD_tfCokLdg
components-product-empty-state--experiments-needs-setup--light:
@@ -1821,9 +1841,9 @@ snapshots:
components-product-empty-state--links-needs-setup--light:
hash: v1.k794b7964.b183161da12461f01783c1f14501d0a1c14a964d891e6380a8e002115e58f3e2.TPHWkv5zEqn4Fg-H2SUPRRJrHVyMlXLPtJrpdvfinuM
components-product-empty-state--llm-prompts-needs-setup--dark:
- hash: v1.k794b7964.185b4c941d3476e16eb8b80411bf3f7da1cb663b74388a4ede2aafeb6a2790f3.-WUfqEIfvblTzH2_907USJIjLuKBmE1An_uf_0Avw7w
+ hash: v1.k794b7964.fdd99f387e7d5885faca819190788b78c604be9c25d72a234daac5782d00eb73.YY1FKMtEKT0kYnSd-BFzETTo38_Iz3420mOMtMSpzWc
components-product-empty-state--llm-prompts-needs-setup--light:
- hash: v1.k794b7964.f1455829166714291d8024cd356da16409421f025bdab9345f1d52563d92fe2b.60AARTvAq_U7Kb1gH-DnkTk9ypxPM8g1JT4VCLtuTvo
+ hash: v1.k794b7964.c3e4634294bdb1582ce43c77c7d1075144d4410d551eb4d1bdd9b04846cba79b.54gmU9o9rPj8Skp924kc_djpXXXRW0MftHzY_4ZaDkk
components-product-empty-state--logs-needs-setup--dark:
hash: v1.k794b7964.96e30395bc4290ad188a84e94f5d40d46f545a3223e4d13fe44737d322129e2f.kj5dwA7EuPOvu6YfDc2jc2s38u8BfXT1EcfPAMPztuM
components-product-empty-state--logs-needs-setup--light:
@@ -5989,9 +6009,9 @@ snapshots:
scenes-app-ai-observability-instrumentation-checklist-card--warnings-with-a-dismissal--light:
hash: v1.k794b7964.5b59fa66c967caa25a3b42447aef2a9cc28e7a7297f68bf2c6ef52f93868340b.VU8b650GOEljJTYfBvHHLbvSMPSS35X5ZJzE63xAv6M
scenes-app-ai-observability-prompts--empty-state--dark:
- hash: v1.k794b7964.34208d6347c35d9f570e8d107d47e7360aeed280aa1c87c92d25d25182ddeda5.JGg5hNoklZduz1RmWxJIGvp-ZKpgVuWio9YDjjPtGYU
+ hash: v1.k794b7964.3881018cfbf85cf1beed0dd610d747267571381277a983c7b8239acc5d372b86.yIUKSXpWrhD6XV_uZ1Sk-kb3tJbbBLfdcYML7kWkw40
scenes-app-ai-observability-prompts--empty-state--light:
- hash: v1.k794b7964.7c89cc30eb2e3c2954825c97d74035b5cc1bf6b2e0f3b834bec9af95e4ccd34a.OHsm7KiejL_cG9mSiVzaJiLnIuuRR9fhLdQmOp-9dI8
+ hash: v1.k794b7964.59b3b3f6cff7db50863f7894a3c8ae00774ef5fd96d0607dc68379e0a4e606cc.-uyE1CWJWfnXDndj60yp3prOUr_ZrFSf8Yxxfj2jbj0
scenes-app-ai-observability-prompts--prompts-list--dark:
hash: v1.k794b7964.5cdaae6b72efa77261704903c3b14197bd4996f9db290718a4a585758aaa6cf2.xbF6ujFL2OI5SqKxuBM4wYp4MT4t2IC_HjI5-9mkT4c
scenes-app-ai-observability-prompts--prompts-list--light:
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
index 2cc78f8a47e7..56af6b9c1af8 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
@@ -4,8 +4,12 @@ import type { Mocks } from '~/mocks/utils'
import { actionsEmptyState } from 'products/actions/frontend/emptyState/actionsEmptyState'
import { aiObservabilityEmptyState } from 'products/ai_observability/frontend/emptyState/aiObservabilityEmptyState'
+import { clustersEmptyState } from 'products/ai_observability/frontend/emptyState/clustersEmptyState'
+import { datasetsEmptyState } from 'products/ai_observability/frontend/emptyState/datasetsEmptyState'
+import { evaluationsEmptyState } from 'products/ai_observability/frontend/emptyState/evaluationsEmptyState'
import { llmPromptsEmptyState } from 'products/ai_observability/frontend/emptyState/llmPromptsEmptyState'
import { annotationsEmptyState } from 'products/annotations/frontend/emptyState/annotationsEmptyState'
+import { businessKnowledgeEmptyState } from 'products/business_knowledge/frontend/emptyState/businessKnowledgeEmptyState'
import { webScriptsEmptyState } from 'products/cdp/frontend/emptyState/webScriptsEmptyState'
import { cohortsEmptyState } from 'products/cohorts/frontend/emptyState/cohortsEmptyState'
import { supportEmptyState } from 'products/conversations/frontend/emptyState/supportEmptyState'
@@ -116,6 +120,40 @@ export const SkillsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(l
mocks: { get: { '/api/projects/:team_id/llm_skills/': [200, emptyEntityList] } },
})
+export const DatasetsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(datasetsEmptyState, 'needs-setup', {
+ mocks: { get: { '/api/projects/:team_id/datasets/': [200, emptyEntityList] } },
+})
+
+export const EvaluationsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(
+ evaluationsEmptyState,
+ 'needs-setup',
+ {
+ mocks: {
+ get: {
+ '/api/projects/:team_id/evaluations/': [200, emptyEntityList],
+ '/api/projects/:team_id/evaluation_directories/': [200, []],
+ },
+ },
+ }
+)
+
+// Clusters detection is three-state: no AI events, AI events but no clustering run
+// yet, and runs. The default query mock answers the run query with no rows.
+export const ClustersNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(clustersEmptyState, 'needs-setup')
+
+export const ClustersWaitingForData: ProductEmptyStateStory = productEmptyStateStory(
+ clustersEmptyState,
+ 'waiting-for-data'
+)
+
+export const BusinessKnowledgeNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(
+ businessKnowledgeEmptyState,
+ 'needs-setup',
+ {
+ mocks: { get: { '/api/projects/:team_id/business_knowledge/sources/': [200, emptyEntityList] } },
+ }
+)
+
export const EndpointsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(endpointsEmptyState, 'needs-setup', {
mocks: { get: { '/api/projects/:team_id/endpoints/': [200, emptyEntityList] } },
})
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsx
index 034b4d30b192..731e4a780efb 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsx
@@ -1,4 +1,7 @@
import { cleanup, render, screen } from '@testing-library/react'
+import { expectLogic } from 'kea-test-utils'
+
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { useMocks } from '~/mocks/jest'
import { ProductKey } from '~/queries/schema/schema-general'
@@ -89,4 +92,34 @@ describe('ProductEmptyState', () => {
// The hint introduces the action, so it leaves with it rather than dangling.
expect(!!screen.queryByText('Hint')).toBe(expected)
})
+
+ // An install command keyed to `needs-setup` must not survive into `waiting-for-data`:
+ // events already flow, so there is nothing left to install.
+ it.each([
+ ['needs-setup' as const, true],
+ ['waiting-for-data' as const, false],
+ ])('in %s renders a needs-setup-only wizard: %s', async (mode, expected) => {
+ // preflightLogic is already mounted with cloud off; the wizard card only renders on cloud.
+ useMocks({ get: { '/_preflight/': { cloud: true } } })
+ preflightLogic.actions.loadPreflight()
+ await expectLogic(preflightLogic).toDispatchActions(['loadPreflightSuccess'])
+ const modeKeyedConfig: ProductEmptyStateConfig = {
+ ...config,
+ primaryAction: undefined,
+ text: {
+ 'needs-setup': { headline: 'Headline', lead: 'Lead', hint: 'Hint' },
+ 'waiting-for-data': { headline: 'Waiting' },
+ },
+ wizard: { 'needs-setup': { slug: 'experiments' } },
+ }
+
+ render(<ProductEmptyState config={modeKeyedConfig} mode={mode} />)
+
+ if (expected) {
+ expect(await screen.findByLabelText(/Copy command/)).toBeTruthy()
+ } else {
+ expect(screen.queryByLabelText(/Copy command/)).toBeNull()
+ }
+ expect(!!screen.queryByText('Hint')).toBe(expected)
+ })
})
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx
index fb248c3e53b9..6f8dbaa764f5 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx
@@ -17,6 +17,7 @@ import type {
ProductEmptyStateMode,
ProductEmptyStatePrimaryAction,
ProductEmptyStateText,
+ ProductEmptyStateWizard,
} from './types'
export interface ProductEmptyStateProps {
@@ -37,6 +38,17 @@ function resolvePrimaryAction(
return 'label' in primaryAction ? primaryAction : primaryAction[mode]
}
+/** A single wizard covers every mode; a mode-keyed one applies only to the modes it names. */
+function resolveWizard(
+ wizard: ProductEmptyStateConfig['wizard'],
+ mode: ProductEmptyStateMode
+): ProductEmptyStateWizard | undefined {
+ if (!wizard) {
+ return undefined
+ }
+ return 'slug' in wizard ? wizard : wizard[mode]
+}
+
/**
* The product setup empty state: pitch + install command on the left, an animated
* preview of the product filled with example data on the right. Shown before
@@ -44,8 +56,9 @@ function resolvePrimaryAction(
* `emptyState` on the scene's `SceneExport` and the app shell gates for you).
*/
export function ProductEmptyState({ config, mode }: ProductEmptyStateProps): JSX.Element {
- const { wizardCommand, isCloudOrDev } = useWizardCommand(config.wizard?.slug, {
- pinProjectId: config.wizard?.pinProjectId,
+ const wizard = resolveWizard(config.wizard, mode)
+ const { wizardCommand, isCloudOrDev } = useWizardCommand(wizard?.slug, {
+ pinProjectId: wizard?.pinProjectId,
})
const { skipEmptyState } = useActions(productSetupStatusLogic({ productKey: config.productKey }))
@@ -57,7 +70,7 @@ export function ProductEmptyState({ config, mode }: ProductEmptyStateProps): JSX
const text: ProductEmptyStateText = { ...config.text['needs-setup'], ...config.text[mode] }
// Wizard commands only work against cloud; self-hosted falls back to the manual path.
- const showWizard = !!config.wizard && isCloudOrDev
+ const showWizard = !!wizard && isCloudOrDev
const manualUrl = config.manualSetupUrl ?? config.docsUrl
const Hedgehog = config.hedgehog
diff --git a/frontend/src/lib/components/ProductEmptyState/types.ts b/frontend/src/lib/components/ProductEmptyState/types.ts
index 7c9ceee07592..ace07bcaecfd 100644
--- a/frontend/src/lib/components/ProductEmptyState/types.ts
+++ b/frontend/src/lib/components/ProductEmptyState/types.ts
@@ -49,6 +49,14 @@ export interface ProductEmptyStateWizard {
pinProjectId?: boolean
}
+/**
+ * A wizard keyed by mode, mirroring `primaryAction`: a mode left out shows no terminal
+ * card, no manual setup link, and no hint. Key it when the install command stops making
+ * sense once events flow - a product that then only waits on a scheduled job has nothing
+ * left to install.
+ */
+export type ProductEmptyStateWizardByMode = Partial<Record<ProductEmptyStateMode, ProductEmptyStateWizard>>
+
export interface ProductEmptyStateAccessControl {
resourceType: AccessControlResourceType
minAccessLevel: AccessControlLevel
@@ -113,8 +121,11 @@ export interface ProductEmptyStateConfig {
*/
hedgehogPlacement?: 'above' | 'beside'
text: ProductEmptyStateTextByMode
- /** Install-command CTA. Omit for creation-first products (use `primaryAction`) or self-hosted-only flows */
- wizard?: ProductEmptyStateWizard
+ /**
+ * Install-command CTA. Omit for creation-first products (use `primaryAction`) or self-hosted-only flows.
+ * One wizard covers every mode; pass a `ProductEmptyStateWizardByMode` map to show it in some only.
+ */
+ wizard?: ProductEmptyStateWizard | ProductEmptyStateWizardByMode
/**
* Primary CTA for products set up in the UI rather than via the wizard, e.g. "Create your first flag".
* With `wizard` also set, the terminal card stays the hero and this renders as a secondary button
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index b06c4407a881..39859b652125 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -557,6 +557,7 @@ export const productConfiguration: Record<string, any> = {
name: 'Business knowledge',
projectBased: true,
activityScope: 'KnowledgeSource',
+ iconType: 'conversations',
description:
'Upload text, public URLs, or files so PostHog AI can understand your business context, vision, and policies.',
},
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 6fef7c99be5f..4ac1032c1e39 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -40213,6 +40213,7 @@
"llm_analytics",
"alerts",
"annotations",
+ "business_knowledge",
"cohorts",
"comments",
"conversations",
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 65de25f41a11..ce9a259fc1a0 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -10073,6 +10073,7 @@ export enum ProductKey {
AI_OBSERVABILITY = 'llm_analytics',
ALERTS = 'alerts',
ANNOTATIONS = 'annotations',
+ BUSINESS_KNOWLEDGE = 'business_knowledge',
COHORTS = 'cohorts',
COMMENTS = 'comments',
CONVERSATIONS = 'conversations',
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a73fd3e1591a..3229e0499eb6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2609,6 +2609,9 @@ importers:
products/business_knowledge:
dependencies:
+ '@posthog/brand':
+ specifier: 'catalog:'
+ version: 0.11.0([email protected])
'@posthog/icons':
specifier: 'catalog:'
@@ -2636,6 +2639,10 @@ importers:
react:
specifier: 18.3.1
version: 18.3.1
+ devDependencies:
+ kea-test-utils:
+ specifier: 'catalog:'
+ version: 0.2.4([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))
products/canvas:
dependencies:
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index a4ad1ad38ed6..0aad3c879bd2 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -3687,6 +3687,7 @@ class ProductKey(StrEnum):
LLM_ANALYTICS = "llm_analytics"
ALERTS = "alerts"
ANNOTATIONS = "annotations"
+ BUSINESS_KNOWLEDGE = "business_knowledge"
COHORTS = "cohorts"
COMMENTS = "comments"
CONVERSATIONS = "conversations"
diff --git a/products/ai_observability/frontend/clusters/AIObservabilityClustersScene.tsx b/products/ai_observability/frontend/clusters/AIObservabilityClustersScene.tsx
index f1e4b399acc6..ed2582553532 100644
--- a/products/ai_observability/frontend/clusters/AIObservabilityClustersScene.tsx
+++ b/products/ai_observability/frontend/clusters/AIObservabilityClustersScene.tsx
@@ -4,6 +4,7 @@ import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
+import { clustersEmptyState } from '../emptyState/clustersEmptyState'
import { clustersLogic } from './clustersLogic'
import { ClustersView } from './ClustersView'
@@ -11,6 +12,7 @@ export const scene: SceneExport = {
component: AIObservabilityClustersScene,
logic: clustersLogic,
productKey: ProductKey.AI_OBSERVABILITY,
+ emptyState: clustersEmptyState,
}
export function AIObservabilityClustersScene(): JSX.Element {
diff --git a/products/ai_observability/frontend/datasets/AIObservabilityDatasetsScene.tsx b/products/ai_observability/frontend/datasets/AIObservabilityDatasetsScene.tsx
index 9dae027b8756..70b6c9c5e0ad 100644
--- a/products/ai_observability/frontend/datasets/AIObservabilityDatasetsScene.tsx
+++ b/products/ai_observability/frontend/datasets/AIObservabilityDatasetsScene.tsx
@@ -19,6 +19,7 @@ import { toAccessControlLevel } from '~/lib/utils/accessControlUtils'
import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType, type UserBasicType } from '~/types'
+import { datasetsEmptyState } from '../emptyState/datasetsEmptyState'
import type { DatasetReadApi as Dataset } from '../generated/api.schemas'
import { DATASETS_PER_PAGE, aiObservabilityDatasetsLogic, getDatasetDetailUrl } from './aiObservabilityDatasetsLogic'
@@ -26,6 +27,7 @@ export const scene: SceneExport = {
component: AIObservabilityDatasetsScene,
logic: aiObservabilityDatasetsLogic,
productKey: ProductKey.AI_OBSERVABILITY,
+ emptyState: datasetsEmptyState,
}
export function AIObservabilityDatasetsScene(): JSX.Element {
diff --git a/products/ai_observability/frontend/emptyState/ClustersPreview.scss b/products/ai_observability/frontend/emptyState/ClustersPreview.scss
new file mode 100644
index 000000000000..4b8a4b1ae49e
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/ClustersPreview.scss
@@ -0,0 +1,263 @@
+@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
+
+.ClustersPreview {
+ --clusters-preview-accent: var(--empty-state-accent, var(--color-primary-500));
+ --clusters-preview-billing: var(--clusters-preview-accent);
+ --clusters-preview-bugs: var(--color-orange-500);
+ --clusters-preview-howto: var(--color-blue-500);
+
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+
+ // Hidden selected-cluster state. Direct children so `:checked ~` reaches every card.
+ &__radio {
+ position: absolute;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+ opacity: 0;
+ }
+
+ &__plot,
+ &__list,
+ &__detail {
+ overflow: hidden;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ // Per-cluster detail is stacked on one grid cell and crossfaded, so switching
+ // never changes any element's size (no layout shift).
+ &__swap {
+ display: grid;
+ }
+
+ &__swap > * {
+ grid-area: 1 / 1;
+ min-width: 0;
+ }
+
+ &__when-billing,
+ &__when-bugs,
+ &__when-howto {
+ @include preview-swap-hidden;
+ }
+
+ &__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__title {
+ font-size: 0.75rem;
+ font-weight: 600;
+ }
+
+ &__scatter {
+ display: block;
+ width: 100%;
+ height: 120px;
+ padding: 0.25rem 0.5rem;
+ }
+
+ // Unselected clusters fade back; the selected one is painted at full strength below.
+ &__point {
+ opacity: 0.3;
+ transition: opacity 200ms ease;
+ }
+
+ &__group--billing &__point {
+ fill: var(--clusters-preview-billing);
+ }
+
+ &__group--bugs &__point {
+ fill: var(--clusters-preview-bugs);
+ }
+
+ &__group--howto &__point {
+ fill: var(--clusters-preview-howto);
+ }
+
+ &__list {
+ display: flex;
+ flex-direction: column;
+ padding: 0.25rem 0.5rem;
+ }
+
+ &__row {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ padding: 0.4375rem 0.5rem;
+ cursor: pointer;
+ user-select: none;
+ border: 1px solid transparent;
+ border-radius: var(--radius);
+ transition:
+ background-color 150ms ease,
+ border-color 150ms ease;
+ }
+
+ &__row:hover {
+ background: var(--color-bg-fill-highlight-50);
+ }
+
+ &__swatch {
+ flex-shrink: 0;
+ width: 10px;
+ height: 10px;
+ border-radius: 50%;
+
+ &--billing {
+ background: var(--clusters-preview-billing);
+ }
+
+ &--bugs {
+ background: var(--clusters-preview-bugs);
+ }
+
+ &--howto {
+ background: var(--clusters-preview-howto);
+ }
+ }
+
+ &__name {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ font-size: 0.75rem;
+ font-weight: 600;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__share {
+ font-family: var(--font-mono);
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ }
+
+ &__hint,
+ &__listening {
+ padding: 0.375rem 0.5rem;
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ }
+
+ // waiting-for-data: the list ends on a row that reads as "listening".
+ &__listening {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ }
+
+ &__listening-dot {
+ flex-shrink: 0;
+ width: 7px;
+ height: 7px;
+ background: var(--clusters-preview-accent);
+ border-radius: 50%;
+ animation: ClustersPreview__pulse 1.8s ease-in-out infinite;
+ }
+
+ &__detail {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ padding: 0.625rem 0.75rem;
+ }
+
+ &__detail-title {
+ margin-right: 0.5rem;
+ font-size: 0.75rem;
+ font-weight: 600;
+
+ @include preview-accent-text(var(--clusters-preview-accent));
+ }
+
+ &__detail-meta {
+ font-size: 0.6875rem;
+ color: var(--color-text-tertiary);
+ }
+
+ &__sample {
+ overflow: hidden;
+ font-size: 0.6875rem;
+ font-style: italic;
+ color: var(--color-text-secondary);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+}
+
+// Selected cluster, driven purely by the hidden radios.
+
+#clusters-preview-billing:checked ~ * .ClustersPreview__when-billing,
+#clusters-preview-bugs:checked ~ * .ClustersPreview__when-bugs,
+#clusters-preview-howto:checked ~ * .ClustersPreview__when-howto {
+ @include preview-swap-visible;
+}
+
+#clusters-preview-billing:checked ~ .ClustersPreview__list .ClustersPreview__row--billing,
+#clusters-preview-bugs:checked ~ .ClustersPreview__list .ClustersPreview__row--bugs,
+#clusters-preview-howto:checked ~ .ClustersPreview__list .ClustersPreview__row--howto {
+ background: color-mix(in oklab, var(--clusters-preview-accent) 8%, transparent);
+ border-color: color-mix(in oklab, var(--clusters-preview-accent) 40%, transparent);
+}
+
+#clusters-preview-billing:checked ~ .ClustersPreview__plot .ClustersPreview__group--billing .ClustersPreview__point,
+#clusters-preview-bugs:checked ~ .ClustersPreview__plot .ClustersPreview__group--bugs .ClustersPreview__point,
+#clusters-preview-howto:checked ~ .ClustersPreview__plot .ClustersPreview__group--howto .ClustersPreview__point {
+ opacity: 1;
+}
+
+// The ambient bit: one trace in the selected cluster keeps arriving.
+.ClustersPreview:not(.ClustersPreview--static) {
+ #clusters-preview-billing:checked ~ .ClustersPreview__plot .ClustersPreview__group--billing,
+ #clusters-preview-bugs:checked ~ .ClustersPreview__plot .ClustersPreview__group--bugs,
+ #clusters-preview-howto:checked ~ .ClustersPreview__plot .ClustersPreview__group--howto {
+ .ClustersPreview__point:first-child {
+ transform-box: fill-box;
+ transform-origin: center;
+ animation: ClustersPreview__arrive 2.2s ease-in-out infinite;
+ }
+ }
+}
+
+// The radios stay keyboard-focusable while visually hidden, so the row they label
+// needs a visible focus indicator (WCAG 2.4.7).
+#clusters-preview-billing:focus-visible ~ .ClustersPreview__list .ClustersPreview__row--billing,
+#clusters-preview-bugs:focus-visible ~ .ClustersPreview__list .ClustersPreview__row--bugs,
+#clusters-preview-howto:focus-visible ~ .ClustersPreview__list .ClustersPreview__row--howto {
+ outline: 2px solid var(--clusters-preview-accent);
+ outline-offset: 1px;
+}
+
+@keyframes ClustersPreview__arrive {
+ 0%,
+ 100% {
+ transform: scale(1);
+ }
+
+ 50% {
+ transform: scale(1.8);
+ }
+}
+
+@keyframes ClustersPreview__pulse {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--clusters-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--clusters-preview-accent) 0%, transparent);
+ }
+}
+
+@include preview-motion-guards('ClustersPreview');
diff --git a/products/ai_observability/frontend/emptyState/ClustersPreview.tsx b/products/ai_observability/frontend/emptyState/ClustersPreview.tsx
new file mode 100644
index 000000000000..bd461e281aa3
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/ClustersPreview.tsx
@@ -0,0 +1,161 @@
+import './ClustersPreview.scss'
+
+import type { ProductEmptyStateMode } from 'lib/components/ProductEmptyState/types'
+import { LemonTag } from 'lib/lemon-ui/LemonTag'
+import { cn } from 'lib/utils/css-classes'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+
+interface PreviewCluster {
+ id: string
+ name: string
+ share: string
+ traces: number
+ sample: string
+ /** Scatter positions in the 200x110 viewBox. */
+ points: [number, number][]
+}
+
+// Example clusters - hand-authored, not real data. `id` keys the radio that drives
+// the `:checked ~` selection styles and the highlighted dots.
+const CLUSTERS: PreviewCluster[] = [
+ {
+ id: 'billing',
+ name: 'Billing questions',
+ share: '38%',
+ traces: 412,
+ sample: '"Why did my invoice go up this month?"',
+ points: [
+ [38, 34],
+ [46, 22],
+ [52, 40],
+ [30, 48],
+ [58, 30],
+ [42, 54],
+ [64, 46],
+ [34, 20],
+ [50, 58],
+ [26, 34],
+ ],
+ },
+ {
+ id: 'bugs',
+ name: 'Bug reports',
+ share: '27%',
+ traces: 291,
+ sample: '"The export button does nothing on Safari"',
+ points: [
+ [132, 28],
+ [144, 40],
+ [124, 44],
+ [150, 24],
+ [138, 56],
+ [158, 46],
+ [128, 18],
+ [162, 32],
+ ],
+ },
+ {
+ id: 'howto',
+ name: 'Feature how-tos',
+ share: '21%',
+ traces: 227,
+ sample: '"How do I share a dashboard with my team?"',
+ points: [
+ [92, 82],
+ [104, 92],
+ [84, 94],
+ [110, 78],
+ [96, 70],
+ [118, 90],
+ [78, 80],
+ ],
+ },
+]
+
+/**
+ * Example-data preview for the clusters empty state: a scatter of traces wired to
+ * the cluster list, so picking a cluster lights up its dots and shows what those
+ * conversations were about. Three hidden radios drive `:checked ~` styles - no
+ * timers or state, per the preview rules in the `building-product-empty-states`
+ * skill. In `waiting-for-data` a pinned row reads as listening for the first run.
+ */
+export function ClustersPreview({ mode }: { mode: ProductEmptyStateMode }): JSX.Element {
+ const isStatic = inStorybook() || inStorybookTestRunner()
+
+ return (
+ <div className={cn('ClustersPreview', isStatic && 'ClustersPreview--static')}>
+ {CLUSTERS.map((cluster, i) => (
+ <input
+ key={cluster.id}
+ type="radio"
+ name="clusters-preview-cluster"
+ id={`clusters-preview-${cluster.id}`}
+ defaultChecked={i === 0}
+ className="ClustersPreview__radio"
+ />
+ ))}
+
+ <div className="ClustersPreview__plot">
+ <div className="ClustersPreview__head">
+ <span className="ClustersPreview__title">Traces, last 7 days</span>
+ <LemonTag size="small">example data</LemonTag>
+ </div>
+ <svg className="ClustersPreview__scatter" viewBox="0 0 200 110" aria-hidden="true">
+ {CLUSTERS.map((cluster) => (
+ <g key={cluster.id} className={`ClustersPreview__group ClustersPreview__group--${cluster.id}`}>
+ {cluster.points.map(([x, y], i) => (
+ <circle key={i} className="ClustersPreview__point" cx={x} cy={y} r={3.5} />
+ ))}
+ </g>
+ ))}
+ </svg>
+ </div>
+
+ <div className="ClustersPreview__list">
+ {CLUSTERS.map((cluster) => (
+ <label
+ key={cluster.id}
+ htmlFor={`clusters-preview-${cluster.id}`}
+ className={`ClustersPreview__row ClustersPreview__row--${cluster.id}`}
+ >
+ <span
+ className={`ClustersPreview__swatch ClustersPreview__swatch--${cluster.id}`}
+ aria-hidden="true"
+ />
+ <span className="ClustersPreview__name">{cluster.name}</span>
+ <span className="ClustersPreview__share">{cluster.share}</span>
+ </label>
+ ))}
+ {mode === 'waiting-for-data' ? (
+ <div className="ClustersPreview__listening">
+ <span className="ClustersPreview__listening-dot" aria-hidden="true" />
+ Listening for the first clustering run
+ </div>
+ ) : (
+ <div className="ClustersPreview__hint">Select a cluster to see what it groups.</div>
+ )}
+ </div>
+
+ <div className="ClustersPreview__detail">
+ <div className="ClustersPreview__swap">
+ {CLUSTERS.map((cluster) => (
+ <span key={cluster.id} className={`ClustersPreview__when-${cluster.id}`}>
+ <span className="ClustersPreview__detail-title">{cluster.name}</span>
+ <span className="ClustersPreview__detail-meta">{cluster.traces} traces</span>
+ </span>
+ ))}
+ </div>
+ <div className="ClustersPreview__swap">
+ {CLUSTERS.map((cluster) => (
+ <span
+ key={cluster.id}
+ className={`ClustersPreview__sample ClustersPreview__when-${cluster.id}`}
+ >
+ {cluster.sample}
+ </span>
+ ))}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/ai_observability/frontend/emptyState/DatasetsPreview.scss b/products/ai_observability/frontend/emptyState/DatasetsPreview.scss
new file mode 100644
index 000000000000..7ffcc80c6e11
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/DatasetsPreview.scss
@@ -0,0 +1,258 @@
+@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
+
+.DatasetsPreview {
+ --datasets-preview-accent: var(--empty-state-accent, var(--color-primary-500));
+
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+
+ // Hidden selected-dataset state. Direct children of .DatasetsPreview so `:checked ~` reaches both cards.
+ &__radio {
+ position: absolute;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+ opacity: 0;
+ }
+
+ &__list,
+ &__items {
+ overflow: hidden;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ // Per-dataset content is stacked on one grid cell and crossfaded, so switching
+ // datasets never changes any element's size (no layout shift).
+ &__swap {
+ display: grid;
+ }
+
+ &__swap > * {
+ grid-area: 1 / 1;
+ min-width: 0;
+ }
+
+ &__when-support,
+ &__when-refunds,
+ &__when-onboarding {
+ @include preview-swap-hidden;
+ }
+
+ &__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__title {
+ font-size: 0.75rem;
+ font-weight: 600;
+ }
+
+ &__count {
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ text-align: right;
+ }
+
+ &__rows {
+ display: flex;
+ flex-direction: column;
+ padding: 0.25rem 0.5rem;
+ }
+
+ &__row {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ padding: 0.4375rem 0.5rem;
+ cursor: pointer;
+ user-select: none;
+ border: 1px solid transparent;
+ border-radius: var(--radius);
+ transition:
+ background-color 150ms ease,
+ border-color 150ms ease;
+ }
+
+ &__row:hover {
+ background: var(--color-bg-fill-highlight-50);
+ }
+
+ &__vradio {
+ position: relative;
+ flex-shrink: 0;
+ width: 12px;
+ height: 12px;
+ border: 1.5px solid var(--datasets-preview-accent);
+ border-radius: 50%;
+
+ &::after {
+ position: absolute;
+ inset: 2px;
+ content: '';
+ background: var(--datasets-preview-accent);
+ border-radius: 50%;
+ transition: transform 150ms ease;
+ transform: scale(0);
+ }
+ }
+
+ &__copy {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ }
+
+ &__name {
+ overflow: hidden;
+ font-size: 0.75rem;
+ font-weight: 600;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__meta {
+ overflow: hidden;
+ font-size: 0.625rem;
+ color: var(--color-text-tertiary);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__hint {
+ padding: 0 0.75rem 0.625rem;
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ }
+
+ // The items table the selected dataset opens.
+ &__cols,
+ &__cells {
+ display: grid;
+ grid-template-columns: 1fr 1.3fr;
+ gap: 0.75rem;
+ padding: 0.375rem 0.75rem;
+ }
+
+ &__cols {
+ font-size: 0.625rem;
+ font-weight: 600;
+ color: var(--color-text-tertiary);
+ text-transform: uppercase;
+ letter-spacing: 0.02em;
+ background: var(--color-bg-surface-secondary);
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__item {
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__input,
+ &__expected {
+ overflow: hidden;
+ font-size: 0.6875rem;
+ line-height: 1.35;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__input {
+ font-family: var(--font-mono);
+ font-weight: 600;
+
+ @include preview-accent-text(var(--datasets-preview-accent));
+ }
+
+ &__expected {
+ color: var(--color-text-secondary);
+ }
+
+ // The ambient bit: an item arriving from a trace, pulsing at the bottom of the table.
+ &__incoming {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ padding: 0.4375rem 0.75rem;
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ background: color-mix(in oklab, var(--datasets-preview-accent) 6%, transparent);
+ }
+
+ &__dot {
+ flex-shrink: 0;
+ width: 7px;
+ height: 7px;
+ background: var(--datasets-preview-accent);
+ border-radius: 50%;
+ animation: DatasetsPreview__pulse 1.8s ease-in-out infinite;
+ }
+}
+
+// Selected dataset, driven purely by the hidden radios.
+
+#datasets-preview-support:checked ~ * .DatasetsPreview__when-support,
+#datasets-preview-refunds:checked ~ * .DatasetsPreview__when-refunds,
+#datasets-preview-onboarding:checked ~ * .DatasetsPreview__when-onboarding {
+ @include preview-swap-visible;
+}
+
+#datasets-preview-support:checked ~ .DatasetsPreview__list .DatasetsPreview__row--support,
+#datasets-preview-refunds:checked ~ .DatasetsPreview__list .DatasetsPreview__row--refunds,
+#datasets-preview-onboarding:checked ~ .DatasetsPreview__list .DatasetsPreview__row--onboarding {
+ background: color-mix(in oklab, var(--datasets-preview-accent) 8%, transparent);
+ border-color: color-mix(in oklab, var(--datasets-preview-accent) 40%, transparent);
+}
+
+#datasets-preview-support:checked ~ .DatasetsPreview__list .DatasetsPreview__vradio--support::after,
+#datasets-preview-refunds:checked ~ .DatasetsPreview__list .DatasetsPreview__vradio--refunds::after,
+#datasets-preview-onboarding:checked ~ .DatasetsPreview__list .DatasetsPreview__vradio--onboarding::after {
+ transform: scale(1);
+}
+
+// The radios stay keyboard-focusable while visually hidden, so the row they label
+// needs a visible focus indicator (WCAG 2.4.7).
+#datasets-preview-support:focus-visible ~ .DatasetsPreview__list .DatasetsPreview__row--support,
+#datasets-preview-refunds:focus-visible ~ .DatasetsPreview__list .DatasetsPreview__row--refunds,
+#datasets-preview-onboarding:focus-visible ~ .DatasetsPreview__list .DatasetsPreview__row--onboarding {
+ outline: 2px solid var(--datasets-preview-accent);
+ outline-offset: 1px;
+}
+
+// Nudge attention at the next dataset's radio until the default selection changes.
+.DatasetsPreview:not(.DatasetsPreview--static)
+ #datasets-preview-support:checked
+ ~ .DatasetsPreview__list
+ .DatasetsPreview__vradio--refunds {
+ animation: DatasetsPreview__nudge 2.4s ease-in-out infinite;
+}
+
+@keyframes DatasetsPreview__nudge {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--datasets-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--datasets-preview-accent) 20%, transparent);
+ }
+}
+
+@keyframes DatasetsPreview__pulse {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--datasets-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--datasets-preview-accent) 0%, transparent);
+ }
+}
+
+@include preview-motion-guards('DatasetsPreview');
diff --git a/products/ai_observability/frontend/emptyState/DatasetsPreview.tsx b/products/ai_observability/frontend/emptyState/DatasetsPreview.tsx
new file mode 100644
index 000000000000..e27cbb8376db
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/DatasetsPreview.tsx
@@ -0,0 +1,152 @@
+import './DatasetsPreview.scss'
+
+import { LemonTag } from 'lib/lemon-ui/LemonTag'
+import { cn } from 'lib/utils/css-classes'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+
+interface PreviewDataset {
+ id: string
+ name: string
+ items: number
+ updated: string
+ rows: { input: string; expected: string }[]
+}
+
+// Example datasets - hand-authored, not real data. `id` keys the radio that drives
+// the `:checked ~` selection styles.
+const DATASETS: PreviewDataset[] = [
+ {
+ id: 'support',
+ name: 'Support replies',
+ items: 48,
+ updated: 'updated 2h ago',
+ rows: [
+ { input: 'How do I export my data?', expected: 'Links to the export docs, mentions CSV and API' },
+ { input: 'Can I pause my subscription?', expected: 'Yes, from billing settings, keeps data for 90 days' },
+ { input: 'Is there a free tier?', expected: 'Yes, with monthly usage limits per product' },
+ ],
+ },
+ {
+ id: 'refunds',
+ name: 'Refund policy Q&A',
+ items: 21,
+ updated: 'updated yesterday',
+ rows: [
+ { input: 'I was charged twice this month', expected: 'Apologize, confirm the duplicate, offer a refund' },
+ { input: 'Refund a plan I cancelled last week?', expected: 'Prorated refund within 14 days of cancelling' },
+ { input: 'Do you refund annual plans?', expected: 'Within 30 days of purchase, in full' },
+ ],
+ },
+ {
+ id: 'onboarding',
+ name: 'Onboarding prompts',
+ items: 33,
+ updated: 'updated 3d ago',
+ rows: [
+ { input: 'Set up tracking on a Next.js app', expected: 'Install steps, provider wrapper, env var' },
+ { input: "My events aren't showing up", expected: 'Check the API key, host, and ad blockers' },
+ { input: 'Invite my team', expected: 'Settings > Members, roles explained' },
+ ],
+ },
+]
+
+/**
+ * Example-data preview for the datasets empty state: the dataset list wired to
+ * the items table it opens, so picking a dataset shows its inputs and expected
+ * outputs. Three hidden radios drive `:checked ~` styles - no timers or state,
+ * per the preview rules in the `building-product-empty-states` skill. Per-dataset
+ * items are stacked in `__swap` grids and crossfaded, so switching never changes
+ * the layout's size.
+ */
+export function DatasetsPreview(): JSX.Element {
+ const isStatic = inStorybook() || inStorybookTestRunner()
+
+ return (
+ <div className={cn('DatasetsPreview', isStatic && 'DatasetsPreview--static')}>
+ {DATASETS.map((dataset, i) => (
+ <input
+ key={dataset.id}
+ type="radio"
+ name="datasets-preview-dataset"
+ id={`datasets-preview-${dataset.id}`}
+ defaultChecked={i === 0}
+ className="DatasetsPreview__radio"
+ />
+ ))}
+
+ <div className="DatasetsPreview__list">
+ <div className="DatasetsPreview__head">
+ <span className="DatasetsPreview__title">Datasets</span>
+ <LemonTag size="small">example data</LemonTag>
+ </div>
+ <div className="DatasetsPreview__rows">
+ {DATASETS.map((dataset) => (
+ <label
+ key={dataset.id}
+ htmlFor={`datasets-preview-${dataset.id}`}
+ className={`DatasetsPreview__row DatasetsPreview__row--${dataset.id}`}
+ >
+ <span
+ className={`DatasetsPreview__vradio DatasetsPreview__vradio--${dataset.id}`}
+ aria-hidden="true"
+ />
+ <span className="DatasetsPreview__copy">
+ <span className="DatasetsPreview__name">{dataset.name}</span>
+ <span className="DatasetsPreview__meta">
+ {dataset.items} items · {dataset.updated}
+ </span>
+ </span>
+ </label>
+ ))}
+ </div>
+ <div className="DatasetsPreview__hint">Select a dataset to open its items.</div>
+ </div>
+
+ <div className="DatasetsPreview__items">
+ <div className="DatasetsPreview__head">
+ <span className="DatasetsPreview__swap">
+ {DATASETS.map((dataset) => (
+ <span
+ key={dataset.id}
+ className={`DatasetsPreview__title DatasetsPreview__when-${dataset.id}`}
+ >
+ {dataset.name}
+ </span>
+ ))}
+ </span>
+ <span className="DatasetsPreview__swap">
+ {DATASETS.map((dataset) => (
+ <span
+ key={dataset.id}
+ className={`DatasetsPreview__count DatasetsPreview__when-${dataset.id}`}
+ >
+ {dataset.items} items
+ </span>
+ ))}
+ </span>
+ </div>
+ <div className="DatasetsPreview__cols">
+ <span>Input</span>
+ <span>Expected output</span>
+ </div>
+ {[0, 1, 2].map((rowIndex) => (
+ <div key={rowIndex} className="DatasetsPreview__swap DatasetsPreview__item">
+ {DATASETS.map((dataset) => (
+ <span
+ key={dataset.id}
+ className={`DatasetsPreview__cells DatasetsPreview__when-${dataset.id}`}
+ >
+ <span className="DatasetsPreview__input">{dataset.rows[rowIndex].input}</span>
+ <span className="DatasetsPreview__expected">{dataset.rows[rowIndex].expected}</span>
+ </span>
+ ))}
+ </div>
+ ))}
+ <div className="DatasetsPreview__incoming">
+ <span className="DatasetsPreview__dot" aria-hidden="true" />
+ New item saved from a trace
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/ai_observability/frontend/emptyState/EvaluationsPreview.scss b/products/ai_observability/frontend/emptyState/EvaluationsPreview.scss
new file mode 100644
index 000000000000..3aa7a994a9c8
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/EvaluationsPreview.scss
@@ -0,0 +1,288 @@
+@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
+
+.EvaluationsPreview {
+ --evaluations-preview-accent: var(--empty-state-accent, var(--color-primary-500));
+
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+
+ // Hidden selected-evaluation state. Direct children so `:checked ~` reaches every card.
+ &__radio {
+ position: absolute;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+ opacity: 0;
+ }
+
+ &__list,
+ &__stats,
+ &__feed {
+ overflow: hidden;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ // Per-evaluation content is stacked on one grid cell and crossfaded, so switching
+ // never changes any element's size (no layout shift).
+ &__swap {
+ display: grid;
+ }
+
+ &__swap > * {
+ grid-area: 1 / 1;
+ min-width: 0;
+ }
+
+ &__when-accuracy,
+ &__when-links,
+ &__when-sentiment {
+ @include preview-swap-hidden;
+ }
+
+ &__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__title {
+ font-size: 0.75rem;
+ font-weight: 600;
+ }
+
+ &__rows {
+ display: flex;
+ flex-direction: column;
+ padding: 0.25rem 0.5rem;
+ }
+
+ &__row {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ padding: 0.4375rem 0.5rem;
+ cursor: pointer;
+ user-select: none;
+ border: 1px solid transparent;
+ border-radius: var(--radius);
+ transition:
+ background-color 150ms ease,
+ border-color 150ms ease;
+ }
+
+ &__row:hover {
+ background: var(--color-bg-fill-highlight-50);
+ }
+
+ &__vradio {
+ position: relative;
+ flex-shrink: 0;
+ width: 12px;
+ height: 12px;
+ border: 1.5px solid var(--evaluations-preview-accent);
+ border-radius: 50%;
+
+ &::after {
+ position: absolute;
+ inset: 2px;
+ content: '';
+ background: var(--evaluations-preview-accent);
+ border-radius: 50%;
+ transition: transform 150ms ease;
+ transform: scale(0);
+ }
+ }
+
+ &__name {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ font-size: 0.75rem;
+ font-weight: 600;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ // "Running" only lights up on the selected row; the others stay muted.
+ &__running {
+ display: flex;
+ gap: 0.3125rem;
+ align-items: center;
+ font-size: 0.625rem;
+ color: var(--color-text-tertiary);
+ }
+
+ &__running-dot {
+ width: 6px;
+ height: 6px;
+ background: var(--color-border-primary);
+ border-radius: 50%;
+ }
+
+ &__hint {
+ padding: 0 0.75rem 0.625rem;
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ }
+
+ &__stats {
+ padding: 0.625rem 0.75rem;
+ }
+
+ &__spark-value {
+ @include preview-accent-text(var(--evaluations-preview-accent));
+ }
+
+ &__chart {
+ display: block;
+ width: 100%;
+ height: 40px;
+ margin-top: 0.375rem;
+ }
+
+ &__bar {
+ opacity: 0.55;
+ fill: var(--evaluations-preview-accent);
+ }
+
+ // The most recent day reads as "live": full strength and breathing.
+ &__bar:last-child {
+ opacity: 1;
+ animation: EvaluationsPreview__breathe 1.8s ease-in-out infinite;
+ }
+
+ &__feed {
+ display: flex;
+ flex-direction: column;
+ }
+
+ &__verdict-row + &__verdict-row {
+ border-top: 1px solid var(--color-border-primary);
+ }
+
+ &__verdict {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ padding: 0.4375rem 0.75rem;
+ }
+
+ &__mark {
+ flex-shrink: 0;
+ width: 16px;
+ height: 16px;
+ font-size: 0.625rem;
+ font-weight: 700;
+ line-height: 16px;
+ text-align: center;
+ border-radius: 50%;
+
+ &--pass {
+ color: var(--color-green-700);
+ background: color-mix(in oklab, var(--color-green-500) 18%, transparent);
+ }
+
+ &--fail {
+ color: var(--color-red-700);
+ background: color-mix(in oklab, var(--color-red-500) 18%, transparent);
+ }
+ }
+
+ &__verdict-text {
+ overflow: hidden;
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ @include preview-sparkline;
+}
+
+// Selected evaluation, driven purely by the hidden radios.
+
+#evaluations-preview-accuracy:checked ~ * .EvaluationsPreview__when-accuracy,
+#evaluations-preview-links:checked ~ * .EvaluationsPreview__when-links,
+#evaluations-preview-sentiment:checked ~ * .EvaluationsPreview__when-sentiment {
+ @include preview-swap-visible;
+}
+
+#evaluations-preview-accuracy:checked ~ .EvaluationsPreview__list .EvaluationsPreview__row--accuracy,
+#evaluations-preview-links:checked ~ .EvaluationsPreview__list .EvaluationsPreview__row--links,
+#evaluations-preview-sentiment:checked ~ .EvaluationsPreview__list .EvaluationsPreview__row--sentiment {
+ background: color-mix(in oklab, var(--evaluations-preview-accent) 8%, transparent);
+ border-color: color-mix(in oklab, var(--evaluations-preview-accent) 40%, transparent);
+
+ // "Running" lights up on the selected row only.
+ .EvaluationsPreview__running {
+ color: var(--color-green-700);
+ }
+
+ .EvaluationsPreview__running-dot {
+ background: var(--color-green-500);
+ animation: EvaluationsPreview__pulse 1.6s ease-in-out infinite;
+ }
+}
+
+#evaluations-preview-accuracy:checked ~ .EvaluationsPreview__list .EvaluationsPreview__vradio--accuracy::after,
+#evaluations-preview-links:checked ~ .EvaluationsPreview__list .EvaluationsPreview__vradio--links::after,
+#evaluations-preview-sentiment:checked ~ .EvaluationsPreview__list .EvaluationsPreview__vradio--sentiment::after {
+ transform: scale(1);
+}
+
+// The radios stay keyboard-focusable while visually hidden, so the row they label
+// needs a visible focus indicator (WCAG 2.4.7).
+#evaluations-preview-accuracy:focus-visible ~ .EvaluationsPreview__list .EvaluationsPreview__row--accuracy,
+#evaluations-preview-links:focus-visible ~ .EvaluationsPreview__list .EvaluationsPreview__row--links,
+#evaluations-preview-sentiment:focus-visible ~ .EvaluationsPreview__list .EvaluationsPreview__row--sentiment {
+ outline: 2px solid var(--evaluations-preview-accent);
+ outline-offset: 1px;
+}
+
+// Nudge attention at the next evaluation's radio until the default selection changes.
+.EvaluationsPreview:not(.EvaluationsPreview--static)
+ #evaluations-preview-accuracy:checked
+ ~ .EvaluationsPreview__list
+ .EvaluationsPreview__vradio--links {
+ animation: EvaluationsPreview__nudge 2.4s ease-in-out infinite;
+}
+
+@keyframes EvaluationsPreview__nudge {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--evaluations-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--evaluations-preview-accent) 20%, transparent);
+ }
+}
+
+@keyframes EvaluationsPreview__pulse {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--color-green-500) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--color-green-500) 0%, transparent);
+ }
+}
+
+@keyframes EvaluationsPreview__breathe {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+
+ 50% {
+ opacity: 0.6;
+ }
+}
+
+@include preview-motion-guards('EvaluationsPreview');
diff --git a/products/ai_observability/frontend/emptyState/EvaluationsPreview.tsx b/products/ai_observability/frontend/emptyState/EvaluationsPreview.tsx
new file mode 100644
index 000000000000..068ff54e318f
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/EvaluationsPreview.tsx
@@ -0,0 +1,188 @@
+import './EvaluationsPreview.scss'
+
+import { LemonTag, LemonTagType } from 'lib/lemon-ui/LemonTag'
+import { cn } from 'lib/utils/css-classes'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+
+interface PreviewEvaluation {
+ id: string
+ name: string
+ /** Evaluator type, tagged the way the templates gallery tags them. */
+ kind: { label: string; tag: LemonTagType }
+ passRate: string
+ /** Seven days of pass rate, 0-100, oldest first. Drives the bar chart. */
+ series: number[]
+ verdicts: { pass: boolean; text: string }[]
+}
+
+// Example evaluations - hand-authored, not real data. `id` keys the radio that
+// drives the `:checked ~` selection styles.
+const EVALUATIONS: PreviewEvaluation[] = [
+ {
+ id: 'accuracy',
+ name: 'Answer accuracy',
+ kind: { label: 'LLM judge', tag: 'caution' },
+ passRate: '94%',
+ series: [81, 84, 88, 86, 91, 93, 94],
+ verdicts: [
+ { pass: true, text: 'Cites the correct refund window' },
+ { pass: false, text: 'Invents a plan tier that does not exist' },
+ { pass: true, text: 'Matches the export docs step by step' },
+ ],
+ },
+ {
+ id: 'links',
+ name: 'Links to the docs',
+ kind: { label: 'Hog', tag: 'option' },
+ passRate: '88%',
+ series: [90, 87, 85, 82, 86, 89, 88],
+ verdicts: [
+ { pass: true, text: 'Reply contains a posthog.com/docs link' },
+ { pass: true, text: 'Links the export guide' },
+ { pass: false, text: 'No docs link in a how-to answer' },
+ ],
+ },
+ {
+ id: 'sentiment',
+ name: 'User sentiment',
+ kind: { label: 'Sentiment', tag: 'success' },
+ passRate: '81%',
+ series: [76, 78, 74, 80, 83, 79, 81],
+ verdicts: [
+ { pass: true, text: 'Positive: "perfect, that fixed it"' },
+ { pass: true, text: 'Neutral: "ok, and the annual plan?"' },
+ { pass: false, text: 'Negative: "this is the third time I ask"' },
+ ],
+ },
+]
+
+const CHART_WIDTH = 140
+const CHART_HEIGHT = 40
+const BAR_GAP = 6
+const BAR_WIDTH = (CHART_WIDTH - BAR_GAP * 6) / 7
+// Pass rates cluster in the 80-100 band, so a chart anchored at 0 reads as flat.
+const CHART_FLOOR = 60
+
+/**
+ * Example-data preview for the evaluations empty state: the evaluation list wired
+ * to a pass-rate card and a verdict feed, so picking an evaluation shows its trend
+ * and its latest judgments. Three hidden radios drive `:checked ~` styles - no
+ * timers or state, per the preview rules in the `building-product-empty-states`
+ * skill. Per-evaluation content is stacked in `__swap` grids and crossfaded, so
+ * switching never changes the layout's size.
+ */
+export function EvaluationsPreview(): JSX.Element {
+ const isStatic = inStorybook() || inStorybookTestRunner()
+
+ return (
+ <div className={cn('EvaluationsPreview', isStatic && 'EvaluationsPreview--static')}>
+ {EVALUATIONS.map((evaluation, i) => (
+ <input
+ key={evaluation.id}
+ type="radio"
+ name="evaluations-preview-evaluation"
+ id={`evaluations-preview-${evaluation.id}`}
+ defaultChecked={i === 0}
+ className="EvaluationsPreview__radio"
+ />
+ ))}
+
+ <div className="EvaluationsPreview__list">
+ <div className="EvaluationsPreview__head">
+ <span className="EvaluationsPreview__title">Evaluations</span>
+ <LemonTag size="small">example data</LemonTag>
+ </div>
+ <div className="EvaluationsPreview__rows">
+ {EVALUATIONS.map((evaluation) => (
+ <label
+ key={evaluation.id}
+ htmlFor={`evaluations-preview-${evaluation.id}`}
+ className={`EvaluationsPreview__row EvaluationsPreview__row--${evaluation.id}`}
+ >
+ <span
+ className={`EvaluationsPreview__vradio EvaluationsPreview__vradio--${evaluation.id}`}
+ aria-hidden="true"
+ />
+ <span className="EvaluationsPreview__name">{evaluation.name}</span>
+ <LemonTag size="small" type={evaluation.kind.tag}>
+ {evaluation.kind.label}
+ </LemonTag>
+ <span className="EvaluationsPreview__running">
+ <span className="EvaluationsPreview__running-dot" aria-hidden="true" />
+ Running
+ </span>
+ </label>
+ ))}
+ </div>
+ <div className="EvaluationsPreview__hint">Select an evaluation to see how it scores.</div>
+ </div>
+
+ <div className="EvaluationsPreview__stats">
+ <div className="EvaluationsPreview__spark-head">
+ <span className="EvaluationsPreview__spark-title">Pass rate, last 7 days</span>
+ </div>
+ <div className="EvaluationsPreview__spark-value EvaluationsPreview__swap">
+ {EVALUATIONS.map((evaluation) => (
+ <span key={evaluation.id} className={`EvaluationsPreview__when-${evaluation.id}`}>
+ {evaluation.passRate}
+ </span>
+ ))}
+ </div>
+ <div className="EvaluationsPreview__swap">
+ {EVALUATIONS.map((evaluation) => (
+ <svg
+ key={evaluation.id}
+ className={`EvaluationsPreview__chart EvaluationsPreview__when-${evaluation.id}`}
+ viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}
+ preserveAspectRatio="none"
+ aria-hidden="true"
+ >
+ {evaluation.series.map((value, i) => {
+ const height = ((value - CHART_FLOOR) / (100 - CHART_FLOOR)) * CHART_HEIGHT
+ return (
+ <rect
+ key={i}
+ className="EvaluationsPreview__bar"
+ x={i * (BAR_WIDTH + BAR_GAP)}
+ y={CHART_HEIGHT - height}
+ width={BAR_WIDTH}
+ height={height}
+ rx={1.5}
+ />
+ )
+ })}
+ </svg>
+ ))}
+ </div>
+ </div>
+
+ <div className="EvaluationsPreview__feed">
+ {[0, 1, 2].map((rowIndex) => (
+ <div key={rowIndex} className="EvaluationsPreview__swap EvaluationsPreview__verdict-row">
+ {EVALUATIONS.map((evaluation) => {
+ const verdict = evaluation.verdicts[rowIndex]
+ return (
+ <span
+ key={evaluation.id}
+ className={`EvaluationsPreview__verdict EvaluationsPreview__when-${evaluation.id}`}
+ >
+ <span
+ className={cn(
+ 'EvaluationsPreview__mark',
+ verdict.pass
+ ? 'EvaluationsPreview__mark--pass'
+ : 'EvaluationsPreview__mark--fail'
+ )}
+ >
+ {verdict.pass ? '✓' : '✗'}
+ </span>
+ <span className="EvaluationsPreview__verdict-text">{verdict.text}</span>
+ </span>
+ )
+ })}
+ </div>
+ ))}
+ </div>
+ </div>
+ )
+}
diff --git a/products/ai_observability/frontend/emptyState/clustersEmptyState.tsx b/products/ai_observability/frontend/emptyState/clustersEmptyState.tsx
new file mode 100644
index 000000000000..3c83a3366490
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/clustersEmptyState.tsx
@@ -0,0 +1,41 @@
+import * as scientistPng from '@posthog/brand/hoggies/png/scientist'
+import { IconScatter } from '@posthog/icons'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { ClustersPreview } from './ClustersPreview'
+import { clustersSetupLogic } from './clustersSetupLogic'
+
+const HedgehogScientist = pngHoggie(scientistPng)
+
+export const clustersEmptyState: SceneProductEmptyState = {
+ statusLogic: clustersSetupLogic,
+ config: {
+ productKey: ProductKey.LLM_CLUSTERS,
+ productName: 'Clusters',
+ icon: <IconScatter />,
+ accentColor: 'var(--color-product-llm-clusters-light)',
+ accentColorDark: 'var(--color-product-llm-analytics-dark)',
+ hedgehog: HedgehogScientist,
+ text: {
+ 'needs-setup': {
+ headline: 'Find the patterns in how people use your AI',
+ lead: 'Clusters group similar traces, generations, and evaluation results, so you can see what people actually ask for, where conversations go wrong, and which failures repeat. Clustering runs on your AI observability data, so it starts with sending events.',
+ hint: 'Point the setup agent at your project root. Setup costs are on us, no API key needed:',
+ },
+ 'waiting-for-data': {
+ headline: 'AI events are flowing. Waiting for the first clustering run',
+ lead: 'Clustering runs on a schedule and needs enough data to work with: around 1,000 traces or generations in the past week. Once your project reaches that, the first clusters appear after the next run. You can skip ahead to manage clustering jobs in the meantime.',
+ },
+ },
+ // Once AI events flow there is nothing left to install: the wait is on the scheduled run.
+ wizard: { 'needs-setup': { slug: 'ai-observability', pinProjectId: true } },
+ docsUrl: 'https://posthog.com/docs/ai-observability/clusters',
+ manualSetupUrl: 'https://posthog.com/docs/ai-observability/installation',
+ previewLabel: 'Clusters, once your traces are grouped',
+ Preview: ClustersPreview,
+ },
+}
diff --git a/products/ai_observability/frontend/emptyState/clustersSetupLogic.test.ts b/products/ai_observability/frontend/emptyState/clustersSetupLogic.test.ts
new file mode 100644
index 000000000000..f45f70092606
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/clustersSetupLogic.test.ts
@@ -0,0 +1,43 @@
+import { expectLogic } from 'kea-test-utils'
+
+import api from 'lib/api'
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import { hasRecentAIEvents } from '../utils/aiEvents'
+import { clustersSetupLogic } from './clustersSetupLogic'
+
+jest.mock('../utils/aiEvents', () => ({ hasRecentAIEvents: jest.fn() }))
+
+const mockHasRecentAIEvents = hasRecentAIEvents as jest.MockedFunction<typeof hasRecentAIEvents>
+
+// Guards the three-way mapping into the app-wide setup-status layer: if it breaks,
+// the scene empty-state gate strands on its spinner or shows the wrong surface.
+describe('clustersSetupLogic', () => {
+ let querySpy: jest.SpyInstance
+
+ beforeEach(() => {
+ jest.clearAllMocks()
+ querySpy = jest.spyOn(api, 'queryHogQL')
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ querySpy.mockRestore()
+ })
+
+ it.each([
+ [1, false, 'has-data'],
+ [0, true, 'waiting-for-data'],
+ [0, false, 'needs-setup'],
+ ])('pushes %i runs and AI events=%s as status %s', async (runRows, hasAIEvents, expected) => {
+ querySpy.mockResolvedValue({ results: Array.from({ length: runRows }, () => [1]) })
+ mockHasRecentAIEvents.mockResolvedValue(hasAIEvents)
+ const logic = clustersSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.LLM_CLUSTERS }).values.status).toBe(expected)
+ })
+})
diff --git a/products/ai_observability/frontend/emptyState/clustersSetupLogic.ts b/products/ai_observability/frontend/emptyState/clustersSetupLogic.ts
new file mode 100644
index 000000000000..d3db27e84be9
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/clustersSetupLogic.ts
@@ -0,0 +1,35 @@
+import api from 'lib/api'
+import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { hogql } from '~/queries/utils'
+
+import { CLUSTERING_RUNS_LOOKBACK_DAYS } from '../clusters/constants'
+import { hasRecentAIEvents } from '../utils/aiEvents'
+
+const CLUSTERING_RUN_EVENTS = ['$ai_trace_clusters', '$ai_generation_clusters', '$ai_evaluation_clusters']
+
+/**
+ * Setup detection for the clusters empty state. Three-state: a clustering run at
+ * any level → has-data; AI events flowing but no run yet → waiting-for-data (runs
+ * are scheduled, so the first one lags the first trace); no AI events → needs-setup.
+ * The lookback matches the scene's own run query so both agree on "no runs".
+ */
+export const clustersSetupLogic = createSetupDetectionLogic({
+ productKey: ProductKey.LLM_CLUSTERS,
+ path: ['products', 'ai_observability', 'frontend', 'emptyState', 'clustersSetupLogic'],
+ detect: async () => {
+ const response = await api.queryHogQL(
+ hogql`SELECT 1 FROM events WHERE event IN ${CLUSTERING_RUN_EVENTS} AND timestamp >= now() - INTERVAL ${hogql.raw(String(CLUSTERING_RUNS_LOOKBACK_DAYS))} DAY LIMIT 1`,
+ { productKey: ProductKey.AI_OBSERVABILITY, scene: 'AIObservabilityClusters' },
+ { refresh: 'force_blocking' }
+ )
+ if ((response.results?.length ?? 0) > 0) {
+ return 'has-data'
+ }
+ return (await hasRecentAIEvents()) ? 'waiting-for-data' : 'needs-setup'
+ },
+ // Runs are emitted about once a day, so a slow poll is enough to flip the
+ // screen; the wizard flow is what needs the needs-setup → waiting flip.
+ pollIntervalMs: 30000,
+})
diff --git a/products/ai_observability/frontend/emptyState/datasetsEmptyState.tsx b/products/ai_observability/frontend/emptyState/datasetsEmptyState.tsx
new file mode 100644
index 000000000000..0b1f33de7ef9
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/datasetsEmptyState.tsx
@@ -0,0 +1,45 @@
+import * as researchPng from '@posthog/brand/hoggies/png/research'
+import { IconDocument } from '@posthog/icons'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'
+import { urls } from 'scenes/urls'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import { DatasetsPreview } from './DatasetsPreview'
+import { datasetsSetupLogic } from './datasetsSetupLogic'
+
+const HedgehogResearch = pngHoggie(researchPng)
+
+export const datasetsEmptyState: SceneProductEmptyState = {
+ statusLogic: datasetsSetupLogic,
+ config: {
+ productKey: ProductKey.LLM_DATASETS,
+ productName: 'Datasets',
+ icon: <IconDocument />,
+ accentColor: 'var(--color-product-llm-datasets-light)',
+ accentColorDark: 'var(--color-product-llm-analytics-dark)',
+ hedgehog: HedgehogResearch,
+ text: {
+ 'needs-setup': {
+ headline: 'Check changes before they reach production',
+ lead: 'Datasets are the input and output pairs you expect from your AI. Add items manually or save them from production traces. Then pull them in wherever you test changes to catch regressions before they go live.',
+ },
+ },
+ primaryAction: {
+ label: 'Create your first dataset',
+ to: urls.aiObservabilityDataset('new'),
+ accessControl: {
+ resourceType: AccessControlResourceType.LlmAnalytics,
+ minAccessLevel: AccessControlLevel.Editor,
+ },
+ dataAttr: 'create-dataset-button',
+ },
+ docsUrl: 'https://posthog.com/docs/ai-evals/datasets',
+ skippable: false,
+ previewLabel: 'Your datasets, once filled',
+ Preview: DatasetsPreview,
+ },
+}
diff --git a/products/ai_observability/frontend/emptyState/datasetsSetupLogic.test.ts b/products/ai_observability/frontend/emptyState/datasetsSetupLogic.test.ts
new file mode 100644
index 000000000000..38d96af0affc
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/datasetsSetupLogic.test.ts
@@ -0,0 +1,36 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import * as generatedApi from '../generated/api'
+import { datasetsSetupLogic } from './datasetsSetupLogic'
+
+// Guards the mapping into the app-wide setup-status layer: if it breaks, the scene
+// empty-state gate strands on its spinner or shows the wrong surface.
+describe('datasetsSetupLogic', () => {
+ let listSpy: jest.SpyInstance
+
+ beforeEach(() => {
+ listSpy = jest.spyOn(generatedApi, 'datasetsList')
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ listSpy.mockRestore()
+ })
+
+ it.each([
+ [0, 'needs-setup'],
+ [1, 'has-data'],
+ [12, 'has-data'],
+ ])('pushes a dataset count of %i as status %s', async (count, expected) => {
+ listSpy.mockResolvedValue({ count, next: null, previous: null, results: [] })
+ const logic = datasetsSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.LLM_DATASETS }).values.status).toBe(expected)
+ })
+})
diff --git a/products/ai_observability/frontend/emptyState/datasetsSetupLogic.ts b/products/ai_observability/frontend/emptyState/datasetsSetupLogic.ts
new file mode 100644
index 000000000000..7817f624ff2c
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/datasetsSetupLogic.ts
@@ -0,0 +1,20 @@
+import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+import { projectLogic } from 'scenes/projectLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { datasetsList } from '../generated/api'
+
+/**
+ * Setup detection for the datasets empty state. Datasets are a creation-first
+ * product, so "set up" simply means the project has at least one active dataset.
+ */
+export const datasetsSetupLogic = createSetupDetectionLogic({
+ productKey: ProductKey.LLM_DATASETS,
+ path: ['products', 'ai_observability', 'frontend', 'emptyState', 'datasetsSetupLogic'],
+ detect: async () => {
+ const projectId = String(projectLogic.findMounted()?.values.currentProjectId)
+ const response = await datasetsList(projectId, { limit: 1 })
+ return response.count > 0 ? 'has-data' : 'needs-setup'
+ },
+})
diff --git a/products/ai_observability/frontend/emptyState/evaluationsEmptyState.tsx b/products/ai_observability/frontend/emptyState/evaluationsEmptyState.tsx
new file mode 100644
index 000000000000..48028da1e38e
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/evaluationsEmptyState.tsx
@@ -0,0 +1,45 @@
+import * as judgePng from '@posthog/brand/hoggies/png/judge'
+import { IconListCheck } from '@posthog/icons'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'
+import { urls } from 'scenes/urls'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import { EvaluationsPreview } from './EvaluationsPreview'
+import { evaluationsSetupLogic } from './evaluationsSetupLogic'
+
+const HedgehogJudge = pngHoggie(judgePng)
+
+export const evaluationsEmptyState: SceneProductEmptyState = {
+ statusLogic: evaluationsSetupLogic,
+ config: {
+ productKey: ProductKey.LLM_EVALUATIONS,
+ productName: 'Evaluations',
+ icon: <IconListCheck />,
+ accentColor: 'var(--color-product-llm-evaluations-light)',
+ accentColorDark: 'var(--color-product-llm-analytics-dark)',
+ hedgehog: HedgehogJudge,
+ text: {
+ 'needs-setup': {
+ headline: 'Score AI responses as they happen',
+ lead: 'Score your generations, traces, or sessions in production. Use an LLM as a judge, Hog code, or sentiment analysis for a wide range of checks. Start with a template, from scratch, or with PostHog AI, then view pass rates over time and jump straight into the runs that failed.',
+ },
+ },
+ primaryAction: {
+ label: 'Create your first evaluation',
+ to: urls.aiObservabilityEvaluationTemplates(),
+ accessControl: {
+ resourceType: AccessControlResourceType.Evaluation,
+ minAccessLevel: AccessControlLevel.Editor,
+ },
+ dataAttr: 'create-evaluation-button',
+ },
+ docsUrl: 'https://posthog.com/docs/ai-evals/evaluations',
+ skippable: false,
+ previewLabel: 'Your evaluations, once running',
+ Preview: EvaluationsPreview,
+ },
+}
diff --git a/products/ai_observability/frontend/emptyState/evaluationsSetupLogic.test.ts b/products/ai_observability/frontend/emptyState/evaluationsSetupLogic.test.ts
new file mode 100644
index 000000000000..6d3e341f6aaa
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/evaluationsSetupLogic.test.ts
@@ -0,0 +1,40 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import * as generatedApi from '../generated/api'
+import { evaluationsSetupLogic } from './evaluationsSetupLogic'
+
+// Guards the mapping into the app-wide setup-status layer: if it breaks, the scene
+// empty-state gate strands on its spinner or shows the wrong surface.
+describe('evaluationsSetupLogic', () => {
+ let evaluationsSpy: jest.SpyInstance
+ let directoriesSpy: jest.SpyInstance
+
+ beforeEach(() => {
+ evaluationsSpy = jest.spyOn(generatedApi, 'evaluationsList')
+ directoriesSpy = jest.spyOn(generatedApi, 'evaluationDirectoriesList')
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ evaluationsSpy.mockRestore()
+ directoriesSpy.mockRestore()
+ })
+
+ it.each([
+ [0, 0, 'needs-setup'],
+ [1, 0, 'has-data'],
+ [0, 1, 'has-data'],
+ ])('pushes %i evaluations and %i directories as status %s', async (evaluationCount, directoryCount, expected) => {
+ evaluationsSpy.mockResolvedValue({ count: evaluationCount, next: null, previous: null, results: [] })
+ directoriesSpy.mockResolvedValue(Array.from({ length: directoryCount }, (_, i) => ({ id: String(i) })))
+ const logic = evaluationsSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.LLM_EVALUATIONS }).values.status).toBe(expected)
+ })
+})
diff --git a/products/ai_observability/frontend/emptyState/evaluationsSetupLogic.ts b/products/ai_observability/frontend/emptyState/evaluationsSetupLogic.ts
new file mode 100644
index 000000000000..c131d8fa9805
--- /dev/null
+++ b/products/ai_observability/frontend/emptyState/evaluationsSetupLogic.ts
@@ -0,0 +1,24 @@
+import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+import { projectLogic } from 'scenes/projectLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { evaluationDirectoriesList, evaluationsList } from '../generated/api'
+
+/**
+ * Setup detection for the evaluations empty state. Creation-first: an evaluation
+ * or a directory in the project counts as set up, matching the scene's own
+ * "first evaluation" check so a person with only a directory still reaches it.
+ */
+export const evaluationsSetupLogic = createSetupDetectionLogic({
+ productKey: ProductKey.LLM_EVALUATIONS,
+ path: ['products', 'ai_observability', 'frontend', 'emptyState', 'evaluationsSetupLogic'],
+ detect: async () => {
+ const projectId = String(projectLogic.findMounted()?.values.currentProjectId)
+ const [evaluations, directories] = await Promise.all([
+ evaluationsList(projectId, { limit: 1 }),
+ evaluationDirectoriesList(projectId),
+ ])
+ return evaluations.count > 0 || directories.length > 0 ? 'has-data' : 'needs-setup'
+ },
+})
diff --git a/products/ai_observability/frontend/emptyState/llmPromptsEmptyState.tsx b/products/ai_observability/frontend/emptyState/llmPromptsEmptyState.tsx
index 8693d3a4a750..7c1d8073a90e 100644
--- a/products/ai_observability/frontend/emptyState/llmPromptsEmptyState.tsx
+++ b/products/ai_observability/frontend/emptyState/llmPromptsEmptyState.tsx
@@ -25,7 +25,7 @@ export const llmPromptsEmptyState: SceneProductEmptyState = {
text: {
'needs-setup': {
headline: 'Update prompts without redeploying',
- lead: 'Create and version LLM prompts in PostHog, then fetch them from your code at runtime. Every change becomes an immutable version you can compare, restore, and A/B test. Point a label like production at any version to control what your app serves, and move it whenever you want. Prompt management is free.',
+ lead: 'Create, version, and fetch LLM prompts in PostHog, free of charge. A/B test prompts using experiments, and use production labels to only ship changes when you are ready.',
},
},
primaryAction: {
diff --git a/products/ai_observability/frontend/evaluations/AIObservabilityEvaluationsScene.tsx b/products/ai_observability/frontend/evaluations/AIObservabilityEvaluationsScene.tsx
index 7364581649fe..d769b709b85d 100644
--- a/products/ai_observability/frontend/evaluations/AIObservabilityEvaluationsScene.tsx
+++ b/products/ai_observability/frontend/evaluations/AIObservabilityEvaluationsScene.tsx
@@ -46,6 +46,7 @@ import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
+import { evaluationsEmptyState } from '../emptyState/evaluationsEmptyState'
import type { EvaluationDirectoryApi } from '../generated/api.schemas'
import { LLMProviderKey } from '../settings/llmProviderKeysLogic'
import {
@@ -71,6 +72,7 @@ export const scene: SceneExport = {
component: AIObservabilityEvaluationsScene,
logic: llmEvaluationsLogic,
productKey: ProductKey.AI_OBSERVABILITY,
+ emptyState: evaluationsEmptyState,
}
function getActiveTab(
diff --git a/products/business_knowledge/frontend/emptyState/BusinessKnowledgePreview.scss b/products/business_knowledge/frontend/emptyState/BusinessKnowledgePreview.scss
new file mode 100644
index 000000000000..1650d05e9528
--- /dev/null
+++ b/products/business_knowledge/frontend/emptyState/BusinessKnowledgePreview.scss
@@ -0,0 +1,271 @@
+@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
+
+.BusinessKnowledgePreview {
+ --bk-preview-accent: var(--empty-state-accent, var(--color-primary-500));
+
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+
+ // Hidden selected-source state. Direct children so `:checked ~` reaches both cards.
+ &__radio {
+ position: absolute;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+ opacity: 0;
+ }
+
+ &__list,
+ &__thread {
+ overflow: hidden;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ // Per-source messages are stacked on one grid cell and crossfaded, so switching
+ // sources never changes any element's size (no layout shift).
+ &__swap {
+ display: grid;
+ }
+
+ &__swap > * {
+ grid-area: 1 / 1;
+ min-width: 0;
+ }
+
+ &__when-pricing,
+ &__when-refunds,
+ &__when-brand {
+ @include preview-swap-hidden;
+ }
+
+ &__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__title {
+ font-size: 0.75rem;
+ font-weight: 600;
+ }
+
+ &__rows {
+ display: flex;
+ flex-direction: column;
+ padding: 0.25rem 0.5rem;
+ }
+
+ &__row {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ padding: 0.4375rem 0.5rem;
+ cursor: pointer;
+ user-select: none;
+ border: 1px solid transparent;
+ border-radius: var(--radius);
+ transition:
+ background-color 150ms ease,
+ border-color 150ms ease;
+ }
+
+ &__row:hover {
+ background: var(--color-bg-fill-highlight-50);
+ }
+
+ &__vradio {
+ position: relative;
+ flex-shrink: 0;
+ width: 12px;
+ height: 12px;
+ border: 1.5px solid var(--bk-preview-accent);
+ border-radius: 50%;
+
+ &::after {
+ position: absolute;
+ inset: 2px;
+ content: '';
+ background: var(--bk-preview-accent);
+ border-radius: 50%;
+ transition: transform 150ms ease;
+ transform: scale(0);
+ }
+ }
+
+ &__copy {
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ min-width: 0;
+ }
+
+ &__name {
+ overflow: hidden;
+ font-size: 0.75rem;
+ font-weight: 600;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__meta {
+ overflow: hidden;
+ font-size: 0.625rem;
+ color: var(--color-text-tertiary);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__status {
+ display: flex;
+ flex-shrink: 0;
+ gap: 0.3125rem;
+ align-items: center;
+ font-size: 0.625rem;
+ color: var(--color-text-secondary);
+ }
+
+ &__status-dot {
+ width: 6px;
+ height: 6px;
+ background: var(--color-green-500);
+ border-radius: 50%;
+ }
+
+ &__hint {
+ padding: 0 0.75rem 0.625rem;
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ }
+
+ // The mini PostHog AI thread.
+ &__thread {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ padding: 0.75rem;
+ }
+
+ &__bubble {
+ max-width: 92%;
+ padding: 0.5rem 0.625rem;
+ font-size: 0.6875rem;
+ line-height: 1.4;
+ border-radius: var(--radius);
+
+ &--user {
+ align-self: flex-end;
+ color: var(--color-text-primary);
+ background: var(--color-bg-fill-tertiary);
+ }
+
+ &--ai {
+ display: flex;
+ flex-direction: column;
+ gap: 0.375rem;
+ align-self: flex-start;
+ background: color-mix(in oklab, var(--bk-preview-accent) 8%, transparent);
+ border: 1px solid color-mix(in oklab, var(--bk-preview-accent) 30%, transparent);
+ }
+ }
+
+ &__cite {
+ justify-self: start;
+ padding: 0.0625rem 0.375rem;
+ font-size: 0.625rem;
+ font-weight: 600;
+ border: 1px solid color-mix(in oklab, var(--bk-preview-accent) 40%, transparent);
+ border-radius: 999px;
+
+ @include preview-accent-text(var(--bk-preview-accent));
+ }
+
+ // The ambient bit: PostHog AI is still typing.
+ &__cursor {
+ display: inline-block;
+ width: 6px;
+ height: 11px;
+ margin-left: 2px;
+ vertical-align: text-bottom;
+ background: var(--bk-preview-accent);
+ animation: BusinessKnowledgePreview__blink 1.1s step-end infinite;
+ }
+}
+
+// Selected source, driven purely by the hidden radios.
+
+#business-knowledge-preview-pricing:checked ~ * .BusinessKnowledgePreview__when-pricing,
+#business-knowledge-preview-refunds:checked ~ * .BusinessKnowledgePreview__when-refunds,
+#business-knowledge-preview-brand:checked ~ * .BusinessKnowledgePreview__when-brand {
+ @include preview-swap-visible;
+}
+
+#business-knowledge-preview-pricing:checked ~ .BusinessKnowledgePreview__list .BusinessKnowledgePreview__row--pricing,
+#business-knowledge-preview-refunds:checked ~ .BusinessKnowledgePreview__list .BusinessKnowledgePreview__row--refunds,
+#business-knowledge-preview-brand:checked ~ .BusinessKnowledgePreview__list .BusinessKnowledgePreview__row--brand {
+ background: color-mix(in oklab, var(--bk-preview-accent) 8%, transparent);
+ border-color: color-mix(in oklab, var(--bk-preview-accent) 40%, transparent);
+}
+
+#business-knowledge-preview-pricing:checked
+ ~ .BusinessKnowledgePreview__list
+ .BusinessKnowledgePreview__vradio--pricing::after,
+#business-knowledge-preview-refunds:checked
+ ~ .BusinessKnowledgePreview__list
+ .BusinessKnowledgePreview__vradio--refunds::after,
+#business-knowledge-preview-brand:checked
+ ~ .BusinessKnowledgePreview__list
+ .BusinessKnowledgePreview__vradio--brand::after {
+ transform: scale(1);
+}
+
+// The radios stay keyboard-focusable while visually hidden, so the row they label
+// needs a visible focus indicator (WCAG 2.4.7).
+#business-knowledge-preview-pricing:focus-visible
+ ~ .BusinessKnowledgePreview__list
+ .BusinessKnowledgePreview__row--pricing,
+#business-knowledge-preview-refunds:focus-visible
+ ~ .BusinessKnowledgePreview__list
+ .BusinessKnowledgePreview__row--refunds,
+#business-knowledge-preview-brand:focus-visible
+ ~ .BusinessKnowledgePreview__list
+ .BusinessKnowledgePreview__row--brand {
+ outline: 2px solid var(--bk-preview-accent);
+ outline-offset: 1px;
+}
+
+// Nudge attention at the next source's radio until the default selection changes.
+.BusinessKnowledgePreview:not(.BusinessKnowledgePreview--static)
+ #business-knowledge-preview-pricing:checked
+ ~ .BusinessKnowledgePreview__list
+ .BusinessKnowledgePreview__vradio--refunds {
+ animation: BusinessKnowledgePreview__nudge 2.4s ease-in-out infinite;
+}
+
+@keyframes BusinessKnowledgePreview__nudge {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--bk-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--bk-preview-accent) 20%, transparent);
+ }
+}
+
+@keyframes BusinessKnowledgePreview__blink {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+
+ 50% {
+ opacity: 0;
+ }
+}
+
+@include preview-motion-guards('BusinessKnowledgePreview');
diff --git a/products/business_knowledge/frontend/emptyState/BusinessKnowledgePreview.tsx b/products/business_knowledge/frontend/emptyState/BusinessKnowledgePreview.tsx
new file mode 100644
index 000000000000..8de9eac64b8c
--- /dev/null
+++ b/products/business_knowledge/frontend/emptyState/BusinessKnowledgePreview.tsx
@@ -0,0 +1,132 @@
+import './BusinessKnowledgePreview.scss'
+
+import { LemonTag } from 'lib/lemon-ui/LemonTag'
+import { cn } from 'lib/utils/css-classes'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+
+interface PreviewSource {
+ id: string
+ name: string
+ kind: string
+ chunks: number
+ question: string
+ answer: string
+}
+
+// Example sources - hand-authored, not real data. `id` keys the radio that drives
+// the `:checked ~` selection styles.
+const SOURCES: PreviewSource[] = [
+ {
+ id: 'pricing',
+ name: 'Pricing page',
+ kind: 'URL · refreshes daily',
+ chunks: 14,
+ question: 'Which customers are on a plan with usage limits?',
+ answer: 'Your Free plan caps events at 1M a month, so I filtered to organizations on that plan. 212 match.',
+ },
+ {
+ id: 'refunds',
+ name: 'Refund policy',
+ kind: 'Text · manual',
+ chunks: 6,
+ question: 'Draft a reply to a refund request from last week',
+ answer: 'Your policy allows a prorated refund within 14 days of cancelling, so this one qualifies. Here is a draft.',
+ },
+ {
+ id: 'brand',
+ name: 'Brand guidelines',
+ kind: 'PDF · manual',
+ chunks: 9,
+ question: 'Write the survey intro for the new onboarding flow',
+ answer: 'Kept it in sentence case and dropped the exclamation marks, per your voice guide. Two options below.',
+ },
+]
+
+/**
+ * Example-data preview for the business knowledge empty state: the source list
+ * wired to a mini PostHog AI thread, so picking a source shows an answer that
+ * cites it. Three hidden radios drive `:checked ~` styles - no timers or state,
+ * per the preview rules in the `building-product-empty-states` skill. Per-source
+ * messages are stacked in `__swap` grids and crossfaded, so switching never
+ * changes the layout's size.
+ */
+export function BusinessKnowledgePreview(): JSX.Element {
+ const isStatic = inStorybook() || inStorybookTestRunner()
+
+ return (
+ <div className={cn('BusinessKnowledgePreview', isStatic && 'BusinessKnowledgePreview--static')}>
+ {SOURCES.map((source, i) => (
+ <input
+ key={source.id}
+ type="radio"
+ name="business-knowledge-preview-source"
+ id={`business-knowledge-preview-${source.id}`}
+ defaultChecked={i === 0}
+ className="BusinessKnowledgePreview__radio"
+ />
+ ))}
+
+ <div className="BusinessKnowledgePreview__list">
+ <div className="BusinessKnowledgePreview__head">
+ <span className="BusinessKnowledgePreview__title">Sources</span>
+ <LemonTag size="small">example data</LemonTag>
+ </div>
+ <div className="BusinessKnowledgePreview__rows">
+ {SOURCES.map((source) => (
+ <label
+ key={source.id}
+ htmlFor={`business-knowledge-preview-${source.id}`}
+ className={`BusinessKnowledgePreview__row BusinessKnowledgePreview__row--${source.id}`}
+ >
+ <span
+ className={`BusinessKnowledgePreview__vradio BusinessKnowledgePreview__vradio--${source.id}`}
+ aria-hidden="true"
+ />
+ <span className="BusinessKnowledgePreview__copy">
+ <span className="BusinessKnowledgePreview__name">{source.name}</span>
+ <span className="BusinessKnowledgePreview__meta">{source.kind}</span>
+ </span>
+ <span className="BusinessKnowledgePreview__status">
+ <span className="BusinessKnowledgePreview__status-dot" aria-hidden="true" />
+ {source.chunks} chunks
+ </span>
+ </label>
+ ))}
+ </div>
+ <div className="BusinessKnowledgePreview__hint">Select a source to see PostHog AI use it.</div>
+ </div>
+
+ <div className="BusinessKnowledgePreview__thread">
+ <div className="BusinessKnowledgePreview__bubble BusinessKnowledgePreview__bubble--user">
+ <span className="BusinessKnowledgePreview__swap">
+ {SOURCES.map((source) => (
+ <span key={source.id} className={`BusinessKnowledgePreview__when-${source.id}`}>
+ {source.question}
+ </span>
+ ))}
+ </span>
+ </div>
+ <div className="BusinessKnowledgePreview__bubble BusinessKnowledgePreview__bubble--ai">
+ <span className="BusinessKnowledgePreview__swap">
+ {SOURCES.map((source) => (
+ <span key={source.id} className={`BusinessKnowledgePreview__when-${source.id}`}>
+ {source.answer}
+ <span className="BusinessKnowledgePreview__cursor" aria-hidden="true" />
+ </span>
+ ))}
+ </span>
+ <span className="BusinessKnowledgePreview__swap">
+ {SOURCES.map((source) => (
+ <span
+ key={source.id}
+ className={`BusinessKnowledgePreview__cite BusinessKnowledgePreview__when-${source.id}`}
+ >
+ From {source.name}
+ </span>
+ ))}
+ </span>
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/business_knowledge/frontend/emptyState/BusinessKnowledgePrimaryAction.tsx b/products/business_knowledge/frontend/emptyState/BusinessKnowledgePrimaryAction.tsx
new file mode 100644
index 000000000000..7a5ce922440c
--- /dev/null
+++ b/products/business_knowledge/frontend/emptyState/BusinessKnowledgePrimaryAction.tsx
@@ -0,0 +1,32 @@
+import { useActions } from 'kea'
+
+import { IconPlusSmall } from '@posthog/icons'
+
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+
+import { CreateKnowledgeSourceModal } from '../components/CreateKnowledgeSourceModal'
+import { REFRESH_INTERVAL_OPTIONS, businessKnowledgeLogic } from '../scenes/businessKnowledgeLogic'
+
+/**
+ * "Add source" for the business knowledge empty state. The scene normally renders
+ * the create modal, and the gate replaces the scene, so the empty state renders
+ * the modal itself or the button would open nothing.
+ */
+export function BusinessKnowledgePrimaryAction(): JSX.Element {
+ const { openCreateModal } = useActions(businessKnowledgeLogic)
+
+ return (
+ <>
+ <LemonButton
+ type="primary"
+ className="self-start"
+ icon={<IconPlusSmall />}
+ onClick={() => openCreateModal()}
+ data-attr="add-knowledge-source-button"
+ >
+ Add your first source
+ </LemonButton>
+ <CreateKnowledgeSourceModal refreshIntervalOptions={REFRESH_INTERVAL_OPTIONS} />
+ </>
+ )
+}
diff --git a/products/business_knowledge/frontend/emptyState/businessKnowledgeEmptyState.tsx b/products/business_knowledge/frontend/emptyState/businessKnowledgeEmptyState.tsx
new file mode 100644
index 000000000000..bbdc99148ba8
--- /dev/null
+++ b/products/business_knowledge/frontend/emptyState/businessKnowledgeEmptyState.tsx
@@ -0,0 +1,38 @@
+import * as readingIsMagicPng from '@posthog/brand/hoggies/png/reading-is-magic'
+import { IconBook } from '@posthog/icons'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'
+import { FEATURE_FLAGS } from 'lib/constants'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { BusinessKnowledgePreview } from './BusinessKnowledgePreview'
+import { BusinessKnowledgePrimaryAction } from './BusinessKnowledgePrimaryAction'
+import { businessKnowledgeSetupLogic } from './businessKnowledgeSetupLogic'
+
+const HedgehogReading = pngHoggie(readingIsMagicPng)
+
+export const businessKnowledgeEmptyState: SceneProductEmptyState = {
+ statusLogic: businessKnowledgeSetupLogic,
+ // The scene already shows "not found" when the flag is off, so keep the gate behind it.
+ featureFlag: FEATURE_FLAGS.PRODUCT_BUSINESS_KNOWLEDGE,
+ config: {
+ productKey: ProductKey.BUSINESS_KNOWLEDGE,
+ productName: 'Business knowledge',
+ icon: <IconBook />,
+ accentColor: 'var(--color-product-support-light)',
+ accentColorDark: 'var(--color-product-support-dark)',
+ hedgehog: HedgehogReading,
+ text: {
+ 'needs-setup': {
+ headline: 'Teach PostHog AI how your business works',
+ lead: 'Add pricing pages, policies, product docs, or any text, and PostHog AI uses them to answer questions with your context in mind. Sources refresh on a schedule you choose, so answers stay current as your docs change.',
+ },
+ },
+ PrimaryAction: BusinessKnowledgePrimaryAction,
+ skippable: false,
+ previewLabel: 'PostHog AI, once it knows your business',
+ Preview: BusinessKnowledgePreview,
+ },
+}
diff --git a/products/business_knowledge/frontend/emptyState/businessKnowledgeSetupLogic.test.ts b/products/business_knowledge/frontend/emptyState/businessKnowledgeSetupLogic.test.ts
new file mode 100644
index 000000000000..e06c9ec8ad70
--- /dev/null
+++ b/products/business_knowledge/frontend/emptyState/businessKnowledgeSetupLogic.test.ts
@@ -0,0 +1,36 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import * as generatedApi from '../generated/api'
+import { businessKnowledgeSetupLogic } from './businessKnowledgeSetupLogic'
+
+// Guards the mapping into the app-wide setup-status layer: if it breaks, the scene
+// empty-state gate strands on its spinner or shows the wrong surface.
+describe('businessKnowledgeSetupLogic', () => {
+ let listSpy: jest.SpyInstance
+
+ beforeEach(() => {
+ listSpy = jest.spyOn(generatedApi, 'businessKnowledgeSourcesList')
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ listSpy.mockRestore()
+ })
+
+ it.each([
+ [0, 'needs-setup'],
+ [1, 'has-data'],
+ [9, 'has-data'],
+ ])('pushes a source count of %i as status %s', async (count, expected) => {
+ listSpy.mockResolvedValue({ count, next: null, previous: null, results: [] })
+ const logic = businessKnowledgeSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.BUSINESS_KNOWLEDGE }).values.status).toBe(expected)
+ })
+})
diff --git a/products/business_knowledge/frontend/emptyState/businessKnowledgeSetupLogic.ts b/products/business_knowledge/frontend/emptyState/businessKnowledgeSetupLogic.ts
new file mode 100644
index 000000000000..807532227f1a
--- /dev/null
+++ b/products/business_knowledge/frontend/emptyState/businessKnowledgeSetupLogic.ts
@@ -0,0 +1,27 @@
+import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+import { projectLogic } from 'scenes/projectLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { businessKnowledgeSourcesList } from '../generated/api'
+import { businessKnowledgeLogic } from '../scenes/businessKnowledgeLogic'
+
+/**
+ * Setup detection for the business knowledge empty state. Creation-first: one
+ * knowledge source of any type counts as set up. The empty state's own "Add
+ * source" modal submits through the scene logic, so re-detect on those submits.
+ */
+export const businessKnowledgeSetupLogic = createSetupDetectionLogic({
+ productKey: ProductKey.BUSINESS_KNOWLEDGE,
+ path: ['products', 'business_knowledge', 'frontend', 'emptyState', 'businessKnowledgeSetupLogic'],
+ detect: async () => {
+ const projectId = String(projectLogic.findMounted()?.values.currentProjectId)
+ const response = await businessKnowledgeSourcesList(projectId, { limit: 1 })
+ return response.count > 0 ? 'has-data' : 'needs-setup'
+ },
+ recheckActionTypes: () => [
+ businessKnowledgeLogic.actionTypes.submitTextSourceSuccess,
+ businessKnowledgeLogic.actionTypes.submitUrlSourceSuccess,
+ businessKnowledgeLogic.actionTypes.submitFileSourceSuccess,
+ ],
+})
diff --git a/products/business_knowledge/frontend/scenes/BusinessKnowledgeScene.tsx b/products/business_knowledge/frontend/scenes/BusinessKnowledgeScene.tsx
index 718e324b0845..4bf9c81b3491 100644
--- a/products/business_knowledge/frontend/scenes/BusinessKnowledgeScene.tsx
+++ b/products/business_knowledge/frontend/scenes/BusinessKnowledgeScene.tsx
@@ -10,25 +10,25 @@ import { SceneExport } from 'scenes/sceneTypes'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+import { ProductKey } from '~/queries/schema/schema-general'
-import type { RefreshIntervalOption } from '../api'
import { CreateKnowledgeSourceModal } from '../components/CreateKnowledgeSourceModal'
import { EditKnowledgeSourceModal } from '../components/EditKnowledgeSourceModal'
import { RefreshStatusCell } from '../components/RefreshStatusCell'
import { StatusTag } from '../components/StatusTag'
-import { type AggregatedGap, KnowledgeSource, businessKnowledgeLogic } from './businessKnowledgeLogic'
-
-const REFRESH_INTERVAL_OPTIONS: RefreshIntervalOption[] = [
- { value: 'manual', label: 'Manual only' },
- { value: '1h', label: 'Every hour' },
- { value: '6h', label: 'Every 6 hours' },
- { value: '24h', label: 'Every day' },
- { value: '7d', label: 'Every week' },
-]
+import { businessKnowledgeEmptyState } from '../emptyState/businessKnowledgeEmptyState'
+import {
+ type AggregatedGap,
+ KnowledgeSource,
+ REFRESH_INTERVAL_OPTIONS,
+ businessKnowledgeLogic,
+} from './businessKnowledgeLogic'
export const scene: SceneExport = {
component: BusinessKnowledgeScene,
logic: businessKnowledgeLogic,
+ productKey: ProductKey.BUSINESS_KNOWLEDGE,
+ emptyState: businessKnowledgeEmptyState,
}
export function BusinessKnowledgeScene(): JSX.Element {
diff --git a/products/business_knowledge/frontend/scenes/businessKnowledgeLogic.ts b/products/business_knowledge/frontend/scenes/businessKnowledgeLogic.ts
index 1a495d28df62..86a50adb62ae 100644
--- a/products/business_knowledge/frontend/scenes/businessKnowledgeLogic.ts
+++ b/products/business_knowledge/frontend/scenes/businessKnowledgeLogic.ts
@@ -16,7 +16,7 @@ import {
refreshSource,
updateSource,
} from '../api'
-import type { CreateUrlSourcePayload, RefreshIntervalValue, UpdateSourcePayload } from '../api'
+import type { CreateUrlSourcePayload, RefreshIntervalOption, RefreshIntervalValue, UpdateSourcePayload } from '../api'
import {
businessKnowledgeGapSuggestionsAcceptTopicCreate,
businessKnowledgeGapSuggestionsDismissTopicCreate,
@@ -62,6 +62,14 @@ export interface FileSourceFormValues {
export type CreateTab = 'text' | 'url' | 'file'
+export const REFRESH_INTERVAL_OPTIONS: RefreshIntervalOption[] = [
+ { value: 'manual', label: 'Manual only' },
+ { value: '1h', label: 'Every hour' },
+ { value: '6h', label: 'Every 6 hours' },
+ { value: '24h', label: 'Every day' },
+ { value: '7d', label: 'Every week' },
+]
+
const MAX_TEXT_BYTES = 1_000_000
function validateText({ name, text }: TextSourceFormValues): {
diff --git a/products/business_knowledge/manifest.tsx b/products/business_knowledge/manifest.tsx
index 03dbeecc5680..d521eebc9463 100644
--- a/products/business_knowledge/manifest.tsx
+++ b/products/business_knowledge/manifest.tsx
@@ -18,6 +18,7 @@ export const manifest: ProductManifest = {
import: () => import('./frontend/scenes/BusinessKnowledgeScene'),
projectBased: true,
activityScope: 'KnowledgeSource',
+ iconType: 'conversations',
description:
'Upload text, public URLs, or files so PostHog AI can understand your business context, vision, and policies.',
},
diff --git a/products/business_knowledge/package.json b/products/business_knowledge/package.json
index 00bd34ec628d..708efd1a759d 100644
--- a/products/business_knowledge/package.json
+++ b/products/business_knowledge/package.json
@@ -10,7 +10,11 @@
"kea-router": "catalog:",
"posthog-js": "catalog:"
},
+ "devDependencies": {
+ "kea-test-utils": "catalog:"
+ },
"peerDependencies": {
+ "@posthog/brand": "catalog:",
"@posthog/icons": "catalog:",
"@posthog/lemon-ui": "*",
"@types/react": "*",