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): show recommended templates in the evaluations empty state (#121199)

Bernat Torres62dd90a74f2c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index fe030cae2cce..ad4da153f54c 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2345,9 +2345,9 @@ snapshots:
components-product-empty-state--error-tracking-waiting-for-data-new-wizard--light:
hash: v1.k794b7964.1c2478e9c9e74eb47d896585f4f78e377c27a838e4f60cb35f7e685709d4fff9.xW8y7FqybbzrWn2szBUXyfUTJMNMrCVmSVBDVa6Fpbg
components-product-empty-state--evaluations-needs-setup--dark:
- hash: v1.k794b7964.86a1b36b37f9dba0c971d777a8c88d7826037d7555560bb58290f354a4098fa2.yFdmlSWulwx9q7PbzGH5DIbxYeTqN5evO1mASoujGTs
+ hash: v1.k794b7964.47253feb151dd454bb9b923ad4f16c33799adf85cbb71820a1423ac0d0b57879.xtfb6L2QhuISgVONfbXV1Lp3RrCGkaby34U8-TDPhjs
components-product-empty-state--evaluations-needs-setup--light:
- hash: v1.k794b7964.5558ae08fe036047b496a2b39a36103445afb56eda50861dc5e25997994740e8.Nxl8CSYD-xHBRdqky0ya_qSAoIRQcyBFTRgsgarS-BM
+ hash: v1.k794b7964.e24e2db71b56e55358983e0a88c8ce62df3d368fcbe8daf739c79aec47bb0915.cmhpDu6zXhscKt3sf8ylGH5gg9Gc3KjfLPvCbYeboyg
components-product-empty-state--experiments-needs-setup--dark:
hash: v1.k794b7964.2cdc47f158cecd85687618856c238c7ac65456dfa887db9e5e66baa9476cd145.mBKJtWHPn-vr4FCycrTMD2WE4K4a6cOT8SGg4p6MzbE
components-product-empty-state--experiments-needs-setup--light:
diff --git a/products/ai_observability/frontend/emptyState/evaluationsEmptyState.tsx b/products/ai_observability/frontend/emptyState/evaluationsEmptyState.tsx
index cbec165d5806..981317973476 100644
--- a/products/ai_observability/frontend/emptyState/evaluationsEmptyState.tsx
+++ b/products/ai_observability/frontend/emptyState/evaluationsEmptyState.tsx
@@ -8,6 +8,7 @@ import { urls } from 'scenes/urls'
import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
+import { EvaluationQuickStart } from '../evaluations/EvaluationQuickStart'
import { EvaluationsPreview } from './EvaluationsPreview'
import { evaluationsSetupLogic } from './evaluationsSetupLogic'
@@ -37,6 +38,7 @@ export const evaluationsEmptyState: SceneProductEmptyState = {
},
dataAttr: 'create-evaluation-button',
},
+ SetupActions: EvaluationQuickStart,
docsUrl: 'https://posthog.com/docs/ai-evals/evaluations',
skippable: false,
previewLabel: 'Example: how your evaluations will score',
diff --git a/products/ai_observability/frontend/evaluations/EvaluationQuickStart.test.tsx b/products/ai_observability/frontend/evaluations/EvaluationQuickStart.test.tsx
new file mode 100644
index 000000000000..615b3c7c097d
--- /dev/null
+++ b/products/ai_observability/frontend/evaluations/EvaluationQuickStart.test.tsx
@@ -0,0 +1,48 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render } from '@testing-library/react'
+import { router } from 'kea-router'
+
+import { initKeaTests } from '~/test/init'
+import { AccessControlLevel, AccessControlResourceType, AppContext } from '~/types'
+
+import { EvaluationQuickStart } from './EvaluationQuickStart'
+
+describe('EvaluationQuickStart', () => {
+ const originalAppContext = window.POSTHOG_APP_CONTEXT
+
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ window.POSTHOG_APP_CONTEXT = originalAppContext
+ })
+
+ const renderWithAccess = (level: AccessControlLevel): HTMLElement => {
+ window.POSTHOG_APP_CONTEXT = {
+ ...originalAppContext,
+ resource_access_control: {
+ ...originalAppContext?.resource_access_control,
+ [AccessControlResourceType.Evaluation]: level,
+ },
+ } as AppContext
+ return render(<EvaluationQuickStart mode="needs-setup" preview={false} />).container
+ }
+
+ it('opens a new evaluation from the clicked template', () => {
+ const container = renderWithAccess(AccessControlLevel.Editor)
+
+ container.querySelector<HTMLButtonElement>('[data-attr="evaluation-template-sentiment"]')!.click()
+
+ expect(router.values.location.pathname).toContain('/evaluations/new')
+ expect(router.values.searchParams.template).toEqual('sentiment')
+ })
+
+ it('shows no templates to a user who cannot create evaluations', () => {
+ const container = renderWithAccess(AccessControlLevel.Viewer)
+
+ expect(container.querySelector('[data-attr^="evaluation-template-"]')).toBeNull()
+ })
+})
diff --git a/products/ai_observability/frontend/evaluations/EvaluationQuickStart.tsx b/products/ai_observability/frontend/evaluations/EvaluationQuickStart.tsx
new file mode 100644
index 000000000000..eab30345da28
--- /dev/null
+++ b/products/ai_observability/frontend/evaluations/EvaluationQuickStart.tsx
@@ -0,0 +1,68 @@
+import { useActions } from 'kea'
+import { router } from 'kea-router'
+import posthog from 'posthog-js'
+
+import { Link } from '@posthog/lemon-ui'
+
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+import type { ProductEmptyStateMode } from 'lib/components/ProductEmptyState/types'
+import { userHasAccess } from 'lib/utils/accessControlUtils'
+import { urls } from 'scenes/urls'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import { TemplateCard } from './components/TemplateCard'
+import { getEvaluationTemplateSelectionUrl } from './evaluationNavigation'
+import { RECOMMENDED_TEMPLATE_KEYS } from './EvaluationTemplates'
+import { type EvaluationTemplate, defaultEvaluationTemplates } from './templates'
+
+const QUICK_START_TEMPLATES = RECOMMENDED_TEMPLATE_KEYS.slice(0, 4).flatMap((key) =>
+ defaultEvaluationTemplates.filter((template) => template.key === key)
+)
+
+export function EvaluationQuickStart({
+ mode,
+ preview,
+}: {
+ mode: ProductEmptyStateMode
+ preview: boolean
+}): JSX.Element | null {
+ const { reportSetupInteraction } = useActions(productSetupStatusLogic({ productKey: ProductKey.LLM_EVALUATIONS }))
+
+ const selectTemplate = (template: EvaluationTemplate, placement: 'card' | 'example'): void => {
+ // pinned: same analytics event as the template picker, so template funnels count both entry points
+ posthog.capture('llm evaluation template selected', {
+ template_key: template.key,
+ output_type: template.output_type,
+ placement,
+ source: 'empty_state_quick_start',
+ })
+ reportSetupInteraction('template selected', mode, null, preview)
+ router.actions.push(getEvaluationTemplateSelectionUrl(router.values.searchParams, template.key))
+ }
+
+ // Viewers see the disabled primary action instead, because every card opens the creation form.
+ if (!userHasAccess(AccessControlResourceType.Evaluation, AccessControlLevel.Editor)) {
+ return null
+ }
+
+ return (
+ <div className="flex flex-col gap-2">
+ <p className="m-0 text-sm text-secondary">Start from a template or create your own.</p>
+ <div className="flex flex-col gap-2">
+ {QUICK_START_TEMPLATES.map((template) => (
+ <TemplateCard key={template.key} template={template} onSelect={selectTemplate} />
+ ))}
+ </div>
+ <Link
+ to={urls.aiObservabilityEvaluationTemplates()}
+ className="self-start text-sm"
+ data-attr="evaluation-quick-start-more-templates"
+ onClick={() => reportSetupInteraction('more templates clicked', mode, null, preview)}
+ >
+ Or choose from more templates
+ </Link>
+ </div>
+ )
+}
diff --git a/products/ai_observability/frontend/evaluations/EvaluationTemplates.tsx b/products/ai_observability/frontend/evaluations/EvaluationTemplates.tsx
index e7732a7097cd..50a63f288ff9 100644
--- a/products/ai_observability/frontend/evaluations/EvaluationTemplates.tsx
+++ b/products/ai_observability/frontend/evaluations/EvaluationTemplates.tsx
@@ -22,7 +22,7 @@ const POPULAR_TEMPLATE_KEYS = ['relevance', 'cost_latency', 'helpfulness', 'hall
// Sentiment leads because more teams run sentiment checks than any other kind.
// The score and category templates complete the first row so people discover those output types.
// The second row holds the other templates that people most often keep running.
-const RECOMMENDED_TEMPLATE_KEYS = [
+export const RECOMMENDED_TEMPLATE_KEYS = [
'sentiment',
'response_quality',
'task_outcome',
diff --git a/products/ai_observability/frontend/evaluations/components/TemplateCard.tsx b/products/ai_observability/frontend/evaluations/components/TemplateCard.tsx
index 571e94872172..8903cb0f4dbf 100644
--- a/products/ai_observability/frontend/evaluations/components/TemplateCard.tsx
+++ b/products/ai_observability/frontend/evaluations/components/TemplateCard.tsx
@@ -49,7 +49,8 @@ export function TemplateCard({
{METHOD_TAGS[template.evaluation_type]}
</LemonTag>
</div>
- <p className="m-0 text-xs text-secondary line-clamp-2">{template.description}</p>
+ {/* As a flex item with hidden overflow, the description would shrink in a short card and cut its clamped lines in half. */}
+ <p className="m-0 shrink-0 text-xs text-secondary line-clamp-2">{template.description}</p>
<div className="flex items-center justify-between gap-2 mt-auto pt-1">
<span className="text-xs text-muted truncate">{templateOutputText(template)}</span>
<div className="relative z-10 shrink-0">