: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, kea, path, props, selectors } from 'kea'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { SIDE_PANEL_CONTEXT_KEY, SidePanelSceneContext } from '~/layout/navigation-3000/sidepanel/types'
import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from '~/layout/today/todayPeople'
import { cohortsModel } from '~/models/cohortsModel'
import { ActivityScope, Breadcrumb, ProjectTreeRef } from '~/types'
import { CohortLogicProps } from './cohortEditLogic'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface cohortSceneLogicValues {
breadcrumbs: Breadcrumb[]
projectTreeRef: ProjectTreeRef
sidePanelContext: SidePanelSceneContext | null
todayPeopleRecent: TodayPeopleRecent | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface cohortSceneLogicMeta {
__keaTypeGenInternalSelectorTypes: {
todayPeopleRecent: (
cohortsById: Partial<Record<number | string, import('~/types').CohortType>>,
arg: any
) => TodayPeopleRecent | null
breadcrumbs: (
cohortsById: Partial<Record<number | string, import('~/types').CohortType>>,
arg: CohortLogicProps['id']
) => Breadcrumb[]
sidePanelContext: (arg: number | 'new' | undefined) => SidePanelSceneContext | null
projectTreeRef: (arg: number | 'new' | undefined) => ProjectTreeRef
}
}
export type cohortSceneLogicType = MakeLogicType<cohortSceneLogicValues, {}, CohortLogicProps, cohortSceneLogicMeta>
export const cohortSceneLogic = kea<cohortSceneLogicType>([
props({} as CohortLogicProps),
path(['scenes', 'cohorts', 'cohortLogic']),
selectors({
[TODAY_PEOPLE_RECENT_KEY]: [
() => [cohortsModel.selectors.cohortsById, (_, props) => props.id],
(
cohortsById: Partial<Record<number | string, import('~/types').CohortType>>,
cohortId: CohortLogicProps['id']
): TodayPeopleRecent | null => {
const cohort = cohortId && cohortId !== 'new' ? cohortsById[cohortId] : null
return cohort && cohortId
? { type: 'cohort', name: cohort.name || 'Untitled', href: urls.cohort(cohortId) }
: null
},
],
breadcrumbs: [
() => [cohortsModel.selectors.cohortsById, (_, props) => props.id as CohortLogicProps['id']],
(
cohortsById: Partial<Record<number | string, import('~/types').CohortType>>,
cohortId: CohortLogicProps['id']
): Breadcrumb[] => {
return [
{
key: 'cohorts',
name: 'Cohorts',
path: urls.cohorts(),
iconType: 'cohort',
},
{
key: [Scene.Cohort, cohortId || 'loading'],
name: cohortId && cohortId !== 'new' ? cohortsById[cohortId]?.name || 'Untitled' : 'Untitled',
iconType: 'cohort',
},
]
},
],
[SIDE_PANEL_CONTEXT_KEY]: [
() => [(_, props: CohortLogicProps) => props.id],
(id: CohortLogicProps['id']): SidePanelSceneContext | null => {
return id && id !== 'new'
? {
activity_scope: ActivityScope.COHORT,
activity_item_id: `${id}`,
}
: null
},
],
projectTreeRef: [
() => [(_, props: CohortLogicProps) => props.id],
(id: number | 'new' | undefined): ProjectTreeRef => ({
type: 'cohort',
ref: id === 'new' ? null : String(id),
}),
],
}),
])