Skip to content

: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.

1.2 KB
Raw Blame
import { MakeLogicType, kea, path, reducers, selectors } from 'kea'

// Toolbar shim — prevents the real teamLogic from auto-mounting and making API requests to the wrong host
export function isAuthenticatedTeam(team: unknown): boolean {
    return !!team && typeof team === 'object' && 'api_token' in team
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface teamLogicValues {
    currentTeam: Record<string, unknown> | null
    timezone: string
    weekStartDay: number
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface teamLogicMeta {
    __keaTypeGenInternalSelectorTypes: {
        timezone: (currentTeam: Record<string, unknown> | null) => string
        weekStartDay: (currentTeam: Record<string, unknown> | null) => number
    }
}

export type teamLogicType = MakeLogicType<teamLogicValues, {}, Record<string, any>, teamLogicMeta>

export const teamLogic = kea<teamLogicType>([
    path(['toolbar', 'shims', 'teamLogic']),
    reducers({
        currentTeam: [null as Record<string, unknown> | null, {}],
    }),
    selectors({
        timezone: [(s) => [s.currentTeam], (): string => 'UTC'],
        weekStartDay: [(s) => [s.currentTeam], (): number => 0],
    }),
])