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(annotations): replace the intro card with the product empty state (#91046)

Rafael Audibert71b5e6c616f7
diff --git a/docs/internal/product-empty-state-adoption.md b/docs/internal/product-empty-state-adoption.md
index 5364f720e837..4c326cf7b1eb 100644
--- a/docs/internal/product-empty-state-adoption.md
+++ b/docs/internal/product-empty-state-adoption.md
@@ -62,6 +62,7 @@ Rows marked "in review" are not on `master` yet. See "Regenerating the lists" fo
| Marketing analytics | `frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx` | in review |
| Customer analytics | `products/customer_analytics/frontend/CustomerAnalyticsScene.tsx` | in review |
| Actions | `products/actions/frontend/pages/Actions.tsx` | on master |
+| Annotations | `frontend/src/scenes/annotations/Annotations.tsx` | on master |
Only four products resolve their status at app boot, via a `setupProbe` in their manifest:
LLM analytics, error tracking, MCP analytics, web analytics.
@@ -81,7 +82,6 @@ These are the scenes a new user is most likely to land on before they have data.
| Dashboards | `frontend/src/scenes/dashboard/dashboards/Dashboards.tsx` | `ProductIntroduction` |
| Single empty dashboard | `frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx` | `ProductIntroduction` |
| Cohorts | `frontend/src/scenes/cohorts/Cohorts.tsx` | `ProductIntroduction`, plus a second table-level empty state |
-| Annotations | `frontend/src/scenes/annotations/Annotations.tsx` | `ProductIntroduction` |
### Tier 2: cheap, or actively misleading today
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2238712b4068..0107ffd203d4 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1760,6 +1760,10 @@ snapshots:
hash: v1.k794b7964.f10735d00b8b7484f071fdcaebec654ef0042bf7894e374cbe077acb88d1de1f.DVP2UF6lwJvd5PyN12NBZIhS9EOv5z-N0T-aYKrAONw
components-product-empty-state--ai-observability-needs-setup--light:
hash: v1.k794b7964.356081f2e978bf91130ebf0aa39fdc921a169780d2c3b9e289191d40dc73f6f1.nOlwt03p_7y2o0g2xV7835qBylZDe7uIdPxowxXI8mA
+ components-product-empty-state--annotations-needs-setup--dark:
+ 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--early-access-features-needs-setup--dark:
hash: v1.k794b7964.ce612c03290780c1098886d9e2e0f9d920bfa899c591fadfecabf969b1897fe6.RlwNrGim39bhZH0hO39-bt6bWPUPJU-5XgIq2smDxSk
components-product-empty-state--early-access-features-needs-setup--light:
@@ -5921,17 +5925,17 @@ snapshots:
scenes-app-aigateway--page--light:
hash: v1.k794b7964.c0c671f9520955f2d7b427ea9d998cafcaa32498677b7c0c933e887786a016cc.P3yeVak_kL5AjaxOowXaoIxcGpWslxE9XKtHckP1_sk
scenes-app-annotations--annotations--dark:
- hash: v1.k794b7964.ee361eed99f04232ba32af0b7b7e38eb803860ee2faee52e094cf4fd126c30b1.ljX92vC8uyiUAdMxYyoQCDb2U9lqekhny9AhNrfVLpg
+ hash: v1.k794b7964.651aae7146d31971a314f627499eafdaa3d35933cde8dd0ad47abc6eab722148.H9u02T71vFBWS4vd-5sVVqacwrqXc9xeeOHs7b4qnL4
scenes-app-annotations--annotations--light:
- hash: v1.k794b7964.c4cd2e6378d0ca91c00ab119af9a6f90176f22c543a5bd528d5aace6f7b8735d._IB-eDQtHoWcvfVHdowMOuWI_-I4Vl3ocmRFR_9VbQQ
+ hash: v1.k794b7964.3a5efa1132f5645476b02c317d2722c755c8140bd22d7ebef1c3604da56b9a55.gRBLehN4iFhe4hjAdQ-s-Zg7RQ2IRkLELQbilD82l1M
scenes-app-annotations--new-annotation-modal-lemon-ui-date-picker--dark:
- hash: v1.k794b7964.2897b63eec94e0010603ce742c62307857482ed93c1d452b6c818c23582b60d7.Ly2KAZSnvkoh4VAkutRET8VyxM-u4RIlot2dAGerRME
+ hash: v1.k794b7964.836ed57b5116ea3e1d1c0923300e519670dbb31441d8321bec780c008ae61ae2.8xyGCATTfXtnncf1B0NYPs1eEusfJ3Ok5yQGE3orjUQ
scenes-app-annotations--new-annotation-modal-lemon-ui-date-picker--light:
- hash: v1.k794b7964.c235866a3fa6b24848866527076439d80e65846ab4eae834d67b5fd5aa8de5f4.vwgbPqvntlUIst3HD7CbT44IUH1x0vb9JVNOgTlfbIw
+ hash: v1.k794b7964.8b698dcaeb714e79114d305797220cba14a23c9945c3f53638294613d5630d3e.V426gKG2RQf3uR7Jt_9BpRewHHeFa0D3V7OP52NqOvQ
scenes-app-annotations--new-annotation-modal-quill-date-picker--dark:
- hash: v1.k794b7964.a107ec4f1a5d1a0c2bfc855af287d11950a5b9200282d85dfb623850c70a9079.uk9yTbLgIwALjw2ehSojXRAyCVuuCmr3w-nvQkB639E
+ hash: v1.k794b7964.d0203fea61aee15ac584fa0386834615751bbcd6f50aaaaed4dc111bfc2ef8bd.g6BEMBzNGgJVhCuR9doqE1sIWiy7hlLu09s9XtmFwnw
scenes-app-annotations--new-annotation-modal-quill-date-picker--light:
- hash: v1.k794b7964.609c7911fc3a6ae0bee8e425a7e3a3d40f1efa271688392ca1c36892188cf7ff.JLaAMu0jmyaXXVcU02Yg69waPQyMxjoBu_4Nd9QBURI
+ hash: v1.k794b7964.80e951d6a80390a8f78649dd20bd3a267d638faa180f57fd4250f2af89a02d1b.JtotgGUtEhBga78Cwphlhyy7Pxp5GHq752kJAPiyRnQ
scenes-app-batchexports--backfills-empty--dark:
hash: v1.k794b7964.8addbab5dc9322002703f43982a0f950666fd19066808134206cf88a4d3fca23.rQn27PGaf9lf989r2DJBj1BYEWNECVUB8h3wcMgQo5c
scenes-app-batchexports--backfills-empty--light:
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
index fe27b75c2af9..8b345b5264c6 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
@@ -5,6 +5,7 @@ import type { Mocks } from '~/mocks/utils'
import { actionsEmptyState } from 'products/actions/frontend/emptyState/actionsEmptyState'
import { aiObservabilityEmptyState } from 'products/ai_observability/frontend/emptyState/aiObservabilityEmptyState'
import { llmPromptsEmptyState } from 'products/ai_observability/frontend/emptyState/llmPromptsEmptyState'
+import { annotationsEmptyState } from 'products/annotations/frontend/emptyState/annotationsEmptyState'
import { webScriptsEmptyState } from 'products/cdp/frontend/emptyState/webScriptsEmptyState'
import { supportEmptyState } from 'products/conversations/frontend/emptyState/supportEmptyState'
import { earlyAccessFeaturesEmptyState } from 'products/early_access_features/frontend/emptyState/earlyAccessFeaturesEmptyState'
@@ -179,6 +180,17 @@ export const ActionsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(
mocks: actionsMocks,
})
+// Annotations detection lists annotations on mount - answer "none yet".
+const annotationsMocks = {
+ get: { '/api/projects/:team_id/annotations/': [200, { count: 0, results: [] }] },
+} as const
+
+export const AnnotationsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(
+ annotationsEmptyState,
+ 'needs-setup',
+ { mocks: annotationsMocks }
+)
+
// Error tracking detection asks the issues-exists API on mount - answer "none yet".
const errorTrackingMocks = {
get: { '/api/projects/:team_id/error_tracking/issues/exists/': [200, { exists: false }] },
diff --git a/frontend/src/scenes/annotations/Annotations.tsx b/frontend/src/scenes/annotations/Annotations.tsx
index f74b40cef8db..093108228a26 100644
--- a/frontend/src/scenes/annotations/Annotations.tsx
+++ b/frontend/src/scenes/annotations/Annotations.tsx
@@ -1,12 +1,9 @@
import { useActions, useValues } from 'kea'
-import * as reporterPng from '@posthog/brand/hoggies/png/reporter'
import { IconPencil } from '@posthog/icons'
import { LemonSelect, Link } from '@posthog/lemon-ui'
-import { pngHoggie } from 'lib/brand/hoggies'
import { TextContent } from 'lib/components/Cards/TextCard/TextCard'
-import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
import { TZLabel } from 'lib/components/TZLabel'
@@ -16,7 +13,6 @@ import { createdAtColumn } from 'lib/lemon-ui/LemonTable/columnUtils'
import { LemonTag } from 'lib/lemon-ui/LemonTag/LemonTag'
import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
-import { cn } from 'lib/utils/css-classes'
import { organizationLogic } from 'scenes/organizationLogic'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene, SceneExport } from 'scenes/sceneTypes'
@@ -29,16 +25,17 @@ import { annotationsModel } from '~/models/annotationsModel'
import { ProductKey } from '~/queries/schema/schema-general'
import { AnnotationScope, AnnotationType, InsightShortId } from '~/types'
+import { annotationsEmptyState } from 'products/annotations/frontend/emptyState/annotationsEmptyState'
+
import { AnnotationModal } from './AnnotationModal'
import { annotationModalLogic, annotationScopeToLevel, annotationScopeToName } from './annotationModalLogic'
import { annotationScopesMenuOptions, annotationsLogic } from './annotationsLogic'
-const HedgehogReporter = pngHoggie(reporterPng)
-
export const scene: SceneExport = {
component: Annotations,
logic: annotationsLogic,
productKey: ProductKey.ANNOTATIONS,
+ emptyState: annotationsEmptyState,
}
export function Annotations(): JSX.Element {
@@ -48,7 +45,7 @@ export function Annotations(): JSX.Element {
const { openModalToCreateAnnotation } = useActions(annotationModalLogic)
- const { filteredAnnotations, shouldShowEmptyState, annotationsLoading, scope } = useValues(annotationsLogic)
+ const { filteredAnnotations, annotationsLoading, scope } = useValues(annotationsLogic)
const { setScope } = useActions(annotationsLogic)
const { loadingNext, next } = useValues(annotationsModel)
@@ -189,48 +186,31 @@ export function Annotations(): JSX.Element {
<LemonSelect options={annotationScopesMenuOptions()} value={scope} onSelect={setScope} />
</div>
<div data-attr="annotations-content">
- <div className={cn('mt-4 mb-0 empty:hidden')}>
- <ProductIntroduction
- productName="Annotations"
- productKey={ProductKey.ANNOTATIONS}
- thingName="annotation"
- description="Annotations allow you to mark when certain changes happened so you can easily see how they impacted your metrics."
- docsURL="https://posthog.com/docs/data/annotations"
- action={() => openModalToCreateAnnotation()}
- isEmpty={shouldShowEmptyState}
- customHog={HedgehogReporter}
- mcpSurfaceKey="annotations.create"
- />
- </div>
- {!shouldShowEmptyState && (
- <>
- <LemonTable
- data-attr="annotations-table"
- rowKey="id"
- dataSource={filteredAnnotations}
- columns={columns}
- defaultSorting={{
- columnKey: 'date_marker',
- order: -1,
+ <LemonTable
+ data-attr="annotations-table"
+ rowKey="id"
+ dataSource={filteredAnnotations}
+ columns={columns}
+ defaultSorting={{
+ columnKey: 'date_marker',
+ order: -1,
+ }}
+ noSortingCancellation
+ loading={annotationsLoading}
+ emptyState="No annotations yet"
+ />
+ {next && (
+ <div className="flex justify-center mt-6">
+ <LemonButton
+ type="primary"
+ loading={loadingNext}
+ onClick={(): void => {
+ loadAnnotationsNext()
}}
- noSortingCancellation
- loading={annotationsLoading}
- emptyState="No annotations yet"
- />
- {next && (
- <div className="flex justify-center mt-6">
- <LemonButton
- type="primary"
- loading={loadingNext}
- onClick={(): void => {
- loadAnnotationsNext()
- }}
- >
- Load more annotations
- </LemonButton>
- </div>
- )}
- </>
+ >
+ Load more annotations
+ </LemonButton>
+ </div>
)}
</div>
<AnnotationModal />
diff --git a/frontend/src/scenes/appScenes.ts b/frontend/src/scenes/appScenes.ts
index 96ee37990fe4..ca5470b014ae 100644
--- a/frontend/src/scenes/appScenes.ts
+++ b/frontend/src/scenes/appScenes.ts
@@ -7,6 +7,7 @@ export const appScenes: Record<Scene | string, () => any> = {
...productScenes,
[Scene.AdvancedActivityLogs]: () => import('./audit-logs/AdvancedActivityLogsScene'),
[Scene.AgenticAuthorize]: () => import('./agentic/AgenticAuthorize'),
+ [Scene.Annotations]: () => import('./annotations/Annotations'),
[Scene.Approval]: () => import('./approvals/ApprovalDetail'),
[Scene.AsyncMigrations]: () => import('./instance/AsyncMigrations/AsyncMigrations'),
[Scene.MaterializedColumns]: () => import('./data-management/MaterializedColumns/MaterializedColumns'),
diff --git a/frontend/src/scenes/data-management/DataManagementScene.tsx b/frontend/src/scenes/data-management/DataManagementScene.tsx
index f9f4800731a5..c4ef5b290ce3 100644
--- a/frontend/src/scenes/data-management/DataManagementScene.tsx
+++ b/frontend/src/scenes/data-management/DataManagementScene.tsx
@@ -12,8 +12,6 @@ import { LemonTag } from 'lib/lemon-ui/LemonTag'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { capitalizeFirstLetter } from 'lib/utils/strings'
-import { Annotations } from 'scenes/annotations'
-import { NewAnnotationButton } from 'scenes/annotations/AnnotationModal'
import { Comments } from 'scenes/data-management/comments/Comments'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene, SceneExport } from 'scenes/sceneTypes'
@@ -41,7 +39,6 @@ export enum DataManagementTab {
EventDefinitions = 'events',
PropertyDefinitions = 'properties',
SchemaManagement = 'schema',
- Annotations = 'annotations',
Comments = 'comments',
History = 'history',
IngestionWarnings = 'warnings',
@@ -112,16 +109,6 @@ const tabs: Record<DataManagementTab, TabConfig> = {
content: <SchemaManagement />,
flag: FEATURE_FLAGS.SCHEMA_MANAGEMENT,
},
- [DataManagementTab.Annotations]: {
- url: urls.annotations(),
- content: <Annotations />,
- label: 'Annotations',
- buttons: <NewAnnotationButton />,
- tooltipDocLink: 'https://posthog.com/docs/data/annotations',
- children: {
- [urls.annotation(':id')]: {},
- },
- },
[DataManagementTab.Comments]: {
url: urls.comments(),
content: <Comments />,
@@ -262,15 +249,6 @@ const dataManagementSceneLogic = kea<dataManagementSceneLogicType>([
iconType: sceneConfigurations[Scene.EventDefinition].iconType || 'default_icon_type',
},
]
- } else if (tab === DataManagementTab.Annotations) {
- return [
- {
- key: Scene.Annotations,
- name: sceneConfigurations[Scene.Annotations].name,
- path: urls.annotations(),
- iconType: sceneConfigurations[Scene.Annotations].iconType || 'default_icon_type',
- },
- ]
} else if (tab === DataManagementTab.PropertyDefinitions) {
return [
{
diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.ts
index 2daae1a2bf19..f09b45f3fbda 100644
--- a/frontend/src/scenes/scenes.ts
+++ b/frontend/src/scenes/scenes.ts
@@ -831,8 +831,8 @@ export const routes: Record<string, [Scene | string, string]> = {
[urls.featureFlagsStaffTools()]: ['FeatureFlagsStaffTools' as Scene, 'featureFlagsStaffTools'],
[urls.cohortsStaffTools()]: ['CohortsStaffTools' as Scene, 'cohortsStaffTools'],
[urls.featureFlag(':id')]: [Scene.FeatureFlag, 'featureFlag'],
- [urls.annotations()]: [Scene.DataManagement, 'annotations'],
- [urls.annotation(':id')]: [Scene.DataManagement, 'annotation'],
+ [urls.annotations()]: [Scene.Annotations, 'annotations'],
+ [urls.annotation(':id')]: [Scene.Annotations, 'annotation'],
[urls.comments()]: [Scene.DataManagement, 'comments'],
[urls.variables()]: [Scene.DataManagement, 'variables'],
[urls.variableEdit(':id')]: [Scene.SqlVariableEdit, 'sqlVariableEdit'],
diff --git a/frontend/src/styles/base.scss b/frontend/src/styles/base.scss
index 3c7dc0f38d85..3d1999c33e80 100644
--- a/frontend/src/styles/base.scss
+++ b/frontend/src/styles/base.scss
@@ -366,6 +366,8 @@
--color-product-cohorts-dark: rgb(45 212 191);
--color-product-activity-light: rgb(225 29 72);
--color-product-activity-dark: rgb(251 113 133);
+ --color-product-annotations-light: rgb(124 92 252);
+ --color-product-annotations-dark: rgb(167 139 250);
// Generic brand color assignments
// Change these to change the brand colors
diff --git a/playwright/e2e/annotations.spec.ts b/playwright/e2e/annotations.spec.ts
index eacd914f4231..b290d4f91622 100644
--- a/playwright/e2e/annotations.spec.ts
+++ b/playwright/e2e/annotations.spec.ts
@@ -15,16 +15,18 @@ test.describe('Annotations', () => {
test('Annotations loaded', async ({ page }) => {
// Check that the annotations page loaded with key elements visible.
- // Scope to the scene title — a bare 'Annotations' heading match also hits the
+ // Scope to the scene title, a bare 'Annotations' heading match also hits the
// empty-state "Welcome to Annotations!" h2 (substring match) and trips strict mode.
await expect(page.getByTestId('scene-name').getByRole('heading', { name: 'Annotations' })).toBeVisible()
- await expect(page.getByRole('button', { name: 'New annotation' })).toBeVisible()
- await expect(page.locator('[data-attr="annotations-content"]')).toBeVisible()
+ // The setup empty state replaces the table until the first annotation exists, and
+ // both render a create button under this data-attr. Assert the attr rather than the
+ // label so the check holds whichever of the two the project is currently showing.
+ await expect(page.getByTestId('create-annotation')).toBeVisible()
})
test('Create annotation', async ({ page }) => {
// Wait for the create button to be visible before clicking
- const createButton = page.getByRole('button', { name: 'New annotation' })
+ const createButton = page.getByTestId('create-annotation')
await expect(createButton).toBeVisible()
await createButton.click()
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1dab544fe8bb..bf5f6ff78e13 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -459,7 +459,7 @@ importers:
version: 29.5.14
jest:
specifier: ^29.7.0
jest-junit:
specifier: 'catalog:'
version: 16.0.0
@@ -2495,7 +2495,33 @@ importers:
products/analytics_platform: {}
- products/annotations: {}
+ products/annotations:
+ dependencies:
+ '@posthog/brand':
+ specifier: 'catalog:'
+ version: 0.10.0([email protected])
+ '@posthog/icons':
+ specifier: 'catalog:'
+ '@types/react':
+ specifier: 18.3.27
+ version: 18.3.27
+ clsx:
+ specifier: '*'
+ version: 2.1.1
+ kea:
+ specifier: 'catalog:'
+ version: 4.0.0-pre.6(patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected])
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ devDependencies:
+ '@storybook/react':
+ specifier: 'catalog:'
+ kea-test-utils:
+ specifier: 'catalog:'
+ version: 0.2.4([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))
products/apm: {}
@@ -4917,7 +4943,7 @@ importers:
version: 6.0.3
vite-tsconfig-paths:
specifier: ^5.1.4
vitest:
specifier: ^3.2.4
@@ -4963,7 +4989,7 @@ importers:
version: 6.0.3
vite-tsconfig-paths:
specifier: ^5.1.4
vitest:
specifier: ^3.2.4
diff --git a/products/annotations/frontend/emptyState/AnnotationsPreview.scss b/products/annotations/frontend/emptyState/AnnotationsPreview.scss
new file mode 100644
index 000000000000..887e19ae5834
--- /dev/null
+++ b/products/annotations/frontend/emptyState/AnnotationsPreview.scss
@@ -0,0 +1,256 @@
+@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
+
+.AnnotationPreview {
+ --annotation-preview-accent: var(--empty-state-accent, var(--color-product-annotations-light));
+
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+
+ // Hidden annotated state. A direct child of .AnnotationPreview so `:checked ~` reaches all cards.
+ &__checkbox {
+ position: absolute;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+ opacity: 0;
+ }
+
+ &__chart,
+ &__panel {
+ overflow: hidden;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ // Before/after pairs are stacked on one grid cell and crossfaded, so pinning the
+ // note never changes any element's size (no layout shift).
+ &__swap {
+ display: grid;
+ }
+
+ &__swap > * {
+ grid-area: 1 / 1;
+ min-width: 0;
+ }
+
+ &__when-after {
+ @include preview-swap-hidden;
+ }
+
+ &__when-before {
+ @include preview-swap-visible;
+ }
+
+ &__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;
+ }
+
+ // Chart card
+
+ &__plot {
+ position: relative;
+ padding: 0.75rem 0.75rem 0.25rem;
+ }
+
+ &__spark-area {
+ fill: color-mix(in oklab, var(--annotation-preview-accent) 13%, transparent);
+ stroke: none;
+ }
+
+ &__spark-line {
+ fill: none;
+ stroke: color-mix(in oklab, var(--annotation-preview-accent) 32%, transparent);
+ stroke-width: 2;
+ }
+
+ // The moving bit: a short bright segment cycling along the line.
+ &__spark-trace {
+ fill: none;
+ stroke: var(--annotation-preview-accent);
+ stroke-dasharray: 16 84;
+ stroke-linecap: round;
+ stroke-width: 2;
+ animation: AnnotationPreview__trace 3.2s linear infinite;
+ }
+
+ // The dashed date rule, hidden until the note is pinned.
+ &__marker-line {
+ opacity: 0;
+ stroke: var(--annotation-preview-accent);
+ stroke-dasharray: 3 3;
+ stroke-width: 1;
+ transition: opacity 250ms ease;
+ }
+
+ // 66% matches the marker line's x in the viewBox, so the dot sits on the dip.
+ &__marker {
+ position: absolute;
+ top: 0.5rem;
+ left: calc(0.75rem + 66% - 0.75rem * 1.32);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 1rem;
+ height: 1rem;
+ cursor: pointer;
+ }
+
+ &__marker-dot {
+ width: 9px;
+ height: 9px;
+ background: var(--color-bg-surface-primary);
+ border: 2px solid var(--annotation-preview-accent);
+ border-radius: 50%;
+ transition:
+ background 200ms ease,
+ transform 200ms ease;
+ }
+
+ &__note {
+ margin-top: 0.375rem;
+ font-size: 0.625rem;
+ color: var(--color-text-tertiary);
+ text-align: center;
+ }
+
+ &__note-card {
+ display: inline-flex;
+ gap: 0.375rem;
+ align-items: baseline;
+ justify-self: center;
+ padding: 0.25rem 0.5rem;
+ font-size: 0.625rem;
+ background: color-mix(in oklab, var(--annotation-preview-accent) 10%, var(--color-bg-surface-primary));
+ border: 1px solid color-mix(in oklab, var(--annotation-preview-accent) 30%, transparent);
+ border-radius: var(--radius);
+
+ @include preview-accent-text(var(--annotation-preview-accent));
+ }
+
+ &__note-date {
+ font-weight: 600;
+ }
+
+ &__hint {
+ padding: 0.25rem 0.75rem 0.625rem;
+ font-size: 0.625rem;
+ color: var(--color-text-tertiary);
+ text-align: center;
+ }
+
+ // Annotations list
+
+ &__rows {
+ display: flex;
+ flex-direction: column;
+ padding: 0.25rem 0.5rem;
+ }
+
+ &__row-slot,
+ &__row-spacer {
+ min-height: 1.75rem;
+ }
+
+ &__row {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ gap: 0.5rem;
+ align-items: center;
+ padding: 0.375rem 0.5rem;
+ border-radius: var(--radius);
+ }
+
+ &__row--new {
+ background: color-mix(in oklab, var(--annotation-preview-accent) 8%, transparent);
+ }
+
+ &__flag {
+ width: 3px;
+ height: 12px;
+ background: var(--annotation-preview-accent);
+ border-radius: 999px;
+ }
+
+ &__text {
+ overflow: hidden;
+ font-size: 0.6875rem;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__date {
+ font-size: 0.625rem;
+ font-variant-numeric: tabular-nums;
+ color: var(--color-text-tertiary);
+ white-space: nowrap;
+ }
+
+ @include preview-sparkline;
+}
+
+// Annotated state (user pinned the note)
+
+.AnnotationPreview__checkbox:checked ~ * .AnnotationPreview__when-after {
+ @include preview-swap-visible;
+}
+
+.AnnotationPreview__checkbox:checked ~ * .AnnotationPreview__when-before {
+ @include preview-swap-hidden;
+}
+
+.AnnotationPreview__checkbox:checked ~ .AnnotationPreview__chart .AnnotationPreview__marker-line {
+ opacity: 1;
+}
+
+.AnnotationPreview__checkbox:checked ~ .AnnotationPreview__chart .AnnotationPreview__marker-dot {
+ background: var(--annotation-preview-accent);
+ transform: scale(1.1);
+}
+
+// The checkbox stays keyboard-focusable while visually hidden, so the marker it labels
+// needs a visible focus indicator (WCAG 2.4.7).
+.AnnotationPreview__checkbox:focus-visible ~ .AnnotationPreview__chart .AnnotationPreview__marker-dot {
+ outline: 2px solid var(--annotation-preview-accent);
+ outline-offset: 2px;
+}
+
+// Nudge attention at the marker until it's clicked.
+.AnnotationPreview:not(.AnnotationPreview--static)
+ .AnnotationPreview__checkbox:not(:checked)
+ ~ .AnnotationPreview__chart
+ .AnnotationPreview__marker-dot {
+ animation: AnnotationPreview__pulse 2.4s ease-in-out infinite;
+}
+
+@keyframes AnnotationPreview__pulse {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--annotation-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 5px color-mix(in oklab, var(--annotation-preview-accent) 18%, transparent);
+ }
+}
+
+// pathLength is normalized to 100, so the dash offset loops cleanly regardless of length.
+@keyframes AnnotationPreview__trace {
+ to {
+ stroke-dashoffset: -100;
+ }
+}
+
+// Storybook snapshots and reduced motion drop all ambient motion; clicking the
+// marker still pins the note (transitions only).
+@include preview-motion-guards('AnnotationPreview');
diff --git a/products/annotations/frontend/emptyState/AnnotationsPreview.tsx b/products/annotations/frontend/emptyState/AnnotationsPreview.tsx
new file mode 100644
index 000000000000..0dd523febe5e
--- /dev/null
+++ b/products/annotations/frontend/emptyState/AnnotationsPreview.tsx
@@ -0,0 +1,114 @@
+import './AnnotationsPreview.scss'
+
+import { LemonTag } from 'lib/lemon-ui/LemonTag'
+import { cn } from 'lib/utils/css-classes'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+
+// Hand-authored weekly sign-up series with a visible dip two thirds along, which is
+// the moment the annotation explains.
+const LINE = 'M 0 18 L 14 15 L 28 17 L 42 13 L 56 14 L 66 31 L 80 28 L 100 24'
+
+function areaPath(line: string): string {
+ return `${line} L 100 40 L 0 40 Z`
+}
+
+/**
+ * Example-data preview for the annotations empty state: a chart with an unexplained
+ * dip, and the note that explains it. Clicking the marker pins the annotation - the
+ * flag lands on the dip, the note opens, and the row joins the list below. One hidden
+ * checkbox drives it all via `:checked ~` styles - no timers or state, per the preview
+ * rules in the `building-product-empty-states` skill. Before/after pairs are stacked
+ * in `__swap` grids and crossfaded, so nothing shifts.
+ */
+export function AnnotationsPreview(): JSX.Element {
+ const isStatic = inStorybook() || inStorybookTestRunner()
+
+ return (
+ <div className={cn('AnnotationPreview', isStatic && 'AnnotationPreview--static')}>
+ {/* Annotated state, before all cards so `:checked ~` can style them. */}
+ <input type="checkbox" id="annotation-preview-add" className="AnnotationPreview__checkbox" />
+
+ <div className="AnnotationPreview__chart">
+ <div className="AnnotationPreview__head">
+ <span className="AnnotationPreview__title">Weekly sign-ups</span>
+ <LemonTag size="small">example data</LemonTag>
+ </div>
+
+ <div className="AnnotationPreview__plot">
+ <svg
+ className="AnnotationPreview__spark-svg"
+ viewBox="0 0 100 40"
+ preserveAspectRatio="none"
+ aria-hidden="true"
+ >
+ <path className="AnnotationPreview__spark-area" d={areaPath(LINE)} />
+ <path className="AnnotationPreview__spark-line" d={LINE} vectorEffect="non-scaling-stroke" />
+ <path
+ className="AnnotationPreview__spark-trace"
+ d={LINE}
+ pathLength={100}
+ vectorEffect="non-scaling-stroke"
+ />
+ <line
+ className="AnnotationPreview__marker-line"
+ x1="66"
+ x2="66"
+ y1="0"
+ y2="40"
+ vectorEffect="non-scaling-stroke"
+ />
+ </svg>
+
+ {/* Sits over the dip, at the same x as the marker line. */}
+ <label htmlFor="annotation-preview-add" className="AnnotationPreview__marker">
+ <span className="AnnotationPreview__marker-dot" aria-hidden="true" />
+ </label>
+
+ <div className="AnnotationPreview__note AnnotationPreview__swap">
+ <span className="AnnotationPreview__when-before">Sign-ups dropped 38% this week</span>
+ <span className="AnnotationPreview__note-card AnnotationPreview__when-after">
+ <span className="AnnotationPreview__note-date">Mar 14</span>
+ Pricing page redesign shipped
+ </span>
+ </div>
+ </div>
+
+ <div className="AnnotationPreview__hint AnnotationPreview__swap">
+ <span className="AnnotationPreview__when-before">Click the marker to explain the drop.</span>
+ <span className="AnnotationPreview__when-after">
+ Every chart covering Mar 14 now shows this note. Click again to undo.
+ </span>
+ </div>
+ </div>
+
+ <div className="AnnotationPreview__panel">
+ <div className="AnnotationPreview__head">
+ <span className="AnnotationPreview__title">Annotations</span>
+ </div>
+
+ <div className="AnnotationPreview__rows">
+ {/* Reserved slot: the new row fades in over a spacer of the same
+ height, so the rows below never move. */}
+ <div className="AnnotationPreview__row-slot AnnotationPreview__swap">
+ <span className="AnnotationPreview__row-spacer AnnotationPreview__when-before" />
+ <div className="AnnotationPreview__row AnnotationPreview__row--new AnnotationPreview__when-after">
+ <span className="AnnotationPreview__flag" aria-hidden="true" />
+ <span className="AnnotationPreview__text">Pricing page redesign shipped</span>
+ <span className="AnnotationPreview__date">Mar 14</span>
+ </div>
+ </div>
+ <div className="AnnotationPreview__row">
+ <span className="AnnotationPreview__flag" aria-hidden="true" />
+ <span className="AnnotationPreview__text">Switched onboarding emails on</span>
+ <span className="AnnotationPreview__date">Mar 2</span>
+ </div>
+ <div className="AnnotationPreview__row">
+ <span className="AnnotationPreview__flag" aria-hidden="true" />
+ <span className="AnnotationPreview__text">Launched on Product Hunt</span>
+ <span className="AnnotationPreview__date">Feb 19</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/annotations/frontend/emptyState/AnnotationsPrimaryAction.tsx b/products/annotations/frontend/emptyState/AnnotationsPrimaryAction.tsx
new file mode 100644
index 000000000000..f7692d07eb88
--- /dev/null
+++ b/products/annotations/frontend/emptyState/AnnotationsPrimaryAction.tsx
@@ -0,0 +1,23 @@
+import { useActions } from 'kea'
+
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { AnnotationModal } from 'scenes/annotations/AnnotationModal'
+import { annotationModalLogic } from 'scenes/annotations/annotationModalLogic'
+
+/**
+ * Create button for the annotations empty state. Annotations are created in a modal
+ * that the scene normally renders, and the gate replaces the scene - so the empty
+ * state has to render the modal itself or the button would open nothing.
+ */
+export function AnnotationsPrimaryAction(): JSX.Element {
+ const { openModalToCreateAnnotation } = useActions(annotationModalLogic)
+
+ return (
+ <>
+ <LemonButton type="primary" onClick={() => openModalToCreateAnnotation()} data-attr="create-annotation">
+ Create your first annotation
+ </LemonButton>
+ <AnnotationModal />
+ </>
+ )
+}
diff --git a/products/annotations/frontend/emptyState/annotationsEmptyState.tsx b/products/annotations/frontend/emptyState/annotationsEmptyState.tsx
new file mode 100644
index 000000000000..3208ba7a0095
--- /dev/null
+++ b/products/annotations/frontend/emptyState/annotationsEmptyState.tsx
@@ -0,0 +1,36 @@
+import * as reporterPng from '@posthog/brand/hoggies/png/reporter'
+import { IconNotification } 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 { AnnotationsPreview } from './AnnotationsPreview'
+import { AnnotationsPrimaryAction } from './AnnotationsPrimaryAction'
+import { annotationsSetupLogic } from './annotationsSetupLogic'
+
+const HedgehogReporter = pngHoggie(reporterPng)
+
+export const annotationsEmptyState: SceneProductEmptyState = {
+ statusLogic: annotationsSetupLogic,
+ config: {
+ productKey: ProductKey.ANNOTATIONS,
+ productName: 'Annotations',
+ icon: <IconNotification />,
+ accentColor: 'var(--color-product-annotations-light)',
+ accentColorDark: 'var(--color-product-annotations-dark)',
+ hedgehog: HedgehogReporter,
+ text: {
+ 'needs-setup': {
+ headline: 'Mark the days that explain your charts',
+ lead: 'A spike or a drop usually has a cause: a release, a pricing change, a campaign. Write it down once as an annotation and it shows up on every chart covering that date, so the next person to open the graph reads the reason instead of guessing.',
+ },
+ },
+ PrimaryAction: AnnotationsPrimaryAction,
+ skippable: false,
+ docsUrl: 'https://posthog.com/docs/data/annotations',
+ previewLabel: 'Your annotations, once created',
+ Preview: AnnotationsPreview,
+ },
+}
diff --git a/products/annotations/frontend/emptyState/annotationsSetupLogic.test.ts b/products/annotations/frontend/emptyState/annotationsSetupLogic.test.ts
new file mode 100644
index 000000000000..c59c54f0be96
--- /dev/null
+++ b/products/annotations/frontend/emptyState/annotationsSetupLogic.test.ts
@@ -0,0 +1,59 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+
+import { annotationsModel } from '~/models/annotationsModel'
+import { ProductKey } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import * as generatedApi from '../generated/api'
+import { annotationsSetupLogic } from './annotationsSetupLogic'
+
+// 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('annotationsSetupLogic', () => {
+ let listSpy: jest.SpyInstance
+
+ beforeEach(() => {
+ listSpy = jest.spyOn(generatedApi, 'annotationsList')
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ listSpy.mockRestore()
+ })
+
+ it.each([
+ [0, 'needs-setup'],
+ [1, 'has-data'],
+ [17, 'has-data'],
+ ])('pushes an annotation count of %i as status %s', async (count, expected) => {
+ listSpy.mockResolvedValue({ count, results: [] })
+ const logic = annotationsSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.ANNOTATIONS }).values.status).toBe(expected)
+ })
+
+ it('re-detects when an annotation is created without leaving the scene', async () => {
+ listSpy.mockResolvedValueOnce({ count: 0, results: [] }).mockResolvedValue({ count: 1, results: [] })
+ const logic = annotationsSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.ANNOTATIONS }).values.status).toBe('needs-setup')
+
+ // The empty state's modal appends the annotation in place, so without the recheck
+ // wiring the gate would keep hiding it until the user re-entered the scene.
+ annotationsModel.actions.appendAnnotations([])
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.ANNOTATIONS }).values.status).toBe('has-data')
+ })
+
+ it('fails open to unknown when the count query fails before any answer', async () => {
+ listSpy.mockRejectedValue(new Error('network down'))
+ const logic = annotationsSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.ANNOTATIONS }).values.status).toBe('unknown')
+ })
+})
diff --git a/products/annotations/frontend/emptyState/annotationsSetupLogic.ts b/products/annotations/frontend/emptyState/annotationsSetupLogic.ts
new file mode 100644
index 000000000000..ba311b2c5220
--- /dev/null
+++ b/products/annotations/frontend/emptyState/annotationsSetupLogic.ts
@@ -0,0 +1,25 @@
+import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+import { projectLogic } from 'scenes/projectLogic'
+
+import { annotationsModel } from '~/models/annotationsModel'
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { annotationsList } from '../generated/api'
+
+/**
+ * Setup detection for the annotations empty state. Annotations are a creation-first
+ * product, so "set up" simply means the project has at least one annotation - no
+ * event or traffic signal involved.
+ */
+export const annotationsSetupLogic = createSetupDetectionLogic({
+ productKey: ProductKey.ANNOTATIONS,
+ path: ['products', 'annotations', 'frontend', 'emptyState', 'annotationsSetupLogic'],
+ detect: async () => {
+ const projectId = String(projectLogic.findMounted()?.values.currentProjectId)
+ const response = await annotationsList(projectId, { limit: 1 })
+ return response.count > 0 ? 'has-data' : 'needs-setup'
+ },
+ // The empty state creates the first annotation in a modal, without leaving the scene,
+ // so no remount would re-run detection and the gate would keep hiding what was created.
+ recheckActionTypes: () => [annotationsModel.actionTypes.appendAnnotations],
+})
diff --git a/products/annotations/package.json b/products/annotations/package.json
index 3b99880c0344..dc339f0d78b4 100644
--- a/products/annotations/package.json
+++ b/products/annotations/package.json
@@ -2,5 +2,19 @@
"name": "@posthog/products-annotations",
"scripts": {
"backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/ -v --tb=short"
+ },
+ "dependencies": {
+ "kea": "catalog:"
+ },
+ "devDependencies": {
+ "@storybook/react": "catalog:",
+ "kea-test-utils": "catalog:"
+ },
+ "peerDependencies": {
+ "@posthog/brand": "catalog:",
+ "@posthog/icons": "catalog:",
+ "@types/react": "*",
+ "clsx": "*",
+ "react": "*"
}
}