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 { useValues } from 'kea'
import { PropsWithChildren, useMemo } from 'react'

import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { IntegrationView } from 'lib/integrations/IntegrationView'
import { cn } from 'lib/utils/css-classes'

import { IntegrationKind, IntegrationType } from '~/types'

export function Integration({
    kind,
    centered,
    children,
    integrationSuffix,
}: PropsWithChildren<{ kind: IntegrationKind; centered?: boolean; integrationSuffix?: JSX.Element }>): JSX.Element {
    const integrations = useIntegrations(kind)

    return (
        <div className="flex flex-col">
            <div className="flex flex-col gap-y-2">
                {integrations.map((integration) => (
                    <IntegrationView key={integration.id} integration={integration} suffix={integrationSuffix} />
                ))}
                <div className={cn('flex', centered && 'justify-center')}>{children}</div>
            </div>
        </div>
    )
}

export function useIntegrations(kind: IntegrationKind): IntegrationType[] {
    const { getIntegrationsByKind } = useValues(integrationsLogic)

    return useMemo(() => getIntegrationsByKind([kind] satisfies IntegrationKind[]), [getIntegrationsByKind, kind])
}