: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(destinations): add type column and filter to destination lists (#63240)
Ross8a74c787f683
diff --git a/frontend/src/scenes/hog-functions/hog-function-utils.test.ts b/frontend/src/scenes/hog-functions/hog-function-utils.test.tsnew file mode 100644index 000000000000..0b47208b39bc--- /dev/null+++ b/frontend/src/scenes/hog-functions/hog-function-utils.test.ts@@ -0,0 +1,13 @@+import { getHogFunctionDeliveryType } from './hog-function-utils'++describe('getHogFunctionDeliveryType', () => {+ it.each([+ ['batch-export-9', 'batch'],+ ['batch-export-AwsS3', 'batch'],+ ['plugin-7', 'realtime'],+ ['abc123', 'realtime'],+ ['template-slack', 'realtime'],+ ])('classifies %s as %s', (id, expected) => {+ expect(getHogFunctionDeliveryType({ id })).toBe(expected)+ })+})diff --git a/frontend/src/scenes/hog-functions/hog-function-utils.ts b/frontend/src/scenes/hog-functions/hog-function-utils.tsindex 43dceaef15eb..c3af4f06dee3 100644--- a/frontend/src/scenes/hog-functions/hog-function-utils.ts+++ b/frontend/src/scenes/hog-functions/hog-function-utils.ts@@ -1,5 +1,12 @@import { HogFunctionTypeType } from '~/types'+export type HogFunctionDeliveryType = 'batch' | 'realtime'++// Batch exports vs realtime destinations share `type: 'destination'`; the only signal is the id prefix.+export function getHogFunctionDeliveryType(item: { id: string }): HogFunctionDeliveryType {+ return item.id.startsWith('batch-export-') ? 'batch' : 'realtime'+}+export function humanizeHogFunctionType(type: HogFunctionTypeType, plural: boolean = false): string {if (type === 'source_webhook') {return 'source' + (plural ? 's' : '')diff --git a/frontend/src/scenes/hog-functions/list/DeliveryTypeTag.tsx b/frontend/src/scenes/hog-functions/list/DeliveryTypeTag.tsxnew file mode 100644index 000000000000..4e2a98c98cca--- /dev/null+++ b/frontend/src/scenes/hog-functions/list/DeliveryTypeTag.tsx@@ -0,0 +1,24 @@+import { IconClock, IconLive } from '@posthog/icons'+import { LemonSelectOptions, LemonTag } from '@posthog/lemon-ui'++import { HogFunctionDeliveryType, getHogFunctionDeliveryType } from '../hog-function-utils'++// Batch exports vs realtime destinations (hog functions). Shared by the destinations list and the+// new-destination picker so the colour/icon/label stay in one place.+export function DeliveryTypeTag({ item }: { item: { id: string } }): JSX.Element {+ return getHogFunctionDeliveryType(item) === 'batch' ? (+ <LemonTag type="completion" icon={<IconClock />} className="text-xs">+ Batch+ </LemonTag>+ ) : (+ <LemonTag type="highlight" icon={<IconLive />} className="text-xs">+ Realtime+ </LemonTag>+ )+}++export const DELIVERY_TYPE_FILTER_OPTIONS: LemonSelectOptions<HogFunctionDeliveryType | null> = [+ { label: 'All types', value: null },+ { label: 'Realtime', value: 'realtime' },+ { label: 'Batch', value: 'batch' },+]diff --git a/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsx b/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsxindex c617f7e8f21e..ae4f78c89bce 100644--- a/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsx+++ b/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsx@@ -2,18 +2,19 @@ import { useActions, useValues } from 'kea'import { useEffect } from 'react'import { IconMegaphone, IconPlusSmall } from '@posthog/icons'-import { LemonButton, LemonInput, LemonTable, Link } from '@posthog/lemon-ui'+import { LemonButton, LemonInput, LemonSelect, LemonTable, Link } from '@posthog/lemon-ui'import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'-import { AccessControlLevel, AccessControlResourceType } from '~/types'+import { AccessControlLevel, AccessControlResourceType, HogFunctionTemplateType } from '~/types'import { SourceReleaseTag } from 'products/data_warehouse/frontend/shared/components/SourceReleaseTag'import { isManagedSourceTemplate } from 'products/data_warehouse/frontend/utils'import { HogFunctionIcon } from '../configuration/HogFunctionIcon'import { HogFunctionStatusTag } from '../misc/HogFunctionStatusTag'+import { DELIVERY_TYPE_FILTER_OPTIONS, DeliveryTypeTag } from './DeliveryTypeTag'import { hogFunctionRequestModalLogic } from './hogFunctionRequestModalLogic'import { HogFunctionTemplateListLogicProps, hogFunctionTemplateListLogic } from './hogFunctionTemplateListLogic'@@ -47,6 +48,14 @@ export function HogFunctionTemplateList({</Link>) : null}<div className="flex-1" />+ {props.type === 'destination' && (+ <LemonSelect+ size="small"+ value={filters.deliveryType ?? null}+ onChange={(value) => setFilters({ deliveryType: value ?? undefined })}+ options={DELIVERY_TYPE_FILTER_OPTIONS}+ />+ )}{extraControls}</div>@@ -99,6 +108,17 @@ export function HogFunctionTemplateList({},},+ ...(props.type === 'destination'+ ? [+ {+ title: 'Type',+ width: 0,+ render: function RenderDeliveryType(_: any, template: HogFunctionTemplateType) {+ return <DeliveryTypeTag item={template} />+ },+ },+ ]+ : []),{width: 0,render: function Render(_, template) {diff --git a/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsx b/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsxindex da716ff03bb6..69e1d1143a88 100644--- a/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsx+++ b/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsx@@ -8,6 +8,7 @@ import {LemonButton,LemonCheckbox,LemonInput,+ LemonSelect,LemonTable,LemonTableColumn,LemonTag,@@ -30,6 +31,7 @@ import { HogFunctionIcon } from '../configuration/HogFunctionIcon'import { humanizeHogFunctionType } from '../hog-function-utils'import { HogFunctionStatusIndicator } from '../misc/HogFunctionStatusIndicator'import { eventToHogFunctionContextId } from '../sub-templates/sub-templates'+import { DELIVERY_TYPE_FILTER_OPTIONS, DeliveryTypeTag } from './DeliveryTypeTag'import { HogFunctionOrderModal } from './HogFunctionOrderModal'import { hogFunctionRequestModalLogic } from './hogFunctionRequestModalLogic'import { HogFunctionListLogicProps, hogFunctionsListLogic } from './hogFunctionsListLogic'@@ -274,6 +276,18 @@ export function HogFunctionList({},]+ if (props.type === 'destination') {+ // insert after the Name column+ columns.splice(2, 0, {+ title: 'Type',+ key: 'deliveryType',+ width: 0,+ render: function RenderDeliveryType(_, hogFunction) {+ return <DeliveryTypeTag item={hogFunction} />+ },+ })+ }+if (props.type === 'transformation') {// insert it in the second columncolumns.splice(1, 0, {@@ -329,6 +343,14 @@ export function HogFunctionList({onChange={(user) => setFilters({ createdBy: user?.uuid || null })}/></div>+ {props.type === 'destination' && (+ <LemonSelect+ size="small"+ value={filters.deliveryType ?? null}+ onChange={(value) => setFilters({ deliveryType: value ?? undefined })}+ options={DELIVERY_TYPE_FILTER_OPTIONS}+ />+ )}<LemonCheckboxlabel="Show paused"bordereddiff --git a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.tsindex 417f277eb5da..c3a72563bca5 100644--- a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts+++ b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts@@ -1,6 +1,7 @@import { initKeaTests } from '~/test/init'import {CyclotronJobFiltersType,+ HogFunctionTemplateType,HogFunctionTemplateWithSubTemplateType,PropertyFilterType,PropertyOperator,@@ -59,3 +60,62 @@ describe('hogFunctionTemplateListLogic - configuration structure', () => {expect(configuration).not.toHaveProperty('properties') // Should not be at top level})})++describe('hogFunctionTemplateListLogic - deliveryType filter', () => {+ const makeTemplate = (id: string, name: string): HogFunctionTemplateType => ({+ id,+ name,+ type: 'destination',+ status: 'stable',+ free: true,+ code: '',+ code_language: 'hog',+ })++ const batchTemplate = makeTemplate('batch-export-S3', 'S3 batch export')+ const realtimeTemplate = makeTemplate('template-slack', 'Slack realtime')++ const buildLogic = (): ReturnType<typeof hogFunctionTemplateListLogic.build> => {+ const logic = hogFunctionTemplateListLogic.build({+ type: 'destination',+ manualTemplates: [batchTemplate, realtimeTemplate],+ })+ logic.mount()+ return logic+ }++ beforeEach(() => {+ initKeaTests()+ })++ it('shows both frequencies when no deliveryType filter is set', () => {+ const logic = buildLogic()+ expect(logic.values.filteredTemplates.map((t) => t.id)).toEqual(+ expect.arrayContaining(['batch-export-S3', 'template-slack'])+ )+ })++ it('filters to batch in the non-search branch', () => {+ const logic = buildLogic()+ logic.actions.setFilters({ deliveryType: 'batch' })+ expect(logic.values.filteredTemplates.map((t) => t.id)).toEqual(['batch-export-S3'])+ })++ it('filters to realtime in the non-search branch', () => {+ const logic = buildLogic()+ logic.actions.setFilters({ deliveryType: 'realtime' })+ expect(logic.values.filteredTemplates.map((t) => t.id)).toEqual(['template-slack'])+ })++ it('applies the deliveryType filter in the search branch too', () => {+ const logic = buildLogic()+ // Only the batch template's name contains "export", so the search matches just that one.+ logic.actions.setFilters({ search: 'export', deliveryType: 'batch' })+ expect(logic.values.filteredTemplates.map((t) => t.id)).toEqual(['batch-export-S3'])++ // Same search still matches the batch template, but the realtime filter must drop it —+ // an empty result proves the deliveryType filter is applied inside the search branch.+ logic.actions.setFilters({ search: 'export', deliveryType: 'realtime' })+ expect(logic.values.filteredTemplates.map((t) => t.id)).toEqual([])+ })+})diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsxindex 86a3c5b26057..6a16242fe80e 100644--- a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx+++ b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx@@ -25,6 +25,7 @@ import {import { cleanSourceId, isManagedSourceId, isSelfManagedSourceId } from 'products/data_warehouse/frontend/utils'+import { HogFunctionDeliveryType, getHogFunctionDeliveryType } from '../hog-function-utils'import { getSubTemplate } from '../sub-templates/sub-templates'import type { hogFunctionTemplateListLogicType } from './hogFunctionTemplateListLogicType'@@ -33,6 +34,7 @@ export interface Fuse extends FuseClass<HogFunctionTemplateType> {}export type HogFunctionTemplateListFilters = {search?: string+ deliveryType?: HogFunctionDeliveryType}export type HogFunctionTemplateListLogicProps = {@@ -205,13 +207,15 @@ export const hogFunctionTemplateListLogic = kea<hogFunctionTemplateListLogicTypehideComingSoonByDefault,customFilterFunction): HogFunctionTemplateType[] => {- const { search } = filters+ const { search, deliveryType } = filters+ const matchesDelivery = (template: HogFunctionTemplateType): boolean =>+ !deliveryType || getHogFunctionDeliveryType(template) === deliveryTypeif (search) {return templatesFuse.search(search).map((x) => {- if (!customFilterFunction(x.item)) {+ if (!customFilterFunction(x.item) || !matchesDelivery(x.item)) {return null}return x.item@@ -221,7 +225,7 @@ export const hogFunctionTemplateListLogic = kea<hogFunctionTemplateListLogicTypeconst [available, comingSoon] = templates.reduce(([available, comingSoon], template) => {- if (!customFilterFunction(template)) {+ if (!customFilterFunction(template) || !matchesDelivery(template)) {return [available, comingSoon]}diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsx b/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsxindex 454f3ce9f038..e9f634696520 100644--- a/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsx+++ b/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsx@@ -14,6 +14,7 @@ import { userLogic } from 'scenes/userLogic'import { deleteFromTree, refreshTreeItem } from '~/layout/panel-layout/ProjectTree/projectTreeLogic'import { CyclotronJobFiltersType, HogFunctionType, HogFunctionTypeType, UserType } from '~/types'+import { HogFunctionDeliveryType, getHogFunctionDeliveryType } from '../hog-function-utils'import type { hogFunctionsListLogicType } from './hogFunctionsListLogicType'export const CDP_TEST_HIDDEN_FLAG = '[CDP-TEST-HIDDEN]'@@ -23,6 +24,7 @@ export type HogFunctionListFilters = {search?: stringshowPaused?: booleancreatedBy?: string | null+ deliveryType?: HogFunctionDeliveryType}export type HogFunctionListLogicProps = {@@ -178,7 +180,7 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([filteredHogFunctions: [(s) => [s.filters, s.sortedHogFunctions, s.user],(filters, hogFunctions, user): HogFunctionType[] => {- const { showPaused, createdBy } = filters+ const { showPaused, createdBy, deliveryType } = filtersreturn hogFunctions.filter((x) => {if (!shouldShowHogFunction(x, user)) {@@ -193,6 +195,10 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([return false}+ if (deliveryType && getHogFunctionDeliveryType(x) !== deliveryType) {+ return false+ }+return true})},diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.tsindex e9af0108de52..c55108b8a4bd 100644--- a/frontend/src/scenes/scenes.ts+++ b/frontend/src/scenes/scenes.ts@@ -149,7 +149,8 @@ export const sceneConfigurations: Record<Scene | string, SceneConfig> = {[Scene.Destinations]: {projectBased: true,name: 'Destinations',- description: 'Destinations allow you to send your data to external systems in real time.',+ description:+ 'Destinations allow you to send your data to external systems either in real time or in scheduled batches.',activityScope: ActivityScope.HOG_FUNCTION,iconType: 'data_pipeline',},