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(dashboards): upsell dashboard widgets feature preview (#62490)

Matt Pua22492e2c3964
diff --git a/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx b/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx
index 3a1502a7e8a5..5bdf5a55b809 100644
--- a/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx
+++ b/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx
@@ -6,6 +6,7 @@ import { IconGridMasonry, IconPlusSmall, IconShare } from '@posthog/icons'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { AppShortcut } from 'lib/components/AppShortcuts/AppShortcut'
import { keyBinds } from 'lib/components/AppShortcuts/shortcuts'
+import { FEATURE_FLAGS } from 'lib/constants'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonMenu } from 'lib/lemon-ui/LemonMenu'
import { DashboardEventSource } from 'lib/utils/eventUsageLogic'
@@ -71,16 +72,19 @@ export function DashboardAddTileButton(): JSX.Element | null {
onClick: () => push(urls.dashboardButtonTile(dashboard.id, 'new')),
'data-attr': 'dashboard-add-button-tile',
},
- ...(dashboardWidgetsEnabled
- ? [
- {
- label: 'Widget',
- tag: 'new' as const,
- onClick: () => setAddWidgetModalOpen(true),
- 'data-attr': 'dashboard-add-widget',
- },
- ]
- : []),
+ dashboardWidgetsEnabled
+ ? {
+ label: 'Widget',
+ tag: 'new' as const,
+ onClick: () => setAddWidgetModalOpen(true),
+ 'data-attr': 'dashboard-add-widget',
+ }
+ : {
+ label: 'Widget',
+ tag: 'beta' as const,
+ onClick: () => push(urls.featurePreview(FEATURE_FLAGS.DASHBOARD_WIDGETS)),
+ 'data-attr': 'dashboard-add-widget-preview',
+ },
]}
>
<LemonButton type="primary" data-attr="dashboard-add-tile" size="small" icon={<IconPlusSmall />}>
diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
index 3434c271443f..fb7d956a9244 100644
--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
@@ -3,10 +3,12 @@ import '@testing-library/jest-dom'
import { cleanup, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { BindLogic } from 'kea'
+import { router } from 'kea-router'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -87,13 +89,28 @@ describe('EmptyDashboardComponent', () => {
await userEvent.click(document.querySelector('[data-attr="dashboard-add-dropdown"]')!)
}
+ it('routes Add widget preview to feature previews when flag is disabled', async () => {
+ const pushSpy = jest.spyOn(router.actions, 'push')
+ const { logic } = renderEmptyState()
+
+ await openGetStartedDropdown()
+ await userEvent.click(screen.getByText('Add widget'))
+
+ expect(pushSpy).toHaveBeenCalledWith(urls.featurePreview(FEATURE_FLAGS.DASHBOARD_WIDGETS))
+ expect(logic.values.addWidgetModalOpen).toBe(false)
+
+ pushSpy.mockRestore()
+ logic.unmount()
+ })
+
it('shows Add text card in Get started dropdown', async () => {
const { logic } = renderEmptyState()
await openGetStartedDropdown()
expect(screen.getByText('Add text card')).toBeInTheDocument()
- expect(screen.queryByText('Add widget')).not.toBeInTheDocument()
+ expect(screen.getByText('Add widget')).toBeInTheDocument()
+ expect(screen.getByText('BETA')).toBeInTheDocument()
logic.unmount()
})
diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
index a67c20709873..262f91c5685b 100644
--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
@@ -7,6 +7,7 @@ import { LemonTag, Spinner } from '@posthog/lemon-ui'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { GraphsHog } from 'lib/components/hedgehogs'
import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
+import { FEATURE_FLAGS } from 'lib/constants'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
import { urls } from 'scenes/urls'
@@ -80,24 +81,34 @@ function DashboardEmptyActions({
Add text card
</LemonButton>
</AccessControlAction>
- {dashboardWidgetsEnabled ? (
- <AccessControlAction
- resourceType={AccessControlResourceType.Dashboard}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={dashboard.user_access_level}
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Dashboard}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={dashboard.user_access_level}
+ >
+ <LemonButton
+ fullWidth
+ onClick={
+ dashboardWidgetsEnabled
+ ? onAddWidget
+ : () => push(urls.featurePreview(FEATURE_FLAGS.DASHBOARD_WIDGETS))
+ }
+ data-attr={
+ dashboardWidgetsEnabled
+ ? 'dashboard-add-widget'
+ : 'dashboard-add-widget-preview'
+ }
>
- <LemonButton
- fullWidth
- onClick={onAddWidget}
- data-attr="dashboard-add-widget"
+ Add widget
+ <LemonTag
+ type={dashboardWidgetsEnabled ? 'success' : 'warning'}
+ size="small"
+ className="ml-2"
>
- Add widget
- <LemonTag type="success" size="small" className="ml-2">
- NEW
- </LemonTag>
- </LemonButton>
- </AccessControlAction>
- ) : null}
+ {dashboardWidgetsEnabled ? 'NEW' : 'BETA'}
+ </LemonTag>
+ </LemonButton>
+ </AccessControlAction>
</>
),
},
diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.ts
index 33e4078db598..9164e02a831b 100644
--- a/frontend/src/scenes/urls.ts
+++ b/frontend/src/scenes/urls.ts
@@ -138,6 +138,7 @@ export const urls = {
aiHistory: (): string => '/ai/history',
settings: (section: SettingSectionId | SettingLevelId = 'project', setting?: SettingId): string =>
combineUrl(`/settings/${section}`, undefined, setting).url,
+ featurePreview: (flagKey: string): string => combineUrl('/settings/user-feature-previews', {}, flagKey).url,
organizationCreationConfirm: (): string => '/organization/confirm-creation',
toolbarLaunch: (): string => '/toolbar',
site: (url: string): string => `/site/${url === ':url' ? url : encodeURIComponent(url)}`,