: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
feat(dashboards): add metrics to add-insight modal menu (#127780)
Frank Hamand0cd92701c481
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 14a55b647429..e659e982c5de 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6878,6 +6878,10 @@ snapshots:hash: v1.k794b7964.010da65c2bb2e55daed38244a9918ab578c84f020a1c8df2ed847a4670005aec.M8-1Oet6RSJ7ulOk_R2yYMfKo4IUctrRZQulmG15BVkproducts-dashboards-add-insight-to-dashboard-modal--with-more-insight-types--light:hash: v1.k794b7964.6c001db5555f48832f11ae8d9dcc535dff4e22044bb6dfce15db3a2a522f1fa9.GQCxp64JkEqDCNEeSD6gPtc5rwlzjHFJ-QnZu4lRips+ products-dashboards-add-insight-to-dashboard-modal--with-more-insight-types-and-metrics--dark:+ hash: v1.k794b7964.ae47defe4c15916f4bc9dbbc552a3aef89d54102aa4a9ae94d9961613189782a.QCkri5EX6WvUH40v6bfL147fml_W9EOjEAIGK-FQjAk+ products-dashboards-add-insight-to-dashboard-modal--with-more-insight-types-and-metrics--light:+ hash: v1.k794b7964.0d90933bf7fe46580b45cd8bedc78895be3e1694ac2d25e8dbbaf4156995e8b2.uDZhPMLvnomVB-RV_1Lmmgjzy2AMIcYu411UKLZjpnMproducts-dashboards-dashboard-widgets-overview--all-widget-types--dark:hash: v1.k794b7964.3b3689c002c42da7502405c35d4ebe2285aeaeda2015418d9e700bfe9dc47205.ByGuHj3aUBKZNgl5AzGDwbuMXT-HGQhG-Vcab7mz4Ywproducts-dashboards-dashboard-widgets-overview--all-widget-types--light:diff --git a/frontend/src/scenes/dashboard/addInsightToDashboardModal/AddInsightToDashboardModal.tsx b/frontend/src/scenes/dashboard/addInsightToDashboardModal/AddInsightToDashboardModal.tsxindex 77e14203a1e0..131328ab6294 100644--- a/frontend/src/scenes/dashboard/addInsightToDashboardModal/AddInsightToDashboardModal.tsx+++ b/frontend/src/scenes/dashboard/addInsightToDashboardModal/AddInsightToDashboardModal.tsx@@ -2,6 +2,7 @@ import { useActions, useValues } from 'kea'import { BindLogic } from 'kea'import posthog from 'posthog-js'+import { FEATURE_FLAGS } from 'lib/constants'import { IconInsightFunnels, IconInsightRetention, IconInsightTrends } from 'lib/lemon-ui/icons'import { LemonBanner } from 'lib/lemon-ui/LemonBanner'import { LemonButton } from 'lib/lemon-ui/LemonButton'@@ -9,10 +10,14 @@ import { LemonModal } from 'lib/lemon-ui/LemonModal'import { Popover } from 'lib/lemon-ui/Popover'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { addSavedInsightsModalLogic } from 'scenes/saved-insights/addSavedInsightsModalLogic'-import { isInsightTypeCreatable } from 'scenes/saved-insights/insightTypesMetadata'-import { INSIGHT_TYPES_METADATA } from 'scenes/saved-insights/insightTypesMetadata'+import {+ INSIGHT_TYPES_METADATA,+ QUERY_TYPES_METADATA,+ isInsightTypeCreatable,+} from 'scenes/saved-insights/insightTypesMetadata'import { urls } from 'scenes/urls'+import { NodeKind } from '~/queries/schema/schema-general'import { InsightType } from '~/types'import { AddSavedInsightsToDashboard } from 'products/product_analytics/frontend/insights/savedInsights/AddSavedInsightsToDashboard'@@ -52,6 +57,10 @@ export function AddInsightToDashboardModal(): JSX.Element {!QUICK_CREATE_TYPES.some((qt) => qt.type === type))+ const metricsEnabled =+ !!featureFlags[FEATURE_FLAGS.METRICS] && !!featureFlags[FEATURE_FLAGS.METRICS_INSIGHT_BUILDER]+ const MetricsIcon = QUERY_TYPES_METADATA[NodeKind.MetricsQuery].icon+return (<BindLogic logic={addSavedInsightsModalLogic} props={{}}><LemonModal@@ -115,6 +124,21 @@ export function AddInsightToDashboardModal(): JSX.Element {</LemonButton>)})}+ {metricsEnabled && (+ <LemonButton+ type="tertiary"+ fullWidth+ icon={<MetricsIcon />}+ to={urls.insightNew({+ type: InsightType.METRICS,+ dashboardId: dashboard?.id,+ })}+ data-attr="create-metrics"+ onClick={() => handleNewInsightClicked(InsightType.METRICS)}+ >+ {QUERY_TYPES_METADATA[NodeKind.MetricsQuery].name}+ </LemonButton>+ )}</div>}>diff --git a/products/dashboards/frontend/components/AddInsightToDashboardModal/AddInsightToDashboardModal.stories.tsx b/products/dashboards/frontend/components/AddInsightToDashboardModal/AddInsightToDashboardModal.stories.tsxindex b5489daeab7d..dfc7fa63ba84 100644--- a/products/dashboards/frontend/components/AddInsightToDashboardModal/AddInsightToDashboardModal.stories.tsx+++ b/products/dashboards/frontend/components/AddInsightToDashboardModal/AddInsightToDashboardModal.stories.tsx@@ -1,6 +1,7 @@import { Meta, StoryObj } from '@storybook/react'import { BindLogic } from 'kea'+import { FEATURE_FLAGS } from 'lib/constants'import __dashboard1 from 'scenes/dashboard/__mocks__/dashboard1.json'import __dashboards from 'scenes/dashboard/__mocks__/dashboards.json'import { AddInsightToDashboardModal } from 'scenes/dashboard/addInsightToDashboardModal/AddInsightToDashboardModal'@@ -92,6 +93,13 @@ export const WithMoreInsightTypes: Story = {render: () => <ModalStory showMore />,}+export const WithMoreInsightTypesAndMetrics: Story = {+ render: () => <ModalStory showMore />,+ parameters: {+ featureFlags: [FEATURE_FLAGS.METRICS, FEATURE_FLAGS.METRICS_INSIGHT_BUILDER],+ },+}+export const Empty: Story = {render: () => <ModalStory />,decorators: [