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.8 KB
Raw Blame
import { MakeLogicType, actions, kea, listeners, path, reducers } from 'kea'

import { MARKETING_ONBOARDING_STORAGE_KEYS } from './constants'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface marketingOnboardingLogicValues {
    manualSourceSearch: string
    showManualSources: boolean
    showOnboarding: boolean
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface marketingOnboardingLogicActions {
    completeOnboarding: () => {
        value: true
    }
    setManualSourceSearch: (search: string) => {
        search: string
    }
    setShowManualSources: (show: boolean) => {
        show: boolean
    }
}

export type marketingOnboardingLogicType = MakeLogicType<
    marketingOnboardingLogicValues,
    marketingOnboardingLogicActions
>

export const marketingOnboardingLogic = kea<marketingOnboardingLogicType>([
    path(['scenes', 'marketing-analytics', 'Onboarding', 'marketingOnboardingLogic']),

    actions({
        setManualSourceSearch: (search: string) => ({ search }),
        setShowManualSources: (show: boolean) => ({ show }),
        completeOnboarding: true,
    }),

    reducers({
        manualSourceSearch: ['', { setManualSourceSearch: (_, { search }) => search }],
        showManualSources: [
            false,
            {
                setShowManualSources: (_, { show }) => show,
                completeOnboarding: () => false,
            },
        ],
        showOnboarding: [
            localStorage.getItem(MARKETING_ONBOARDING_STORAGE_KEYS.COMPLETED) !== 'true',
            {
                completeOnboarding: () => false,
            },
        ],
    }),

    listeners(() => ({
        completeOnboarding: () => {
            localStorage.setItem(MARKETING_ONBOARDING_STORAGE_KEYS.COMPLETED, 'true')
        },
    })),
])