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.

feat(heatmaps): surface a notice when an iframe heatmap is height-capped (#70754)

Xander937effaf820a
diff --git a/frontend/src/lib/components/heatmaps/heatmapDataLogic.ts b/frontend/src/lib/components/heatmaps/heatmapDataLogic.ts
index 101ac5be65d3..facf01af4cf0 100644
--- a/frontend/src/lib/components/heatmaps/heatmapDataLogic.ts
+++ b/frontend/src/lib/components/heatmaps/heatmapDataLogic.ts
@@ -36,6 +36,10 @@ import type { heatmapDataLogicType } from './heatmapDataLogicType'
// The endpoint defaults to a bounded page for API callers; the overlay renders every point.
const UNBOUNDED_HEATMAP_LIMIT = 0
+// Limit canvas height to prevent browser freezing with heatmap.js
+// Large canvases (e.g., 24000px) cause heatmap.js to block the main thread
+export const MAX_HEATMAP_HEIGHT = 8000
+
export const HEATMAP_COLOR_PALETTE_OPTIONS: LemonSelectOption<string>[] = [
{ value: 'default', label: 'Default (multicolor)' },
{ value: 'red', label: 'Red (monocolor)' },
@@ -437,9 +441,6 @@ export const heatmapDataLogic = kea<heatmapDataLogicType>([
heightOverride: [
(s) => [s.maxYFromEvents, s.windowHeight],
(maxYFromEvents: number, windowHeight: number): number => {
- // Limit canvas height to prevent browser freezing with heatmap.js
- // Large canvases (e.g., 24000px) cause heatmap.js to block the main thread
- const MAX_HEATMAP_HEIGHT = 8000
if (maxYFromEvents > 0) {
const calculatedHeight = Math.ceil((maxYFromEvents + 100) / 100) * 100
return Math.min(Math.max(calculatedHeight, windowHeight), MAX_HEATMAP_HEIGHT)
@@ -448,6 +449,18 @@ export const heatmapDataLogic = kea<heatmapDataLogicType>([
},
],
+ // True when captured points extend past the rendered canvas cap, so the overlay is clipped
+ isHeightCapped: [
+ (s) => [s.maxYFromEvents],
+ (maxYFromEvents: number): boolean => {
+ if (maxYFromEvents <= 0) {
+ return false
+ }
+ const calculatedHeight = Math.ceil((maxYFromEvents + 100) / 100) * 100
+ return calculatedHeight > MAX_HEATMAP_HEIGHT
+ },
+ ],
+
// the one place the area bounds filter applies, so rendering (heatmapJsData) and
// click-to-view-events hit testing can't disagree about which points exist
filteredHeatmapElements: [
diff --git a/frontend/src/scenes/heatmaps/components/HeatmapsBrowser.tsx b/frontend/src/scenes/heatmaps/components/HeatmapsBrowser.tsx
index ea50835d68e4..d830dd9e9b49 100644
--- a/frontend/src/scenes/heatmaps/components/HeatmapsBrowser.tsx
+++ b/frontend/src/scenes/heatmaps/components/HeatmapsBrowser.tsx
@@ -9,7 +9,7 @@ import { pngHoggie } from 'lib/brand/hoggies'
import { AuthorizedUrlList } from 'lib/components/AuthorizedUrlList/AuthorizedUrlList'
import { AuthorizedUrlListType, appEditorUrl } from 'lib/components/AuthorizedUrlList/authorizedUrlListLogic'
import { exportsLogic } from 'lib/components/ExportButton/exportsLogic'
-import { heatmapDataLogic } from 'lib/components/heatmaps/heatmapDataLogic'
+import { heatmapDataLogic, MAX_HEATMAP_HEIGHT } from 'lib/components/heatmaps/heatmapDataLogic'
import { dayjs } from 'lib/dayjs'
import { useResizeObserver } from 'lib/hooks/useResizeObserver'
import { IconOpenInNew } from 'lib/lemon-ui/icons'
@@ -352,7 +352,8 @@ export function HeatmapsBrowser(): JSX.Element {
const logic = heatmapsBrowserLogic({ iframeRef })
const clickmapLogic = recordingClickmapLogic({ iframeRef })
- const { displayUrl, isBrowserUrlAuthorized, hasValidReplayIframeData, isBrowserUrlValid } = useValues(logic)
+ const { displayUrl, isBrowserUrlAuthorized, hasValidReplayIframeData, isBrowserUrlValid, isHeightCapped } =
+ useValues(logic)
const { clickmapAvailable } = useValues(clickmapLogic)
return (
@@ -371,6 +372,12 @@ export function HeatmapsBrowser(): JSX.Element {
/>
<LemonDivider className="my-4" />
<div className="relative border">
+ {isHeightCapped && (
+ <LemonBanner type="info">
+ This heatmap is capped at {MAX_HEATMAP_HEIGHT.toLocaleString()}px tall to keep rendering
+ fast, so data below that point isn't shown.
+ </LemonBanner>
+ )}
{hasValidReplayIframeData ? (
<FixedReplayHeatmapBrowser iframeRef={iframeRef} />
) : displayUrl ? (
diff --git a/frontend/src/scenes/heatmaps/components/heatmapsBrowserLogic.ts b/frontend/src/scenes/heatmaps/components/heatmapsBrowserLogic.ts
index 47f7da82a6fa..7b5039486b32 100644
--- a/frontend/src/scenes/heatmaps/components/heatmapsBrowserLogic.ts
+++ b/frontend/src/scenes/heatmaps/components/heatmapsBrowserLogic.ts
@@ -67,6 +67,7 @@ export const heatmapsBrowserLogic = kea<heatmapsBrowserLogicType>([
'hrefMatchType',
'widthOverride',
'heightOverride',
+ 'isHeightCapped',
'commonFilters',
'heatmapFilters',
'heatmapFixedPositionMode',
diff --git a/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapScene.tsx b/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapScene.tsx
index 72b40ad0d20c..9ad9313336e5 100644
--- a/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapScene.tsx
+++ b/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapScene.tsx
@@ -8,6 +8,7 @@ import { LemonTag, Spinner } from '@posthog/lemon-ui'
import { pngHoggie } from 'lib/brand/hoggies'
import { appEditorUrl } from 'lib/components/AuthorizedUrlList/authorizedUrlListLogic'
import { HeatmapCanvas } from 'lib/components/heatmaps/HeatmapCanvas'
+import { MAX_HEATMAP_HEIGHT } from 'lib/components/heatmaps/heatmapDataLogic'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner/LemonBanner'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LoadingBar } from 'lib/lemon-ui/LoadingBar'
@@ -41,6 +42,7 @@ export function HeatmapScene({ id }: { id: string }): JSX.Element {
desiredNumericWidth,
effectiveWidth,
scalePercent,
+ isHeightCapped,
} = useValues(logic)
const {
setName,
@@ -141,6 +143,12 @@ export function HeatmapScene({ id }: { id: string }): JSX.Element {
<HeatmapHeader />
<FilterPanel captureMethod={type} onCaptureMethodChange={changeCaptureMethod} />
<SceneDivider />
+ {isHeightCapped && (
+ <LemonBanner type="info" className="mb-2">
+ This heatmap is capped at {MAX_HEATMAP_HEIGHT.toLocaleString()}px tall to keep rendering fast,
+ so data below that point isn't shown.
+ </LemonBanner>
+ )}
<div ref={measureRef} className="w-full">
<div
className="border mx-auto bg-surface-primary rounded-lg"
diff --git a/frontend/src/scenes/heatmaps/scenes/heatmap/heatmapLogic.ts b/frontend/src/scenes/heatmaps/scenes/heatmap/heatmapLogic.ts
index 717bc49914a2..bbf0a0eb403a 100644
--- a/frontend/src/scenes/heatmaps/scenes/heatmap/heatmapLogic.ts
+++ b/frontend/src/scenes/heatmaps/scenes/heatmap/heatmapLogic.ts
@@ -62,6 +62,7 @@ export const heatmapLogic = kea<heatmapLogicType>([
'commonFilters',
'widthOverride',
'heightOverride',
+ 'isHeightCapped',
],
],
actions: [