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.

fix(data-warehouse): make self-managed sources findable in the catalog (#110675)

Tom Owers45a06cef4175
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx b/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx
index db5c4e8ea908..58927211b90f 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx
@@ -152,6 +152,7 @@ export function SourceCatalog({ allowedSources }: SourceCatalogProps): JSX.Eleme
categoriesWithCounts,
search,
selectedCategory,
+ selectedCategoryLabel,
hasCrossCategoryMatches,
registeredInterestSources,
sourceRequestModalOpen,
@@ -212,7 +213,7 @@ export function SourceCatalog({ allowedSources }: SourceCatalogProps): JSX.Eleme
<div className="flex flex-col gap-1">
{hasCrossCategoryMatches ? (
<div className="text-muted text-sm">
- No sources match "{search.trim()}" in {selectedCategory}.{' '}
+ No sources match "{search.trim()}" in {selectedCategoryLabel}.{' '}
<Link onClick={() => setSelectedCategory('all')}>Search all categories</Link> or request
one below.
</div>
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
index 5e9d8387210b..f11a66c93b6d 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
@@ -1,5 +1,6 @@
import FuseClass from 'fuse.js'
import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, props, reducers, selectors } from 'kea'
+import { urlToAction } from 'kea-router'
import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
@@ -32,15 +33,18 @@ import {
fileUploadSourceType,
fileUploadSourceUrl,
} from './fileUploadSource'
+import {
+ ALL_SOURCES_CATEGORY,
+ CATEGORY_SEARCH_PARAM,
+ SELF_MANAGED_CATEGORY,
+ SourceCategoryFilter,
+ isSourceCategoryFilter,
+} from './sourceCategories'
import { sourceWizardLogic } from './sourceWizardLogic'
// Helps kea-typegen reference the Fuse type without a bad `import { Fuse } from 'fuse.js'`.
export interface Fuse extends FuseClass<CatalogItem> {}
-export type SourceCategoryFilter = DataWarehouseSourceCategoryApi | 'all'
-
-export const ALL_SOURCES_CATEGORY = 'all'
-
// Self-managed (S3/GCS/Azure/R2) connectors don't flow through SourceConfigResponseApi, so place
// them in a sensible catalog bucket explicitly.
const MANUAL_SOURCE_CATEGORY: DataWarehouseSourceCategoryApi = 'File storage'
@@ -65,6 +69,19 @@ const DATABASE_CATEGORY_KEYWORDS = ['warehouse', 'data warehouse', 'dwh']
// them to request a source we already support. Matches the formats the link form accepts.
const FILE_STORAGE_FORMAT_KEYWORDS = ['csv', 'parquet', 'delta', 'file', 'files', 'flat file']
+// "Self-managed data warehouse sources" is the name the sources list gives these, but no connector
+// carries the phrase in its label or keywords, so searching the catalog for the name we taught the
+// user found nothing at all.
+const SELF_MANAGED_KEYWORDS = [
+ 'self-managed',
+ 'self managed',
+ 'selfmanaged',
+ 'bring your own',
+ 'byo',
+ 'own bucket',
+ 'own storage',
+]
+
// "Request a data warehouse source" survey. We render our own modal and submit the answer
// directly as a `survey sent` event rather than using the posthog-js survey popover.
export const SOURCE_REQUEST_SURVEY_ID = '0190ff15-5032-0000-722a-e13933c140ac'
@@ -131,6 +148,7 @@ export interface sourceCatalogLogicValues {
registeredInterestSources: string[]
search: string
selectedCategory: SourceCategoryFilter
+ selectedCategoryLabel: string
sourceRequestModalOpen: boolean
sourceRequestText: string
}
@@ -180,6 +198,10 @@ export interface sourceCatalogLogicMeta {
arg: ExternalDataSourceTypeEnumApi[] | undefined
) => CatalogItem[]
categoriesWithCounts: (catalogItems: CatalogItem[]) => CatalogCategory[]
+ selectedCategoryLabel: (
+ categoriesWithCounts: CatalogCategory[],
+ selectedCategory: SourceCategoryFilter
+ ) => string
catalogFuse: (catalogItems: CatalogItem[]) => Fuse
filteredItems: (
catalogItems: CatalogItem[],
@@ -221,6 +243,18 @@ function searchCatalog(catalogFuse: Fuse, term: string): CatalogItem[] {
return [...matchCounts.keys()].sort((a, b) => (matchCounts.get(b) ?? 0) - (matchCounts.get(a) ?? 0))
}
+// `self-managed` filters on the connection model rather than on `item.category`, so every place
+// that narrows the catalog to a category has to ask through here.
+function matchesCategory(item: CatalogItem, category: SourceCategoryFilter): boolean {
+ if (category === ALL_SOURCES_CATEGORY) {
+ return true
+ }
+ if (category === SELF_MANAGED_CATEGORY) {
+ return !!item.selfManaged
+ }
+ return item.category === category
+}
+
export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
path(['products', 'dataWarehouse', 'sourceCatalogLogic']),
props({} as SourceCatalogLogicProps),
@@ -354,7 +388,11 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
label: source.name,
iconType: source.type,
category: MANUAL_SOURCE_CATEGORY,
- keywords: [...(MANUAL_SOURCE_KEYWORDS[source.type] ?? []), ...FILE_STORAGE_FORMAT_KEYWORDS],
+ keywords: [
+ ...(MANUAL_SOURCE_KEYWORDS[source.type] ?? []),
+ ...FILE_STORAGE_FORMAT_KEYWORDS,
+ ...SELF_MANAGED_KEYWORDS,
+ ],
status: 'stable',
url: urls.dataWarehouseSourceNew(source.type),
selfManaged: true,
@@ -370,7 +408,7 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
label,
iconType: FILE_UPLOAD_SOURCE_NAME,
category: MANUAL_SOURCE_CATEGORY,
- keywords,
+ keywords: [...keywords, ...SELF_MANAGED_KEYWORDS],
status: 'stable',
releaseStatus: FILE_UPLOAD_SOURCE_CONFIG.releaseStatus,
url: fileUploadSourceUrl(format),
@@ -409,13 +447,31 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
)
// Most-populated categories first; fall back to taxonomy order on a tie.
.sort((a, b) => b.count - a.count)
+ const selfManagedCount = catalogItems.filter((item) => item.selfManaged).length
return [
{ category: ALL_SOURCES_CATEGORY, label: 'All sources', count: catalogItems.length },
+ ...(selfManagedCount
+ ? [
+ {
+ category: SELF_MANAGED_CATEGORY as SourceCategoryFilter,
+ label: 'Self-managed',
+ count: selfManagedCount,
+ },
+ ]
+ : []),
...present,
]
},
],
+ // The empty state names the active filter. A real category's value is already its label
+ // ("File storage"), but `self-managed` is a slug, so read the label off the sidebar.
+ selectedCategoryLabel: [
+ (s) => [s.categoriesWithCounts, s.selectedCategory],
+ (categoriesWithCounts: CatalogCategory[], selectedCategory: SourceCategoryFilter): string =>
+ categoriesWithCounts.find((cat) => cat.category === selectedCategory)?.label ?? selectedCategory,
+ ],
+
catalogFuse: [
(s) => [s.catalogItems],
(catalogItems: CatalogItem[]): Fuse =>
@@ -434,10 +490,7 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
): CatalogItem[] => {
const trimmed = search.trim()
const base = trimmed ? searchCatalog(catalogFuse, trimmed) : catalogItems
- const filtered =
- selectedCategory === ALL_SOURCES_CATEGORY
- ? base
- : base.filter((item) => item.category === selectedCategory)
+ const filtered = base.filter((item) => matchesCategory(item, selectedCategory))
// Keep fuzzy-search relevance order when searching. When browsing, lead with the
// featured sources people connect most (Stripe, Postgres, the ad platforms, ...),
// then the rest of the connectable sources, then "Coming soon" ones — all
@@ -478,7 +531,7 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
return false
}
return searchCatalog(catalogFuse, trimmed).some(
- (item) => item.status !== 'coming_soon' && item.category !== selectedCategory
+ (item) => item.status !== 'coming_soon' && !matchesCategory(item, selectedCategory)
)
},
],
@@ -523,6 +576,17 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
lemonToast.success('Thanks! Your source request has been submitted.')
},
})),
+ // The sources list links here with the category already chosen, so "New self-managed source"
+ // opens on the self-managed tiles rather than on the whole catalog.
+ urlToAction(({ actions, values }) => ({
+ '*': (_, searchParams) => {
+ const category = searchParams[CATEGORY_SEARCH_PARAM]
+ if (!isSourceCategoryFilter(category) || category === values.selectedCategory) {
+ return
+ }
+ actions.setSelectedCategory(category)
+ },
+ })),
afterMount(({ actions, values }) => {
// The catalog can be opened without passing the sources list first (a deep link, or the
// pipeline new-source page), and nothing else on those pages loads it.
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCategories.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCategories.ts
new file mode 100644
index 000000000000..65104a490f46
--- /dev/null
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCategories.ts
@@ -0,0 +1,21 @@
+import { DataWarehouseSourceCategoryApi } from 'products/warehouse_sources/frontend/generated/api.schemas'
+
+export type SourceCategoryFilter = DataWarehouseSourceCategoryApi | 'all' | 'self-managed'
+
+export const ALL_SOURCES_CATEGORY = 'all'
+
+// Not a `DataWarehouseSourceCategoryApi` value: self-managed describes who holds the data, not what
+// the source is about, so a connector has both a category and this flag. The sources list already
+// splits on it, and people look for the same split here.
+export const SELF_MANAGED_CATEGORY = 'self-managed'
+
+// pinned: URL search param — the sources list deep-links into the catalog with it.
+export const CATEGORY_SEARCH_PARAM = 'category'
+
+export function isSourceCategoryFilter(value: unknown): value is SourceCategoryFilter {
+ return (
+ value === ALL_SOURCES_CATEGORY ||
+ value === SELF_MANAGED_CATEGORY ||
+ Object.values(DataWarehouseSourceCategoryApi).includes(value as DataWarehouseSourceCategoryApi)
+ )
+}
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts
index da03447aa0f7..a63076392abd 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts
@@ -1,6 +1,9 @@
+import { router } from 'kea-router'
+
import { PaginatedResponse } from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -133,15 +136,17 @@ describe('sourceCatalogLogic', () => {
expect(names.indexOf('ApplePay')).toBeLessThan(names.indexOf('Apple'))
})
- it('surfaces self-managed file-storage connectors when searching for a file format', () => {
- const logic = sourceCatalogLogic()
- logic.actions.setSearch('csv')
+ // Each of these dead-ended on "no sources match" and pushed the user to request a source we
+ // already have. "self-managed" is the name the sources list itself gives these connectors.
+ it.each(['csv', 'parquet', 'self-managed', 'self managed', 'bring your own'])(
+ 'surfaces the self-managed connectors when searching for "%s"',
+ (search) => {
+ const logic = sourceCatalogLogic()
+ logic.actions.setSearch(search)
- // CSV files are imported via the self-managed bucket connectors, so a "csv" search must
- // find them instead of dead-ending on "no sources match".
- const names = logic.values.filteredItems.map((item) => item.name)
- expect(names).toContain('aws')
- })
+ expect(logic.values.filteredItems.map((item) => item.name)).toContain('aws')
+ }
+ )
// Fuse matches the whole search term as one pattern, so one extra word buries a term that
// matches on its own: each of these returned nothing at all, which sent the user to "request
@@ -176,10 +181,13 @@ describe('sourceCatalogLogic', () => {
expect(logic.values.filteredItems.map((item) => item.name)).toContain('Postgres')
})
- it('flags a cross-category match when a filtered search only hits another category', () => {
+ it.each([
+ { category: 'Sales' as const, search: 'Datadog' },
+ { category: 'self-managed' as const, search: 'Datadog' },
+ ])('flags a cross-category match when a $category search only hits another category', ({ category, search }) => {
const logic = sourceCatalogLogic()
- logic.actions.setSelectedCategory('Sales')
- logic.actions.setSearch('Datadog')
+ logic.actions.setSelectedCategory(category)
+ logic.actions.setSearch(search)
// The category filter hides the only match, so the list dead-ends...
expect(logic.values.filteredItems).toHaveLength(0)
@@ -192,6 +200,37 @@ describe('sourceCatalogLogic', () => {
expect(logic.values.hasCrossCategoryMatches).toBe(false)
})
+ // No other test covers narrowing the catalog by category: `self-managed` is the one filter that
+ // narrows on the connection model rather than on `item.category`, so it needs its own coverage.
+ it('narrows the catalog to the self-managed connectors', () => {
+ const logic = sourceCatalogLogic()
+ const selfManagedCount = logic.values.catalogItems.filter((item) => item.selfManaged).length
+ expect(selfManagedCount).toBeGreaterThan(0)
+
+ expect(logic.values.categoriesWithCounts).toContainEqual({
+ category: 'self-managed',
+ label: 'Self-managed',
+ count: selfManagedCount,
+ })
+
+ logic.actions.setSelectedCategory('self-managed')
+ expect(logic.values.filteredItems).toHaveLength(selfManagedCount)
+ expect(logic.values.filteredItems.every((item) => item.selfManaged)).toBe(true)
+ expect(logic.values.selectedCategoryLabel).toEqual('Self-managed')
+ })
+
+ it('opens on the category the sources list linked to', () => {
+ const logic = sourceCatalogLogic()
+ expect(logic.values.selectedCategory).toEqual('all')
+
+ router.actions.push(urls.dataPipelinesNew('source'), { category: 'self-managed' })
+ expect(logic.values.selectedCategory).toEqual('self-managed')
+
+ // An unknown value leaves the catalog as it is rather than filtering it down to nothing.
+ router.actions.push(urls.dataPipelinesNew('source'), { category: 'not-a-category' })
+ expect(logic.values.selectedCategory).toEqual('self-managed')
+ })
+
it('clears the request text when the modal is closed', () => {
const logic = sourceCatalogLogic()
logic.actions.setSearch('Podium')
diff --git a/products/data_warehouse/frontend/scenes/SourcesScene/SourcesList.tsx b/products/data_warehouse/frontend/scenes/SourcesScene/SourcesList.tsx
index 72830b244d6a..e5d5abb6b04c 100644
--- a/products/data_warehouse/frontend/scenes/SourcesScene/SourcesList.tsx
+++ b/products/data_warehouse/frontend/scenes/SourcesScene/SourcesList.tsx
@@ -1,3 +1,5 @@
+import { combineUrl } from 'kea-router'
+
import { IconPlusSmall } from '@posthog/icons'
import { LemonButton, LemonTag } from '@posthog/lemon-ui'
@@ -8,6 +10,10 @@ import { urls } from 'scenes/urls'
import { SceneDivider } from '~/layout/scenes/components/SceneDivider'
import { SceneSection } from '~/layout/scenes/components/SceneSection'
+import {
+ CATEGORY_SEARCH_PARAM,
+ SELF_MANAGED_CATEGORY,
+} from 'products/data_warehouse/frontend/scenes/NewSourceScene/sourceCategories'
import { DirectConnectSourcesTable } from 'products/data_warehouse/frontend/shared/components/DirectConnectSourcesTable'
import { ManagedSourcesTable } from 'products/data_warehouse/frontend/shared/components/ManagedSourcesTable'
import { SelfManagedSourcesTable } from 'products/data_warehouse/frontend/shared/components/SelfManagedSourcesTable'
@@ -64,6 +70,21 @@ export function SourcesList(): JSX.Element {
<SceneSection
title="Self-managed data warehouse sources"
description="Connect to your own data sources, making them queryable in PostHog"
+ actions={
+ <LemonButton
+ type="primary"
+ size="small"
+ icon={<IconPlusSmall />}
+ to={
+ combineUrl(urls.dataPipelinesNew('source'), {
+ [CATEGORY_SEARCH_PARAM]: SELF_MANAGED_CATEGORY,
+ }).url
+ }
+ data-attr="new-self-managed-source"
+ >
+ New self-managed source
+ </LemonButton>
+ }
>
<SelfManagedSourcesTable />
</SceneSection>