: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(engineering-analytics): correct deployment metrics and scope (#95595)
Paul D'Ambra6170ead4d667
diff --git a/products/engineering_analytics/backend/facade/api.py b/products/engineering_analytics/backend/facade/api.pyindex ac801c8344b0..73319508f325 100644--- a/products/engineering_analytics/backend/facade/api.py+++ b/products/engineering_analytics/backend/facade/api.py@@ -502,7 +502,7 @@ def get_dora_overview(team: Team,date_from: str | None = None,date_to: str | None = None,- environments: list[str] | None = None,+ validated_environments: list[str] | None = None,github_team: str | None = None,granularity: str | None = None,source_id: str | None = None,@@ -513,12 +513,30 @@ def get_dora_overview(curated=_authorized_source(team, source_id, user_access_control, repo=repo),date_from=date_from,date_to=date_to,- environments=environments,+ validated_environments=validated_environments,github_team=github_team,granularity=granularity,)+def get_dora_environment_choices(+ environments: list[str],+ *,+ team: Team,+ date_from: str | None = None,+ date_to: str | None = None,+ source_id: str | None = None,+ repo: str | None = None,+ user_access_control: "UserAccessControl | None" = None,+) -> list[str]:+ return logic.get_dora_environment_choices(+ environments=environments,+ curated=_authorized_source(team, source_id, user_access_control, repo=repo),+ date_from=date_from,+ date_to=date_to,+ )++def get_current_branch_health(*,team: Team,diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.pyindex c90881a639f7..7b6efbde913f 100644--- a/products/engineering_analytics/backend/facade/contracts.py+++ b/products/engineering_analytics/backend/facade/contracts.py@@ -1336,18 +1336,12 @@ class DoraOverview:# False when the deployments/deployment_statuses tables aren't synced for the selected repo.deploy_data_available: bool- # What the environment filter resolved to: the exact environment name(s) it matches —- # the caller's picks (comma-joined when several), or by default the busiest environment- # GitHub marks production, falling back to the busiest persistent environment, so a- # multi-region repo doesn't multiply every count — or 'persistent' (no persistent- # environment deployed in the window at all, so every non-transient one counts). Transient- # environments (ephemeral per-PR previews) never join a default scope. The scope resolves- # from deployments in the scan window, so two different windows can resolve different- # scopes and are not always comparable.+ # Display label only; selected_environments carries the exact names without delimiter ambiguity.environment_scope: str# Distinct persistent environments deployed to in the scan window, most-deployed first — the# picker's options. Transient environments are omitted but stay reachable by exact name.environments: list[str]+ selected_environments: list[str]# True when the optional team-membership snapshot is synced (the github_team filter's substrate).has_membership_data: bool# Distinct GitHub team slugs from the membership snapshot, sorted — the team picker's options.diff --git a/products/engineering_analytics/backend/logic/__init__.py b/products/engineering_analytics/backend/logic/__init__.pyindex 0772839cbfe6..1e45470efca9 100644--- a/products/engineering_analytics/backend/logic/__init__.py+++ b/products/engineering_analytics/backend/logic/__init__.py@@ -18,7 +18,10 @@ from products.engineering_analytics.backend.logic.ci_signals_config import (get_ci_signals_config as get_ci_signals_config,update_ci_signals_config as update_ci_signals_config,)-from products.engineering_analytics.backend.logic.dora import build_dora_overview as build_dora_overview+from products.engineering_analytics.backend.logic.dora import (+ build_dora_overview as build_dora_overview,+ get_dora_environment_choices as get_dora_environment_choices,+)from products.engineering_analytics.backend.logic.pull_requests import (build_author_workflow_costs as build_author_workflow_costs,build_ci_cards as build_ci_cards,diff --git a/products/engineering_analytics/backend/logic/dora.py b/products/engineering_analytics/backend/logic/dora.pyindex a0a7f36cc86c..512ec94247e0 100644--- a/products/engineering_analytics/backend/logic/dora.py+++ b/products/engineering_analytics/backend/logic/dora.py@@ -6,7 +6,10 @@ from products.engineering_analytics.backend.facade.contracts import DoraOverviewfrom products.engineering_analytics.backend.logic._shared import _DEFAULT_WINDOW, _parse_windowfrom products.engineering_analytics.backend.logic.queries._buckets import Granularityfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource-from products.engineering_analytics.backend.logic.queries.dora import query_dora_overview+from products.engineering_analytics.backend.logic.queries.dora import (+ query_dora_environment_choices,+ query_dora_overview,+)_GRANULARITIES: tuple[Granularity, ...] = get_args(Granularity)@@ -16,7 +19,7 @@ def build_dora_overview(curated: CuratedGitHubSource,date_from: str | None = None,date_to: str | None = None,- environments: list[str] | None = None,+ validated_environments: list[str] | None = None,github_team: str | None = None,granularity: str | None = None,) -> DoraOverview:@@ -26,13 +29,20 @@ def build_dora_overview(if granularity not in _GRANULARITIES:raise ValueError(f"granularity must be one of {', '.join(_GRANULARITIES)}")parsed_granularity = cast(Granularity, granularity)- # Blank means "no filter", matching the branch-filter convention.- environments_filter = [name.strip() for name in (environments or []) if name.strip()]return query_dora_overview(curated=curated,date_from=parsed_from,date_to=parsed_to,- environments_filter=environments_filter or None,+ validated_environments=validated_environments,github_team=(github_team or "").strip() or None,granularity=parsed_granularity,)+++def get_dora_environment_choices(+ *, curated: CuratedGitHubSource, environments: list[str], date_from: str | None = None, date_to: str | None = None+) -> list[str]:+ parsed_from, parsed_to = _parse_window(curated.team, date_from, date_to, default=_DEFAULT_WINDOW)+ return query_dora_environment_choices(+ curated=curated, environments=environments, date_from=parsed_from, date_to=parsed_to+ )diff --git a/products/engineering_analytics/backend/logic/queries/dora.py b/products/engineering_analytics/backend/logic/queries/dora.pyindex b6657392eeb8..0226af8480b2 100644--- a/products/engineering_analytics/backend/logic/queries/dora.py+++ b/products/engineering_analytics/backend/logic/queries/dora.py@@ -26,7 +26,6 @@ surface, aggregates only (SPEC §6). Deploy counts are repo events and ignore thteam filter by design."""-import refrom datetime import datetime, timedeltafrom typing import Any@@ -62,9 +61,7 @@ _MERGE_SCAN_LOOKBACK = timedelta(days=30)# per-repo and small enough that the wider floor costs nothing measurable._DEPLOY_SCAN_SLACK = timedelta(days=7)-# `prod`, `production`, and their regional/suffixed forms (`prod-us`, `Production-EU`), any case.-# Anchored so `preview-pr-123` and `reproduction` do not read as production.-_PRODUCTION_NAME_PATTERN = re.compile(r"^prod(uction)?([-_.].*)?$", re.IGNORECASE)+_ENVIRONMENT_LOOKBACK = timedelta(days=30)_ENVIRONMENTS_LIMIT = 100_TEAMS_LIMIT = 500@@ -76,14 +73,16 @@ _TEAMS_LIMIT = 500# Assumes one deployment id per attempt (GitHub's normal shape): a deployment carrying both a# failure and a later success status on the same id would count toward both outcomes and could# pair with itself in the restore self-join.+# minOrNullIf is required even when a source has non-null timestamps: minIf returns an epoch+# for a missing outcome, which would win every first-deployment attribution._DEPLOYS_CTE = """deploys AS (SELECTd.id AS id,any(d.sha) AS sha,any(d.environment) AS environment,- minIf(s.created_at, s.state = 'success') AS first_success_at,- minIf(s.created_at, s.state IN ('failure', 'error')) AS first_failure_at+ minOrNullIf(s.created_at, s.state = 'success') AS first_success_at,+ minOrNullIf(s.created_at, s.state IN ('failure', 'error')) AS first_failure_atFROM __DEPLOYMENTS_SOURCE__ AS dINNER JOIN __STATUSES_SOURCE__ AS s ON s.deployment_id = d.idWHERE d.created_at >= {deploy_scan_floor} AND __ENV_PREDICATE__@@ -283,14 +282,33 @@ _LEAD_TIME_SERIES_SELECT = f"""# options and the default scope: a busy repo deploys previews hundreds of times a week, which# would swamp every deploy count. An exact ``environment`` filter can still reach one by name._ENVIRONMENTS_SELECT = f"""- SELECT environment, max(is_production_environment) AS is_production, count() AS n+ SELECT environment, count() AS nFROM __DEPLOYMENTS_SOURCE__ AS d- WHERE d.created_at >= {{prev_from}} AND NOT d.is_transient_environment __DATE_TO_CREATED__+ WHERE d.created_at >= {{environment_scan_floor}} AND NOT d.is_transient_environment __DATE_TO_CREATED__GROUP BY environmentORDER BY n DESC, environment ASCLIMIT {_ENVIRONMENTS_LIMIT}"""+# Keep default production resolution separate from the capped picker query. Returning one aggregate+# row also avoids HogQL's implicit row limit when a repository has more than 100 production regions.+_PRODUCTION_ENVIRONMENTS_SELECT = """+ SELECT groupUniqArray(environment) AS environments+ FROM __DEPLOYMENTS_SOURCE__ AS d+ WHERE d.created_at >= {environment_scan_floor}+ AND NOT d.is_transient_environment+ AND (d.is_production_environment OR match(lower(d.environment), '^prod(uction)?([-_.].*)?$'))+ __DATE_TO_CREATED__+"""++_ENVIRONMENT_CHOICES_SELECT = """+ SELECT groupUniqArray(environment) AS environments+ FROM __DEPLOYMENTS_SOURCE__ AS d+ WHERE d.created_at >= {environment_scan_floor}+ AND d.environment IN {requested_environments}+ __DATE_TO_CREATED__+"""+_TEAMS_SELECT = f"""SELECT DISTINCT team_slugFROM __MEMBERS_SOURCE__ AS m@@ -344,43 +362,31 @@ class _DoraScan:def _resolve_environment_scope(- environments_filter: list[str] | None, environments: list[tuple[str, bool]]+ requested_environments: list[str] | None,+ environments: list[str],+ production_environments: list[str],) -> _EnvironmentScope:- """Pick the deploy population: the caller's exact environment(s) when given; otherwise the- single busiest environment GitHub marks production; otherwise the busiest environment whose- NAME says production; otherwise the single busiest persistent environment, so a repo that- never sets the production flag still gets numbers instead of a false zero.- The name tier exists because the ``production_environment`` flag is optional and widely- unset, and a dev or staging environment can deploy more often than production, which would- put every default DORA figure on that environment.- Busiest-single, not every-matching: a multi-region repo deploys each merge to several- production and persistent environments (and to dev, package registries, ...), which would- multiply every deploy count and hand lead time to whichever region deploys first.- 'persistent' survives only when the window has no persistent environment at all. Transient- environments never join a default scope: they are ephemeral per-PR previews, and on this- repo they outnumber real deploys by an order of magnitude."""- if environments_filter:+ if requested_environments is not None:+ if requested_environments:+ return _EnvironmentScope(+ scope=", ".join(requested_environments),+ predicate="d.environment IN {environments}",+ values=requested_environments,+ )+ return _EnvironmentScope(scope="No matching environments", predicate="0 = 1", values=[])++ if production_environments:return _EnvironmentScope(- scope=", ".join(environments_filter),+ scope=", ".join(production_environments),predicate="d.environment IN {environments}",- values=environments_filter,+ values=production_environments,)- # ``environments`` arrives busiest-first, so the first match in each tier is the busiest match.- production = next((name for name, is_production in environments if is_production), None)- if production is not None:- return _single_environment_scope(production)- named = next((name for name, _ in environments if _PRODUCTION_NAME_PATTERN.match(name)), None)- if named is not None:- return _single_environment_scope(named)if environments:- return _single_environment_scope(environments[0][0])+ fallback = environments[0]+ return _EnvironmentScope(scope=fallback, predicate="d.environment IN {environments}", values=[fallback])return _EnvironmentScope(scope="persistent", predicate="NOT d.is_transient_environment", values=None)-def _single_environment_scope(name: str) -> _EnvironmentScope:- return _EnvironmentScope(scope=name, predicate="d.environment IN {environments}", values=[name])--def _empty_overview(*,deploy_data_available: bool,@@ -394,6 +400,7 @@ def _empty_overview(deploy_data_available=deploy_data_available,environment_scope=environment_scope,environments=environments,+ selected_environments=[],has_membership_data=has_membership_data,github_teams=github_teams,deployment_count=0,@@ -603,7 +610,7 @@ def query_dora_overview(curated: CuratedGitHubSource,date_from: datetime,date_to: datetime | None,- environments_filter: list[str] | None = None,+ validated_environments: list[str] | None = None,github_team: str | None = None,granularity: Granularity | None = None,) -> DoraOverview:@@ -616,7 +623,7 @@ def query_dora_overview(if deploy_sources is None:return _empty_overview(deploy_data_available=False,- environment_scope=", ".join(environments_filter) if environments_filter else "persistent",+ environment_scope=", ".join(validated_environments) if validated_environments else "persistent",environments=[],has_membership_data=has_membership_data,github_teams=github_teams,@@ -630,6 +637,7 @@ def query_dora_overview(placeholders: dict[str, ast.Expr] = {"date_from": ast.Constant(value=date_from),"prev_from": ast.Constant(value=prev_from),+ "environment_scan_floor": ast.Constant(value=_environment_scan_floor(date_from, end)),"deploy_scan_floor": ast.Constant(value=prev_from - _DEPLOY_SCAN_SLACK),"merge_scan_floor": ast.Constant(value=prev_from - _MERGE_SCAN_LOOKBACK),}@@ -642,7 +650,21 @@ def query_dora_overview(placeholders=placeholders,date_to_filter=_date_to_clause(date_to, "d.created_at"),)- env_scope = _resolve_environment_scope(environments_filter, environments)+ production_environments = (+ _query_production_environments(+ curated,+ deploy_sources.deployments,+ placeholders=placeholders,+ date_to_filter=_date_to_clause(date_to, "d.created_at"),+ )+ if validated_environments is None+ else []+ )+ env_scope = _resolve_environment_scope(+ validated_environments,+ environments,+ production_environments,+ )# The busiest-environment fallbacks bind the same placeholder as an explicit filter: either# way ``values`` holds exactly the environment names the predicate matches.if env_scope.values is not None:@@ -667,7 +689,8 @@ def query_dora_overview(return DoraOverview(deploy_data_available=True,environment_scope=env_scope.scope,- environments=[name for name, _ in environments],+ environments=environments,+ selected_environments=env_scope.values or [],has_membership_data=has_membership_data,github_teams=github_teams,deployment_count=outcomes.deployment_count,@@ -736,13 +759,66 @@ def _query_environments(*,placeholders: dict[str, ast.Expr],date_to_filter: str,-) -> list[tuple[str, bool]]:- """``(environment, is_production)`` pairs deployed to in the scan window, most-deployed first."""+) -> list[str]:+ """Persistent environments deployed to in the scan window, most-deployed first."""sql = _ENVIRONMENTS_SELECT.replace("__DEPLOYMENTS_SOURCE__", deployments_source).replace("__DATE_TO_CREATED__", date_to_filter)response = curated.run(sql, query_type="engineering_analytics.dora_environments", placeholders=placeholders)- return [(str(name), bool(is_production)) for name, is_production, _ in (response.results or []) if name]+ return [str(name) for name, _ in (response.results or []) if name]+++def _environment_scan_floor(date_from: datetime, date_to: datetime) -> datetime:+ prev_from = date_from - (date_to - date_from)+ return min(prev_from - _DEPLOY_SCAN_SLACK, date_to - _ENVIRONMENT_LOOKBACK)+++def _query_production_environments(+ curated: CuratedGitHubSource,+ deployments_source: str,+ *,+ placeholders: dict[str, ast.Expr],+ date_to_filter: str,+) -> list[str]:+ sql = _PRODUCTION_ENVIRONMENTS_SELECT.replace("__DEPLOYMENTS_SOURCE__", deployments_source).replace(+ "__DATE_TO_CREATED__", date_to_filter+ )+ response = curated.run(+ sql,+ query_type="engineering_analytics.dora_production_environments",+ placeholders=placeholders,+ )+ names = response.results[0][0] if response.results else []+ return sorted(str(name) for name in names or [] if name)+++def query_dora_environment_choices(+ *,+ curated: CuratedGitHubSource,+ environments: list[str],+ date_from: datetime,+ date_to: datetime | None,+) -> list[str]:+ deploy_sources = curated.deploy_sources()+ if deploy_sources is None or not environments:+ return []+ end = date_to or datetime.now(tz=date_from.tzinfo)+ placeholders: dict[str, ast.Expr] = {+ "environment_scan_floor": ast.Constant(value=_environment_scan_floor(date_from, end)),+ "requested_environments": ast.Tuple(exprs=[ast.Constant(value=name) for name in environments]),+ }+ if date_to is not None:+ placeholders["date_to"] = ast.Constant(value=date_to)+ sql = _ENVIRONMENT_CHOICES_SELECT.replace("__DEPLOYMENTS_SOURCE__", deploy_sources.deployments).replace(+ "__DATE_TO_CREATED__", _date_to_clause(date_to, "d.created_at")+ )+ response = curated.run(+ sql,+ query_type="engineering_analytics.dora_environment_choices",+ placeholders=placeholders,+ )+ names = response.results[0][0] if response.results else []+ return sorted(str(name) for name in names or [] if name)def _query_github_teams(curated: CuratedGitHubSource, members_source: str | None) -> list[str]:diff --git a/products/engineering_analytics/backend/presentation/serializers/__init__.py b/products/engineering_analytics/backend/presentation/serializers/__init__.pyindex 494a2b455f57..8fc152ac4eec 100644--- a/products/engineering_analytics/backend/presentation/serializers/__init__.py+++ b/products/engineering_analytics/backend/presentation/serializers/__init__.py@@ -1,6 +1,6 @@"""DRF serializers for engineering_analytics.-Output-only serializers that turn the facade's frozen dataclasses into JSON via+Request validation and response serializers that turn the facade's frozen dataclasses into JSON via``DataclassSerializer``, one module per surface area mirroring ``views/``. Fieldtypes are auto-derived from the contract types; ``help_text`` is added through``Meta.extra_kwargs`` so it flows downstream into the OpenAPI spec, generateddiff --git a/products/engineering_analytics/backend/presentation/serializers/dora.py b/products/engineering_analytics/backend/presentation/serializers/dora.pyindex 476954cec7d2..a8040bafa727 100644--- a/products/engineering_analytics/backend/presentation/serializers/dora.py+++ b/products/engineering_analytics/backend/presentation/serializers/dora.py@@ -1,5 +1,6 @@"""Payloads for the DORA deploy-metrics read."""+from rest_framework import serializersfrom rest_framework_dataclasses.serializers import DataclassSerializerfrom products.engineering_analytics.backend.facade.contracts import (@@ -9,6 +10,23 @@ from products.engineering_analytics.backend.facade.contracts import ()+class DoraEnvironmentQuerySerializer(serializers.Serializer):+ environment = serializers.ListField(+ child=serializers.CharField(),+ required=False,+ allow_empty=False,+ help_text="Deploy environments to scope to. Names are trimmed and deduplicated; blank or unknown names "+ "are rejected. Real transient environments are allowed. Omit to use the production default.",+ )++ def validate_environment(self, value: list[str]) -> list[str]:+ names = list(dict.fromkeys(value))+ choice = serializers.ChoiceField(choices=self.context["get_environment_choices"](names))+ for name in names:+ choice.run_validation(name)+ return names++class DeploymentFrequencyBucketSerializer(DataclassSerializer):class Meta:dataclass = DeploymentFrequencyBucket@@ -106,18 +124,18 @@ class DoraOverviewSerializer(DataclassSerializer):"selected repo; every other field is then empty or null, never a fake zero."},"environment_scope": {- "help_text": "What the environment filter resolved to: the exact environment name(s) it matches "- "(the caller's picks, comma-joined when several; by default the busiest production-marked "- "environment, falling back to the busiest persistent one), or 'persistent' (no persistent "- "environment deployed in the window, so every non-transient one counts). Transient environments "- "(ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in "- "the scan window, so two different windows can resolve different scopes and are not always "- "comparable."+ "help_text": "Display label for the selected environments, comma-separated, 'persistent' when no "+ "persistent environments were discovered. Use selected_environments for exact names."},"environments": {- "help_text": "Distinct persistent environments deployed to in the scan window, most-deployed "- "first — the environment picker's options. Transient environments are omitted but stay "- "reachable by exact name."+ "help_text": "Distinct persistent environments from the metric scan window or the 30 days before "+ "its end, whichever starts earlier, most-deployed first. Transient environments are omitted."+ },+ "selected_environments": {+ "help_text": "Exact environment names used for these metrics. Defaults to all persistent "+ "environments marked production or named prod/production (including regional suffixes), "+ "falling back to the busiest persistent environment. Explicit filters are trimmed and deduplicated. "+ "DRF rejects blank or unknown names; real transient names are allowed."},"has_membership_data": {"help_text": "True when the optional team-membership snapshot is synced. When false, a "diff --git a/products/engineering_analytics/backend/presentation/views/dora.py b/products/engineering_analytics/backend/presentation/views/dora.pyindex cf40532dc6b3..d7e80ac10811 100644--- a/products/engineering_analytics/backend/presentation/views/dora.py+++ b/products/engineering_analytics/backend/presentation/views/dora.py@@ -1,5 +1,7 @@"""DORA deploy-metrics read."""+from functools import partial+from drf_spectacular.types import OpenApiTypesfrom drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schemafrom rest_framework.decorators import action@@ -7,7 +9,10 @@ from rest_framework.request import Requestfrom rest_framework.response import Responsefrom products.engineering_analytics.backend.facade import api-from products.engineering_analytics.backend.presentation.serializers.dora import DoraOverviewSerializer+from products.engineering_analytics.backend.presentation.serializers.dora import (+ DoraEnvironmentQuerySerializer,+ DoraOverviewSerializer,+)from products.engineering_analytics.backend.presentation.views._base import (_DATE_FROM,_DATE_TO,@@ -28,8 +33,10 @@ _ENVIRONMENT = OpenApiParameter(# environment.explode=True,description="Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit "- "to scope to the busiest environment GitHub marks production, falling back to the busiest persistent "- "(non-transient) environment when none are marked production.",+ "to include all persistent environments marked production or named prod/production (including regional "+ "suffixes), falling back to the busiest persistent environment when none match. Explicit names are trimmed, "+ "deduplicated, and validated against the source, including transient environments. Blank or unknown names "+ "are rejected with a 400 response.",)_GRANULARITY = OpenApiParameter(@@ -58,10 +65,18 @@ class DoraActionsMixin(EngineeringAnalyticsViewSetBase):@extend_schema(operation_id="engineering_analytics_dora",- parameters=[_DATE_FROM, _DATE_TO, _ENVIRONMENT, _GITHUB_TEAM, _GRANULARITY, _SOURCE_ID, _REPO],+ parameters=[+ _DATE_FROM,+ _DATE_TO,+ _ENVIRONMENT,+ _GITHUB_TEAM,+ _GRANULARITY,+ _SOURCE_ID,+ _REPO,+ ],responses={200: DoraOverviewSerializer,- 400: OpenApiResponse(description="Invalid date_from, date_to, granularity, or source_id."),+ 400: OpenApiResponse(description="Invalid environment, date_from, date_to, granularity, or source_id."),},description=("DORA-style deploy metrics over the GitHub deployments + deployment_statuses warehouse pair, each "@@ -74,11 +89,26 @@ class DoraActionsMixin(EngineeringAnalyticsViewSetBase):@action(detail=False, methods=["get"], pagination_class=None)def dora(self, request: Request, **kwargs) -> Response:try:+ query = DoraEnvironmentQuerySerializer(+ data=request.query_params,+ context={+ "get_environment_choices": partial(+ api.get_dora_environment_choices,+ team=self.team,+ date_from=request.query_params.get("date_from") or None,+ date_to=request.query_params.get("date_to") or None,+ source_id=request.query_params.get("source_id") or None,+ repo=request.query_params.get("repo") or None,+ user_access_control=self.user_access_control,+ )+ },+ )+ query.is_valid(raise_exception=True)result = api.get_dora_overview(team=self.team,date_from=request.query_params.get("date_from") or None,date_to=request.query_params.get("date_to") or None,- environments=request.query_params.getlist("environment") or None,+ validated_environments=query.validated_data.get("environment"),github_team=request.query_params.get("github_team") or None,granularity=request.query_params.get("granularity") or None,source_id=request.query_params.get("source_id") or None,diff --git a/products/engineering_analytics/backend/tests/test_dora.py b/products/engineering_analytics/backend/tests/test_dora.pyindex e57addc6fef5..ec785c82db64 100644--- a/products/engineering_analytics/backend/tests/test_dora.py+++ b/products/engineering_analytics/backend/tests/test_dora.py@@ -3,12 +3,19 @@ from typing import Anyfrom posthog.test.base import APIBaseTest, BaseTest, ClickhouseTestMixin+from django.http import QueryDict+from django.test import SimpleTestCase++from parameterized import parameterizedfrom rest_framework import statusfrom posthog.models.team import Teamfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource-from products.engineering_analytics.backend.logic.queries.dora import query_dora_overview+from products.engineering_analytics.backend.logic.queries.dora import (+ query_dora_environment_choices,+ query_dora_overview,+)from products.engineering_analytics.backend.logic.sources import GitHubTablesfrom products.engineering_analytics.backend.logic.views.source_schema import (DEPLOYMENT_STATUSES_COLUMNS,@@ -16,6 +23,7 @@ from products.engineering_analytics.backend.logic.views.source_schema import (PULL_REQUESTS_COLUMNS,TEAM_MEMBERS_COLUMNS,)+from products.engineering_analytics.backend.presentation.serializers.dora import DoraEnvironmentQuerySerializerfrom products.engineering_analytics.backend.tests._github_fixtures import (_pr_row,connect_github_source_without_data,@@ -23,6 +31,31 @@ from products.engineering_analytics.backend.tests._github_fixtures import ()+class TestDoraEnvironmentQuerySerializer(SimpleTestCase):+ @parameterized.expand(+ [+ ("", None),+ ("environment=%20prod-us%20&environment=prod-eu&environment=prod-us", ["prod-us", "prod-eu"]),+ ("environment=preview-pr-1", ["preview-pr-1"]),+ ]+ )+ def test_valid_environment_selection(self, query: str, expected: list[str] | None) -> None:+ serializer = DoraEnvironmentQuerySerializer(+ data=QueryDict(query),+ context={"get_environment_choices": lambda names: ["prod-eu", "prod-us", "preview-pr-1"]},+ )+ assert serializer.is_valid(), serializer.errors+ assert serializer.validated_data.get("environment") == expected++ @parameterized.expand([("environment=",), ("environment=%20",), ("environment=prod-us&environment=unknown",)])+ def test_rejects_invalid_environment_selection(self, query: str) -> None:+ serializer = DoraEnvironmentQuerySerializer(+ data=QueryDict(query), context={"get_environment_choices": lambda names: ["prod-us"]}+ )+ assert not serializer.is_valid()+ assert "environment" in serializer.errors++def _deployment_row(deployment_id: int, sha: str, environment: str, created_at: str, *, production: bool, transient: bool = False) -> dict:@@ -74,8 +107,26 @@ class TestDoraEndpoint(ClickhouseTestMixin, APIBaseTest):assert payload["deployment_frequency_series"] == []assert payload["merge_to_deploy_series"] == []+ response = self.client.get(f"/api/projects/{self.team.id}/engineering_analytics/dora/", {"environment": " "})+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.content+class TestDoraQuery(ClickhouseTestMixin, BaseTest):+ def _validated_environments(self, curated: CuratedGitHubSource, names: list[str]) -> list[str]:+ serializer = DoraEnvironmentQuerySerializer(+ data={"environment": names},+ context={+ "get_environment_choices": lambda environments: query_dora_environment_choices(+ curated=curated,+ environments=environments,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ )+ },+ )+ serializer.is_valid(raise_exception=True)+ return serializer.validated_data["environment"]+def _curated(self,team: Team,@@ -84,13 +135,19 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):status_rows: list[dict[str, Any]],pr_rows: list[dict[str, Any]],member_rows: list[dict[str, Any]] | None = None,+ nullable_status_timestamps: bool = True,) -> CuratedGitHubSource:deployments_table = create_github_warehouse_table(self, "github_deployments", DEPLOYMENTS_COLUMNS, deployment_rows)- statuses_table = create_github_warehouse_table(- self, "github_deployment_statuses", DEPLOYMENT_STATUSES_COLUMNS, status_rows- )+ status_columns = {+ **DEPLOYMENT_STATUSES_COLUMNS,+ "created_at": {+ **DEPLOYMENT_STATUSES_COLUMNS["created_at"],+ "clickhouse": "Nullable(String)" if nullable_status_timestamps else "String",+ },+ }+ statuses_table = create_github_warehouse_table(self, "github_deployment_statuses", status_columns, status_rows)pr_table = create_github_warehouse_table(self, "github_pull_requests", PULL_REQUESTS_COLUMNS, pr_rows)members_table = (create_github_warehouse_table(self, "github_team_members", TEAM_MEMBERS_COLUMNS, member_rows)@@ -394,6 +451,32 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):)assert result.deployment_count == 1+ assert result.environments == ["prod"]+ assert result.selected_environments == ["prod"]++ def test_environment_discovery_covers_the_deployment_scan_slack(self):+ curated = self._curated(+ self.team,+ deployment_rows=[+ _deployment_row(1, "sha-eu", "prod-eu", "2025-12-29 09:00:00", production=True),+ _deployment_row(2, "sha-us", "prod-us", "2026-01-20 09:00:00", production=True),+ ],+ status_rows=[+ _status_row(11, 1, "success", "prod-eu", "2026-01-02 10:00:00"),+ _status_row(21, 2, "success", "prod-us", "2026-01-20 10:00:00"),+ ],+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-01 08:00:00")],+ )+ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 16, tzinfo=UTC),+ date_to=datetime(2026, 1, 31, tzinfo=UTC),+ )++ assert result.environments == ["prod-eu", "prod-us"]+ assert result.selected_environments == ["prod-eu", "prod-us"]+ assert result.deployment_count == 1+ assert result.deployment_count_prev == 1def test_exact_environment_scope(self):# A dedicated fixture, not _seeded_curated: that shared fixture's PR 5 (merged Jan 5) has@@ -425,7 +508,7 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):curated=curated,date_from=datetime(2026, 1, 10, tzinfo=UTC),date_to=datetime(2026, 1, 20, tzinfo=UTC),- environments_filter=["staging"],+ validated_environments=self._validated_environments(curated, ["staging"]),)assert result.environment_scope == "staging"@@ -438,24 +521,105 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):curated=curated,date_from=datetime(2026, 1, 10, tzinfo=UTC),date_to=datetime(2026, 1, 20, tzinfo=UTC),- environments_filter=["staging", "prod"],+ validated_environments=self._validated_environments(curated, [" staging ", "prod", "staging"]),granularity="week",)assert both.environment_scope == "staging, prod"+ assert both.selected_environments == ["staging", "prod"]assert both.deployment_count == 2 # the multi-environment scope admits d1 and d4assert both.series_granularity == "week" # the caller's override beats the window fit- def test_default_scope_picks_busiest_production_environment(self):- # Two production-marked regions: the default scope takes the busiest one, so a- # multi-region repo doesn't double-count every deploy and hand lead time to- # whichever region ships first.+ def test_exact_environment_scope_can_select_a_transient_environment(self) -> None:curated = self._curated(self.team,deployment_rows=[- _deployment_row(1, "sha-a", "prod-us", "2026-01-12 09:30:00", production=True),- _deployment_row(2, "sha-b", "prod-us", "2026-01-13 09:30:00", production=True),- _deployment_row(3, "sha-c", "prod-eu", "2026-01-12 09:30:00", production=True),+ _deployment_row(1, "sha-a", "prod", "2026-01-12 09:30:00", production=True),+ _deployment_row(+ 2,+ "sha-b",+ "preview-pr-2",+ "2026-01-13 09:30:00",+ production=False,+ transient=True,+ ),+ ],+ status_rows=[+ _status_row(11, 1, "success", "prod", "2026-01-12 10:00:00"),+ _status_row(21, 2, "success", "preview-pr-2", "2026-01-13 10:00:00"),+ ],+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-11 08:00:00")],+ )+ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ validated_environments=self._validated_environments(curated, ["preview-pr-2"]),+ )++ assert result.environments == ["prod"]+ assert result.selected_environments == ["preview-pr-2"]+ assert result.deployment_count == 1++ def test_exact_environment_lookup_is_not_limited_by_picker_options(self) -> None:+ deployment_rows = [+ _deployment_row(+ index,+ f"sha-{index}",+ f"environment-{index:03}",+ "2026-01-12 09:30:00",+ production=False,+ )+ for index in range(1, 102)+ ]+ status_rows = [+ _status_row(index + 1000, index, "success", f"environment-{index:03}", "2026-01-12 10:00:00")+ for index in range(1, 102)+ ]+ curated = self._curated(+ self.team,+ deployment_rows=deployment_rows,+ status_rows=status_rows,+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-11 08:00:00")],+ )+ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ validated_environments=self._validated_environments(curated, ["environment-101"]),+ )++ assert len(result.environments) == 100+ assert "environment-101" not in result.environments+ assert result.selected_environments == ["environment-101"]+ assert result.deployment_count == 1++ def test_environment_discovery_keeps_a_quiet_persistent_option(self) -> None:+ curated = self._curated(+ self.team,+ deployment_rows=[_deployment_row(1, "sha-a", "staging", "2026-01-05 09:30:00", production=False)],+ status_rows=[_status_row(11, 1, "success", "staging", "2026-01-05 10:00:00")],+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-01 08:00:00")],+ )+ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 20, tzinfo=UTC),+ date_to=datetime(2026, 1, 31, tzinfo=UTC),+ )++ assert result.environments == ["staging"]+ assert result.selected_environments == ["staging"]+ assert result.deployment_count == 0+ assert result.deployment_count_prev == 0++ @parameterized.expand([(True, True), (False, False), (True, False)])+ def test_default_scope_includes_production_regions(self, us_production: bool, eu_production: bool) -> None:+ curated = self._curated(+ self.team,+ deployment_rows=[+ _deployment_row(1, "sha-a", "prod-us", "2026-01-12 09:30:00", production=us_production),+ _deployment_row(2, "sha-b", "prod-us", "2026-01-13 09:30:00", production=us_production),+ _deployment_row(3, "sha-c", "prod-eu", "2026-01-12 09:30:00", production=eu_production),],status_rows=[_status_row(11, 1, "success", "prod-us", "2026-01-12 10:00:00"),@@ -470,6 +634,165 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):date_to=datetime(2026, 1, 20, tzinfo=UTC),)- assert result.environment_scope == "prod-us"+ assert result.environment_scope == "prod-eu, prod-us"assert result.environments == ["prod-us", "prod-eu"]+ assert result.selected_environments == ["prod-eu", "prod-us"]+ assert result.deployment_count == 3++ def test_default_production_scope_is_not_limited_by_picker_options(self) -> None:+ deployment_rows = [+ _deployment_row(+ index * 10 + repetition,+ f"staging-sha-{index}-{repetition}",+ f"staging-{index:03}",+ "2026-01-12 09:00:00",+ production=False,+ )+ for index in range(1, 101)+ for repetition in range(2)+ ]+ deployment_rows.extend(+ [+ _deployment_row(2001, "prod-us-sha", "prod-us", "2026-01-12 09:00:00", production=False),+ _deployment_row(2002, "prod-eu-sha", "prod-eu", "2026-01-12 09:00:00", production=False),+ ]+ )+ curated = self._curated(+ self.team,+ deployment_rows=deployment_rows,+ status_rows=[+ _status_row(3001, 2001, "success", "prod-us", "2026-01-12 10:00:00"),+ _status_row(3002, 2002, "success", "prod-eu", "2026-01-12 10:00:00"),+ ],+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-11 08:00:00")],+ )++ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ )++ assert len(result.environments) == 100+ assert "prod-us" not in result.environments+ assert "prod-eu" not in result.environments+ assert result.selected_environments == ["prod-eu", "prod-us"]assert result.deployment_count == 2++ def test_default_scope_includes_flagged_names_and_excludes_transient_production_names(self) -> None:+ curated = self._curated(+ self.team,+ deployment_rows=[+ _deployment_row(1, "custom-sha", "release", "2026-01-12 09:00:00", production=True),+ _deployment_row(+ 2,+ "preview-sha",+ "prod-preview",+ "2026-01-12 09:00:00",+ production=True,+ transient=True,+ ),+ ],+ status_rows=[+ _status_row(11, 1, "success", "release", "2026-01-12 10:00:00"),+ _status_row(21, 2, "success", "prod-preview", "2026-01-12 10:00:00"),+ ],+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-11 08:00:00")],+ )++ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ )++ assert result.selected_environments == ["release"]+ assert result.deployment_count == 1++ def test_default_scope_includes_more_than_one_hundred_production_environments(self) -> None:+ deployment_rows = [+ _deployment_row(+ index,+ f"sha-{index}",+ f"prod-{index:03}",+ "2026-01-12 09:00:00",+ production=False,+ )+ for index in range(1, 102)+ ]+ status_rows = [+ _status_row(index + 1000, index, "success", f"prod-{index:03}", "2026-01-12 10:00:00")+ for index in range(1, 102)+ ]+ curated = self._curated(+ self.team,+ deployment_rows=deployment_rows,+ status_rows=status_rows,+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-11 08:00:00")],+ )++ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ )++ assert len(result.environments) == 100+ assert len(result.selected_environments) == 101+ assert result.selected_environments == [f"prod-{index:03}" for index in range(1, 102)]+ assert result.deployment_count == 101++ explicitly_selected = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ validated_environments=self._validated_environments(+ curated, [f"prod-{index:03}" for index in range(1, 102)]+ ),+ )+ assert explicitly_selected.selected_environments == [f"prod-{index:03}" for index in range(1, 102)]+ assert explicitly_selected.deployment_count == 101++ @parameterized.expand([(True,), (False,)])+ def test_unsuccessful_deploy_cannot_hide_a_later_success(self, nullable_status_timestamps: bool) -> None:+ curated = self._curated(+ self.team,+ deployment_rows=[+ _deployment_row(1, "merge-a", "prod", "2026-01-12 09:00:00", production=True),+ _deployment_row(2, "merge-a", "prod", "2026-01-12 11:00:00", production=True),+ ],+ status_rows=[+ _status_row(11, 1, "failure", "prod", "2026-01-12 10:00:00"),+ _status_row(21, 2, "success", "prod", "2026-01-12 12:00:00"),+ ],+ nullable_status_timestamps=nullable_status_timestamps,+ pr_rows=[+ _pr_row(+ 1,+ "alice",+ "closed",+ 0,+ "2026-01-11 08:00:00",+ merged_at="2026-01-12 08:00:00",+ merge_commit_sha="merge-a",+ ),+ ],+ )+ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ )++ assert result.deployed_pr_count == 1+ assert result.median_open_to_deploy_seconds == 28 * 3600+ assert result.median_merge_to_deploy_seconds == 4 * 3600+ assert result.median_failed_deploy_to_next_success_seconds == 2 * 3600+ for series, median in [+ (result.open_to_deploy_series, 28 * 3600),+ (result.open_to_merge_series, 24 * 3600),+ (result.merge_to_deploy_series, 4 * 3600),+ ]:+ populated = [bucket for bucket in series if bucket.deployed_pr_count]+ assert len(populated) == 1+ assert populated[0].p50_seconds == mediandiff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.tsindex 7dd8e3e301bf..6868b75afe83 100644--- a/products/engineering_analytics/frontend/generated/api.schemas.ts+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts@@ -266,10 +266,12 @@ export interface DoraOverviewApi {open_to_deploy_series: LeadTimeBucketApi[]/** False when the deployments/deployment_statuses tables aren't synced for the selected repo; every other field is then empty or null, never a fake zero. */deploy_data_available: boolean- /** What the environment filter resolved to: the exact environment name(s) it matches (the caller's picks, comma-joined when several; by default the busiest production-marked environment, falling back to the busiest persistent one), or 'persistent' (no persistent environment deployed in the window, so every non-transient one counts). Transient environments (ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in the scan window, so two different windows can resolve different scopes and are not always comparable. */+ /** Display label for the selected environments, comma-separated, 'persistent' when no persistent environments were discovered. Use selected_environments for exact names. */environment_scope: string- /** Distinct persistent environments deployed to in the scan window, most-deployed first — the environment picker's options. Transient environments are omitted but stay reachable by exact name. */+ /** Distinct persistent environments from the metric scan window or the 30 days before its end, whichever starts earlier, most-deployed first. Transient environments are omitted. */environments: string[]+ /** Exact environment names used for these metrics. Defaults to all persistent environments marked production or named prod/production (including regional suffixes), falling back to the busiest persistent environment. Explicit filters are trimmed and deduplicated. DRF rejects blank or unknown names; real transient names are allowed. */+ selected_environments: string[]/** True when the optional team-membership snapshot is synced. When false, a github_team filter cannot be honored and the merge-to-deploy figures go empty rather than silently unfiltered. */has_membership_data: boolean/** Distinct GitHub team slugs from the membership snapshot, sorted — the team picker's options. Empty when membership isn't synced. */@@ -1741,7 +1743,7 @@ export type EngineeringAnalyticsDoraParams = {*/date_to?: string/**- * Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit to scope to the busiest environment GitHub marks production, falling back to the busiest persistent (non-transient) environment when none are marked production.+ * Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit to include all persistent environments marked production or named prod/production (including regional suffixes), falling back to the busiest persistent environment when none match. Explicit names are trimmed, deduplicated, and validated against the source, including transient environments. Blank or unknown names are rejected with a 400 response.*/environment?: string[]/**diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsxindex a100a292f946..d495efe10dcc 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsx@@ -58,6 +58,7 @@ function leadTimeSeries(stats: (number[] | null)[]): DoraOverviewApi['merge_to_dconst DORA: DoraOverviewApi = {deploy_data_available: true,environment_scope: 'prod-us',+ selected_environments: ['prod-us'],environments: ['prod-us', 'prod-eu', 'dev'],has_membership_data: true,github_teams: ['team-devex', 'team-ingestion', 'team-replay'],@@ -94,6 +95,7 @@ const EMPTY_DORA: DoraOverviewApi = {...DORA,deploy_data_available: false,environment_scope: 'persistent',+ selected_environments: [],environments: [],github_teams: [],has_membership_data: false,diff --git a/products/engineering_analytics/frontend/scenes/doraLogic.ts b/products/engineering_analytics/frontend/scenes/doraLogic.tsindex 11249ae014a1..a82f3d2d3532 100644--- a/products/engineering_analytics/frontend/scenes/doraLogic.ts+++ b/products/engineering_analytics/frontend/scenes/doraLogic.ts@@ -256,12 +256,17 @@ export const doraLogic = kea<doraLogicType>([? 'all persistent environments': dora.environment_scope,],- // With environments selected, environment_scope echoes the picks, so the resolved default- // can only be offered while the selection is empty; picked names stay selectable options.+ // selected_environments carries the resolved default scope while the selection is empty. Its+ // names can fall outside the capped environments list, so they must be offered explicitly.+ // Picked names stay selectable options.environmentOptions: [(s) => [s.dora, s.environments],(dora: DoraOverviewApi | null, environments: string[]): { key: string; label: string }[] => {- const names = new Set([...(dora?.environments ?? []), ...environments])+ const names = new Set([+ ...(dora?.environments ?? []),+ ...(dora?.selected_environments ?? []),+ ...environments,+ ])return [...names].map((name) => ({ key: name, label: name }))},],diff --git a/products/engineering_analytics/mcp/tools.yaml b/products/engineering_analytics/mcp/tools.yamlindex 22463f6c7e73..5a53b4643000 100644--- a/products/engineering_analytics/mcp/tools.yaml+++ b/products/engineering_analytics/mcp/tools.yaml@@ -93,13 +93,14 @@ tools:(deployments with a failure/error status over deployments that reached an outcome — NOT true change failurerate, since no incident data is linked) and median_failed_deploy_to_next_success_seconds (first failurestatus to the next successful deploy in the same environment — NOT true time-to-restore, since recovery by- anything other than a deploy is invisible). Environments default to the busiest production-marked- environment, falling back to the busiest persistent (non-transient) one when none are marked production —- ephemeral per-PR preview environments never join a default scope; pass environment (repeatable, from the- response's environments list) to scope exactly. Pass github_team (a slug from github_teams) to narrow the- PR-scoped lead-time figures to that team's authors — deploy counts stay repo-wide. deploy_data_available is- false when the deployments endpoints aren't synced on the GitHub source; the fix is enabling them, not- re-querying.+ anything other than a deploy is invisible). Environments default to all persistent production-marked or+ production-named environments (including regional suffixes), falling back to the busiest persistent one when+ none match; ephemeral per-PR preview environments never join a default scope. selected_environments lists+ the exact names used. Repeat environment to scope to exact names; the API trims and deduplicates them, keeps+ real transient names, and rejects blank or unknown names with a 400 response. Pass github_team (a slug from+ github_teams) to narrow the PR-scoped lead-time figures to that team's authors — deploy counts stay+ repo-wide. deploy_data_available is false when the deployments endpoints aren't synced on the GitHub source;+ the fix is enabling them, not re-querying.engineering-analytics-flaky-tests:operation: engineering_analytics_flaky_testsenabled: truediff --git a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.mdindex ec9d842461ff..1ce1cd7a03e8 100644--- a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md+++ b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md@@ -142,3 +142,5 @@ numbers as a saved insight, a dashboard tile, or a scheduled email/Slack deliver(`<prefix>github_pull_requests` / `<prefix>github_workflow_runs`, prefix from `engineering-analytics-sources`)are directly queryable with HogQL, and that skill carries the curated column semantics plus theinsight-create / subscriptions-create workflow.++DORA environment defaults include all persistent production-marked or production-named regions. Read `selected_environments` for the validated exact scope. DRF validates explicit filters against real names, including transient environments. It trims and deduplicates valid names and rejects blank or unknown names with a 400 response. Omit the filter to use the default. Each regional deployment counts separately; lead time counts each PR once at its first successful deployment in any selected environment.diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 87597379e797..568a2ae8dfbb 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -29667,10 +29667,12 @@ export namespace Schemas {open_to_deploy_series: LeadTimeBucket[];/** False when the deployments/deployment_statuses tables aren't synced for the selected repo; every other field is then empty or null, never a fake zero. */deploy_data_available: boolean;- /** What the environment filter resolved to: the exact environment name(s) it matches (the caller's picks, comma-joined when several; by default the busiest production-marked environment, falling back to the busiest persistent one), or 'persistent' (no persistent environment deployed in the window, so every non-transient one counts). Transient environments (ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in the scan window, so two different windows can resolve different scopes and are not always comparable. */+ /** Display label for the selected environments, comma-separated, 'persistent' when no persistent environments were discovered. Use selected_environments for exact names. */environment_scope: string;- /** Distinct persistent environments deployed to in the scan window, most-deployed first — the environment picker's options. Transient environments are omitted but stay reachable by exact name. */+ /** Distinct persistent environments from the metric scan window or the 30 days before its end, whichever starts earlier, most-deployed first. Transient environments are omitted. */environments: string[];+ /** Exact environment names used for these metrics. Defaults to all persistent environments marked production or named prod/production (including regional suffixes), falling back to the busiest persistent environment. Explicit filters are trimmed and deduplicated. DRF rejects blank or unknown names; real transient names are allowed. */+ selected_environments: string[];/** True when the optional team-membership snapshot is synced. When false, a github_team filter cannot be honored and the merge-to-deploy figures go empty rather than silently unfiltered. */has_membership_data: boolean;/** Distinct GitHub team slugs from the membership snapshot, sorted — the team picker's options. Empty when membership isn't synced. */@@ -94753,7 +94755,7 @@ export namespace Schemas {*/date_to?: string;/**- * Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit to scope to the busiest environment GitHub marks production, falling back to the busiest persistent (non-transient) environment when none are marked production.+ * Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit to include all persistent environments marked production or named prod/production (including regional suffixes), falling back to the busiest persistent environment when none match. Explicit names are trimmed, deduplicated, and validated against the source, including transient environments. Blank or unknown names are rejected with a 400 response.*/environment?: string[];/**