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.

2.1 KB
Raw Blame
import { MakeLogicType, kea, key, path, props, selectors } from 'kea'

import { IntegrationType } from '~/types'

export interface MessageChannelLogicProps {
    integration?: IntegrationType
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface messageChannelLogicValues {
    displayName: string
    isVerificationRequired: boolean
    isVerified: boolean
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface messageChannelLogicMeta {
    key: string
    __keaTypeGenInternalSelectorTypes: {
        displayName: (arg: any) => string
        isVerificationRequired: (arg: any) => boolean
        isVerified: (arg: any) => boolean
    }
}

export type messageChannelLogicType = MakeLogicType<
    messageChannelLogicValues,
    {},
    MessageChannelLogicProps,
    messageChannelLogicMeta
>

export const messageChannelLogic = kea<messageChannelLogicType>([
    path(['products', 'workflows', 'frontend', 'messageChannelLogic']),
    props({} as MessageChannelLogicProps),
    key(({ integration }) => `${integration?.kind}-${integration?.id}`),
    selectors(() => ({
        displayName: [
            () => [(_, props) => props],
            ({ integration }): string => {
                switch (integration?.kind) {
                    case 'email':
                        return integration.config.domain
                    default:
                        return integration.display_name
                }
            },
        ],
        isVerificationRequired: [
            () => [(_, props) => props],
            ({ integration }): boolean => {
                return ['email'].includes(integration?.kind)
            },
        ],
        isVerified: [
            () => [(_, props) => props],
            ({ integration }): boolean => {
                switch (integration?.kind) {
                    case 'email':
                        return integration.config.verified === true
                    default:
                        return true
                }
            },
        ],
    })),
])