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(growth): judge sdk outdated and sdk health from the daily rollup (#126051)

Rafael Audibert408cd21ec1a0
diff --git a/posthog/api/sdk_health.py b/posthog/api/sdk_health.py
index 75d124cd553f..9cc5a5284a7c 100644
--- a/posthog/api/sdk_health.py
+++ b/posthog/api/sdk_health.py
@@ -20,7 +20,7 @@ from products.growth.backend.constants import (
SDK_TYPES,
SdkVersionEntry,
github_sdk_versions_key,
- team_sdk_versions_v2_key,
+ team_sdk_versions_v3_key,
)
from products.growth.backend.sdk_health import SdkHealthReport, compute_sdk_health
@@ -175,9 +175,8 @@ class SdkHealthViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
type=bool,
required=False,
description=(
- "When true, bypasses the Redis cache and re-queries ClickHouse for SDK usage. "
- "A background job refreshes this data once a day, so the cached answer is "
- "usually current. Use sparingly."
+ "When true, bypasses the cache and re-reads SDK usage. The cached answer is at "
+ "most an hour old, so use this sparingly."
),
),
],
@@ -226,8 +225,8 @@ class SdkHealthViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
@permission_classes([IsAuthenticated])
def sdk_health(request: Request) -> Response:
"""
- Serve team SDK versions. Data is cached by the Temporal sdk_outdated health check.
- Supports force_refresh=true for on-demand detection.
+ Serve team SDK versions, built from the daily rollup plus live events and cached for an hour.
+ Supports force_refresh=true to rebuild the answer now.
"""
user = cast(User, request.user)
@@ -275,7 +274,7 @@ def get_team_data(team_id: int, force_refresh: bool) -> dict[str, list[SdkVersio
redis_client = get_client()
if not force_refresh:
- cache_key = team_sdk_versions_v2_key(team_id)
+ cache_key = team_sdk_versions_v3_key(team_id)
cached_data = redis_client.get(cache_key)
if cached_data:
try:
diff --git a/posthog/api/test/test_sdk_health.py b/posthog/api/test/test_sdk_health.py
index 44bbc3de0fa6..d857cb711c57 100644
--- a/posthog/api/test/test_sdk_health.py
+++ b/posthog/api/test/test_sdk_health.py
@@ -10,7 +10,7 @@ from posthog.api.sdk_health import get_team_data
class TestGetTeamData(SimpleTestCase):
@patch("posthog.api.sdk_health.get_client")
- def test_reads_v2_team_cache(self, mock_get_client: MagicMock) -> None:
+ def test_reads_v3_team_cache(self, mock_get_client: MagicMock) -> None:
redis_client = MagicMock()
redis_client.get.return_value = b'{"posthog-java": []}'
mock_get_client.return_value = redis_client
@@ -18,11 +18,11 @@ class TestGetTeamData(SimpleTestCase):
result = get_team_data(7, force_refresh=False)
assert result == {"posthog-java": []}
- redis_client.get.assert_called_once_with("sdk_versions:team:v2:7")
+ redis_client.get.assert_called_once_with("sdk_versions:team:v3:7")
@patch("products.growth.backend.team_sdk_versions.get_and_cache_team_sdk_versions")
@patch("posthog.api.sdk_health.get_client")
- def test_v2_cache_miss_fetches_fresh_data(self, mock_get_client: MagicMock, mock_get_and_cache: MagicMock) -> None:
+ def test_v3_cache_miss_fetches_fresh_data(self, mock_get_client: MagicMock, mock_get_and_cache: MagicMock) -> None:
redis_client = MagicMock()
redis_client.get.return_value = None
mock_get_client.return_value = redis_client
@@ -31,7 +31,7 @@ class TestGetTeamData(SimpleTestCase):
result = get_team_data(7, force_refresh=False)
assert result == {"web": []}
- redis_client.get.assert_called_once_with("sdk_versions:team:v2:7")
+ redis_client.get.assert_called_once_with("sdk_versions:team:v3:7")
mock_get_and_cache.assert_called_once_with(7, redis_client)
diff --git a/posthog/temporal/health_checks/README.md b/posthog/temporal/health_checks/README.md
index 24a0836e2216..ff0dc6b933f3 100644
--- a/posthog/temporal/health_checks/README.md
+++ b/posthog/temporal/health_checks/README.md
@@ -232,9 +232,9 @@ Default ClickHouse settings: `max_execution_time=30`, `max_threads=2`.
Checks that would scan days of raw `events` read a daily rollup on Postgres instead.
A Dagster job per rollup reads one UTC day from ClickHouse and replaces that day in a small Postgres table in one transaction.
-| Table | Product | Kept | Dagster job |
-| --------------------------- | ------- | ------- | ------------------------------- |
-| `growth_sdk_versions_daily` | growth | 10 days | `growth_sdk_versions_daily_job` |
+| Table | Product | Kept | Dagster job | Read by |
+| --------------------------- | ------- | ------- | ------------------------------- | ----------------------------------- |
+| `growth_sdk_versions_daily` | growth | 10 days | `growth_sdk_versions_daily_job` | `sdk_outdated`, the SDK Health page |
### How a day is published
@@ -255,6 +255,17 @@ Dagster retries a failed run twice, 15 minutes apart, unless every failed day wa
To fill a day by hand, launch the job in Dagster with `days: ["2026-10-01", ...]`, and add `force: true` to publish a day the median rule refused.
+### Reading a rollup from a check
+
+Subclass `RollupHealthCheck` instead of `HealthCheck`, set `rollup_model` and `window_days`, and implement `detect_from_rollup(team_ids, window)`.
+The window ends at the latest published day (L).
+When L is missing or more than two days old, or any day of the window is missing, the base class raises `HealthCheckBatchSkipped`.
+The batch then keeps its issues, and the run fails once skipped teams pass `not_processed_threshold`.
+Events after L are not in the rollup, so a check that must see them adds a small live ClickHouse query from `window.live_since`.
+
+Read rows through `window_rows(model, team_ids, window)` (`rollups/freshness.py`).
+Name the rollup model in `READ_REPLICA_OPT_IN` to read it from the read replica.
+
### Adding a rollup
Subclass `DailyRollup` (`rollups/framework.py`) next to the product's model, with `columns`, `fill_sql()` and `retention_days`.
diff --git a/posthog/temporal/health_checks/models.py b/posthog/temporal/health_checks/models.py
index 49174bafdfde..1b8e78b2a952 100644
--- a/posthog/temporal/health_checks/models.py
+++ b/posthog/temporal/health_checks/models.py
@@ -109,3 +109,11 @@ class HealthCheckWorkflowInputs:
class HealthCheckThresholdExceeded(Exception):
pass
+
+
+class HealthCheckBatchSkipped(Exception):
+ """Raised by `detect` when the batch cannot be judged, for example when its input data is stale.
+
+ The framework counts every team in the batch as skipped, so each team keeps its current issues
+ and the run fails once skipped teams pass `not_processed_threshold`.
+ """
diff --git a/posthog/temporal/health_checks/processing.py b/posthog/temporal/health_checks/processing.py
index 52ac54329175..f423e3917971 100644
--- a/posthog/temporal/health_checks/processing.py
+++ b/posthog/temporal/health_checks/processing.py
@@ -5,7 +5,7 @@ import structlog
from posthog.temporal.health_checks.alerts import emit_health_check_alert
from posthog.temporal.health_checks.db import resolve_stale_issues_with_deltas, upsert_issues_with_deltas
from posthog.temporal.health_checks.framework import health_check_class_for_kind
-from posthog.temporal.health_checks.models import BatchDetectFn, BatchResult
+from posthog.temporal.health_checks.models import BatchDetectFn, BatchResult, HealthCheckBatchSkipped
from posthog.temporal.health_checks.registry import HEALTH_CHECKS, ensure_registry_loaded, get_detect_fn
from posthog.temporal.health_checks.signal_emitter import emit_health_check_signals
from posthog.temporal.health_checks.validation import _validate_batch_output
@@ -46,8 +46,14 @@ def _process_batch_detection(
return result
start = time.monotonic()
- issues_by_team = detect_fn(eligible_team_ids)
- result.detect_duration = time.monotonic() - start
+ try:
+ issues_by_team = detect_fn(eligible_team_ids)
+ except HealthCheckBatchSkipped as skipped:
+ logger.warning("health check batch skipped", kind=kind, reason=str(skipped), teams=len(eligible_team_ids))
+ result.teams_skipped = len(eligible_team_ids)
+ return result
+ finally:
+ result.detect_duration = time.monotonic() - start
issues_by_team, teams_dropped = _validate_batch_output(issues_by_team, set(eligible_team_ids), kind)
diff --git a/posthog/temporal/health_checks/rollups/checks.py b/posthog/temporal/health_checks/rollups/checks.py
new file mode 100644
index 000000000000..5172692a7146
--- /dev/null
+++ b/posthog/temporal/health_checks/rollups/checks.py
@@ -0,0 +1,39 @@
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, ClassVar
+
+from posthog.temporal.health_checks.detectors import HealthExecutionPolicy
+from posthog.temporal.health_checks.framework import HealthCheck
+from posthog.temporal.health_checks.models import HealthCheckBatchSkipped, HealthCheckResult
+from posthog.temporal.health_checks.rollups.freshness import RollupWindow, rollup_window
+
+if TYPE_CHECKING:
+ from django.db import models
+
+# A batch reads Postgres rollup rows, not raw events, so it holds as many teams as a Postgres check.
+# That size also bounds the issue upserts, which take one advisory lock per team in one transaction.
+ROLLUP_EXECUTION_POLICY = HealthExecutionPolicy(batch_size=1000, max_concurrent=2)
+
+
+class RollupHealthCheck(HealthCheck):
+ """A health check that reads a daily rollup instead of raw events.
+
+ `detect` resolves the window ending at the latest published day and calls `detect_from_rollup`.
+ When the rollup is stale or the window has a gap, the batch is skipped, so every team keeps its
+ current issues instead of reading as healthy.
+ """
+
+ rollup_model: ClassVar[type[models.Model]]
+ window_days: ClassVar[int]
+ policy = ROLLUP_EXECUTION_POLICY
+
+ def detect(self, team_ids: list[int]) -> dict[int, list[HealthCheckResult]]:
+ window = rollup_window(self.rollup_model, self.window_days)
+ if window is None:
+ raise HealthCheckBatchSkipped(
+ f"{self.rollup_model._meta.db_table} has no fresh {self.window_days}-day window"
+ )
+ return self.detect_from_rollup(team_ids, window)
+
+ def detect_from_rollup(self, team_ids: list[int], window: RollupWindow) -> dict[int, list[HealthCheckResult]]:
+ raise NotImplementedError
diff --git a/posthog/temporal/health_checks/rollups/tests/test_rollup_store.py b/posthog/temporal/health_checks/rollups/tests/test_rollup_store.py
index 4bb3ba9eae37..83b30dce05da 100644
--- a/posthog/temporal/health_checks/rollups/tests/test_rollup_store.py
+++ b/posthog/temporal/health_checks/rollups/tests/test_rollup_store.py
@@ -10,13 +10,16 @@ from django.core.cache import cache
import dagster
from posthog.dags.daily_rollups import DailyRollupConfig
+from posthog.models.health_issue import HealthIssue
from posthog.models.team import Team
+from posthog.temporal.health_checks.processing import _process_batch_detection
from posthog.temporal.health_checks.rollups import store
from posthog.temporal.health_checks.rollups.runner import RollupDay, RollupDayRefused, run_rollup_day
from posthog.temporal.health_checks.rollups.store import delete_days_before, delete_rollup_rows_for_teams
from products.growth.backend.models import SdkVersionsDaily
from products.growth.backend.sdk_version_rollup import SdkVersionsDailyRollup
+from products.growth.backend.temporal.health_checks.sdk_outdated import SdkOutdatedCheck
from products.growth.dags.sdk_versions_rollup import sdk_versions_daily_rollup
YESTERDAY = dt.date(2026, 10, 28)
@@ -167,3 +170,21 @@ class TestRollupFillAndPublish(ClickhouseTestMixin, BaseTest):
assert list(
SdkVersionsDaily.objects.for_team(self.team.id).filter(day=YESTERDAY).values_list("event_count", flat=True)
) == [1]
+
+ def test_check_skips_the_batch_and_keeps_issues_when_the_rollup_is_stale(self) -> None:
+ issue = HealthIssue.objects.create(
+ team=self.team,
+ kind=SdkOutdatedCheck.kind,
+ severity=HealthIssue.Severity.WARNING,
+ payload={"sdk_name": "web"},
+ unique_hash=HealthIssue.compute_unique_hash(SdkOutdatedCheck.kind, {"sdk_name": "web"}, ["sdk_name"]),
+ )
+ SdkVersionsDaily.objects.unscoped().bulk_create(
+ [_sdk_row(self.team.id, YESTERDAY - dt.timedelta(days=offset)) for offset in range(2, 10)]
+ )
+
+ result = _process_batch_detection([self.team.id], SdkOutdatedCheck.kind, SdkOutdatedCheck().detect)
+
+ assert result.teams_skipped == 1
+ issue.refresh_from_db()
+ assert issue.status == HealthIssue.Status.ACTIVE
diff --git a/products/growth/backend/constants.py b/products/growth/backend/constants.py
index 1c43e02a5d49..a660a28f734e 100644
--- a/products/growth/backend/constants.py
+++ b/products/growth/backend/constants.py
@@ -4,15 +4,7 @@ from django.conf import settings
SDK_CACHE_EXPIRY = 60 * 60 * 24 * 7 # 7 days — used by the GitHub `latestVersion` cache (hourly Dagster job)
-# Team-events snapshot TTL — sized to self-heal one missed daily cron run.
-# The Temporal `sdk_outdated` cron starts at 08:00 UTC; per-team writes happen mid-batch, so the
-# previous day's write for any given team can be timestamped meaningfully later. A 26h TTL gives
-# ~2h headroom relative to cron *start*, and less for teams late in the batch queue. That's
-# deliberate: when a team's TTL expires before its next batch slot, the next user request hits
-# the cache-miss fallback in posthog/api/sdk_health.py:get_team_data, which runs one fresh
-# single-team HogQL query and repopulates Redis. Steady-state load is unchanged; the trade-off
-# prevents days-long stale snapshots when a team's batch is skipped or times out.
-TEAM_SDK_CACHE_EXPIRY = 60 * 60 * 26 # 26 hours
+TEAM_SDK_CACHE_EXPIRY = 60 * 60
# Canonical list of the SDK identifiers SDK Health tracks. Lives here (rather than in
@@ -278,5 +270,5 @@ def github_sdk_versions_key(sdk_type: str) -> str:
return f"github:sdk_versions:{sdk_type}"
-def team_sdk_versions_v2_key(team_id: int) -> str:
- return f"sdk_versions:team:v2:{team_id}"
+def team_sdk_versions_v3_key(team_id: int) -> str:
+ return f"sdk_versions:team:v3:{team_id}"
diff --git a/products/growth/backend/sdk_version_rollup.py b/products/growth/backend/sdk_version_rollup.py
index c1b80936ede9..3b7285da082a 100644
--- a/products/growth/backend/sdk_version_rollup.py
+++ b/products/growth/backend/sdk_version_rollup.py
@@ -1,11 +1,19 @@
+import datetime as dt
+from collections import defaultdict
from collections.abc import Mapping
from typing import Any
+from django.db.models import Max, Sum
+
from posthog.clickhouse.query_tagging import Product
+from posthog.dataclasses import frozen
from posthog.temporal.health_checks.rollups.framework import DailyRollup
+from posthog.temporal.health_checks.rollups.freshness import RollupWindow, rollup_window, window_rows
+from posthog.utils import ensure_utc
-from products.growth.backend.constants import SDK_TYPES
+from products.growth.backend.constants import SDK_TYPES, SdkVersionEntry
from products.growth.backend.models import SdkVersionsDaily
+from products.growth.backend.sdk_health import sort_sdk_version_entries
MAX_VERSIONS_PER_TEAM_LIB_DAY = 100
@@ -48,3 +56,73 @@ class SdkVersionsDailyRollup(DailyRollup):
"max_version_length": SdkVersionsDaily._meta.get_field("lib_version").max_length,
"max_versions": MAX_VERSIONS_PER_TEAM_LIB_DAY,
}
+
+
+SDK_VERSIONS_WINDOW_DAYS = 7
+
+TeamSdkVersions = dict[str, list[SdkVersionEntry]]
+
+
+@frozen
+class _SdkVersion:
+ lib: str
+ lib_version: str
+
+
+@frozen
+class _VersionUsage:
+ count: int
+ max_timestamp: dt.datetime
+
+
+def sdk_versions_window() -> RollupWindow | None:
+ return rollup_window(SdkVersionsDaily, SDK_VERSIONS_WINDOW_DAYS)
+
+
+def _read_usage(team_ids: list[int], window: RollupWindow) -> dict[int, dict[_SdkVersion, _VersionUsage]]:
+ rows = (
+ window_rows(SdkVersionsDaily, team_ids, window)
+ .values("team_id", "lib", "lib_version")
+ .annotate(count=Sum("event_count"), max_timestamp=Max("max_timestamp"))
+ )
+ usage: defaultdict[int, dict[_SdkVersion, _VersionUsage]] = defaultdict(dict)
+ for row in rows:
+ usage[row["team_id"]][_SdkVersion(lib=row["lib"], lib_version=row["lib_version"])] = _VersionUsage(
+ count=row["count"], max_timestamp=ensure_utc(row["max_timestamp"]).astimezone(dt.UTC)
+ )
+ return dict(usage)
+
+
+def _to_entries(usage: dict[_SdkVersion, _VersionUsage]) -> TeamSdkVersions:
+ entries: defaultdict[str, list[SdkVersionEntry]] = defaultdict(list)
+ for version, version_usage in usage.items():
+ if version.lib not in SDK_TYPES:
+ continue
+ entries[version.lib].append(
+ {
+ "lib_version": version.lib_version,
+ "max_timestamp": str(version_usage.max_timestamp),
+ "count": version_usage.count,
+ }
+ )
+ return {lib: sort_sdk_version_entries(lib_entries) for lib, lib_entries in entries.items()}
+
+
+def sdk_versions_from_rollup(team_ids: list[int], window: RollupWindow) -> dict[int, TeamSdkVersions]:
+ """SDK versions per team over the window, in the shape SDK Health reads. Teams with no traffic are absent."""
+ return {team_id: _to_entries(usage) for team_id, usage in _read_usage(team_ids, window).items()}
+
+
+def merge_live_usage(
+ team_id: int, window: RollupWindow | None, live_rows: list[tuple[str, str, dt.datetime, int]]
+) -> TeamSdkVersions:
+ """Combine the team's rollup window, if any, with live `(lib, lib_version, max_timestamp, count)` rows."""
+ usage = _read_usage([team_id], window).get(team_id, {}) if window else {}
+ for lib, lib_version, live_max_timestamp, count in live_rows:
+ max_timestamp = ensure_utc(live_max_timestamp).astimezone(dt.UTC)
+ key = _SdkVersion(lib=lib, lib_version=lib_version or "")
+ previous = usage.get(key, _VersionUsage(count=0, max_timestamp=max_timestamp))
+ usage[key] = _VersionUsage(
+ count=previous.count + count, max_timestamp=max(previous.max_timestamp, max_timestamp)
+ )
+ return _to_entries(usage)
diff --git a/products/growth/backend/team_sdk_versions.py b/products/growth/backend/team_sdk_versions.py
index b99baf9fbf20..72967f08e1ed 100644
--- a/products/growth/backend/team_sdk_versions.py
+++ b/products/growth/backend/team_sdk_versions.py
@@ -1,5 +1,5 @@
import json
-from collections import defaultdict
+import datetime as dt
import redis
import structlog
@@ -8,23 +8,21 @@ from tenacity import retry, stop_after_attempt, wait_exponential
from posthog.schema import HogQLQueryResponse
+from posthog.hogql import ast
from posthog.hogql.parser import parse_select
from posthog.hogql.query import execute_hogql_query
from posthog.clickhouse.query_tagging import Feature, Product, tags_context
+from posthog.clickhouse.workload import Workload
from posthog.exceptions_capture import capture_exception
from posthog.models import Team
-from products.growth.backend.constants import (
- SDK_TYPES,
- TEAM_SDK_CACHE_EXPIRY,
- SdkVersionEntry,
- team_sdk_versions_v2_key,
-)
-from products.growth.backend.sdk_health import sort_sdk_version_entries
+from products.growth.backend.constants import TEAM_SDK_CACHE_EXPIRY, SdkVersionEntry, team_sdk_versions_v3_key
+from products.growth.backend.sdk_version_rollup import SDK_VERSIONS_WINDOW_DAYS, merge_live_usage, sdk_versions_window
default_logger: BoundLogger = structlog.get_logger(__name__)
+# HogQL returns 100 rows unless the query sets a LIMIT. A team can have more SDK versions than that.
QUERY = parse_select("""
SELECT
properties.$lib AS lib,
@@ -33,18 +31,17 @@ QUERY = parse_select("""
COUNT(*) AS event_count
FROM events
WHERE
- timestamp >= now() - INTERVAL 7 DAY
+ timestamp >= {since}
AND lib IS NOT NULL
AND (lib = 'posthog-java' OR (lib_version IS NOT NULL AND lib_version != ''))
GROUP BY lib, lib_version
- ORDER BY
- lib,
- event_count DESC
+ ORDER BY event_count DESC
+ LIMIT 10000
""")
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=1, max=10))
-def run_query(team: Team) -> HogQLQueryResponse:
+def run_query(team: Team, since: dt.datetime) -> HogQLQueryResponse:
query_type = "sdk_versions_for_team"
with tags_context(
product=Product.SDK_HEALTH,
@@ -53,7 +50,13 @@ def run_query(team: Team) -> HogQLQueryResponse:
org_id=team.organization_id,
query_type=query_type,
):
- response = execute_hogql_query(QUERY, team, query_type=query_type)
+ response = execute_hogql_query(
+ QUERY,
+ team,
+ query_type=query_type,
+ placeholders={"since": ast.Constant(value=since)},
+ workload=Workload.ONLINE,
+ )
return response
@@ -63,25 +66,21 @@ def get_sdk_versions_for_team(
logger: BoundLogger = default_logger,
) -> dict[str, list[SdkVersionEntry]] | None:
"""
- Query ClickHouse for events in the last 7 days and extract SDK usage.
- Returns dict of SDK versions with minimal data, grouped by lib type.
+ SDK usage for the last week, grouped by lib type.
+
+ Reads the daily rollup plus a live query for the hours since it ended. When the rollup has no
+ fresh window, falls back to a 7-day query over raw events.
"""
try:
team = Team.objects.get(id=team_id)
- response = run_query(team)
-
- output: defaultdict[str, list[SdkVersionEntry]] = defaultdict(list)
- for lib, lib_version, max_timestamp, event_count in response.results:
- if lib in SDK_TYPES:
- output[lib].append(
- {
- "lib_version": lib_version,
- "max_timestamp": str(max_timestamp),
- "count": event_count,
- }
- )
-
- return {lib: sort_sdk_version_entries(entries) for lib, entries in output.items()}
+ window = sdk_versions_window()
+ if window is None:
+ logger.info("sdk_health_rollup_unavailable", team_id=team_id)
+ since = dt.datetime.now(dt.UTC) - dt.timedelta(days=SDK_VERSIONS_WINDOW_DAYS)
+ else:
+ since = window.live_since
+ live_rows = [tuple(row) for row in run_query(team, since).results]
+ return merge_live_usage(team_id, window, live_rows)
except Team.DoesNotExist:
logger.exception(f"[SDK Health] Team {team_id} not found")
return {} # Safe to return empty dict, this is not an error
@@ -106,7 +105,7 @@ def get_and_cache_team_sdk_versions(
sdk_versions = get_sdk_versions_for_team(team_id, logger=logger)
if sdk_versions is not None:
payload = json.dumps(sdk_versions)
- cache_key = team_sdk_versions_v2_key(team_id)
+ cache_key = team_sdk_versions_v3_key(team_id)
redis_client.setex(cache_key, TEAM_SDK_CACHE_EXPIRY, payload)
logger.info(f"[SDK Health] Team {team_id} SDK versions cached successfully")
diff --git a/products/growth/backend/temporal/health_checks/sdk_outdated.py b/products/growth/backend/temporal/health_checks/sdk_outdated.py
index 783d2744c3e5..209fa0514b25 100644
--- a/products/growth/backend/temporal/health_checks/sdk_outdated.py
+++ b/products/growth/backend/temporal/health_checks/sdk_outdated.py
@@ -7,31 +7,21 @@ import structlog
from posthog.job_owners import JobOwners
from posthog.models.health_issue import HealthIssue
from posthog.redis import get_client
-from posthog.temporal.health_checks.detectors import HealthExecutionPolicy
from posthog.temporal.health_checks.framework import (
_SEVERITY_WEIGHT,
AlertContent,
- HealthCheck,
Remediation,
SignalContent,
build_signal_extra,
)
-from posthog.temporal.health_checks.models import HealthCheckResult
-from posthog.temporal.health_checks.query import execute_clickhouse_health_team_query
+from posthog.temporal.health_checks.models import HealthCheckBatchSkipped, HealthCheckResult
+from posthog.temporal.health_checks.rollups.checks import RollupHealthCheck
+from posthog.temporal.health_checks.rollups.freshness import RollupWindow
-from products.growth.backend.constants import (
- SDK_TYPES,
- TEAM_SDK_CACHE_EXPIRY,
- SdkVersionEntry,
- github_sdk_versions_key,
- team_sdk_versions_v2_key,
-)
-from products.growth.backend.sdk_health import (
- SdkAssessment,
- _is_safe_for_interpolation,
- compute_sdk_health,
- sort_sdk_version_entries,
-)
+from products.growth.backend.constants import SDK_TYPES, SdkVersionEntry, github_sdk_versions_key
+from products.growth.backend.models import SdkVersionsDaily
+from products.growth.backend.sdk_health import SdkAssessment, _is_safe_for_interpolation, compute_sdk_health
+from products.growth.backend.sdk_version_rollup import SDK_VERSIONS_WINDOW_DAYS, sdk_versions_from_rollup
# Issue severity follows the SDK Health assessment severity: a single outdated SDK is a warning,
# but when the bulk of a team's SDKs are outdated the assessment escalates to "danger".
@@ -42,30 +32,6 @@ _SEVERITY_BY_ASSESSMENT: dict[str, HealthIssue.Severity] = {
logger = structlog.get_logger(__name__)
-SDK_VERSIONS_SQL = """
-SELECT
- team_id,
- `mat_$lib` AS lib,
- `mat_$lib_version` AS lib_version,
- max(timestamp) AS max_timestamp,
- count(*) AS event_count
-FROM events
-WHERE
- team_id IN %(team_ids)s
- AND timestamp >= now() - INTERVAL %(lookback_days)s DAY
- AND `mat_$lib` IS NOT NULL
- AND `mat_$lib` != ''
- AND (
- `mat_$lib` = 'posthog-java'
- OR (`mat_$lib_version` IS NOT NULL AND `mat_$lib_version` != '')
- )
-GROUP BY team_id, lib, lib_version
-ORDER BY
- team_id,
- lib,
- event_count DESC
-"""
-
def _decode_redis_json(raw: bytes | str) -> dict:
return json.loads(raw.decode("utf-8") if isinstance(raw, bytes) else raw)
@@ -87,26 +53,14 @@ def _load_github_sdk_data() -> dict[str, dict]:
return data
-def _cache_team_sdk_data(team_sdk_data: dict[int, dict[str, list[SdkVersionEntry]]]) -> None:
- """Cache team SDK version data in Redis for the SDK Health API."""
- if not team_sdk_data:
- return
-
- redis_client = get_client()
- pipe = redis_client.pipeline()
- for team_id, sdk_data in team_sdk_data.items():
- cache_key = team_sdk_versions_v2_key(team_id)
- pipe.setex(cache_key, TEAM_SDK_CACHE_EXPIRY, json.dumps(sdk_data))
- pipe.execute()
-
-
-class SdkOutdatedCheck(HealthCheck):
+class SdkOutdatedCheck(RollupHealthCheck):
name = "sdk_outdated"
kind = "sdk_outdated"
owner = JobOwners.TEAM_GROWTH
- policy = HealthExecutionPolicy(batch_size=10, max_concurrent=3)
schedule = "0 8 * * *"
active_since_days = 30
+ rollup_model = SdkVersionsDaily
+ window_days = SDK_VERSIONS_WINDOW_DAYS
remediation = Remediation(
human="""
Open the SDK Health page (the Health section of the app). It lists every SDK you're sending
@@ -175,48 +129,56 @@ class SdkOutdatedCheck(HealthCheck):
extra=build_signal_extra(issue, title=title, summary=reason, link="/health/sdk-health"),
)
- def detect(self, team_ids: list[int]) -> dict[int, list[HealthCheckResult]]:
+ def detect_from_rollup(self, team_ids: list[int], window: RollupWindow) -> dict[int, list[HealthCheckResult]]:
github_data = _load_github_sdk_data()
if not github_data:
- logger.warning("GitHub SDK version data unavailable in Redis; skipping sdk_outdated check")
- return {}
+ raise HealthCheckBatchSkipped("GitHub SDK version data unavailable in Redis")
- rows = execute_clickhouse_health_team_query(
- SDK_VERSIONS_SQL,
- team_ids=team_ids,
- lookback_days=7,
- )
+ issues = _issues_from_sdk_usage(sdk_versions_from_rollup(team_ids, window), github_data)
+ for team_id, kept in _issues_without_github_data(team_ids, github_data).items():
+ issues.setdefault(team_id, []).extend(kept)
+ return issues
- team_sdk_data: defaultdict[int, defaultdict[str, list[SdkVersionEntry]]] = defaultdict(
- lambda: defaultdict(list)
- )
- for team_id, lib, lib_version, max_timestamp, event_count in rows:
- if lib in SDK_TYPES:
- team_sdk_data[team_id][lib].append(
- {
- "lib_version": lib_version,
- "max_timestamp": str(max_timestamp),
- "count": event_count,
- }
- )
- for sdk_data in team_sdk_data.values():
- for lib, entries in sdk_data.items():
- sdk_data[lib] = sort_sdk_version_entries(entries)
+def _issues_from_sdk_usage(
+ team_sdk_data: dict[int, dict[str, list[SdkVersionEntry]]], github_data: dict[str, dict]
+) -> dict[int, list[HealthCheckResult]]:
+ issues: defaultdict[int, list[HealthCheckResult]] = defaultdict(list)
+ for team_id, sdk_data in team_sdk_data.items():
+ combined = _build_combined_data(sdk_data, github_data)
+ if not combined:
+ continue
+ report = compute_sdk_health(combined, project_id=team_id)
+ for assessment in report.sdks:
+ if assessment.needs_updating:
+ issues[team_id].append(_build_health_result(assessment))
+ return dict(issues)
- _cache_team_sdk_data({tid: dict(sdk_data) for tid, sdk_data in team_sdk_data.items()})
- issues: defaultdict[int, list[HealthCheckResult]] = defaultdict(list)
- for team_id, sdk_data in team_sdk_data.items():
- combined = _build_combined_data(sdk_data, github_data)
- if not combined:
- continue
- report = compute_sdk_health(combined, project_id=team_id)
- for assessment in report.sdks:
- if assessment.needs_updating:
- issues[team_id].append(_build_health_result(assessment))
+def _issues_without_github_data(
+ team_ids: list[int], github_data: dict[str, dict]
+) -> dict[int, list[HealthCheckResult]]:
+ """Re-emit active issues for SDKs that have no GitHub data in this run.
- return issues
+ Such an SDK cannot be judged, so the run must not read its absence as healthy and resolve it.
+ The re-emitted result has the same payload and hash, so it updates the issue in place and
+ sends no new alert.
+ """
+ active = (
+ HealthIssue.objects.filter(team_id__in=team_ids, kind=SdkOutdatedCheck.kind, status=HealthIssue.Status.ACTIVE)
+ .exclude(payload__sdk_name__in=list(github_data))
+ .only("team_id", "severity", "payload")
+ )
+ kept: defaultdict[int, list[HealthCheckResult]] = defaultdict(list)
+ for issue in active:
+ sdk_name = issue.payload.get("sdk_name")
+ if sdk_name:
+ kept[issue.team_id].append(
+ HealthCheckResult(
+ severity=HealthIssue.Severity(issue.severity), payload=issue.payload, hash_keys=["sdk_name"]
+ )
+ )
+ return dict(kept)
def _build_combined_data(
diff --git a/products/growth/backend/temporal/health_checks/tests/test_sdk_outdated.py b/products/growth/backend/temporal/health_checks/tests/test_sdk_outdated.py
index b9b0b3e182ef..90d9baa2f651 100644
--- a/products/growth/backend/temporal/health_checks/tests/test_sdk_outdated.py
+++ b/products/growth/backend/temporal/health_checks/tests/test_sdk_outdated.py
@@ -1,53 +1,56 @@
-from unittest.mock import MagicMock, patch
+import datetime as dt
+
+import pytest
+from posthog.test.base import BaseTest
+from unittest.mock import patch
from django.test import SimpleTestCase
from parameterized import parameterized
from posthog.models.health_issue import HealthIssue
+from posthog.temporal.health_checks.models import HealthCheckBatchSkipped
+from posthog.temporal.health_checks.rollups.freshness import RollupWindow
-from products.growth.backend.constants import TEAM_SDK_CACHE_EXPIRY
-from products.growth.backend.temporal.health_checks.sdk_outdated import SdkOutdatedCheck, _cache_team_sdk_data
+from products.growth.backend.models import SdkVersionsDaily
+from products.growth.backend.temporal.health_checks.sdk_outdated import SdkOutdatedCheck
# A release date far enough in the past that any version behind latest is unambiguously outdated,
# independent of the wall clock when the test runs.
OLD_RELEASE = "2020-01-01T00:00:00Z"
+WINDOW = RollupWindow(start=dt.date(2026, 3, 14), end=dt.date(2026, 3, 20))
+
-def _make_ch_row(
+def _make_row(
team_id: int,
lib: str,
lib_version: str | None,
- max_timestamp: str = "2026-03-20 12:00:00",
+ max_timestamp: dt.datetime = dt.datetime(2026, 3, 20, 12, tzinfo=dt.UTC),
event_count: int = 5000,
-) -> tuple:
- return (team_id, lib, lib_version, max_timestamp, event_count)
-
-
-def _patch_check(github: dict | None, rows: list[tuple]):
- """Patch the three external boundaries the check touches: GitHub version data, ClickHouse, Redis cache."""
- return (
- patch(
- "products.growth.backend.temporal.health_checks.sdk_outdated._load_github_sdk_data",
- return_value=github or {},
- ),
- patch(
- "products.growth.backend.temporal.health_checks.sdk_outdated.execute_clickhouse_health_team_query",
- return_value=rows,
- ),
- patch("products.growth.backend.temporal.health_checks.sdk_outdated._cache_team_sdk_data"),
+) -> SdkVersionsDaily:
+ return SdkVersionsDaily(
+ team_id=team_id,
+ day=WINDOW.end,
+ lib=lib,
+ lib_version=lib_version or "",
+ event_count=event_count,
+ max_timestamp=max_timestamp,
)
-class TestSdkOutdatedCheck(SimpleTestCase):
+class TestSdkOutdatedCheck(BaseTest):
def setUp(self):
+ super().setUp()
self.check = SdkOutdatedCheck()
- def _run(self, github: dict | None, rows: list[tuple], team_ids: list[int]) -> dict:
- p_github, p_ch, p_cache = _patch_check(github, rows)
- with p_github, p_ch, p_cache as mock_cache:
- self._mock_cache = mock_cache
- return self.check.detect(team_ids)
+ def _run(self, github: dict | None, rows: list[SdkVersionsDaily], team_ids: list[int]) -> dict:
+ SdkVersionsDaily.objects.unscoped().bulk_create(rows)
+ with patch(
+ "products.growth.backend.temporal.health_checks.sdk_outdated._load_github_sdk_data",
+ return_value=github or {},
+ ):
+ return self.check.detect_from_rollup(team_ids, WINDOW)
def test_detects_outdated_sdk_with_enriched_payload(self):
github = {
@@ -56,9 +59,9 @@ class TestSdkOutdatedCheck(SimpleTestCase):
"posthog-python": {"latestVersion": "5.0.0", "releaseDates": {"4.0.0": OLD_RELEASE}},
}
rows = [
- _make_ch_row(1, "web", "2.0.0"),
- _make_ch_row(1, "posthog-node", "3.0.0"),
- _make_ch_row(1, "posthog-python", "4.0.0", event_count=900),
+ _make_row(1, "web", "2.0.0"),
+ _make_row(1, "posthog-node", "3.0.0"),
+ _make_row(1, "posthog-python", "4.0.0", event_count=900),
]
results = self._run(github, rows, [1])
@@ -95,8 +98,8 @@ class TestSdkOutdatedCheck(SimpleTestCase):
},
}
rows = [
- _make_ch_row(1, "posthog-java", None),
- _make_ch_row(1, "posthog-server", "2.7.5"),
+ _make_row(1, "posthog-java", None),
+ _make_row(1, "posthog-server", "2.7.5"),
]
results = self._run(github, rows, [1])
@@ -135,8 +138,8 @@ class TestSdkOutdatedCheck(SimpleTestCase):
}
}
rows = [
- _make_ch_row(1, sdk_type, "1.2.0", event_count=100),
- _make_ch_row(1, sdk_type, "1.10", event_count=50),
+ _make_row(1, sdk_type, "1.2.0", event_count=100),
+ _make_row(1, sdk_type, "1.10", event_count=50),
]
results = self._run(github, rows, [1])
@@ -149,8 +152,8 @@ class TestSdkOutdatedCheck(SimpleTestCase):
# rather than the contradictory "on 1.142.0, latest is 1.142.0".
github = {"web": {"latestVersion": "1.142.0", "releaseDates": {"1.130.0": OLD_RELEASE}}}
rows = [
- _make_ch_row(1, "web", "1.142.0", event_count=700), # primary: latest, healthy
- _make_ch_row(1, "web", "1.130.0", event_count=300), # 30% traffic, behind, old
+ _make_row(1, "web", "1.142.0", event_count=700), # primary: latest, healthy
+ _make_row(1, "web", "1.130.0", event_count=300), # 30% traffic, behind, old
]
results = self._run(github, rows, [1])
@@ -172,7 +175,7 @@ class TestSdkOutdatedCheck(SimpleTestCase):
def test_escalates_to_critical_when_majority_outdated(self):
github = {"posthog-python": {"latestVersion": "5.0.0", "releaseDates": {"4.0.0": OLD_RELEASE}}}
- rows = [_make_ch_row(1, "posthog-python", "4.0.0")]
+ rows = [_make_row(1, "posthog-python", "4.0.0")]
results = self._run(github, rows, [1])
@@ -181,7 +184,7 @@ class TestSdkOutdatedCheck(SimpleTestCase):
def test_skips_team_on_latest_version(self):
github = {"web": {"latestVersion": "1.200.0", "releaseDates": {}}}
- rows = [_make_ch_row(1, "web", "1.200.0")]
+ rows = [_make_row(1, "web", "1.200.0")]
assert self._run(github, rows, [1]) == {}
@@ -189,27 +192,45 @@ class TestSdkOutdatedCheck(SimpleTestCase):
# Proves the heuristics run: a crude current!=latest rule would flag this, but a patch
# difference is never outdated.
github = {"web": {"latestVersion": "2.0.5", "releaseDates": {}}}
- rows = [_make_ch_row(1, "web", "2.0.3")]
+ rows = [_make_row(1, "web", "2.0.3")]
assert self._run(github, rows, [1]) == {}
- def test_returns_empty_when_no_github_data(self):
- p_github, p_ch, p_cache = _patch_check({}, [])
- with p_github, p_ch as mock_ch, p_cache:
- results = self.check.detect([1])
- assert results == {}
- mock_ch.assert_not_called()
+ def test_skips_batch_when_no_github_data(self):
+ with pytest.raises(HealthCheckBatchSkipped):
+ self._run({}, [_make_row(1, "web", "1.0.0")], [1])
+
+ def test_keeps_open_issue_for_sdk_without_github_data(self):
+ kept_payload = {"sdk_name": "posthog-ruby", "latest_version": "3.0.0", "reason": "behind"}
+ HealthIssue.objects.create(
+ team_id=self.team.id,
+ kind=SdkOutdatedCheck.kind,
+ severity=HealthIssue.Severity.WARNING,
+ payload=kept_payload,
+ unique_hash=HealthIssue.compute_unique_hash(SdkOutdatedCheck.kind, kept_payload, ["sdk_name"]),
+ )
+ github = {"web": {"latestVersion": "2.0.0", "releaseDates": {}}}
+
+ results = self._run(
+ github,
+ [_make_row(self.team.id, "web", "1.0.0"), _make_row(self.team.id, "posthog-ruby", "2.0.0")],
+ [self.team.id],
+ )
+
+ assert sorted(issue.payload["sdk_name"] for issue in results[self.team.id]) == ["posthog-ruby", "web"]
+ kept = next(issue for issue in results[self.team.id] if issue.payload["sdk_name"] == "posthog-ruby")
+ assert kept.payload == kept_payload
- def test_skips_team_with_no_clickhouse_data(self):
+ def test_skips_team_with_no_rollup_data(self):
github = {"web": {"latestVersion": "2.0.0", "releaseDates": {}}}
assert self._run(github, [], [1]) == {}
def test_multiple_teams_in_batch(self):
github = {"web": {"latestVersion": "2.0.0", "releaseDates": {}}}
rows = [
- _make_ch_row(1, "web", "1.0.0"), # major behind -> outdated
- _make_ch_row(2, "web", "2.0.0"), # latest -> healthy
- _make_ch_row(3, "web", "1.0.0"), # major behind -> outdated
+ _make_row(1, "web", "1.0.0"), # major behind -> outdated
+ _make_row(2, "web", "2.0.0"), # latest -> healthy
+ _make_row(3, "web", "1.0.0"), # major behind -> outdated
]
results = self._run(github, rows, [1, 2, 3])
@@ -225,36 +246,10 @@ class TestSdkOutdatedCheck(SimpleTestCase):
def test_ignores_unknown_sdk_types(self):
github = {"web": {"latestVersion": "2.0.0", "releaseDates": {}}}
- rows = [_make_ch_row(1, "unknown-sdk", "1.0.0", event_count=100)]
+ rows = [_make_row(1, "unknown-sdk", "1.0.0", event_count=100)]
assert self._run(github, rows, [1]) == {}
- def test_caches_team_data_in_redis(self):
- github = {"web": {"latestVersion": "2.0.0", "releaseDates": {}}}
- rows = [_make_ch_row(1, "web", "1.5.0")]
-
- self._run(github, rows, [1])
-
- self._mock_cache.assert_called_once()
- cached_data = self._mock_cache.call_args[0][0]
- assert 1 in cached_data
- assert "web" in cached_data[1]
- assert cached_data[1]["web"][0]["lib_version"] == "1.5.0"
-
- @patch("products.growth.backend.temporal.health_checks.sdk_outdated.get_client")
- def test_cache_team_sdk_data_uses_team_sdk_cache_expiry(self, mock_get_client: MagicMock):
- mock_redis = MagicMock()
- mock_pipe = MagicMock()
- mock_redis.pipeline.return_value = mock_pipe
- mock_get_client.return_value = mock_redis
-
- _cache_team_sdk_data({1: {"web": [{"lib_version": "1.0.0", "max_timestamp": "x", "count": 1}]}})
-
- mock_pipe.setex.assert_called_once()
- key, ttl, _payload = mock_pipe.setex.call_args[0]
- assert key == "sdk_versions:team:v2:1"
- assert ttl == TEAM_SDK_CACHE_EXPIRY
-
class TestSdkOutdatedRenderAlert(SimpleTestCase):
def test_render_alert_prefers_reason_when_present(self) -> None:
diff --git a/products/growth/backend/tests/test_team_sdk_versions.py b/products/growth/backend/tests/test_team_sdk_versions.py
index 35d350b7fb1d..3931fbffd314 100644
--- a/products/growth/backend/tests/test_team_sdk_versions.py
+++ b/products/growth/backend/tests/test_team_sdk_versions.py
@@ -1,10 +1,16 @@
+import datetime as dt
+
+import time_machine
+from posthog.test.base import BaseTest, ClickhouseTestMixin, _create_event, flush_persons_and_events
from unittest.mock import MagicMock, patch
+from django.core.cache import cache
from django.test import SimpleTestCase
from parameterized import parameterized
from products.growth.backend.constants import TEAM_SDK_CACHE_EXPIRY
+from products.growth.backend.models import SdkVersionsDaily
from products.growth.backend.team_sdk_versions import get_and_cache_team_sdk_versions, get_sdk_versions_for_team
@@ -28,16 +34,17 @@ class TestGetSdkVersionsForTeam(SimpleTestCase):
("js",),
]
)
+ @patch("products.growth.backend.team_sdk_versions.sdk_versions_window", return_value=None)
@patch("products.growth.backend.team_sdk_versions.run_query")
@patch("products.growth.backend.team_sdk_versions.Team.objects.get")
def test_sorts_partial_and_full_semver_versions_consistently(
- self, sdk_type: str, mock_team_get: MagicMock, mock_run_query: MagicMock
+ self, sdk_type: str, mock_team_get: MagicMock, mock_run_query: MagicMock, _mock_window: MagicMock
) -> None:
mock_team_get.return_value = MagicMock()
mock_run_query.return_value = MagicMock(
results=[
- (sdk_type, "1.2.0", "2026-07-14T00:00:00Z", 100),
- (sdk_type, "1.10", "2026-07-14T00:00:00Z", 50),
+ (sdk_type, "1.2.0", dt.datetime(2026, 7, 14, tzinfo=dt.UTC), 100),
+ (sdk_type, "1.10", dt.datetime(2026, 7, 14, tzinfo=dt.UTC), 50),
]
)
@@ -57,5 +64,77 @@ class TestGetAndCacheTeamSdkVersions(SimpleTestCase):
mock_redis.setex.assert_called_once()
key, ttl, _payload = mock_redis.setex.call_args[0]
- assert key == "sdk_versions:team:v2:1"
+ assert key == "sdk_versions:team:v3:1"
assert ttl == TEAM_SDK_CACHE_EXPIRY
+
+
+@time_machine.travel("2026-10-29T12:00:00Z", tick=False)
+class TestSdkVersionsFromRollup(ClickhouseTestMixin, BaseTest):
+ def setUp(self) -> None:
+ super().setUp()
+ cache.clear()
+
+ def _publish(self, days_ago: range, version: str, count_per_day: int) -> None:
+ today = dt.datetime.now(dt.UTC).date()
+ SdkVersionsDaily.objects.unscoped().bulk_create(
+ SdkVersionsDaily(
+ team_id=self.team.id,
+ day=today - dt.timedelta(days=offset),
+ lib="web",
+ lib_version=version,
+ event_count=count_per_day,
+ max_timestamp=dt.datetime.combine(today - dt.timedelta(days=offset), dt.time(12), tzinfo=dt.UTC),
+ )
+ for offset in days_ago
+ )
+
+ def _web_event(self, version: str, timestamp: dt.datetime) -> None:
+ _create_event(
+ team=self.team,
+ event="$pageview",
+ distinct_id="user",
+ timestamp=timestamp,
+ properties={"$lib": "web", "$lib_version": version},
+ )
+ flush_persons_and_events()
+
+ def test_sums_the_rollup_week_and_adds_events_since_it_ended(self) -> None:
+ self.team.timezone = "America/Phoenix"
+ self.team.save()
+ self._publish(range(1, 8), "1.0.0", count_per_day=10)
+ self._publish(range(8, 9), "0.9.0", count_per_day=10)
+ self._web_event("1.1.0", dt.datetime.now(dt.UTC))
+ self._web_event("1.0.0", dt.datetime.now(dt.UTC))
+
+ result = get_sdk_versions_for_team(self.team.id)
+
+ assert result is not None
+ assert [(entry["lib_version"], entry["count"], entry["max_timestamp"]) for entry in result["web"]] == [
+ ("1.1.0", 1, "2026-10-29 12:00:00+00:00"),
+ ("1.0.0", 71, "2026-10-29 12:00:00+00:00"),
+ ]
+
+ def test_falls_back_to_raw_events_when_the_rollup_is_stale(self) -> None:
+ self._publish(range(3, 10), "1.0.0", count_per_day=10)
+ self._web_event("2.0.0", dt.datetime.now(dt.UTC) - dt.timedelta(days=2))
+
+ result = get_sdk_versions_for_team(self.team.id)
+
+ assert result is not None
+ assert [(entry["lib_version"], entry["count"]) for entry in result["web"]] == [("2.0.0", 1)]
+
+ def test_reads_every_live_version_past_the_default_hogql_row_limit(self) -> None:
+ for patch_version in range(150):
+ _create_event(
+ team=self.team,
+ event="$pageview",
+ distinct_id="user",
+ timestamp=dt.datetime.now(dt.UTC),
+ properties={"$lib": "web", "$lib_version": f"1.0.{patch_version}"},
+ )
+ flush_persons_and_events()
+
+ result = get_sdk_versions_for_team(self.team.id)
+
+ assert result is not None
+ assert len(result["web"]) == 150
diff --git a/products/growth/frontend/generated/api.schemas.ts b/products/growth/frontend/generated/api.schemas.ts
index 068f958f472b..c2ecd1b563ca 100644
--- a/products/growth/frontend/generated/api.schemas.ts
+++ b/products/growth/frontend/generated/api.schemas.ts
@@ -886,7 +886,7 @@ export const IdentityMatchingLinksListTier = {
export type SdkHealthReportRetrieveParams = {
/**
- * When true, bypasses the Redis cache and re-queries ClickHouse for SDK usage. A background job refreshes this data once a day, so the cached answer is usually current. Use sparingly.
+ * When true, bypasses the cache and re-reads SDK usage. The cached answer is at most an hour old, so use this sparingly.
*/
force_refresh?: boolean
}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 75fb305892c2..c09a61db6a6f 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -141730,7 +141730,7 @@ export namespace Schemas {
export type SdkHealthReportRetrieveParams = {
/**
- * When true, bypasses the Redis cache and re-queries ClickHouse for SDK usage. A background job refreshes this data once a day, so the cached answer is usually current. Use sparingly.
+ * When true, bypasses the cache and re-reads SDK usage. The cached answer is at most an hour old, so use this sparingly.
*/
force_refresh?: boolean;
};