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

import { teamLogic } from 'scenes/teamLogic'

import { dataCatalogCertificationsList } from 'products/data_catalog/frontend/generated/api'
import { DataCatalogCertificationApi } from 'products/data_catalog/frontend/generated/api.schemas'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface biStartersLogicValues {
    sources: DataCatalogCertificationApi[]
    sourcesLoading: boolean
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface biStartersLogicActions {
    loadSources: () => any
    loadSourcesFailure: (
        error: string,
        errorObject?: any
    ) => {
        error: string
        errorObject?: any
    }
    loadSourcesSuccess: (
        sources: DataCatalogCertificationApi[],
        payload?: any
    ) => {
        sources: DataCatalogCertificationApi[]
        payload?: any
    }
}

export type biStartersLogicType = MakeLogicType<biStartersLogicValues, biStartersLogicActions>

export const biStartersLogic = kea<biStartersLogicType>([
    path(['products', 'business_intelligence', 'biStartersLogic']),
    loaders({
        sources: [
            [] as DataCatalogCertificationApi[],
            {
                loadSources: async (): Promise<DataCatalogCertificationApi[]> => {
                    try {
                        const response = await dataCatalogCertificationsList(String(teamLogic.values.currentTeamId), {
                            status: 'certified',
                            limit: 3,
                        })
                        return response.results
                    } catch {
                        // Catalog suggestions are optional; the library remains usable without them.
                        return []
                    }
                },
            },
        ],
    }),
    afterMount(({ actions }) => {
        actions.loadSources()
    }),
])