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.

fix(exports): stop the metric image export squeezing its chart flat (#74800)

Sam Pennington320e29f1f736
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 5ce90eb266a3..58e5f5a7bd74 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2285,9 +2285,13 @@ snapshots:
exporter-other--sql-insight-no-results--light:
hash: v1.k794b7964.61d2bc9e86a0f575ed9653d7a8591219e402a06f6e53021eee8efcc7eb87d644._4TYA0cVTREdm7CEPknXXiutaQB4rZKngjK1MrAGE-Y
exporter-trends--trends-metric-insight--dark:
- hash: v1.k794b7964.cf3fe4db037b81c1da572706946b49e6c92aa70951bce07ebba3d7d7dd4befb0.3brUeK-WhFsdEAxR7gWVWAsrkVwv3C7Me4MiX7CHHvM
+ hash: v1.k794b7964.b98d85ed23d2217983a6af3c3e26c619eb1b127740286c0c2fcde8b9a9061f80.jy33WcgkTnYivlpUdM1G7XUd0K1l9VFyA4F0jbuixAQ
exporter-trends--trends-metric-insight--light:
- hash: v1.k794b7964.312a58724b4972bd2eb142ff2591025408edf13663b9c1d1fa77a14c68e7924a.F2Yl15jP_qWWs0Yamx5tPRz8ZLTzbMtn71HB2C0rxjU
+ hash: v1.k794b7964.3ac22e9e0970b0aad2dddc54f0b992090749e747f65456759bd78b54463b02e3.U4LTvYbvCJX3WP5Wh8ipV1VNcPzjAaJxYKBxh15x5Sg
+ exporter-trends--trends-metric-insight-long-description--dark:
+ hash: v1.k794b7964.a3e948cac8df850d07f19453d3673b3af964de60c035783828d40dbc07c9510c.Ug8lyaKpYbYf7q2FUzYtcrs3mqizSPkwqYGIWEUuMyY
+ exporter-trends--trends-metric-insight-long-description--light:
+ hash: v1.k794b7964.7ef74ec9ef5f02c0b687455fb81b8c6a9759ad706a9e737c0217d8e8ed630697.Dh8uWZrhEunDTpFMVH0tCoUqLSHYPtKoMe8T0T4TUC0
exporter-trends--trends-pie-insight--dark:
hash: v1.k794b7964.e5e7c9e36ec62680c87794152b474fcd8ae0061bc7e8145416512ee745e05d21.uVeV9IUiset22yU0BtIEzyXgbkadZEoT1M-mMbalaVw
exporter-trends--trends-pie-insight--light:
diff --git a/frontend/src/exporter/ExportedInsight/ExportedInsight.scss b/frontend/src/exporter/ExportedInsight/ExportedInsight.scss
index 99ce8906ad2a..6159997bf469 100644
--- a/frontend/src/exporter/ExportedInsight/ExportedInsight.scss
+++ b/frontend/src/exporter/ExportedInsight/ExportedInsight.scss
@@ -32,21 +32,16 @@
border-radius: 0 0 var(--radius) var(--radius);
}
- // A metric card renders best as a wide 2:1 card — header plus chart, proportioned like a dashboard
- // tile — rather than stretched to the full exporter height. The aspect-ratio derives the card's
- // height from the export width, and the content flex-fills the space under the header so the
- // filling sparkline hugs the bottom of the card.
+ // A metric renders as a dashboard-tile-like card — header plus chart band — rather than stretched to
+ // the full exporter height. The ratio sits on the band, not the card, so a tall header (a long
+ // description wrapping over several lines) grows the card instead of squeezing the chart to a sliver.
&--metric {
flex: 0 0 auto;
height: auto;
- aspect-ratio: 2 / 1;
.ExportedInsight__content {
- flex: 1 1 0;
-
- // `min-height: 0` overrides the flex-item `auto` floor so the aspect-ratio governs the card's
- // height instead of the content's min-content height stretching the card taller.
- min-height: 0;
+ flex: 0 0 auto;
+ aspect-ratio: 2 / 1;
}
// The quill sparkline shifts itself down 6px (`top-[6px]`) so its zero-baseline — drawn 6px
diff --git a/frontend/src/exporter/stories/ExporterTrends.stories.tsx b/frontend/src/exporter/stories/ExporterTrends.stories.tsx
index d3a1fce7d894..40ac723e2d75 100644
--- a/frontend/src/exporter/stories/ExporterTrends.stories.tsx
+++ b/frontend/src/exporter/stories/ExporterTrends.stories.tsx
@@ -146,8 +146,8 @@ export const TrendsNumberInsight: Story = {
/** The Metric sparkline is SVG/canvas, so it captures cleanly and guards against the exported card
* collapsing to a fixed-height sparkline that floats mid-card instead of filling and hugging the bottom.
* The fixed-width wrapper mirrors the backend's 600px metric export viewport — the test runner's
- * shrink-to-fit root would otherwise collapse the aspect-ratio card to its text width, leaving the
- * filling sparkline no height at all. */
+ * shrink-to-fit root would otherwise collapse the chart band to its text width, leaving the filling
+ * sparkline no height at all. */
export const TrendsMetricInsight: Story = {
args: { insight: __trendsMetric as any },
decorators: [(StoryFn): JSX.Element => <div className="w-[600px]">{StoryFn()}</div>],
@@ -160,6 +160,28 @@ export const TrendsMetricInsight: Story = {
},
}
+/** A long description pushes the metric card's header tall. The card has to grow to keep the chart band
+ * at full height — a ratio on the card itself squeezed the sparkline to a sliver that spilled past the
+ * bottom edge. */
+export const TrendsMetricInsightLongDescription: Story = {
+ args: {
+ insight: {
+ ...(__trendsMetric as any),
+ name: 'Scanners created — total',
+ description:
+ 'Total Replay Vision scanners created (autocaptured "Create scanner" clicks, data-attr=vision-editor-save). Last 90 days, excludes internal/test accounts.',
+ },
+ },
+ decorators: [(StoryFn): JSX.Element => <div className="w-[600px]">{StoryFn()}</div>],
+ parameters: {
+ mockDate: '2022-04-01',
+ testOptions: {
+ snapshotBrowsers: ['chromium'],
+ waitForSelector: '.Metric canvas',
+ },
+ },
+}
+
export const TrendsTableInsight: Story = {
args: { insight: __trendsTable as any },
}
diff --git a/products/exports/backend/tasks/image_exporter.py b/products/exports/backend/tasks/image_exporter.py
index e207e65f07e7..e1ecfad21e9e 100644
--- a/products/exports/backend/tasks/image_exporter.py
+++ b/products/exports/backend/tasks/image_exporter.py
@@ -159,8 +159,8 @@ def _insight_query_screenshot_width(query: dict) -> ScreenWidth:
layout) grow vertically, not horizontally. Small funnels are constrained later by the
width measurement. The higher the number, the more RAM the Chromium driver needs.
- A metric renders as a wide 2:1 card whose height derives from the viewport width, so a
- narrower viewport keeps it at dashboard-tile size instead of a 400px-tall banner.
+ A metric renders as a card whose height derives from the viewport width, so a narrower
+ viewport keeps it at dashboard-tile size instead of a 400px-tall banner.
Mirrors the frontend's check (InsightVizNode wrapper required), which gates the
metric card CSS — a bare TrendsQuery gets neither, so it must keep the default viewport.
"""