: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'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface webScriptsSceneLogicValues {
activeTab: 'all' | 'history'
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface webScriptsSceneLogicActions {
setActiveTab: (tab: 'all' | 'history') => {
tab: 'all' | 'history'
}
}
export type webScriptsSceneLogicType = MakeLogicType<webScriptsSceneLogicValues, webScriptsSceneLogicActions>
export const webScriptsSceneLogic = kea<webScriptsSceneLogicType>([
path(['scenes', 'data-pipelines', 'webScriptsSceneLogic']),
actions({
setActiveTab: (tab: 'all' | 'history') => ({ tab }),
}),
reducers({
activeTab: [
'all' as 'all' | 'history',
{
setActiveTab: (_, { tab }) => tab,
},
],
}),
actionToUrl(({ values }) => ({
setActiveTab: () => {
const { tab: _, ...otherParams } = router.values.searchParams
const searchParams = values.activeTab === 'history' ? { ...otherParams, tab: 'history' } : otherParams
return [router.values.location.pathname, searchParams, router.values.hashParams]
},
})),
urlToAction(({ actions }) => ({
'/web-scripts': (_, searchParams) => {
const tab = searchParams.tab === 'history' ? 'history' : 'all'
actions.setActiveTab(tab)
},
})),
{
selectors: {
breadcrumbs: [
() => [],
(): Breadcrumb[] => {
return [
{
key: 'Web scripts',
name: 'Web scripts',
iconType: 'data_pipeline',
},
]
},
],
},
},
])