: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 { DEFAULT_TICKET_COLUMNS, TicketColumnKey, isTicketColumnMandatory } from './ticketColumns'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface ticketColumnsLogicValues {
visibleColumns: TicketColumnKey[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface ticketColumnsLogicActions {
setVisibleColumns: (columns: TicketColumnKey[]) => {
columns: TicketColumnKey[]
}
toggleColumn: (column: TicketColumnKey) => {
column: TicketColumnKey
}
}
export type ticketColumnsLogicType = MakeLogicType<ticketColumnsLogicValues, ticketColumnsLogicActions>
/**
* Which ticket table columns the user wants to see. Deliberately not part of
* supportTicketsSceneLogic: that logic is keyed per mount point (notebook nodes pass their
* own nodeId), so a persisted reducer there would fragment the preference across instances.
*/
export const ticketColumnsLogic = kea<ticketColumnsLogicType>([
path(['products', 'conversations', 'frontend', 'scenes', 'tickets', 'ticketColumnsLogic']),
actions({
setVisibleColumns: (columns: TicketColumnKey[]) => ({ columns }),
toggleColumn: (column: TicketColumnKey) => ({ column }),
}),
reducers({
visibleColumns: [
DEFAULT_TICKET_COLUMNS as TicketColumnKey[],
{ persist: true },
{
setVisibleColumns: (_, { columns }) => columns,
toggleColumn: (state, { column }) => {
if (isTicketColumnMandatory(column)) {
return state
}
return state.includes(column) ? state.filter((key) => key !== column) : [...state, column]
},
},
],
}),
])