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 { MakeLogicType, afterMount, connect, kea, path } from 'kea'

import { toolStreamEventsLogic } from 'products/posthog_ai/frontend/api/logics'

import { biWorksheetsLogic } from './biWorksheetsLogic'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export type biAgentSyncLogicType = MakeLogicType<{}, {}>

export const biAgentSyncLogic = kea<biAgentSyncLogicType>([
    path(['products', 'business_intelligence', 'biAgentSyncLogic']),
    connect(() => ({ logic: [toolStreamEventsLogic] })),
    afterMount(({ cache }) => {
        cache.disposables.add(
            () => {
                toolStreamEventsLogic.actions.registerToolListener('bi-worksheets', {
                    tools: ['insight-create', 'insight-update'],
                    foregroundOnly: true,
                    onEvent: (event) => {
                        if (event.phase === 'completed') {
                            biWorksheetsLogic.findMounted()?.actions.loadWorksheets()
                        }
                    },
                })
                return () => toolStreamEventsLogic.actions.deregisterToolListener('bi-worksheets')
            },
            'tools',
            { pauseOnPageHidden: false }
        )
    }),
])