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(bi): split business intelligence from the sql editor (#111994)

Marius Andrad6d630428eba
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.md
index eed5642fb1f9..d7e311a26ad6 100644
--- a/docs/published/handbook/engineering/data-warehouse.md
+++ b/docs/published/handbook/engineering/data-warehouse.md
@@ -12,10 +12,15 @@ The SQL editor keeps unrun edits in browser storage, scoped to the user, project
An **Edited** label marks changes to a saved view or insight. **Discard changes** restores the saved copy already loaded in memory, then refreshes it from the server. The refresh preserves edits made after discarding.
Insights can be saved or updated before running the SQL. Updating a view still requires a successful run of the current SQL so its result types match the saved query. **Continue in a notebook** is in the update button's dropdown for saved views and insights.
-## Choosing data in BI mode
+## Choosing data in Business intelligence
-Clicking **BI** closes the SQL editor database sidebar; clicking **SQL** opens it again.
-The sidebar toggle remains available in both modes. **Locate** in the BI data pane is shown only while the sidebar is open.
+**Business intelligence** opens a visual worksheet at `/bi`, separately from the SQL editor, when the `sql-editor-bi-mode` feature flag is enabled. Both products keep their own unsaved working copies, including edits to the same saved view, insight, or draft. Existing SQL working copies remain available. Worksheet breadcrumbs preserve the visual configuration, and existing SQL editor links with `mode=bi` open in Business intelligence.
+
+Choose a connection in the **Data** panel, then select a table below it. **Run** is the first toolbar action, before **Swap rows and columns**.
+
+Discarding query edits preserves the worksheet's selected source and shelves.
+
+SQL query-scan advisories are hidden in Business intelligence. Query errors and warnings about stale sources or restricted data remain visible.
Use the table picker in the data pane to browse the same source groups and folders as the database tree.
The selected table is highlighted; expanding a folder does not select it.
@@ -23,7 +28,7 @@ Direct connections group tables by schema. Search matches table and folder names
## Calculated measures in BI mode
-With `SQL_EDITOR_BI_MODE` enabled, select a table in the SQL editor's BI mode and choose **Add calculated measure** in the data pane.
+With `SQL_EDITOR_BI_MODE` enabled, open **Business intelligence**, select a table and choose **Add calculated measure** in the data pane.
Enter a name and an aggregate SQL formula, such as `sum(revenue) / nullIf(count(DISTINCT user_id), 0)` for average revenue per user.
Use field names from the selected table. Filters apply before the formula runs for each group on the worksheet.
diff --git a/frontend/package.json b/frontend/package.json
index ce80f4c3d70e..8c83698d2da5 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -95,6 +95,7 @@
"@posthog/products-autoresearch": "workspace:*",
"@posthog/products-batch-exports": "workspace:*",
"@posthog/products-billing-alerts": "workspace:*",
+ "@posthog/products-business-intelligence": "workspace:*",
"@posthog/products-business-knowledge": "workspace:*",
"@posthog/products-canvas": "workspace:*",
"@posthog/products-cdp": "workspace:*",
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 20fd68266dd1..721f957807b1 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -9535,29 +9535,33 @@ snapshots:
scenes-app-data-warehouse-settings-schemas--multi-schema--light:
hash: v1.k794b7964.e5d678194a8e191fdf4f8a92cd7328f1e3cb162a81d3c4d05ef608f3c61537da.ZshlecoDn8CpsaVHaONi7UiXq8r-Xi4zJSWKeg7nAP0
scenes-app-data-warehouse-sql-editor--bi-calculated-measure-editor--dark:
- hash: v1.k794b7964.25fd8a22fa490bf3e3e600a984b131b28202b8172e46e1a35e090694dfe63e2f.UBgi2bw3KLPn9F1RDJIVKYgfFlzVDD2yZj4iUPufRVA
+ hash: v1.k794b7964.fed28414cb5986aa50993fc74438bc3bc5c6af5642e70ebabbe9e0e81eb50255.U2imLtSRZEitoDNd7tUBdss8HjEPZd_hYKGetLnhNq0
scenes-app-data-warehouse-sql-editor--bi-calculated-measure-editor--light:
- hash: v1.k794b7964.66016e766d5d3b78aae28be29d15e9bbf7ebb60b48de6d488eb7b10ea4676afd.wpa1Nkk9kYDByTPyA-MjGrtArnLDfzP4S6zkO34CMfo
+ hash: v1.k794b7964.fae71b7b2914a4275d15a3e6a9206ffb1bf49e0b9b9f74aab84c6de17b65f66c.BeaxGcG29CWTphBRLZ3TJgCpso521IxcRsMb7I1bd9g
scenes-app-data-warehouse-sql-editor--bi-connections--dark:
- hash: v1.k794b7964.1f2ab2237c64512591fa64ede2d01c957272510b58e8d280d03f972947127f18.FGHAY9evifk4UKdQC7B9nSpLfbdJH9G26TeeACebtLY
+ hash: v1.k794b7964.8e94a9871a03d59bfcadaed645a6162cac04afb123d8a8192292dfd8a4a95ce4.ulWG69cJoeFdHPN_HCAXYRrrI5YnUV7VWxVft0w_BlQ
scenes-app-data-warehouse-sql-editor--bi-connections--light:
- hash: v1.k794b7964.6cc3f998d8be9bf398eaaa215c3f8eaa9dc6557a2008361d3ba9bf3bf9d91da2.ddofcjJWgAQ_QZYP6WkNgJIp_TeW5k1Wmc_NTG1M7ZQ
+ hash: v1.k794b7964.e2a088f47b00a016ad23c3817301f58cc190608e91d6effda8f3b443b0a389eb.ydPs19XrC4KxNPRwT7PBvFewRyro0kEHP9mqHdXVZrY
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--dark:
- hash: v1.k794b7964.5a7a0a5291dae3a67320c33fe0d7e087ab35dcd5738ee99f101735cd7fe6895d.v84-mZ0JtjVV_28syxCq0lC0DPMk7Z4LPSKq_seARBg
+ hash: v1.k794b7964.d0440befffca1dd59f9c1ac2e2c6d6426d33eeea67e4d88442d55f990be1a1c5.m8IL1-1OvSPM3romBZjpwiPSA0MNh9v2nAS-LkwQ9HI
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--light:
- hash: v1.k794b7964.1ffabd4884721dfaf6e3fea1784ac20538d1e5af30d29271b2db164f5223d706.Z0ETewXWNHoOkvasozeFiSBGEQHOoMz6ep3by86ZWTI
+ hash: v1.k794b7964.5df84066a65ce86e3747075a17ba15d69b305b721e86d89c51d449bf09a98ec6.-PhhHAq0nBqAjxgbpSXwNToeEqW3rldWkmSoVr-OLVc
+ scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--dark:
+ hash: v1.k794b7964.25ca60ab3b6a8a145943a36e5ffd5a4545780102137b6934459cdf68cfe84362.B2hkGTtj1tGzx46nOdwvzrnzGXZLo-35IqPmny88x8s
+ scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--light:
+ hash: v1.k794b7964.e4efc0753b9983352857818d43228380326c6d091294bd48ecc4cdc3b06ed342.VECi00-laFbOutjLYmrcDW5XRJ9meAiWW6aBVd0wQ3U
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--dark:
- hash: v1.k794b7964.ec7208e3d9f889ee6eccaec6109093fd6ea85b10ad19f1aa4789308197f2608f.IaUpl-X0QQu76brKDTNqjxOXEgO4qro9a3NSFX-n0uw
+ hash: v1.k794b7964.2533d219e59391087bab8b6296551345fcf346c09723c6cc60b309324999fd3b.UdZA1IAlhdAtgYISqEHVZI4UvBu0r3Ukr6UAcXuBjp4
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--light:
- hash: v1.k794b7964.df08de4b285910a523a4074657beabe516e0132ecd5fe87f988dd9490188f43b.G0eYvWelXNWqVgrwyW0GlLMoUDDhkChYKpjXKwm9IWs
+ hash: v1.k794b7964.e4efc0753b9983352857818d43228380326c6d091294bd48ecc4cdc3b06ed342.yYO8bZAbQcCAq1-sKA6EcbhG9OZVduWTouJGttICkuY
scenes-app-data-warehouse-sql-editor--bi-quick-filters--dark:
- hash: v1.k794b7964.d18442be26b311eab84c68699e59cb29c8e2c6e70a0442ea7e998b5ceae7d634.K8j9lWp-nB9fGXpZV3l__sgKeGmnwrIKSH892cSTAZk
+ hash: v1.k794b7964.cd69820262ce6015b4504644eb20fc7c570801cda07b1ef67c6998bc657b435d.wNQ4wFfn91nZmfZHWSEh0sJQ2hTTP-Aa3VEhM6_oO5Y
scenes-app-data-warehouse-sql-editor--bi-quick-filters--light:
- hash: v1.k794b7964.7d055020d8b9cdc001efc8b5ca146f2d22e7c916af54b7361f2d8f61d59b940f.11bvglysenXe98m_innE4VvTdCUKMhRuSS62QGmFscM
+ hash: v1.k794b7964.f8cac292fb166b71a8df608d348766e4ce8dd17f3a2d9147944f96beea18cc43.b1VpKnlkIyNwUetcnrkx_ElNV6RuEWVsjl87p33Lrd0
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--dark:
- hash: v1.k794b7964.9438ec9789fe83709762909669ffa2b2377eab421066004a257c7467ea941ad1.zz_SahLmEDK9GozyYfPrB5ydS01sT-n0L9kpHjIPCd0
+ hash: v1.k794b7964.0d530bd2913cfd22c22ed60a9285d12b68737d3558dca5577ab9f4fcac4eb0d3.-JqBL5KmtMrF4ZtfyKT65AOils1mrFZjlqInCGPdSOs
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--light:
- hash: v1.k794b7964.27d42f80122f06e2159d402c8887260e3a057bae29102b96b66f6de97c4116c3.04u1T8VmDQZWOP90QHr9sO19BElmuaemVAxK-394fHc
+ hash: v1.k794b7964.9765f8c25dcf91c7cce0c14eab7ab4eebae8c6748f0d489ecb55b2d89aaa55dc.7alrfcAikJhVuMlo6_s85O3vANBxSj24UxR5XuCd4Dw
scenes-app-data-warehouse-sql-editor--edited-insight--dark:
hash: v1.k794b7964.334b216a8359c768613cdec5b99a8a8ee26b6b5fac76397eaed8d6d1401a23c0.0pI7NMTufzUIfDel9Ngmhv3P3sdBu6IgpSj5xYNmYrY
scenes-app-data-warehouse-sql-editor--edited-insight--light:
diff --git a/frontend/src/layout/panel-layout/DatabaseTree/DatabaseTree.tsx b/frontend/src/layout/panel-layout/DatabaseTree/DatabaseTree.tsx
index 67c0b53552c9..2aa3b3ef487b 100644
--- a/frontend/src/layout/panel-layout/DatabaseTree/DatabaseTree.tsx
+++ b/frontend/src/layout/panel-layout/DatabaseTree/DatabaseTree.tsx
@@ -102,7 +102,6 @@ export const DatabaseTree = memo(function DatabaseTree({
<QueryDatabase
virtualizationScrollContainerRef={scrollContainerRef}
extraTreeSections={extraTreeSections}
- tabId={tabId}
/>
</div>
<SyncMoreNotice />
diff --git a/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx b/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx
index e70ea30fb61b..c8f5fded140e 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/defaultTree.tsx
@@ -47,6 +47,7 @@ import {
IconMessage,
IconNotebook,
IconNotification,
+ IconPageChart,
IconPencil,
IconPeople,
IconPerson,
@@ -154,6 +155,13 @@ const iconTypes: Record<FileSystemIconType, { icon: JSX.Element; iconColor?: Fil
icon: <IconEndpoints />,
iconColor: ['var(--color-product-endpoints-light)', 'var(--color-product-endpoints-dark)'],
},
+ business_intelligence: {
+ icon: <IconPageChart />,
+ iconColor: [
+ 'var(--color-product-business-intelligence-light)',
+ 'var(--color-product-business-intelligence-dark)',
+ ],
+ },
sql_editor: {
icon: <IconServer />,
iconColor: ['var(--color-product-data-warehouse-light)'],
diff --git a/frontend/src/layout/panel-layout/sidebarProductMeta.ts b/frontend/src/layout/panel-layout/sidebarProductMeta.ts
index a3ced4a9bbc6..3413799676b9 100644
--- a/frontend/src/layout/panel-layout/sidebarProductMeta.ts
+++ b/frontend/src/layout/panel-layout/sidebarProductMeta.ts
@@ -69,6 +69,7 @@ export const SIDEBAR_PRODUCTS_WITHOUT_DOCS = new Set<string>([
'Apps',
'Autoresearch',
'Broadcasts',
+ 'Business intelligence',
'Business knowledge',
'Engineering analytics',
'Identity matching',
diff --git a/frontend/src/productScenes.tsx b/frontend/src/productScenes.tsx
index ca1c023972c0..e9adf6118e71 100644
--- a/frontend/src/productScenes.tsx
+++ b/frontend/src/productScenes.tsx
@@ -51,6 +51,7 @@ export const productScenes: Record<string, () => Promise<any>> = {
Autoresearch: () => import('../../products/autoresearch/frontend/AutoresearchScene'),
AutoresearchNew: () => import('../../products/autoresearch/frontend/AutoresearchNewScene'),
AutoresearchPipeline: () => import('../../products/autoresearch/frontend/AutoresearchPipelineScene'),
+ BusinessIntelligence: () => import('../../products/business_intelligence/frontend/BusinessIntelligenceScene'),
BusinessKnowledge: () => import('../../products/business_knowledge/frontend/scenes/sources/BusinessKnowledgeScene'),
BusinessKnowledgePlayground: () =>
import('products/business_knowledge/frontend/scenes/playground/BusinessKnowledgePlaygroundScene'),
diff --git a/frontend/src/products.json b/frontend/src/products.json
index f981766cf230..c3d7cb258302 100644
--- a/frontend/src/products.json
+++ b/frontend/src/products.json
@@ -63,6 +63,13 @@
"type": "autoresearch",
"intents": ["autoresearch"]
},
+ {
+ "path": "Business intelligence",
+ "category": "Data",
+ "iconType": "business_intelligence",
+ "type": null,
+ "intents": []
+ },
{
"path": "Business knowledge",
"category": "Data",
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index aa08008a8e67..a17b4e0673e2 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -112,6 +112,7 @@ export const productRoutes: Record<string, [string, string]> = {
'/autoresearch': ['Autoresearch', 'autoresearch'],
'/autoresearch/new': ['AutoresearchNew', 'autoresearchNew'],
'/autoresearch/:id': ['AutoresearchPipeline', 'autoresearchPipeline'],
+ '/bi': ['BusinessIntelligence', 'businessIntelligence'],
'/business-knowledge': ['BusinessKnowledge', 'businessKnowledge'],
'/business-knowledge/settings': ['BusinessKnowledgeSettings', 'businessKnowledgeSettings'],
'/business-knowledge/playground': ['BusinessKnowledgePlayground', 'businessKnowledgePlayground'],
@@ -667,6 +668,14 @@ export const productConfiguration: Record<string, any> = {
},
AutoresearchNew: { name: 'New model', projectBased: true },
AutoresearchPipeline: { name: 'Autoresearch model', projectBased: true },
+ BusinessIntelligence: {
+ name: 'Business intelligence',
+ projectBased: true,
+ layout: 'app-raw-no-header',
+ hideProjectNotice: true,
+ description: 'Explore data and build charts with a visual worksheet.',
+ iconType: 'business_intelligence',
+ },
BusinessKnowledge: {
name: 'Business knowledge',
projectBased: true,
@@ -1310,6 +1319,7 @@ export const productUrls = {
autoresearch: (): string => '/autoresearch',
autoresearchNew: (): string => '/autoresearch/new',
autoresearchPipeline: (id: string): string => `/autoresearch/${id}`,
+ businessIntelligence: (): string => '/bi',
businessKnowledge: (): string => '/business-knowledge',
businessKnowledgeSettings: (): string => '/business-knowledge/settings',
businessKnowledgePlayground: (chatId?: string): string =>
@@ -2106,6 +2116,7 @@ export type ProductTreePath =
| 'Apps'
| 'Autoresearch'
| 'Broadcasts'
+ | 'Business intelligence'
| 'Business knowledge'
| 'Clusters'
| 'Code review'
@@ -2202,6 +2213,20 @@ export const getTreeItemsProducts = (): FileSystemImport[] => [
sceneKey: 'Broadcasts',
sceneKeys: ['Workflows', 'Workflow', 'WorkflowsLibraryTemplate', 'Broadcasts', 'Broadcast'],
},
+ {
+ path: 'Business intelligence',
+ intents: [],
+ category: ProductItemCategory.DATA,
+ iconType: 'business_intelligence',
+ iconColor: [
+ 'var(--color-product-business-intelligence-light)',
+ 'var(--color-product-business-intelligence-dark)',
+ ],
+ href: urls.businessIntelligence(),
+ flag: FEATURE_FLAGS.SQL_EDITOR_BI_MODE,
+ sceneKey: 'BusinessIntelligence',
+ sceneKeys: ['BusinessIntelligence'],
+ },
{
path: 'Business knowledge',
intents: [ProductKey.BUSINESS_KNOWLEDGE],
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index de8f2992699a..7fc69a2cc44c 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -27189,6 +27189,7 @@
"managed_viewsets",
"endpoints",
"sql_editor",
+ "business_intelligence",
"web_analytics",
"error_tracking",
"heatmap",
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 6cf29ee4aaaf..97a560fd2972 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -5433,6 +5433,7 @@ export type FileSystemIconType =
| 'managed_viewsets'
| 'endpoints'
| 'sql_editor'
+ | 'business_intelligence'
| 'web_analytics'
| 'error_tracking'
| 'heatmap'
diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
index 91b4f655d22f..0dfd0223174a 100644
--- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
@@ -867,6 +867,7 @@ export function OutputPane({ tabId, showToolbar = true, biMode = false, onShareT
setProgress,
progress: queryId ? progressCache[queryId] : undefined,
showVisualizationSettings: showToolbar && isChartSettingsPanelOpen,
+ showQueryScan: !biMode,
isEmbeddedMode,
}
const sharedActionsProps = {
@@ -1219,7 +1220,13 @@ const QueryWarningsBanner = ({ warnings }: { warnings?: HogQLQueryResponse['warn
)
}
-const ErrorState = ({ responseError, sourceQuery, queryCancelled, response }: any): JSX.Element | null => {
+const ErrorState = ({
+ responseError,
+ sourceQuery,
+ queryCancelled,
+ response,
+ showQueryScan,
+}: any): JSX.Element | null => {
const error = queryCancelled
? 'The query was cancelled'
: response && 'error' in response && !!response.error
@@ -1242,7 +1249,7 @@ const ErrorState = ({ responseError, sourceQuery, queryCancelled, response }: an
<FixErrorButton contentOverride="Fix error with AI" type="primary" source="query-error" />
}
/>
- <EditorQueryScanBanner />
+ {showQueryScan && <EditorQueryScanBanner />}
</div>
</div>
)
@@ -1279,6 +1286,7 @@ const Content = ({
progress,
insightLoading,
showVisualizationSettings,
+ showQueryScan,
isEmbeddedMode,
}: any): JSX.Element | null => {
const { selectedDirectSource } = useValues(sqlEditorLogic)
@@ -1340,6 +1348,7 @@ const Content = ({
sourceQuery={sourceQuery}
queryCancelled={queryCancelled}
response={response}
+ showQueryScan={showQueryScan}
/>
)
}
@@ -1372,7 +1381,7 @@ const Content = ({
return (
<div className="absolute inset-0 flex flex-col border-t overflow-hidden">
<QueryWarningsBanner warnings={response?.warnings} />
- <EditorQueryScanBanner />
+ {showQueryScan && <EditorQueryScanBanner />}
<div className="flex flex-col flex-1 min-h-0 hide-scrollbar overflow-auto">
<InternalDataTableVisualization
uniqueKey={vizKey}
@@ -1444,7 +1453,7 @@ const Content = ({
return (
<div className="flex flex-col flex-1 min-h-0 w-full overflow-hidden">
<QueryWarningsBanner warnings={response?.warnings} />
- <EditorQueryScanBanner />
+ {showQueryScan && <EditorQueryScanBanner />}
{rows.length === 0 ? (
<EmptyResultsState />
) : (
diff --git a/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx b/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx
index 115f0547176c..0f8dffa3bfa1 100644
--- a/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx
@@ -4,27 +4,21 @@ import type { editor as importedEditor } from 'monaco-editor'
import posthog from 'posthog-js'
import { memo, useCallback, useMemo, useRef } from 'react'
-import { IconDatabase, IconGear, IconInfo, IconPlayFilled, IconSidebarClose } from '@posthog/icons'
+import { IconDatabase, IconGear, IconInfo, IconSidebarClose } from '@posthog/icons'
import { LemonDivider } from '@posthog/lemon-ui'
import { AccessControlAction } from 'lib/components/AccessControlAction'
-import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
-import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
import { useDebouncedValue } from 'lib/hooks/useDebouncedValue'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
-import { IconCancel } from 'lib/lemon-ui/icons'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonMenu } from 'lib/lemon-ui/LemonMenu/LemonMenu'
-import { LemonSegmentedButton } from 'lib/lemon-ui/LemonSegmentedButton'
import { LemonSwitch } from 'lib/lemon-ui/LemonSwitch'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { cn } from 'lib/utils/css-classes'
import { SQLEditorMode } from 'scenes/data-warehouse/editor/sqlEditorModes'
-import { Scene } from 'scenes/sceneTypes'
import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
import { SceneTitlePanelButton } from '~/layout/scenes/components/SceneTitlePanelButton'
-import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
@@ -32,9 +26,6 @@ import { VimrcModal } from 'products/data_warehouse/frontend/shared/components/V
import { sqlEditorVimLogic } from 'products/data_warehouse/frontend/shared/logics/sqlEditorVimLogic'
import { useAttachedContext, useMcpToolApplyBack } from 'products/posthog_ai/frontend/api/logics'
-import { BIEditor } from './bi/BIEditor'
-import { biEditorLogic } from './bi/biEditorLogic'
-import { BIEditorView } from './bi/biEditorTypes'
import { FixErrorButton } from './components/FixErrorButton'
import { ConnectionSelector } from './ConnectionSelector'
import { editorSizingLogic } from './editorSizingLogic'
@@ -43,6 +34,7 @@ import { OutputPane } from './OutputPane'
import { QueryFiltersMenu } from './QueryFiltersMenu'
import { QueryPane } from './QueryPane'
import { QueryVariablesMenu } from './QueryVariablesMenu'
+import { RunButton } from './RunButton'
import { sqlEditorLogic, tabModelPath } from './sqlEditorLogic'
const EMBEDDED_MAX_TOOL_CONTEXT_DEBOUNCE_MS = 150
@@ -93,7 +85,6 @@ export function QueryWindow({
}: QueryWindowProps): JSX.Element {
const codeEditorKey = `hogql-editor-${tabId}`
const logic = sqlEditorLogic({ tabId })
- const biLogic = biEditorLogic({ tabId })
const {
queryInput,
@@ -107,7 +98,6 @@ export function QueryWindow({
sendRawQueryEnabled,
selectedConnectionSupportsHogQL,
} = useValues(logic)
- const { config: biConfig, editorView } = useValues(biLogic)
const {
setQueryInput,
@@ -120,18 +110,14 @@ export function QueryWindow({
openMaterializationModal,
setSourceQuery,
} = useActions(logic)
- const { setEditorView } = useActions(biLogic)
const { setSuggestedQueryInput, reportAIQueryPromptOpen, fixIndexUsageWithAI } = useActions(logic)
- const biModeFeatureEnabled = useFeatureFlag('SQL_EDITOR_BI_MODE')
const vimModeFeatureEnabled = useFeatureFlag('SQL_EDITOR_VIM_MODE')
const { vimModeEnabled, vimrc, editorSettingsMenuKey } = useValues(sqlEditorVimLogic)
const { setVimModeEnabled, openVimrcModal, setEditorSettingsMenuOpen } = useActions(sqlEditorVimLogic)
const { isDatabaseTreeCollapsed } = useValues(editorSizingLogic)
- const { setDatabaseTreeCollapsed } = useActions(editorSizingLogic)
// Raw-only connections are forced to raw SQL mode — no toggle to show.
const canSendRawQuery = !!selectedConnectionId && selectedConnectionSupportsHogQL
- const showBIEditor = biModeFeatureEnabled && mode === SQLEditorMode.FullScene && editorView === BIEditorView.BI
const debouncedMaxToolQueryInput = useDebouncedValue(queryInput, EMBEDDED_MAX_TOOL_CONTEXT_DEBOUNCE_MS)
const debouncedMaxToolSourceQuery = useDebouncedValue(sourceQuery, EMBEDDED_MAX_TOOL_CONTEXT_DEBOUNCE_MS)
const executeSqlToolStateRef = useRef({ queryInput, sourceQuery })
@@ -289,44 +275,23 @@ export function QueryWindow({
mode={mode}
hostProduct={hostProduct}
/>
- {mode === SQLEditorMode.FullScene && biModeFeatureEnabled ? (
- <LemonSegmentedButton
- value={editorView}
- onChange={(view) => {
- setEditorView(view)
- setDatabaseTreeCollapsed(view === BIEditorView.BI)
- }}
- options={[
- { value: BIEditorView.SQL, label: 'SQL' },
- { value: BIEditorView.BI, label: 'BI' },
- ]}
- size="small"
- />
- ) : null}
{hideRunButton ? null : (
<RunButton
onRunQuery={onRunQuery}
runQueryLoading={runQueryLoading}
- runQueryDisabledReason={
- runQueryDisabledReason ??
- (showBIEditor && !biConfig.source
- ? 'Drag a field into the BI editor before running'
- : undefined)
- }
+ runQueryDisabledReason={runQueryDisabledReason}
runQueryTooltip={runQueryTooltip}
onCancelQuery={onCancelQuery}
cancelQueryLoading={cancelQueryLoading}
/>
)}
<CollapsedConnectionSelector tabId={tabId} mode={mode} />
- {!showBIEditor ? <LemonDivider vertical /> : null}
- {!showBIEditor ? (
- <QueryVariablesMenu
- disabledReason={editingView ? 'Variables are not allowed in views.' : undefined}
- />
- ) : null}
- {!showBIEditor ? <QueryFiltersMenu /> : null}
- {editingView && !showBIEditor ? (
+ <LemonDivider vertical />
+ <QueryVariablesMenu
+ disabledReason={editingView ? 'Variables are not allowed in views.' : undefined}
+ />
+ <QueryFiltersMenu />
+ {editingView ? (
<AccessControlAction
resourceType={AccessControlResourceType.WarehouseObjects}
minAccessLevel={AccessControlLevel.Editor}
@@ -374,13 +339,7 @@ export function QueryWindow({
</div>
) : null}
- {showQueryPanel && showBIEditor ? (
- <BIEditor tabId={tabId}>
- {showOutputPanel ? <InternalQueryWindow tabId={tabId} biMode onShareTab={onShareTab} /> : null}
- </BIEditor>
- ) : null}
-
- {showQueryPanel && !showBIEditor ? (
+ {showQueryPanel ? (
<QueryPane
originalValue={originalQueryInput ?? ''}
queryInput={(suggestedQueryInput || queryInput) ?? ''}
@@ -444,9 +403,7 @@ export function QueryWindow({
/>
) : null}
- {showOutputPanel && !(showQueryPanel && showBIEditor) ? (
- <InternalQueryWindow tabId={tabId} biMode={showBIEditor} onShareTab={onShareTab} />
- ) : null}
+ {showOutputPanel ? <InternalQueryWindow tabId={tabId} biMode={false} onShareTab={onShareTab} /> : null}
</div>
)
}
@@ -494,118 +451,6 @@ function ExpandDatabaseTreeButton({
)
}
-function RunButton({
- onRunQuery,
- runQueryLoading,
- runQueryDisabledReason,
- runQueryTooltip,
- onCancelQuery,
- cancelQueryLoading,
-}: {
- onRunQuery?: () => void
- runQueryLoading?: boolean
- runQueryDisabledReason?: string
- runQueryTooltip?: string
- onCancelQuery?: () => void
- cancelQueryLoading?: boolean
-}): JSX.Element {
- const { runQuery, runSubquery } = useActions(sqlEditorLogic)
- const { cancelQuery } = useActions(dataNodeLogic)
- const { responseLoading } = useValues(dataNodeLogic)
- const { metadata, queryInput, isSourceQueryLastRun } = useValues(sqlEditorLogic)
-
- const isRunning = onRunQuery ? !!runQueryLoading : responseLoading
- // The external-run path shows a cancel affordance only when a canceller is provided.
- const showCancel = isRunning && (!onRunQuery || !!onCancelQuery)
-
- const [iconColor, tooltipContent] = useMemo(() => {
- if (onRunQuery) {
- if (isRunning && onCancelQuery) {
- return ['var(--success)', 'Stop the running query']
- }
- return ['var(--success)', runQueryTooltip ?? 'Run query']
- }
-
- if (isSourceQueryLastRun) {
- return ['var(--primary)', 'No changes to run']
- }
-
- // No index verdict colors this button. The per-filter report counts filters, and a count does
- // not track what a query costs: one selective filter bounds the read however many others scan,
- // and nothing here yet looks at the time range, which is what really decides how much is read.
- return ['var(--success)', 'New changes to run']
- }, [metadata, queryInput, isSourceQueryLastRun, onRunQuery, runQueryTooltip, isRunning, onCancelQuery])
-
- const sideAction = useMemo(
- () =>
- responseLoading || onRunQuery
- ? undefined
- : {
- dropdown: {
- placement: 'bottom-end' as const,
- overlay: (
- <>
- <LemonButton
- fullWidth
- onClick={() => runQuery()}
- sideIcon={<span className="text-muted text-xs">⌘↵</span>}
- >
- Run query at cursor
- </LemonButton>
- <LemonButton
- fullWidth
- onClick={() => runSubquery()}
- sideIcon={<span className="text-muted text-xs">⌘⇧↵</span>}
- >
- Run innermost subquery at cursor
- </LemonButton>
- </>
- ),
- },
- },
- [onRunQuery, responseLoading, runQuery, runSubquery]
- )
-
- return (
- <Shortcut
- name="SQLEditorRun"
- keybind={[keyBinds.run]}
- intent={showCancel ? 'Cancel query' : 'Run query'}
- interaction="click"
- scope={Scene.SQLEditor}
- >
- <LemonButton
- data-attr="sql-editor-run-button"
- onClick={() => {
- if (onRunQuery) {
- if (runQueryLoading) {
- // Guard against double submission: one cancel request at a time.
- if (onCancelQuery && !cancelQueryLoading) {
- onCancelQuery()
- }
- } else {
- onRunQuery()
- }
- } else if (responseLoading) {
- cancelQuery()
- } else {
- runQuery()
- }
- }}
- icon={showCancel ? <IconCancel /> : <IconPlayFilled color={iconColor} />}
- type="primary"
- size="small"
- tooltip={tooltipContent}
- sideAction={sideAction}
- loading={onRunQuery ? (onCancelQuery ? !!cancelQueryLoading : isRunning) : false}
- disabledReason={runQueryDisabledReason}
- >
- {showCancel ? 'Cancel' : 'Run'}
- </LemonButton>
- </Shortcut>
- )
-}
-
const InternalQueryWindow = memo(function InternalQueryWindow({
tabId,
biMode,
diff --git a/frontend/src/scenes/data-warehouse/editor/RunButton.tsx b/frontend/src/scenes/data-warehouse/editor/RunButton.tsx
new file mode 100644
index 000000000000..eb95a5a78014
--- /dev/null
+++ b/frontend/src/scenes/data-warehouse/editor/RunButton.tsx
@@ -0,0 +1,128 @@
+import { useActions, useValues } from 'kea'
+import { useMemo } from 'react'
+
+import { IconPlayFilled } from '@posthog/icons'
+
+import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
+import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
+import { IconCancel } from 'lib/lemon-ui/icons'
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { Scene } from 'scenes/sceneTypes'
+
+import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
+
+import { sqlEditorLogic } from './sqlEditorLogic'
+
+export function RunButton({
+ onRunQuery,
+ runQueryLoading,
+ runQueryDisabledReason,
+ runQueryTooltip,
+ onCancelQuery,
+ cancelQueryLoading,
+ scope = Scene.SQLEditor,
+}: {
+ onRunQuery?: () => void
+ runQueryLoading?: boolean
+ runQueryDisabledReason?: string
+ runQueryTooltip?: string
+ onCancelQuery?: () => void
+ cancelQueryLoading?: boolean
+ scope?: Scene.SQLEditor | Scene.BusinessIntelligence
+}): JSX.Element {
+ const { runQuery, runSubquery } = useActions(sqlEditorLogic)
+ const { cancelQuery } = useActions(dataNodeLogic)
+ const { responseLoading } = useValues(dataNodeLogic)
+ const { metadata, queryInput, isSourceQueryLastRun } = useValues(sqlEditorLogic)
+
+ const isRunning = onRunQuery ? !!runQueryLoading : responseLoading
+ // The external-run path shows a cancel affordance only when a canceller is provided.
+ const showCancel = isRunning && (!onRunQuery || !!onCancelQuery)
+
+ const [iconColor, tooltipContent] = useMemo(() => {
+ if (onRunQuery) {
+ if (isRunning && onCancelQuery) {
+ return ['var(--success)', 'Stop the running query']
+ }
+ return ['var(--success)', runQueryTooltip ?? 'Run query']
+ }
+
+ if (isSourceQueryLastRun) {
+ return ['var(--primary)', 'No changes to run']
+ }
+
+ // No index verdict colors this button. The per-filter report counts filters, and a count does
+ // not track what a query costs: one selective filter bounds the read however many others scan,
+ // and nothing here yet looks at the time range, which is what really decides how much is read.
+ return ['var(--success)', 'New changes to run']
+ }, [metadata, queryInput, isSourceQueryLastRun, onRunQuery, runQueryTooltip, isRunning, onCancelQuery])
+
+ const sideAction = useMemo(
+ () =>
+ responseLoading || onRunQuery || scope === Scene.BusinessIntelligence
+ ? undefined
+ : {
+ dropdown: {
+ placement: 'bottom-end' as const,
+ overlay: (
+ <>
+ <LemonButton
+ fullWidth
+ onClick={() => runQuery()}
+ sideIcon={<span className="text-muted text-xs">⌘↵</span>}
+ >
+ Run query at cursor
+ </LemonButton>
+ <LemonButton
+ fullWidth
+ onClick={() => runSubquery()}
+ sideIcon={<span className="text-muted text-xs">⌘⇧↵</span>}
+ >
+ Run innermost subquery at cursor
+ </LemonButton>
+ </>
+ ),
+ },
+ },
+ [onRunQuery, responseLoading, runQuery, runSubquery, scope]
+ )
+
+ return (
+ <Shortcut
+ name="SQLEditorRun"
+ keybind={[keyBinds.run]}
+ intent={showCancel ? 'Cancel query' : 'Run query'}
+ interaction="click"
+ scope={scope}
+ >
+ <LemonButton
+ data-attr="sql-editor-run-button"
+ onClick={() => {
+ if (onRunQuery) {
+ if (runQueryLoading) {
+ // Guard against double submission: one cancel request at a time.
+ if (onCancelQuery && !cancelQueryLoading) {
+ onCancelQuery()
+ }
+ } else {
+ onRunQuery()
+ }
+ } else if (responseLoading) {
+ cancelQuery()
+ } else {
+ runQuery()
+ }
+ }}
+ icon={showCancel ? <IconCancel /> : <IconPlayFilled color={iconColor} />}
+ type="primary"
+ size="small"
+ tooltip={tooltipContent}
+ sideAction={sideAction}
+ loading={onRunQuery ? (onCancelQuery ? !!cancelQueryLoading : isRunning) : false}
+ disabledReason={runQueryDisabledReason}
+ >
+ {showCancel ? 'Cancel' : 'Run'}
+ </LemonButton>
+ </Shortcut>
+ )
+}
diff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsx
index 8e53198e02c6..a07f14cff836 100644
--- a/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsx
@@ -1,7 +1,7 @@
import { Monaco } from '@monaco-editor/react'
import { BindLogic, useActions, useValues } from 'kea'
import type { editor as importedEditor } from 'monaco-editor'
-import { useEffect, useMemo, useRef, useState } from 'react'
+import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
import { IconBook, IconChevronDown, IconDownload, IconNotebook, IconX } from '@posthog/icons'
import { LemonModal, LemonTag, Spinner } from '@posthog/lemon-ui'
@@ -66,6 +66,8 @@ const VARIABLE_QUERY_SYNC_DEBOUNCE_MS = 150
const MAX_TOOL_CONTEXT_DEBOUNCE_MS = 150
interface SQLEditorProps {
+ children?: ReactNode
+
tabId?: string
mode?: SQLEditorMode
showDatabaseTree?: boolean
@@ -94,6 +96,7 @@ interface SQLEditorProps {
}
export function SQLEditor({
+ children,
tabId,
mode = SQLEditorMode.FullScene,
showDatabaseTree,
@@ -125,9 +128,9 @@ export function SQLEditor({
const shouldShowDatabaseTree = showDatabaseTree ?? hasShownDatabaseTree
const showQueryPanel = panel !== SQLEditorPanel.Output
const showOutputPanel = panel !== SQLEditorPanel.Query
- const showSceneTitle = panel === SQLEditorPanel.Full && mode === SQLEditorMode.FullScene
+ const showSceneTitle = panel === SQLEditorPanel.Full && !isEmbeddedSQLEditorMode(mode)
const showDatabaseTreePanel = showQueryPanel && shouldShowDatabaseTree
- const showFullSceneModals = mode === SQLEditorMode.FullScene
+ const showFullSceneModals = !isEmbeddedSQLEditorMode(mode)
const editorSizingLogicProps = useMemo(() => {
// The scene keeps one shared set of pane sizes across its tabs. Notebook cells each get their
@@ -170,7 +173,7 @@ export function SQLEditor({
logicKey: resizerKey('database-tree'),
placement: 'right' as const,
persistent: true,
- marginTop: mode === SQLEditorMode.FullScene ? 8 : 0,
+ marginTop: !isEmbeddedSQLEditorMode(mode) ? 8 : 0,
},
}
}, [mode, tabId, queryPaneDefaultHeight, queryPaneMinHeight])
@@ -186,7 +189,7 @@ export function SQLEditor({
}
})
- // The SQL/BI view toggle and the sidebar "Query" action tear the editor widget down and
+ // The sidebar "Query" action tears the editor widget down and
// rebuild it while this scene stays mounted. Nothing else clears the cached reference, so the
// logic keeps a disposed editor as a prop. Drop only the editor the instant Monaco disposes it,
// and keep the Monaco namespace: `Uri` and `editor.createModel`/`getModel` stay valid after the
@@ -302,27 +305,29 @@ export function SQLEditor({
ref={ref}
>
<ViewLoadingOverlay />
- <QueryWindow
- mode={mode}
- tabId={tabId || ''}
- showDatabaseTree={showDatabaseTreePanel}
- onShowDatabaseTree={() => setHasShownDatabaseTree(true)}
- hostProduct={hostProduct}
- showQueryPanel={showQueryPanel}
- showOutputPanel={showOutputPanel}
- onSetMonacoAndEditor={(nextMonaco, nextEditor) =>
- setMonacoAndEditor([nextMonaco, nextEditor])
- }
- onRunQuery={onRunQuery}
- runQueryLoading={runQueryLoading}
- runQueryDisabledReason={runQueryDisabledReason}
- runQueryTooltip={runQueryTooltip}
- onCancelQuery={onCancelQuery}
- cancelQueryLoading={cancelQueryLoading}
- hideRunButton={hideRunButton}
- onShareTab={onShareTab}
- autoFocusQueryPane={autoFocusQueryPane}
- />
+ {children ?? (
+ <QueryWindow
+ mode={mode}
+ tabId={tabId || ''}
+ showDatabaseTree={showDatabaseTreePanel}
+ onShowDatabaseTree={() => setHasShownDatabaseTree(true)}
+ hostProduct={hostProduct}
+ showQueryPanel={showQueryPanel}
+ showOutputPanel={showOutputPanel}
+ onSetMonacoAndEditor={(nextMonaco, nextEditor) =>
+ setMonacoAndEditor([nextMonaco, nextEditor])
+ }
+ onRunQuery={onRunQuery}
+ runQueryLoading={runQueryLoading}
+ runQueryDisabledReason={runQueryDisabledReason}
+ runQueryTooltip={runQueryTooltip}
+ onCancelQuery={onCancelQuery}
+ cancelQueryLoading={cancelQueryLoading}
+ hideRunButton={hideRunButton}
+ onShareTab={onShareTab}
+ autoFocusQueryPane={autoFocusQueryPane}
+ />
+ )}
</div>
</div>
</div>
diff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
index 8d322b1de39c..c7f4226c8abf 100644
--- a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
@@ -16,9 +16,10 @@ import type { MockResolverInfo } from '~/mocks/utils'
import type { DataWarehouseSavedQuery } from '~/types'
import { AccessControlLevel, AccessControlResourceType, ChartDisplayType } from '~/types'
+import { BIConfig, BIField, buildBIQuery } from 'products/business_intelligence/frontend/biEditorTypes'
+
import { expect, userEvent } from 'storybook/test'
-import { BIConfig, BIField, buildBIQuery } from './bi/biEditorTypes'
import { QueryInfo } from './output-pane-tabs/QueryInfo'
import { sqlEditorLogic } from './sqlEditorLogic'
@@ -395,7 +396,7 @@ export const BIModeWorksheet: Story = {
parameters: {
featureFlags: [FEATURE_FLAGS.SQL_EDITOR_BI_MODE],
// The editor restores BI state only alongside the query it generated
- pageUrl: `${urls.sqlEditor()}#${new URLSearchParams({
+ pageUrl: `${urls.businessIntelligence()}#${new URLSearchParams({
q: buildBIQuery(BI_WORKSHEET_CONFIG)?.query ?? '',
mode: 'bi',
bi: JSON.stringify(BI_WORKSHEET_CONFIG),
@@ -422,6 +423,15 @@ export const BIModeWorksheet: Story = {
},
}
+export const BIEmptyWorksheet: Story = {
+ ...BIModeWorksheet,
+ parameters: {
+ ...BIModeWorksheet.parameters,
+ pageUrl: urls.businessIntelligence(),
+ testOptions: { waitForSelector: '[data-attr="bi-editor-data-source"]' },
+ },
+}
+
export const BICalculatedMeasureEditor: Story = {
...BIModeWorksheet,
parameters: {
@@ -468,7 +478,7 @@ export const BIQuickFilters: Story = {
...BIModeWorksheet,
parameters: {
...BIModeWorksheet.parameters,
- pageUrl: `${urls.sqlEditor()}#${new URLSearchParams({ q: buildBIQuery(BI_QUICK_FILTERS_CONFIG)?.query ?? '', mode: 'bi', bi: JSON.stringify(BI_QUICK_FILTERS_CONFIG) })}`,
+ pageUrl: `${urls.businessIntelligence()}#${new URLSearchParams({ q: buildBIQuery(BI_QUICK_FILTERS_CONFIG)?.query ?? '', mode: 'bi', bi: JSON.stringify(BI_QUICK_FILTERS_CONFIG) })}`,
msw: {
mocks: {
...BIModeWorksheet.parameters?.msw.mocks,
@@ -506,7 +516,7 @@ export const BIQuickFiltersNarrow: Story = {
...BIQuickFilters,
parameters: {
...BIQuickFilters.parameters,
- pageUrl: `${urls.sqlEditor()}#${new URLSearchParams({
+ pageUrl: `${urls.businessIntelligence()}#${new URLSearchParams({
mode: 'bi',
bi: JSON.stringify({
...BI_QUICK_FILTERS_CONFIG,
@@ -737,8 +747,6 @@ export const BIDataSourcePicker: Story = {
await waitFor(() => expect(canvasElement.querySelector('[data-attr="bi-editor-data-source"]')).toBeVisible(), {
timeout: 15000,
})
- await userEvent.click(canvas.getByRole('button', { name: 'SQL' }))
- await userEvent.click(canvas.getByRole('button', { name: 'BI' }))
await waitFor(() => expect(canvas.queryByText('Locate')).not.toBeInTheDocument())
await userEvent.click(canvasElement.querySelector('[data-attr="bi-editor-data-source"]')!)
const page = within(canvasElement.ownerDocument.body)
@@ -883,7 +891,7 @@ export const BIConnections: Story = {
...BIModeWorksheet,
parameters: {
...BIModeWorksheet.parameters,
- pageUrl: `${urls.sqlEditor()}#${new URLSearchParams({
+ pageUrl: `${urls.businessIntelligence()}#${new URLSearchParams({
q: buildBIQuery(BI_CONNECTIONS_CONFIG)?.query ?? '',
mode: 'bi',
bi: JSON.stringify(BI_CONNECTIONS_CONFIG),
@@ -961,8 +969,6 @@ export const BIConnections: Story = {
await waitFor(() => expect(canvasElement.querySelector('[data-attr="bi-editor-data-source"]')).toBeVisible(), {
timeout: 15000,
})
- await userEvent.click(canvas.getByRole('button', { name: 'SQL' }))
- await userEvent.click(canvas.getByRole('button', { name: 'BI' }))
const autoUpdate = canvasElement.querySelector('[data-attr="bi-editor-auto-update"]')!
if (autoUpdate.getAttribute('aria-checked') === 'true') {
await userEvent.click(autoUpdate)
diff --git a/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx b/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx
index 9f2983f8d4e5..ffc05f2ea919 100644
--- a/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx
@@ -1,5 +1,6 @@
import { deepEqual as equal } from 'fast-equals'
import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { combineUrl } from 'kea-router'
import posthog from 'posthog-js'
import { JSONContent } from 'lib/components/RichContentEditor/types'
@@ -20,6 +21,7 @@ import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
import type { DataWarehouseSavedQuery, LinkBreadcrumb, InsightModel } from '../../../types'
import { NEW_QUERY, normalizeFiltersForUrl, sqlEditorLogic, toDataVisualizationNode } from './sqlEditorLogic'
import type { QueryTab, SqlEditorSource } from './sqlEditorLogic'
+import { SQLEditorMode } from './sqlEditorModes'
export interface SaveAsMenuItem {
action: 'insight' | 'endpoint' | 'view' | 'metric'
@@ -57,6 +59,7 @@ export const renderTableCount = (count: undefined | number): null | JSX.Element
export interface EditorSceneLogicProps {
tabId: string
+ mode?: SQLEditorMode
}
export function buildSqlNotebook(
@@ -105,6 +108,7 @@ export interface editorSceneLogicValues {
editingInsight: InsightModel | null // sqlEditorLogic
editingView: DataWarehouseSavedQuery | undefined // sqlEditorLogic
editorSource: SqlEditorSource // sqlEditorLogic
+ editorUrl: string // sqlEditorLogic
featureFlags: FeatureFlagsSet // sqlEditorLogic
insightLoading: boolean // sqlEditorLogic
queryInput: string | null // sqlEditorLogic
@@ -194,7 +198,7 @@ export interface editorSceneLogicMeta {
projectTreeRef: (
editingInsight: InsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>> | null
) => ProjectTreeRef | null
- breadcrumbs: (activeTab: QueryTab | null) => Breadcrumb[]
+ breadcrumbs: (activeTab: QueryTab | null, editorUrl: string) => Breadcrumb[]
titleSectionProps: (
editingInsight: InsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>> | null,
insightLoading: boolean,
@@ -202,7 +206,8 @@ export interface editorSceneLogicMeta {
viewLoading: boolean,
editorSource: SqlEditorSource,
dashboardId: number | null,
- activeTab: QueryTab | null
+ activeTab: QueryTab | null,
+ editorUrl: string
) =>
| {
description: string
@@ -257,13 +262,14 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
key((props) => props.tabId),
connect((props: EditorSceneLogicProps) => ({
values: [
- sqlEditorLogic({ tabId: props.tabId }),
+ sqlEditorLogic({ tabId: props.tabId, ...(props.mode ? { mode: props.mode } : {}) }),
[
'activeTab',
'dashboardId',
'dataLogicKey',
'editingInsight',
'editingView',
+ 'editorUrl',
'editorSource',
'featureFlags',
'insightLoading',
@@ -298,21 +304,27 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
editingInsight ? { type: 'insight', ref: editingInsight.short_id } : null,
],
breadcrumbs: [
- (s) => [s.activeTab],
- (activeTab: null | import('./sqlEditorLogic').QueryTab): Breadcrumb[] => {
+ (s) => [s.activeTab, s.editorUrl],
+ (activeTab: null | import('./sqlEditorLogic').QueryTab, editorUrl: string): Breadcrumb[] => {
const { draft, insight, view } = activeTab || {}
+ const biHash =
+ editorUrl === urls.businessIntelligence() && activeTab?.biEditorState
+ ? { mode: activeTab.biEditorState.editorView, bi: activeTab.biEditorState.config }
+ : undefined
const first = {
- key: Scene.SQLEditor,
- name: 'SQL query',
- to: urls.sqlEditor(),
- iconType: 'sql_editor' as FileSystemIconType,
+ key: editorUrl === urls.businessIntelligence() ? Scene.BusinessIntelligence : Scene.SQLEditor,
+ name: editorUrl === urls.businessIntelligence() ? 'Business intelligence' : 'SQL query',
+ to: editorUrl,
+ iconType: (editorUrl === urls.businessIntelligence()
+ ? 'business_intelligence'
+ : 'sql_editor') as FileSystemIconType,
}
if (view) {
return [
{
key: view.id,
name: view.name,
- path: urls.sqlEditor({ view_id: view.id }),
+ path: combineUrl(editorUrl, { open_view: view.id }, biHash).url,
iconType: 'sql_editor',
},
]
@@ -322,9 +334,7 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
{
key: insight.id,
name: insight.name || insight.derived_name || 'Untitled',
- path: urls.sqlEditor({
- insightShortId: insight.short_id,
- }),
+ path: combineUrl(editorUrl, { open_insight: insight.short_id }, biHash).url,
iconType: 'sql_editor',
},
]
@@ -334,7 +344,7 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
{
key: draft.id,
name: draft.name || 'Untitled',
- path: urls.sqlEditor({ draftId: draft.id }),
+ path: combineUrl(editorUrl, { open_draft: draft.id }, biHash).url,
iconType: 'sql_editor',
},
]
@@ -351,6 +361,7 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
s.editorSource,
s.dashboardId,
s.activeTab,
+ s.editorUrl,
],
(
editingInsight: null | import('~/types').InsightModel,
@@ -359,7 +370,8 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
viewLoading: boolean,
editorSource: import('./sqlEditorLogic').SqlEditorSource,
dashboardId: number | null,
- activeTab: null | import('./sqlEditorLogic').QueryTab
+ activeTab: null | import('./sqlEditorLogic').QueryTab,
+ editorUrl: string
) => {
if (editingInsight) {
const forceBackTo: Breadcrumb = dashboardId
@@ -471,8 +483,10 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
}
return {
- name: 'New SQL query',
- resourceType: { type: 'sql_editor' },
+ name: editorUrl === urls.businessIntelligence() ? 'New worksheet' : 'New SQL query',
+ resourceType: {
+ type: editorUrl === urls.businessIntelligence() ? 'business_intelligence' : 'sql_editor',
+ },
}
},
],
@@ -601,6 +615,12 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
}
setFiltersHashParam(shareUrl, sourceQuery.source.filters)
+ if (values.editorUrl === urls.businessIntelligence() && activeTab.biEditorState) {
+ const hashParams = new URLSearchParams(shareUrl.hash.slice(1))
+ hashParams.set('mode', activeTab.biEditorState.editorView)
+ hashParams.set('bi', JSON.stringify(activeTab.biEditorState.config))
+ shareUrl.hash = hashParams.toString()
+ }
void copyToClipboard(shareUrl.toString(), 'share link')
},
diff --git a/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx b/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx
index 2a4b55b8fbee..340ef41ebef4 100644
--- a/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx
@@ -39,16 +39,6 @@ import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { cn } from 'lib/utils/css-classes'
import { newInternalTab } from 'lib/utils/newInternalTab'
import { PropertyDefinitionEditModal } from 'scenes/data-management/properties/PropertyDefinitionEditModal'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
-import {
- BI_FIELD_DRAG_MIME_TYPE,
- BIDataSource,
- BIEditorView,
- BIField,
- getBIFieldId,
- isBIFieldCompatible,
- serializeBIField,
-} from 'scenes/data-warehouse/editor/bi/biEditorTypes'
import { POSTHOG_WAREHOUSE } from 'scenes/data-warehouse/editor/connectionSelectorLogic'
import { OutputTab } from 'scenes/data-warehouse/editor/outputPaneLogic'
import { sqlEditorLogic } from 'scenes/data-warehouse/editor/sqlEditorLogic'
@@ -125,7 +115,6 @@ const filterTreeSections = (sections: TreeDataItem[], searchTerm: string): TreeD
export const QueryDatabase = ({
virtualizationScrollContainerRef,
extraTreeSections,
- tabId,
}: {
virtualizationScrollContainerRef?: React.RefObject<HTMLDivElement | null>
/**
@@ -135,7 +124,6 @@ export const QueryDatabase = ({
* unaffected.
*/
extraTreeSections?: TreeDataItem[]
- tabId: string
}): JSX.Element => {
const {
searchTerm,
@@ -150,8 +138,6 @@ export const QueryDatabase = ({
featureFlags,
editingPropertyDefinition,
} = useValues(queryDatabaseLogic)
- const { config: biConfig, editorView } = useValues(biEditorLogic({ tabId }))
- const isBIEditor = editorView === BIEditorView.BI
const {
setExpandedFolders,
toggleFolderOpen,
@@ -406,10 +392,8 @@ export const QueryDatabase = ({
<LemonTree
ref={treeRef}
data={treeData}
- enableDragAndDrop={!searchTerm && !isBIEditor}
- isItemDraggable={(item) =>
- !searchTerm && !isBIEditor && item.record?.type === 'view' && item.record?.isSavedQuery
- }
+ enableDragAndDrop={!searchTerm}
+ isItemDraggable={(item) => !searchTerm && item.record?.type === 'view' && item.record?.isSavedQuery}
isItemDroppable={(item) =>
!searchTerm &&
((item.record?.type === 'folder' && item.record?.folderType === 'view-folder') ||
@@ -453,7 +437,7 @@ export const QueryDatabase = ({
}
// Insert the column at the cursor, preserving the rest of the query the user has typed
- const columnInsertText = isBIEditor ? null : getColumnInsertText(item?.record)
+ const columnInsertText = getColumnInsertText(item?.record)
if (columnInsertText) {
insertTextAtCursor(columnInsertText)
}
@@ -471,26 +455,6 @@ export const QueryDatabase = ({
const matches = item.record?.searchMatches
const hasMatches = matches && matches.length > 0
const isColumn = item.record?.type === 'column'
- const biFieldSource: BIDataSource | null =
- isColumn && typeof item.record?.table === 'string'
- ? {
- table: item.record.table,
- connectionId:
- connectionId && connectionId !== POSTHOG_WAREHOUSE ? connectionId : undefined,
- }
- : null
- const columnExpression = isColumn ? getColumnInsertText(item.record) : null
- const biField: BIField | null =
- biFieldSource && columnExpression
- ? {
- id: getBIFieldId(biFieldSource, columnExpression),
- name: item.name,
- expression: columnExpression,
- type: item.record?.field.type,
- source: biFieldSource,
- }
- : null
- const canDragBIField = isBIEditor && !!biField && isBIFieldCompatible(biConfig.source, biField)
const columnType = isColumn ? item.record?.field?.type : null
const savedExpression =
isColumn && item.record?.table && item.record?.field
@@ -516,21 +480,7 @@ export const QueryDatabase = ({
return (
<span
- className={cn(
- 'truncate',
- isBIEditor && isColumn && 'cursor-grab',
- isBIEditor && isColumn && !canDragBIField && 'cursor-not-allowed opacity-40'
- )}
- draggable={canDragBIField}
- onDragStart={(event) => {
- if (!biField || !canDragBIField) {
- event.preventDefault()
- return
- }
- event.stopPropagation()
- event.dataTransfer.effectAllowed = 'copy'
- event.dataTransfer.setData(BI_FIELD_DRAG_MIME_TYPE, serializeBIField(biField))
- }}
+ className="truncate"
onDoubleClick={(e) => {
if (!isPreviewableViewItem(item)) {
return
diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
index fd39485b19cc..05221c6fe771 100644
--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
@@ -8,7 +8,9 @@ import { LemonDialog } from '@posthog/lemon-ui'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import * as clipboard from 'lib/utils/copyToClipboard'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
+import { draftsLogic } from 'scenes/data-warehouse/editor/draftsLogic'
import { dataWarehouseViewsLogic } from 'scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic'
import { insightsApi } from 'scenes/insights/utils/api'
import { getMarkdownNotebookMarkdown } from 'scenes/notebooks/Notebook/markdownNotebookV2'
@@ -31,13 +33,20 @@ import {
import { initKeaTests } from '~/test/init'
import { ChartDisplayType, InsightShortId, InsightModel } from '~/types'
+import { biConnectionsLogic } from 'products/business_intelligence/frontend/biConnectionsLogic'
+import { BI_EDITOR_EVENTS } from 'products/business_intelligence/frontend/biEditorAnalytics'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import {
+ BIConfig,
+ BIEditorView,
+ BIField,
+ DEFAULT_BI_CONFIG,
+ getBIFieldPillLabel,
+ getBIShelfEditorKey,
+} from 'products/business_intelligence/frontend/biEditorTypes'
import { metricsLogic } from 'products/data_catalog/frontend/metricsLogic'
-import { biConnectionsLogic } from 'products/data_warehouse/frontend/bi/biConnectionsLogic'
import { sqlEditorDraftStorage } from 'products/data_warehouse/frontend/sqlEditorDraftStorage'
-import { BI_EDITOR_EVENTS } from './bi/biEditorAnalytics'
-import { biEditorLogic } from './bi/biEditorLogic'
-import { BIConfig, BIEditorView, BIField, getBIFieldPillLabel, getBIShelfEditorKey } from './bi/biEditorTypes'
import { buildSqlNotebook, editorSceneLogic } from './editorSceneLogic'
import { OutputTab } from './outputPaneLogic'
import { SELECTION_NOT_A_QUERY } from './saveCandidateProblems'
@@ -332,23 +341,50 @@ describe('sqlEditorLogic', () => {
})
describe('local draft recovery', () => {
- const mountEditor = (): void => {
- logic = sqlEditorLogic({ tabId: TAB_ID, monaco: createMockMonaco(), editor: createMockEditor() })
+ const mountEditor = (mode = SQLEditorMode.FullScene): void => {
+ logic = sqlEditorLogic({ tabId: TAB_ID, mode, monaco: createMockMonaco(), editor: createMockEditor() })
logic.mount()
}
- it.each([
- { searchParams: { open_view: MOCK_VIEW.id }, savedQuery: MOCK_VIEW.query.query },
- {
- searchParams: { open_insight: MOCK_INSIGHT_SHORT_ID },
- savedQuery: MOCK_INSIGHT_QUERY.source.query,
- },
- ])('discards an unrun edit and does not recover it again (%j)', async ({ searchParams, savedQuery }) => {
- mountEditor()
- await expectLogic(logic, () => router.actions.push(urls.sqlEditor(), searchParams))
+ it.each(
+ [
+ { searchParams: { open_view: MOCK_VIEW.id }, savedQuery: MOCK_VIEW.query.query },
+ {
+ searchParams: { open_insight: MOCK_INSIGHT_SHORT_ID },
+ savedQuery: MOCK_INSIGHT_QUERY.source.query,
+ },
+ ].flatMap((savedItem) =>
+ [SQLEditorMode.FullScene, SQLEditorMode.BusinessIntelligence].map((mode) => ({ ...savedItem, mode }))
+ )
+ )('discards an unrun edit and does not recover it again (%j)', async ({ searchParams, savedQuery, mode }) => {
+ mountEditor(mode)
+ const editorUrl =
+ mode === SQLEditorMode.BusinessIntelligence ? urls.businessIntelligence() : urls.sqlEditor()
+ const hashParams =
+ mode === SQLEditorMode.BusinessIntelligence
+ ? {
+ mode: BIEditorView.BI,
+ bi: {
+ ...DEFAULT_BI_CONFIG,
+ source: { table: 'events' },
+ rows: [
+ {
+ id: 'event',
+ name: 'event',
+ expression: 'event',
+ type: 'string',
+ source: { table: 'events' },
+ },
+ ],
+ },
+ }
+ : undefined
+ await expectLogic(logic, () => router.actions.push(editorUrl, searchParams, hashParams))
.toDispatchActions(['createTab', 'setQueryInput'])
.toFinishAllListeners()
expect(logic.values.hasEditorChanges).toBe(false)
+ const biEditorState = logic.values.activeTab?.biEditorState
+ expect(biEditorState?.config.rows).toEqual(hashParams?.bi.rows)
logic.actions.setQueryInput('SELECT unfinished')
expect(logic.values.hasEditorChanges).toBe(true)
@@ -360,6 +396,7 @@ describe('sqlEditorLogic', () => {
})
.toFinishAllListeners()
.toMatchValues({ queryInput: savedQuery, hasEditorChanges: false })
+ expect(logic.values.activeTab?.biEditorState).toEqual(biEditorState)
expect(router.values.hashParams.q).toEqual(savedQuery)
expect(logic.values.activeTab?.view?.id ?? logic.values.activeTab?.insight?.short_id).toEqual(
searchParams.open_view ?? searchParams.open_insight
@@ -367,8 +404,8 @@ describe('sqlEditorLogic', () => {
logic.unmount()
initKeaTests()
- mountEditor()
- await expectLogic(logic, () => router.actions.push(urls.sqlEditor(), searchParams))
+ mountEditor(mode)
+ await expectLogic(logic, () => router.actions.push(editorUrl, searchParams))
.toDispatchActions(['createTab', 'setQueryInput'])
.toFinishAllListeners()
.toMatchValues({ queryInput: savedQuery, hasEditorChanges: false })
@@ -522,6 +559,40 @@ describe('sqlEditorLogic', () => {
}
)
+ it.each([
+ ['new', {}],
+ [`view:${MOCK_VIEW.id}`, { open_view: MOCK_VIEW.id }],
+ [`insight:${MOCK_INSIGHT_SHORT_ID}`, { open_insight: MOCK_INSIGHT_SHORT_ID }],
+ [`draft:${MOCK_DRAFT.id}`, { open_draft: MOCK_DRAFT.id }],
+ ])('keeps BI and existing SQL working copies separate for %s', async (target, searchParams) => {
+ const sqlDraft = sqlEditorDraftStorage(MOCK_DEFAULT_USER.uuid, MOCK_DEFAULT_TEAM.id, target)!
+ const biDraft = sqlEditorDraftStorage(MOCK_DEFAULT_USER.uuid, MOCK_DEFAULT_TEAM.id, `bi:${target}`)!
+ sqlDraft.set({ q: 'SELECT sql_draft' })
+ biDraft.set({ q: 'SELECT bi_draft' })
+ logic = sqlEditorLogic({ tabId: TAB_ID, mode: SQLEditorMode.BusinessIntelligence })
+ logic.mount()
+ draftsLogic.actions.setDrafts([MOCK_DRAFT])
+ await expectLogic(logic, () => router.actions.push(urls.businessIntelligence(), searchParams))
+ .toDispatchActions(['createTab', 'setQueryInput'])
+ .toFinishAllListeners()
+ .toMatchValues({ queryInput: 'SELECT bi_draft' })
+ logic.actions.setQueryInput('SELECT edited_bi_draft')
+ expect(biDraft.get()?.q).toBe('SELECT edited_bi_draft')
+ expect(sqlDraft.get()?.q).toBe('SELECT sql_draft')
+
+ logic.unmount()
+ initKeaTests()
+ mountEditor()
+ draftsLogic.actions.setDrafts([MOCK_DRAFT])
+ await expectLogic(logic, () => router.actions.push(urls.sqlEditor(), searchParams))
+ .toDispatchActions(['createTab', 'setQueryInput'])
+ .toFinishAllListeners()
+ .toMatchValues({ queryInput: 'SELECT sql_draft' })
+ logic.actions.setQueryInput('SELECT edited_sql_draft')
+ expect(sqlDraft.get()?.q).toBe('SELECT edited_sql_draft')
+ expect(biDraft.get()?.q).toBe('SELECT edited_bi_draft')
+ })
+
it('does not replace this tab with another browser tab’s draft on reload', async () => {
sqlEditorDraftStorage(MOCK_DEFAULT_USER.uuid, MOCK_DEFAULT_TEAM.id, 'new')?.set({ q: 'SELECT other_tab' })
sessionStorage.clear()
@@ -2362,8 +2433,96 @@ describe('sqlEditorLogic', () => {
sort_direction: null,
}
+ it('opens and restores a BI worksheet without loading Monaco', async () => {
+ logic = sqlEditorLogic({ tabId: TAB_ID, mode: SQLEditorMode.BusinessIntelligence })
+ logic.mount()
+ const biLogic = biEditorLogic({ tabId: TAB_ID })
+ biLogic.mount()
+
+ await expectLogic(logic, () =>
+ router.actions.push(urls.businessIntelligence(), undefined, {
+ q: 'SELECT event FROM events',
+ mode: BIEditorView.BI,
+ bi: config,
+ })
+ ).toDispatchActions(['createTab', 'updateTab'])
+
+ expect(logic.values.queryInput).toBe('SELECT event FROM events')
+ expect(biLogic.values.config).toMatchObject(config)
+ expect(biLogic.values.editorView).toBe(BIEditorView.BI)
+ logic.actions.syncUrlWithQuery()
+ expect(router.values.location.pathname).toBe(
+ `/project/${MOCK_DEFAULT_TEAM.id}${urls.businessIntelligence()}`
+ )
+ expect(router.values.hashParams.bi).toMatchObject(config)
+ const copy = jest.spyOn(clipboard, 'copyToClipboard').mockResolvedValue(true)
+ editorRootLogic = editorSceneLogic({ tabId: TAB_ID, mode: SQLEditorMode.BusinessIntelligence })
+ editorRootLogic.mount()
+ editorRootLogic.actions.shareTab()
+ const sharedUrl = new URL(copy.mock.calls[0][0])
+ expect(JSON.parse(new URLSearchParams(sharedUrl.hash.slice(1)).get('bi')!)).toMatchObject(config)
+ copy.mockRestore()
+ biLogic.unmount()
+ })
+
+ it('redirects bookmarked SQL editor BI links with their query state', () => {
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.SQL_EDITOR_BI_MODE], {
+ [FEATURE_FLAGS.SQL_EDITOR_BI_MODE]: true,
+ })
+ logic = sqlEditorLogic({ tabId: TAB_ID })
+ logic.mount()
+ router.actions.push(
+ urls.sqlEditor(),
+ { open_view: MOCK_VIEW.id },
+ {
+ q: 'SELECT event FROM events',
+ mode: BIEditorView.BI,
+ bi: config,
+ }
+ )
+ expect(router.values.location.pathname).toBe(
+ `/project/${MOCK_DEFAULT_TEAM.id}${urls.businessIntelligence()}`
+ )
+ expect(router.values.searchParams.open_view).toBe(MOCK_VIEW.id)
+ expect(router.values.hashParams.q).toBe('SELECT event FROM events')
+ expect(router.values.hashParams.bi).toMatchObject(config)
+ })
+
+ it.each([{ open_view: MOCK_VIEW.id }, { open_insight: MOCK_INSIGHT_SHORT_ID }, { open_draft: MOCK_DRAFT.id }])(
+ 'preserves worksheet configuration in saved-item breadcrumbs (%j)',
+ async (searchParams) => {
+ logic = sqlEditorLogic({ tabId: TAB_ID, mode: SQLEditorMode.BusinessIntelligence })
+ logic.mount()
+ editorRootLogic = editorSceneLogic({ tabId: TAB_ID, mode: SQLEditorMode.BusinessIntelligence })
+ editorRootLogic.mount()
+ draftsLogic.actions.setDrafts([{ ...MOCK_DRAFT, saved_query_id: undefined }])
+ await expectLogic(logic, () =>
+ router.actions.push(urls.businessIntelligence(), searchParams, {
+ mode: BIEditorView.BI,
+ bi: config,
+ })
+ )
+ .toDispatchActions(['createTab', 'setQueryInput'])
+ .toFinishAllListeners()
+
+ const breadcrumb = editorRootLogic.values.breadcrumbs.at(-1)!
+ expect(breadcrumb).toHaveProperty('path')
+ const breadcrumbUrl = new URL((breadcrumb as { path: string }).path, window.location.origin)
+ const hashParams = new URLSearchParams(breadcrumbUrl.hash.slice(1))
+ expect(breadcrumbUrl.pathname).toBe(urls.businessIntelligence())
+ expect(Object.fromEntries(breadcrumbUrl.searchParams)).toEqual(searchParams)
+ expect(hashParams.get('mode')).toBe(BIEditorView.BI)
+ expect(JSON.parse(hashParams.get('bi')!)).toMatchObject(config)
+ }
+ )
+
it('updates the chart breakdown when dimensions move between shelves or are removed', async () => {
- logic = sqlEditorLogic({ tabId: TAB_ID, monaco: createMockMonaco(), editor: createMockEditor() })
+ logic = sqlEditorLogic({
+ tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
+ monaco: createMockMonaco(),
+ editor: createMockEditor(),
+ })
logic.mount()
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
@@ -2399,6 +2558,7 @@ describe('sqlEditorLogic', () => {
})
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
@@ -2406,7 +2566,7 @@ describe('sqlEditorLogic', () => {
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
- router.actions.push(urls.sqlEditor(), undefined, {
+ router.actions.push(urls.businessIntelligence(), undefined, {
q: "SELECT event, count(*) FROM events WHERE event = 'signup' GROUP BY event",
mode: BIEditorView.BI,
bi: config,
@@ -2454,6 +2614,7 @@ describe('sqlEditorLogic', () => {
const createSpy = jest.spyOn(insightsApi, 'create').mockResolvedValue(MOCK_INSIGHT)
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
@@ -2461,7 +2622,7 @@ describe('sqlEditorLogic', () => {
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
- router.actions.push(urls.sqlEditor(), undefined, {
+ router.actions.push(urls.businessIntelligence(), undefined, {
q: "SELECT event, count(*) FROM events WHERE event = 'signup' GROUP BY event",
mode: BIEditorView.BI,
bi: config,
@@ -2511,6 +2672,7 @@ describe('sqlEditorLogic', () => {
})
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
@@ -2817,7 +2979,12 @@ describe('sqlEditorLogic', () => {
})
it("does not expose another connection's fields and resets the worksheet when switching connections", () => {
- logic = sqlEditorLogic({ tabId: TAB_ID, monaco: createMockMonaco(), editor: createMockEditor() })
+ logic = sqlEditorLogic({
+ tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
+ monaco: createMockMonaco(),
+ editor: createMockEditor(),
+ })
logic.mount()
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
@@ -2855,7 +3022,12 @@ describe('sqlEditorLogic', () => {
test.each(['ready', 'failed', 'cancelled', 'missing'] as const)(
'handles chart-only changes with %s query results and runs changed table SQL',
async (resultState) => {
- logic = sqlEditorLogic({ tabId: TAB_ID, monaco: createMockMonaco(), editor: createMockEditor() })
+ logic = sqlEditorLogic({
+ tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
+ monaco: createMockMonaco(),
+ editor: createMockEditor(),
+ })
logic.mount()
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
@@ -2902,7 +3074,12 @@ describe('sqlEditorLogic', () => {
test.each(['disable', 'sql', 'clear', 'invalid', 'unchanged'] as const)(
'handles a pending automatic query when the worksheet is %s',
async (transition) => {
- logic = sqlEditorLogic({ tabId: TAB_ID, monaco: createMockMonaco(), editor: createMockEditor() })
+ logic = sqlEditorLogic({
+ tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
+ monaco: createMockMonaco(),
+ editor: createMockEditor(),
+ })
logic.mount()
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
@@ -2947,7 +3124,12 @@ describe('sqlEditorLogic', () => {
)
it('clears the displayed result when clearing the worksheet', async () => {
- logic = sqlEditorLogic({ tabId: TAB_ID, monaco: createMockMonaco(), editor: createMockEditor() })
+ logic = sqlEditorLogic({
+ tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
+ monaco: createMockMonaco(),
+ editor: createMockEditor(),
+ })
logic.mount()
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
@@ -2978,6 +3160,7 @@ describe('sqlEditorLogic', () => {
})
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
@@ -2990,7 +3173,7 @@ describe('sqlEditorLogic', () => {
limit: 50000,
}
- router.actions.push(urls.sqlEditor(), undefined, {
+ router.actions.push(urls.businessIntelligence(), undefined, {
q: "SELECT event, count(*) FROM events WHERE event = 'signup' GROUP BY event",
mode: BIEditorView.BI,
bi: persistedConfig,
@@ -3059,6 +3242,7 @@ describe('sqlEditorLogic', () => {
it('regenerates the query and URL when a date bucket changes', async () => {
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
@@ -3067,7 +3251,7 @@ describe('sqlEditorLogic', () => {
biLogic.mount()
const dateConfig: BIConfig = { ...config, rows: [timestampField], filters: [] }
- router.actions.push(urls.sqlEditor(), undefined, {
+ router.actions.push(urls.businessIntelligence(), undefined, {
q: 'SELECT timestamp, count(*) FROM events GROUP BY timestamp',
mode: BIEditorView.BI,
bi: dateConfig,
@@ -3092,6 +3276,7 @@ describe('sqlEditorLogic', () => {
it('regenerates the query and URL when the result limit changes', async () => {
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
@@ -3099,7 +3284,7 @@ describe('sqlEditorLogic', () => {
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
- router.actions.push(urls.sqlEditor(), undefined, {
+ router.actions.push(urls.businessIntelligence(), undefined, {
q: 'SELECT event, count(*) FROM events GROUP BY event LIMIT 1000',
mode: BIEditorView.BI,
bi: config,
@@ -3129,6 +3314,7 @@ describe('sqlEditorLogic', () => {
it('clears incompatible fields and opens persisted blank shelf fields for editing', async () => {
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
@@ -3136,7 +3322,7 @@ describe('sqlEditorLogic', () => {
const biLogic = biEditorLogic({ tabId: TAB_ID })
biLogic.mount()
- router.actions.push(urls.sqlEditor(), undefined, {
+ router.actions.push(urls.businessIntelligence(), undefined, {
q: 'SELECT event, count(*) FROM events GROUP BY event',
mode: BIEditorView.BI,
bi: config,
@@ -3184,6 +3370,7 @@ describe('sqlEditorLogic', () => {
it('adds a removable default date filter for event data', async () => {
logic = sqlEditorLogic({
tabId: TAB_ID,
+ mode: SQLEditorMode.BusinessIntelligence,
monaco: createMockMonaco(),
editor: createMockEditor(),
})
diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
index 4716497ad7bf..e2f3a47b3654 100644
--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
@@ -112,20 +112,25 @@ import type { ExternalDataSourceConnectionOptionApi } from '../../../../../produ
// Mirrors MANAGED_WAREHOUSE_SOURCE_PREFIX in products/warehouse_sources/backend/models/external_data_source.py.
export const MANAGED_WAREHOUSE_SOURCE_PREFIX = 'managed_warehouse'
-import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
-import type { DatabaseSchemaQueryResponse, Node } from '../../../queries/schema/schema-general'
-import type { DataWarehouseSavedQueryFolder, UserType } from '../../../types'
-import { dataWarehouseViewsLogic } from '../saved_queries/dataWarehouseViewsLogic'
-import type { DataWarehouseSavedQuerySummary } from '../saved_queries/dataWarehouseViewsLogic'
-import { validateSavedQueryName } from '../saved_queries/savedQueryNameValidation'
-import { captureBIEditorQueryRun, captureBIEditorQuerySaved } from './bi/biEditorAnalytics'
+import {
+ captureBIEditorQueryRun,
+ captureBIEditorQuerySaved,
+} from 'products/business_intelligence/frontend/biEditorAnalytics'
import {
BIEditorState,
+ DEFAULT_BI_CONFIG,
BIEditorView,
buildBIQuery,
getBIFilterValidationError,
parseBIEditorState,
-} from './bi/biEditorTypes'
+} from 'products/business_intelligence/frontend/biEditorTypes'
+
+import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
+import type { DatabaseSchemaQueryResponse, Node } from '../../../queries/schema/schema-general'
+import type { DataWarehouseSavedQueryFolder, UserType } from '../../../types'
+import { dataWarehouseViewsLogic } from '../saved_queries/dataWarehouseViewsLogic'
+import type { DataWarehouseSavedQuerySummary } from '../saved_queries/dataWarehouseViewsLogic'
+import { validateSavedQueryName } from '../saved_queries/savedQueryNameValidation'
import { connectionSelectorLogic } from './connectionSelectorLogic'
import { draftsLogic } from './draftsLogic'
import { fixSQLErrorsLogic } from './fixSQLErrorsLogic'
@@ -289,7 +294,7 @@ function clearQueryOutlineOverlay(
export const NEW_QUERY = 'Untitled'
export interface QueryTab {
- uri: Uri
+ uri?: Uri
view?: DataWarehouseSavedQuery
name: string
description?: string
@@ -615,6 +620,7 @@ export interface sqlEditorLogicValues {
editingView: DataWarehouseSavedQuery | undefined
editorKey: string
editorSource: SqlEditorSource
+ editorUrl: string
error: string | null
exportContext: ExportContext
filtersPlaceholderBindings: string[] | null
@@ -1175,6 +1181,7 @@ export interface sqlEditorLogicActions {
export interface sqlEditorLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
+ editorUrl: (arg: SQLEditorMode | undefined) => string
suggestedSource: (
suggestionPayload: SuggestionPayload | null
) => 'hogql_fixer' | 'materialization_fix' | 'max_ai' | 'query_history' | null
@@ -1829,7 +1836,11 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
: insight
? `insight:${insight.short_id}`
: 'new'
- const storage = sqlEditorDraftStorage(values.user?.uuid, teamLogic.values.currentTeamId, target)
+ const storage = sqlEditorDraftStorage(
+ values.user?.uuid,
+ teamLogic.values.currentTeamId,
+ props.mode === SQLEditorMode.BusinessIntelligence ? `bi:${target}` : target
+ )
const savedQuery =
draft?.query.query ?? view?.query?.query ?? toDataVisualizationNode(insight?.query)?.source.query
if (savedQuery !== undefined && values.queryInput === savedQuery) {
@@ -1868,7 +1879,9 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
return resolveSaveCandidatesPure(fullText, cursorOffset, selectionText)
}
const getActiveBIEditorState = (): BIEditorState | undefined =>
- values.featureFlags[FEATURE_FLAGS.SQL_EDITOR_BI_MODE] ? values.activeTab?.biEditorState : undefined
+ props.mode === SQLEditorMode.BusinessIntelligence && values.featureFlags[FEATURE_FLAGS.SQL_EDITOR_BI_MODE]
+ ? values.activeTab?.biEditorState
+ : undefined
return {
fixErrorsSuccess: ({ response }) => {
@@ -2078,19 +2091,30 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
})
)
}
-
- actions.updateTab({
- uri,
- view,
- insight,
- name: tabName,
- description: tabDescription,
- sourceQuery: insightVisualizationQuery,
- draft: draft,
- metricName,
- biEditorState,
- })
}
+ actions.updateTab({
+ uri: props.monaco?.Uri.parse(tabModelPath(props.tabId)),
+ view,
+ insight,
+ name: tabName,
+ description: tabDescription,
+ sourceQuery: insightVisualizationQuery,
+ draft,
+ metricName,
+ biEditorState:
+ props.mode === SQLEditorMode.BusinessIntelligence
+ ? {
+ editorView: BIEditorView.BI,
+ config: biEditorState?.config ?? {
+ ...DEFAULT_BI_CONFIG,
+ rows: [],
+ columns: [],
+ values: [],
+ filters: [],
+ },
+ }
+ : biEditorState,
+ })
if (insightVisualizationQuery) {
actions.setLastRunQuery(insightVisualizationQuery)
}
@@ -3135,7 +3159,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
return
}
actions._setSuggestionPayload(null)
- actions.createTab(savedQuery.source.query, view, insight)
+ actions.createTab(savedQuery.source.query, view, insight, undefined, undefined, tab.biEditorState)
actions.setSourceQuery(savedQuery)
applyUndoableModelEdit(props.monaco, values.activeTab?.uri, savedQuery.source.query)
actions.syncUrlWithQuery()
@@ -3219,7 +3243,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
window.history.replaceState(
{},
'',
- `${urls.sqlEditor()}${currentUrl.searchParams.toString() ? `?${currentUrl.searchParams.toString()}` : ''}#${nextHash}`
+ `${values.editorUrl}${currentUrl.searchParams.toString() ? `?${currentUrl.searchParams.toString()}` : ''}#${nextHash}`
)
}
},
@@ -3271,7 +3295,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
if (!values.isEmbeddedMode) {
router.actions.replace(
- urls.sqlEditor(),
+ values.editorUrl,
undefined,
getTabHash({ ...values, activeTab: nextTab })
)
@@ -3483,6 +3507,11 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
},
})),
selectors({
+ editorUrl: [
+ () => [(_, p: SqlEditorLogicProps) => p.mode],
+ (mode: SQLEditorMode | undefined) =>
+ mode === SQLEditorMode.BusinessIntelligence ? urls.businessIntelligence() : urls.sqlEditor(),
+ ],
suggestedSource: [
(s) => [s.suggestionPayload],
(suggestionPayload: SuggestionPayload | null) => {
@@ -3707,31 +3736,40 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
if (
values.isEmbeddedMode ||
values.queryInput === null ||
- removeProjectIdIfPresent(router.values.location.pathname) !== urls.sqlEditor()
+ removeProjectIdIfPresent(router.values.location.pathname) !== values.editorUrl
) {
return
}
- return [urls.sqlEditor(), undefined, getTabHash(values), { replace: true }]
+ return [values.editorUrl, undefined, getTabHash(values), { replace: true }]
},
createTab: () => {
if (values.isEmbeddedMode) {
return
}
- return [urls.sqlEditor(), undefined, getTabHash(values), { replace: true }]
+ return [values.editorUrl, undefined, getTabHash(values), { replace: true }]
},
setActiveTab: () => {
if (values.isEmbeddedMode || !values.activeTab) {
return
}
- return [urls.sqlEditor(), undefined, getTabHash(values), { replace: true }]
+ return [values.editorUrl, undefined, getTabHash(values), { replace: true }]
},
})),
urlToAction(({ actions, values, props, cache }) => ({
- [urls.sqlEditor()]: async (_, searchParams, hashParams, { initial }) => {
+ [values.editorUrl]: async (_, searchParams, hashParams, { initial }) => {
if (isEmbeddedSQLEditorMode(props.mode ?? SQLEditorMode.FullScene)) {
return
}
+ if (
+ props.mode !== SQLEditorMode.BusinessIntelligence &&
+ hashParams.mode === BIEditorView.BI &&
+ values.featureFlags[FEATURE_FLAGS.SQL_EDITOR_BI_MODE]
+ ) {
+ router.actions.replace(urls.businessIntelligence(), searchParams, hashParams)
+ return
+ }
+
if (
searchParams.source === 'endpoint' ||
searchParams.source === 'insight' ||
@@ -3761,7 +3799,11 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
: insightTarget
? `insight:${insightTarget}`
: 'new'
- const draftStorage = sqlEditorDraftStorage(values.user?.uuid, teamLogic.values.currentTeamId, target)
+ const draftStorage = sqlEditorDraftStorage(
+ values.user?.uuid,
+ teamLogic.values.currentTeamId,
+ props.mode === SQLEditorMode.BusinessIntelligence ? `bi:${target}` : target
+ )
const storedDraft = draftStorage?.get()
const isReload =
initial &&
@@ -3981,7 +4023,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
actions.setViewLoading(false)
actions.setViewQueryLoading(false)
tabAdded = true
- router.actions.replace(urls.sqlEditor(), undefined, getTabHash(values))
+ router.actions.replace(values.editorUrl, undefined, getTabHash(values))
} else if (
insightShortIdFromUrl &&
(searchParams.open_insight ||
@@ -4010,7 +4052,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
biEditorStateFromUrl ?? undefined
)
tabAdded = true
- router.actions.replace(urls.sqlEditor(), undefined, getTabHash(values))
+ router.actions.replace(values.editorUrl, undefined, getTabHash(values))
return
}
@@ -4072,7 +4114,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
}
}
tabAdded = true
- router.actions.replace(urls.sqlEditor(), undefined, getTabHash(values))
+ router.actions.replace(values.editorUrl, undefined, getTabHash(values))
} else if (searchParams.edit_metric) {
// edit_metric binds the "Update metric" button to overwrite a named metric.
// Both edit_metric and open_query are URL-controlled, so we never bind the
@@ -4148,7 +4190,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
)
}
- if (props.monaco) {
+ if (props.monaco || props.mode === SQLEditorMode.BusinessIntelligence) {
await createQueryTab()
} else {
// The newest URL wins. A run that a newer URL replaced drops its target when its wait times out.
@@ -4392,7 +4434,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
const hasExplicitEditorUrlState =
window.location.search.length > 0 ||
window.location.hash.length > 0 ||
- window.location.pathname !== urls.sqlEditor()
+ removeProjectIdIfPresent(window.location.pathname) !== values.editorUrl
if (
(isEmbeddedSQLEditorMode(props.mode ?? SQLEditorMode.FullScene) || !hasExplicitEditorUrlState) &&
diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorModes.ts b/frontend/src/scenes/data-warehouse/editor/sqlEditorModes.ts
index 5352e67405b3..188487ff6a4c 100644
--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorModes.ts
+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorModes.ts
@@ -1,5 +1,6 @@
export enum SQLEditorMode {
FullScene = 'full_scene',
+ BusinessIntelligence = 'business_intelligence',
Embedded = 'embedded',
}
diff --git a/frontend/src/scenes/sceneTypes.ts b/frontend/src/scenes/sceneTypes.ts
index f27ee9d3f164..1fd73e2073c9 100644
--- a/frontend/src/scenes/sceneTypes.ts
+++ b/frontend/src/scenes/sceneTypes.ts
@@ -27,6 +27,7 @@ export enum Scene {
Billing = 'Billing',
BillingAuthorizationStatus = 'BillingAuthorizationStatus',
BillingSection = 'BillingSection',
+ BusinessIntelligence = 'BusinessIntelligence',
Canvas = 'Canvas',
CLIAuthorize = 'CLIAuthorize',
CLILive = 'CLILive',
diff --git a/frontend/src/styles/base.scss b/frontend/src/styles/base.scss
index ff81c38a0baa..fa0af897a0d3 100644
--- a/frontend/src/styles/base.scss
+++ b/frontend/src/styles/base.scss
@@ -342,6 +342,8 @@
--color-product-product-tours-dark: rgb(244 114 182);
--color-product-customer-analytics-light: rgb(23 158 172);
--color-product-customer-analytics-dark: rgb(85 199 211);
+ --color-product-business-intelligence-light: rgb(8 145 178);
+ --color-product-business-intelligence-dark: rgb(34 211 238);
--color-product-data-warehouse-light: rgb(133 103 255);
--color-product-data-warehouse-dark: rgb(160 135 255);
--color-product-data-catalog-light: rgb(101 78 196);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 00035c73bf92..bfb99648726d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -686,6 +686,9 @@ importers:
'@posthog/products-billing-alerts':
specifier: workspace:*
version: link:../products/billing_alerts
+ '@posthog/products-business-intelligence':
+ specifier: workspace:*
+ version: link:../products/business_intelligence
'@posthog/products-business-knowledge':
specifier: workspace:*
version: link:../products/business_knowledge
@@ -2709,6 +2712,37 @@ importers:
specifier: 6.0.3
version: 6.0.3
+ products/business_intelligence:
+ dependencies:
+ '@posthog/icons':
+ specifier: 'catalog:'
+ '@posthog/lemon-ui':
+ specifier: '*'
+ version: 0.0.0([email protected]([email protected])([email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected])))([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))([email protected]([email protected]))([email protected])
+ '@types/react':
+ specifier: 18.3.27
+ version: 18.3.27
+ kea:
+ specifier: 'catalog:'
+ version: 4.0.0-pre.6(patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected])
+ kea-loaders:
+ specifier: 'catalog:'
+ version: 3.1.1([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))
+ kea-subscriptions:
+ specifier: 'catalog:'
+ version: 3.0.1([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))
+ posthog-js:
+ specifier: 'catalog:'
+ version: 1.435.5(@types/[email protected])([email protected])
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ devDependencies:
+ kea-test-utils:
+ specifier: 'catalog:'
+ version: 0.2.4([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))
+
products/business_knowledge:
dependencies:
'@posthog/brand':
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index c95fbe052920..40f3890194d5 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -1376,6 +1376,7 @@ class FileSystemIconType(StrEnum):
MANAGED_VIEWSETS = "managed_viewsets"
ENDPOINTS = "endpoints"
SQL_EDITOR = "sql_editor"
+ BUSINESS_INTELLIGENCE = "business_intelligence"
WEB_ANALYTICS = "web_analytics"
ERROR_TRACKING = "error_tracking"
HEATMAP = "heatmap"
diff --git a/products/business_intelligence/__init__.py b/products/business_intelligence/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/products/data_warehouse/frontend/bi/BICalculatedMeasureModal.tsx b/products/business_intelligence/frontend/BICalculatedMeasureModal.tsx
similarity index 97%
rename from products/data_warehouse/frontend/bi/BICalculatedMeasureModal.tsx
rename to products/business_intelligence/frontend/BICalculatedMeasureModal.tsx
index 083d2c656010..d1b59cd4ea03 100644
--- a/products/data_warehouse/frontend/bi/BICalculatedMeasureModal.tsx
+++ b/products/business_intelligence/frontend/BICalculatedMeasureModal.tsx
@@ -3,11 +3,12 @@ import { useActions, useValues } from 'kea'
import { LemonButton, LemonInput, LemonLabel, LemonModal } from '@posthog/lemon-ui'
import { CodeEditorInline } from 'lib/monaco/CodeEditorInline'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
import { NodeKind } from '~/queries/schema/schema-general'
import { escapeDottedHogQLIdentifier } from '~/queries/utils'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+
export function BICalculatedMeasureModal(): JSX.Element | null {
const { calculatedMeasureDraft: draft, config } = useValues(biEditorLogic)
const { setCalculatedMeasureDraft, saveCalculatedMeasure } = useActions(biEditorLogic)
diff --git a/products/data_warehouse/frontend/bi/BIConnectionGroup.tsx b/products/business_intelligence/frontend/BIConnectionGroup.tsx
similarity index 93%
rename from products/data_warehouse/frontend/bi/BIConnectionGroup.tsx
rename to products/business_intelligence/frontend/BIConnectionGroup.tsx
index 58a8d58315a0..6cf123d37e29 100644
--- a/products/data_warehouse/frontend/bi/BIConnectionGroup.tsx
+++ b/products/business_intelligence/frontend/BIConnectionGroup.tsx
@@ -5,9 +5,9 @@ import { LemonButton, Spinner } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
-import { biConnectionsLogic } from './biConnectionsLogic'
-import { BIConnection } from './biConnectionTree'
-import { BIDataPaneSection } from './BIDataPaneSection'
+import { biConnectionsLogic } from 'products/business_intelligence/frontend/biConnectionsLogic'
+import { BIConnection } from 'products/business_intelligence/frontend/biConnectionTree'
+import { BIDataPaneSection } from 'products/business_intelligence/frontend/BIDataPaneSection'
export function BIConnectionGroup({ connections }: { connections: BIConnection[] }): JSX.Element | null {
const { toggleConnection, hydrateTableFields } = useActions(biConnectionsLogic)
diff --git a/products/data_warehouse/frontend/bi/BIConnections.tsx b/products/business_intelligence/frontend/BIConnections.tsx
similarity index 69%
rename from products/data_warehouse/frontend/bi/BIConnections.tsx
rename to products/business_intelligence/frontend/BIConnections.tsx
index 0bab933ca361..adda76f99689 100644
--- a/products/data_warehouse/frontend/bi/BIConnections.tsx
+++ b/products/business_intelligence/frontend/BIConnections.tsx
@@ -1,9 +1,8 @@
import { BindLogic, useMountedLogic, useValues } from 'kea'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
-
-import { BIConnectionGroup } from './BIConnectionGroup'
-import { biConnectionsLogic } from './biConnectionsLogic'
+import { BIConnectionGroup } from 'products/business_intelligence/frontend/BIConnectionGroup'
+import { biConnectionsLogic } from 'products/business_intelligence/frontend/biConnectionsLogic'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
export function BIConnections(): JSX.Element {
const biLogic = useMountedLogic(biEditorLogic)
diff --git a/products/data_warehouse/frontend/bi/BIDataPaneSection.tsx b/products/business_intelligence/frontend/BIDataPaneSection.tsx
similarity index 95%
rename from products/data_warehouse/frontend/bi/BIDataPaneSection.tsx
rename to products/business_intelligence/frontend/BIDataPaneSection.tsx
index 03d9ece1968f..a49d81424811 100644
--- a/products/data_warehouse/frontend/bi/BIDataPaneSection.tsx
+++ b/products/business_intelligence/frontend/BIDataPaneSection.tsx
@@ -3,13 +3,14 @@ import { useActions } from 'kea'
import { IconCalendar } from '@posthog/icons'
import { cn } from 'lib/utils/css-classes'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
+
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
import {
BIField,
BI_FIELD_DRAG_MIME_TYPE,
getBIDropTarget,
serializeBIField,
-} from 'scenes/data-warehouse/editor/bi/biEditorTypes'
+} from 'products/business_intelligence/frontend/biEditorTypes'
function FieldTypeGlyph({ field, measure }: { field: BIField; measure: boolean }): JSX.Element {
const glyph =
diff --git a/products/data_warehouse/frontend/bi/BIDataSourcePicker.tsx b/products/business_intelligence/frontend/BIDataSourcePicker.tsx
similarity index 93%
rename from products/data_warehouse/frontend/bi/BIDataSourcePicker.tsx
rename to products/business_intelligence/frontend/BIDataSourcePicker.tsx
index 0a34d954224c..3a510696c852 100644
--- a/products/data_warehouse/frontend/bi/BIDataSourcePicker.tsx
+++ b/products/business_intelligence/frontend/BIDataSourcePicker.tsx
@@ -6,10 +6,10 @@ import { LemonButton, LemonDropdown, LemonInput, Spinner } from '@posthog/lemon-
import { LemonTree } from 'lib/lemon-ui/LemonTree/LemonTree'
import { TreeNodeDisplayIcon } from 'lib/lemon-ui/LemonTree/LemonTreeUtils'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
-import { getBIDataSourceKey } from 'scenes/data-warehouse/editor/bi/biEditorTypes'
-import { biDataSourcePickerLogic } from './biDataSourcePickerLogic'
+import { biDataSourcePickerLogic } from 'products/business_intelligence/frontend/biDataSourcePickerLogic'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { getBIDataSourceKey } from 'products/business_intelligence/frontend/biEditorTypes'
export function BIDataSourcePicker(): JSX.Element {
const biLogic = useMountedLogic(biEditorLogic)
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/BIEditor.tsx b/products/business_intelligence/frontend/BIEditor.tsx
similarity index 82%
rename from frontend/src/scenes/data-warehouse/editor/bi/BIEditor.tsx
rename to products/business_intelligence/frontend/BIEditor.tsx
index e30465b1807b..79fa0c360ff2 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/BIEditor.tsx
+++ b/products/business_intelligence/frontend/BIEditor.tsx
@@ -3,20 +3,22 @@ import type { ReactNode } from 'react'
import { Resizer } from 'lib/components/Resizer/Resizer'
import { IconTableChart } from 'lib/lemon-ui/icons'
+import { editorSizingLogic } from 'scenes/data-warehouse/editor/editorSizingLogic'
-import { BICalculatedMeasureModal } from 'products/data_warehouse/frontend/bi/BICalculatedMeasureModal'
-import { BIFilterControl } from 'products/data_warehouse/frontend/bi/BIFilterControl'
-
-import { editorSizingLogic } from '../editorSizingLogic'
-import { biEditorLogic } from './biEditorLogic'
-import { BI_SHELF_PILL_DRAG_MIME_TYPE, parseBIShelfPillDragData } from './biEditorTypes'
-import { BIDataPane } from './components/BIDataPane'
-import { BIFieldPill } from './components/BIFieldPill'
-import { BIFiltersCard } from './components/BIFiltersCard'
-import { BIMarksCard } from './components/BIMarksCard'
-import { BIShelfStrip } from './components/BIShelfStrip'
-import { BIShowMe } from './components/BIShowMe'
-import { BIToolbar } from './components/BIToolbar'
+import { BICalculatedMeasureModal } from 'products/business_intelligence/frontend/BICalculatedMeasureModal'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import {
+ BI_SHELF_PILL_DRAG_MIME_TYPE,
+ parseBIShelfPillDragData,
+} from 'products/business_intelligence/frontend/biEditorTypes'
+import { BIFilterControl } from 'products/business_intelligence/frontend/BIFilterControl'
+import { BIDataPane } from 'products/business_intelligence/frontend/components/BIDataPane'
+import { BIFieldPill } from 'products/business_intelligence/frontend/components/BIFieldPill'
+import { BIFiltersCard } from 'products/business_intelligence/frontend/components/BIFiltersCard'
+import { BIMarksCard } from 'products/business_intelligence/frontend/components/BIMarksCard'
+import { BIShelfStrip } from 'products/business_intelligence/frontend/components/BIShelfStrip'
+import { BIShowMe } from 'products/business_intelligence/frontend/components/BIShowMe'
+import { BIToolbar } from 'products/business_intelligence/frontend/components/BIToolbar'
/**
* A worksheet laid out like desktop BI tools: data pane, filter and marks cards, rows and columns
@@ -56,7 +58,7 @@ export function BIEditor({ tabId, children }: { tabId: string; children: ReactNo
>
{/* The resizer measures the data pane alone, because the cards column has a fixed width */}
<div ref={biEditorResizerProps.containerRef} className="flex min-h-0 min-w-0 flex-1 flex-col">
- <BIDataPane />
+ <BIDataPane tabId={tabId} />
</div>
<div className="flex max-h-[40%] shrink-0 flex-col overflow-y-auto border-t @5xl/bi-editor:max-h-none @5xl/bi-editor:w-40 @5xl/bi-editor:border-l @5xl/bi-editor:border-t-0">
<BIFiltersCard />
diff --git a/products/data_warehouse/frontend/bi/BIFilterControl.tsx b/products/business_intelligence/frontend/BIFilterControl.tsx
similarity index 92%
rename from products/data_warehouse/frontend/bi/BIFilterControl.tsx
rename to products/business_intelligence/frontend/BIFilterControl.tsx
index 2ef96509f272..ef54c69a63fb 100644
--- a/products/data_warehouse/frontend/bi/BIFilterControl.tsx
+++ b/products/business_intelligence/frontend/BIFilterControl.tsx
@@ -4,14 +4,15 @@ import { IconChevronDown } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonDropdown } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
+
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
import {
getBIFieldPillLabel,
getBIFilterSummary,
getBIFilterValidationError,
getBIShelfEditorKey,
-} from 'scenes/data-warehouse/editor/bi/biEditorTypes'
-import { BIFilterEditor } from 'scenes/data-warehouse/editor/bi/components/BIFilterEditor'
+} from 'products/business_intelligence/frontend/biEditorTypes'
+import { BIFilterEditor } from 'products/business_intelligence/frontend/components/BIFilterEditor'
export function BIFilterControl({ index }: { index: number }): JSX.Element | null {
const { config, activeExpressionEditorId } = useValues(biEditorLogic)
diff --git a/products/data_warehouse/frontend/bi/BIFilterValueInput.tsx b/products/business_intelligence/frontend/BIFilterValueInput.tsx
similarity index 96%
rename from products/data_warehouse/frontend/bi/BIFilterValueInput.tsx
rename to products/business_intelligence/frontend/BIFilterValueInput.tsx
index 8ec62ba789e3..ae47c5ca59eb 100644
--- a/products/data_warehouse/frontend/bi/BIFilterValueInput.tsx
+++ b/products/business_intelligence/frontend/BIFilterValueInput.tsx
@@ -5,14 +5,14 @@ import { LemonButton, LemonInput, LemonInputSelect } from '@posthog/lemon-ui'
import { dayjs } from 'lib/dayjs'
import { LemonCalendarSelectInput } from 'lib/lemon-ui/LemonCalendar/LemonCalendarSelect'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
+
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
import {
buildBIFilterOptionsQuery,
getBIFilterValidationError,
isDateTimeBIField,
-} from 'scenes/data-warehouse/editor/bi/biEditorTypes'
-
-import { biFilterValuesLogic } from './biFilterValuesLogic'
+} from 'products/business_intelligence/frontend/biEditorTypes'
+import { biFilterValuesLogic } from 'products/business_intelligence/frontend/biFilterValuesLogic'
export function BIFilterValueInput({ index }: { index: number }): JSX.Element | null {
const { config } = useValues(biEditorLogic)
diff --git a/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx b/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
new file mode 100644
index 000000000000..5c758bf07ad6
--- /dev/null
+++ b/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
@@ -0,0 +1,54 @@
+import { useActions, useValues } from 'kea'
+
+import 'scenes/data-warehouse/editor/EditorScene.scss'
+import { AccessDenied } from 'lib/components/AccessDenied'
+import { NotFound } from 'lib/components/NotFound'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { userHasAccess } from 'lib/utils/accessControlUtils'
+import { editorSceneLogic } from 'scenes/data-warehouse/editor/editorSceneLogic'
+import { OutputPane } from 'scenes/data-warehouse/editor/OutputPane'
+import { SQLEditor } from 'scenes/data-warehouse/editor/SQLEditor'
+import { SQLEditorMode } from 'scenes/data-warehouse/editor/sqlEditorModes'
+import { SceneExport } from 'scenes/sceneTypes'
+
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import { BIEditor } from './BIEditor'
+
+export const scene: SceneExport = {
+ component: BusinessIntelligenceScene,
+ logic: editorSceneLogic,
+ paramsToProps: ({ params }) => ({
+ tabId: `bi-${params.tabId ?? 'default'}`,
+ mode: SQLEditorMode.BusinessIntelligence,
+ }),
+}
+
+export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: string }): JSX.Element {
+ const { featureFlags } = useValues(featureFlagLogic)
+ const { shareTab } = useActions(editorSceneLogic({ tabId, mode: SQLEditorMode.BusinessIntelligence }))
+
+ if (!featureFlags[FEATURE_FLAGS.SQL_EDITOR_BI_MODE]) {
+ return <NotFound object="page" />
+ }
+
+ if (!userHasAccess(AccessControlResourceType.WarehouseObjects, AccessControlLevel.Viewer)) {
+ return (
+ <AccessDenied reason="You don't have access to Data warehouse tables & views, so Business intelligence isn't available." />
+ )
+ }
+
+ return (
+ <SQLEditor
+ tabId={tabId}
+ mode={SQLEditorMode.BusinessIntelligence}
+ showDatabaseTree={false}
+ onShareTab={shareTab}
+ >
+ <BIEditor tabId={tabId}>
+ <OutputPane tabId={tabId} biMode onShareTab={shareTab} />
+ </BIEditor>
+ </SQLEditor>
+ )
+}
diff --git a/products/data_warehouse/frontend/bi/biConnectionTree.test.ts b/products/business_intelligence/frontend/biConnectionTree.test.ts
similarity index 97%
rename from products/data_warehouse/frontend/bi/biConnectionTree.test.ts
rename to products/business_intelligence/frontend/biConnectionTree.test.ts
index 2a35595ece30..3652de147b56 100644
--- a/products/data_warehouse/frontend/bi/biConnectionTree.test.ts
+++ b/products/business_intelligence/frontend/biConnectionTree.test.ts
@@ -1,14 +1,17 @@
+import { DatabaseSchemaField, DatabaseSchemaTable } from '~/queries/schema/schema-general'
+
+import {
+ buildBIConnections,
+ filterBIConnections,
+ getPendingBIConnectionTables,
+} from 'products/business_intelligence/frontend/biConnectionTree'
import {
BIDataSource,
BIField,
buildBIQuery,
DEFAULT_BI_CONFIG,
getBIDropTarget,
-} from 'scenes/data-warehouse/editor/bi/biEditorTypes'
-
-import { DatabaseSchemaField, DatabaseSchemaTable } from '~/queries/schema/schema-general'
-
-import { buildBIConnections, filterBIConnections, getPendingBIConnectionTables } from './biConnectionTree'
+} from 'products/business_intelligence/frontend/biEditorTypes'
const field = (
name: string,
diff --git a/products/data_warehouse/frontend/bi/biConnectionTree.ts b/products/business_intelligence/frontend/biConnectionTree.ts
similarity index 98%
rename from products/data_warehouse/frontend/bi/biConnectionTree.ts
rename to products/business_intelligence/frontend/biConnectionTree.ts
index 8cbf7b50a156..675fc2036075 100644
--- a/products/data_warehouse/frontend/bi/biConnectionTree.ts
+++ b/products/business_intelligence/frontend/biConnectionTree.ts
@@ -1,9 +1,14 @@
import { TableFieldsStatus } from 'scenes/data-management/database/databaseTableListLogic'
-import { BIDataPaneFields, BIDataSource, getBIDataPaneFields } from 'scenes/data-warehouse/editor/bi/biEditorTypes'
import { resolveFieldTraverserTarget } from 'scenes/data-warehouse/editor/sidebar/queryDatabaseLogic'
import { DatabaseSchemaField, DatabaseSchemaTable } from '~/queries/schema/schema-general'
+import {
+ BIDataPaneFields,
+ BIDataSource,
+ getBIDataPaneFields,
+} from 'products/business_intelligence/frontend/biEditorTypes'
+
export interface BIConnection {
id: string
name: string
diff --git a/products/data_warehouse/frontend/bi/biConnectionsLogic.ts b/products/business_intelligence/frontend/biConnectionsLogic.ts
similarity index 84%
rename from products/data_warehouse/frontend/bi/biConnectionsLogic.ts
rename to products/business_intelligence/frontend/biConnectionsLogic.ts
index 32540e430d70..d12e08a42f09 100644
--- a/products/data_warehouse/frontend/bi/biConnectionsLogic.ts
+++ b/products/business_intelligence/frontend/biConnectionsLogic.ts
@@ -13,13 +13,18 @@ import {
} from 'kea'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
+import type { TableFieldsStatus } from 'scenes/data-management/database/databaseTableListLogic'
-import type { DatabaseSchemaTable } from '../../../../frontend/src/queries/schema/schema-general'
-import type { TableFieldsStatus } from '../../../../frontend/src/scenes/data-management/database/databaseTableListLogic'
-import type { BIConfig } from '../../../../frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes'
-import { buildBIConnections, filterBIConnections, getPendingBIConnectionTables } from './biConnectionTree'
-import type { BIConnection } from './biConnectionTree'
+import type { DatabaseSchemaTable } from '~/queries/schema/schema-general'
+
+import {
+ buildBIConnections,
+ filterBIConnections,
+ getPendingBIConnectionTables,
+} from 'products/business_intelligence/frontend/biConnectionTree'
+import type { BIConnection } from 'products/business_intelligence/frontend/biConnectionTree'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import type { BIConfig } from 'products/business_intelligence/frontend/biEditorTypes'
export interface BIConnectionsLogicProps {
tabId: string
@@ -43,10 +48,8 @@ export interface biConnectionsLogicActions {
resetConfig: () => {
value: true
} // biEditorLogic
- setDataSource: (
- source: import('../../../../frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes').BIDataSource
- ) => {
- source: import('../../../../frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes').BIDataSource
+ setDataSource: (source: import('products/business_intelligence/frontend/biEditorTypes').BIDataSource) => {
+ source: import('products/business_intelligence/frontend/biEditorTypes').BIDataSource
} // biEditorLogic
hydrateTableFields: (tableNames: string[]) => {
tableNames: string[]
@@ -93,7 +96,7 @@ export type biConnectionsLogicType = MakeLogicType<
export const biConnectionsLogic: LogicWrapper<biConnectionsLogicType> = kea<biConnectionsLogicType>([
props({} as BIConnectionsLogicProps),
key((props) => props.tabId),
- path((key) => ['products', 'data_warehouse', 'frontend', 'bi', 'biConnectionsLogic', key]),
+ path((key) => ['products', 'business_intelligence', 'frontend', 'biConnectionsLogic', key]),
connect((props: BIConnectionsLogicProps) => ({
values: [
biEditorLogic({ tabId: props.tabId }),
diff --git a/products/data_warehouse/frontend/bi/biDataSourcePickerLogic.ts b/products/business_intelligence/frontend/biDataSourcePickerLogic.ts
similarity index 87%
rename from products/data_warehouse/frontend/bi/biDataSourcePickerLogic.ts
rename to products/business_intelligence/frontend/biDataSourcePickerLogic.ts
index 146ea64d7679..5e66286153f4 100644
--- a/products/data_warehouse/frontend/bi/biDataSourcePickerLogic.ts
+++ b/products/business_intelligence/frontend/biDataSourcePickerLogic.ts
@@ -12,15 +12,19 @@ import {
selectors,
} from 'kea'
-import { biEditorLogic } from 'scenes/data-warehouse/editor/bi/biEditorLogic'
-import { getBIDataSourceKey } from 'scenes/data-warehouse/editor/bi/biEditorTypes'
+import type { TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'
import { POSTHOG_WAREHOUSE } from 'scenes/data-warehouse/editor/connectionSelectorLogic'
import { queryDatabaseLogic } from 'scenes/data-warehouse/editor/sidebar/queryDatabaseLogic'
-import type { TreeDataItem } from '../../../../frontend/src/lib/lemon-ui/LemonTree/LemonTree'
-import type { BIConfig, BIDataSource } from '../../../../frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes'
-import type { ExternalDataSourceConnectionOptionApi } from '../../../warehouse_sources/frontend/generated/api.schemas'
-import { buildBIDataSourceTree, getBIDataSourceFolderIds, searchBIDataSourceTree } from './biDataSourceTree'
+import {
+ buildBIDataSourceTree,
+ getBIDataSourceFolderIds,
+ searchBIDataSourceTree,
+} from 'products/business_intelligence/frontend/biDataSourceTree'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { getBIDataSourceKey } from 'products/business_intelligence/frontend/biEditorTypes'
+import type { BIConfig, BIDataSource } from 'products/business_intelligence/frontend/biEditorTypes'
+import type { ExternalDataSourceConnectionOptionApi } from 'products/warehouse_sources/frontend/generated/api.schemas'
export interface BIDataSourcePickerLogicProps {
tabId: string
@@ -90,7 +94,7 @@ export type biDataSourcePickerLogicType = MakeLogicType<
export const biDataSourcePickerLogic: LogicWrapper<biDataSourcePickerLogicType> = kea<biDataSourcePickerLogicType>([
props({} as BIDataSourcePickerLogicProps),
key((props) => props.tabId),
- path((key) => ['products', 'data_warehouse', 'frontend', 'bi', 'biDataSourcePickerLogic', key]),
+ path((key) => ['products', 'business_intelligence', 'frontend', 'biDataSourcePickerLogic', key]),
connect((props: BIDataSourcePickerLogicProps) => ({
values: [
biEditorLogic({ tabId: props.tabId }),
diff --git a/products/data_warehouse/frontend/bi/biDataSourceTree.test.ts b/products/business_intelligence/frontend/biDataSourceTree.test.ts
similarity index 95%
rename from products/data_warehouse/frontend/bi/biDataSourceTree.test.ts
rename to products/business_intelligence/frontend/biDataSourceTree.test.ts
index 4e25ef607a77..7ce0a0b7f413 100644
--- a/products/data_warehouse/frontend/bi/biDataSourceTree.test.ts
+++ b/products/business_intelligence/frontend/biDataSourceTree.test.ts
@@ -1,7 +1,7 @@
import { TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'
-import { BIDataSource, getBIDataSourceKey } from 'scenes/data-warehouse/editor/bi/biEditorTypes'
-import { buildBIDataSourceTree, searchBIDataSourceTree } from './biDataSourceTree'
+import { buildBIDataSourceTree, searchBIDataSourceTree } from 'products/business_intelligence/frontend/biDataSourceTree'
+import { BIDataSource, getBIDataSourceKey } from 'products/business_intelligence/frontend/biEditorTypes'
const tree: TreeDataItem[] = [
{
diff --git a/products/data_warehouse/frontend/bi/biDataSourceTree.ts b/products/business_intelligence/frontend/biDataSourceTree.ts
similarity index 96%
rename from products/data_warehouse/frontend/bi/biDataSourceTree.ts
rename to products/business_intelligence/frontend/biDataSourceTree.ts
index c2d7b7850888..62242f7486cc 100644
--- a/products/data_warehouse/frontend/bi/biDataSourceTree.ts
+++ b/products/business_intelligence/frontend/biDataSourceTree.ts
@@ -1,7 +1,8 @@
import { TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'
-import { BIDataSource, getBIDataSourceKey } from 'scenes/data-warehouse/editor/bi/biEditorTypes'
import { groupDirectConnectionTableNodesBySchema } from 'scenes/data-warehouse/editor/sidebar/queryDatabaseLogic'
+import { BIDataSource, getBIDataSourceKey } from 'products/business_intelligence/frontend/biEditorTypes'
+
export function buildBIDataSourceTree(
tree: TreeDataItem[],
sources: BIDataSource[],
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorAnalytics.ts b/products/business_intelligence/frontend/biEditorAnalytics.ts
similarity index 98%
rename from frontend/src/scenes/data-warehouse/editor/bi/biEditorAnalytics.ts
rename to products/business_intelligence/frontend/biEditorAnalytics.ts
index 37889be53357..96efd531f065 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/biEditorAnalytics.ts
+++ b/products/business_intelligence/frontend/biEditorAnalytics.ts
@@ -1,6 +1,6 @@
import posthog from 'posthog-js'
-import { type BIConfig, type BIEditorState, BIEditorView } from './biEditorTypes'
+import { type BIConfig, type BIEditorState, BIEditorView } from 'products/business_intelligence/frontend/biEditorTypes'
export const BI_EDITOR_EVENTS = {
MODE_SELECTED: 'sql-editor-bi-mode-selected',
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorLogic.ts b/products/business_intelligence/frontend/biEditorLogic.ts
similarity index 98%
rename from frontend/src/scenes/data-warehouse/editor/bi/biEditorLogic.ts
rename to products/business_intelligence/frontend/biEditorLogic.ts
index f9716573740a..bd90f2b42e88 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/biEditorLogic.ts
+++ b/products/business_intelligence/frontend/biEditorLogic.ts
@@ -3,14 +3,14 @@ import { subscriptions } from 'kea-subscriptions'
import { uuid } from 'lib/utils/dom'
import { TableFieldsStatus, databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
+import { sqlEditorLogic } from 'scenes/data-warehouse/editor/sqlEditorLogic'
+import type { QueryTab } from 'scenes/data-warehouse/editor/sqlEditorLogic'
import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
import { DatabaseSchemaTable } from '~/queries/schema/schema-general'
import { ChartDisplayType } from '~/types'
-import { sqlEditorLogic } from '../sqlEditorLogic'
-import type { QueryTab } from '../sqlEditorLogic'
-import { captureBIEditorModeSelected } from './biEditorAnalytics'
+import { captureBIEditorModeSelected } from 'products/business_intelligence/frontend/biEditorAnalytics'
import {
BIAggregation,
BIChartFit,
@@ -40,7 +40,7 @@ import {
getBISortOptions,
isBIFieldCompatible,
normalizeBIConfig,
-} from './biEditorTypes'
+} from 'products/business_intelligence/frontend/biEditorTypes'
export interface BIEditorLogicProps {
tabId: string
@@ -267,7 +267,7 @@ export interface biEditorLogicActions {
tableNames: string[]
} // databaseTableListLogic
loadDatabaseSuccess: (
- database: Required<import('~/queries/schema/schema-general').DatabaseSchemaQueryResponse> | null,
+ database: Required<import('~/queries/schema').DatabaseSchemaQueryResponse> | null,
payload?:
| {
force?: boolean
@@ -275,14 +275,14 @@ export interface biEditorLogicActions {
}
| undefined
) => {
- database: Required<import('~/queries/schema/schema-general').DatabaseSchemaQueryResponse> | null
+ database: Required<import('~/queries/schema').DatabaseSchemaQueryResponse> | null
payload?: {
force?: boolean
shallow?: boolean
}
} // databaseTableListLogic
- setSourceQuery: (sourceQuery: import('~/queries/schema/schema-general').DataVisualizationNode) => {
- sourceQuery: import('~/queries/schema/schema-general').DataVisualizationNode
+ setSourceQuery: (sourceQuery: import('~/queries/schema').DataVisualizationNode) => {
+ sourceQuery: import('~/queries/schema').DataVisualizationNode
} // sqlEditorLogic
syncUrlWithQuery: () => {
value: true
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorOptions.tsx b/products/business_intelligence/frontend/biEditorOptions.tsx
similarity index 95%
rename from frontend/src/scenes/data-warehouse/editor/bi/biEditorOptions.tsx
rename to products/business_intelligence/frontend/biEditorOptions.tsx
index fb2217362ee9..dd1da395d47e 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/biEditorOptions.tsx
+++ b/products/business_intelligence/frontend/biEditorOptions.tsx
@@ -6,7 +6,12 @@ import { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { ChartDisplayType } from '~/types'
-import { BIAggregation, BIDateBucket, BIFilterOperator, BI_QUERY_LIMITS } from './biEditorTypes'
+import {
+ BIAggregation,
+ BIDateBucket,
+ BIFilterOperator,
+ BI_QUERY_LIMITS,
+} from 'products/business_intelligence/frontend/biEditorTypes'
export const CHART_TYPE_OPTIONS: { value: ChartDisplayType; label: string; icon: JSX.Element }[] = [
{ value: ChartDisplayType.Auto, label: 'Automatic', icon: <IconMagicWand /> },
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.test.ts b/products/business_intelligence/frontend/biEditorTypes.test.ts
similarity index 99%
rename from frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.test.ts
rename to products/business_intelligence/frontend/biEditorTypes.test.ts
index 5f5c3a48c70e..b360a19ad328 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.test.ts
+++ b/products/business_intelligence/frontend/biEditorTypes.test.ts
@@ -22,7 +22,7 @@ import {
isBIFieldCompatible,
isBIMeasureField,
parseBIEditorState,
-} from './biEditorTypes'
+} from 'products/business_intelligence/frontend/biEditorTypes'
const eventField: BIField = {
id: 'warehouse:events:event',
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.ts b/products/business_intelligence/frontend/biEditorTypes.ts
similarity index 100%
rename from frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.ts
rename to products/business_intelligence/frontend/biEditorTypes.ts
diff --git a/products/data_warehouse/frontend/bi/biFilterValuesLogic.test.ts b/products/business_intelligence/frontend/biFilterValuesLogic.test.ts
similarity index 93%
rename from products/data_warehouse/frontend/bi/biFilterValuesLogic.test.ts
rename to products/business_intelligence/frontend/biFilterValuesLogic.test.ts
index 2406f3d9f438..d88705093168 100644
--- a/products/data_warehouse/frontend/bi/biFilterValuesLogic.test.ts
+++ b/products/business_intelligence/frontend/biFilterValuesLogic.test.ts
@@ -4,7 +4,7 @@ import * as queryRunner from '~/queries/query'
import { NodeKind } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
-import { biFilterValuesLogic } from './biFilterValuesLogic'
+import { biFilterValuesLogic } from 'products/business_intelligence/frontend/biFilterValuesLogic'
describe('BI filter suggestions', () => {
beforeEach(() => initKeaTests())
diff --git a/products/data_warehouse/frontend/bi/biFilterValuesLogic.ts b/products/business_intelligence/frontend/biFilterValuesLogic.ts
similarity index 96%
rename from products/data_warehouse/frontend/bi/biFilterValuesLogic.ts
rename to products/business_intelligence/frontend/biFilterValuesLogic.ts
index 3cceca1f3024..534d757823df 100644
--- a/products/data_warehouse/frontend/bi/biFilterValuesLogic.ts
+++ b/products/business_intelligence/frontend/biFilterValuesLogic.ts
@@ -50,7 +50,7 @@ export type biFilterValuesLogicType = MakeLogicType<
export const biFilterValuesLogic = kea<biFilterValuesLogicType>([
props({} as BIFilterValuesLogicProps),
key((props) => JSON.stringify(props.query)),
- path((key) => ['products', 'data_warehouse', 'frontend', 'bi', 'biFilterValuesLogic', key]),
+ path((key) => ['products', 'business_intelligence', 'frontend', 'biFilterValuesLogic', key]),
loaders(({ props }) => ({
options: [
null as string[] | null,
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIDataPane.tsx b/products/business_intelligence/frontend/components/BIDataPane.tsx
similarity index 74%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIDataPane.tsx
rename to products/business_intelligence/frontend/components/BIDataPane.tsx
index 7dcbcbe5a5bf..f16888af8ec8 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIDataPane.tsx
+++ b/products/business_intelligence/frontend/components/BIDataPane.tsx
@@ -3,16 +3,15 @@ import { useActions, useValues } from 'kea'
import { IconPlus } from '@posthog/icons'
import { LemonButton, LemonInput, Spinner } from '@posthog/lemon-ui'
-import { BIConnections } from 'products/data_warehouse/frontend/bi/BIConnections'
-import { BIDataPaneSection } from 'products/data_warehouse/frontend/bi/BIDataPaneSection'
-import { BIDataSourcePicker } from 'products/data_warehouse/frontend/bi/BIDataSourcePicker'
+import { ConnectionSelector } from 'scenes/data-warehouse/editor/ConnectionSelector'
-import { editorSizingLogic } from '../../editorSizingLogic'
-import { queryDatabaseLogic } from '../../sidebar/queryDatabaseLogic'
-import { biEditorLogic } from '../biEditorLogic'
+import { BIConnections } from 'products/business_intelligence/frontend/BIConnections'
+import { BIDataPaneSection } from 'products/business_intelligence/frontend/BIDataPaneSection'
+import { BIDataSourcePicker } from 'products/business_intelligence/frontend/BIDataSourcePicker'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
/** Lists the selected table's fields as dimensions and measures, ready to drag onto shelves. */
-export function BIDataPane(): JSX.Element {
+export function BIDataPane({ tabId }: { tabId: string }): JSX.Element {
const {
config,
dataPaneFields,
@@ -22,8 +21,6 @@ export function BIDataPane(): JSX.Element {
filteredDataPaneFields,
} = useValues(biEditorLogic)
const { editCalculatedMeasure, hydrateTableFields, setDataPaneSearch } = useActions(biEditorLogic)
- const { isDatabaseTreeCollapsed } = useValues(editorSizingLogic)
- const { locateTable } = useActions(queryDatabaseLogic)
const hasFields = dataPaneFields.dimensions.length > 0 || dataPaneFields.measures.length > 0
const hasMatches = filteredDataPaneFields.dimensions.length > 0 || filteredDataPaneFields.measures.length > 0
@@ -32,23 +29,9 @@ export function BIDataPane(): JSX.Element {
<div className="flex min-h-0 flex-1 flex-col">
<div className="flex items-center justify-between gap-1 px-2 pt-2">
<span className="text-sm font-semibold">Data</span>
- {!isDatabaseTreeCollapsed ? (
- <LemonButton
- type="tertiary"
- size="xsmall"
- disabledReason={!config.source ? 'Select a data source first' : undefined}
- tooltip="Show this table in the database tree"
- onClick={() => {
- if (config.source) {
- locateTable(config.source.table)
- }
- }}
- >
- Locate
- </LemonButton>
- ) : null}
</div>
<div className="flex flex-col gap-1.5 p-2">
+ <ConnectionSelector tabId={tabId} />
<BIDataSourcePicker />
{config.source ? (
<LemonInput
@@ -63,9 +46,7 @@ export function BIDataPane(): JSX.Element {
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-1 pb-2">
{!config.source ? (
- <p className="px-2 text-xs text-secondary">
- Select a table to list its fields. You can also drag columns from the database tree.
- </p>
+ <p className="px-2 text-xs text-secondary">Select a table to list its fields.</p>
) : dataPaneFieldsLoading && !hasFields ? (
<div className="flex items-center gap-2 px-2 text-xs text-secondary">
<Spinner /> Loading fields
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIExpressionPopover.tsx b/products/business_intelligence/frontend/components/BIExpressionPopover.tsx
similarity index 95%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIExpressionPopover.tsx
rename to products/business_intelligence/frontend/components/BIExpressionPopover.tsx
index f3d6f7fb0b1b..0412b0d8dbc3 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIExpressionPopover.tsx
+++ b/products/business_intelligence/frontend/components/BIExpressionPopover.tsx
@@ -5,7 +5,7 @@ import { HogQLEditor } from 'lib/components/HogQLEditor/HogQLEditor'
import { NodeKind } from '~/queries/schema/schema-general'
import { escapeDottedHogQLIdentifier } from '~/queries/utils'
-import { BIDataSource } from '../biEditorTypes'
+import { BIDataSource } from 'products/business_intelligence/frontend/biEditorTypes'
export function BIExpressionPopover({
visible,
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFieldPill.tsx b/products/business_intelligence/frontend/components/BIFieldPill.tsx
similarity index 93%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIFieldPill.tsx
rename to products/business_intelligence/frontend/components/BIFieldPill.tsx
index ba498f721f02..385bca6fcabf 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFieldPill.tsx
+++ b/products/business_intelligence/frontend/components/BIFieldPill.tsx
@@ -3,8 +3,12 @@ import { useActions, useValues } from 'kea'
import { IconArrowDown, IconArrowUp } from 'lib/lemon-ui/icons'
import { LemonMenu, LemonMenuItems } from 'lib/lemon-ui/LemonMenu'
-import { biEditorLogic } from '../biEditorLogic'
-import { AGGREGATION_OPTIONS, DATE_BUCKET_OPTIONS, NUMERIC_AGGREGATIONS } from '../biEditorOptions'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import {
+ AGGREGATION_OPTIONS,
+ DATE_BUCKET_OPTIONS,
+ NUMERIC_AGGREGATIONS,
+} from 'products/business_intelligence/frontend/biEditorOptions'
import {
BIShelf,
getBIFieldPillLabel,
@@ -13,9 +17,9 @@ import {
getBIValueSortKey,
isDateTimeBIField,
isNumericBIField,
-} from '../biEditorTypes'
-import { BIExpressionPopover } from './BIExpressionPopover'
-import { BIPill } from './BIPill'
+} from 'products/business_intelligence/frontend/biEditorTypes'
+import { BIExpressionPopover } from 'products/business_intelligence/frontend/components/BIExpressionPopover'
+import { BIPill } from 'products/business_intelligence/frontend/components/BIPill'
type ExpressionTarget = 'field' | 'aggregation'
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFilterEditor.tsx b/products/business_intelligence/frontend/components/BIFilterEditor.tsx
similarity index 92%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIFilterEditor.tsx
rename to products/business_intelligence/frontend/components/BIFilterEditor.tsx
index 5e77147e7320..30b498a0a5fd 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFilterEditor.tsx
+++ b/products/business_intelligence/frontend/components/BIFilterEditor.tsx
@@ -5,11 +5,10 @@ import { LemonButton, LemonCheckbox, LemonLabel, LemonSelect } from '@posthog/le
import { HogQLDropdown } from 'lib/components/HogQLDropdown/HogQLDropdown'
-import { BIFilterValueInput } from 'products/data_warehouse/frontend/bi/BIFilterValueInput'
-
-import { biEditorLogic } from '../biEditorLogic'
-import { DATE_BUCKET_OPTIONS, FILTER_OPERATOR_OPTIONS } from '../biEditorOptions'
-import { isDateTimeBIField, isNumericBIField } from '../biEditorTypes'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { DATE_BUCKET_OPTIONS, FILTER_OPERATOR_OPTIONS } from 'products/business_intelligence/frontend/biEditorOptions'
+import { isDateTimeBIField, isNumericBIField } from 'products/business_intelligence/frontend/biEditorTypes'
+import { BIFilterValueInput } from 'products/business_intelligence/frontend/BIFilterValueInput'
export function BIFilterEditor({ index, onDone }: { index: number; onDone: () => void }): JSX.Element | null {
const { config } = useValues(biEditorLogic)
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFilterPill.tsx b/products/business_intelligence/frontend/components/BIFilterPill.tsx
similarity index 85%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIFilterPill.tsx
rename to products/business_intelligence/frontend/components/BIFilterPill.tsx
index 329fb3cae13d..b92b81615678 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFilterPill.tsx
+++ b/products/business_intelligence/frontend/components/BIFilterPill.tsx
@@ -4,15 +4,15 @@ import { LemonDropdown } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
-import { biEditorLogic } from '../biEditorLogic'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
import {
getBIFieldPillLabel,
getBIFilterSummary,
getBIFilterValidationError,
getBIShelfEditorKey,
-} from '../biEditorTypes'
-import { BIFilterEditor } from './BIFilterEditor'
-import { BIPill } from './BIPill'
+} from 'products/business_intelligence/frontend/biEditorTypes'
+import { BIFilterEditor } from 'products/business_intelligence/frontend/components/BIFilterEditor'
+import { BIPill } from 'products/business_intelligence/frontend/components/BIPill'
export function BIFilterPill({ index }: { index: number }): JSX.Element | null {
const { config, activeExpressionEditorId } = useValues(biEditorLogic)
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFiltersCard.tsx b/products/business_intelligence/frontend/components/BIFiltersCard.tsx
similarity index 76%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIFiltersCard.tsx
rename to products/business_intelligence/frontend/components/BIFiltersCard.tsx
index e3aa70a17691..1ea8c254867c 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIFiltersCard.tsx
+++ b/products/business_intelligence/frontend/components/BIFiltersCard.tsx
@@ -3,10 +3,10 @@ import { useActions, useValues } from 'kea'
import { IconPlus } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
-import { biEditorLogic } from '../biEditorLogic'
-import { BIFilterPill } from './BIFilterPill'
-import { BIShelfCard } from './BIShelfCard'
-import { BIShelfDropTarget } from './BIShelfDropTarget'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { BIFilterPill } from 'products/business_intelligence/frontend/components/BIFilterPill'
+import { BIShelfCard } from 'products/business_intelligence/frontend/components/BIShelfCard'
+import { BIShelfDropTarget } from 'products/business_intelligence/frontend/components/BIShelfDropTarget'
export function BIFiltersCard(): JSX.Element {
const { config } = useValues(biEditorLogic)
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIMarksCard.tsx b/products/business_intelligence/frontend/components/BIMarksCard.tsx
similarity index 78%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIMarksCard.tsx
rename to products/business_intelligence/frontend/components/BIMarksCard.tsx
index 0f17d3a3026b..6be7ec61a9c2 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIMarksCard.tsx
+++ b/products/business_intelligence/frontend/components/BIMarksCard.tsx
@@ -4,9 +4,9 @@ import { LemonSelect } from '@posthog/lemon-ui'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { biEditorLogic } from '../biEditorLogic'
-import { getChartTypeOptions } from '../biEditorOptions'
-import { BIShelfCard } from './BIShelfCard'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { getChartTypeOptions } from 'products/business_intelligence/frontend/biEditorOptions'
+import { BIShelfCard } from 'products/business_intelligence/frontend/components/BIShelfCard'
export function BIMarksCard(): JSX.Element {
const { config } = useValues(biEditorLogic)
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIPill.tsx b/products/business_intelligence/frontend/components/BIPill.tsx
similarity index 90%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIPill.tsx
rename to products/business_intelligence/frontend/components/BIPill.tsx
index b71f33b4aa32..9edeb0c804c2 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIPill.tsx
+++ b/products/business_intelligence/frontend/components/BIPill.tsx
@@ -5,8 +5,12 @@ import { IconChevronDown } from '@posthog/icons'
import { cn } from 'lib/utils/css-classes'
-import { biEditorLogic } from '../biEditorLogic'
-import { BIShelf, BI_SHELF_PILL_DRAG_MIME_TYPE, BIShelfPillDragData } from '../biEditorTypes'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import {
+ BIShelf,
+ BI_SHELF_PILL_DRAG_MIME_TYPE,
+ BIShelfPillDragData,
+} from 'products/business_intelligence/frontend/biEditorTypes'
export type BIPillKind = 'dimension' | 'measure' | 'filter'
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfCard.tsx b/products/business_intelligence/frontend/components/BIShelfCard.tsx
similarity index 100%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfCard.tsx
rename to products/business_intelligence/frontend/components/BIShelfCard.tsx
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfDropTarget.tsx b/products/business_intelligence/frontend/components/BIShelfDropTarget.tsx
similarity index 95%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfDropTarget.tsx
rename to products/business_intelligence/frontend/components/BIShelfDropTarget.tsx
index 7cc36ae8ba4b..5a50022bed88 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfDropTarget.tsx
+++ b/products/business_intelligence/frontend/components/BIShelfDropTarget.tsx
@@ -3,7 +3,7 @@ import type { DragEvent, ReactNode } from 'react'
import { cn } from 'lib/utils/css-classes'
-import { biEditorLogic } from '../biEditorLogic'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
import {
BIShelf,
BI_FIELD_DRAG_MIME_TYPE,
@@ -11,7 +11,7 @@ import {
getBIDropTarget,
parseBIField,
parseBIShelfPillDragData,
-} from '../biEditorTypes'
+} from 'products/business_intelligence/frontend/biEditorTypes'
function carriesBIDrag(event: DragEvent<HTMLElement>): 'field' | 'pill' | null {
const types = Array.from(event.dataTransfer.types)
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfStrip.tsx b/products/business_intelligence/frontend/components/BIShelfStrip.tsx
similarity index 86%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfStrip.tsx
rename to products/business_intelligence/frontend/components/BIShelfStrip.tsx
index 2cb4a120e6c7..5104db203897 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIShelfStrip.tsx
+++ b/products/business_intelligence/frontend/components/BIShelfStrip.tsx
@@ -4,9 +4,9 @@ import type { ReactNode } from 'react'
import { IconPlus } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
-import { biEditorLogic } from '../biEditorLogic'
-import { BIShelf } from '../biEditorTypes'
-import { BIShelfDropTarget } from './BIShelfDropTarget'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { BIShelf } from 'products/business_intelligence/frontend/biEditorTypes'
+import { BIShelfDropTarget } from 'products/business_intelligence/frontend/components/BIShelfDropTarget'
/** A horizontal Rows or Columns shelf above the view. */
export function BIShelfStrip({
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIShowMe.tsx b/products/business_intelligence/frontend/components/BIShowMe.tsx
similarity index 95%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIShowMe.tsx
rename to products/business_intelligence/frontend/components/BIShowMe.tsx
index fa22d598a3f5..31ebffd018f7 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIShowMe.tsx
+++ b/products/business_intelligence/frontend/components/BIShowMe.tsx
@@ -8,8 +8,8 @@ import { cn } from 'lib/utils/css-classes'
import { ChartDisplayType } from '~/types'
-import { biEditorLogic } from '../biEditorLogic'
-import { getChartTypeOptions } from '../biEditorOptions'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { getChartTypeOptions } from 'products/business_intelligence/frontend/biEditorOptions'
/** Chart picker that highlights the chart types that suit the fields on the shelves. */
export function BIShowMe({ docked }: { docked: boolean }): JSX.Element {
diff --git a/frontend/src/scenes/data-warehouse/editor/bi/components/BIToolbar.tsx b/products/business_intelligence/frontend/components/BIToolbar.tsx
similarity index 89%
rename from frontend/src/scenes/data-warehouse/editor/bi/components/BIToolbar.tsx
rename to products/business_intelligence/frontend/components/BIToolbar.tsx
index 6512f585cac7..444cdc8a83f6 100644
--- a/frontend/src/scenes/data-warehouse/editor/bi/components/BIToolbar.tsx
+++ b/products/business_intelligence/frontend/components/BIToolbar.tsx
@@ -4,11 +4,13 @@ import { IconSort } from '@posthog/icons'
import { LemonButton, LemonDivider, LemonDropdown, LemonSelect, LemonSwitch } from '@posthog/lemon-ui'
import { IconArrowDown, IconArrowUp, IconSwapHoriz } from 'lib/lemon-ui/icons'
+import { RunButton } from 'scenes/data-warehouse/editor/RunButton'
+import { Scene } from 'scenes/sceneTypes'
-import { biEditorLogic } from '../biEditorLogic'
-import { LIMIT_OPTIONS } from '../biEditorOptions'
-import { BISortDirection } from '../biEditorTypes'
-import { BIShowMe } from './BIShowMe'
+import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
+import { LIMIT_OPTIONS } from 'products/business_intelligence/frontend/biEditorOptions'
+import { BISortDirection } from 'products/business_intelligence/frontend/biEditorTypes'
+import { BIShowMe } from 'products/business_intelligence/frontend/components/BIShowMe'
export function BIToolbar(): JSX.Element {
const { autoUpdate, config, showMeOpen, sortOptions } = useValues(biEditorLogic)
@@ -26,6 +28,10 @@ export function BIToolbar(): JSX.Element {
return (
<div className="flex flex-wrap items-center gap-1 border-b px-2 py-1">
+ <RunButton
+ scope={Scene.BusinessIntelligence}
+ runQueryDisabledReason={!config.source ? 'Select a table before running' : undefined}
+ />
<LemonButton
icon={<IconSwapHoriz />}
size="small"
diff --git a/products/business_intelligence/manifest.tsx b/products/business_intelligence/manifest.tsx
new file mode 100644
index 000000000000..1911fdcb661f
--- /dev/null
+++ b/products/business_intelligence/manifest.tsx
@@ -0,0 +1,44 @@
+import { FEATURE_FLAGS } from 'lib/constants'
+import { urls } from 'scenes/urls'
+
+import { ProductItemCategory } from '~/queries/schema/schema-general'
+import { ProductManifest } from '~/types'
+
+export const manifest: ProductManifest = {
+ name: 'Business intelligence',
+ scenes: {
+ BusinessIntelligence: {
+ name: 'Business intelligence',
+ import: () => import('./frontend/BusinessIntelligenceScene'),
+ projectBased: true,
+ layout: 'app-raw-no-header',
+ hideProjectNotice: true,
+ description: 'Explore data and build charts with a visual worksheet.',
+ iconType: 'business_intelligence',
+ },
+ },
+ routes: {
+ '/bi': ['BusinessIntelligence', 'businessIntelligence'],
+ },
+ redirects: {},
+ urls: {
+ businessIntelligence: (): string => '/bi',
+ },
+ fileSystemTypes: {},
+ treeItemsNew: [],
+ treeItemsProducts: [
+ {
+ path: 'Business intelligence',
+ intents: [],
+ category: ProductItemCategory.DATA,
+ iconType: 'business_intelligence',
+ iconColor: [
+ 'var(--color-product-business-intelligence-light)',
+ 'var(--color-product-business-intelligence-dark)',
+ ],
+ href: urls.businessIntelligence(),
+ flag: FEATURE_FLAGS.SQL_EDITOR_BI_MODE,
+ sceneKey: 'BusinessIntelligence',
+ },
+ ],
+}
diff --git a/products/business_intelligence/package.json b/products/business_intelligence/package.json
new file mode 100644
index 000000000000..2ce4210ea662
--- /dev/null
+++ b/products/business_intelligence/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "@posthog/products-business-intelligence",
+ "private": true,
+ "dependencies": {
+ "kea": "catalog:",
+ "kea-loaders": "catalog:",
+ "kea-subscriptions": "catalog:",
+ "posthog-js": "catalog:"
+ },
+ "devDependencies": {
+ "kea-test-utils": "catalog:"
+ },
+ "peerDependencies": {
+ "@posthog/icons": "catalog:",
+ "@posthog/lemon-ui": "*",
+ "@types/react": "*",
+ "react": "*"
+ }
+}
diff --git a/products/business_intelligence/product.yaml b/products/business_intelligence/product.yaml
new file mode 100644
index 000000000000..674f87aa9319
--- /dev/null
+++ b/products/business_intelligence/product.yaml
@@ -0,0 +1,3 @@
+name: Business intelligence
+owners:
+ - team-data-tools
diff --git a/products/business_intelligence/tsconfig.json b/products/business_intelligence/tsconfig.json
new file mode 100644
index 000000000000..fe425d6fcba8
--- /dev/null
+++ b/products/business_intelligence/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "composite": true
+ }
+}
diff --git a/services/mcp/src/tools/links/app-url-manifest.json b/services/mcp/src/tools/links/app-url-manifest.json
index 952f08b20398..5de924d120b3 100644
--- a/services/mcp/src/tools/links/app-url-manifest.json
+++ b/services/mcp/src/tools/links/app-url-manifest.json
@@ -299,6 +299,11 @@
"params": [],
"scope": "project"
},
+ "businessIntelligence": {
+ "template": "/bi",
+ "params": [],
+ "scope": "project"
+ },
"businessKnowledge": {
"template": "/business-knowledge",
"params": [],
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json
index f4d784820165..40e83b3af93b 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/generate-app-url.json
@@ -13,7 +13,7 @@
"type": "object"
},
"url": {
- "description": "A path template copied verbatim from the catalog below (e.g. `/persons/{uuid}`). Its `{placeholders}` are filled from `params`. These slugs come from PostHog's canonical route table, so they are always correct — never pass a path that is not in this list.\n\n/account-connected/{kind}\n/account/credential-review\n/account/social-connected\n/activity-logs\n/activity/{tab}\n/agentic/account-mismatch\n/agentic/authorize\n/ai\n/ai-enrichment\n/ai-evals/datasets\n/ai-evals/datasets/{id}\n/ai-evals/evaluations\n/ai-evals/evaluations/offline/experiments\n/ai-evals/evaluations/offline/experiments/{experimentId}\n/ai-evals/evaluations/scorers\n/ai-evals/evaluations/scorers/{scorerId}\n/ai-evals/evaluations/scorers/{scorerId}/offline\n/ai-evals/evaluations/templates\n/ai-evals/evaluations/{id}\n/ai-evals/taggers\n/ai-evals/taggers/{id}\n/ai-gateway\n/ai-observability/clusters\n/ai-observability/clusters/{runId}/{clusterId}\n/ai-observability/dashboard\n/ai-observability/errors\n/ai-observability/generations\n/ai-observability/playground\n/ai-observability/reviews\n/ai-observability/self-driving\n/ai-observability/sentiment\n/ai-observability/sessions\n/ai-observability/sessions/{id}\n/ai-observability/tools\n/ai-observability/traces\n/ai-observability/traces/{id}\n/ai-observability/users\n/ai/history\n/alerts\n/approvals/{id}\n/autoresearch\n/autoresearch/new\n/autoresearch/{id}\n/billing/authorization_status\n/broadcasts\n/broadcasts/new\n/broadcasts/{id}\n/business-knowledge\n/business-knowledge/playground\n/business-knowledge/settings\n/business-knowledge/{id}\n/canvas\n/canvases\n/canvases/new\n/canvases/{id}\n/cli/authorize\n/cli/live\n/code-review\n/code/canvas/{channelId}/{dashboardId}\n/code/channel/{channelId}\n/code/loop/{loopId}\n/code/task/{taskId}\n/cohorts\n/cohorts/{id}\n/cohorts/{id}/calculation-history\n/connect/vercel/link\n/coupons/{campaign}\n/create-organization\n/cross-project-dashboards\n/cross-project-dashboards/{id}\n/customer_analytics\n/customer_analytics/accounts\n/customer_analytics/accounts/by-external-id/{externalId}\n/customer_analytics/accounts/{accountId}\n/customer_analytics/announcements\n/customer_analytics/configuration\n/customer_analytics/dashboard\n/customer_analytics/feature-requests\n/customer_analytics/feed\n/customer_analytics/journeys\n/customer_analytics/journeys/new\n/customer_analytics/journeys/templates\n/customer_analytics/journeys/{id}/edit\n/customer_analytics/notes\n/customer_analytics/tasks\n/dashboard\n/dashboard/templates/{templateId}/copy-to-project\n/dashboard/{id}\n/dashboard/{id}/sharing\n/dashboard/{id}/subscriptions\n/dashboard/{id}/subscriptions/{subscriptionId}\n/dashboard/{id}/tiles/{tileId}\n/data-catalog\n/data-catalog/metrics/{name}\n/data-management/actions\n/data-management/actions/new\n/data-management/actions/new/\n/data-management/actions/{id}\n/data-management/annotations\n/data-management/annotations/{id}\n/data-management/core-events\n/data-management/database\n/data-management/destinations\n/data-management/event-filtering\n/data-management/events\n/data-management/events/{id}\n/data-management/events/{id}/edit\n/data-management/history\n/data-management/ingestion-warnings\n/data-management/ingestion-warnings-v2\n/data-management/managed-viewsets\n/data-management/materialized-columns\n/data-management/properties\n/data-management/properties/{id}\n/data-management/properties/{id}/edit\n/data-management/revenue\n/data-management/schema\n/data-management/sources\n/data-management/sources/{id}/schemas\n/data-management/sources/{sourceId}/schemas/{schemaId}\n/data-management/transformations\n/data-management/variables\n/data-management/variables/{id}\n/data-management/variables/{id}/edit\n/data-management/warehouse-destinations\n/data-management/warehouse-properties\n/data-ops\n/data-warehouse/connect\n/data-warehouse/new-source\n/debug\n/debug/hog\n/debug/precompute\n/early_access_features\n/early_access_features/{id}\n/embedded/{token}\n/endpoints\n/endpoints/{name}\n/engineering-analytics/authors\n/engineering-analytics/authors/{handle}\n/engineering-analytics/deploys\n/engineering-analytics/overview\n/engineering-analytics/pull-requests\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/runs/{runId}\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/workflows/{workflowName}\n/engineering-analytics/repos/{repoOwner}/{repoName}/pull-requests/{number}\n/engineering-analytics/teams\n/engineering-analytics/teams/{ownerTeam}\n/engineering-analytics/tests\n/engineering-analytics/workflows\n/error_tracking\n/error_tracking/alerts/new/{templateId}\n/error_tracking/alerts/{id}\n/error_tracking/fingerprint/{fingerprint}\n/error_tracking/{id}\n/etl\n/events/{id}/{timestamp}\n/experiments\n/experiments/shared-metrics\n/experiments/shared-metrics/{id}\n/experiments/staff\n/experiments/{id}\n/exports\n/feature_flags\n/feature_flags/new\n/feature_flags/staff\n/feature_flags/staff/cohorts\n/feature_flags/templates\n/feature_flags/{id}\n/files\n/functions/new/{templateId}\n/functions/{id}\n/games/368hedgehogs\n/games/flappyhog\n/games/shipit\n/groups/{groupTypeIndex}\n/groups/{groupTypeIndex}/new\n/groups/{groupTypeIndex}/{groupKey}\n/health\n/health/alerts\n/health/pipeline-status\n/health/sdk-health\n/health/{category}\n/heatmaps\n/heatmaps/new\n/heatmaps/recording\n/heatmaps/{id}\n/home\n/identity-matching\n/inbox\n/inbox/reports/triage\n/inbox/scouts/findings\n/inbox/scouts/runs\n/inbox/scouts/scratchpad\n/inbox/scouts/{skillName}\n/inbox/{tab}/{reportId}\n/insights\n/insights/new\n/insights/quick-start\n/insights/{id}\n/insights/{id}/edit\n/insights/{id}/sharing\n/insights/{id}/subscriptions\n/insights/{id}/subscriptions/{subscriptionId}\n/insights/{insightShortId}/alerts\n/instance/async_migrations\n/instance/async_migrations/future\n/instance/async_migrations/settings\n/instance/dead_letter_queue\n/instance/kafka_inspector\n/instance/metrics\n/instance/settings\n/instance/staff_users\n/instance/status\n/integrations/stripe/confirm-install\n/integrations/vercel/link-error\n/integrations/{kind}/callback\n/integrations/{slug}\n/legal\n/legal/new/{type}\n/login\n/login/2fa\n/login/2fa_setup\n/logs\n/logs/alerts/{alertId}/notifications/{hogFunctionId}\n/logs/alerts/{id}\n/logs/drop-rules/new\n/logs/drop-rules/{id}\n/logs/retention-rules/new\n/logs/retention-rules/{id}\n/managed_migrations\n/managed_migrations/new\n/marketing\n/mcp-analytics\n/mcp-analytics/activity\n/mcp-analytics/dashboard\n/mcp-analytics/intent-clustering\n/mcp-analytics/missing-capabilities\n/mcp-analytics/notifications\n/mcp-analytics/sessions\n/mcp-analytics/tool-quality\n/mcp-analytics/tool-quality/{toolName}\n/mcp-registry\n/mcp-servers\n/mcp-servers/agent/{id}\n/mcp-servers/member/{id}\n/mcp-servers/server/{id}\n/mcp-servers/{tab}\n/metrics\n/models\n/models/{id}\n/move-to-cloud\n/my-tickets\n/notebooks\n/notebooks/widgets/{widgetId}\n/notebooks/{shortId}\n/oauth/authorize\n/onboarding\n/organization-deactivated\n/organization-pending-deletion\n/organization/billing\n/organization/billing/overview\n/organization/billing/real-time-usage\n/organization/confirm-creation\n/organization/create-project\n/person/{id}\n/persons\n/persons/{uuid}\n/pipeline/batch-exports/new/{service}\n/pipeline/batch-exports/{id}\n/pipeline/new/\n/pipeline/plugins/{id}\n/preflight\n/product_tours\n/product_tours/{id}\n/project-pending-deletion\n/prompt-management/prompts\n/prompt-management/prompts/{name}\n/pulse\n/replay-vision\n/replay-vision/new/template\n/replay-vision/observations/{observationId}\n/replay-vision/{id}/budget\n/replay-vision/{id}/configure\n/replay-vision/{id}/details\n/replay-vision/{id}/overview\n/replay-vision/{id}/self-driving\n/replay-vision/{id}/template\n/replay-vision/{id}/triggers\n/replay/file-playback\n/replay/home\n/replay/kiosk\n/replay/playlists/{id}\n/replay/settings\n/replay/{id}\n/reset\n/reset/{userUuid}/{token}\n/reset_2fa/{userUuid}/{token}\n/resource-transfer/{resourceKind}/{resourceId}\n/scout-trials\n/sessions/{id}\n/settings/environment-approvals\n/settings/organization-authentication/{feature}/{configId}\n/settings/project\n/settings/user-feature-previews\n/shared/{token}\n/shared_dashboard/{shareToken}\n/signup\n/signup/{id}\n/site/{url}\n/skills\n/skills/community\n/skills/{categoryTab}\n/skills/{name}\n/slack-task-context\n/spaces\n/spaces/new\n/spaces/{id}\n/spaces/{id}/canvases\n/spaces/{id}/new\n/spaces/{id}/settings\n/sql\n/stamphog\n/stamphog/digests\n/stamphog/install/callback\n/stamphog/runs\n/startups\n/streamlit-apps\n/streamlit-apps/new\n/streamlit-apps/{id}\n/streamlit-apps/{id}/edit\n/subscriptions\n/subscriptions/new\n/subscriptions/{id}\n/subscriptions/{id}/edit\n/support\n/support/settings\n/support/tickets\n/support/tickets/{ticketId}\n/surveys\n/surveys/form/new\n/surveys/guided/new\n/surveys/{id}\n/tasks\n/tasks/new\n/tasks/{taskId}\n/terminal\n/themes/custom-css\n/toolbar\n/tools\n/tracing\n/tracing/retention-rules/new\n/tracing/retention-rules/{id}\n/unsubscribe\n/verify_email\n/views\n/views/new\n/visual_review\n/visual_review/repos/{repoId}/flakiness\n/visual_review/repos/{repoId}/runs\n/visual_review/repos/{repoId}/snapshots\n/visual_review/repos/{repoId}/{runType}/snapshots/{identifier}\n/visual_review/runs/{runId}\n/visual_review/settings\n/web\n/web-scripts\n/web-scripts/new\n/web/agents\n/web/bots\n/web/content-autopilot\n/web/health\n/web/live\n/web/marketing\n/web/page-performance\n/web/page-reports\n/web/recap\n/web/session-attribution-explorer\n/web/web-vitals\n/wizard/runs\n/workflows\n/workflows/library/messages/{id}\n/workflows/library/templates/new\n/workflows/library/templates/{id}\n/workflows/new/workflow\n/workflows/{id}/{tab}",
+ "description": "A path template copied verbatim from the catalog below (e.g. `/persons/{uuid}`). Its `{placeholders}` are filled from `params`. These slugs come from PostHog's canonical route table, so they are always correct — never pass a path that is not in this list.\n\n/account-connected/{kind}\n/account/credential-review\n/account/social-connected\n/activity-logs\n/activity/{tab}\n/agentic/account-mismatch\n/agentic/authorize\n/ai\n/ai-enrichment\n/ai-evals/datasets\n/ai-evals/datasets/{id}\n/ai-evals/evaluations\n/ai-evals/evaluations/offline/experiments\n/ai-evals/evaluations/offline/experiments/{experimentId}\n/ai-evals/evaluations/scorers\n/ai-evals/evaluations/scorers/{scorerId}\n/ai-evals/evaluations/scorers/{scorerId}/offline\n/ai-evals/evaluations/templates\n/ai-evals/evaluations/{id}\n/ai-evals/taggers\n/ai-evals/taggers/{id}\n/ai-gateway\n/ai-observability/clusters\n/ai-observability/clusters/{runId}/{clusterId}\n/ai-observability/dashboard\n/ai-observability/errors\n/ai-observability/generations\n/ai-observability/playground\n/ai-observability/reviews\n/ai-observability/self-driving\n/ai-observability/sentiment\n/ai-observability/sessions\n/ai-observability/sessions/{id}\n/ai-observability/tools\n/ai-observability/traces\n/ai-observability/traces/{id}\n/ai-observability/users\n/ai/history\n/alerts\n/approvals/{id}\n/autoresearch\n/autoresearch/new\n/autoresearch/{id}\n/bi\n/billing/authorization_status\n/broadcasts\n/broadcasts/new\n/broadcasts/{id}\n/business-knowledge\n/business-knowledge/playground\n/business-knowledge/settings\n/business-knowledge/{id}\n/canvas\n/canvases\n/canvases/new\n/canvases/{id}\n/cli/authorize\n/cli/live\n/code-review\n/code/canvas/{channelId}/{dashboardId}\n/code/channel/{channelId}\n/code/loop/{loopId}\n/code/task/{taskId}\n/cohorts\n/cohorts/{id}\n/cohorts/{id}/calculation-history\n/connect/vercel/link\n/coupons/{campaign}\n/create-organization\n/cross-project-dashboards\n/cross-project-dashboards/{id}\n/customer_analytics\n/customer_analytics/accounts\n/customer_analytics/accounts/by-external-id/{externalId}\n/customer_analytics/accounts/{accountId}\n/customer_analytics/announcements\n/customer_analytics/configuration\n/customer_analytics/dashboard\n/customer_analytics/feature-requests\n/customer_analytics/feed\n/customer_analytics/journeys\n/customer_analytics/journeys/new\n/customer_analytics/journeys/templates\n/customer_analytics/journeys/{id}/edit\n/customer_analytics/notes\n/customer_analytics/tasks\n/dashboard\n/dashboard/templates/{templateId}/copy-to-project\n/dashboard/{id}\n/dashboard/{id}/sharing\n/dashboard/{id}/subscriptions\n/dashboard/{id}/subscriptions/{subscriptionId}\n/dashboard/{id}/tiles/{tileId}\n/data-catalog\n/data-catalog/metrics/{name}\n/data-management/actions\n/data-management/actions/new\n/data-management/actions/new/\n/data-management/actions/{id}\n/data-management/annotations\n/data-management/annotations/{id}\n/data-management/core-events\n/data-management/database\n/data-management/destinations\n/data-management/event-filtering\n/data-management/events\n/data-management/events/{id}\n/data-management/events/{id}/edit\n/data-management/history\n/data-management/ingestion-warnings\n/data-management/ingestion-warnings-v2\n/data-management/managed-viewsets\n/data-management/materialized-columns\n/data-management/properties\n/data-management/properties/{id}\n/data-management/properties/{id}/edit\n/data-management/revenue\n/data-management/schema\n/data-management/sources\n/data-management/sources/{id}/schemas\n/data-management/sources/{sourceId}/schemas/{schemaId}\n/data-management/transformations\n/data-management/variables\n/data-management/variables/{id}\n/data-management/variables/{id}/edit\n/data-management/warehouse-destinations\n/data-management/warehouse-properties\n/data-ops\n/data-warehouse/connect\n/data-warehouse/new-source\n/debug\n/debug/hog\n/debug/precompute\n/early_access_features\n/early_access_features/{id}\n/embedded/{token}\n/endpoints\n/endpoints/{name}\n/engineering-analytics/authors\n/engineering-analytics/authors/{handle}\n/engineering-analytics/deploys\n/engineering-analytics/overview\n/engineering-analytics/pull-requests\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/runs/{runId}\n/engineering-analytics/repos/{repoOwner}/{repoName}/actions/workflows/{workflowName}\n/engineering-analytics/repos/{repoOwner}/{repoName}/pull-requests/{number}\n/engineering-analytics/teams\n/engineering-analytics/teams/{ownerTeam}\n/engineering-analytics/tests\n/engineering-analytics/workflows\n/error_tracking\n/error_tracking/alerts/new/{templateId}\n/error_tracking/alerts/{id}\n/error_tracking/fingerprint/{fingerprint}\n/error_tracking/{id}\n/etl\n/events/{id}/{timestamp}\n/experiments\n/experiments/shared-metrics\n/experiments/shared-metrics/{id}\n/experiments/staff\n/experiments/{id}\n/exports\n/feature_flags\n/feature_flags/new\n/feature_flags/staff\n/feature_flags/staff/cohorts\n/feature_flags/templates\n/feature_flags/{id}\n/files\n/functions/new/{templateId}\n/functions/{id}\n/games/368hedgehogs\n/games/flappyhog\n/games/shipit\n/groups/{groupTypeIndex}\n/groups/{groupTypeIndex}/new\n/groups/{groupTypeIndex}/{groupKey}\n/health\n/health/alerts\n/health/pipeline-status\n/health/sdk-health\n/health/{category}\n/heatmaps\n/heatmaps/new\n/heatmaps/recording\n/heatmaps/{id}\n/home\n/identity-matching\n/inbox\n/inbox/reports/triage\n/inbox/scouts/findings\n/inbox/scouts/runs\n/inbox/scouts/scratchpad\n/inbox/scouts/{skillName}\n/inbox/{tab}/{reportId}\n/insights\n/insights/new\n/insights/quick-start\n/insights/{id}\n/insights/{id}/edit\n/insights/{id}/sharing\n/insights/{id}/subscriptions\n/insights/{id}/subscriptions/{subscriptionId}\n/insights/{insightShortId}/alerts\n/instance/async_migrations\n/instance/async_migrations/future\n/instance/async_migrations/settings\n/instance/dead_letter_queue\n/instance/kafka_inspector\n/instance/metrics\n/instance/settings\n/instance/staff_users\n/instance/status\n/integrations/stripe/confirm-install\n/integrations/vercel/link-error\n/integrations/{kind}/callback\n/integrations/{slug}\n/legal\n/legal/new/{type}\n/login\n/login/2fa\n/login/2fa_setup\n/logs\n/logs/alerts/{alertId}/notifications/{hogFunctionId}\n/logs/alerts/{id}\n/logs/drop-rules/new\n/logs/drop-rules/{id}\n/logs/retention-rules/new\n/logs/retention-rules/{id}\n/managed_migrations\n/managed_migrations/new\n/marketing\n/mcp-analytics\n/mcp-analytics/activity\n/mcp-analytics/dashboard\n/mcp-analytics/intent-clustering\n/mcp-analytics/missing-capabilities\n/mcp-analytics/notifications\n/mcp-analytics/sessions\n/mcp-analytics/tool-quality\n/mcp-analytics/tool-quality/{toolName}\n/mcp-registry\n/mcp-servers\n/mcp-servers/agent/{id}\n/mcp-servers/member/{id}\n/mcp-servers/server/{id}\n/mcp-servers/{tab}\n/metrics\n/models\n/models/{id}\n/move-to-cloud\n/my-tickets\n/notebooks\n/notebooks/widgets/{widgetId}\n/notebooks/{shortId}\n/oauth/authorize\n/onboarding\n/organization-deactivated\n/organization-pending-deletion\n/organization/billing\n/organization/billing/overview\n/organization/billing/real-time-usage\n/organization/confirm-creation\n/organization/create-project\n/person/{id}\n/persons\n/persons/{uuid}\n/pipeline/batch-exports/new/{service}\n/pipeline/batch-exports/{id}\n/pipeline/new/\n/pipeline/plugins/{id}\n/preflight\n/product_tours\n/product_tours/{id}\n/project-pending-deletion\n/prompt-management/prompts\n/prompt-management/prompts/{name}\n/pulse\n/replay-vision\n/replay-vision/new/template\n/replay-vision/observations/{observationId}\n/replay-vision/{id}/budget\n/replay-vision/{id}/configure\n/replay-vision/{id}/details\n/replay-vision/{id}/overview\n/replay-vision/{id}/self-driving\n/replay-vision/{id}/template\n/replay-vision/{id}/triggers\n/replay/file-playback\n/replay/home\n/replay/kiosk\n/replay/playlists/{id}\n/replay/settings\n/replay/{id}\n/reset\n/reset/{userUuid}/{token}\n/reset_2fa/{userUuid}/{token}\n/resource-transfer/{resourceKind}/{resourceId}\n/scout-trials\n/sessions/{id}\n/settings/environment-approvals\n/settings/organization-authentication/{feature}/{configId}\n/settings/project\n/settings/user-feature-previews\n/shared/{token}\n/shared_dashboard/{shareToken}\n/signup\n/signup/{id}\n/site/{url}\n/skills\n/skills/community\n/skills/{categoryTab}\n/skills/{name}\n/slack-task-context\n/spaces\n/spaces/new\n/spaces/{id}\n/spaces/{id}/canvases\n/spaces/{id}/new\n/spaces/{id}/settings\n/sql\n/stamphog\n/stamphog/digests\n/stamphog/install/callback\n/stamphog/runs\n/startups\n/streamlit-apps\n/streamlit-apps/new\n/streamlit-apps/{id}\n/streamlit-apps/{id}/edit\n/subscriptions\n/subscriptions/new\n/subscriptions/{id}\n/subscriptions/{id}/edit\n/support\n/support/settings\n/support/tickets\n/support/tickets/{ticketId}\n/surveys\n/surveys/form/new\n/surveys/guided/new\n/surveys/{id}\n/tasks\n/tasks/new\n/tasks/{taskId}\n/terminal\n/themes/custom-css\n/toolbar\n/tools\n/tracing\n/tracing/retention-rules/new\n/tracing/retention-rules/{id}\n/unsubscribe\n/verify_email\n/views\n/views/new\n/visual_review\n/visual_review/repos/{repoId}/flakiness\n/visual_review/repos/{repoId}/runs\n/visual_review/repos/{repoId}/snapshots\n/visual_review/repos/{repoId}/{runType}/snapshots/{identifier}\n/visual_review/runs/{runId}\n/visual_review/settings\n/web\n/web-scripts\n/web-scripts/new\n/web/agents\n/web/bots\n/web/content-autopilot\n/web/health\n/web/live\n/web/marketing\n/web/page-performance\n/web/page-reports\n/web/recap\n/web/session-attribution-explorer\n/web/web-vitals\n/wizard/runs\n/workflows\n/workflows/library/messages/{id}\n/workflows/library/templates/new\n/workflows/library/templates/{id}\n/workflows/new/workflow\n/workflows/{id}/{tab}",
"type": "string"
}
},