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.5 KB
Raw Blame
import { MakeLogicType, afterMount, kea, path } from 'kea'
import { loaders } from 'kea-loaders'

import api from 'lib/api'

import { OrganizationOAuthApplicationApi } from '~/generated/core/api.schemas'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface oauthAppsLogicValues {
    oauthApps: OrganizationOAuthApplicationApi[]
    oauthAppsLoading: boolean
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface oauthAppsLogicActions {
    loadOAuthApps: () => any
    loadOAuthAppsFailure: (
        error: string,
        errorObject?: any
    ) => {
        error: string
        errorObject?: any
    }
    loadOAuthAppsSuccess: (
        oauthApps: OrganizationOAuthApplicationApi[],
        payload?: any
    ) => {
        oauthApps: OrganizationOAuthApplicationApi[]
        payload?: any
    }
}

export type oauthAppsLogicType = MakeLogicType<oauthAppsLogicValues, oauthAppsLogicActions>

export const oauthAppsLogic = kea<oauthAppsLogicType>([
    path(['scenes', 'settings', 'organization', 'oauthAppsLogic']),

    loaders(() => ({
        oauthApps: [
            [] as OrganizationOAuthApplicationApi[],
            {
                loadOAuthApps: async () => {
                    const response = await api.organizationOAuthApplications.list()
                    return response.results
                },
            },
        ],
    })),

    afterMount(({ actions }) => {
        actions.loadOAuthApps()
    }),
])