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
// AUTO-GENERATED by generate-ui-apps.ts — do not edit
import '../../styles/tailwind.css'

import type { App } from '@modelcontextprotocol/ext-apps'
import { useCallback } from 'react'
import { createRoot } from 'react-dom/client'

import { type ErrorIssueData, type ErrorIssueListData, ErrorIssueListView } from 'products/error_tracking/mcp/apps'

import { AppWrapper } from '../../components/AppWrapper'

function ErrorIssueListApp(): JSX.Element {
    return (
        <AppWrapper<ErrorIssueListData> appName="PostHog Error Issue List">
            {({ data, app }) => <ErrorIssueListContent data={data!} app={app} />}
        </AppWrapper>
    )
}

function ErrorIssueListContent({ data, app }: { data: ErrorIssueListData; app: App | null }): JSX.Element {
    const fallbackToChat = useCallback(
        (name: string) => {
            app?.sendMessage({
                role: 'user',
                content: [{ type: 'text', text: `Show me the details for error issue "${name}"` }],
            })
        },
        [app]
    )

    const handleClick = useCallback(
        async (item: ErrorIssueData): Promise<ErrorIssueData | null> => {
            if (!app) {
                fallbackToChat(item.name)
                return null
            }
            try {
                const result = await app.callServerTool({
                    name: 'query-error-tracking-issue',
                    arguments: { issueId: item.id },
                })
                if (result.isError || !result.structuredContent) {
                    fallbackToChat(item.name)
                    return null
                }
                return result.structuredContent as unknown as ErrorIssueData
            } catch {
                fallbackToChat(item.name)
                return null
            }
        },
        [app, fallbackToChat]
    )

    return <ErrorIssueListView data={data} onIssueClick={handleClick} />
}

const container = document.getElementById('root')
if (container) {
    createRoot(container).render(<ErrorIssueListApp />)
}