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.3 KB
Raw Blame
import { Collapsible } from 'lib/ui/Collapsible/Collapsible'

import { ErrorTrackingStackFrame, ErrorTrackingStackFrameContext, ErrorTrackingStackFrameRecord } from '../types'
import { FrameContext } from './FrameContext'
import { getFrameLanguage } from './frameLanguage'
import { FrameVariables } from './FrameVariables'

export interface CollapsibleFrameContentProps {
    frame: ErrorTrackingStackFrame
    record?: ErrorTrackingStackFrameRecord

    onFrameContextClick?: (context: ErrorTrackingStackFrameContext, event: React.MouseEvent<HTMLDivElement>) => void
}

export function CollapsibleFrameContent({
    frame,
    record,
    onFrameContextClick,
}: CollapsibleFrameContentProps): JSX.Element | null {
    const { code_variables } = frame
    if (!record || !record.context) {
        return null
    }
    return (
        <Collapsible.Panel className="border-t-[color:var(--frame-border,var(--color-border-primary))]">
            <div onClick={(e) => onFrameContextClick?.(record.context!, e)}>
                <FrameContext context={record.context} language={getFrameLanguage(frame)} />
                {code_variables && Object.keys(code_variables).length > 0 && (
                    <FrameVariables variables={code_variables} />
                )}
            </div>
        </Collapsible.Panel>
    )
}