: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(cdp): group destinations into tabs by kind (#103001)
Meikel Ratzd4dc620f2e33
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 6f0afd1f9847..9830e75e494a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7569,13 +7569,13 @@ snapshots:scenes-app-data-management--warehouse-properties-groups-tab--light:hash: v1.k794b7964.055dad5f89f7a11a6b6d0bb732e7f9420d68508a00745e8de1fcf8b204450779.Ab4pvOaOoH-NBrU1x5hj1DJs--s5NlJM6B3cyqiWbNUscenes-app-data-management-actions--action--dark:- hash: v1.k794b7964.00b57c65346e514c9454e88054c04eb8aef6f1093d64fdc46cbbef3604e7f2d6.89yiroC6COFhV4T8jtCoYYdBQat6ZW24vyN_AW3GRTI+ hash: v1.k794b7964.5a20010c1f9832758f1c32c5e96a26028a7ba0ae9280b45d77909143364dc16a.pqiIS7EdiJq_M1ULx_6ZI2XfRSB_fImz4nooaueuk7Uscenes-app-data-management-actions--action--light:- hash: v1.k794b7964.01991f5b587ce8b67319035310436131bdc75c0a13959fe581d282029b14c84f.gOBOxAz7KA0qJWzxJDdwKKsqAGfzX9anWCouWgYrpwM+ hash: v1.k794b7964.1254a5f7f2a53d46fc427926128b044356309b303cdc84d9a3582358994438dd.NEsCv4O2yUM9RrzNH7iDlUVIp7d4XqTUJkw97iNWTIAscenes-app-data-management-actions--action-with-unhealthy-events--dark:- hash: v1.k794b7964.17e04442462e2205fd44671940fe1590ccb9dae475b2cd36b3f144149a725775.HooKXvFA43P0ElNL6WnmM91ojGV8B88jS3jpIkAlL4E+ hash: v1.k794b7964.820e4f2044bcc259a5de29206352f8267c811ee731f0e27330d274726f169bfe.YAjsyH7PNttDYBAKlhX8XXaC3CQPUAy1hgcTG0oV2Y0scenes-app-data-management-actions--action-with-unhealthy-events--light:- hash: v1.k794b7964.461e7169c71c1e17678bb80070a5f12c87caf45b2cfc80836cd698910d193380.8fBJ18-v0I7TOlJYsbIFQTvWQYgdPeBUvS5odEmYXho+ hash: v1.k794b7964.6d8192f414af3016181889e47380a2476ae0d7d0037e2568af50eadddb2c0b41.riOWoQ2bOolklOMlbs-9ETGsmRbtvwZUm_l0vvhtyb8scenes-app-data-management-actions--actions-list--dark:hash: v1.k794b7964.bd5168e579fa746d3f0fe22cd50e94e879f638b594e39b93ed3cbf329d797045.t0zAJGmPzUfxAEBp7io3QgPwzbXoekfensWiOF3PmVoscenes-app-data-management-actions--actions-list--light:@@ -7589,25 +7589,25 @@ snapshots:scenes-app-data-management-actions--new-action--light:hash: v1.k794b7964.1f645c933009b0be73528f04ff97cf4f098f956a8e9b394e24330947519e165c.GaYMgqk5vdu3_IKK85vXoyu57VCAD1OFAxU6cJwq_-kscenes-app-data-management-actions--screen-action--dark:- hash: v1.k794b7964.a7d45c674c8c2c5b4a953da0a6edc035c483190477dae0d543c1b6b2b1a6cf85.eslQPw_7Y7zBCu9G7OoVbBuAzSA-bqUoje0pbZUki6Q+ hash: v1.k794b7964.66949c2d71b0a0f1b92fa2560d89904e86a41564fd870ecf4810af4be7eccc0b.djOV-rreUF-Q4jQ8Y3a-X1d7MBd-umfszWm_ygowPy8scenes-app-data-management-actions--screen-action--light:- hash: v1.k794b7964.e1aa47cc899a55d9dbb81ab75b9359f0dbccc5b7e13d97788a4f425eebb564c3.1-xT7t4rwCttUwS4xNKzAG3aGXNBR6O5wXuui1lJ8R8+ hash: v1.k794b7964.b45c6c24839597d94c6496b05585dbfcb9fc5bd2fead7f23d3850c44887e8fde.avmUnARPC1llVXREFYHM9uu7gNtLIq5nUBBIzJWGFjMscenes-app-data-management-definition-view--event-definition-metadata--medium--dark:- hash: v1.k794b7964.4570896f57f20da64793984191bd890cc7854b6f269bf89165bfc75109834935.aI92q2nrEuMv6vHVVZ8n3OyqrRrMowzV7_VGBX0juak+ hash: v1.k794b7964.eea9b7e23eccb23305f38c5f6cc4b8495c02501d4c9f9c5cec9568a60a10ac4f.J5uYAV82pkubu9QGglvSkHhRkM7vvLiillXbn9-ycwoscenes-app-data-management-definition-view--event-definition-metadata--medium--light:- hash: v1.k794b7964.c59103f3d41ba52595009f04cab2cc75f77425b819970447fc1e2bdfe155b305.KolrDRnJNwgqWIgUzpSiDMDdQG_6p5xpwnZhYjkfYkc+ hash: v1.k794b7964.1453c6d262c8e214b0414133fd1d26740500e30b7599b3969ed87698d1b6e856.HuoM3DybGd6ORAh04zLotd8UXwLhH5b-GKaGcInfAK0scenes-app-data-management-definition-view--event-definition-metadata--narrow--dark:- hash: v1.k794b7964.28ccc232fced11cc1ec4c59c09a5e05dee79be308d02e8c22c24f83d2773e767.B_dnXMXeYRz4-25ASYtG8ZlVXBHGL88nzfxBySoHphU+ hash: v1.k794b7964.36d647851fa1f64bf20f56eba4963fc5b44b7f96b177c29153d2401bd3566219.64oCpPpIQA9_n7PFqXLhJ18qdGEllL2YUcMQ_YhS3y4scenes-app-data-management-definition-view--event-definition-metadata--narrow--light:- hash: v1.k794b7964.e357cbd2584fd43dc43e2dbccbe9befea2c3115cbacfa462e630b6bfcc57f9b7.WqDbCToRd4CyEHQyuWI9QiS4yoaNbZUEjdTzyCrtSr8+ hash: v1.k794b7964.a59d8937e9b45540737454eb5c8dae9bcf5f8a55937df45039844108dbf3652f.9LGPqg6Sbd0MbF6_uMO5i3wLUWcB0XvS5jzJee224nwscenes-app-data-management-definition-view--event-definition-metadata--superwide--dark:hash: v1.k794b7964.f5df8bbcd6199837c03c01ac32dca20fac649a54904169554678200998d000da.sHAOHhJE6KtsYJ1W-So2KKHfRomMgj066WsaQRV3gfMscenes-app-data-management-definition-view--event-definition-metadata--superwide--light:hash: v1.k794b7964.65f9813df1b04cdec3cda85d4a3611e4994ec2781d285c6f95d8da96a439703f.NEe0liyZyB2ql34bDOdUOANpw4Xa4YjIPn8VbnY2eUIscenes-app-data-management-definition-view--event-definition-metadata--wide--dark:- hash: v1.k794b7964.00e9ab4d5b49ab209819bd569b6ed1ee80d757bb8a4697eb94277f4d8879145f.QxgTW_3zdsPCCnEba4H3esT9zbe_zg4BfVA5HSWVZBE+ hash: v1.k794b7964.747518b350f0346670a31067f5cf83394de0bb46a4aab5432b6985455eb84042.PU8xVvBITTTkgidgY9mKaWBK4As0MVwWkq2Repoyfjsscenes-app-data-management-definition-view--event-definition-metadata--wide--light:- hash: v1.k794b7964.bcd0733641ad526571025b4d6636886d673602d2c6375bb7927f1c5b270c6900.kvjPEZFMkQhgRCCHHO3Ul9b8Lll83N3715Cp9SxjxFM+ hash: v1.k794b7964.bbebff9b92fa30583a75b6176cb5a68c42b0507fe804941f64c5e8333a81543a.Mq-LalWKlCD58ctQgsUpHHoyionRzSjgFS4fRSL_D-Yscenes-app-data-management-event-definitions--default--dark:hash: v1.k794b7964.d0440958f26df761c2257d96f14a9dd541bb70baa1aed199ffa5928aeea47cb1.LtJRGPRtS4lvpOZuHtH7vD8fgt_QyRns2zOHK5NqggAscenes-app-data-management-event-definitions--default--light:@@ -7640,10 +7640,26 @@ snapshots:hash: v1.k794b7964.6fa2b66d27a1675f40be299d4063d6530d9b7899854e2a4f90a7ed9261457532.zZxRebzp1LR0fgFq5G61QARku_wdiC8mrBG5BtU4Iloscenes-app-data-management-revenue-analytics-event-configuration-modal--default--light:hash: v1.k794b7964.380602ae2b746844554126dce9f27bca9ec04854e281d8467c8de724f4fd49fc.ySrW_TUWEFnfdhQOLX6USTN5uxF1kODMuE5iXuYWtQU+ scenes-app-data-pipelines-destinations--batch-exports--dark:+ hash: v1.k794b7964.68a003f363323b934475a55028191c937344fceef087c97ad3c6b19a4bb176e2.8GK6PfHj0R13FnSQPzgL9Zbwv06w9txP9reUFRf4EG0+ scenes-app-data-pipelines-destinations--batch-exports--light:+ hash: v1.k794b7964.cb2bdba18ef9aca40f73dcfd2667e285108ba8080f809cef1ad8a653cf58b455.aOTBWyt6R8p8V1K8jFm2uuGMA1AGk0MyUD-171Xb1pI+ scenes-app-data-pipelines-destinations--history--dark:+ hash: v1.k794b7964.16d4631d029d5395eb69b5d0c81ee6f634a050756c0c500225d36e67091dac1a.mlbnmmUx3bCbCoVymsLeEj9Rvq4rWnrZZM_X__Ss6NA+ scenes-app-data-pipelines-destinations--history--light:+ hash: v1.k794b7964.6557d6e9be2711c1d12c550a3457aae92cc1ccdc588e379c8d35704e88e3e4e6.EH5U-_mUHbtR6cRzQxeg5a-LrZ0xVGAxbuueIb3PZu4+ scenes-app-data-pipelines-destinations--notifications--dark:+ hash: v1.k794b7964.057e1f33021e704a9d6a8082482d341565c7d2c763a54ab12f8cf034d74211b8.3AV0qN-JP9yIqKfNYEBlqMjjR2SaApsmvlXldNK-7A0+ scenes-app-data-pipelines-destinations--notifications--light:+ hash: v1.k794b7964.5ea1d48c810b8e6257a7f2cd1cdf8a5ba7e9980645ceee74227e150801ce36a6.zAfwwB5m4LgmSNm6H6cpnQyueSE8ePiw3D25v9_v3Hc+ scenes-app-data-pipelines-destinations--realtime--dark:+ hash: v1.k794b7964.80ed280a18ac82339016e10800dd1ccbeaff542a392e26996c31590a5a745e8d.hBH3ORNIgQtdMNE08Hbdt7zaAyUWBD8rhYJmdVqOEo4+ scenes-app-data-pipelines-destinations--realtime--light:+ hash: v1.k794b7964.90a104b79843b4b06635df7d85ccd0549df8f0b9a4971afea09f374c05bcd010.E9MSjaXn9JMVTj-quN955urarkj2H7a3oVXuHooUd50scenes-app-data-pipelines-destinations-incident-replay-banner--default--dark:- hash: v1.k794b7964.e473b8fe8f528606bceba2f9d46d78c8df3f5cd3175c8746aa20d4ae3cfa68a6.PViFZdv24uzTmitBcq0xYDFNupLKX-wieQJtpM3zdrI+ hash: v1.k794b7964.e6d0767c743d29188c9e2cd7cda13c4ae2580e323fc61298dd749c2ada6748ce.hsLdEbmZBzM5ytotm0trAusUL8v0kk9mrHCvtLDleDkscenes-app-data-pipelines-destinations-incident-replay-banner--default--light:- hash: v1.k794b7964.4304bd76f4383695934d5f63aa85e968e9d47caebf2fa08143f1317868506882.M9dN3mtOfOdRQuQe9ga5GzGCNK1s48y8S7OQfvwd4cQ+ hash: v1.k794b7964.9470c6fd30bf7a37caf55d61d73a8b2e4fc52c95634c18832212f7e8470a27b7.hdLajs9Vv1linws_5FrgcdRjMWpzk4_8SnDzkWz9z64scenes-app-data-pipelines-event-filtering--add-condition-and-test-case--dark:hash: v1.k794b7964.054b485fa44909bda3f635ba9d134cea4dfa7e60bbc65206ba752f23b7729c42._2cxQzZ_XmaTvoI9Z7hIKh5kpuDY5rxQG0-1RNRyDgEscenes-app-data-pipelines-event-filtering--add-condition-and-test-case--light:@@ -10377,9 +10393,9 @@ snapshots:scenes-app-settings-environment--settings-environment-error-tracking--light:hash: v1.k794b7964.9b4435125bee69ec16432bab017c8822dcc554ab4b48551f1d817af8c70b3825.wSTcj7MUvVP3zBvhpajH8ZIbdXBmdlCn05--nsVm3XIscenes-app-settings-environment--settings-environment-error-tracking-configuration--dark:- hash: v1.k794b7964.0d228c5d345d88e02faea660484d33e44dcf53044d102a4f12fd895b3a20808a.m7glKiW1lyzNr4vVE2rLRGzrUFjrsZU4Bh21Bk4Pros+ hash: v1.k794b7964.5389531656b98551428d0348f86123184edee37f4c3a32fdb4a1cc0869adc3ff.W_v_OXNRYXMUup9iAKFHeMPkwy3iwVpJ6BlmnA6QO_cscenes-app-settings-environment--settings-environment-error-tracking-configuration--light:- hash: v1.k794b7964.7d62fa47841096cceaa13c9a7cb15c1152b2f929ee030674bc0d97c5bc66c239.GptZ3dbdhoABnDP-dWhaqUCQOTeKYOsMFokkyWuNjwQ+ hash: v1.k794b7964.05cd4d11178a6ab2b511d9bf210abe0d975216c98945669170f00138e560fd16.sqlVQyLt-1PLj-fF9YbPdwnFo_RxtHzrHyZe2OQiSDcscenes-app-settings-environment--settings-environment-feature-flags--dark:hash: v1.k794b7964.5a881bd552287989f50952ebfaa5d49db21340cf8f00869bbf771b0f10d72af4.GlQuGlJ3nXoNmBC-rUWaKdwUCxfkUs1Xlc93cJXUaRQscenes-app-settings-environment--settings-environment-feature-flags--light:diff --git a/frontend/src/scenes/data-pipelines/DataPipelinesHogFunctions.tsx b/frontend/src/scenes/data-pipelines/DataPipelinesHogFunctions.tsxindex 0400e9155efc..4a8e1560b1fc 100644--- a/frontend/src/scenes/data-pipelines/DataPipelinesHogFunctions.tsx+++ b/frontend/src/scenes/data-pipelines/DataPipelinesHogFunctions.tsx@@ -8,10 +8,9 @@ import { HogFunctionTemplateList } from 'scenes/hog-functions/list/HogFunctionTeimport { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneDivider } from '~/layout/scenes/components/SceneDivider'import { SceneSection } from '~/layout/scenes/components/SceneSection'-import { HogFunctionType, HogFunctionTypeType } from '~/types'+import { HogFunctionTypeType } from '~/types'import { nonHogFunctionsLogic } from './utils/nonHogFunctionsLogic'-import { nonHogFunctionTemplatesLogic } from './utils/nonHogFunctionTemplatesLogic'export type DataPipelinesHogFunctionsProps = {kind: HogFunctionTypeType@@ -22,17 +21,17 @@ export function DataPipelinesHogFunctions({ kind, additionalKinds }: DataPipelinconst humanizedKind = humanizeHogFunctionType(kind)const logicKey = `data-pipelines-hog-functions-${kind}`- const { hogFunctionPluginsDestinations, hogFunctionBatchExports, hogFunctionPluginsSiteApps } =- useValues(nonHogFunctionsLogic)- const { loadHogFunctionPluginsDestinations, loadHogFunctionBatchExports, loadHogFunctionPluginsSiteApps } =- useActions(nonHogFunctionsLogic)-- const { hogFunctionTemplatesBatchExports } = useValues(nonHogFunctionTemplatesLogic)+ const {+ hogFunctionPluginsDestinations,+ hogFunctionPluginsDestinationsLoading,+ hogFunctionPluginsSiteApps,+ hogFunctionPluginsSiteAppsLoading,+ } = useValues(nonHogFunctionsLogic)+ const { loadHogFunctionPluginsDestinations, loadHogFunctionPluginsSiteApps } = useActions(nonHogFunctionsLogic)useEffect(() => {if (kind === 'destination') {loadHogFunctionPluginsDestinations()- loadHogFunctionBatchExports()}if (kind === 'site_app') {@@ -40,15 +39,13 @@ export function DataPipelinesHogFunctions({ kind, additionalKinds }: DataPipelin}}, [kind]) // oxlint-disable-line react-hooks/exhaustive-deps- // Each source is null until it loads; the list just needs everything in one array.- const manualSources: (HogFunctionType[] | null)[] =+ // Legacy plugins are listed next to the hog functions until the migration off plugins completes.+ const [manualFunctions, manualFunctionsLoading] =kind === 'destination'- ? [hogFunctionPluginsDestinations, hogFunctionBatchExports]+ ? [hogFunctionPluginsDestinations, hogFunctionPluginsDestinationsLoading]: kind === 'site_app'- ? [hogFunctionPluginsSiteApps]- : []-- const manualFunctions = manualSources.length > 0 ? manualSources.flatMap((source) => source ?? []) : undefined+ ? [hogFunctionPluginsSiteApps, hogFunctionPluginsSiteAppsLoading]+ : [null, false]return (<SceneContent>@@ -57,18 +54,14 @@ export function DataPipelinesHogFunctions({ kind, additionalKinds }: DataPipelinlogicKey={logicKey}type={kind}additionalTypes={additionalKinds}- manualFunctions={manualFunctions}+ manualFunctions={manualFunctions ?? undefined}+ manualFunctionsLoading={manualFunctionsLoading}truncateDescriptions/></SceneSection><SceneDivider /><SceneSection title={`Create a new ${humanizedKind}`}>- <HogFunctionTemplateList- type={kind}- additionalTypes={additionalKinds}- manualTemplates={kind === 'destination' ? hogFunctionTemplatesBatchExports : undefined}- hideComingSoonByDefault- />+ <HogFunctionTemplateList type={kind} additionalTypes={additionalKinds} hideComingSoonByDefault /></SceneSection></SceneContent>)diff --git a/frontend/src/scenes/data-pipelines/DestinationsBatchExportsTab.tsx b/frontend/src/scenes/data-pipelines/DestinationsBatchExportsTab.tsxnew file mode 100644index 000000000000..560c0bc75e55--- /dev/null+++ b/frontend/src/scenes/data-pipelines/DestinationsBatchExportsTab.tsx@@ -0,0 +1,30 @@+import { useValues } from 'kea'++import { HogFunctionTemplateList } from 'scenes/hog-functions/list/HogFunctionTemplateList'++import { SceneContent } from '~/layout/scenes/components/SceneContent'+import { SceneDivider } from '~/layout/scenes/components/SceneDivider'+import { SceneSection } from '~/layout/scenes/components/SceneSection'++import { BatchExportsList } from './batch-exports/BatchExportsList'+import { nonHogFunctionTemplatesLogic } from './utils/nonHogFunctionTemplatesLogic'++export function DestinationsBatchExportsTab(): JSX.Element {+ const { hogFunctionTemplatesBatchExports } = useValues(nonHogFunctionTemplatesLogic)++ return (+ <SceneContent>+ <SceneSection>+ <BatchExportsList />+ </SceneSection>+ <SceneDivider />+ <SceneSection title="Create a new batch export">+ <HogFunctionTemplateList+ type="destination"+ manualTemplates={hogFunctionTemplatesBatchExports}+ manualTemplatesOnly+ />+ </SceneSection>+ </SceneContent>+ )+}diff --git a/frontend/src/scenes/data-pipelines/DestinationsNotificationsTab.tsx b/frontend/src/scenes/data-pipelines/DestinationsNotificationsTab.tsxnew file mode 100644index 000000000000..0770f6a80443--- /dev/null+++ b/frontend/src/scenes/data-pipelines/DestinationsNotificationsTab.tsx@@ -0,0 +1,26 @@+import { HogFunctionList } from 'scenes/hog-functions/list/HogFunctionsList'++import { SceneContent } from '~/layout/scenes/components/SceneContent'+import { SceneSection } from '~/layout/scenes/components/SceneSection'++export function DestinationsNotificationsTab(): JSX.Element {+ return (+ <SceneContent>+ <SceneSection+ description={+ <>+ These destinations deliver the alerts and other events that PostHog itself sends, such as an+ insight alert that fires or a new error tracking issue. Create them from the product they belong+ to, for example from an alert or from the error tracking settings.+ </>+ }+ >+ <HogFunctionList+ logicKey="data-pipelines-notifications"+ type="internal_destination"+ truncateDescriptions+ />+ </SceneSection>+ </SceneContent>+ )+}diff --git a/frontend/src/scenes/data-pipelines/DestinationsScene.stories.tsx b/frontend/src/scenes/data-pipelines/DestinationsScene.stories.tsxnew file mode 100644index 000000000000..bc1463fbb0a7--- /dev/null+++ b/frontend/src/scenes/data-pipelines/DestinationsScene.stories.tsx@@ -0,0 +1,94 @@+import { Meta, StoryObj } from '@storybook/react'++import { App } from 'scenes/App'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'++import batchExports from './__mocks__/batchExports.json'+import hogFunctionDestinations from './__mocks__/hogFunctionDestinations.json'++const notification = (id: string, name: string, eventId: string, enabled: boolean): Record<string, unknown> => ({+ id,+ name,+ type: 'internal_destination',+ enabled,+ filters: { source: 'internal-events', events: [{ id: eventId, type: 'events' }] },+ icon_url: '/static/services/slack.png',+ created_by: hogFunctionDestinations.results[0].created_by,+ created_at: '2023-11-02T09:15:00Z',+ updated_at: '2023-12-20T16:40:00Z',+})++const NOTIFICATIONS = {+ count: 3,+ next: null,+ previous: null,+ results: [+ notification('0195f0e8-0000-0000-0000-000000000001', 'Signup alert to #growth', '$insight_alert_firing', true),+ notification(+ '0195f0e8-0000-0000-0000-000000000002',+ 'New issues to #on-call',+ '$error_tracking_issue_created',+ true+ ),+ notification(+ '0195f0e8-0000-0000-0000-000000000003',+ 'Significant experiment results',+ '$experiment_metric_significant',+ false+ ),+ ],+}++const EMPTY_PAGE = { count: 0, next: null, previous: null, results: [] }++const meta: Meta = {+ component: App,+ title: 'Scenes-App/Data pipelines/Destinations',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2026-01-15',+ },+ decorators: [+ mswDecorator({+ get: {+ // Each tab asks for its own hog function types, so the mock answers by type.+ '/api/environments/:team_id/hog_functions/': ({ request }) =>+ new URL(request.url).searchParams.get('type') === 'internal_destination'+ ? NOTIFICATIONS+ : hogFunctionDestinations,+ '/api/projects/:team_id/hog_functions/masked_secrets/': [],+ '/api/projects/:team_id/batch_exports/': batchExports,+ '/api/environments/:team_id/batch_exports/': batchExports,+ '/api/projects/:team_id/pipeline_destination_configs/': EMPTY_PAGE,+ '/api/organizations/:organization_id/pipeline_destinations/': EMPTY_PAGE,+ '/api/environments/:team_id/external_data_sources/wizard': {},+ '/api/projects/:team_id/activity_log/': { results: [], total_count: 0 },+ },+ post: {+ '/api/environments/:team_id/query/:query_kind/': { results: [] },+ },+ }),+ ],+}+export default meta++type Story = StoryObj<{}>++export const Realtime: Story = {+ parameters: { pageUrl: urls.destinations() },+}++export const BatchExports: Story = {+ parameters: { pageUrl: urls.destinations('batch') },+}++export const Notifications: Story = {+ parameters: { pageUrl: urls.destinations('notifications') },+}++export const History: Story = {+ parameters: { pageUrl: urls.destinations('history') },+}diff --git a/frontend/src/scenes/data-pipelines/DestinationsScene.tsx b/frontend/src/scenes/data-pipelines/DestinationsScene.tsxindex ca035c045cdd..eafd8aecef31 100644--- a/frontend/src/scenes/data-pipelines/DestinationsScene.tsx+++ b/frontend/src/scenes/data-pipelines/DestinationsScene.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import { IconPlusSmall } from '@posthog/icons'-import { LemonButton, LemonTabs } from '@posthog/lemon-ui'+import { LemonButton, LemonTab, LemonTabs } from '@posthog/lemon-ui'import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'import { Shortcut } from 'lib/components/Shortcuts/Shortcut'@@ -19,7 +19,9 @@ import { DestinationsIncidentReplayBanner } from 'products/cdp/frontend/Destinatimport { destinationsEmptyState } from 'products/cdp/frontend/emptyState/destinationsEmptyState'import { DataPipelinesHogFunctions } from './DataPipelinesHogFunctions'-import { destinationsSceneLogic } from './destinationsSceneLogic'+import { DestinationsBatchExportsTab } from './DestinationsBatchExportsTab'+import { DestinationsNotificationsTab } from './DestinationsNotificationsTab'+import { DestinationsSceneTab, destinationsSceneLogic } from './destinationsSceneLogic'export const scene: SceneExport = {component: DestinationsScene,@@ -28,6 +30,37 @@ export const scene: SceneExport = {emptyState: destinationsEmptyState,}+// Each tab mounts its own list, so only the active kind of destination is fetched.+const TABS: LemonTab<DestinationsSceneTab>[] = [+ {+ key: 'realtime',+ label: 'Real-time',+ tooltip: 'Destinations that receive each event as it arrives.',+ 'data-attr': 'destinations-tab-realtime',+ content: <DataPipelinesHogFunctions kind="destination" additionalKinds={['site_destination']} />,+ },+ {+ key: 'batch',+ label: 'Batch exports',+ tooltip: 'Destinations that receive data on a schedule, such as a warehouse or a storage bucket.',+ 'data-attr': 'destinations-tab-batch',+ content: <DestinationsBatchExportsTab />,+ },+ {+ key: 'notifications',+ label: 'Notifications',+ tooltip: 'Destinations for the alerts and other events that PostHog itself sends.',+ 'data-attr': 'destinations-tab-notifications',+ content: <DestinationsNotificationsTab />,+ },+ {+ key: 'history',+ label: 'History',+ 'data-attr': 'destinations-tab-history',+ content: <ActivityLog scope={[ActivityScope.HOG_FUNCTION, ActivityScope.BATCH_EXPORT]} />,+ },+]+export function DestinationsScene(): JSX.Element {const { activeTab } = useValues(destinationsSceneLogic)const { setActiveTab } = useActions(destinationsSceneLogic)@@ -53,24 +86,6 @@ export function DestinationsScene(): JSX.Element {</Shortcut>)- const tabs = [- {- key: 'all',- label: 'All destinations',- content: (- <DataPipelinesHogFunctions- kind="destination"- additionalKinds={['site_destination', 'internal_destination']}- />- ),- },- {- key: 'history',- label: 'History',- content: <ActivityLog scope={[ActivityScope.HOG_FUNCTION, ActivityScope.BATCH_EXPORT]} />,- },- ]-return (<SceneContent><SceneTitleSection@@ -82,12 +97,7 @@ export function DestinationsScene(): JSX.Element {actions={action}/><DestinationsIncidentReplayBanner />- <LemonTabs- activeKey={activeTab}- onChange={(key) => setActiveTab(key as 'all' | 'history')}- tabs={tabs}- sceneInset- />+ <LemonTabs activeKey={activeTab} onChange={setActiveTab} tabs={TABS} sceneInset /></SceneContent>)}diff --git a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.tsx b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.tsxindex 19f7e4c2ab8f..eb9c3c21fc02 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.tsx@@ -111,7 +111,7 @@ export const batchExportSceneLogic = kea<batchExportSceneLogicType>([{key: Scene.Destinations,name: 'Destinations',- path: urls.destinations(),+ path: urls.destinations('batch'),iconType: 'data_pipeline',},{diff --git a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportsList.tsx b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportsList.tsxnew file mode 100644index 000000000000..1717322bfe59--- /dev/null+++ b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportsList.tsx@@ -0,0 +1,166 @@+import { useActions, useValues } from 'kea'++import { LemonCheckbox, LemonInput, LemonTable, LemonTableColumn, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'++import { AppMetricsSparkline } from 'lib/components/AppMetrics/AppMetricsSparkline'+import { createdAtColumn } from 'lib/lemon-ui/LemonTable/columnUtils'+import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'+import { HogFunctionIcon } from 'scenes/hog-functions/configuration/HogFunctionIcon'+import { urls } from 'scenes/urls'++import type { BatchExportApi } from 'products/batch_exports/frontend/generated/api.schemas'++import { BATCH_EXPORT_ICON_MAP } from './BatchExportIcon'+import { batchExportsListLogic } from './batchExportsListLogic'+import {+ compareBatchExportScheduleStatus,+ getBatchExportScheduleStatus,+ humanizeBatchExportInterval,+ humanizeBatchExportName,+ normalizeBatchExportService,+} from './utils'++const columns: LemonTableColumn<BatchExportApi, any>[] = [+ {+ title: '',+ width: 0,+ render: function RenderIcon(_, batchExport) {+ return (+ <HogFunctionIcon+ src={BATCH_EXPORT_ICON_MAP[normalizeBatchExportService(batchExport.destination.type)]}+ size="small"+ />+ )+ },+ },+ {+ title: 'Name',+ sticky: true,+ key: 'name',+ dataIndex: 'name',+ sorter: (a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base', numeric: true }),+ render: (_, batchExport) => (+ <LemonTableLink+ to={urls.batchExport(batchExport.id)}+ title={batchExport.name}+ description={humanizeBatchExportName(normalizeBatchExportService(batchExport.destination.type))}+ />+ ),+ },+ {+ title: 'Interval',+ key: 'interval',+ dataIndex: 'interval',+ width: 0,+ render: (_, batchExport) => (+ <span className="whitespace-nowrap">{humanizeBatchExportInterval(batchExport.interval)}</span>+ ),+ },+ createdAtColumn() as LemonTableColumn<BatchExportApi, any>,+ {+ title: 'Last 7 days',+ width: 0,+ render: (_, batchExport) => (+ <Link to={urls.batchExport(batchExport.id, 'metrics')}>+ <AppMetricsSparkline+ logicKey={batchExport.id}+ metricLabels={{ cancellation: 'Canceled' }}+ metricColors={{ cancellation: 'warning' }}+ forceParams={{+ appSource: 'batch_export',+ appSourceId: batchExport.id,+ // Canceled runs report under the 'cancellation' kind. Without it, a week of+ // cancellations reads as idle and this row disagrees with the metrics tab.+ metricKind: ['success', 'failure', 'cancellation'],+ breakdownBy: 'metric_kind',+ interval: 'day',+ dateFrom: '-7d',+ }}+ />+ </Link>+ ),+ },+ {+ title: 'Status',+ key: 'paused',+ width: 0,+ sorter: compareBatchExportScheduleStatus,+ render: function RenderStatus(_, batchExport) {+ const status = getBatchExportScheduleStatus(batchExport)+ if (status === 'paused') {+ return <LemonTag type="default">Paused</LemonTag>+ }+ if (status === 'ended') {+ return (+ <Tooltip title="This export is past its end date, so it will not run again.">+ <LemonTag type="default">Ended</LemonTag>+ </Tooltip>+ )+ }+ return <LemonTag type="success">Active</LemonTag>+ },+ },+]++export function BatchExportsList(): JSX.Element {+ const { batchExports, batchExportsLoading, filteredBatchExports, hiddenBatchExports, filters } =+ useValues(batchExportsListLogic)+ const { setFilters, resetFilters } = useActions(batchExportsListLogic)++ return (+ <div className="flex flex-col gap-4">+ <div className="flex flex-wrap gap-2 items-center">+ <LemonInput+ type="search"+ placeholder="Search..."+ value={filters.search ?? ''}+ onChange={(search) => setFilters({ search })}+ />+ <div className="flex-1" />+ <LemonCheckbox+ label="Show paused"+ bordered+ size="small"+ checked={filters.showPaused}+ onChange={(showPaused) => setFilters({ showPaused: showPaused || undefined })}+ />+ </div>++ <LemonTable+ dataSource={filteredBatchExports}+ // The sparkline loads once per row, so a row must keep its export across a sort or a search.+ rowKey="id"+ size="small"+ loading={batchExportsLoading}+ columns={columns}+ pagination={{ pageSize: 30 }}+ emptyState={+ batchExports === null ? (+ "Couldn't load batch exports. Refresh the page to try again."+ ) : batchExports.length === 0 ? (+ 'No batch exports found'+ ) : (+ <>+ No batch exports matching filters. <Link onClick={() => resetFilters()}>Clear filters</Link>+ </>+ )+ }+ footer={+ hiddenBatchExports.length > 0 && (+ <div className="p-3 text-secondary">+ <span>{`${hiddenBatchExports.length} hidden.`}</span>{' '}+ <Link+ onClick={() => {+ resetFilters()+ setFilters({ showPaused: true })+ }}+ >+ Show all+ </Link>+ </div>+ )+ }+ />+ </div>+ )+}diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsxindex b13805a1f3f5..100547f28d4e 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx@@ -1197,7 +1197,7 @@ export const batchExportConfigFormLogic = kea<batchExportConfigFormLogicType>([try {await api.batchExports.delete(batchExportId)lemonToast.success('Batch export deleted successfully')- router.actions.replace(urls.destinations())+ router.actions.replace(urls.destinations('batch'))} catch (error: any) {// Show error toast with the error message from the APIconst errorMessage = error.detail || error.message || 'Failed to delete'diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportsListLogic.test.ts b/frontend/src/scenes/data-pipelines/batch-exports/batchExportsListLogic.test.tsnew file mode 100644index 000000000000..aa1b491340bd--- /dev/null+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportsListLogic.test.ts@@ -0,0 +1,92 @@+import { expectLogic } from 'kea-test-utils'++import { teamLogic } from 'scenes/teamLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import type { BatchExportApi } from 'products/batch_exports/frontend/generated/api.schemas'++import { batchExportsListLogic } from './batchExportsListLogic'++const makeBatchExport = (+ id: string,+ name: string,+ destination: BatchExportApi['destination'],+ paused: boolean+): BatchExportApi => ({+ id,+ team_id: 997,+ name,+ destination,+ interval: 'hour',+ paused,+ created_at: '2024-01-01T00:00:00Z',+ last_updated_at: '2024-01-01T00:00:00Z',+ latest_runs: [],+ schema: null,+})++const ACTIVE_EXPORT = makeBatchExport(+ 'active',+ 'Hourly bucket',+ { type: 'AwsS3', config: { type: 'AwsS3', bucket_name: 'exports', region: 'us-east-1', prefix: 'events/' } },+ false+)+const PAUSED_EXPORT = makeBatchExport(+ 'paused',+ 'Nightly warehouse',+ { type: 'Snowflake', config: { type: 'Snowflake', database: 'analytics', warehouse: 'compute', schema: 'public' } },+ true+)++describe('batchExportsListLogic', () => {+ let logic: ReturnType<typeof batchExportsListLogic.build>++ beforeEach(async () => {+ useMocks({+ get: {+ '/api/projects/:team_id/batch_exports/': {+ count: 2,+ next: null,+ previous: null,+ // Paused first, so the sort by status is what puts the active export on top.+ results: [PAUSED_EXPORT, ACTIVE_EXPORT],+ },+ },+ })+ initKeaTests()+ await expectLogic(teamLogic).toFinishAllListeners()+ logic = batchExportsListLogic()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ })++ afterEach(() => {+ logic.unmount()+ })++ it('hides paused exports until "Show paused" is on, and counts them as hidden', async () => {+ await expectLogic(logic).toMatchValues({+ filteredBatchExports: [ACTIVE_EXPORT],+ hiddenBatchExports: [PAUSED_EXPORT],+ })++ logic.actions.setFilters({ showPaused: true })++ await expectLogic(logic).toMatchValues({+ filteredBatchExports: [ACTIVE_EXPORT, PAUSED_EXPORT],+ hiddenBatchExports: [],+ })+ })++ it.each([+ ['nightly', [PAUSED_EXPORT]],+ ['snowflake', [PAUSED_EXPORT]],+ ['bucket', [ACTIVE_EXPORT]],+ ])('matches the search "%s" against the name and the destination service', async (search, expected) => {+ logic.actions.setFilters({ showPaused: true, search })++ await expectLogic(logic).toMatchValues({ filteredBatchExports: expected })+ })+})diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportsListLogic.ts b/frontend/src/scenes/data-pipelines/batch-exports/batchExportsListLogic.tsnew file mode 100644index 000000000000..4aa3b40accc9--- /dev/null+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportsListLogic.ts@@ -0,0 +1,136 @@+import { MakeLogicType, actions, afterMount, connect, kea, path, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'++import api from 'lib/api'+import { teamLogic } from 'scenes/teamLogic'++import { batchExportsList } from 'products/batch_exports/frontend/generated/api'+import type { BatchExportApi } from 'products/batch_exports/frontend/generated/api.schemas'++import { compareBatchExportScheduleStatus, humanizeBatchExportName, normalizeBatchExportService } from './utils'++export type BatchExportsListFilters = {+ search?: string+ showPaused?: boolean+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface batchExportsListLogicValues {+ currentTeamId: number | null // teamLogic+ batchExports: BatchExportApi[] | null+ batchExportsLoading: boolean+ filteredBatchExports: BatchExportApi[]+ filters: BatchExportsListFilters+ hiddenBatchExports: BatchExportApi[]+ sortedBatchExports: BatchExportApi[]+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface batchExportsListLogicActions {+ loadBatchExports: () => any+ loadBatchExportsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadBatchExportsSuccess: (+ batchExports: BatchExportApi[],+ payload?: any+ ) => {+ batchExports: BatchExportApi[]+ payload?: any+ }+ resetFilters: () => {+ value: true+ }+ setFilters: (filters: Partial<BatchExportsListFilters>) => {+ filters: Partial<BatchExportsListFilters>+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface batchExportsListLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ sortedBatchExports: (batchExports: BatchExportApi[] | null) => BatchExportApi[]+ filteredBatchExports: (+ sortedBatchExports: BatchExportApi[],+ filters: BatchExportsListFilters+ ) => BatchExportApi[]+ hiddenBatchExports: (+ sortedBatchExports: BatchExportApi[],+ filteredBatchExports: BatchExportApi[]+ ) => BatchExportApi[]+ }+}++export type batchExportsListLogicType = MakeLogicType<+ batchExportsListLogicValues,+ batchExportsListLogicActions,+ Record<string, any>,+ batchExportsListLogicMeta+>++export const batchExportsListLogic = kea<batchExportsListLogicType>([+ path(['scenes', 'data-pipelines', 'batch-exports', 'batchExportsListLogic']),+ connect(() => ({+ values: [teamLogic, ['currentTeamId']],+ })),+ actions({+ setFilters: (filters: Partial<BatchExportsListFilters>) => ({ filters }),+ resetFilters: true,+ }),+ loaders(({ values }) => ({+ batchExports: [+ null as BatchExportApi[] | null,+ {+ loadBatchExports: async () => {+ const firstPage = await batchExportsList(String(values.currentTeamId))+ const otherPages = await api.loadPaginatedResults<BatchExportApi>(firstPage.next ?? null)+ return [...firstPage.results, ...otherPages]+ },+ },+ ],+ })),+ reducers({+ filters: [+ {} as BatchExportsListFilters,+ {+ setFilters: (state, { filters }) => ({ ...state, ...filters }),+ resetFilters: () => ({}),+ },+ ],+ }),+ selectors({+ sortedBatchExports: [+ (s) => [s.batchExports],+ (batchExports: BatchExportApi[] | null): BatchExportApi[] =>+ [...(batchExports ?? [])].sort(compareBatchExportScheduleStatus),+ ],+ filteredBatchExports: [+ (s) => [s.sortedBatchExports, s.filters],+ (sortedBatchExports: BatchExportApi[], filters: BatchExportsListFilters): BatchExportApi[] => {+ const search = filters.search?.trim().toLowerCase()+ return sortedBatchExports.filter((batchExport) => {+ if (!filters.showPaused && batchExport.paused) {+ return false+ }+ if (!search) {+ return true+ }+ const service = humanizeBatchExportName(normalizeBatchExportService(batchExport.destination.type))+ return batchExport.name.toLowerCase().includes(search) || service.toLowerCase().includes(search)+ })+ },+ ],+ hiddenBatchExports: [+ (s) => [s.sortedBatchExports, s.filteredBatchExports],+ (sortedBatchExports: BatchExportApi[], filteredBatchExports: BatchExportApi[]): BatchExportApi[] =>+ sortedBatchExports.filter((batchExport) => !filteredBatchExports.includes(batchExport)),+ ],+ }),+ afterMount(({ actions }) => {+ actions.loadBatchExports()+ }),+])diff --git a/frontend/src/scenes/data-pipelines/batch-exports/utils.test.ts b/frontend/src/scenes/data-pipelines/batch-exports/utils.test.tsnew file mode 100644index 000000000000..9e42717630c8--- /dev/null+++ b/frontend/src/scenes/data-pipelines/batch-exports/utils.test.ts@@ -0,0 +1,25 @@+import { dayjs } from 'lib/dayjs'++import { compareBatchExportScheduleStatus, getBatchExportScheduleStatus } from './utils'++const PAST = dayjs().subtract(1, 'day').toISOString()+const FUTURE = dayjs().add(1, 'day').toISOString()++describe('batch export utils', () => {+ it.each([+ ['paused, whatever the end date', { paused: true, end_at: FUTURE }, 'paused'],+ ['unpaused and past its end date', { paused: false, end_at: PAST }, 'ended'],+ ['unpaused and before its end date', { paused: false, end_at: FUTURE }, 'active'],+ ['unpaused with no end date', { paused: false, end_at: null }, 'active'],+ ])('reads an export that is %s', (_, batchExport, expected) => {+ expect(getBatchExportScheduleStatus(batchExport)).toBe(expected)+ })++ it('sorts live exports before ended ones and paused ones last', () => {+ const ended = { paused: false, end_at: PAST }+ const active = { paused: false, end_at: null }+ const paused = { paused: true, end_at: null }++ expect([paused, ended, active].sort(compareBatchExportScheduleStatus)).toEqual([active, ended, paused])+ })+})diff --git a/frontend/src/scenes/data-pipelines/batch-exports/utils.ts b/frontend/src/scenes/data-pipelines/batch-exports/utils.tsindex 20f123a31c42..5b0c17aa33c3 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/utils.ts+++ b/frontend/src/scenes/data-pipelines/batch-exports/utils.ts@@ -1,9 +1,12 @@import { dayjs } from 'lib/dayjs'import type { LemonTagType } from 'lib/lemon-ui/LemonTag'+import { capitalizeFirstLetter } from 'lib/utils/strings'-import type { BatchExportRun, BatchExportService } from '~/types'+import type { BatchExportInterval, BatchExportRun, BatchExportService } from '~/types'import { BATCH_EXPORT_SERVICE_NAMES } from '~/types'+import type { BatchExportApi } from 'products/batch_exports/frontend/generated/api.schemas'+export const humanizeBatchExportName = (service: BatchExportService['type']): string => {switch (service) {case 'HTTP':@@ -31,6 +34,19 @@ export const humanizeBatchExportDescription = (service: BatchExportService['type}}+export const humanizeBatchExportInterval = (interval: BatchExportInterval): string => {+ switch (interval) {+ case 'hour':+ return 'Hourly'+ case 'day':+ return 'Daily'+ case 'week':+ return 'Weekly'+ default:+ return capitalizeFirstLetter(interval)+ }+}+export const normalizeBatchExportService = (service: string): BatchExportService['type'] => {return (BATCH_EXPORT_SERVICE_NAMES.find((s) => s.toLowerCase() === service.toLowerCase()) ??@@ -38,6 +54,39 @@ export const normalizeBatchExportService = (service: string): BatchExportService)}+/** Whether the export's schedule can still fire, which `paused` alone does not tell you. */+export type BatchExportScheduleStatus = 'active' | 'ended' | 'paused'++export function getBatchExportScheduleStatus(+ batchExport: Pick<BatchExportApi, 'paused' | 'end_at'>+): BatchExportScheduleStatus {+ if (batchExport.paused) {+ return 'paused'+ }+ // An end date in the past bounds the Temporal schedule, so the export can never run again.+ if (batchExport.end_at && dayjs(batchExport.end_at).isBefore(dayjs())) {+ return 'ended'+ }+ return 'active'+}++// Live exports first, then the ones that no longer run.+const SCHEDULE_STATUS_SORT_ORDER: Record<BatchExportScheduleStatus, number> = {+ active: 0,+ ended: 1,+ paused: 2,+}++export function compareBatchExportScheduleStatus(+ a: Pick<BatchExportApi, 'paused' | 'end_at'>,+ b: Pick<BatchExportApi, 'paused' | 'end_at'>+): number {+ return (+ SCHEDULE_STATUS_SORT_ORDER[getBatchExportScheduleStatus(a)] -+ SCHEDULE_STATUS_SORT_ORDER[getBatchExportScheduleStatus(b)]+ )+}+export const formatHourString = (hour: number): string => {return dayjs().hour(hour).format('HH:00')}diff --git a/frontend/src/scenes/data-pipelines/destinationsSceneLogic.test.ts b/frontend/src/scenes/data-pipelines/destinationsSceneLogic.test.tsnew file mode 100644index 000000000000..529c6ea92a5c--- /dev/null+++ b/frontend/src/scenes/data-pipelines/destinationsSceneLogic.test.ts@@ -0,0 +1,47 @@+import { router } from 'kea-router'+import { expectLogic } from 'kea-test-utils'++import { urls } from 'scenes/urls'++import { initKeaTests } from '~/test/init'++import { DestinationsSceneTab, destinationsSceneLogic } from './destinationsSceneLogic'++describe('destinationsSceneLogic', () => {+ let logic: ReturnType<typeof destinationsSceneLogic.build>++ beforeEach(() => {+ initKeaTests()+ logic = destinationsSceneLogic()+ logic.mount()+ })++ afterEach(() => {+ logic.unmount()+ })++ it.each<[string | undefined, DestinationsSceneTab]>([+ ['batch', 'batch'],+ ['notifications', 'notifications'],+ ['history', 'history'],+ // `?tab=all` is what bookmarks from the single-list version of the scene carry.+ ['all', 'realtime'],+ [undefined, 'realtime'],+ ])('opens the "%s" URL tab as %s', async (tab, expected) => {+ router.actions.push(urls.destinations(), tab ? { tab } : {})++ await expectLogic(logic).toMatchValues({ activeTab: expected })+ })++ it('writes every tab except the default one to the URL', async () => {+ router.actions.push(urls.destinations())++ logic.actions.setActiveTab('batch')+ await expectLogic(logic).toMatchValues({ activeTab: 'batch' })+ expect(router.values.searchParams.tab).toBe('batch')++ logic.actions.setActiveTab('realtime')+ await expectLogic(logic).toMatchValues({ activeTab: 'realtime' })+ expect(router.values.searchParams.tab).toBeUndefined()+ })+})diff --git a/frontend/src/scenes/data-pipelines/destinationsSceneLogic.ts b/frontend/src/scenes/data-pipelines/destinationsSceneLogic.tsindex b7ed5f133965..5e44ec66afa6 100644--- a/frontend/src/scenes/data-pipelines/destinationsSceneLogic.ts+++ b/frontend/src/scenes/data-pipelines/destinationsSceneLogic.ts@@ -3,15 +3,24 @@ import { actionToUrl, router, urlToAction } from 'kea-router'import { Breadcrumb } from '~/types'+// pinned: `?tab=` values are URL API. `/batch_exports` redirects to `batch` and bookmarks carry the rest.+export const DESTINATIONS_SCENE_TABS = ['realtime', 'batch', 'notifications', 'history'] as const+export type DestinationsSceneTab = (typeof DESTINATIONS_SCENE_TABS)[number]++const DEFAULT_TAB: DestinationsSceneTab = 'realtime'++const isDestinationsSceneTab = (tab: unknown): tab is DestinationsSceneTab =>+ DESTINATIONS_SCENE_TABS.includes(tab as DestinationsSceneTab)+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface destinationsSceneLogicValues {- activeTab: 'all' | 'history'+ activeTab: DestinationsSceneTab}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface destinationsSceneLogicActions {- setActiveTab: (tab: 'all' | 'history') => {- tab: 'all' | 'history'+ setActiveTab: (tab: DestinationsSceneTab) => {+ tab: 'batch' | 'history' | 'notifications' | 'realtime'}}@@ -20,11 +29,11 @@ export type destinationsSceneLogicType = MakeLogicType<destinationsSceneLogicValexport const destinationsSceneLogic = kea<destinationsSceneLogicType>([path(['scenes', 'data-pipelines', 'destinationsSceneLogic']),actions({- setActiveTab: (tab: 'all' | 'history') => ({ tab }),+ setActiveTab: (tab: DestinationsSceneTab) => ({ tab }),}),reducers({activeTab: [- 'all' as 'all' | 'history',+ DEFAULT_TAB as DestinationsSceneTab,{setActiveTab: (_, { tab }) => tab,},@@ -33,14 +42,17 @@ export const destinationsSceneLogic = kea<destinationsSceneLogicType>([actionToUrl(({ values }) => ({setActiveTab: () => {const { tab: _, ...otherParams } = router.values.searchParams- const searchParams = values.activeTab === 'history' ? { ...otherParams, tab: 'history' } : otherParams+ const searchParams =+ values.activeTab === DEFAULT_TAB ? otherParams : { ...otherParams, tab: values.activeTab }return [router.values.location.pathname, searchParams, router.values.hashParams]},})),- urlToAction(({ actions }) => ({+ urlToAction(({ actions, values }) => ({'/data-management/destinations': (_, searchParams) => {- const tab = searchParams.tab === 'history' ? 'history' : 'all'- actions.setActiveTab(tab)+ const tab = isDestinationsSceneTab(searchParams.tab) ? searchParams.tab : DEFAULT_TAB+ if (tab !== values.activeTab) {+ actions.setActiveTab(tab)+ }},})),{diff --git a/frontend/src/scenes/data-pipelines/utils/nonHogFunctionsLogic.tsx b/frontend/src/scenes/data-pipelines/utils/nonHogFunctionsLogic.tsxindex 0ea320e6a20c..755c89260548 100644--- a/frontend/src/scenes/data-pipelines/utils/nonHogFunctionsLogic.tsx+++ b/frontend/src/scenes/data-pipelines/utils/nonHogFunctionsLogic.tsx@@ -15,8 +15,6 @@ import { sourceWizardLogic } from 'products/data_warehouse/frontend/scenes/NewSoimport type { SourceConfigResponseApi } from '../../../../../products/warehouse_sources/frontend/generated/api.schemas'import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'import type { UserType } from '../../../types'-import { BATCH_EXPORT_ICON_MAP } from '../batch-exports/BatchExportIcon'-import { humanizeBatchExportDescription } from '../batch-exports/utils'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface nonHogFunctionsLogicValues {@@ -25,8 +23,6 @@ export interface nonHogFunctionsLogicValues {connectors: SourceConfigResponseApi[] // sourceWizardLogiccurrentProjectId: number | string // teamLogicuser: UserType | null // userLogic- hogFunctionBatchExports: HogFunctionType[] | null- hogFunctionBatchExportsLoading: booleanhogFunctionPluginsDestinations: HogFunctionType[] | nullhogFunctionPluginsDestinationsLoading: booleanhogFunctionPluginsSiteApps: HogFunctionType[] | null@@ -35,21 +31,6 @@ export interface nonHogFunctionsLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface nonHogFunctionsLogicActions {- loadHogFunctionBatchExports: () => any- loadHogFunctionBatchExportsFailure: (- error: string,- errorObject?: any- ) => {- error: string- errorObject?: any- }- loadHogFunctionBatchExportsSuccess: (- hogFunctionBatchExports: HogFunctionType[],- payload?: any- ) => {- hogFunctionBatchExports: HogFunctionType[]- payload?: any- }loadHogFunctionPluginsDestinations: () => anyloadHogFunctionPluginsDestinationsFailure: (error: string,@@ -202,35 +183,5 @@ export const nonHogFunctionsLogic = kea<nonHogFunctionsLogicType>([},},],-- hogFunctionBatchExports: [- null as HogFunctionType[] | null,- {- loadHogFunctionBatchExports: async () => {- const response = await api.batchExports.list()- const results = response.results- const hogFunctions: HogFunctionType[] = []-- for (const batchExport of results) {- // TODO - exclude Workflows from here- hogFunctions.push({- id: `batch-export-${batchExport.id}`,- name: batchExport.name,- description: humanizeBatchExportDescription(batchExport.destination.type),- type: 'destination',- created_by: null,- created_at: batchExport.created_at,- updated_at: batchExport.created_at,- enabled: !batchExport.paused,- hog: '',- icon_url: BATCH_EXPORT_ICON_MAP[batchExport.destination.type],- execution_order: undefined,- })- }-- return hogFunctions- },- },- ],})),])diff --git a/frontend/src/scenes/hog-functions/HogFunctionScene.tsx b/frontend/src/scenes/hog-functions/HogFunctionScene.tsxindex 8c8d5c3c1235..196a8cf3472a 100644--- a/frontend/src/scenes/hog-functions/HogFunctionScene.tsx+++ b/frontend/src/scenes/hog-functions/HogFunctionScene.tsx@@ -354,7 +354,7 @@ export const hogFunctionSceneLogic = kea<hogFunctionSceneLogicType>([{key: Scene.HogFunction,name: 'Notifications',- path: returnTo,+ path: returnTo ?? urls.destinations('notifications'),},finalCrumb,]diff --git a/frontend/src/scenes/hog-functions/hog-function-utils.ts b/frontend/src/scenes/hog-functions/hog-function-utils.tsindex 4a496fea7db2..b3e3d4df0825 100644--- a/frontend/src/scenes/hog-functions/hog-function-utils.ts+++ b/frontend/src/scenes/hog-functions/hog-function-utils.ts@@ -11,6 +11,9 @@ export function humanizeHogFunctionType(type: HogFunctionTypeType, plural: booleif (type === 'source_webhook') {return 'source' + (plural ? 's' : '')}+ if (type === 'internal_destination') {+ return 'notification' + (plural ? 's' : '')+ }if (type === 'site_app') {return 'Web script' + (plural ? 's' : '')}diff --git a/frontend/src/scenes/hog-functions/hogFunctionSceneLogic.test.ts b/frontend/src/scenes/hog-functions/hogFunctionSceneLogic.test.tsindex 74036488ec6f..2cafd69deb11 100644--- a/frontend/src/scenes/hog-functions/hogFunctionSceneLogic.test.ts+++ b/frontend/src/scenes/hog-functions/hogFunctionSceneLogic.test.ts@@ -5,7 +5,7 @@ import api from 'lib/api'import { urls } from 'scenes/urls'import { initKeaTests } from '~/test/init'-import { HogFunctionType } from '~/types'+import { Breadcrumb, HogFunctionType } from '~/types'jest.mock('lib/api', () => ({...jest.requireActual('lib/api'),@@ -37,7 +37,38 @@ const LOG_TRANSFORMATION: HogFunctionType = {status: { state: 1, tokens: 0 } as any,} as unknown as HogFunctionType+const makeNotification = (eventId: string, alertId?: string): HogFunctionType =>+ ({+ ...LOG_TRANSFORMATION,+ type: 'internal_destination',+ name: 'Slack notification',+ filters: {+ events: [{ id: eventId, type: 'events' }],+ properties: alertId ? [{ key: 'alert_id', value: alertId, operator: 'exact', type: 'event' }] : [],+ },+ }) as unknown as HogFunctionType+describe('hogFunctionSceneLogic', () => {+ it.each([+ ['an insight alert', makeNotification('$insight_alert_firing', 'alert-1'), ['Insight', 'Alert']],+ ['a logs alert', makeNotification('$logs_alert_firing', 'alert-2'), ['Logs', 'Alert']],+ ['a notification with no owning alert', makeNotification('$health_alert_firing'), ['Notifications']],+ ])('links the breadcrumbs of %s to the product that owns it', async (_, hogFunction, expectedNames) => {+ initKeaTests()+ const { hogFunctionSceneLogic } = require('./HogFunctionScene')+ mockApi.get.mockResolvedValue(hogFunction)++ router.actions.push(urls.hogFunction('fn-1'))+ const logic = hogFunctionSceneLogic({ id: 'fn-1' })+ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadHogFunctionSuccess'])++ const crumbs = logic.values.breadcrumbs.slice(0, -1)+ expect(crumbs.map((crumb: Breadcrumb) => crumb.name)).toEqual(expectedNames)+ expect(crumbs.filter((crumb: Breadcrumb) => !crumb.path)).toEqual([])+ logic.unmount()+ })+it('falls back from a deep-linked tab the loaded type never renders', async () => {// `type` arrives after the URL fires, so ?tab=invocations on a log// transformation used to stick and LemonTabs rendered no active content.diff --git a/frontend/src/scenes/hog-functions/list/DeliveryTypeTag.tsx b/frontend/src/scenes/hog-functions/list/DeliveryTypeTag.tsxindex 4e2a98c98cca..c3051ed018fc 100644--- a/frontend/src/scenes/hog-functions/list/DeliveryTypeTag.tsx+++ b/frontend/src/scenes/hog-functions/list/DeliveryTypeTag.tsx@@ -3,8 +3,8 @@ 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.+// Batch exports vs realtime destinations (hog functions) in the new-destination picker, which+// is the one list that still mixes both kinds of templates.export function DeliveryTypeTag({ item }: { item: { id: string } }): JSX.Element {return getHogFunctionDeliveryType(item) === 'batch' ? (<LemonTag type="completion" icon={<IconClock />} className="text-xs">diff --git a/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsx b/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsxindex ae4f78c89bce..17728bc7b0ca 100644--- a/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsx+++ b/frontend/src/scenes/hog-functions/list/HogFunctionTemplateList.tsx@@ -23,7 +23,7 @@ export function HogFunctionTemplateList({hideFeedback = false,...props}: HogFunctionTemplateListLogicProps & { extraControls?: JSX.Element; hideFeedback?: boolean }): JSX.Element {- const { loading, filteredTemplates, filters, templates, urlForTemplate } = useValues(+ const { loading, filteredTemplates, filters, templates, urlForTemplate, hasMultipleDeliveryTypes } = useValues(hogFunctionTemplateListLogic(props))const { loadHogFunctionTemplates, setFilters, resetFilters, registerInterest } = useActions(@@ -31,7 +31,11 @@ export function HogFunctionTemplateList({)const { openFeedbackDialog } = useActions(hogFunctionRequestModalLogic)- useEffect(() => loadHogFunctionTemplates(), [props.type]) // oxlint-disable-line exhaustive-deps+ useEffect(() => {+ if (!props.manualTemplatesOnly) {+ loadHogFunctionTemplates()+ }+ }, [props.type, props.manualTemplatesOnly]) // oxlint-disable-line exhaustive-depsreturn (<div className="flex flex-col gap-4">@@ -48,7 +52,7 @@ export function HogFunctionTemplateList({</Link>) : null}<div className="flex-1" />- {props.type === 'destination' && (+ {hasMultipleDeliveryTypes && (<LemonSelectsize="small"value={filters.deliveryType ?? null}@@ -108,7 +112,7 @@ export function HogFunctionTemplateList({},},- ...(props.type === 'destination'+ ...(hasMultipleDeliveryTypes? [{title: 'Type',diff --git a/frontend/src/scenes/hog-functions/list/HogFunctionsList.test.ts b/frontend/src/scenes/hog-functions/list/HogFunctionsList.test.tsindex 5b94f7e9bad9..a956f2198679 100644--- a/frontend/src/scenes/hog-functions/list/HogFunctionsList.test.ts+++ b/frontend/src/scenes/hog-functions/list/HogFunctionsList.test.ts@@ -18,8 +18,4 @@ describe('urlForHogFunction', () => {it('does not append returnTo for plugin- prefix IDs', () => {expect(urlForHogFunction(makeFn('plugin-7'), '/health/sdk-health')).toBe('/pipeline/plugins/7')})-- it('does not append returnTo for batch-export- prefix IDs', () => {- expect(urlForHogFunction(makeFn('batch-export-9'), '/health/sdk-health')).toBe('/pipeline/batch-exports/9')- })})diff --git a/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsx b/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsxindex 68cea76915e3..d4379550d3d1 100644--- a/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsx+++ b/frontend/src/scenes/hog-functions/list/HogFunctionsList.tsx@@ -9,6 +9,7 @@ import {LemonCheckbox,LemonInput,LemonSelect,+ LemonSelectOptions,LemonTable,LemonTableColumn,LemonTag,@@ -31,7 +32,6 @@ 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'@@ -53,10 +53,14 @@ const INTERNAL_DESTINATION_CONTEXT: Partial<},'insight-alerts': { label: 'Insight alerts' },'experiment-alerts': { label: 'Experiment alerts' },+ 'logs-alerting': { label: 'Logs alerts' },'health-alerts': {label: 'Health alerts',url: urls.healthAlerts(),},+ 'batch-export-alerts': { label: 'Batch export alerts' },+ 'billing-alerts': { label: 'Billing alerts' },+ 'replay-vision-alerts': { label: 'Replay vision alerts' },}function NotificationContextTag({ hogFunction }: { hogFunction: HogFunctionType }): JSX.Element | null {@@ -96,15 +100,11 @@ function NotificationContextTag({ hogFunction }: { hogFunction: HogFunctionType)}-// `returnTo` only applies to the canonical hog-function path; legacy plugin and-// batch-export scenes don't read it.+// `returnTo` only applies to the canonical hog-function path; the legacy plugin scene doesn't read it.export const urlForHogFunction = (hogFunction: HogFunctionType, returnTo?: string): string => {if (hogFunction.id.startsWith('plugin-')) {return urls.legacyPlugin(hogFunction.id.replace('plugin-', ''))}- if (hogFunction.id.startsWith('batch-export-')) {- return urls.batchExport(hogFunction.id.replace('batch-export-', ''))- }const path = urls.hogFunction(hogFunction.id)return returnTo ? combineUrl(path, { returnTo }).url : path}@@ -117,6 +117,7 @@ export function HogFunctionList({onEditHogFunction,returnTo,truncateDescriptions = false,+ manualFunctionsLoading = false,...props}: HogFunctionListLogicProps & {extraControls?: JSX.Element@@ -124,19 +125,34 @@ export function HogFunctionList({emptyText?: stringonDeleteHogFunction?: (hogFunction: HogFunctionType) => voidonEditHogFunction?: (hogFunction: HogFunctionType) => void+ /** Path the row's breadcrumbs return to. An alert row reads it as the owning alert's path, so pass the owner's URL rather than a list URL. */returnTo?: string/** Clamp long descriptions to two lines with a "Show more" toggle. */truncateDescriptions?: boolean+ /** Whether `manualFunctions` are still being fetched, so the table shows a skeleton and not an empty state. */+ manualFunctionsLoading?: boolean}): JSX.Element {- const { loading, filteredHogFunctions, filters, hogFunctions, hiddenHogFunctions } = useValues(- hogFunctionsListLogic(props)- )+ const { loading, filteredHogFunctions, filters, sortedHogFunctions, hiddenHogFunctions, notificationSources } =+ useValues(hogFunctionsListLogic(props))const { loadHogFunctions, setFilters, resetFilters, toggleEnabled, deleteHogFunction, setReorderModalOpen } =useActions(hogFunctionsListLogic(props))const { openFeedbackDialog } = useActions(hogFunctionRequestModalLogic)const humanizedType = humanizeHogFunctionType(props.type)+ // One source leaves nothing to narrow down, so the filter only shows for a list that mixes sources.+ const showNotificationSourceFilter = notificationSources.length > 1 || !!filters.notificationSource+ const notificationSourceOptions: LemonSelectOptions<HogFunctionConfigurationContextId | null> = [+ { label: 'All sources', value: null },+ ...notificationSources+ .map((contextId) => ({+ // An internal event with no entry above falls back to the 'standard' context id,+ // which is an internal token rather than something to show a person.+ label: INTERNAL_DESTINATION_CONTEXT[contextId]?.label ?? 'Other',+ value: contextId,+ }))+ .sort((a, b) => a.label.localeCompare(b.label)),+ ]useOnMountEffect(loadHogFunctions)@@ -191,26 +207,6 @@ export function HogFunctionList({title: 'Last 7 days',width: 0,render: (_, hogFunction) => {- if (hogFunction.id.startsWith('batch-export-')) {- // TODO: Make this less hacky, maybe with some extended type for managing these values- const batchExportId = hogFunction.id.replace('batch-export-', '')- return (- <Link to={urlForHogFunction(hogFunction) + '?tab=metrics'}>- <AppMetricsSparkline- logicKey={batchExportId}- forceParams={{- appSource: 'batch_export',- appSourceId: batchExportId,- metricKind: ['success', 'failure'],- breakdownBy: 'metric_kind',- interval: 'day',- dateFrom: '-7d',- }}- />- </Link>- )- }-if (isManualFunction(hogFunction) || hogFunction.type === 'site_app') {return <>N/A</>}@@ -285,18 +281,6 @@ 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' || props.type === 'transformation_log') {// insert it in the second columncolumns.splice(1, 0, {@@ -333,7 +317,7 @@ export function HogFunctionList({return (<div className="flex flex-col gap-4">- <div className="flex gap-2 items-center">+ <div className="flex flex-wrap gap-2 items-center"><LemonInputtype="search"placeholder="Search..."@@ -353,12 +337,13 @@ export function HogFunctionList({onChange={(user) => setFilters({ createdBy: user?.uuid || null })}/></div>- {props.type === 'destination' && (+ {showNotificationSourceFilter && (<LemonSelectsize="small"- value={filters.deliveryType ?? null}- onChange={(value) => setFilters({ deliveryType: value ?? undefined })}- options={DELIVERY_TYPE_FILTER_OPTIONS}+ value={filters.notificationSource ?? null}+ onChange={(value) => setFilters({ notificationSource: value ?? undefined })}+ options={notificationSourceOptions}+ data-attr="hog-function-notification-source-filter"/>)}<LemonCheckbox@@ -375,11 +360,14 @@ export function HogFunctionList({<LemonTabledataSource={filteredHogFunctions}size="small"- loading={loading}+ loading={loading || manualFunctionsLoading}columns={columns}+ // The sparkline loads once per row, so a row must keep its function across a sort or a search.+ rowKey="id"pagination={{ pageSize: 30 }}emptyState={- hogFunctions.length === 0 && !loading ? (+ // The API applies the search itself, so an empty result with a search is a filter miss.+ sortedHogFunctions.length === 0 && !filters.search?.trim() ? ((emptyText ?? `No ${humanizedType}s found`)) : (<>diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.tsindex c3a72563bca5..9c553eb3fd94 100644--- a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts+++ b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts@@ -1,3 +1,7 @@+import { expectLogic } from 'kea-test-utils'++import api from 'lib/api'+import { initKeaTests } from '~/test/init'import {CyclotronJobFiltersType,@@ -107,6 +111,25 @@ describe('hogFunctionTemplateListLogic - deliveryType filter', () => {expect(logic.values.filteredTemplates.map((t) => t.id)).toEqual(['template-slack'])})+ it('shows the delivery type from the first render when manual templates wait for fetched ones', async () => {+ let resolveTemplates: (value: { results: HogFunctionTemplateType[] }) => void = () => {}+ jest.spyOn(api.hogFunctions, 'listTemplates').mockReturnValue(+ new Promise((resolve) => {+ resolveTemplates = resolve+ })+ )+ const logic = hogFunctionTemplateListLogic.build({ type: 'destination', manualTemplates: [batchTemplate] })+ logic.mount()+ expect(logic.values.hasMultipleDeliveryTypes).toBe(false)++ logic.actions.loadHogFunctionTemplates()+ expect(logic.values.hasMultipleDeliveryTypes).toBe(true)++ resolveTemplates({ results: [realtimeTemplate] })+ await expectLogic(logic).toDispatchActions(['loadHogFunctionTemplatesSuccess'])+ expect(logic.values.hasMultipleDeliveryTypes).toBe(true)+ })+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.diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsxindex 0091407fd88e..d68824e04a24 100644--- a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx+++ b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx@@ -60,6 +60,8 @@ export type HogFunctionTemplateListLogicProps = {syncFiltersWithUrl?: booleanmanualTemplates?: HogFunctionTemplateType[] | nullmanualTemplatesLoading?: boolean+ /** Show `manualTemplates` alone and do not fetch templates from the API. */+ manualTemplatesOnly?: booleanhideComingSoonByDefault?: booleancustomFilterFunction?: (template: HogFunctionTemplateType) => boolean/** Extra search params to include in the URL when navigating to create a new hog function */@@ -91,6 +93,7 @@ export interface hogFunctionTemplateListLogicValues {user: UserType | null // userLogicfilteredTemplates: HogFunctionTemplateType[]filters: HogFunctionTemplateListFilters+ hasMultipleDeliveryTypes: booleanloading: booleanrawTemplates: HogFunctionTemplateType[]rawTemplatesLoading: boolean@@ -140,6 +143,11 @@ export interface hogFunctionTemplateListLogicMeta {arg2: HogFunctionSubTemplateIdType[]) => HogFunctionTemplateWithSubTemplateType[]templatesFuse: (templates: HogFunctionTemplateWithSubTemplateType[]) => Fuse+ hasMultipleDeliveryTypes: (+ templates: HogFunctionTemplateWithSubTemplateType[],+ loading: boolean,+ arg: HogFunctionTemplateType[]+ ) => booleanfilteredTemplates: (filters: HogFunctionTemplateListFilters,templates: HogFunctionTemplateWithSubTemplateType[],@@ -167,7 +175,7 @@ export const hogFunctionTemplateListLogic = kea<hogFunctionTemplateListLogicType(props) =>`${props.syncFiltersWithUrl ? 'scene' : 'default'}/${props.type ?? 'destination'}/${props.subTemplateIds?.join(',') ?? ''- }`+ }${props.manualTemplatesOnly ? '/manual-only' : ''}`),path((id) => ['scenes', 'pipeline', 'destinationsLogic', id]),connect(() => ({@@ -272,6 +280,23 @@ export const hogFunctionTemplateListLogic = kea<hogFunctionTemplateListLogicType},],+ // Delivery type is only worth a column and a filter when realtime and batch templates are mixed. A list+ // that carries manual templates while it fetches more will mix them once the fetch lands, so the column+ // is there from the first render instead of appearing after the load.+ hasMultipleDeliveryTypes: [+ (s) => [+ s.templates,+ s.loading,+ (_, p: HogFunctionTemplateListLogicProps) => p.manualTemplates ?? EMPTY_ARRAY,+ ],+ (+ templates: HogFunctionTemplateWithSubTemplateType[],+ loading: boolean,+ manualTemplates: HogFunctionTemplateType[]+ ): boolean =>+ new Set(templates.map(getHogFunctionDeliveryType)).size > 1 || (loading && manualTemplates.length > 0),+ ],+filteredTemplates: [(s) => [s.filters,diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.test.ts b/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.test.tsnew file mode 100644index 000000000000..8a0e0ff32f7a--- /dev/null+++ b/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.test.ts@@ -0,0 +1,79 @@+import { expectLogic } from 'kea-test-utils'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'+import { HogFunctionType } from '~/types'++import { hogFunctionsListLogic } from './hogFunctionsListLogic'++const makeNotification = (id: string, eventId: string): HogFunctionType =>+ ({+ id,+ name: id,+ type: 'internal_destination',+ enabled: true,+ hog: '',+ created_at: '2024-01-01T00:00:00Z',+ updated_at: '2024-01-01T00:00:00Z',+ filters: { events: [{ id: eventId, type: 'events' }] },+ }) as HogFunctionType++const INSIGHT_ALERT = makeNotification('insight-alert', '$insight_alert_firing')+const ERROR_TRACKING = makeNotification('error-tracking', '$error_tracking_issue_created')++describe('hogFunctionsListLogic', () => {+ let logic: ReturnType<typeof hogFunctionsListLogic.build>++ beforeEach(async () => {+ useMocks({+ get: {+ '/api/environments/:team_id/hog_functions/': {+ count: 2,+ next: null,+ results: [INSIGHT_ALERT, ERROR_TRACKING],+ },+ },+ })+ initKeaTests()+ logic = hogFunctionsListLogic({ type: 'internal_destination' })+ logic.mount()+ logic.actions.loadHogFunctions()+ await expectLogic(logic).toFinishAllListeners()+ })++ afterEach(() => {+ logic.unmount()+ })++ it('filters notifications by the product that sends them', async () => {+ await expectLogic(logic).toMatchValues({+ filteredHogFunctions: [INSIGHT_ALERT, ERROR_TRACKING],+ notificationSources: ['insight-alerts', 'error-tracking'],+ })++ logic.actions.setFilters({ notificationSource: 'error-tracking' })++ await expectLogic(logic).toMatchValues({+ filteredHogFunctions: [ERROR_TRACKING],+ hiddenHogFunctions: [INSIGHT_ALERT],+ })+ })++ it.each([+ ['drops the row when the API accepts the delete', false, [INSIGHT_ALERT]],+ ['keeps the row when the API refuses the delete', true, [INSIGHT_ALERT, ERROR_TRACKING]],+ ])('%s', async (_, refused, expected) => {+ useMocks({+ patch: {+ '/api/projects/:team_id/hog_functions/:id': refused+ ? () => [400, { detail: 'Alert notification destinations are managed through the alert API.' }]+ : { ...ERROR_TRACKING, deleted: true },+ },+ })++ logic.actions.deleteHogFunction(ERROR_TRACKING)+ await expectLogic(logic).toFinishAllListeners()++ await expectLogic(logic).toMatchValues({ hogFunctions: expected })+ })+})diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsx b/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsxindex c67f5ecbde38..e7e73408ed17 100644--- a/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsx+++ b/frontend/src/scenes/hog-functions/list/hogFunctionsListLogic.tsx@@ -12,11 +12,17 @@ import { projectLogic } from 'scenes/projectLogic'import { userLogic } from 'scenes/userLogic'import { deleteFromTree, refreshTreeItem } from '~/layout/panel-layout/ProjectTree/projectTreeLogic'-import { CyclotronJobFiltersType, HogFunctionType, HogFunctionTypeType, UserType } from '~/types'+import {+ CyclotronJobFiltersType,+ HogFunctionConfigurationContextId,+ HogFunctionType,+ HogFunctionTypeType,+ UserType,+} from '~/types'import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'import type { AvailableFeature } from '../../../types'-import { HogFunctionDeliveryType, getHogFunctionDeliveryType } from '../hog-function-utils'+import { eventToHogFunctionContextId } from '../sub-templates/sub-templates'export const CDP_TEST_HIDDEN_FLAG = '[CDP-TEST-HIDDEN]'const EMPTY_MANUAL_FUNCTIONS: HogFunctionType[] = []@@ -25,7 +31,8 @@ export type HogFunctionListFilters = {search?: stringshowPaused?: booleancreatedBy?: string | null- deliveryType?: HogFunctionDeliveryType+ /** Which PostHog product an `internal_destination` delivers notifications for. */+ notificationSource?: HogFunctionConfigurationContextId}export type HogFunctionListLogicProps = {@@ -60,6 +67,7 @@ export interface hogFunctionsListLogicValues {hogFunctions: HogFunctionType[]hogFunctionsLoading: booleanloading: boolean+ notificationSources: HogFunctionConfigurationContextId[]reorderModalOpen: booleansortedHogFunctions: HogFunctionType[]}@@ -202,6 +210,10 @@ export interface hogFunctionsListLogicMeta {sortedHogFunctions: HogFunctionType[],filteredHogFunctions: HogFunctionType[]) => HogFunctionType[]+ notificationSources: (+ sortedHogFunctions: HogFunctionType[],+ filters: HogFunctionListFilters+ ) => HogFunctionConfigurationContextId[]}}@@ -269,9 +281,7 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([filter_groups: props.forceFilterGroups,types: [props.type, ...(props.additionalTypes || [])],search,- // TODO: This is a temporary fix. We need proper server-side pagination- // once we rework the data pipelines UI and batch exports is no longer- // part of the same list+ // TODO: This is a temporary fix. We need proper server-side pagination.limit: 300,})).results@@ -280,6 +290,10 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([return await api.hogFunctions.rearrange(newOrders)},deleteHogFunction: async ({ hogFunction }) => {+ // deleteWithUndo turns an API rejection into a toast, so the callback firing is+ // the only signal that the row really went. Destinations a product manages are+ // refused, and dropping those rows here makes the table disagree with the server.+ let deleted = falseawait deleteWithUndo({endpoint: `projects/${values.currentProjectId}/hog_functions`,object: {@@ -291,12 +305,13 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([actions.loadHogFunctions()refreshTreeItem('hog_function/', hogFunction.id)} else {+ deleted = truedeleteFromTree('hog_function/', hogFunction.id)}},})- return values.hogFunctions.filter((x) => x.id !== hogFunction.id)+ return deleted ? values.hogFunctions.filter((x) => x.id !== hogFunction.id) : values.hogFunctions},toggleEnabled: async ({ hogFunction, enabled }) => {const { hogFunctions } = values@@ -350,7 +365,7 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([hogFunctions: HogFunctionType[],user: UserType | null): HogFunctionType[] => {- const { showPaused, createdBy, deliveryType } = filters+ const { showPaused, createdBy, notificationSource } = filtersreturn hogFunctions.filter((x) => {if (!shouldShowHogFunction(x, user)) {@@ -365,7 +380,10 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([return false}- if (deliveryType && getHogFunctionDeliveryType(x) !== deliveryType) {+ if (+ notificationSource &&+ eventToHogFunctionContextId(x.filters?.events?.[0]?.id) !== notificationSource+ ) {return false}@@ -380,6 +398,26 @@ export const hogFunctionsListLogic = kea<hogFunctionsListLogicType>([return sortedHogFunctions.filter((hogFunction) => !filteredHogFunctions.includes(hogFunction))},],++ // The products that the listed notifications deliver for. The selected source stays in the list even+ // when a search removed its notifications, so the filter never shows a value it cannot list.+ notificationSources: [+ (s) => [s.sortedHogFunctions, s.filters],+ (+ sortedHogFunctions: HogFunctionType[],+ filters: HogFunctionListFilters+ ): HogFunctionConfigurationContextId[] => {+ const sources = new Set(+ sortedHogFunctions+ .filter((hogFunction) => hogFunction.type === 'internal_destination')+ .map((hogFunction) => eventToHogFunctionContextId(hogFunction.filters?.events?.[0]?.id))+ )+ if (filters.notificationSource) {+ sources.add(filters.notificationSource)+ }+ return Array.from(sources)+ },+ ],}),listeners(({ actions }) => ({diff --git a/frontend/src/scenes/hog-functions/sub-templates/sub-templates.test.ts b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.test.tsnew file mode 100644index 000000000000..787e39f3d45d--- /dev/null+++ b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.test.ts@@ -0,0 +1,23 @@+import { eventToHogFunctionContextId } from './sub-templates'++describe('sub-templates', () => {+ // One event per product that creates internal destinations. An id missing from the switch+ // falls back to 'standard', which merges that product into the notification list's "Other"+ // source and drops its source tag.+ it.each([+ ['$error_tracking_issue_created', 'error-tracking'],+ ['$insight_alert_firing', 'insight-alerts'],+ ['$experiment_metric_significant', 'experiment-alerts'],+ ['$activity_log_entry_created', 'activity-log'],+ ['$discussion_mention_created', 'discussion-mention'],+ ['$logs_alert_firing', 'logs-alerting'],+ ['$health_check_issue_firing', 'health-alerts'],+ ['$batch_export_run_failed', 'batch-export-alerts'],+ ['$billing_alert_firing', 'billing-alerts'],+ ['$replay_vision_alert_match', 'replay-vision-alerts'],+ ['$pageview', 'standard'],+ [undefined, 'standard'],+ ])('reads %s as the %s context', (event, expected) => {+ expect(eventToHogFunctionContextId(event)).toBe(expected)+ })+})diff --git a/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.tsindex 004bf5f10d60..e1a15b5758da 100644--- a/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts+++ b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts@@ -1734,6 +1734,17 @@ export const eventToHogFunctionContextId = (event: string | undefined): HogFunctreturn 'health-alerts'case '$batch_export_run_failed':return 'batch-export-alerts'+ case '$billing_alert_firing':+ case '$billing_alert_resolved':+ case '$billing_alert_errored':+ case '$billing_alert_auto_disabled':+ return 'billing-alerts'+ case '$replay_vision_alert_firing':+ case '$replay_vision_alert_resolved':+ case '$replay_vision_alert_errored':+ case '$replay_vision_alert_auto_disabled':+ case '$replay_vision_alert_match':+ return 'replay-vision-alerts'default:return 'standard'}diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.tsindex 4e1bf28dcaab..53bf8e9769f3 100644--- a/frontend/src/scenes/scenes.ts+++ b/frontend/src/scenes/scenes.ts@@ -618,7 +618,7 @@ export const redirects: Record<'/annotations': () => urls.annotations(),'/annotations/:id': ({ id }) => urls.annotation(id),'/batch_exports/:id': ({ id }) => urls.batchExport(id),- '/batch_exports': urls.destinations(),+ '/batch_exports': urls.destinations('batch'),// Billing lives at /organization/billing. A bare /billing has no scene, so send it there.// /billing/authorization_status keeps its own scene route, so it must not be caught here.'/billing': urls.organizationBilling(),diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.tsindex 3fbe71ca0d21..4c00c9e393c0 100644--- a/frontend/src/scenes/urls.ts+++ b/frontend/src/scenes/urls.ts@@ -15,7 +15,9 @@ import { ActivityTab, OnboardingStepKey, SDKKey } from '~/types'import type { MetricFormPrefill } from 'products/data_catalog/frontend/common'import type { BillingSectionId } from './billing/types'+import type { BatchExportSceneTab } from './data-pipelines/batch-exports/BatchExportScene'import { DataPipelinesNewSceneKind } from './data-pipelines/DataPipelinesNewScene'+import type { DestinationsSceneTab } from './data-pipelines/destinationsSceneLogic'import { OutputTab } from './data-warehouse/editor/outputPaneLogic'import type { HogFunctionSceneTab } from './hog-functions/HogFunctionScene'import type { SettingId, SettingLevelId, SettingSectionId } from './settings/types'@@ -54,7 +56,7 @@ export const urls = {dataWarehouseManagedViewsets: (): string => '/data-management/managed-viewsets',webScripts: (): string => '/web-scripts',webScriptsNew: (): string => '/web-scripts/new',- destinations: (): string => '/data-management/destinations',+ destinations: (tab?: DestinationsSceneTab): string => `/data-management/destinations${tab ? `?tab=${tab}` : ''}`,transformations: (): string => '/data-management/transformations',eventFiltering: (): string => '/data-management/event-filtering',activity: (tab: ActivityTab | ':tab' = ActivityTab.ExploreEvents): string => `/activity/${tab}`,@@ -309,7 +311,8 @@ export const urls = {oauthAuthorize: (): string => '/oauth/authorize',dataPipelinesNew: (kind?: DataPipelinesNewSceneKind): string => `/pipeline/new/${kind ?? ''}`,batchExportNew: (service: string): string => `/pipeline/batch-exports/new/${service}`,- batchExport: (id: string): string => `/pipeline/batch-exports/${id}`,+ batchExport: (id: string, tab?: BatchExportSceneTab): string =>+ `/pipeline/batch-exports/${id}${tab ? `?tab=${tab}` : ''}`,legacyPlugin: (id: string): string => `/pipeline/plugins/${id}`,hogFunction: (id: string, tab?: HogFunctionSceneTab): string => `/functions/${id}${tab ? `?tab=${tab}` : ''}`,hogFunctionNew: (templateId: string): string => `/functions/new/${templateId}`,diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 0bee0cc8e6eb..bff6195bdd15 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -7487,6 +7487,8 @@ export type HogFunctionConfigurationContextId =| 'logs-alerting'| 'health-alerts'| 'batch-export-alerts'+ | 'billing-alerts'+ | 'replay-vision-alerts'export type HogFunctionSubTemplateIdType =| 'early-access-feature-enrollment'