:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(dashboards): add multi-viewport VR stories for AI button label (#71534)
Paul D'Ambrac14710688e90
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e345a1bc37ec..d1dfd928fd01 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5510,6 +5510,38 @@ snapshots:hash: v1.k794b7964.d5253d0fd9f143de83259d6ba9cd213fdff2ce949117c52b2f88bc78f6a73f7e.7-lf2SKFsVV2pNFc4mN3mW4wW1EpJfwEd1lXLybo3mkscenes-app-dashboards--not-found--light:hash: v1.k794b7964.ed4b8e9397bf960ff4b19b54e722c74962b25a2ec0270ecc090eda9b6d5d7f7b.XiealyyQzU_NqFX_PQmkZiIkJcX0h_joVE0Wbl-1twc+ scenes-app-dashboards--show-with-post-hog-ai-button-label--medium--dark:+ hash: v1.k794b7964.481f06431d59b57234e51cbe077a1cbec97ad944f93e5340d8856a0050da1a5c.Pbnljimr_K862P2_ljaqi4nrbtGLF9mIVTuC0sE_M2g+ scenes-app-dashboards--show-with-post-hog-ai-button-label--medium--light:+ hash: v1.k794b7964.144537e7aace7c53560e8b1c6e0b9d7b120de36e7c7a0aedd2aa2a34858d0bbe._HC-JXT62grCqW_Lpp9OkEKyURyJA8TOqFGo_AoOUXc+ scenes-app-dashboards--show-with-post-hog-ai-button-label--narrow--dark:+ hash: v1.k794b7964.4ea07e704d46a0495dbae82890a560c28670e24a9b71c6d63cdb1580151a5121.b_5FvU7MoXFArf7g9EhkXw0JiH3d-_Vmnbm3IR6gIcA+ scenes-app-dashboards--show-with-post-hog-ai-button-label--narrow--light:+ hash: v1.k794b7964.d96e224f83bfe7ec92a0f61ba319b8c3373189f345f77120be9a12c22116fd02.I40DluW7O4DYLszEDuT88nhoMQtQjVaZUv5R9fkdWNw+ scenes-app-dashboards--show-with-post-hog-ai-button-label--superwide--dark:+ hash: v1.k794b7964.68a378f55241be720f381165043d30d595927581e0cb8a397e937bdaa25f78fc.Yk-xHi3W1TbkCiOLeqgTb_kYvzodmeG3UbvGlz56vj4+ scenes-app-dashboards--show-with-post-hog-ai-button-label--superwide--light:+ hash: v1.k794b7964.9bd4d2714f9900c45b8687fc72431aab13e800fe1b776727aafa46cb18b726e9.tuNp6_rpbRUE_K4SJjfuxDmGAqEhEs2coFmRKgIJUU0+ scenes-app-dashboards--show-with-post-hog-ai-button-label--wide--dark:+ hash: v1.k794b7964.124619da7d409d7b932970ca6cf582fc0d19d29dfc6cbb48675a9fe447c60892.BmxOeG12uGLWXhlL_qzUgtq-blyQRG1RVxDq22rJKqU+ scenes-app-dashboards--show-with-post-hog-ai-button-label--wide--light:+ hash: v1.k794b7964.de9199dae71356e9180e03b49457c499980fce0748123f2e30aebc761be65b32.qIuiMZLH79AWKTwDrvkk7w8BqYC-VjGifh3e0lQVP4s+ scenes-app-dashboards--show-without-post-hog-ai-button-label--medium--dark:+ hash: v1.k794b7964.8e451e072f54f7e2a4bf649e2af129a1624a9ce5939d023a10cef4dbe200d00a.35hPLpid_TQpN7vdWwVb9IwsPn0qt_aoDmzGmhvA0nA+ scenes-app-dashboards--show-without-post-hog-ai-button-label--medium--light:+ hash: v1.k794b7964.443d8b0d9fa99c87330e0976a6ed9f3593f7011c383dc4dce4fa3ca35bc1cbd2.C4WFLsVYpl4hc7tDJZ6sZHBjwKdUERUrOrM5mOR7XJQ+ scenes-app-dashboards--show-without-post-hog-ai-button-label--narrow--dark:+ hash: v1.k794b7964.88687d2cc1bbd12296214f07d5f6bb2548705ae3baae37985858225116896a10.YogXGZXR1uFB4qD8nOjCfWyWL--g1SLKNxz0gZvEoWw+ scenes-app-dashboards--show-without-post-hog-ai-button-label--narrow--light:+ hash: v1.k794b7964.2035f84708f35d51de9ca7ce036c497c17d8a812e4a64c682d76caa066cb0954._S1SJobvQ3RqTPgANTGgE3vUYRijIBEFRYinuHFsQIA+ scenes-app-dashboards--show-without-post-hog-ai-button-label--superwide--dark:+ hash: v1.k794b7964.cad32a04659183c6bfecbc34e5ae23c08c095f70df65ef0ee7d863d2103a124d.2bYQoklhY3opedkpy5pUC52pEvCwdnEfKowjCBPaDb8+ scenes-app-dashboards--show-without-post-hog-ai-button-label--superwide--light:+ hash: v1.k794b7964.d0bef90d18f987e2544aa611b9341dd92177201242030b3d30352b308604675e.CWWmG6lSkFT83glxSckbnPhQTIUZiwkaGiqD3V0JVtY+ scenes-app-dashboards--show-without-post-hog-ai-button-label--wide--dark:+ hash: v1.k794b7964.d0252e5613e6bcf9202e82ae3cfa5846cec3195c72e6d4332cc55461b4378dd3.L6IVBe6Y9cpQ6M1XHL46HlYwPkWQmz_R-0_JXx7pwWw+ scenes-app-dashboards--show-without-post-hog-ai-button-label--wide--light:+ hash: v1.k794b7964.f9c443be46dd64532ac7c1f1e6efcd7f85a51232f815919fe5f53ce0d220184c.Dt2jIfjTWjeFAZNzMRlpM6vCbaatiKB5t5KmWoaAyQkscenes-app-dashboards--view-only-dashboard--dark:hash: v1.k794b7964.a65acee97de57aeef30368365580e0e2c962193d6215acf55dac639823cb0ca8.zkO7nnEw6JoWOSq1KJ1DQrXzCI1FSmD0yzRsrMwcfA0scenes-app-dashboards--view-only-dashboard--light:diff --git a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx b/frontend/src/scenes/dashboard/DashboardHeader.test.tsxindex b5ff2d93ba29..9421081250d3 100644--- a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx+++ b/frontend/src/scenes/dashboard/DashboardHeader.test.tsx@@ -3,8 +3,7 @@ import '@testing-library/jest-dom'import { cleanup, render } from '@testing-library/react'import { BindLogic } from 'kea'-import { useFeatureFlagVariantKey } from '@posthog/react'-+import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { DashboardEventSource } from 'lib/utils/eventUsageLogic'@@ -21,12 +20,6 @@ jest.mock('lib/components/FullScreen', () => ({jest.mock('scenes/max/MaxTool', () => ({MaxTool: ({ children }: any) => <>{children}</>,}))-jest.mock('@posthog/react', () => ({- ...jest.requireActual('@posthog/react'),- useFeatureFlagVariantKey: jest.fn(),-}))--const mockUseFeatureFlagVariantKey = jest.mocked(useFeatureFlagVariantKey)const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {id: 5,@@ -175,7 +168,9 @@ describe('DashboardHeader', () => {{ variant: 'control_b', showsLabel: false },{ variant: 'test', showsLabel: true },])('$variant variant sets the PostHog AI button label', ({ variant, showsLabel }) => {- mockUseFeatureFlagVariantKey.mockReturnValue(variant)+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.DASHBOARD_POSTHOG_AI_BUTTON_LABEL], {+ [FEATURE_FLAGS.DASHBOARD_POSTHOG_AI_BUTTON_LABEL]: variant,+ })const { logic } = renderHeader({ dashboard: MOCK_DASHBOARD })const aiButton = document.querySelector('[data-attr="open-context-panel-ai-button"]')diff --git a/frontend/src/scenes/dashboard/DashboardHeader.tsx b/frontend/src/scenes/dashboard/DashboardHeader.tsxindex 793c49861522..562372c05c5a 100644--- a/frontend/src/scenes/dashboard/DashboardHeader.tsx+++ b/frontend/src/scenes/dashboard/DashboardHeader.tsx@@ -1,9 +1,6 @@import { useActions, useValues } from 'kea'-import { useFeatureFlagVariantKey } from '@posthog/react'-import { FullScreen } from 'lib/components/FullScreen'-import { FEATURE_FLAGS } from 'lib/constants'import { DashboardEventSource } from 'lib/utils/eventUsageLogic'import { sceneConfigurations } from 'scenes/scenes'import { Scene } from 'scenes/sceneTypes'@@ -23,10 +20,10 @@ export const DASHBOARD_CANNOT_EDIT_MESSAGE ="You don't have edit permissions for this dashboard. Ask a dashboard collaborator with edit access to add you."export function DashboardHeader(): JSX.Element | null {- const { dashboard, dashboardLoading, dashboardMode, canEditDashboard } = useValues(dashboardLogic)+ const { dashboard, dashboardLoading, dashboardMode, canEditDashboard, postHogAIButtonLabelVariant } =+ useValues(dashboardLogic)const { setDashboardMode, loadDashboard } = useActions(dashboardLogic)const { updateDashboard } = useActions(dashboardsModel)- const postHogAIButtonLabelVariant = useFeatureFlagVariantKey(FEATURE_FLAGS.DASHBOARD_POSTHOG_AI_BUTTON_LABEL)if (!dashboard && !dashboardLoading) {return nulldiff --git a/frontend/src/scenes/dashboard/Dashboards.stories.tsx b/frontend/src/scenes/dashboard/Dashboards.stories.tsxindex 78857802c2f0..600938fb79ab 100644--- a/frontend/src/scenes/dashboard/Dashboards.stories.tsx+++ b/frontend/src/scenes/dashboard/Dashboards.stories.tsx@@ -1,5 +1,6 @@import { Meta, StoryObj } from '@storybook/react'+import { FEATURE_FLAGS } from 'lib/constants'import { useDelayedOnMountEffect } from 'lib/hooks/useOnMountEffect'import { DashboardEventSource } from 'lib/utils/eventUsageLogic'import { App } from 'scenes/App'@@ -200,6 +201,27 @@ export const Show: Story = {},}+// Multi-viewport snapshots of the dashboard scene from mobile to superwide, so we catch the header+// layout (and any squishing) across breakpoints. The "PostHog AI" button label is gated on a+// multivariate experiment flag; DashboardHeader reads it through kea, so the `featureFlags`+// parameter pins the arm. `skipCanvasDraw` is re-declared because per-story `testOptions` replaces+// the meta-level object rather than merging into it.+export const ShowWithoutPostHogAIButtonLabel: Story = {+ parameters: {+ pageUrl: urls.dashboard(BASE_DASHBOARD_ID),+ featureFlags: { [FEATURE_FLAGS.DASHBOARD_POSTHOG_AI_BUTTON_LABEL]: 'control' },+ testOptions: { skipCanvasDraw: true, viewportWidths: ['narrow', 'medium', 'wide', 'superwide'] },+ },+}++export const ShowWithPostHogAIButtonLabel: Story = {+ parameters: {+ pageUrl: urls.dashboard(BASE_DASHBOARD_ID),+ featureFlags: { [FEATURE_FLAGS.DASHBOARD_POSTHOG_AI_BUTTON_LABEL]: 'test' },+ testOptions: { skipCanvasDraw: true, viewportWidths: ['narrow', 'medium', 'wide', 'superwide'] },+ },+}+export const Edit: Story = {render: () => {useDelayedOnMountEffect(() => {diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsxindex 8645ae487c95..758b31281aff 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx@@ -310,6 +310,7 @@ export interface dashboardLogicValues {pageVisibility: booleanpendingInsertion: PendingInsertion | nullplacement: DashboardPlacement+ postHogAIButtonLabelVariant: boolean | string | undefinedprojectTreeRef: ProjectTreeRefrefreshMetrics: {completed: number@@ -1008,6 +1009,7 @@ export interface dashboardLogicMeta {placement: DashboardPlacement) => booleaninlineTileInsertionEnabled: (featureFlags: FeatureFlagsSet) => boolean+ postHogAIButtonLabelVariant: (featureFlags: FeatureFlagsSet) => boolean | string | undefinedinsightTiles: (tiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]) => DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]@@ -2566,6 +2568,13 @@ export const dashboardLogic = kea<dashboardLogicType>([(featureFlags: import('lib/logic/featureFlagLogic').FeatureFlagsSet): boolean =>!!featureFlags[FEATURE_FLAGS.DASHBOARD_INLINE_TILE_INSERTION],],+ postHogAIButtonLabelVariant: [+ (s) => [s.featureFlags],+ // Read through kea so Storybook's `featureFlags` parameter can pin the experiment arm;+ // the @posthog/react hook reads posthog-js, which stories can't seed.+ (featureFlags: FeatureFlagsSet): string | boolean | undefined =>+ featureFlags[FEATURE_FLAGS.DASHBOARD_POSTHOG_AI_BUTTON_LABEL],+ ],insightTiles: [(s) => [s.tiles],(