:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(sql-editor): capture an open of the database schema panel (#102369)
Sinan Kucukkoselerb2e9b41a2686
diff --git a/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx b/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsxindex 8c2f3fa6e495..2c220bc4dbe3 100644--- a/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx+++ b/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx@@ -1,6 +1,7 @@import { Monaco } from '@monaco-editor/react'import { useActions, useValues } from 'kea'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'@@ -25,6 +26,7 @@ import { Scene } from 'scenes/sceneTypes'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'import { SceneTitlePanelButton } from '~/layout/scenes/components/SceneTitleSection'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'+import { ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType } from '~/types'import { useAttachedContext, useMcpToolApplyBack } from 'products/posthog_ai/frontend/api/logics'@@ -50,6 +52,8 @@ interface QueryWindowProps {mode?: SQLEditorModeshowDatabaseTree: booleanonShowDatabaseTree: () => void+ /** Which product embeds this editor. Only used to attribute analytics events to a host. */+ hostProduct?: ProductKeyshowQueryPanel?: booleanshowOutputPanel?: booleanonRunQuery?: () => void@@ -73,6 +77,7 @@ export function QueryWindow({mode,showDatabaseTree,onShowDatabaseTree,+ hostProduct,showQueryPanel = true,showOutputPanel = true,onRunQuery,@@ -269,6 +274,8 @@ export function QueryWindow({<ExpandDatabaseTreeButtonshowDatabaseTree={showDatabaseTree}onShowDatabaseTree={onShowDatabaseTree}+ mode={mode}+ hostProduct={hostProduct}/>{mode === SQLEditorMode.FullScene && biModeFeatureEnabled ? (<LemonSegmentedButton@@ -419,9 +426,13 @@ export function QueryWindow({function ExpandDatabaseTreeButton({showDatabaseTree,onShowDatabaseTree,+ mode,+ hostProduct,}: {showDatabaseTree: booleanonShowDatabaseTree: () => void+ mode?: SQLEditorMode+ hostProduct?: ProductKey}): JSX.Element | null {const { isDatabaseTreeCollapsed } = useValues(editorSizingLogic)const { toggleDatabaseTreeCollapsed } = useActions(editorSizingLogic)@@ -437,6 +448,14 @@ function ExpandDatabaseTreeButton({size="small"tooltip="Expand database schema panel"onClick={() => {+ // This button only ever opens the panel, because it renders nothing once the panel+ // is open and expanded. So every click is one open, and no close is counted here.+ posthog.capture('sql-editor-schema-panel-opened', {+ mode: mode ?? SQLEditorMode.FullScene,+ host_product: hostProduct ?? null,+ // False when the panel was open before and the user collapsed it by dragging.+ is_first_open: !showDatabaseTree,+ })if (!showDatabaseTree) {onShowDatabaseTree()returndiff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsxindex 9424dfd154a9..07150cccb66b 100644--- a/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsx+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditor.tsx@@ -32,6 +32,7 @@ import {} from '~/queries/nodes/DataVisualization/dataVisualizationLogic'import { displayLogic } from '~/queries/nodes/DataVisualization/displayLogic'import { applyDataVisualizationQueryUpdate } from '~/queries/nodes/DataVisualization/queryUpdateUtils'+import { ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType } from '~/types'import { MaterializationLoading } from 'products/data_warehouse/frontend/shared/components/MaterializationLoading'@@ -70,6 +71,8 @@ interface SQLEditorProps {defaultShowDatabaseTree?: boolean/** Extra top-level sections for the database tree, owned by the embedder — see QueryDatabase. */extraTreeSections?: TreeDataItem[]+ /** Which product embeds this editor. Only used to attribute analytics events to a host. */+ hostProduct?: ProductKeypanel?: SQLEditorPanelshowOutputToolbar?: booleanonRunQuery?: () => void@@ -95,6 +98,7 @@ export function SQLEditor({showDatabaseTree,defaultShowDatabaseTree = true,extraTreeSections,+ hostProduct,panel = SQLEditorPanel.Full,showOutputToolbar = true,onRunQuery,@@ -298,6 +302,7 @@ export function SQLEditor({tabId={tabId || ''}showDatabaseTree={showDatabaseTreePanel}onShowDatabaseTree={() => setHasShownDatabaseTree(true)}+ hostProduct={hostProduct}showQueryPanel={showQueryPanel}showOutputPanel={showOutputPanel}onSetMonacoAndEditor={(nextMonaco, nextEditor) =>diff --git a/frontend/src/scenes/notebooks/Nodes/components/NotebookSQLEditor.tsx b/frontend/src/scenes/notebooks/Nodes/components/NotebookSQLEditor.tsxindex 52258936e2ad..43e2f7b6b71e 100644--- a/frontend/src/scenes/notebooks/Nodes/components/NotebookSQLEditor.tsx+++ b/frontend/src/scenes/notebooks/Nodes/components/NotebookSQLEditor.tsx@@ -504,6 +504,7 @@ export function NotebookSQLEditorSettings<T extends { query: QuerySchema }>({mode={SQLEditorMode.Embedded}panel={SQLEditorPanel.Query}defaultShowDatabaseTree={false}+ hostProduct={ProductKey.NOTEBOOKS}queryPaneDefaultHeight={EMBEDDED_SQL_EDITOR_EDIT_DEFAULT_HEIGHT}queryPaneMinHeight={EMBEDDED_SQL_EDITOR_QUERY_PANE_MIN_HEIGHT}autoFocusQueryPane={autoFocusQueryPane}@@ -571,6 +572,7 @@ export function NotebookCodeSQLEditorSettings<T extends { code: string } & Notebpanel={SQLEditorPanel.Query}defaultShowDatabaseTree={false}extraTreeSections={extraTreeSections}+ hostProduct={ProductKey.NOTEBOOKS}autoFocusQueryPane={autoFocusQueryPane}// Read the editor's current text and connection imperatively at run time. The// Cmd+Enter keybinding fires a stale closure (and Monaco's keybinding value can come