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): list the incoming webhook source in the source catalog (#99741)

Tom Owers8476253e72cd
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
index 4e4a674a57ba..8a8991e156dd 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
@@ -4,7 +4,7 @@ import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
-import { FeatureFlagKey } from 'lib/constants'
+import { FEATURE_FLAGS, FeatureFlagKey } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { createFuse } from 'lib/utils/fuseSearch'
import { objectsEqual } from 'lib/utils/objects'
@@ -86,6 +86,20 @@ export interface CatalogItem {
featured?: boolean
}
+// PostHog's own webhook endpoint isn't a warehouse connector, so it never reaches this catalog
+// through `availableSources` — but it's where people look for one, and the only other entry point
+// is the sources list. Gated on the same preview flag as that list's section.
+const EVENT_WEBHOOK_CATALOG_ITEM: CatalogItem = {
+ name: 'event-webhook',
+ label: 'Incoming webhook',
+ iconType: 'PostHog',
+ category: 'Engineering & monitoring',
+ keywords: ['webhook', 'webhooks', 'http', 'https', 'endpoint', 'events', 'incoming', 'custom', 'real time'],
+ status: 'stable',
+ releaseStatus: 'alpha',
+ url: urls.hogFunctionNew('template-source-webhook'),
+}
+
export interface CatalogCategory {
category: SourceCategoryFilter
label: string
@@ -328,7 +342,12 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
})
)
- return [...managed, ...selfManaged, ...fileUpload]
+ // `allowedSources` restricts the catalog to warehouse connectors, so the webhook
+ // source has no place in it.
+ const eventWebhook =
+ !allowedSources && featureFlags[FEATURE_FLAGS.CDP_HOG_SOURCES] ? [EVENT_WEBHOOK_CATALOG_ITEM] : []
+
+ return [...managed, ...selfManaged, ...fileUpload, ...eventWebhook]
},
// featureFlags is a broad dependency that changes identity on every flag refresh;
// keeping the previous array when the derived catalog is unchanged stops the Fuse
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 7e138265dfc6..006e20bf9c5a 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceCatalogLogic.test.ts
@@ -1,3 +1,4 @@
+import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { useMocks } from '~/mocks/jest'
@@ -188,4 +189,37 @@ describe('sourceCatalogLogic', () => {
expect(logic.values.catalogItems).toBe(initialItems)
expect(logic.values.catalogFuse).toBe(initialFuse)
})
+
+ it.each([
+ { previewEnabled: true, expectedMatches: 1 },
+ { previewEnabled: false, expectedMatches: 0 },
+ ])(
+ 'shows the incoming webhook source in a "webhook" search when the preview is $previewEnabled',
+ ({ previewEnabled, expectedMatches }) => {
+ const logic = sourceCatalogLogic()
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags(previewEnabled ? [FEATURE_FLAGS.CDP_HOG_SOURCES] : [], {
+ [FEATURE_FLAGS.CDP_HOG_SOURCES]: previewEnabled,
+ })
+
+ logic.actions.setSearch('webhook')
+
+ expect(logic.values.filteredItems.filter((item) => item.name === 'event-webhook')).toHaveLength(
+ expectedMatches
+ )
+ }
+ )
+
+ it('leaves the incoming webhook source out of a catalog restricted to warehouse sources', () => {
+ const logic = sourceCatalogLogic({ allowedSources: ['Stripe'] })
+ const unmountRestricted = logic.mount()
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CDP_HOG_SOURCES], {
+ [FEATURE_FLAGS.CDP_HOG_SOURCES]: true,
+ })
+
+ expect(logic.values.catalogItems.some((item) => item.name === 'event-webhook')).toBe(false)
+
+ unmountRestricted()
+ })
})