: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
import { MakeLogicType, actions, kea, path, reducers } from 'kea'
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: DestinationsSceneTab
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface destinationsSceneLogicActions {
setActiveTab: (tab: DestinationsSceneTab) => {
tab: 'batch' | 'history' | 'notifications' | 'realtime'
}
}
export type destinationsSceneLogicType = MakeLogicType<destinationsSceneLogicValues, destinationsSceneLogicActions>
export const destinationsSceneLogic = kea<destinationsSceneLogicType>([
path(['scenes', 'data-pipelines', 'destinationsSceneLogic']),
actions({
setActiveTab: (tab: DestinationsSceneTab) => ({ tab }),
}),
reducers({
activeTab: [
DEFAULT_TAB as DestinationsSceneTab,
{
setActiveTab: (_, { tab }) => tab,
},
],
}),
actionToUrl(({ values }) => ({
setActiveTab: () => {
const { tab: _, ...otherParams } = router.values.searchParams
const searchParams =
values.activeTab === DEFAULT_TAB ? otherParams : { ...otherParams, tab: values.activeTab }
return [router.values.location.pathname, searchParams, router.values.hashParams]
},
})),
urlToAction(({ actions, values }) => ({
'/data-management/destinations': (_, searchParams) => {
const tab = isDestinationsSceneTab(searchParams.tab) ? searchParams.tab : DEFAULT_TAB
if (tab !== values.activeTab) {
actions.setActiveTab(tab)
}
},
})),
{
selectors: {
breadcrumbs: [
() => [],
(): Breadcrumb[] => {
return [
{
key: 'Destinations',
name: 'Destinations',
iconType: 'data_pipeline',
},
]
},
],
},
},
])