: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
fix(today): make pulse tooltips opaque and link key metric tiles (#118705)
Shy Alter0ea1ee11c1fe
diff --git a/frontend/src/scenes/project-homepage/today/Today.scss b/frontend/src/scenes/project-homepage/today/Today.scssindex 82af80222866..fc768898731a 100644--- a/frontend/src/scenes/project-homepage/today/Today.scss+++ b/frontend/src/scenes/project-homepage/today/Today.scss@@ -201,9 +201,17 @@ html[data-today-transition]::view-transition-new(root) {white-space: nowrap;}-.TodayPulse__link:hover {- color: var(--today-ink);- text-decoration: underline;+.TodayPulse__link {+ display: flex;+ flex-direction: column;+ gap: 2px;+ min-width: 0;+ color: inherit;++ &:hover .TodayPulse__name {+ color: var(--today-ink);+ text-decoration: underline;+ }}.TodayPulse__row {diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsxindex 115d6a517aed..4ae3fa981933 100644--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx@@ -555,6 +555,14 @@ const PERIOD_STARTS = (count: number, unit: 'day' | 'week'): string[] =>.format('YYYY-MM-DD'))+const KEY_METRIC_URL = (event: string): string =>+ `/insights/new#q=${encodeURIComponent(+ JSON.stringify({+ kind: 'InsightVizNode',+ source: { kind: 'TrendsQuery', series: [{ kind: 'EventsNode', event }] },+ })+ )}`+const HIGHLIGHTS: HighlightsApi = {status: 'ready',generated_at: '2026-09-28T18:00:00Z',@@ -581,7 +589,7 @@ const HIGHLIGHTS: HighlightsApi = {change_pct: 18.1,series: DAILY(170, 7),interval: 'day',- url: null,+ url: KEY_METRIC_URL('$signup'),value_format: null,period_starts: PERIOD_STARTS(28, 'day'),},@@ -593,7 +601,7 @@ const HIGHLIGHTS: HighlightsApi = {change_pct: -3.1,series: DAILY(48, 5),interval: 'day',- url: null,+ url: KEY_METRIC_URL('payment_succeeded'),value_format: null,period_starts: PERIOD_STARTS(28, 'day'),},@@ -605,7 +613,7 @@ const HIGHLIGHTS: HighlightsApi = {change_pct: 1.6,series: DAILY(2600, 11),interval: 'day',- url: null,+ url: KEY_METRIC_URL('$pageview'),value_format: null,period_starts: PERIOD_STARTS(28, 'day'),},diff --git a/frontend/src/scenes/project-homepage/today/TodayPulse.tsx b/frontend/src/scenes/project-homepage/today/TodayPulse.tsxindex cecf3471100c..2fb033acebf8 100644--- a/frontend/src/scenes/project-homepage/today/TodayPulse.tsx+++ b/frontend/src/scenes/project-homepage/today/TodayPulse.tsx@@ -74,22 +74,12 @@ export function TodayPulse({ metrics }: { metrics: HighlightMetricApi[] }): JSX.return (<ul className="TodayPulse" aria-label="Key numbers, against the period before">{metrics.map((metric) => {- const tone = metric.key.startsWith('insight:') ? 'neutral' : metricTone(metric.change_pct, metric.value)+ const isInsight = metric.key.startsWith('insight:')+ const tone = isInsight ? 'neutral' : metricTone(metric.change_pct, metric.value)const formatValue = metricFormatter(metric, baseCurrency)- return (- <li key={metric.key} className="TodayPulse__metric">- {metric.url ? (- <LinkPrimitive- to={metric.url}- className="TodayPulse__name TodayPulse__link"- title={metric.name}- data-attr="today-pulse-insight"- >- {metric.name}- </LinkPrimitive>- ) : (- <span className="TodayPulse__name">{metric.name}</span>- )}+ const content = (+ <>+ <span className="TodayPulse__name">{metric.name}</span><span className="TodayPulse__row"><span className="TodayPulse__value" translate="no">{metric.value_format ? formatValue(metric.value) : todayNumber(metric.value)}@@ -105,6 +95,22 @@ export function TodayPulse({ metrics }: { metrics: HighlightMetricApi[] }): JSX./></span></span>+ </>+ )+ return (+ <li key={metric.key} className="TodayPulse__metric">+ {metric.url ? (+ <LinkPrimitive+ to={metric.url}+ className="TodayPulse__link"+ title={metric.name}+ data-attr={isInsight ? 'today-pulse-insight' : 'today-pulse-key-metric'}+ >+ {content}+ </LinkPrimitive>+ ) : (+ content+ )}</li>)})}diff --git a/frontend/src/scenes/project-homepage/today/TodaySparkline.tsx b/frontend/src/scenes/project-homepage/today/TodaySparkline.tsxindex 320de305587d..85c75e8dc165 100644--- a/frontend/src/scenes/project-homepage/today/TodaySparkline.tsx+++ b/frontend/src/scenes/project-homepage/today/TodaySparkline.tsx@@ -7,6 +7,7 @@ import {type LineChartConfig,type Series,type TooltipContext,+ TooltipSurface,} from '@posthog/quill-charts'import { useChartConfig, useChartTheme } from 'lib/charts/hooks'@@ -84,10 +85,10 @@ export function TodaySparkline({return null}return (- <div className="rounded-md border border-border bg-background px-2 py-1 shadow-sm">- <div className="text-xs text-muted-foreground">{context.label}</div>- <div className="text-xs font-medium tabular-nums text-foreground">{formatValue(value)}</div>- </div>+ <TooltipSurface>+ <div className="opacity-70">{context.label}</div>+ <div className="font-medium tabular-nums">{formatValue(value)}</div>+ </TooltipSurface>)},[formatValue]diff --git a/products/customer_analytics/backend/facade/contracts.py b/products/customer_analytics/backend/facade/contracts.pyindex 6e935fcec9c4..b3fc486cf229 100644--- a/products/customer_analytics/backend/facade/contracts.py+++ b/products/customer_analytics/backend/facade/contracts.py@@ -1513,3 +1513,4 @@ class KeyMetric:daily: list[tuple[date, float]]this_week: floatlast_week: float+ node: dict[str, Any]diff --git a/products/customer_analytics/backend/logic/key_metrics.py b/products/customer_analytics/backend/logic/key_metrics.pyindex 4aa0e790ff26..f15558ca3fbd 100644--- a/products/customer_analytics/backend/logic/key_metrics.py+++ b/products/customer_analytics/backend/logic/key_metrics.py@@ -69,6 +69,12 @@ def _anchored(filters: Any, team: Team, anchor: datetime) -> Any:return anchored+def _anchored_node(node: dict[str, Any], team: Team, anchor: datetime) -> dict[str, Any]:+ if not node.get("properties"):+ return node+ return {**node, "properties": _anchored(node["properties"], team, anchor)}++def _condition(node: dict[str, Any], team: Team, anchor: datetime) -> ast.Expr:if node["kind"] == "ActionsNode":match = parse_expr("matchesAction({id})", placeholders={"id": ast.Constant(value=int(node["id"]))})@@ -169,6 +175,7 @@ def key_metrics(team: Team, user: User) -> list[KeyMetric] | None:daily=points,this_week=this_week,last_week=last_week,+ node=_anchored_node(nodes[key], team, anchor),))return metricsdiff --git a/products/customer_analytics/backend/test/test_key_metrics.py b/products/customer_analytics/backend/test/test_key_metrics.pyindex fcc23eca0afe..63ec7b6f61ec 100644--- a/products/customer_analytics/backend/test/test_key_metrics.py+++ b/products/customer_analytics/backend/test/test_key_metrics.py@@ -170,4 +170,8 @@ class TestKeyMetrics(ClickhouseTestMixin, BaseTest):):second = get_key_metrics(team=self.team, user=self.user)- self.assertEqual((first is not None, second == first), (True, reused))+ assert first is not None+ self.assertEqual(+ (first[0].node["properties"][0]["value"], second == first),+ ("2026-02-23 00:00:00", reused),+ )diff --git a/products/today/backend/logic/highlight_sources/key_metrics.py b/products/today/backend/logic/highlight_sources/key_metrics.pyindex 59395dd0879d..e4b2f372eafd 100644--- a/products/today/backend/logic/highlight_sources/key_metrics.py+++ b/products/today/backend/logic/highlight_sources/key_metrics.py@@ -1,3 +1,6 @@+import json+from urllib.parse import quote+from products.customer_analytics.backend.facade.api import get_key_metricsfrom products.customer_analytics.backend.facade.contracts import KeyMetric@@ -13,6 +16,7 @@ KEY_METRIC_DAY = {}KEY_METRIC_DAY_DETAIL = "{now} yesterday · {usual} on an average {weekday}"KEY_METRIC_DAY_DETAIL_WEEK = "{now} yesterday · {usual} a day over the week before"+PULSE_DAYS = 28def find(context: Context) -> Found:@@ -31,10 +35,28 @@ def _tile(metric: KeyMetric) -> contracts.HighlightMetric:value=metric.this_week,unit=HighlightUnit.PEOPLE if metric.people else HighlightUnit.EVENTS,change_pct=round((metric.this_week / metric.last_week - 1) * 100, 1) if metric.last_week else None,- series=[v for _, v in metric.daily[-28:]],+ series=[v for _, v in metric.daily[-PULSE_DAYS:]],+ url=_url(metric),)+def _url(metric: KeyMetric) -> str | None:+ days = [day for day, _ in metric.daily[-PULSE_DAYS:]]+ if not days:+ return None+ query = {+ "kind": "InsightVizNode",+ "source": {+ "kind": "TrendsQuery",+ "series": [{**metric.node, "math": "dau" if metric.people else "total"}],+ "interval": "day",+ "dateRange": {"date_from": days[0].isoformat(), "date_to": days[-1].isoformat()},+ "filterTestAccounts": True,+ },+ }+ return f"/insights/new#q={quote(json.dumps(query, separators=(',', ':')))}"++def _same_weekday(context: Context, metric: KeyMetric) -> Candidate | None:detections, _ = detect(metric.daily, "day", context.today)found = next((d for d in detections if d.kind == "same_weekday"), None)@@ -51,6 +73,7 @@ def _same_weekday(context: Context, metric: KeyMetric) -> Candidate | None:detail=(KEY_METRIC_DAY_DETAIL if found.same_weekday else KEY_METRIC_DAY_DETAIL_WEEK).format(now=exact(found.now or 0), usual=exact(found.usual or 0, 0), weekday=found.weekday),+ url=_url(metric),series=[v for _, v in metric.daily[-14:]],)diff --git a/products/today/backend/presentation/serializers.py b/products/today/backend/presentation/serializers.pyindex 20fd321dd0e1..d6d2d0867c15 100644--- a/products/today/backend/presentation/serializers.py+++ b/products/today/backend/presentation/serializers.py@@ -294,7 +294,8 @@ class HighlightMetricSerializer(DataclassSerializer):choices=HighlightInterval.choices, help_text="What one value in `series` covers: a day, a week or a month.")url = serializers.CharField(- allow_null=True, help_text="Path of the insight the metric comes from. Null for a key metric."+ allow_null=True,+ help_text="Path of the insight the metric comes from. For a key metric, a new trends insight of the same days.",)value_format = HighlightValueFormatSerializer(allow_null=True,diff --git a/products/today/backend/tests/test_highlight_key_metrics.py b/products/today/backend/tests/test_highlight_key_metrics.pyindex 75652200b922..455659419a62 100644--- a/products/today/backend/tests/test_highlight_key_metrics.py+++ b/products/today/backend/tests/test_highlight_key_metrics.py@@ -1,6 +1,8 @@+import jsonfrom datetime import date, timedeltafrom types import SimpleNamespace-from typing import cast+from typing import Any, cast+from urllib.parse import unquotefrom unittest.mock import patch@@ -24,9 +26,28 @@ def metric(key: str, values: list[float], *, people: bool = False) -> KeyMetric:daily=daily,this_week=sum(values[-7:]),last_week=sum(values[-14:-7]),+ node={"kind": "EventsNode", "event": key},)+def _query(url: str | None) -> Any:+ assert url is not None and url.startswith("/insights/new#q=")+ return json.loads(unquote(url.removeprefix("/insights/new#q=")))+++def _trend(series: dict[str, str]) -> dict[str, Any]:+ return {+ "kind": "InsightVizNode",+ "source": {+ "kind": "TrendsQuery",+ "series": [series],+ "interval": "day",+ "dateRange": {"date_from": "2026-09-15", "date_to": "2026-10-12"},+ "filterTestAccounts": True,+ },+ }++class TestKeyMetrics(SimpleTestCase):def test_key_metrics_fill_the_pulse_and_a_weekday_drop_becomes_an_item(self) -> None:drop = [1000.0] * 6 + [1010.0] + [1000.0] * 6 + [990.0] + [1000.0] * 20 + [500.0]@@ -52,10 +73,15 @@ class TestKeyMetrics(SimpleTestCase):([(m.key, m.value, m.unit, m.change_pct, len(m.series)) for m in found.pulse],[(c.title, c.detail, c.label) for c in found.items],+ [_query(m.url) for m in found.pulse],),([("signup_event", 6500.0, "events", -7.1, 28), ("activity_event", 140.0, "people", 0.0, 28)],[("‘Signup event’ decreased by 50% yesterday", "500 yesterday · 1,000 on an average Monday", "risk")],+ [+ _trend({"kind": "EventsNode", "event": "signup_event", "math": "total"}),+ _trend({"kind": "EventsNode", "event": "activity_event", "math": "dau"}),+ ],),)diff --git a/products/today/frontend/generated/api.schemas.ts b/products/today/frontend/generated/api.schemas.tsindex bed9a9696e08..3bf8886c4373 100644--- a/products/today/frontend/generated/api.schemas.ts+++ b/products/today/frontend/generated/api.schemas.ts@@ -119,7 +119,7 @@ export interface HighlightMetricApi {* * `month` - Month */interval: CalendarUnitEnumApi/**- * Path of the insight the metric comes from. Null for a key metric.+ * Path of the insight the metric comes from. For a key metric, a new trends insight of the same days.* @nullable*/url: string | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex a39f73b661a0..e74d1f8476d7 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -55207,7 +55207,7 @@ export namespace Schemas {* * `month` - Month */interval: CalendarUnitEnum;/**- * Path of the insight the metric comes from. Null for a key metric.+ * Path of the insight the metric comes from. For a key metric, a new trends insight of the same days.* @nullable*/url: string | null;