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): offer the custom rest source when a catalog search finds nothing (#115183)

Tom Owers4736f8805e3a
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx b/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx
index bd56c146f5b7..6df327db683c 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/SourceCatalog.tsx
@@ -157,6 +157,7 @@ export function SourceCatalog({ allowedSources }: SourceCatalogProps): JSX.Eleme
selectedCategory,
selectedCategoryLabel,
hasCrossCategoryMatches,
+ customSourceItem,
registeredInterestSources,
sourceRequestModalOpen,
sourceRequestText,
@@ -234,6 +235,19 @@ export function SourceCatalog({ allowedSources }: SourceCatalogProps): JSX.Eleme
or request one below.
</div>
)}
+ {customSourceItem && !hasCrossCategoryMatches && !accessDisabledReason && (
+ <div className="text-muted text-sm">
+ If the tool has a REST API, you can connect it with a{' '}
+ <Link
+ to={customSourceItem.url}
+ onClick={() => selectSourceType(customSourceItem)}
+ data-attr="catalog-empty-custom-source"
+ >
+ {customSourceItem.label}
+ </Link>
+ .
+ </div>
+ )}
{/* Sources bring data into PostHog; users after an export (e.g. searching
"webhook") land here by mistake, so point them at destinations. */}
<div className="text-muted text-sm">
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
index dbc50576972a..9fc59f74fdb1 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
@@ -159,6 +159,7 @@ export interface sourceCatalogLogicValues {
catalogFuse: Fuse
catalogItems: CatalogItem[]
categoriesWithCounts: CatalogCategory[]
+ customSourceItem: CatalogItem | null
filteredItems: CatalogItem[]
hasCrossCategoryMatches: boolean
registeredInterestSources: string[]
@@ -226,6 +227,7 @@ export interface sourceCatalogLogicMeta {
selectedCategory: SourceCategoryFilter
) => CatalogItem[]
hasCrossCategoryMatches: (catalogFuse: Fuse, search: string, selectedCategory: SourceCategoryFilter) => boolean
+ customSourceItem: (catalogItems: CatalogItem[]) => CatalogItem | null
}
}
@@ -551,6 +553,16 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
)
},
],
+
+ // A search that finds nothing is usually for a tool we have no connector for. Any tool with
+ // a REST API can still connect through the Custom REST source, so the empty state offers it.
+ customSourceItem: [
+ (s) => [s.catalogItems],
+ (catalogItems: CatalogItem[]): CatalogItem | null =>
+ catalogItems.find(
+ (item) => item.name === ExternalDataSourceTypeEnumApi.Custom && item.status !== 'coming_soon'
+ ) ?? null,
+ ],
}),
listeners(({ values, actions }) => ({
registerInterest: ({ item }) => {
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 72a2f02a728f..a2a270fcbec1 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts
@@ -200,6 +200,34 @@ describe('sourceCatalogLogic', () => {
expect(logic.values.hasCrossCategoryMatches).toBe(false)
})
+ it.each([
+ { flagEnabled: true, expectedOffer: 'Custom' },
+ { flagEnabled: false, expectedOffer: null },
+ ])(
+ 'offers the Custom REST source for an unmatched search only when it is connectable ($flagEnabled)',
+ ({ flagEnabled, expectedOffer }) => {
+ availableSourcesLogic.actions.loadSuccess({
+ ...AVAILABLE_SOURCES,
+ Custom: {
+ name: 'Custom',
+ label: 'Custom REST source',
+ featureFlag: 'dwh_custom_source',
+ fields: [],
+ } as unknown as SourceConfigResponseApi,
+ })
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags(flagEnabled ? ['dwh_custom_source'] : [], {
+ dwh_custom_source: flagEnabled,
+ })
+ const logic = sourceCatalogLogic()
+ logic.actions.setSearch('qwxzv')
+
+ expect(logic.values.filteredItems).toHaveLength(0)
+ // Pointing at a "Coming soon" tile would send the user to a source they can't connect.
+ expect(logic.values.customSourceItem?.name ?? null).toEqual(expectedOffer)
+ }
+ )
+
// 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', () => {