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, path, reducers, selectors } from 'kea'
import { urlToAction } from 'kea-router'

import { INTEGRATIONS_BY_SLUG } from './definitions'
import { Integration } from './integrationDefinition'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface integrationsLandingSceneLogicValues {
    integration: Integration | null
    slug: string | null
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface integrationsLandingSceneLogicActions {
    setSlug: (slug: string | null) => {
        slug: string | null
    }
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface integrationsLandingSceneLogicMeta {
    __keaTypeGenInternalSelectorTypes: {
        integration: (slug: string | null) => Integration | null
    }
}

export type integrationsLandingSceneLogicType = MakeLogicType<
    integrationsLandingSceneLogicValues,
    integrationsLandingSceneLogicActions,
    Record<string, any>,
    integrationsLandingSceneLogicMeta
>

export const integrationsLandingSceneLogic = kea<integrationsLandingSceneLogicType>([
    path(['scenes', 'integrations', 'integrationsLandingSceneLogic']),
    actions({
        setSlug: (slug: string | null) => ({ slug }),
    }),
    reducers({
        slug: [
            null as string | null,
            {
                setSlug: (_, { slug }) => slug,
            },
        ],
    }),
    selectors({
        integration: [
            (s) => [s.slug],
            (slug: string | null): Integration | null => (slug ? (INTEGRATIONS_BY_SLUG[slug] ?? null) : null),
        ],
    }),
    urlToAction(({ actions }) => ({
        '/integrations/:slug': ({ slug }) => {
            actions.setSlug(slug ?? null)
        },
    })),
])