: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, selectors } from 'kea'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface welcomeOverrideLogicValues {
overrideHeadlines: string[] | null
providers: Record<string, string[]>
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface welcomeOverrideLogicActions {
deregisterHeadlines: (providerId: string) => {
providerId: string
}
registerHeadlines: (
providerId: string,
headlines: string[]
) => {
headlines: string[]
providerId: string
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface welcomeOverrideLogicMeta {
__keaTypeGenInternalSelectorTypes: {
overrideHeadlines: (providers: Record<string, string[]>) => string[] | null
}
}
export type welcomeOverrideLogicType = MakeLogicType<
welcomeOverrideLogicValues,
welcomeOverrideLogicActions,
Record<string, any>,
welcomeOverrideLogicMeta
>
/**
* Global registry of contextual welcome headlines. A host surface (e.g. a scene with the AI panel
* integration) registers headlines that fit what the user is looking at, and the composer's empty
* state picks from them instead of the generic defaults while the provider stays registered.
*/
export const welcomeOverrideLogic = kea<welcomeOverrideLogicType>([
path(['products', 'posthog_ai', 'frontend', 'logics', 'welcomeOverrideLogic']),
actions({
/** Idempotent upsert — re-register the same `providerId` to update its headlines. */
registerHeadlines: (providerId: string, headlines: string[]) => ({ providerId, headlines }),
deregisterHeadlines: (providerId: string) => ({ providerId }),
}),
reducers({
providers: [
{} as Record<string, string[]>,
{
registerHeadlines: (state, { providerId, headlines }) => ({ ...state, [providerId]: headlines }),
deregisterHeadlines: (state, { providerId }) => {
if (!(providerId in state)) {
return state
}
const { [providerId]: _dropped, ...rest } = state
return rest
},
},
],
}),
selectors({
// First registered provider with headlines wins (object insertion order) — mirrors the
// first-writer-wins convention of `attachedContextLogic`.
overrideHeadlines: [
(s) => [s.providers],
(providers: Record<string, string[]>): string[] | null =>
Object.values(providers).find((headlines) => headlines.length > 0) ?? null,
],
}),
])