: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, key, path, props, reducers, selectors, useActions, useValues } from 'kea'
import { actionToUrl, router, urlToAction } from 'kea-router'
import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'
import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'
import { PipelinePluginConfiguration } from 'scenes/data-pipelines/legacy-plugins/PipelinePluginConfiguration'
import { Scene, SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { ActivityScope, Breadcrumb } from '~/types'
import { PipelineNodeLogs } from './PipelineNodeLogs'
import { PipelineNodeMetrics } from './PipelineNodeMetrics'
const LEGACY_PLUGIN_SCENE_TABS = ['configuration', 'metrics', 'logs', 'history'] as const
export type LegacyPluginSceneTab = (typeof LEGACY_PLUGIN_SCENE_TABS)[number]
export interface LegacyPluginSceneLogicProps {
id: string
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface legacyPluginSceneLogicValues {
breadcrumbs: Breadcrumb[]
currentTab: LegacyPluginSceneTab
logicProps: any
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface legacyPluginSceneLogicActions {
setCurrentTab: (tab: LegacyPluginSceneTab) => {
tab: 'configuration' | 'history' | 'logs' | 'metrics'
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface legacyPluginSceneLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
logicProps: (arg: any) => any
}
}
export type legacyPluginSceneLogicType = MakeLogicType<
legacyPluginSceneLogicValues,
legacyPluginSceneLogicActions,
LegacyPluginSceneLogicProps,
legacyPluginSceneLogicMeta
>
export const legacyPluginSceneLogic = kea<legacyPluginSceneLogicType>([
props({} as LegacyPluginSceneLogicProps),
key(({ id }: LegacyPluginSceneLogicProps) => id ?? 'new'),
path((key) => ['scenes', 'data-pipelines', 'legacy-plugins', 'legacyPluginSceneLogic', key]),
actions({
setCurrentTab: (tab: LegacyPluginSceneTab) => ({ tab }),
}),
reducers(() => ({
currentTab: [
'configuration' as LegacyPluginSceneTab,
{
setCurrentTab: (_, { tab }) => tab,
},
],
})),
selectors({
logicProps: [() => [(_, props) => props], (props) => props],
breadcrumbs: [
() => [],
(): Breadcrumb[] => {
return [
{
key: Scene.Destinations,
name: 'Destinations',
path: urls.destinations(),
iconType: 'data_pipeline',
},
{
key: Scene.LegacyPlugin,
name: 'Plugin destination (deprecated)',
iconType: 'data_pipeline',
},
]
},
],
}),
actionToUrl(({ values }) => ({
setCurrentTab: () => {
return [
router.values.location.pathname,
{
...router.values.searchParams,
tab: values.currentTab,
},
router.values.hashParams,
]
},
})),
urlToAction(({ actions, values }) => {
const reactToTabChange = (_: any, search: Record<string, string>): void => {
const possibleTab = (search.tab ?? 'configuration') as LegacyPluginSceneTab
const tab = LEGACY_PLUGIN_SCENE_TABS.includes(possibleTab) ? possibleTab : 'configuration'
if (tab !== values.currentTab) {
actions.setCurrentTab(tab)
}
}
return {
// All possible routes for this scene need to be listed here
[urls.legacyPlugin(':id')]: reactToTabChange,
}
}),
])
export const scene: SceneExport = {
component: LegacyPluginScene,
logic: legacyPluginSceneLogic,
paramsToProps: ({ params: { id } }): (typeof legacyPluginSceneLogic)['props'] => ({
id,
}),
}
export function LegacyPluginScene(): JSX.Element {
const { currentTab, logicProps } = useValues(legacyPluginSceneLogic)
const { setCurrentTab } = useActions(legacyPluginSceneLogic)
const { id } = logicProps
const pluginConfigId = parseInt(id)
const tabs: (LemonTab<LegacyPluginSceneTab> | null)[] = [
{
label: 'Configuration',
key: 'configuration',
content: <PipelinePluginConfiguration pluginConfigId={pluginConfigId} />,
},
{
label: 'Metrics',
key: 'metrics',
content: <PipelineNodeMetrics id={pluginConfigId} />,
},
{
label: 'Logs',
key: 'logs',
content: <PipelineNodeLogs id={pluginConfigId} />,
},
{
label: 'History',
key: 'history',
content: <ActivityLog id={id} scope={ActivityScope.PLUGIN} />,
},
]
return <LemonTabs activeKey={currentTab} tabs={tabs} onChange={setCurrentTab} />
}