: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
fix(notifications): show batch exports in the pipeline picker (#85121)
Yasen4e4a1ba9bb3e
diff --git a/frontend/src/scenes/settings/user/pipelineNotificationsLogic.test.ts b/frontend/src/scenes/settings/user/pipelineNotificationsLogic.test.tsnew file mode 100644index 000000000000..b405180c759b--- /dev/null+++ b/frontend/src/scenes/settings/user/pipelineNotificationsLogic.test.ts@@ -0,0 +1,66 @@+import { MOCK_DEFAULT_ORGANIZATION, MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import { expectLogic } from 'kea-test-utils'++import { organizationLogic } from 'scenes/organizationLogic'+import { userLogic } from 'scenes/userLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { pipelineNotificationsLogic } from './pipelineNotificationsLogic'++describe('pipelineNotificationsLogic', () => {+ let logic: ReturnType<typeof pipelineNotificationsLogic.build>++ beforeEach(() => {+ useMocks({+ get: {+ '/api/projects/:team_id/hog_functions/': { results: [], next: null },+ '/api/projects/:team_id/pipeline_destination_configs/': { results: [], next: null },+ '/api/projects/1/batch_exports/': {+ results: [{ id: 'be-1', name: 'Nightly export', team_id: 1 }],+ next: null,+ },+ '/api/projects/2/batch_exports/': {+ results: [{ id: 'be-2', name: 'Hourly export', team_id: 2 }],+ next: null,+ },+ },+ })+ initKeaTests()+ userLogic.mount()+ organizationLogic.mount()+ organizationLogic.actions.loadCurrentOrganizationSuccess({+ ...MOCK_DEFAULT_ORGANIZATION,+ teams: [+ { ...MOCK_DEFAULT_TEAM, id: 1, name: 'Project A' },+ { ...MOCK_DEFAULT_TEAM, id: 2, name: 'Project B' },+ ],+ })+ logic = pipelineNotificationsLogic()+ logic.mount()+ })++ it('lists the batch exports of every project', async () => {+ logic.actions.loadPipelines()+ await expectLogic(logic).toDispatchActions(['loadPipelinesSuccess'])++ expect(logic.values.pipelines).toEqual([+ expect.objectContaining({+ id: 'batch_export:be-1',+ name: 'Nightly export',+ kind: 'batch_export',+ teamId: 1,+ teamName: 'Project A',+ }),+ expect.objectContaining({+ id: 'batch_export:be-2',+ name: 'Hourly export',+ kind: 'batch_export',+ teamId: 2,+ teamName: 'Project B',+ }),+ ])+ })+})diff --git a/frontend/src/scenes/settings/user/pipelineNotificationsLogic.ts b/frontend/src/scenes/settings/user/pipelineNotificationsLogic.tsindex 2add933aac9c..1d55efb668c6 100644--- a/frontend/src/scenes/settings/user/pipelineNotificationsLogic.ts+++ b/frontend/src/scenes/settings/user/pipelineNotificationsLogic.ts@@ -108,8 +108,6 @@ export const pipelineNotificationsLogic = kea<pipelineNotificationsLogicType>([return []}- const teamNamesById = new Map(org.teams.map((t) => [t.id, t.name]))-const perTeamItems = await Promise.all(org.teams.map(async (team): Promise<PipelineItem[]> => {const items: PipelineItem[] = []@@ -153,29 +151,31 @@ export const pipelineNotificationsLogic = kea<pipelineNotificationsLogicType>([} catch (e) {console.warn(`Failed to load plugin destinations for team ${team.id}`, e)}+ try {+ const initial: PaginatedBatchExportListApi = await batchExportsList(String(team.id), {+ limit: 100,+ })+ const bes: BatchExportApi[] = [+ ...initial.results,+ ...(await api.loadPaginatedResults<BatchExportApi>(initial.next ?? null)),+ ]+ for (const be of bes) {+ items.push({+ id: `batch_export:${be.id}`,+ name: displayName(be.name),+ kind: 'batch_export',+ teamId: team.id,+ teamName: team.name,+ })+ }+ } catch (e) {+ console.warn(`Failed to load batch exports for team ${team.id}`, e)+ }return items}))- let batchExportItems: PipelineItem[] = []- try {- const initial: PaginatedBatchExportListApi = await batchExportsList(org.id, { limit: 100 })- const bes: BatchExportApi[] = [- ...initial.results,- ...(await api.loadPaginatedResults<BatchExportApi>(initial.next ?? null)),- ]- batchExportItems = bes.map<PipelineItem>((be) => ({- id: `batch_export:${be.id}`,- name: displayName(be.name),- kind: 'batch_export',- teamId: be.team_id,- teamName: teamNamesById.get(be.team_id) ?? '',- }))- } catch (e) {- console.warn('Failed to load batch exports', e)- }-- const items = [...perTeamItems.flat(), ...batchExportItems]+ const items = perTeamItems.flat()return items.sort((a, b) =>a.teamName.localeCompare(b.teamName) ||