: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(engineering-analytics): horizontal log lead time boxes (#101231)
Julian Bez7af12c98c59f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex acc7dfe9ef13..414079e7880d 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7453,13 +7453,13 @@ snapshots:scenes-app-discussions--threads--light:hash: v1.k794b7964.28ac830bf83be5cbb6d7a397d67c9b9c61711904a822de38402b82220b0f7a49.7wENY7hvo1-qAJwq5fcsvKGJsfRAF_vDkpnM8iqFZccscenes-app-engineering-analytics-author--author--dark:- hash: v1.k794b7964.8520adcd3ce8680c16613e32f5d64566355a27bade6dfc442e19be47be8bfbb2._hZPqT7OcEhiSKDedzXlSpJpzb8jceYtcwwSyqB801A+ hash: v1.k794b7964.1d3d5ad4384d1455db661057f83f2981deeac486db482f18fda2ffc4831a0d64.KlfXRXFvKylYGb6tLKz5vnU1IPJ2l0AA7rrBFwIYnOEscenes-app-engineering-analytics-author--author--light:- hash: v1.k794b7964.ad664cfe6903ddfe5bdc7bb15c1817088b89b858eb6e781d2eaa93bfcd6bd74d.KnT1_QSVMPtOR_dHTGSxaXVUDLtkjWcvqfWY_Dy3w3U+ hash: v1.k794b7964.11b4fa1297a2fe26ca31fcbfd078f2eb026dc52d8b9feae8e4b01dd5b5e344d3.ZossZ7M9N-OOLyssbqwNNj6wNb_3-TKgEcxgAIPk0TMscenes-app-engineering-analytics-author--author-narrow--dark:- hash: v1.k794b7964.3bca0cb64645bdd887796aa0ccdc1e4f38ae3e91f6d536dd540b83fd72a3b91f.oXXTVcvEsGIrPvGCG0HR1FqpAwid9TXkQpa00ScMiYM+ hash: v1.k794b7964.61586233f0d99a295503bc466f739ed4b76043ab9bbf39a8c40c643aff3f5eb4.hAIwpK76FMPr3nZ4p2ZN65DyJYuPpaOMSBt7raTwUVUscenes-app-engineering-analytics-author--author-narrow--light:- hash: v1.k794b7964.29c171a5bdbe8125b19c449a55fef1ad52b249d6361d5785929473c53437208f.P_bjFcBIITGAsCj_c-Fo6jdxvgMJiKi1xqwS6x0X0uo+ hash: v1.k794b7964.3d7a289e93726190975964c1a0c13b3aff934688510a92d41c36a61c38e28de0.zbZRiTmhxMUFC_68LYnMHJZ6hn8gOtdJWHLWzTh09yMscenes-app-engineering-analytics-author--author-without-reviews-or-deploys--dark:hash: v1.k794b7964.079499fddb5d88126b2fc93501d215aad1e361fd0622ec9e06aae82b0f81b1b3.X1gQOWOwe8W2YokDSb50W_fa0YC5LU0KyhI3S0wnsxsscenes-app-engineering-analytics-author--author-without-reviews-or-deploys--light:@@ -7496,6 +7496,10 @@ snapshots:hash: v1.k794b7964.a88a986e975778b0ad232c7e8f75211b0d66acb126082b2f781fd9d5641ff28d.P4_7HWOcC-Z8pGr_2GTGkAc_fzupx_TRaZdlauEmVQEscenes-app-engineering-analytics-lead-time-box-plot--default--light:hash: v1.k794b7964.040d7b8b88503881e75c0e7d6c0bc8588c6096f1315f75b5071c2721d13f567a.jAkjFsaMTKwsbxZsBriJ6JoPzwYGQSXgG9ERQd0H06E+ scenes-app-engineering-analytics-lead-time-box-plot--horizontal-log-scale--dark:+ hash: v1.k794b7964.df91ee73eb9c7f851f7c987ff3d06f975e6187267e898a2a8b3a3a1f898dee7a.ieTfJEFpcuil3f4uqJ1jp_tg64ChsB81jLF3Rf9SeFM+ scenes-app-engineering-analytics-lead-time-box-plot--horizontal-log-scale--light:+ hash: v1.k794b7964.bc3a9455717626ef2f9541e03740bd0027c89139cd54ba4eb57a883d0e222667.OlAdmRvrHHSpGH8a2jHqV60Z957X8hIrNlcY9Duvv9Ascenes-app-engineering-analytics-repo-overview--repo-overview--dark:hash: v1.k794b7964.1a470083e7a94ff46652f4368277eae5d35c927d65b58685e43ce34881e1e728.SEm3E8XvqrTHtJNRhVGX-9aaaw6xdWyzTNb_mw6c380scenes-app-engineering-analytics-repo-overview--repo-overview--light:diff --git a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsx b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsxindex 007c3158cc0e..369f3619bbbe 100644--- a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsx+++ b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsx@@ -78,3 +78,16 @@ export default metatype Story = StoryObj<typeof meta>export const Default: Story = {}++export const HorizontalLogScale: Story = {+ args: {+ buckets: [+ bucket('This author', 12, [900, 2700, 7200, 21000, 18000, 259200]),+ bucket('Repo', 340, [600, 3600, 14400, 36000, 43200, 604800]),+ ],+ horizontal: true,+ logScale: true,+ excludeOutliers: true,+ className: 'h-28',+ },+}diff --git a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsx b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsxindex ba7caa622d1e..c6daf94b8a89 100644--- a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsx+++ b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsx@@ -30,6 +30,10 @@ export interface LeadTimeBoxPlotProps {formatSeconds: (seconds: number) => string/** Draw the whiskers at p5/p95 instead of min/max, so one extreme PR can't flatten the boxes. */excludeOutliers?: boolean+ /** List the buckets down the side with the time axis along the bottom. Suits a few buckets. */+ horizontal?: boolean+ /** Put the time axis on a log scale, so minutes and days both stay readable on one axis. */+ logScale?: booleandataAttr: stringclassName?: string}@@ -39,6 +43,9 @@ interface BucketMeta {counts: number[]}+/** The six numbers a box draws, for the checks that have to cover all of them. */+const BOX_STATS = ['min', 'p25', 'median', 'mean', 'p75', 'max'] as const+function toDatum(bucket: BoxPlotBucket, excludeOutliers: boolean): BoxPlotDatum | null {if (bucket.count === 0 ||@@ -68,7 +75,7 @@ function toDatum(bucket: BoxPlotBucket, excludeOutliers: boolean): BoxPlotDatum* One box-and-whisker per bucket (quill BoxPlot): whisker min→max, box p25→p75, a median line* and a mean dot, on a shared seconds scale. Empty buckets stay empty slots so a quiet stretch* reads as "nothing deployed", not missing data. One lead-time stage per instance; the Health- * tab stacks three so the stages compare bucket by bucket.+ * tab stacks three vertical ones so the stages compare bucket by bucket.*/export function LeadTimeBoxPlot({seriesKey,@@ -76,6 +83,8 @@ export function LeadTimeBoxPlot({buckets,formatSeconds,excludeOutliers = false,+ horizontal = false,+ logScale = false,dataAttr,className,}: LeadTimeBoxPlotProps): JSX.Element {@@ -92,6 +101,20 @@ export function LeadTimeBoxPlot({],[seriesKey, seriesLabel, buckets, excludeOutliers])+ const hasZeroDuration = useMemo(+ () => series[0].data.some((datum) => datum != null && BOX_STATS.some((stat) => datum[stat] <= 0)),+ [series]+ )+ const config = useMemo(+ () => ({+ yTickFormatter: formatSeconds,+ axisOrientation: horizontal ? ('horizontal' as const) : ('vertical' as const),+ // A log axis has no zero: the scale clamps a zero-second stat onto the axis floor, where+ // it would read as a real duration. Such a bucket falls back to the linear axis.+ yScaleType: logScale && !hasZeroDuration ? ('log' as const) : ('linear' as const),+ }),+ [formatSeconds, horizontal, logScale, hasZeroDuration]+ )return (// The chart's root is a `flex-1` child, so the sized wrapper must be a flex column —// in a plain block parent the canvas measures 0px tall and paints nothing.@@ -100,7 +123,7 @@ export function LeadTimeBoxPlot({series={series}labels={labels}theme={theme}- config={{ yTickFormatter: formatSeconds }}+ config={config}dataAttr={dataAttr}tooltip={(ctx) => (<BucketTooltipdiff --git a/products/engineering_analytics/frontend/components/LeadTimeComparisonCard.tsx b/products/engineering_analytics/frontend/components/LeadTimeComparisonCard.tsxindex 6522af80b088..bfa1f521adf9 100644--- a/products/engineering_analytics/frontend/components/LeadTimeComparisonCard.tsx+++ b/products/engineering_analytics/frontend/components/LeadTimeComparisonCard.tsx@@ -62,7 +62,8 @@ export function LeadTimeComparisonCard({</div><div>Box: the middle half of the pull requests. Line: median. Dot: mean. Whiskers: 5th to- 95th percentile.+ 95th percentile. The time axis is logarithmic, so a few very slow pull requests don't+ squash the rest.</div><div>Deploy failure share and recovery are not shown: one deploy ships many pull requests, so@@ -114,6 +115,9 @@ export function LeadTimeComparisonCard({]}formatSeconds={compactAgeLabel}excludeOutliers+ horizontal+ logScale+ className="h-28"dataAttr={`engineering-analytics-delivery-${stage.key}`}/></div>