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): A/B test add-tile picker modal (#65866)

Matt Pua55fb1c4ebcc9
diff --git a/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts b/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts
index 39bc5b916764..b92ad81b4a34 100644
--- a/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts
+++ b/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts
@@ -4,6 +4,8 @@ import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
+
import { dashboardsModel } from '~/models/dashboardsModel'
import { DashboardType, QueryBasedInsightModel } from '~/types'
@@ -72,6 +74,10 @@ export const buttonTileCardModalLogic = kea<buttonTileCardModalLogicType>([
actions.resetButtonTile()
props?.onClose?.()
+ if (props.buttonTileId === 'new') {
+ eventUsageLogic.actions.reportDashboardTileAdded('button')
+ }
+
posthog.capture('dashboard button tile saved', {
dashboard_id: props.dashboard.id,
button_tile_id: props.buttonTileId === 'new' ? null : props.buttonTileId,
diff --git a/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts b/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts
index 6d5dc5dd754d..a288102776bc 100644
--- a/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts
+++ b/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts
@@ -4,6 +4,8 @@ import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
+
import { dashboardsModel } from '~/models/dashboardsModel'
import { DashboardTile, DashboardType, QueryBasedInsightModel } from '~/types'
@@ -71,6 +73,10 @@ export const textCardModalLogic = kea<textCardModalLogicType>([
actions.resetTextTile()
props?.onClose?.()
+ if (props.textTileId === 'new') {
+ eventUsageLogic.actions.reportDashboardTileAdded('text_card')
+ }
+
posthog.capture('dashboard text tile saved', {
dashboard_id: props.dashboard.id,
text_tile_id: props.textTileId === 'new' ? null : props.textTileId,
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index b2c0ee8aaa9c..f3ab4732d12f 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -276,6 +276,7 @@ export const FEATURE_FLAGS = {
DASHBOARD_QUICK_FILTERS_EXPERIMENT: 'dashboard-quick-filters-experiment', // owner: @vdekrijger #team-product-analytics multivariate=control,test
DASHBOARD_TEMPLATE_CHOOSER_EXPERIMENT: 'dashboard-template-chooser-experiment', // owner: @mattp #team-analytics-platform multivariate=control,simple,new
DASHBOARD_WIDGETS: 'dashboard-widgets', // owner: @mattp #team-analytics-platform
+ DASHBOARD_ADD_TILE_PICKER_MODAL: 'dashboard-add-tile-picker-modal', // owner: @mattp #team-analytics-platform multivariate=control,test
DATA_MODELING_BACKEND_V2: 'data-modeling-backend-v2', // owner: #team-data-modeling
DATA_MODELING_MULTI_DAG: 'data-modeling-multi-dag', // owner: #team-data-modeling
DATA_MODELING_TAB: 'data-modeling-tab', // owner: #team-data-modeling
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts
index 1560b20f4a4b..fdbae9b0db96 100644
--- a/frontend/src/lib/utils/eventUsageLogic.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.ts
@@ -7,6 +7,7 @@ import { now } from 'lib/dayjs'
import { TimeToSeeDataPayload } from 'lib/internalMetrics'
import { objectClean } from 'lib/utils/objects'
import { BillingUsageInteractionProps } from 'scenes/billing/types'
+import type { DashboardAddTileType } from 'scenes/dashboard/addTilePickerModalLogic'
import { SharedMetric } from 'scenes/experiments/SharedMetrics/sharedMetricLogic'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { ProductTourEvent } from 'scenes/product-tours/constants'
@@ -586,6 +587,11 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportCustomChannelTypeRulesUpdated: (numRules: number) => ({ numRules }),
reportPropertySelectOpened: true,
reportCreatedDashboardFromModal: true,
+ reportDashboardAddTileOptionClicked: (tileType: DashboardAddTileType, variant: 'control' | 'test') => ({
+ tileType,
+ variant,
+ }),
+ reportDashboardTileAdded: (tileType: DashboardAddTileType) => ({ tileType }),
/** Dashboard created via PostHog web app from a template (new dashboard modal / template chooser). */
reportWebDashboardCreatedFromTemplate: (payload: {
dashboard_id: number
@@ -1625,6 +1631,12 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportCreatedDashboardFromModal: async () => {
posthog.capture('created new dashboard from modal')
},
+ reportDashboardAddTileOptionClicked: async ({ tileType, variant }) => {
+ posthog.capture('dashboard add tile option clicked', { tile_type: tileType, variant })
+ },
+ reportDashboardTileAdded: async ({ tileType }) => {
+ posthog.capture('dashboard tile added', { tile_type: tileType })
+ },
reportWebDashboardCreatedFromTemplate: async (payload) => {
posthog.capture('dashboard created from template', {
...payload,
diff --git a/frontend/src/scenes/dashboard/AddTilePickerModal.tsx b/frontend/src/scenes/dashboard/AddTilePickerModal.tsx
new file mode 100644
index 000000000000..5d297a7b7883
--- /dev/null
+++ b/frontend/src/scenes/dashboard/AddTilePickerModal.tsx
@@ -0,0 +1,278 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+import { ReactNode } from 'react'
+
+import { IconCursorClick, IconGraph, IconGridMasonry, IconLetter } from '@posthog/icons'
+import { LemonTag } from '@posthog/lemon-ui'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { LemonModal } from 'lib/lemon-ui/LemonModal'
+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
+import { urls } from 'scenes/urls'
+
+import { addInsightToDashboardLogic } from './addInsightToDashboardModalLogic'
+import { DashboardAddTileType, addTilePickerModalLogic } from './addTilePickerModalLogic'
+import { dashboardLogic } from './dashboardLogic'
+
+interface TileOption {
+ type: DashboardAddTileType
+ label: string
+ description: string
+ icon: JSX.Element
+ preview: JSX.Element
+ tag?: 'new' | 'beta'
+ 'data-attr': string
+}
+
+/**
+ * Chrome shared by the preview tiles: white card with the same compact header a real dashboard tile
+ * has (uppercase type • date row, title, ⋯). Header is omitted for freeform tiles (text / button).
+ */
+function MiniTile({
+ type,
+ title,
+ bodyClassName,
+ children,
+}: {
+ type?: string
+ title?: string
+ bodyClassName?: string
+ children: ReactNode
+}): JSX.Element {
+ return (
+ <div className="flex h-full w-full flex-col overflow-hidden rounded border border-primary bg-surface-primary shadow-sm">
+ {type && (
+ <>
+ <div className="px-1.5 pt-1">
+ <div className="text-[0.5rem] font-bold uppercase leading-tight tracking-[0.03em] text-secondary">
+ {type}
+ </div>
+ <div className="flex items-center justify-between gap-1">
+ <span className="truncate text-[0.7rem] font-semibold leading-tight text-primary">
+ {title}
+ </span>
+ <span className="shrink-0 text-[0.6rem] leading-none text-secondary">•••</span>
+ </div>
+ </div>
+ <div className="mt-1 border-t border-primary" />
+ </>
+ )}
+ <div className={`min-h-0 flex-1 overflow-hidden ${bodyClassName ?? ''}`}>{children}</div>
+ </div>
+ )
+}
+
+/** A faithful-looking trends line tile — header, smooth line with area fill, faint gridlines, date axis. */
+function InsightPreview(): JSX.Element {
+ return (
+ <MiniTile
+ type="Trends • Last 7 days"
+ title="Weekly active users"
+ bodyClassName="flex flex-col px-1.5 pb-1 pt-1"
+ >
+ <svg viewBox="0 0 100 34" preserveAspectRatio="none" className="h-full w-full flex-1">
+ {[8, 17, 26].map((y) => (
+ <line
+ key={y}
+ x1="0"
+ y1={y}
+ x2="100"
+ y2={y}
+ stroke="var(--color-border-primary)"
+ strokeWidth="0.5"
+ />
+ ))}
+ <polygon
+ points="0,34 0,27 14,23 28,26 42,15 56,19 70,9 84,12 100,5 100,34"
+ fill="var(--data-color-1)"
+ fillOpacity="0.15"
+ />
+ <polyline
+ points="0,27 14,23 28,26 42,15 56,19 70,9 84,12 100,5"
+ fill="none"
+ stroke="var(--data-color-1)"
+ strokeWidth="1.5"
+ strokeLinejoin="round"
+ strokeLinecap="round"
+ vectorEffect="non-scaling-stroke"
+ />
+ </svg>
+ <div className="flex justify-between pt-0.5 text-[0.45rem] text-secondary">
+ <span>Jun 1</span>
+ <span>Jun 8</span>
+ <span>Jun 15</span>
+ <span>Jun 22</span>
+ </div>
+ </MiniTile>
+ )
+}
+
+/** Sample rendered markdown so the user can picture a text card. */
+function TextCardPreview(): JSX.Element {
+ return (
+ <MiniTile bodyClassName="flex flex-col justify-center gap-1 px-2">
+ <div className="text-[0.75rem] font-semibold text-primary">Q2 launch goals</div>
+ <div className="text-[0.55rem] leading-snug text-secondary">
+ Track weekly active users and conversion as we roll out the new onboarding flow.
+ </div>
+ </MiniTile>
+ )
+}
+
+/** A non-interactive mock of a button tile. */
+function ButtonPreview(): JSX.Element {
+ return (
+ <MiniTile bodyClassName="flex items-center justify-center">
+ <span className="rounded bg-accent px-2 py-1 text-[0.65rem] font-medium text-white">Read the docs →</span>
+ </MiniTile>
+ )
+}
+
+/** A faithful-looking "Top issues" error-tracking widget — ranked issues with sparklines and counts. */
+function WidgetPreview(): JSX.Element {
+ const issues = [
+ {
+ title: 'TypeError: Cannot read properties of undefined',
+ count: '42',
+ bars: ['h-1', 'h-2', 'h-1.5', 'h-2.5', 'h-2', 'h-3', 'h-2'],
+ },
+ {
+ title: 'NetworkError: Failed to fetch',
+ count: '18',
+ bars: ['h-1', 'h-1.5', 'h-2', 'h-1', 'h-2', 'h-1.5', 'h-1'],
+ },
+ ]
+ return (
+ <MiniTile type="Error tracking • Last 7 days" title="Top issues" bodyClassName="flex flex-col">
+ <div className="flex items-center justify-between border-b border-primary bg-surface-secondary px-1.5 py-0.5 text-[0.45rem] font-semibold uppercase tracking-wide text-secondary">
+ <span>Issue</span>
+ <span>Occurrences</span>
+ </div>
+ <div className="flex-1 divide-y divide-primary">
+ {issues.map((issue) => (
+ <div key={issue.title} className="flex items-center gap-1 px-1.5 py-1">
+ <span className="h-1 w-1 shrink-0 rounded-full bg-danger" />
+ <span className="min-w-0 flex-1 truncate text-[0.55rem] font-medium text-primary">
+ {issue.title}
+ </span>
+ <span className="flex h-2.5 items-end gap-px">
+ {issue.bars.map((h, i) => (
+ <span key={i} className={`w-0.5 rounded-sm bg-accent ${h}`} />
+ ))}
+ </span>
+ <span className="w-4 shrink-0 text-right text-[0.55rem] font-semibold tabular-nums text-primary">
+ {issue.count}
+ </span>
+ </div>
+ ))}
+ </div>
+ <div className="border-t border-primary px-1.5 py-0.5 text-center text-[0.45rem] text-secondary">
+ 2 of 42 issues
+ </div>
+ </MiniTile>
+ )
+}
+
+export function AddTilePickerModal(): JSX.Element | null {
+ const { dashboard, dashboardWidgetsEnabled } = useValues(dashboardLogic)
+ const { setAddWidgetModalOpen } = useActions(dashboardLogic)
+ const { addTilePickerModalVisible } = useValues(addTilePickerModalLogic)
+ const { hideAddTilePickerModal } = useActions(addTilePickerModalLogic)
+ const { showAddInsightToDashboardModal } = useActions(addInsightToDashboardLogic)
+ const { reportDashboardAddTileOptionClicked } = useActions(eventUsageLogic)
+ const { push } = useActions(router)
+
+ if (!dashboard) {
+ return null
+ }
+
+ const onSelect = (type: DashboardAddTileType, proceed: () => void): void => {
+ reportDashboardAddTileOptionClicked(type, 'test')
+ hideAddTilePickerModal()
+ proceed()
+ }
+
+ const options: TileOption[] = [
+ {
+ type: 'insight',
+ label: 'Insight',
+ description: 'Add a trend, funnel, retention, or any saved insight.',
+ icon: <IconGraph />,
+ preview: <InsightPreview />,
+ 'data-attr': 'dashboard-picker-insight',
+ },
+ {
+ type: 'text_card',
+ label: 'Text card',
+ description: 'Add context, notes, or headings in markdown.',
+ icon: <IconLetter />,
+ preview: <TextCardPreview />,
+ 'data-attr': 'dashboard-picker-text',
+ },
+ {
+ type: 'button',
+ label: 'Button',
+ description: 'Link out to docs, runbooks, or related dashboards.',
+ icon: <IconCursorClick />,
+ preview: <ButtonPreview />,
+ 'data-attr': 'dashboard-picker-button',
+ },
+ {
+ type: 'widget',
+ label: 'Widget',
+ description: dashboardWidgetsEnabled
+ ? 'Drop in a ready-made widget from across PostHog.'
+ : 'Drop in a ready-made widget from across PostHog. Enable it from feature previews first.',
+ icon: <IconGridMasonry />,
+ preview: <WidgetPreview />,
+ tag: dashboardWidgetsEnabled ? 'new' : 'beta',
+ 'data-attr': 'dashboard-picker-widget',
+ },
+ ]
+
+ const proceedFor: Record<DashboardAddTileType, () => void> = {
+ insight: () => showAddInsightToDashboardModal(),
+ text_card: () => push(urls.dashboardTextTile(dashboard.id, 'new')),
+ button: () => push(urls.dashboardButtonTile(dashboard.id, 'new')),
+ widget: () =>
+ dashboardWidgetsEnabled
+ ? setAddWidgetModalOpen(true)
+ : push(urls.featurePreview(FEATURE_FLAGS.DASHBOARD_WIDGETS)),
+ }
+
+ return (
+ <LemonModal
+ isOpen={addTilePickerModalVisible}
+ onClose={hideAddTilePickerModal}
+ title="Add to dashboard"
+ description="Pick what you'd like to add."
+ width={720}
+ >
+ <div className="grid grid-cols-1 gap-8 sm:grid-cols-2">
+ {options.map((option) => (
+ <button
+ key={option.type}
+ type="button"
+ data-attr={option['data-attr']}
+ onClick={() => onSelect(option.type, proceedFor[option.type])}
+ className="flex cursor-pointer flex-col gap-2 rounded-lg border border-primary bg-surface-primary p-3 text-left transition-colors hover:border-accent hover:bg-surface-secondary"
+ >
+ <div className="h-32 w-full overflow-hidden rounded-md bg-surface-secondary p-2">
+ {option.preview}
+ </div>
+ <div className="flex items-center gap-2">
+ <span className="text-lg text-accent">{option.icon}</span>
+ <span className="font-semibold text-primary">{option.label}</span>
+ {option.tag && (
+ <LemonTag type={option.tag === 'new' ? 'success' : 'warning'} size="small">
+ {option.tag === 'new' ? 'New' : 'Beta'}
+ </LemonTag>
+ )}
+ </div>
+ <div className="text-xs text-secondary">{option.description}</div>
+ </button>
+ ))}
+ </div>
+ </LemonModal>
+ )
+}
diff --git a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx b/frontend/src/scenes/dashboard/DashboardHeader.test.tsx
index bb66f2ba3e35..85688fbde242 100644
--- a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx
+++ b/frontend/src/scenes/dashboard/DashboardHeader.test.tsx
@@ -1,8 +1,9 @@
import '@testing-library/jest-dom'
-import { cleanup, render } from '@testing-library/react'
+import { cleanup, fireEvent, render } from '@testing-library/react'
import { BindLogic } from 'kea'
+import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { DashboardEventSource } from 'lib/utils/eventUsageLogic'
@@ -10,6 +11,7 @@ import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { AccessControlLevel, DashboardMode, DashboardType, QueryBasedInsightModel } from '~/types'
+import { addTilePickerModalLogic } from './addTilePickerModalLogic'
import { DashboardHeader } from './DashboardHeader'
import { dashboardLogic } from './dashboardLogic'
@@ -161,4 +163,27 @@ describe('DashboardHeader', () => {
logic.unmount()
}
)
+
+ // The add-tile-picker experiment: the flag must route the Add click to the picker modal in the
+ // `test` variant and to the existing dropdown (never the picker) in control. Guards against the
+ // gating being removed or inverted in DashboardAddTileButton.
+ it.each([
+ { variant: 'test' as string | undefined, expectPicker: true },
+ { variant: undefined, expectPicker: false },
+ ])('add button opens picker only for the test variant (variant=$variant)', ({ variant, expectPicker }) => {
+ if (variant) {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.DASHBOARD_ADD_TILE_PICKER_MODAL], {
+ [FEATURE_FLAGS.DASHBOARD_ADD_TILE_PICKER_MODAL]: variant,
+ })
+ }
+
+ const { logic } = renderHeader({})
+ addTilePickerModalLogic.mount()
+
+ fireEvent.click(document.querySelector('[data-attr="dashboard-add-tile"]')!)
+
+ expect(addTilePickerModalLogic.values.addTilePickerModalVisible).toBe(expectPicker)
+
+ logic.unmount()
+ })
})
diff --git a/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx b/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx
index 4ece1bd70098..ab93ba7ad3bd 100644
--- a/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx
+++ b/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx
@@ -7,9 +7,10 @@ import { AccessControlAction } from 'lib/components/AccessControlAction'
import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
import { FEATURE_FLAGS } from 'lib/constants'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonMenu } from 'lib/lemon-ui/LemonMenu'
-import { DashboardEventSource } from 'lib/utils/eventUsageLogic'
+import { DashboardEventSource, eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { MaxTool } from 'scenes/max/MaxTool'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
@@ -18,18 +19,29 @@ import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
import { AccessControlLevel, AccessControlResourceType, DashboardMode } from '~/types'
import { addInsightToDashboardLogic } from './addInsightToDashboardModalLogic'
+import { addTilePickerModalLogic } from './addTilePickerModalLogic'
import { DashboardLoadAction, dashboardLogic } from './dashboardLogic'
export function DashboardAddTileButton(): JSX.Element | null {
const { dashboard, dashboardWidgetsEnabled } = useValues(dashboardLogic)
const { loadDashboard, setAddWidgetModalOpen } = useActions(dashboardLogic)
const { showAddInsightToDashboardModal } = useActions(addInsightToDashboardLogic)
+ const { showAddTilePickerModal } = useActions(addTilePickerModalLogic)
+ const { reportDashboardAddTileOptionClicked } = useActions(eventUsageLogic)
const { push } = useActions(router)
+ const showPickerModal = useFeatureFlag('DASHBOARD_ADD_TILE_PICKER_MODAL', 'test')
+
if (!dashboard) {
return null
}
+ const addButton = (
+ <LemonButton type="primary" data-attr="dashboard-add-tile" size="small" icon={<IconPlusSmall />}>
+ Add
+ </LemonButton>
+ )
+
return (
<MaxTool
className="shrink-0"
@@ -55,43 +67,68 @@ export function DashboardAddTileButton(): JSX.Element | null {
minAccessLevel={AccessControlLevel.Editor}
userAccessLevel={dashboard.user_access_level}
>
- <LemonMenu
- items={[
- {
- label: 'Insight',
- onClick: showAddInsightToDashboardModal,
- 'data-attr': 'dashboard-add-insight',
- },
- {
- label: 'Text card',
- onClick: () => push(urls.dashboardTextTile(dashboard.id, 'new')),
- 'data-attr': 'dashboard-add-text-tile',
- },
- {
- label: 'Button',
- 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',
- }
- : {
- label: 'Widget',
- tag: 'beta' as const,
- tooltip: 'Opens settings to enable the Dashboard widgets beta',
- 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 />}>
+ {showPickerModal ? (
+ <LemonButton
+ type="primary"
+ data-attr="dashboard-add-tile"
+ size="small"
+ icon={<IconPlusSmall />}
+ onClick={showAddTilePickerModal}
+ >
Add
</LemonButton>
- </LemonMenu>
+ ) : (
+ <LemonMenu
+ items={[
+ {
+ label: 'Insight',
+ onClick: () => {
+ reportDashboardAddTileOptionClicked('insight', 'control')
+ showAddInsightToDashboardModal()
+ },
+ 'data-attr': 'dashboard-add-insight',
+ },
+ {
+ label: 'Text card',
+ onClick: () => {
+ reportDashboardAddTileOptionClicked('text_card', 'control')
+ push(urls.dashboardTextTile(dashboard.id, 'new'))
+ },
+ 'data-attr': 'dashboard-add-text-tile',
+ },
+ {
+ label: 'Button',
+ onClick: () => {
+ reportDashboardAddTileOptionClicked('button', 'control')
+ push(urls.dashboardButtonTile(dashboard.id, 'new'))
+ },
+ 'data-attr': 'dashboard-add-button-tile',
+ },
+ dashboardWidgetsEnabled
+ ? {
+ label: 'Widget',
+ tag: 'new' as const,
+ onClick: () => {
+ reportDashboardAddTileOptionClicked('widget', 'control')
+ setAddWidgetModalOpen(true)
+ },
+ 'data-attr': 'dashboard-add-widget',
+ }
+ : {
+ label: 'Widget',
+ tag: 'beta' as const,
+ tooltip: 'Opens settings to enable the Dashboard widgets beta',
+ onClick: () => {
+ reportDashboardAddTileOptionClicked('widget', 'control')
+ push(urls.featurePreview(FEATURE_FLAGS.DASHBOARD_WIDGETS))
+ },
+ 'data-attr': 'dashboard-add-widget-preview',
+ },
+ ]}
+ >
+ {addButton}
+ </LemonMenu>
+ )}
</AccessControlAction>
</MaxTool>
)
diff --git a/frontend/src/scenes/dashboard/DashboardModals.tsx b/frontend/src/scenes/dashboard/DashboardModals.tsx
index a9865cbeaffc..b752d0cd0a62 100644
--- a/frontend/src/scenes/dashboard/DashboardModals.tsx
+++ b/frontend/src/scenes/dashboard/DashboardModals.tsx
@@ -14,6 +14,7 @@ import { userLogic } from 'scenes/userLogic'
import { dashboardsModel } from '~/models/dashboardsModel'
import { DashboardMode, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AddTilePickerModal } from './AddTilePickerModal'
import { DashboardInsightColorsModal } from './DashboardInsightColorsModal'
import { dashboardLogic } from './dashboardLogic'
import { DashboardTemplateEditor } from './DashboardTemplateEditor'
@@ -83,6 +84,7 @@ export function DashboardModals({ dashboard }: { dashboard: DashboardType<QueryB
}}
/>
)}
+ <AddTilePickerModal />
<DeleteDashboardModal />
<DuplicateDashboardModal />
<DashboardInsightColorsModal />
diff --git a/frontend/src/scenes/dashboard/addTilePickerModalLogic.ts b/frontend/src/scenes/dashboard/addTilePickerModalLogic.ts
new file mode 100644
index 000000000000..2026bfb08ef1
--- /dev/null
+++ b/frontend/src/scenes/dashboard/addTilePickerModalLogic.ts
@@ -0,0 +1,22 @@
+import { actions, kea, path, reducers } from 'kea'
+
+import type { addTilePickerModalLogicType } from './addTilePickerModalLogicType'
+
+export type DashboardAddTileType = 'insight' | 'text_card' | 'button' | 'widget'
+
+export const addTilePickerModalLogic = kea<addTilePickerModalLogicType>([
+ path(['scenes', 'dashboard', 'addTilePickerModalLogic']),
+ actions({
+ showAddTilePickerModal: true,
+ hideAddTilePickerModal: true,
+ }),
+ reducers({
+ addTilePickerModalVisible: [
+ false,
+ {
+ showAddTilePickerModal: () => true,
+ hideAddTilePickerModal: () => false,
+ },
+ ],
+ }),
+])
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsx
index bd73569bd0f1..0259c6362298 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx
+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx
@@ -2632,6 +2632,10 @@ export const dashboardLogic = kea<dashboardLogicType>([
}
const count = createdTiles.length
+ // Fire once per add action (not per tile) to stay consistent with the other tile types.
+ if (count > 0) {
+ eventUsageLogic.actions.reportDashboardTileAdded('widget')
+ }
if (count > 1) {
lemonToast.success(`Added ${count} widgets`)
}
diff --git a/frontend/src/scenes/insights/insightLogic.tsx b/frontend/src/scenes/insights/insightLogic.tsx
index 13a8903d4b58..69d222b757bf 100644
--- a/frontend/src/scenes/insights/insightLogic.tsx
+++ b/frontend/src/scenes/insights/insightLogic.tsx
@@ -584,6 +584,12 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
insightNumericId === undefined,
'save'
)
+ // A brand-new insight created with a dashboard attached is a tile added to that dashboard
+ // (the "create new" path of the add-to-dashboard flow). The existing-insight path fires this
+ // separately in addSavedInsightsModalLogic, so this won't double-count.
+ if (insightNumericId === undefined && (dashboards?.length ?? 0) > 0) {
+ eventUsageLogic.actions.reportDashboardTileAdded('insight')
+ }
lemonToast.success(`Insight saved${dashboards?.length === 1 ? ' & added to dashboard' : ''}`, {
button: {
label: 'View Insights list',
diff --git a/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts b/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts
index f8ce734c1b82..69192a759b0e 100644
--- a/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts
+++ b/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts
@@ -233,6 +233,7 @@ export const addSavedInsightsModalLogic = kea<addSavedInsightsModalLogicType>([
logic.mount()
logic.actions.loadDashboard({ action: DashboardLoadAction.Update })
logic.unmount()
+ eventUsageLogic.actions.reportDashboardTileAdded('insight')
lemonToast.success('Insight added to dashboard')
}
} catch (e) {