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, defaults, kea, key, path, props } from 'kea'
import { lazyLoaders } from 'kea-loaders'

import api from 'lib/api'

export interface ReplayCaptureDiagnosticsPanelLogicProps {
    sessionId: string
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface replayCaptureDiagnosticsPanelLogicValues {
    sessionEventProperties: Record<string, any> | null
    sessionEventPropertiesLoading: boolean
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface replayCaptureDiagnosticsPanelLogicActions {
    loadSessionEventProperties: (_: any) => any
    loadSessionEventPropertiesFailure: (
        error: string,
        errorObject?: any
    ) => {
        error: string
        errorObject?: any
    }
    loadSessionEventPropertiesSuccess: (
        sessionEventProperties: Record<string, any> | null,
        payload?: any
    ) => {
        sessionEventProperties: Record<string, any> | null
        payload?: any
    }
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface replayCaptureDiagnosticsPanelLogicMeta {
    key: string
}

export type replayCaptureDiagnosticsPanelLogicType = MakeLogicType<
    replayCaptureDiagnosticsPanelLogicValues,
    replayCaptureDiagnosticsPanelLogicActions,
    ReplayCaptureDiagnosticsPanelLogicProps,
    replayCaptureDiagnosticsPanelLogicMeta
>

export const replayCaptureDiagnosticsPanelLogic = kea<replayCaptureDiagnosticsPanelLogicType>([
    path(['scenes', 'session-recordings', 'components', 'replayCaptureDiagnosticsPanelLogic']),
    props({} as ReplayCaptureDiagnosticsPanelLogicProps),
    key((props) => props.sessionId),
    defaults({
        sessionEventProperties: null as Record<string, any> | null,
    }),
    lazyLoaders(({ props }) => ({
        sessionEventProperties: {
            loadSessionEventProperties: async (_, breakpoint): Promise<Record<string, any> | null> => {
                const result = await api.recordings.getCaptureDiagnostics(props.sessionId)
                breakpoint()
                return result.properties ?? null
            },
        },
    })),
])