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.1 KB
Raw Blame
import { useValues } from 'kea'

import { HEATMAP_LOADING_DEBOUNCE_MS, heatmapDataLogic } from 'lib/components/heatmaps/heatmapDataLogic'
import { useDebouncedValue } from 'lib/hooks/useDebouncedValue'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'

export function HeatmapLoadingInfo({
    context,
    exportToken,
}: {
    context: 'in-app' | 'toolbar'
    exportToken?: string
}): JSX.Element | null {
    const { rawHeatmapLoading } = useValues(heatmapDataLogic({ context, exportToken }))
    const loading = useDebouncedValue(rawHeatmapLoading, HEATMAP_LOADING_DEBOUNCE_MS)

    if (!loading || context === 'toolbar' || exportToken || inStorybook() || inStorybookTestRunner()) {
        return null
    }

    return (
        <div className="absolute inset-0 z-20 flex items-start justify-center pointer-events-none">
            <div className="flex items-center gap-2 mt-8 px-3 py-2 border rounded bg-surface-primary shadow-md font-semibold">
                <Spinner />
                Loading heatmap data
            </div>
        </div>
    )
}