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(logs): replace the setup prompt with the product empty state (#90608)

Rafael Audibert59050eea8084
diff --git a/docs/internal/product-empty-state-adoption.md b/docs/internal/product-empty-state-adoption.md
index 930600ee1c4f..5364f720e837 100644
--- a/docs/internal/product-empty-state-adoption.md
+++ b/docs/internal/product-empty-state-adoption.md
@@ -51,7 +51,7 @@ Rows marked "in review" are not on `master` yet. See "Regenerating the lists" fo
| User interviews | `products/user_interviews/frontend/UserInterviews.tsx` | on master |
| Web scripts | `frontend/src/scenes/data-pipelines/WebScriptsScene.tsx` | on master |
| Error tracking | `products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx` | on master |
-| Logs | `products/logs/frontend/LogsScene.tsx` | in review |
+| Logs | `products/logs/frontend/LogsScene.tsx` | on master |
| Tracing | `products/tracing/frontend/TracingScene.tsx` | in review |
| Metrics | `products/metrics/frontend/MetricsScene.tsx` | in review |
| Surveys | `frontend/src/scenes/surveys/Surveys.tsx` | in review |
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index cf3d8fb45b19..f3798491c556 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1808,6 +1808,10 @@ snapshots:
hash: v1.k794b7964.185b4c941d3476e16eb8b80411bf3f7da1cb663b74388a4ede2aafeb6a2790f3.-WUfqEIfvblTzH2_907USJIjLuKBmE1An_uf_0Avw7w
components-product-empty-state--llm-prompts-needs-setup--light:
hash: v1.k794b7964.f1455829166714291d8024cd356da16409421f025bdab9345f1d52563d92fe2b.60AARTvAq_U7Kb1gH-DnkTk9ypxPM8g1JT4VCLtuTvo
+ components-product-empty-state--logs-needs-setup--dark:
+ hash: v1.k794b7964.96e30395bc4290ad188a84e94f5d40d46f545a3223e4d13fe44737d322129e2f.kj5dwA7EuPOvu6YfDc2jc2s38u8BfXT1EcfPAMPztuM
+ components-product-empty-state--logs-needs-setup--light:
+ hash: v1.k794b7964.e48c85227bbcc871026a1cdf096c1cf21ab5a0504983d138048258516841b153.p74Gybn8AxHmoKKMNcSfmx6gTus5K56ARAEhsPYcxDY
components-product-empty-state--mcp-analytics-needs-setup--dark:
hash: v1.k794b7964.96d4c2d4afe9d7834d3667aa266bafdcb7f8192e4c51927b7661824c9f982d97.leY0JcEWIDNFZQl9s4uuj96BWBHxb3cYGMaU3rJ0g0k
components-product-empty-state--mcp-analytics-needs-setup--light:
diff --git a/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx b/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx
index 7fb04d38bc69..eb3dde6399f6 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx
@@ -168,7 +168,7 @@ const iconTypes: Record<FileSystemIconType, { icon: JSX.Element; iconColor?: Fil
},
logs: {
icon: <IconLive />,
- iconColor: ['var(--color-product-logs-light)'],
+ iconColor: ['var(--color-product-logs-light)', 'var(--color-product-logs-dark)'],
},
tracing: {
icon: <IconListTree />,
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
index 13f4f9e7def9..fe27b75c2af9 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
@@ -13,6 +13,7 @@ import { errorTrackingEmptyState } from 'products/error_tracking/frontend/emptyS
import { experimentsEmptyState } from 'products/experiments/frontend/emptyState/experimentsEmptyState'
import { featureFlagsEmptyState } from 'products/feature_flags/frontend/emptyState/featureFlagsEmptyState'
import { linksEmptyState } from 'products/links/frontend/emptyState/linksEmptyState'
+import { logsEmptyState } from 'products/logs/frontend/emptyState/logsEmptyState'
import { mcpAnalyticsEmptyState } from 'products/mcp_analytics/frontend/emptyState/mcpAnalyticsEmptyState'
import { productToursEmptyState } from 'products/product_tours/frontend/emptyState/productToursEmptyState'
import { replayVisionEmptyState } from 'products/replay_vision/frontend/emptyState/replayVisionEmptyState'
@@ -194,3 +195,9 @@ export const ErrorTrackingWaitingForData: ProductEmptyStateStory = productEmptyS
'waiting-for-data',
{ mocks: errorTrackingMocks }
)
+
+// Logs detection asks the has-logs API on mount - answer "none yet".
+export const LogsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(logsEmptyState, 'needs-setup', {
+ // nosemgrep: no-environments-api-urls-frontend -- api.logs is env-scoped, so the msw mock must match /api/environments to intercept it
+ mocks: { get: { '/api/environments/:team_id/logs/has_logs': [200, { hasLogs: false }] } },
+})
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index 5efa88ec1db2..5aeead600dc3 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -2294,7 +2294,7 @@ export const getTreeItemsProducts = (): FileSystemImport[] => [
intents: [ProductKey.LOGS],
category: ProductItemCategory.APP_MONITORING,
iconType: 'logs' as FileSystemIconType,
- iconColor: ['var(--color-product-logs-light)'] as FileSystemIconColor,
+ iconColor: ['var(--color-product-logs-light)', 'var(--color-product-logs-dark)'] as FileSystemIconColor,
href: urls.logs(),
sceneKey: 'Logs',
sceneKeys: [
diff --git a/frontend/src/styles/base.scss b/frontend/src/styles/base.scss
index baf3212ffb6d..3c7dc0f38d85 100644
--- a/frontend/src/styles/base.scss
+++ b/frontend/src/styles/base.scss
@@ -323,6 +323,7 @@
--color-product-heatmaps-light: rgb(220 152 16);
--color-product-heatmaps-dark: rgb(247 165 1);
--color-product-logs-light: rgb(214 37 123);
+ --color-product-logs-dark: rgb(240 92 161);
--color-product-marketing-analytics-light: rgb(214 37 123);
--color-product-live-debugger-light: rgb(76 14 200);
--color-product-feature-flags-light: rgb(48 171 198);
diff --git a/products/logs/frontend/LogsScene.tsx b/products/logs/frontend/LogsScene.tsx
index d3ef86e54a8b..35572b8b46a8 100644
--- a/products/logs/frontend/LogsScene.tsx
+++ b/products/logs/frontend/LogsScene.tsx
@@ -1,8 +1,9 @@
import { useActions, useValues } from 'kea'
import posthog from 'posthog-js'
-import { LemonBanner, LemonButton, LemonTabs } from '@posthog/lemon-ui'
+import { LemonButton, LemonTabs } from '@posthog/lemon-ui'
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { IconFeedback } from 'lib/lemon-ui/icons'
import { cn } from 'lib/utils/css-classes'
@@ -21,9 +22,8 @@ import { LogsSqlEditor } from 'products/logs/frontend/components/LogsSqlEditor/L
import { LogsTransformations } from 'products/logs/frontend/components/LogsTransformations/LogsTransformations'
import { LogsViewer } from 'products/logs/frontend/components/LogsViewer'
import { LogsViewerModal } from 'products/logs/frontend/components/LogsViewer/LogsViewerModal'
-import { logsIngestionLogic } from 'products/logs/frontend/components/SetupPrompt/logsIngestionLogic'
-import { LogsSetupPrompt } from 'products/logs/frontend/components/SetupPrompt/SetupPrompt'
+import { logsEmptyState } from './emptyState/logsEmptyState'
import { LogsAnomalies } from './LogsAnomalies'
import { LOGS_SCENE_VIEWER_ID, LogsSceneActiveTab, logsSceneLogic } from './logsSceneLogic'
@@ -33,6 +33,7 @@ export const scene: SceneExport = {
component: LogsScene,
logic: logsSceneLogic,
productKey: ProductKey.LOGS,
+ emptyState: logsEmptyState,
}
export function LogsScene(): JSX.Element {
@@ -46,7 +47,7 @@ export function LogsScene(): JSX.Element {
const LogsSceneTabbedContent = (): JSX.Element => {
const { activeTab } = useValues(logsSceneLogic)
const { setActiveTab } = useActions(logsSceneLogic)
- const { hasLogs, teamHasLogsCheckFailed } = useValues(logsIngestionLogic)
+ const { status: logsSetupStatus } = useValues(productSetupStatusLogic({ productKey: ProductKey.LOGS }))
const showServicesView = useFeatureFlag('LOGS_SERVICES_VIEW')
const showServicesV2 = useFeatureFlag('LOGS_SERVICES_VIEW_V2')
const showServices = activeTab === 'services' && showServicesView
@@ -70,21 +71,8 @@ const LogsSceneTabbedContent = (): JSX.Element => {
resourceType={{
type: sceneConfigurations[Scene.Logs].iconType || 'default_icon_type',
}}
- actions={<>{hasLogs && <LogsSceneFeedbackButton />}</>}
+ actions={<>{logsSetupStatus === 'has-data' && <LogsSceneFeedbackButton />}</>}
/>
- {teamHasLogsCheckFailed && (
- <LemonBanner
- type="info"
- dismissKey="logs-setup-hint-banner"
- action={{
- to: 'https://posthog.com/docs/logs/',
- targetBlank: true,
- children: 'Setup guide',
- }}
- >
- Unable to verify logs setup. If you haven't configured logging yet, check out our setup guide.
- </LemonBanner>
- )}
<LemonTabs<LogsSceneActiveTab>
activeKey={activeTab}
onChange={(key) => {
@@ -100,11 +88,9 @@ const LogsSceneTabbedContent = (): JSX.Element => {
logs, scroll position, and virtualized-list state survive — switching away and back
should not replay the initial loading animation. */}
<div className={cn('flex flex-col flex-1 min-h-0', activeTab !== 'viewer' && 'hidden')}>
- <LogsSetupPrompt>
- <div className="flex flex-col gap-2 py-2 flex-1 min-h-0">
- <LogsViewer id={LOGS_SCENE_VIEWER_ID} showSavedViewsButton />
- </div>
- </LogsSetupPrompt>
+ <div className="flex flex-col gap-2 py-2 flex-1 min-h-0">
+ <LogsViewer id={LOGS_SCENE_VIEWER_ID} showSavedViewsButton />
+ </div>
</div>
{showServices && showServicesV2 && <LogsServicesV2 />}
{showServices && !showServicesV2 && (
diff --git a/products/logs/frontend/components/SetupPrompt/SetupPrompt.tsx b/products/logs/frontend/components/SetupPrompt/SetupPrompt.tsx
deleted file mode 100644
index 5e4aed4efe0d..000000000000
--- a/products/logs/frontend/components/SetupPrompt/SetupPrompt.tsx
+++ /dev/null
@@ -1,167 +0,0 @@
-import { useActions, useValues } from 'kea'
-import posthog from 'posthog-js'
-import { useEffect } from 'react'
-
-import * as greekPng from '@posthog/brand/hoggies/png/greek'
-import { IconGear } from '@posthog/icons'
-import { LemonButton, Link, Spinner } from '@posthog/lemon-ui'
-
-import { pngHoggie } from 'lib/brand/hoggies'
-import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
-import { useInterval } from 'lib/hooks/useInterval'
-import goImage from 'scenes/onboarding/shared/logos/go.svg'
-import javaImage from 'scenes/onboarding/shared/logos/java.svg'
-import nextjsImage from 'scenes/onboarding/shared/logos/nextjs.svg'
-import nodejsImage from 'scenes/onboarding/shared/logos/nodejs.svg'
-import pythonImage from 'scenes/onboarding/shared/logos/python.svg'
-import { teamLogic } from 'scenes/teamLogic'
-
-import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-
-import { useOpenLogsSettingsPanel } from '../../hooks/useOpenLogsSettingsPanel'
-import { logsIngestionLogic } from './logsIngestionLogic'
-
-const HedgehogGreek = pngHoggie(greekPng)
-
-const FRAMEWORK_LINKS: { name: string; image?: string; docsLink: string }[] = [
- { name: 'Node.js', image: nodejsImage, docsLink: 'https://posthog.com/docs/logs/installation/nodejs' },
- { name: 'Next.js', image: nextjsImage, docsLink: 'https://posthog.com/docs/logs/installation/nextjs' },
- { name: 'Python', image: pythonImage, docsLink: 'https://posthog.com/docs/logs/installation/python' },
- { name: 'Java', image: javaImage, docsLink: 'https://posthog.com/docs/logs/installation/java' },
- { name: 'Go', image: goImage, docsLink: 'https://posthog.com/docs/logs/installation/go' },
- { name: 'Datadog', docsLink: 'https://posthog.com/docs/logs/installation/datadog' },
- { name: 'Other', docsLink: 'https://posthog.com/docs/logs/installation' },
-]
-
-const POLLING_INTERVAL_MS = 5000
-
-export const LogsSetupPrompt = ({
- children,
- className,
-}: {
- children: React.ReactNode
- className?: string
-}): JSX.Element => {
- const { hasLogs, teamHasLogsLoading, teamHasLogsCheckFailed } = useValues(logsIngestionLogic)
- const { currentTeam } = useValues(teamLogic)
-
- if ((teamHasLogsLoading && hasLogs === undefined) || !currentTeam) {
- return (
- <div className="flex justify-center">
- <Spinner />
- </div>
- )
- }
-
- if (teamHasLogsCheckFailed || hasLogs === undefined) {
- return <>{children}</>
- }
-
- if (!hasLogs) {
- return <NoLogsPrompt className={className} />
- }
-
- return <>{children}</>
-}
-
-const NoLogsPrompt = ({ className }: { className?: string }): JSX.Element | null => {
- const { addProductIntent } = useActions(teamLogic)
- const { hasLogs } = useValues(logsIngestionLogic)
- const { loadTeamHasLogs } = useActions(logsIngestionLogic)
- const openLogsSettings = useOpenLogsSettingsPanel()
-
- useEffect(() => {
- posthog.capture('logs setup prompt viewed')
- }, [])
-
- useInterval(() => {
- if (!hasLogs) {
- loadTeamHasLogs()
- }
- }, POLLING_INTERVAL_MS)
-
- const onDocsLinkClick = (docsType: string): void => {
- posthog.capture('logs onboarding docs clicked', { docs_type: docsType })
- addProductIntent({
- product_type: ProductKey.LOGS,
- intent_context: ProductIntentContext.LOGS_DOCS_VIEWED,
- })
- }
-
- return (
- <ProductIntroduction
- productName="Logs"
- thingName="log"
- titleOverride="You haven't sent any logs yet"
- description="PostHog logs works with any OpenTelemetry-compatible client. You don't need any PostHog-specific packages – just use standard OpenTelemetry libraries to send logs via OTLP."
- isEmpty={true}
- productKey={ProductKey.LOGS}
- className={className}
- customHog={HedgehogGreek}
- actionElementOverride={
- <div className="flex flex-col items-start gap-4">
- <p className="text-sm text-secondary m-0">
- Read our{' '}
- <Link to="https://posthog.com/docs/logs" onClick={() => onDocsLinkClick('Logs')}>
- logs docs
- </Link>
- , learn more about{' '}
- <Link
- to="https://opentelemetry.io/docs/what-is-opentelemetry/"
- target="_blank"
- disableDocsPanel
- onClick={() => onDocsLinkClick('OpenTelemetry')}
- >
- OpenTelemetry
- </Link>
- , or pick a framework to get started:
- </p>
- <div className="flex flex-wrap gap-2">
- {FRAMEWORK_LINKS.map(({ name, image, docsLink }) => (
- <LemonButton
- key={name}
- type="secondary"
- size="small"
- to={docsLink}
- onClick={() => onDocsLinkClick(name)}
- icon={
- image ? (
- <img src={image} alt="" aria-hidden="true" className="w-5 h-5" />
- ) : undefined
- }
- >
- {name}
- </LemonButton>
- ))}
- </div>
- <p className="text-sm text-secondary m-0">
- Already using <code>posthog-js</code>?{' '}
- <LemonButton type="tertiary" size="xsmall" icon={<IconGear />} onClick={openLogsSettings}>
- Enable console log capture
- </LemonButton>
- </p>
- <div className="flex items-center gap-4">
- <div className="flex items-center gap-2 px-3 py-1.5 border border-accent rounded">
- <div className="relative flex items-center justify-center">
- <div className="absolute w-3 h-3 border-2 border-accent rounded-full animate-ping" />
- <div className="w-2 h-2 bg-accent rounded-full" />
- </div>
- <span className="text-sm">Watching for logs</span>
- </div>
- <span className="text-sm text-secondary">
- Missing an integration?{' '}
- <button
- id="logs-missing-integration-button"
- type="button"
- className="text-link font-semibold cursor-pointer"
- onClick={() => posthog.capture('logs missing integration clicked')}
- >
- Let us know
- </button>
- </span>
- </div>
- </div>
- }
- />
- )
-}
diff --git a/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.test.ts b/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.test.ts
deleted file mode 100644
index 340bcfb37326..000000000000
--- a/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.test.ts
+++ /dev/null
@@ -1,212 +0,0 @@
-import { expectLogic } from 'kea-test-utils'
-
-import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'
-import { useMocks } from '~/mocks/jest'
-import { initKeaTests } from '~/test/init'
-
-import { logsIngestionLogic } from './logsIngestionLogic'
-
-jest.mock('lib/utils/async', () => ({
- ...jest.requireActual('lib/utils/async'),
- retryWithBackoff: async <T>(fn: () => Promise<T>, options: { maxAttempts?: number } = {}): Promise<T> => {
- const maxAttempts = options.maxAttempts ?? 3
- let lastError: unknown
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
- try {
- return await fn()
- } catch (e) {
- lastError = e
- if (attempt >= maxAttempts - 1) {
- throw e
- }
- }
- }
- throw lastError
- },
-}))
-
-describe('logsIngestionLogic', () => {
- afterEach(resumeKeaLoadersErrors)
- let logic: ReturnType<typeof logsIngestionLogic.build>
-
- beforeEach(() => {
- localStorage.clear()
- initKeaTests()
- })
-
- afterEach(() => {
- logic?.unmount()
- localStorage.clear()
- })
-
- describe('loadTeamHasLogs', () => {
- it('loads teamHasLogs as true when logs exist', async () => {
- useMocks({
- get: {
- '/api/environments/:team_id/logs/has_logs/': () => [200, { hasLogs: true }],
- },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsSuccess']).toMatchValues({
- teamHasLogs: true,
- teamHasLogsLoading: false,
- teamHasLogsCheckFailed: false,
- })
- })
-
- it('loads teamHasLogs as false when no logs exist', async () => {
- useMocks({
- get: {
- '/api/environments/:team_id/logs/has_logs/': () => [200, { hasLogs: false }],
- },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsSuccess']).toMatchValues({
- teamHasLogs: false,
- teamHasLogsLoading: false,
- teamHasLogsCheckFailed: false,
- })
- })
-
- it('handles API failure and sets teamHasLogsCheckFailed', async () => {
- silenceKeaLoadersErrors()
- useMocks({
- get: {
- '/api/environments/:team_id/logs/has_logs/': () => [500, { detail: 'Server error' }],
- },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- // With retry logic (3 attempts), this will eventually fail
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsFailure']).toMatchValues({
- teamHasLogs: null, // kea-loaders sets to null on failure
- teamHasLogsLoading: false,
- teamHasLogsCheckFailed: true,
- })
- })
-
- it('starts with loading state on mount', async () => {
- useMocks({
- get: {
- '/api/environments/:team_id/logs/has_logs/': () => [200, { hasLogs: true }],
- },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- // Immediately after mount, the loader should be in loading state
- expect(logic.values.teamHasLogsLoading).toBe(true)
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogsSuccess'])
- })
-
- it('resets teamHasLogsCheckFailed on new load attempt', async () => {
- silenceKeaLoadersErrors()
- let callCount = 0
- useMocks({
- get: {
- '/api/environments/:team_id/logs/has_logs/': () => {
- callCount++
- if (callCount <= 3) {
- return [500, { detail: 'Server error' }]
- }
- return [200, { hasLogs: true }]
- },
- },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- // First attempt fails after retries
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsFailure']).toMatchValues({
- teamHasLogsCheckFailed: true,
- })
-
- // Manual retry succeeds
- logic.actions.loadTeamHasLogs()
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsSuccess']).toMatchValues({
- teamHasLogs: true,
- teamHasLogsCheckFailed: false,
- })
- })
- })
-
- describe('caching', () => {
- it('skips API call when cachedTeamHasLogs is true', async () => {
- const mockFn = jest.fn(() => [200, { hasLogs: true }])
- useMocks({
- get: { '/api/environments/:team_id/logs/has_logs/': mockFn },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsSuccess'])
- expect(mockFn).toHaveBeenCalledTimes(1)
-
- logic.unmount()
-
- // Mount again - should skip API call due to cache
- logic = logsIngestionLogic()
- logic.mount()
-
- await expectLogic(logic).toNotHaveDispatchedActions(['loadTeamHasLogs'])
- expect(mockFn).toHaveBeenCalledTimes(1)
- expect(logic.values.hasLogs).toBe(true)
- })
-
- it('makes API call when cachedTeamHasLogs is null', async () => {
- const mockFn = jest.fn(() => [200, { hasLogs: false }])
- useMocks({
- get: { '/api/environments/:team_id/logs/has_logs/': mockFn },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsSuccess'])
- expect(mockFn).toHaveBeenCalledTimes(1)
-
- logic.unmount()
-
- // Mount again - should make API call since false is not cached
- logic = logsIngestionLogic()
- logic.mount()
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogs', 'loadTeamHasLogsSuccess'])
- expect(mockFn).toHaveBeenCalledTimes(2)
- })
-
- it('hasLogs selector falls back to cachedTeamHasLogs when teamHasLogs is undefined', async () => {
- useMocks({
- get: { '/api/environments/:team_id/logs/has_logs/': () => [200, { hasLogs: true }] },
- })
-
- logic = logsIngestionLogic()
- logic.mount()
-
- await expectLogic(logic).toDispatchActions(['loadTeamHasLogsSuccess'])
- expect(logic.values.cachedTeamHasLogs).toBe(true)
-
- logic.unmount()
-
- // Remount - teamHasLogs starts undefined, hasLogs should use cached
- logic = logsIngestionLogic()
- logic.mount()
-
- expect(logic.values.teamHasLogs).toBeFalsy()
- expect(logic.values.hasLogs).toBe(true)
- })
- })
-})
diff --git a/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.tsx b/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.tsx
deleted file mode 100644
index e6e47bcee381..000000000000
--- a/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import { MakeLogicType, afterMount, kea, path, reducers, selectors } from 'kea'
-import { loaders } from 'kea-loaders'
-
-import api from 'lib/api'
-import { retryWithBackoff } from 'lib/utils/async'
-
-const teamId = window.POSTHOG_APP_CONTEXT?.current_team?.id
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface logsIngestionLogicValues {
- cachedTeamHasLogs: boolean | null
- hasLogs: boolean | undefined
- teamHasLogs: boolean | undefined
- teamHasLogsCheckFailed: boolean
- teamHasLogsLoading: boolean
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface logsIngestionLogicActions {
- loadTeamHasLogs: () => any
- loadTeamHasLogsFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadTeamHasLogsSuccess: (
- teamHasLogs: boolean,
- payload?: any
- ) => {
- teamHasLogs: boolean
- payload?: any
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface logsIngestionLogicMeta {
- __keaTypeGenInternalSelectorTypes: {
- hasLogs: (teamHasLogs: boolean | undefined, cachedTeamHasLogs: boolean | null) => boolean | undefined
- }
-}
-
-export type logsIngestionLogicType = MakeLogicType<
- logsIngestionLogicValues,
- logsIngestionLogicActions,
- Record<string, any>,
- logsIngestionLogicMeta
->
-
-export const logsIngestionLogic = kea<logsIngestionLogicType>([
- path(['products', 'logs', 'components', 'SetupPrompt', 'logsIngestionLogic']),
- loaders({
- teamHasLogs: {
- __default: undefined as boolean | undefined,
- loadTeamHasLogs: async (): Promise<boolean> => {
- return await retryWithBackoff(() => api.logs.hasLogs(), { maxAttempts: 3 })
- },
- },
- }),
-
- reducers({
- teamHasLogsCheckFailed: [
- false,
- {
- loadTeamHasLogs: () => false,
- loadTeamHasLogsSuccess: () => false,
- loadTeamHasLogsFailure: () => true,
- },
- ],
- cachedTeamHasLogs: [
- null as boolean | null,
- { persist: true, prefix: `${teamId}__` },
- {
- // Only cache true - logs don't disappear once ingested
- loadTeamHasLogsSuccess: (_, { teamHasLogs }) => teamHasLogs || null,
- },
- ],
- }),
-
- selectors({
- hasLogs: [
- (s) => [s.teamHasLogs, s.cachedTeamHasLogs],
- (teamHasLogs: boolean | undefined, cachedTeamHasLogs: boolean | null): boolean | undefined =>
- teamHasLogs ?? cachedTeamHasLogs ?? undefined,
- ],
- }),
-
- afterMount(({ actions, values }) => {
- if (values.cachedTeamHasLogs !== true) {
- actions.loadTeamHasLogs()
- }
- }),
-])
diff --git a/products/logs/frontend/emptyState/LogsPreview.scss b/products/logs/frontend/emptyState/LogsPreview.scss
new file mode 100644
index 000000000000..2dcfc25504f0
--- /dev/null
+++ b/products/logs/frontend/emptyState/LogsPreview.scss
@@ -0,0 +1,304 @@
+@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
+
+.LogsPreview {
+ --logs-preview-accent: var(--empty-state-accent, var(--color-primary-500));
+
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+
+ // Hidden filter state. A direct child of .LogsPreview so `:checked ~` reaches both cards.
+ &__checkbox {
+ position: absolute;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+ opacity: 0;
+ }
+
+ &__stream,
+ &__detail {
+ overflow: hidden;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ // All/errors pairs are stacked on one grid cell and crossfaded, so filtering
+ // never changes any element's size (no layout shift).
+ &__swap {
+ display: grid;
+ }
+
+ &__swap > * {
+ grid-area: 1 / 1;
+ min-width: 0;
+ }
+
+ &__when-errors {
+ @include preview-swap-hidden;
+ }
+
+ &__when-all {
+ @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 {
+ display: flex;
+ gap: 0.375rem;
+ align-items: center;
+ font-size: 0.75rem;
+ font-weight: 600;
+ }
+
+ &__live-dot {
+ width: 7px;
+ height: 7px;
+ background: var(--logs-preview-accent);
+ border-radius: 50%;
+ animation: LogsPreview__pulse 2s ease-in-out infinite;
+ }
+
+ &__filters {
+ display: flex;
+ gap: 0.375rem;
+ align-items: center;
+ padding: 0.4375rem 0.75rem;
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__chip {
+ display: inline-flex;
+ gap: 0.25rem;
+ align-items: center;
+ padding: 0.0625rem 0.4375rem;
+ font-size: 0.625rem;
+ font-weight: 500;
+ border: 1px solid var(--color-border-primary);
+ border-radius: 999px;
+ }
+
+ &__chip--passive {
+ color: var(--color-text-secondary);
+ }
+
+ &__chip--level {
+ cursor: pointer;
+ user-select: none;
+ transition:
+ background-color 150ms ease,
+ box-shadow 150ms ease;
+ }
+
+ &__chip--level:hover {
+ background: var(--color-bg-fill-highlight-50);
+ }
+
+ &__chip-dot {
+ width: 6px;
+ height: 6px;
+ background: var(--danger);
+ border-radius: 50%;
+ }
+
+ &__result-count {
+ margin-left: auto;
+ font-size: 0.625rem;
+ font-variant-numeric: tabular-nums;
+ color: var(--color-text-tertiary);
+ text-align: right;
+ }
+
+ // Log stream
+
+ &__rows {
+ display: flex;
+ flex-direction: column;
+ padding: 0.375rem 0.5rem;
+ font-family: var(--font-mono);
+ font-size: 0.625rem;
+ }
+
+ &__row {
+ display: grid;
+ grid-template-columns: 3.25rem 2.5rem minmax(0, 1fr);
+ gap: 0.5rem;
+ align-items: baseline;
+ padding: 0.1875rem 0.25rem;
+ border-radius: var(--radius);
+ transition:
+ opacity 250ms ease,
+ background-color 250ms ease;
+ }
+
+ &__time {
+ color: var(--color-text-tertiary);
+ }
+
+ &__level {
+ font-size: 0.5625rem;
+ font-weight: 700;
+ text-transform: uppercase;
+ }
+
+ &__level--info {
+ color: var(--color-text-secondary);
+ }
+
+ &__level--warn {
+ @include preview-accent-text(var(--logs-preview-accent));
+ }
+
+ &__level--error {
+ color: var(--color-text-error);
+ }
+
+ &__message {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ // The stream's tail: a fresh line about to arrive.
+ &__caret {
+ width: 0.4375rem;
+ height: 0.75rem;
+ background: color-mix(in oklab, var(--logs-preview-accent) 65%, transparent);
+ animation: LogsPreview__blink 1.1s steps(1) infinite;
+ }
+
+ // Detail panel
+
+ &__detail-body {
+ padding: 0.625rem 0.75rem;
+ }
+
+ &__detail-hint {
+ align-self: center;
+ font-size: 0.6875rem;
+ color: var(--color-text-tertiary);
+ }
+
+ &__attrs {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ }
+
+ &__attr {
+ display: grid;
+ grid-template-columns: 7rem minmax(0, 1fr);
+ gap: 0.5rem;
+ font-family: var(--font-mono);
+ font-size: 0.625rem;
+ }
+
+ &__attr-key {
+ color: var(--color-text-tertiary);
+ }
+
+ &__attr-val {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__attr-val--error {
+ font-weight: 600;
+ color: var(--color-text-error);
+ }
+
+ &__fresh {
+ font-size: 0.5625rem;
+ font-weight: 600;
+
+ @include preview-accent-text(var(--logs-preview-accent));
+ }
+}
+
+// Filtered state (user selected "errors only")
+
+.LogsPreview__checkbox:checked ~ * .LogsPreview__when-errors {
+ @include preview-swap-visible;
+}
+
+.LogsPreview__checkbox:checked ~ * .LogsPreview__when-all {
+ @include preview-swap-hidden;
+}
+
+.LogsPreview__checkbox:checked ~ .LogsPreview__stream .LogsPreview__chip--level {
+ background: color-mix(in oklab, var(--danger) 12%, var(--color-bg-surface-primary));
+ box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--danger) 40%, transparent);
+}
+
+// Filtering dims non-matching lines in place instead of removing them, so the
+// stream keeps its height (no layout shift).
+.LogsPreview__checkbox:checked
+ ~ .LogsPreview__stream
+ .LogsPreview__row:not(.LogsPreview__row--error, .LogsPreview__row--cursor) {
+ opacity: 0.25;
+}
+
+.LogsPreview__checkbox:checked ~ .LogsPreview__stream .LogsPreview__row--error {
+ background: color-mix(in oklab, var(--danger) 7%, transparent);
+}
+
+// The checkbox stays keyboard-focusable while visually hidden, so the chip it labels
+// needs a visible focus indicator (WCAG 2.4.7).
+.LogsPreview__checkbox:focus-visible ~ .LogsPreview__stream .LogsPreview__chip--level {
+ outline: 2px solid var(--logs-preview-accent);
+ outline-offset: 1px;
+}
+
+// Nudge attention at the filter chip until it's used.
+.LogsPreview:not(.LogsPreview--static)
+ .LogsPreview__checkbox:not(:checked)
+ ~ .LogsPreview__stream
+ .LogsPreview__chip--level {
+ animation: LogsPreview__nudge 2.4s ease-in-out infinite;
+}
+
+@keyframes LogsPreview__nudge {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--logs-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--logs-preview-accent) 20%, transparent);
+ }
+}
+
+@keyframes LogsPreview__pulse {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+
+ 50% {
+ opacity: 0.35;
+ }
+}
+
+@keyframes LogsPreview__blink {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+
+ 50% {
+ opacity: 0;
+ }
+}
+
+// Storybook snapshots and reduced motion drop all ambient motion; the filter chip
+// still flips the state (transitions only).
+@include preview-motion-guards('LogsPreview');
diff --git a/products/logs/frontend/emptyState/LogsPreview.tsx b/products/logs/frontend/emptyState/LogsPreview.tsx
new file mode 100644
index 000000000000..e2d7e69b5947
--- /dev/null
+++ b/products/logs/frontend/emptyState/LogsPreview.tsx
@@ -0,0 +1,115 @@
+import './LogsPreview.scss'
+
+import { LemonTag } from 'lib/lemon-ui/LemonTag'
+import { cn } from 'lib/utils/css-classes'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+
+interface LogRow {
+ time: string
+ level: 'info' | 'warn' | 'error'
+ message: string
+}
+
+const LOG_ROWS: LogRow[] = [
+ { time: '12:04:01', level: 'info', message: 'checkout-api request completed in 42 ms' },
+ { time: '12:04:03', level: 'info', message: 'web cache hit for /api/products' },
+ { time: '12:04:07', level: 'warn', message: 'checkout-api retrying payment provider call (attempt 2)' },
+ { time: '12:04:09', level: 'error', message: 'checkout-api payment failed: card_declined' },
+ { time: '12:04:11', level: 'info', message: 'web GET /api/products 200' },
+ { time: '12:04:12', level: 'error', message: 'checkout-api upstream timeout after 3000 ms' },
+]
+
+/**
+ * Example-data preview for the logs empty state: a live log stream and the detail
+ * panel of its failing request. Clicking the "errors" filter chip dims everything
+ * but the error lines and fills the detail panel with the failing request's
+ * attributes. One hidden checkbox drives it via `:checked ~` styles - no timers or
+ * state, per the preview rules in the `building-product-empty-states` skill.
+ * Filtering dims rows in place and detail states crossfade in `__swap` grids, so
+ * nothing shifts.
+ */
+export function LogsPreview(): JSX.Element {
+ const isStatic = inStorybook() || inStorybookTestRunner()
+
+ return (
+ <div className={cn('LogsPreview', isStatic && 'LogsPreview--static')}>
+ {/* Filter state, before both cards so `:checked ~` can style them. */}
+ <input type="checkbox" id="logs-preview-filter" className="LogsPreview__checkbox" />
+
+ <div className="LogsPreview__stream">
+ <div className="LogsPreview__head">
+ <span className="LogsPreview__title">
+ <span className="LogsPreview__live-dot" aria-hidden="true" />
+ Live logs
+ </span>
+ <LemonTag size="small">example data</LemonTag>
+ </div>
+
+ <div className="LogsPreview__filters">
+ <span className="LogsPreview__chip LogsPreview__chip--passive">service: all</span>
+ <label htmlFor="logs-preview-filter" className="LogsPreview__chip LogsPreview__chip--level">
+ <span className="LogsPreview__chip-dot" aria-hidden="true" />
+ errors only
+ </label>
+ <span className="LogsPreview__result-count LogsPreview__swap">
+ <span className="LogsPreview__when-all">1,204 lines</span>
+ <span className="LogsPreview__when-errors">2 lines</span>
+ </span>
+ </div>
+
+ <div className="LogsPreview__rows">
+ {LOG_ROWS.map((row) => (
+ <div
+ key={`${row.time}-${row.message}`}
+ className={cn('LogsPreview__row', `LogsPreview__row--${row.level}`)}
+ >
+ <span className="LogsPreview__time">{row.time}</span>
+ <span className={cn('LogsPreview__level', `LogsPreview__level--${row.level}`)}>
+ {row.level}
+ </span>
+ <span className="LogsPreview__message">{row.message}</span>
+ </div>
+ ))}
+ <div className="LogsPreview__row LogsPreview__row--cursor" aria-hidden="true">
+ <span className="LogsPreview__time">12:04:13</span>
+ <span className="LogsPreview__caret" />
+ </div>
+ </div>
+ </div>
+
+ <div className="LogsPreview__detail">
+ <div className="LogsPreview__head">
+ <span className="LogsPreview__title">Log attributes</span>
+ <span className="LogsPreview__fresh LogsPreview__when-errors">filtered</span>
+ </div>
+ <div className="LogsPreview__detail-body LogsPreview__swap">
+ <div className="LogsPreview__detail-hint LogsPreview__when-all">
+ Filter to errors only to inspect the failing request.
+ </div>
+ <div className="LogsPreview__attrs LogsPreview__when-errors">
+ <div className="LogsPreview__attr">
+ <span className="LogsPreview__attr-key">service.name</span>
+ <span className="LogsPreview__attr-val">checkout-api</span>
+ </div>
+ <div className="LogsPreview__attr">
+ <span className="LogsPreview__attr-key">severity</span>
+ <span className="LogsPreview__attr-val LogsPreview__attr-val--error">error</span>
+ </div>
+ <div className="LogsPreview__attr">
+ <span className="LogsPreview__attr-key">http.status_code</span>
+ <span className="LogsPreview__attr-val">502</span>
+ </div>
+ <div className="LogsPreview__attr">
+ <span className="LogsPreview__attr-key">trace_id</span>
+ <span className="LogsPreview__attr-val">4f2a91c3d8b0</span>
+ </div>
+ <div className="LogsPreview__attr">
+ <span className="LogsPreview__attr-key">body</span>
+ <span className="LogsPreview__attr-val">payment failed: card_declined</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/logs/frontend/emptyState/logsEmptyState.tsx b/products/logs/frontend/emptyState/logsEmptyState.tsx
new file mode 100644
index 000000000000..6920519766a5
--- /dev/null
+++ b/products/logs/frontend/emptyState/logsEmptyState.tsx
@@ -0,0 +1,34 @@
+import * as greekPng from '@posthog/brand/hoggies/png/greek'
+import { IconLive } 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 { LogsPreview } from './LogsPreview'
+import { logsSetupLogic } from './logsSetupLogic'
+
+const HedgehogGreek = pngHoggie(greekPng)
+
+export const logsEmptyState: SceneProductEmptyState = {
+ statusLogic: logsSetupLogic,
+ config: {
+ productKey: ProductKey.LOGS,
+ productName: 'Logs',
+ icon: <IconLive />,
+ accentColor: 'var(--color-product-logs-light)',
+ accentColorDark: 'var(--color-product-logs-dark)',
+ hedgehog: HedgehogGreek,
+ text: {
+ 'needs-setup': {
+ headline: 'Search every log from your stack in one place',
+ lead: 'Send logs from any OpenTelemetry-compatible client over OTLP. No PostHog-specific packages needed. Filter by severity and attributes, query with SQL, and set alerts on the lines that matter.',
+ },
+ },
+ docsUrl: 'https://posthog.com/docs/logs',
+ manualSetupUrl: 'https://posthog.com/docs/logs/installation',
+ previewLabel: 'Your log stream, once connected',
+ Preview: LogsPreview,
+ },
+}
diff --git a/products/logs/frontend/emptyState/logsSetupLogic.ts b/products/logs/frontend/emptyState/logsSetupLogic.ts
new file mode 100644
index 000000000000..17126a57829c
--- /dev/null
+++ b/products/logs/frontend/emptyState/logsSetupLogic.ts
@@ -0,0 +1,23 @@
+import api from 'lib/api'
+import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+import { retryWithBackoff } from 'lib/utils/async'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+/**
+ * Setup detection for the logs empty state. Binary: the team has ingested at
+ * least one log line, or it hasn't - there is no "instrumented but quiet"
+ * signal to read, so no waiting-for-data state.
+ */
+export const logsSetupLogic = createSetupDetectionLogic({
+ productKey: ProductKey.LOGS,
+ path: ['products', 'logs', 'frontend', 'emptyState', 'logsSetupLogic'],
+ detect: async () => {
+ const hasLogs = await retryWithBackoff(() => api.logs.hasLogs(), { maxAttempts: 3 })
+ return hasLogs ? 'has-data' : 'needs-setup'
+ },
+ // The first log usually lands moments after the collector restarts, so
+ // re-check often enough for the flip to feel immediate.
+ pollIntervalMs: 5000,
+ cacheHasData: true,
+})
diff --git a/products/logs/frontend/hooks/useOpenLogsSettingsPanel.ts b/products/logs/frontend/hooks/useOpenLogsSettingsPanel.ts
deleted file mode 100644
index 10951f655092..000000000000
--- a/products/logs/frontend/hooks/useOpenLogsSettingsPanel.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useActions } from 'kea'
-import { router } from 'kea-router'
-import posthog from 'posthog-js'
-
-import { teamLogic } from 'scenes/teamLogic'
-import { urls } from 'scenes/urls'
-
-import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-
-export function useOpenLogsSettingsPanel(): () => void {
- const { addProductIntent } = useActions(teamLogic)
-
- return () => {
- posthog.capture('logs settings opened')
- addProductIntent({
- product_type: ProductKey.LOGS,
- intent_context: ProductIntentContext.LOGS_SETTINGS_OPENED,
- })
- router.actions.push(urls.settings('environment-logs', 'logs'))
- }
-}
diff --git a/products/logs/manifest.tsx b/products/logs/manifest.tsx
index 55c913d52b7e..7029347d887d 100644
--- a/products/logs/manifest.tsx
+++ b/products/logs/manifest.tsx
@@ -95,7 +95,7 @@ export const manifest: ProductManifest = {
intents: [ProductKey.LOGS],
category: ProductItemCategory.APP_MONITORING,
iconType: 'logs' as FileSystemIconType,
- iconColor: ['var(--color-product-logs-light)'] as FileSystemIconColor,
+ iconColor: ['var(--color-product-logs-light)', 'var(--color-product-logs-dark)'] as FileSystemIconColor,
href: urls.logs(),
sceneKey: 'Logs',
},