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.6 KB
Raw Blame
import { LogicWrapper, MakeLogicType, actions, kea, key, path, props, reducers } from 'kea'

interface FeedbackCooldownProps {
    userId: string
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface mcpAnalyticsFeedbackCooldownLogicValues {
    lastPromptAt: number
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface mcpAnalyticsFeedbackCooldownLogicActions {
    recordPrompt: (timestamp: number) => {
        timestamp: number
    }
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface mcpAnalyticsFeedbackCooldownLogicMeta {
    key: string
}

export type mcpAnalyticsFeedbackCooldownLogicType = MakeLogicType<
    mcpAnalyticsFeedbackCooldownLogicValues,
    mcpAnalyticsFeedbackCooldownLogicActions,
    FeedbackCooldownProps,
    mcpAnalyticsFeedbackCooldownLogicMeta
>

export const mcpAnalyticsFeedbackCooldownLogic: LogicWrapper<mcpAnalyticsFeedbackCooldownLogicType> =
    kea<mcpAnalyticsFeedbackCooldownLogicType>([
        props({} as FeedbackCooldownProps),
        key(({ userId }: FeedbackCooldownProps): string => userId),
        path((key) => ['products', 'mcp_analytics', 'frontend', 'feedback', 'mcpAnalyticsFeedbackCooldownLogic', key]),
        actions({ recordPrompt: (timestamp: number) => ({ timestamp }) }),
        reducers(({ props }) => ({
            lastPromptAt: [
                0,
                { persist: true, storageKey: `mcp-analytics-feedback-last-prompt:${props.userId}` },
                { recordPrompt: (_, { timestamp }) => timestamp },
            ],
        })),
    ])