: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, listeners, path, reducers } from 'kea'
import posthog from 'posthog-js'
import type { CohortUsedInWorkflowsBlockApi } from 'products/cohorts/frontend/generated/api.schemas'
// `view` opens the modal from the cohort's details, before anything is blocked.
export type CohortBlockedAction = 'delete' | 'edit' | 'view'
export interface CohortBlockingWorkflows {
action: CohortBlockedAction
workflows: CohortUsedInWorkflowsBlockApi
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface cohortBlockingWorkflowsModalLogicValues {
blocking: CohortBlockingWorkflows | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface cohortBlockingWorkflowsModalLogicActions {
closeBlockingWorkflowsModal: () => {
value: true
}
openBlockingWorkflowsModal: (blocking: CohortBlockingWorkflows) => {
blocking: CohortBlockingWorkflows
}
}
export type cohortBlockingWorkflowsModalLogicType = MakeLogicType<
cohortBlockingWorkflowsModalLogicValues,
cohortBlockingWorkflowsModalLogicActions
>
export const cohortBlockingWorkflowsModalLogic = kea<cohortBlockingWorkflowsModalLogicType>([
path(['scenes', 'cohorts', 'cohortBlockingWorkflowsModalLogic']),
actions({
openBlockingWorkflowsModal: (blocking: CohortBlockingWorkflows) => ({ blocking }),
closeBlockingWorkflowsModal: true,
}),
reducers({
blocking: [
null as CohortBlockingWorkflows | null,
{
openBlockingWorkflowsModal: (_, { blocking }) => blocking,
closeBlockingWorkflowsModal: () => null,
},
],
}),
listeners({
openBlockingWorkflowsModal: ({ blocking }) => {
if (blocking.action === 'view') {
return
}
// pinned: analytics event name, renaming breaks dashboards
posthog.capture('cohort change blocked by workflows', {
action: blocking.action,
workflow_count: blocking.workflows.total,
hidden_workflow_count: blocking.workflows.hidden,
})
},
}),
])