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(data-warehouse): add Warehouse properties scene to the Data menu (#80465)

Tom Owers5c1439dd9170
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f54ed0dfe51a..a2891d03ac47 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5678,6 +5678,14 @@ snapshots:
hash: v1.k794b7964.6b964cf605487984882e7cbcfcdeb70145d5c82b515548f13c26b9cfc7c48774.Hv4r6gCj6NHtIdIcpwTfjWxoTR0WicAcnKFT5QzJ1mA
scenes-app-data-management--ingestion-warnings--light:
hash: v1.k794b7964.3209e00fefa6b56227f01db9fe3f231e0bef672e4fbae05757144510e79094f1.hzeCCQksEIyxI52va51UNvenmIlxwKNAFf21tLkD_MI
+ scenes-app-data-management--warehouse-properties--dark:
+ hash: v1.k794b7964.665922080691f05ad35d117c89b0eb715ad678a707cb278892eb627eb2ff62c2.ESs6rHGY5A-Ss_ssl5SyF7uc98sfu2wZij4pmR6la18
+ scenes-app-data-management--warehouse-properties--light:
+ hash: v1.k794b7964.cbb43b5ac8dd2d367d44359ebfc3153294dfdb618b7663a5202d9fbfd14d77e6.3zG1301UKdyuoQRz9vTIjlLTTs8LygETMtOTsDK5UqA
+ scenes-app-data-management--warehouse-properties-groups-tab--dark:
+ hash: v1.k794b7964.e7a956ea10bc12b0665dacf6f77e06007c5c881e6af54e6253010a378d216f29.DG8_wQnqLMr-LisByo39mZnjiMBs5r22TzkUYIWBGhc
+ scenes-app-data-management--warehouse-properties-groups-tab--light:
+ hash: v1.k794b7964.64bfec93b16ecc0852691d8f407d19f27b5c3c07b3292ef7fe3eddf57e23c56d.pRBZME1SPf0vemOSwV41eu3dIa91C2E6c5r1imkukTI
scenes-app-data-management-actions--action--dark:
hash: v1.k794b7964.00b57c65346e514c9454e88054c04eb8aef6f1093d64fdc46cbbef3604e7f2d6.89yiroC6COFhV4T8jtCoYYdBQat6ZW24vyN_AW3GRTI
scenes-app-data-management-actions--action--light:
diff --git a/frontend/src/productScenes.tsx b/frontend/src/productScenes.tsx
index 18c18b455f67..e32eaff4dcaf 100644
--- a/frontend/src/productScenes.tsx
+++ b/frontend/src/productScenes.tsx
@@ -52,6 +52,8 @@ export const productScenes: Record<string, () => Promise<any>> = {
import('../../products/customer_analytics/frontend/scenes/CustomerJourneyBuilderScene/CustomerJourneyBuilderScene'),
CustomerJourneyTemplates: () =>
import('../../products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/CustomerJourneyTemplatesScene'),
+ WarehouseProperties: () =>
+ import('../../products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene'),
DataCatalog: () => import('../../products/data_catalog/frontend/DataCatalogScene'),
DataCatalogMetric: () => import('../../products/data_catalog/frontend/DataCatalogMetricScene'),
DataOps: () => import('../../products/data_warehouse/DataWarehouseScene'),
diff --git a/frontend/src/products.json b/frontend/src/products.json
index fee86c683bfd..7e4c131f055c 100644
--- a/frontend/src/products.json
+++ b/frontend/src/products.json
@@ -312,6 +312,13 @@
"intents": []
},
{ "path": "Core events", "category": "Schema", "iconType": null, "type": null, "intents": [] },
+ {
+ "path": "Warehouse properties",
+ "category": "Schema",
+ "iconType": "data_warehouse",
+ "type": null,
+ "intents": []
+ },
{
"path": "Sources",
"category": "Pipeline",
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index f5b8c1ba8c32..ecde07643c69 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -33,6 +33,7 @@ import { ActivityScope } from '~/types'
import { AlertType } from 'products/alerts/frontend/types'
import { AI_OBSERVABILITY_CLUSTER_URL_PATTERN } from '../../products/ai_observability/frontend/clusters/constants'
+import type { WarehousePropertiesSceneTab } from '../../products/customer_analytics/frontend/scenes/WarehousePropertiesScene/warehousePropertiesSceneLogic'
import type {
SchemaConfigurationSection,
SchemaSceneTab,
@@ -111,6 +112,8 @@ export const productRoutes: Record<string, [string, string]> = {
'/customer_analytics/journeys/:id/edit': ['CustomerJourneyBuilder', 'customerJourneyEdit'],
'/customer_analytics/journeys': ['CustomerAnalytics', 'customerAnalyticsJourneys'],
'/customer_analytics/configuration': ['CustomerAnalyticsConfiguration', 'customerAnalyticsConfiguration'],
+ '/data-management/warehouse-properties': ['WarehouseProperties', 'warehouseProperties'],
+ '/data-management/warehouse-properties/:tab': ['WarehouseProperties', 'warehouseProperties'],
'/data-catalog': ['DataCatalog', 'dataCatalog'],
'/data-catalog/metrics/:name': ['DataCatalogMetric', 'dataCatalogMetric'],
'/data-ops': ['DataOps', 'dataOps'],
@@ -560,6 +563,12 @@ export const productConfiguration: Record<string, any> = {
CustomerAnalyticsConfiguration: { projectBased: true, name: 'Customer analytics configuration' },
CustomerJourneyBuilder: { projectBased: true, name: 'New journey' },
CustomerJourneyTemplates: { projectBased: true, name: 'New journey' },
+ WarehouseProperties: {
+ projectBased: true,
+ name: 'Warehouse properties',
+ description: 'Add properties to your people and groups from a data warehouse table.',
+ iconType: 'data_warehouse',
+ },
DataCatalog: {
projectBased: true,
name: 'Data catalog',
@@ -1048,6 +1057,8 @@ export const productUrls = {
customerJourneyBuilder: (): string => '/customer_analytics/journeys/new',
customerJourneyTemplates: (): string => '/customer_analytics/journeys/templates',
customerJourneyEdit: (id: string): string => `/customer_analytics/journeys/${id}/edit`,
+ warehouseProperties: (tab?: WarehousePropertiesSceneTab): string =>
+ `/data-management/warehouse-properties${tab ? `/${tab}` : ''}`,
dashboards: (): string => '/dashboard',
dashboard: (id: string | number, highlightInsightId?: string): string =>
combineUrl(`/dashboard/${id}`, highlightInsightId ? { highlightInsightId } : {}).url,
@@ -2679,4 +2690,13 @@ export const getTreeItemsMetadata = (): FileSystemImport[] => [
sceneKey: 'Transformations',
sceneKeys: ['Transformations'],
},
+ {
+ path: 'Warehouse properties',
+ category: 'Schema',
+ iconType: 'data_warehouse',
+ href: urls.warehouseProperties(),
+ flag: FEATURE_FLAGS.WAREHOUSE_PERSON_PROPERTIES,
+ sceneKey: 'WarehouseProperties',
+ sceneKeys: ['WarehouseProperties'],
+ },
]
diff --git a/frontend/src/scenes/sceneTypes.ts b/frontend/src/scenes/sceneTypes.ts
index 38f5239a9b1f..cd77e2161d09 100644
--- a/frontend/src/scenes/sceneTypes.ts
+++ b/frontend/src/scenes/sceneTypes.ts
@@ -192,6 +192,7 @@ export enum Scene {
VercelConnect = 'VercelConnect',
VercelLinkError = 'VercelLinkError',
VerifyEmail = 'VerifyEmail',
+ WarehouseProperties = 'WarehouseProperties',
WebAnalytics = 'WebAnalytics',
WebAnalyticsPageReports = 'WebAnalyticsPageReports',
WebAnalyticsWebVitals = 'WebAnalyticsWebVitals',
diff --git a/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.stories.tsx b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.stories.tsx
new file mode 100644
index 000000000000..2d3a64a970bb
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.stories.tsx
@@ -0,0 +1,154 @@
+import { MOCK_DEFAULT_ORGANIZATION, MOCK_DEFAULT_USER } from 'lib/api.mock'
+
+import { Meta, StoryObj } from '@storybook/react'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { App } from 'scenes/App'
+import { urls } from 'scenes/urls'
+
+import { mswDecorator } from '~/mocks/browser'
+import { AvailableFeature } from '~/types'
+
+import type { CustomPropertyDefinitionApi } from '../../generated/api.schemas'
+
+// The Groups tab only renders when group analytics is available, so the story has to grant it.
+const userWithGroupAnalytics = {
+ ...MOCK_DEFAULT_USER,
+ organization: {
+ ...MOCK_DEFAULT_ORGANIZATION,
+ available_product_features: [{ key: AvailableFeature.GROUP_ANALYTICS, name: 'Group analytics' }],
+ },
+}
+
+const definitions: CustomPropertyDefinitionApi[] = [
+ {
+ id: '01890000-0000-0000-0000-000000000001',
+ name: 'Billing profile',
+ display_type: 'text',
+ target_type: 'person',
+ is_canonical: false,
+ created_at: '2023-02-01T10:00:00Z',
+ created_by: null,
+ updated_at: null,
+ references: [],
+ source: {
+ id: '01890000-0000-0000-0000-0000000000a1',
+ definition: '01890000-0000-0000-0000-000000000001',
+ external_data_schema: '01890000-0000-0000-0000-0000000000f1',
+ key_column: 'user_email',
+ column_property_map: { plan_name: 'billing_plan', mrr_cents: 'billing_mrr' },
+ is_enabled: true,
+ consecutive_failures: 0,
+ last_synced_at: '2023-02-15T14:30:00Z',
+ last_sync_error: null,
+ created_at: '2023-02-01T10:00:00Z',
+ created_by: null,
+ updated_at: null,
+ sync_frequency_interval_seconds: 86400,
+ next_sync_at: '2023-02-16T14:30:00Z',
+ latest_run: {
+ id: '01890000-0000-0000-0000-0000000000b1',
+ trigger: 'scheduled',
+ status: 'completed',
+ started_at: '2023-02-15T14:29:00Z',
+ finished_at: '2023-02-15T14:30:00Z',
+ rows_read: 4210,
+ changed: 118,
+ existing: 112,
+ produced: 112,
+ skipped_missing_person: 6,
+ error: null,
+ created_at: '2023-02-15T14:29:00Z',
+ },
+ },
+ },
+ {
+ id: '01890000-0000-0000-0000-000000000002',
+ name: 'Support tier',
+ display_type: 'text',
+ target_type: 'person',
+ is_canonical: false,
+ created_at: '2023-02-10T09:00:00Z',
+ created_by: null,
+ updated_at: null,
+ references: [],
+ source: {
+ id: '01890000-0000-0000-0000-0000000000a2',
+ definition: '01890000-0000-0000-0000-000000000002',
+ external_data_schema: '01890000-0000-0000-0000-0000000000f2',
+ key_column: 'distinct_id',
+ column_property_map: { tier: 'support_tier' },
+ is_enabled: true,
+ consecutive_failures: 1,
+ last_synced_at: '2023-02-14T08:00:00Z',
+ last_sync_error: 'Column "tier" is missing from the warehouse table.',
+ created_at: '2023-02-10T09:00:00Z',
+ created_by: null,
+ updated_at: null,
+ sync_frequency_interval_seconds: 86400,
+ next_sync_at: '2023-02-15T08:00:00Z',
+ latest_run: null,
+ },
+ },
+ {
+ id: '01890000-0000-0000-0000-000000000003',
+ name: 'Account revenue',
+ display_type: 'currency',
+ target_type: 'group',
+ group_type_index: 0,
+ is_canonical: false,
+ created_at: '2023-02-12T09:00:00Z',
+ created_by: null,
+ updated_at: null,
+ references: [],
+ source: {
+ id: '01890000-0000-0000-0000-0000000000a3',
+ definition: '01890000-0000-0000-0000-000000000003',
+ external_data_schema: '01890000-0000-0000-0000-0000000000f3',
+ key_column: 'account_id',
+ column_property_map: { arr_cents: 'account_arr' },
+ is_enabled: true,
+ consecutive_failures: 0,
+ last_synced_at: null,
+ last_sync_error: null,
+ created_at: '2023-02-12T09:00:00Z',
+ created_by: null,
+ updated_at: null,
+ sync_frequency_interval_seconds: 86400,
+ next_sync_at: null,
+ latest_run: null,
+ },
+ },
+]
+
+const meta: Meta = {
+ component: App,
+ title: 'Scenes-App/Data Management',
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ mockDate: '2023-02-15',
+ pageUrl: urls.warehouseProperties(),
+ featureFlags: [FEATURE_FLAGS.WAREHOUSE_PERSON_PROPERTIES],
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/custom_property_definitions/': () => [
+ 200,
+ { count: definitions.length, next: null, previous: null, results: definitions },
+ ],
+ '/api/users/@me/': () => [200, userWithGroupAnalytics],
+ },
+ }),
+ ],
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+export const WarehouseProperties: Story = {}
+
+export const WarehousePropertiesGroupsTab: Story = {
+ parameters: { pageUrl: urls.warehouseProperties('groups') },
+}
diff --git a/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.tsx b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.tsx
new file mode 100644
index 000000000000..3eb2b70cdacd
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.tsx
@@ -0,0 +1,62 @@
+import { useActions, useValues } from 'kea'
+
+import { NotFound } from 'lib/components/NotFound'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { groupsAccessLogic } from 'lib/introductions/groupsAccessLogic'
+import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { SceneExport } from 'scenes/sceneTypes'
+
+import { SceneContent } from '~/layout/scenes/components/SceneContent'
+import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+
+import {
+ WarehouseGroupPropertiesSetting,
+ WarehousePersonPropertiesSetting,
+} from '../CustomerAnalyticsConfigurationScene/account/WarehousePersonPropertiesSetting'
+import { WarehousePropertiesSceneTab, warehousePropertiesSceneLogic } from './warehousePropertiesSceneLogic'
+
+export const scene: SceneExport = {
+ component: WarehousePropertiesScene,
+ logic: warehousePropertiesSceneLogic,
+}
+
+export function WarehousePropertiesScene(): JSX.Element {
+ const { featureFlags } = useValues(featureFlagLogic)
+ const { groupsEnabled } = useValues(groupsAccessLogic)
+ const { currentTab } = useValues(warehousePropertiesSceneLogic)
+ const { setCurrentTab } = useActions(warehousePropertiesSceneLogic)
+
+ if (!featureFlags[FEATURE_FLAGS.WAREHOUSE_PERSON_PROPERTIES]) {
+ return <NotFound object="page" caption="Warehouse properties isn't available for this project yet." />
+ }
+
+ const tabs: LemonTab<WarehousePropertiesSceneTab>[] = [
+ {
+ label: 'Persons',
+ key: 'persons',
+ content: <WarehousePersonPropertiesSetting />,
+ },
+ ]
+
+ // Groups need the paid feature and at least one group type, so hide the tab rather than show a
+ // table nothing can be added to.
+ if (groupsEnabled) {
+ tabs.push({
+ label: 'Groups',
+ key: 'groups',
+ content: <WarehouseGroupPropertiesSetting />,
+ })
+ }
+
+ return (
+ <SceneContent>
+ <SceneTitleSection
+ name="Warehouse properties"
+ description="Add properties to your people and groups from a data warehouse table. Each row is matched by a key column, then the mapped columns stay up to date on every sync."
+ resourceType={{ type: 'data_warehouse' }}
+ />
+ <LemonTabs activeKey={currentTab} onChange={setCurrentTab} tabs={tabs} sceneInset />
+ </SceneContent>
+ )
+}
diff --git a/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/warehousePropertiesSceneLogic.ts b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/warehousePropertiesSceneLogic.ts
new file mode 100644
index 000000000000..e70e0d7c395b
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/warehousePropertiesSceneLogic.ts
@@ -0,0 +1,62 @@
+import { MakeLogicType, actions, kea, path, reducers } from 'kea'
+import { actionToUrl, urlToAction } from 'kea-router'
+
+import { urls } from 'scenes/urls'
+
+export const WAREHOUSE_PROPERTIES_SCENE_TABS = ['persons', 'groups'] as const
+export type WarehousePropertiesSceneTab = (typeof WAREHOUSE_PROPERTIES_SCENE_TABS)[number]
+export const DEFAULT_WAREHOUSE_PROPERTIES_SCENE_TAB: WarehousePropertiesSceneTab = 'persons'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface warehousePropertiesSceneLogicValues {
+ currentTab: WarehousePropertiesSceneTab
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface warehousePropertiesSceneLogicActions {
+ _setCurrentTab: (tab: WarehousePropertiesSceneTab) => {
+ tab: 'groups' | 'persons'
+ }
+ setCurrentTab: (tab: WarehousePropertiesSceneTab) => {
+ tab: 'groups' | 'persons'
+ }
+}
+
+export type warehousePropertiesSceneLogicType = MakeLogicType<
+ warehousePropertiesSceneLogicValues,
+ warehousePropertiesSceneLogicActions
+>
+
+export const warehousePropertiesSceneLogic = kea<warehousePropertiesSceneLogicType>([
+ path(['products', 'customer_analytics', 'scenes', 'WarehousePropertiesScene', 'warehousePropertiesSceneLogic']),
+ actions({
+ setCurrentTab: (tab: WarehousePropertiesSceneTab) => ({ tab }),
+ // Mirrors setCurrentTab without writing back to the URL, so urlToAction can't loop.
+ _setCurrentTab: (tab: WarehousePropertiesSceneTab) => ({ tab }),
+ }),
+ reducers({
+ currentTab: [
+ DEFAULT_WAREHOUSE_PROPERTIES_SCENE_TAB as WarehousePropertiesSceneTab,
+ {
+ setCurrentTab: (_, { tab }) => tab,
+ _setCurrentTab: (_, { tab }) => tab,
+ },
+ ],
+ }),
+ actionToUrl(() => ({
+ setCurrentTab: ({ tab }) =>
+ urls.warehouseProperties(tab === DEFAULT_WAREHOUSE_PROPERTIES_SCENE_TAB ? undefined : tab),
+ })),
+ urlToAction(({ actions, values }) => ({
+ [urls.warehouseProperties()]: () => {
+ if (values.currentTab !== DEFAULT_WAREHOUSE_PROPERTIES_SCENE_TAB) {
+ actions._setCurrentTab(DEFAULT_WAREHOUSE_PROPERTIES_SCENE_TAB)
+ }
+ },
+ [urls.warehouseProperties('groups')]: () => {
+ if (values.currentTab !== 'groups') {
+ actions._setCurrentTab('groups')
+ }
+ },
+ })),
+])
diff --git a/products/customer_analytics/manifest.tsx b/products/customer_analytics/manifest.tsx
index 79c9e28ee2d6..a93ed22c796e 100644
--- a/products/customer_analytics/manifest.tsx
+++ b/products/customer_analytics/manifest.tsx
@@ -7,6 +7,8 @@ import { urls } from 'scenes/urls'
import { ProductItemCategory, ProductKey } from '~/queries/schema/schema-general'
import { ProductManifest } from '~/types'
+import type { WarehousePropertiesSceneTab } from './frontend/scenes/WarehousePropertiesScene/warehousePropertiesSceneLogic'
+
export const manifest: ProductManifest = {
name: 'Customer analytics',
scenes: {
@@ -33,6 +35,13 @@ export const manifest: ProductManifest = {
projectBased: true,
name: 'New journey',
},
+ WarehouseProperties: {
+ import: () => import('./frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene'),
+ projectBased: true,
+ name: 'Warehouse properties',
+ description: 'Add properties to your people and groups from a data warehouse table.',
+ iconType: 'data_warehouse',
+ },
},
routes: {
'/customer_analytics/dashboard': ['CustomerAnalytics', 'customerAnalyticsDashboard'],
@@ -49,6 +58,8 @@ export const manifest: ProductManifest = {
'/customer_analytics/journeys/:id/edit': ['CustomerJourneyBuilder', 'customerJourneyEdit'],
'/customer_analytics/journeys': ['CustomerAnalytics', 'customerAnalyticsJourneys'],
'/customer_analytics/configuration': ['CustomerAnalyticsConfiguration', 'customerAnalyticsConfiguration'],
+ '/data-management/warehouse-properties': ['WarehouseProperties', 'warehouseProperties'],
+ '/data-management/warehouse-properties/:tab': ['WarehouseProperties', 'warehouseProperties'],
},
redirects: {
'/customer_analytics': (_params, searchParams, hashParams) => {
@@ -74,6 +85,8 @@ export const manifest: ProductManifest = {
customerJourneyBuilder: (): string => '/customer_analytics/journeys/new',
customerJourneyTemplates: (): string => '/customer_analytics/journeys/templates',
customerJourneyEdit: (id: string): string => `/customer_analytics/journeys/${id}/edit`,
+ warehouseProperties: (tab?: WarehousePropertiesSceneTab): string =>
+ `/data-management/warehouse-properties${tab ? `/${tab}` : ''}`,
},
treeItemsProducts: [
{
@@ -88,4 +101,17 @@ export const manifest: ProductManifest = {
sceneKeys: ['CustomerAnalytics', 'CustomerJourneyTemplates', 'CustomerJourneyBuilder'],
},
],
+ // Deliberately not behind the Customer analytics flag: warehouse-backed person and group
+ // properties are useful without opting into Customer analytics, so this is their home in Data.
+ treeItemsMetadata: [
+ {
+ path: 'Warehouse properties',
+ category: 'Schema',
+ iconType: 'data_warehouse',
+ href: urls.warehouseProperties(),
+ flag: FEATURE_FLAGS.WAREHOUSE_PERSON_PROPERTIES,
+ sceneKey: 'WarehouseProperties',
+ sceneKeys: ['WarehouseProperties'],
+ },
+ ],
}