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.

feat(eng-analytics): show quarantined tests per team (#104801)

Raúl Negrón-Otero37e188d13dd4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 3ef7cdf2e15f..e57753021515 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8037,21 +8037,29 @@ snapshots:
scenes-app-engineering-analytics-run-activity-chart--default--light:
hash: v1.k794b7964.f63752ff3ebf3bbee3be4ddc83d1ff657d9cdd11ee71e7283c30ce5a1aefde72.yTb8kpRqcG51TbM2CqgRmC5YvgE7-6pV1Trc7y5wuto
scenes-app-engineering-analytics-team--team--dark:
- hash: v1.k794b7964.8ab9a14d00c57a179d6ae23a4f318527a125e1a886eb5eec4739e83204ca91d6.nCHqHNwOO6d0m-LoBUv-3mlTDU45SqaZAvg_0XRWqF4
+ hash: v1.k794b7964.2f951d96c575ff0f885d1c81b69bdeaec6d25ee5450d207561ae1215a3bd9be3.Y7zgUsl87c8frDY84qEtWiUwKOjoypzPxNkJQdCzEug
scenes-app-engineering-analytics-team--team--light:
- hash: v1.k794b7964.ce702b43b3812be57a316311450f1f60264f12969ea5b89a1f229bb24c1f5ade.wQYkNs1KtELeBKDCbvAdMTIKf1gCKinpoO2DqlxtTjk
+ hash: v1.k794b7964.c8315ec4a28e42f3ce074e0b5c388eca3be0f46b3d6bbc128d469f011389bbb0.7fQ5t9nHDImfuPh2iOU-74-ymwf2wDsJpAsZPfYnjDU
+ scenes-app-engineering-analytics-team--team-narrow--dark:
+ hash: v1.k794b7964.608002b57ac616fe54a60a80f7bf923b5e16038d2f06724ac372cb3bb0329458.cFoJbUiL6BZE96P9kchIJyJ0u3O2Nc571PJLGgYeXV8
+ scenes-app-engineering-analytics-team--team-narrow--light:
+ hash: v1.k794b7964.cb4bb3728f0f568b646e2a32806502d752fff5de55cd4b5c50a23cd823b2168f.ZAeFoIqOj7QGnVDKdsBjUWwNsyKVA_LND-A-aPmVHlk
+ scenes-app-engineering-analytics-team--team-quarantine-load-error--dark:
+ hash: v1.k794b7964.541452d01837a1c1129b58ec587f3417a8aabd0dd1b92bd52229a160c1d07d6a.j1fzAkcNzZSw9KI7zOdccCx17gv-AlR5SocMTb2cOxw
+ scenes-app-engineering-analytics-team--team-quarantine-load-error--light:
+ hash: v1.k794b7964.cdb1215ddbfbed34cfe0ee14a694349d294a00cf7388e9891de5f080693ae025.BdZyEbPlRvzd9YxLHP4ahd5E_Y2uzEPsF-OjLfxUkNI
scenes-app-engineering-analytics-team--team-without-membership--dark:
- hash: v1.k794b7964.3c3142b9a3a6bb141701854805597465f6f823106746e7b20c381f3d610eaddb.E0-u2Sj4HAj2xqSq6Z4Jh3fQz9gagK4K0Z-3hegKbkE
+ hash: v1.k794b7964.6c597367df91af414d0ed49f8a13e687349f4c8e7952f9f05e9926acc3848dd1.9puYEgRsC--vOo4DwU3e1gWEyHfR4jZb-vY7rKrPYlk
scenes-app-engineering-analytics-team--team-without-membership--light:
- hash: v1.k794b7964.22b8a8a0e228d1af6ef2ee6ccd6790bdd39da67113cf04c9c4dccf349c280fa0.5ydsnSNLbc1Kym8S7J7u-e8YQS8iFYBHS-0g-1Q0VkU
+ hash: v1.k794b7964.d4e2de6cbcb878719014f8b5d038a1cc6e0ddc204de1f82b254ea99c032c57da.5Fd7ZBgUGdp6rQO7sroVkUpeDyRbxOiULjDN54bG3Wk
scenes-app-engineering-analytics-teams--team-ci-health-load-error--dark:
- hash: v1.k794b7964.032ac3a7c28431e14d1ffdcbcbdd8298ba32f6251a07291ccfd6ecdbe7ee47d8.PwPD3bNyLIlN-6hUWq-iiFoWlzvjg09qTxPAib5LOK4
+ hash: v1.k794b7964.2c5b47795360001e6281631b9c29b313cab79a2c10b335f018c3a9b333ba8593.aEHiND5D1aaD-yEMHu8kAQRrHw2X6AIRTQS6X9j0CNk
scenes-app-engineering-analytics-teams--team-ci-health-load-error--light:
- hash: v1.k794b7964.d204e91c0971783b6f322044ff75e69ca6eae1f0f423be5c736e8c4138889d3f.RsRhskU_JsqEk2II3fkKvxynfA3CqNOBPfC-sYuzGEw
+ hash: v1.k794b7964.3c0e74717954d87c4897c6449b6b11e296988aa9b3ecc8169d47e8b290f92852.hin4fcT7XyKyrwZ4N7JtOEUo_RqohPnmkRExX4Ns0TA
scenes-app-engineering-analytics-teams--team-ci-health-roster--dark:
- hash: v1.k794b7964.d7984917604b3b00c62080e1e14df8c6d8627227cd87b386e20f5875dbcae662.vFLjLR41Z042e4HEFAjPTtFk3TUQi32rHZNWjlsVC1Q
+ hash: v1.k794b7964.ab345005be51ec67d355c2fb12b7eaaeb52764b0c0a3b9598ebc1767f9ae7457.Zmaq5AaqeZ-xTAJJ2O24qjoSj03D1kUPUwk9c2bHWfw
scenes-app-engineering-analytics-teams--team-ci-health-roster--light:
- hash: v1.k794b7964.0e0f7789f3b9852991ee2fb1a0921bf56c9b5983875650fa5c5a21995ea1de0f.xAdZUSzJ_tsV3QvHcRu2sGw90W9Lg2NalsLCG-z3ibo
+ hash: v1.k794b7964.cfe54886d432295145a2e955fb75306173e31ba6c5f0f988e47f8304f2c75979.n8OplejM8MfCpDTi27u9UowHP9fdc8ORprBRHaemOUA
scenes-app-engineering-analytics-tests--quarantine-load-error--dark:
hash: v1.k794b7964.bd56f14c086152fa97390134d29ab0cff68e6665c1a309a4db67f45c49a82818.7yComHRRY3qMsmJoz1YQZPupup7KgJWWQpoljHmXm3c
scenes-app-engineering-analytics-tests--quarantine-load-error--light:
diff --git a/products/engineering_analytics/frontend/components/TeamQuarantinedTestsTable.tsx b/products/engineering_analytics/frontend/components/TeamQuarantinedTestsTable.tsx
index a49e326c361a..c9c124f42405 100644
--- a/products/engineering_analytics/frontend/components/TeamQuarantinedTestsTable.tsx
+++ b/products/engineering_analytics/frontend/components/TeamQuarantinedTestsTable.tsx
@@ -7,16 +7,18 @@ import { githubFileUrl } from '../lib/github'
import { TrunkQuarantinedTestRow } from '../scenes/engineeringAnalyticsLogic'
import { TestIdCell } from './TestIdCell'
-/** One team's quarantined tests, rendered inside the debt table's expanded row. */
+/** One team's quarantined tests, shown in the debt table's expanded row and on the team page. */
export function TeamQuarantinedTestsTable({
tests,
ttlDays,
repository,
+ loading = false,
}: {
tests: TrunkQuarantinedTestRow[]
ttlDays: number
/** 'owner/name' the test file paths are relative to, for the GitHub links. */
repository: string
+ loading?: boolean
}): JSX.Element {
const columns: LemonTableColumns<TrunkQuarantinedTestRow> = [
{
@@ -79,7 +81,9 @@ export function TeamQuarantinedTestsTable({
columns={columns}
dataSource={tests}
rowKey={(row) => `${row.runner}:${row.nodeid}`}
+ loading={loading}
useURLForSorting={false}
+ emptyState="No quarantined tests belong to this team."
nouns={['test', 'tests']}
/>
)
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.stories.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.stories.tsx
index efbc0f8685ea..a1ced2b19e18 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.stories.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.stories.tsx
@@ -6,7 +6,12 @@ import { urls } from 'scenes/urls'
import { mswDecorator } from '~/mocks/browser'
-import type { DeliverySummaryApi, DurationDistributionApi, TeamCIHealthListApi } from '../generated/api.schemas'
+import type {
+ DeliverySummaryApi,
+ DurationDistributionApi,
+ TeamCIHealthListApi,
+ TrunkQuarantineDebtApi,
+} from '../generated/api.schemas'
const HOUR = 3600
const TEAM = 'team-replay'
@@ -116,13 +121,38 @@ const TEAM_MERGE_TREND = {
],
}
+const TRUNK_QUARANTINE: TrunkQuarantineDebtApi = {
+ available: true,
+ owners_resolved: true,
+ ttl_days: 15,
+ repository: 'PostHog/posthog',
+ trunk_url: 'https://app.trunk.io/example/flaky-tests',
+ truncated: false,
+ limit: 500,
+ teams: [{ owner_team: TEAM, test_count: 1, overdue_count: 1, oldest_age_days: 21 }],
+ tests: [
+ {
+ runner: 'pytest',
+ nodeid: 'products/replay/test_snapshots.py::test_resume_keeps_cursor',
+ file: 'products/replay/test_snapshots.py',
+ owner_team: TEAM,
+ status: 'FLAKY',
+ quarantine_setting: 'AUTO_QUARANTINE',
+ quarantined_at: '2026-06-12T09:00:00Z',
+ age_days: 21,
+ overdue: true,
+ trunk_url: 'https://app.trunk.io/example/flaky-tests/fixture-1',
+ },
+ ],
+}
+
const meta: Meta = {
component: App,
title: 'Scenes-App/Engineering Analytics/Team',
parameters: {
layout: 'fullscreen',
viewMode: 'story',
- mockDate: '2026-07-02',
+ mockDate: '2026-07-03T12:00:00Z',
featureFlags: [FEATURE_FLAGS.ENGINEERING_ANALYTICS],
pageUrl: urls.engineeringAnalyticsTeam(TEAM),
testOptions: {
@@ -160,14 +190,7 @@ const meta: Meta = {
source_url: null,
generated_at: null,
},
- 'api/projects/:team_id/engineering_analytics/trunk_quarantine/': {
- available: false,
- ttl_days: 15,
- repository: null,
- trunk_url: null,
- teams: [],
- tests: [],
- },
+ 'api/projects/:team_id/engineering_analytics/trunk_quarantine/': TRUNK_QUARANTINE,
},
}),
],
@@ -180,6 +203,12 @@ export const Team: Story = {
render: () => <App />,
}
+// A docked side panel leaves the scene about 520px wide, where the comparison cards must stack.
+export const TeamNarrow: Story = {
+ render: () => <App />,
+ parameters: { testOptions: { viewport: { width: 520, height: 1800 } } },
+}
+
export const TeamWithoutMembership: Story = {
render: () => <App />,
decorators: [
@@ -227,3 +256,14 @@ export const TeamWithoutMembership: Story = {
}),
],
}
+
+export const TeamQuarantineLoadError: Story = {
+ render: () => <App />,
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/engineering_analytics/trunk_quarantine/': () => [500, null],
+ },
+ }),
+ ],
+}
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsx
index 92bd08115f07..3afdb2e5df6c 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsx
@@ -1,10 +1,9 @@
import { useActions, useValues } from 'kea'
import { IconPeople } from '@posthog/icons'
-import { LemonTable, LemonTableColumns, LemonTag, Tooltip } from '@posthog/lemon-ui'
+import { LemonBanner, LemonSkeleton, LemonTable, LemonTableColumns, LemonTag, Tooltip } from '@posthog/lemon-ui'
import { TimeSeriesLineChart, useChartTheme } from '@posthog/quill-charts'
-import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { TZLabel } from 'lib/components/TZLabel'
import { humanFriendlyNumber } from 'lib/utils/numbers'
import { SceneExport } from 'scenes/sceneTypes'
@@ -14,33 +13,30 @@ import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+import { CIAnalyticsLoadError } from '../components/CIAnalyticsLoadError'
+import { ConnectGitHubSource } from '../components/ConnectGitHubSource'
import { CountCell } from '../components/CountCell'
import { EntityHeader } from '../components/EntityHeader'
-import { RepoScopeChip, ScopeBar } from '../components/ScopeBar'
+import { RepoScopeChip, ScopeBar, ScopeDateFilter } from '../components/ScopeBar'
import { ScopePanel } from '../components/ScopePanel'
import { Section } from '../components/Section'
+import { TeamQuarantinedTestsTable } from '../components/TeamQuarantinedTestsTable'
import { TestIdCell } from '../components/TestIdCell'
import { WindowComparisonCard } from '../components/WindowComparisonCard'
import { compactHoursLabel } from '../lib/format'
import { githubFileUrl } from '../lib/github'
+import { withCurrentScope } from '../lib/scope'
import { engineeringAnalyticsLogic } from './engineeringAnalyticsLogic'
import { TeamDeliveryPanel } from './TeamDeliveryPanel'
import { TeamDetailLogicProps, TeamTestSignalRow, teamDetailLogic } from './teamDetailLogic'
-import {
- DEFAULT_TEAMS_WINDOW,
- TEAMS_WINDOW_DATE_OPTIONS,
- TEAMS_WINDOW_LABELS,
- UNOWNED_TEAM,
- isTeamsWindow,
-} from './teamsLogic'
+import { DEFAULT_TEAMS_WINDOW, TEAMS_WINDOW_DATE_OPTIONS, TEAMS_WINDOW_LABELS, UNOWNED_TEAM } from './teamsLogic'
export const scene: SceneExport<TeamDetailLogicProps> = {
component: EngineeringAnalyticsTeamScene,
logic: teamDetailLogic,
- paramsToProps: ({ params: { ownerTeam }, searchParams: { source, window } }) => ({
+ paramsToProps: ({ params: { ownerTeam }, searchParams: { source } }) => ({
ownerTeam: decodeURIComponent(ownerTeam ?? ''),
sourceId: source ?? null,
- window: isTeamsWindow(window) ? window : null,
}),
}
@@ -48,23 +44,31 @@ export function EngineeringAnalyticsTeamScene(): JSX.Element {
const {
activity,
activityLoading,
+ activityStatus,
healthRow,
healthRowLoading,
+ healthRowStatus,
mergeTrend,
mergeTrendLoading,
+ mergeTrendStatus,
mergeTrendSeries,
- window,
ownerTeam,
deliveryScope,
sourceId,
+ quarantinedTests,
} = useValues(teamDetailLogic)
- const { setWindow } = useActions(teamDetailLogic)
- const { activeSource } = useValues(engineeringAnalyticsLogic)
+ const { loadActivity, loadHealthRow, loadMergeTrend } = useActions(teamDetailLogic)
+ const { activeSource, trunkQuarantine, trunkQuarantineLoading, trunkQuarantineStatus } =
+ useValues(engineeringAnalyticsLogic)
+ const { loadTrunkQuarantine } = useActions(engineeringAnalyticsLogic)
const { timezone } = useValues(teamLogic)
const repository = activeSource?.repo ?? null
const chartTheme = useChartTheme()
const isUnowned = ownerTeam === UNOWNED_TEAM
+ const mainDataNotConnected = [activityStatus, healthRowStatus, mergeTrendStatus].includes('notConnected')
+ const hubUrl = withCurrentScope(urls.engineeringAnalytics(), sourceId)
+ const teamsUrl = withCurrentScope(urls.engineeringAnalyticsTeams(), sourceId)
const testColumns: LemonTableColumns<TeamTestSignalRow> = [
{
@@ -111,44 +115,14 @@ export function EngineeringAnalyticsTeamScene(): JSX.Element {
},
]
- return (
- <SceneContent className="pb-16">
- <SceneTitleSection name="Team" resourceType={{ type: 'health' }} />
- <EntityHeader
- icon={<IconPeople />}
- title={isUnowned ? 'Unowned surfaces' : ownerTeam}
- titleSuffix={
- isUnowned ? (
- <Tooltip title="Tests whose CI spans carry no ownership stamp. An ownership gap to close, not a real team.">
- <LemonTag type="warning">ownership gap</LemonTag>
- </Tooltip>
- ) : undefined
- }
- slug={null}
- />
- <ScopeBar
- repoSlot={<RepoScopeChip label={repository ?? 'repository'} to={urls.engineeringAnalytics()} />}
- crumbs={[
- { label: 'teams', to: urls.engineeringAnalyticsTeams() },
- { label: isUnowned ? 'unowned' : ownerTeam },
- ]}
- showDate={false}
- />
-
- {deliveryScope && <TeamDeliveryPanel scope={deliveryScope} sourceId={sourceId} />}
-
- <ScopePanel
- busy={healthRowLoading || mergeTrendLoading}
- controls={
- <DateFilter
- dateFrom={window}
- onChange={(from) => isTeamsWindow(from) && setWindow(from)}
- dateOptions={TEAMS_WINDOW_DATE_OPTIONS}
- size="small"
- />
- }
- >
- <div className="grid grid-cols-1 gap-2 md:grid-cols-2">
+ const windowControls = <ScopeDateFilter dateOptions={TEAMS_WINDOW_DATE_OPTIONS} />
+ const windowBusy = healthRowLoading || mergeTrendLoading
+ const windowedSections = (
+ <>
+ {healthRowStatus === 'error' ? (
+ <CIAnalyticsLoadError onRetry={loadHealthRow} loading={healthRowLoading} />
+ ) : (
+ <div className="grid grid-cols-1 gap-2 @2xl/main-content:grid-cols-2">
<WindowComparisonCard
title="Test files owned"
tooltip="Test files this team owns per the daily owners.yaml census."
@@ -190,60 +164,154 @@ export function EngineeringAnalyticsTeamScene(): JSX.Element {
/>
)}
</div>
+ )}
- {!isUnowned && (
- <Section id="team-merge-trend" title="Time to merge" busy={mergeTrendLoading}>
- {mergeTrendSeries ? (
- // Flex column: the quill chart root is flex-1 and only gets height from a flex parent.
- <div className="flex h-48 w-full flex-col">
- <TimeSeriesLineChart
- series={[
- { key: 'median', label: 'Median', data: mergeTrendSeries.median },
- { key: 'average', label: 'Average', data: mergeTrendSeries.average },
- ]}
- labels={mergeTrendSeries.labels}
- theme={chartTheme}
- config={{
- xAxis: { timezone, interval: 'day' },
- yAxis: { format: 'duration' },
- tooltip: { valueFormatter: (value) => compactHoursLabel(value) },
- legend: { show: true },
- }}
- />
- </div>
- ) : mergeTrend && !mergeTrend.hasMembershipData ? (
- <div className="flex h-32 items-center text-xs text-secondary">
- No team membership data. Sync the GitHub source's team_members endpoint (needs the org
- Members read grant) to attribute merges to teams.
- </div>
+ {!isUnowned && (
+ <Section id="team-merge-trend" title="Time to merge" busy={mergeTrendLoading && !!mergeTrend}>
+ {mergeTrendStatus === 'error' ? (
+ <CIAnalyticsLoadError onRetry={loadMergeTrend} loading={mergeTrendLoading} />
+ ) : mergeTrendLoading && !mergeTrend ? (
+ <LemonSkeleton className="h-48 w-full" />
+ ) : mergeTrendSeries ? (
+ // Flex column: the quill chart root is flex-1 and only gets height from a flex parent.
+ <div className="flex h-48 w-full flex-col">
+ <TimeSeriesLineChart
+ series={[
+ { key: 'median', label: 'Median', data: mergeTrendSeries.median },
+ { key: 'average', label: 'Average', data: mergeTrendSeries.average },
+ ]}
+ labels={mergeTrendSeries.labels}
+ theme={chartTheme}
+ config={{
+ xAxis: { timezone, interval: 'day' },
+ yAxis: { tickFormatter: compactHoursLabel },
+ tooltip: { valueFormatter: (value) => compactHoursLabel(value) },
+ legend: { show: true },
+ }}
+ />
+ </div>
+ ) : mergeTrend && !mergeTrend.hasMembershipData ? (
+ <div className="flex h-32 items-center text-xs text-secondary">
+ No team membership data. Sync the GitHub source's team_members endpoint (needs the org
+ Members read grant) to attribute merges to teams.
+ </div>
+ ) : (
+ <div className="flex h-32 items-center text-xs text-secondary">
+ No merged PRs in this window.
+ </div>
+ )}
+ </Section>
+ )}
+ </>
+ )
+
+ return (
+ <SceneContent className="pb-16">
+ <SceneTitleSection name="Team" resourceType={{ type: 'health' }} />
+ <ScopeBar
+ repoSlot={<RepoScopeChip label={repository ?? 'repository'} to={hubUrl} />}
+ crumbs={[{ label: 'teams', to: teamsUrl }, { label: isUnowned ? 'unowned' : ownerTeam }]}
+ showDate={false}
+ />
+ <EntityHeader
+ icon={<IconPeople />}
+ title={isUnowned ? 'Unowned surfaces' : ownerTeam}
+ titleSuffix={
+ isUnowned ? (
+ <Tooltip title="Tests whose CI spans carry no ownership stamp. An ownership gap to close, not a real team.">
+ <LemonTag type="warning">ownership gap</LemonTag>
+ </Tooltip>
+ ) : undefined
+ }
+ slug={null}
+ />
+
+ {mainDataNotConnected ? (
+ <ConnectGitHubSource />
+ ) : (
+ <>
+ {deliveryScope ? (
+ <TeamDeliveryPanel
+ scope={deliveryScope}
+ sourceId={sourceId}
+ busy={windowBusy}
+ controls={windowControls}
+ >
+ {windowedSections}
+ </TeamDeliveryPanel>
+ ) : (
+ <ScopePanel busy={windowBusy} controls={windowControls}>
+ {windowedSections}
+ </ScopePanel>
+ )}
+
+ <Section id="team-tests" title="Owned tests with signal" busy={activityLoading && !!activity}>
+ {activityStatus === 'error' ? (
+ <CIAnalyticsLoadError onRetry={loadActivity} loading={activityLoading} />
) : (
- <div className="flex h-32 items-center text-xs text-secondary">
- No merged PRs in this window.
+ <LemonTable
+ data-attr="engineering-analytics-team-tests-table"
+ size="small"
+ columns={testColumns}
+ dataSource={activity?.tests ?? []}
+ rowKey={(row) => `${row.runner}:${row.nodeid}`}
+ loading={activityLoading}
+ pagination={{ pageSize: 25 }}
+ useURLForSorting={false}
+ emptyState="No owned tests with signal."
+ nouns={['test', 'tests']}
+ />
+ )}
+ {activity?.truncatedTests && (
+ <div className="mt-2 text-xs text-tertiary">
+ Showing the strongest signals. More owned tests had signal.
</div>
)}
</Section>
- )}
- </ScopePanel>
- <Section id="team-tests" title="Owned tests with signal" busy={activityLoading}>
- <LemonTable
- data-attr="engineering-analytics-team-tests-table"
- size="small"
- columns={testColumns}
- dataSource={activity?.tests ?? []}
- rowKey={(row) => `${row.runner}:${row.nodeid}`}
- loading={activityLoading}
- pagination={{ pageSize: 25 }}
- useURLForSorting={false}
- emptyState="No owned tests with signal."
- nouns={['test', 'tests']}
- />
- {activity?.truncatedTests && (
- <div className="mt-2 text-xs text-tertiary">
- Showing the strongest signals. More owned tests had signal.
- </div>
- )}
- </Section>
+ <Section
+ id="team-quarantined-tests"
+ title="Quarantined tests"
+ busy={trunkQuarantineLoading && !!trunkQuarantine}
+ >
+ {trunkQuarantineStatus === 'error' ? (
+ <CIAnalyticsLoadError
+ title="Couldn't load quarantined tests"
+ description="Loading Trunk quarantine data failed. Retry, or check the source's sync status."
+ onRetry={loadTrunkQuarantine}
+ loading={trunkQuarantineLoading}
+ />
+ ) : trunkQuarantineLoading && !trunkQuarantine ? (
+ <LemonSkeleton className="h-32 w-full" />
+ ) : trunkQuarantineStatus === 'notConnected' || !trunkQuarantine?.available ? (
+ <div className="py-8 text-center text-sm text-secondary">
+ No Trunk source is connected. Connect the Trunk.io data warehouse source to see this
+ team's quarantined tests.
+ </div>
+ ) : !trunkQuarantine.ownersResolved ? (
+ <LemonBanner type="warning">
+ We could not read {trunkQuarantine.repository}'s ownership files, so quarantined tests
+ can't be matched to teams. Try again in a few minutes.
+ </LemonBanner>
+ ) : (
+ <>
+ <TeamQuarantinedTestsTable
+ tests={quarantinedTests}
+ ttlDays={trunkQuarantine.ttlDays}
+ repository={trunkQuarantine.repository}
+ loading={trunkQuarantineLoading}
+ />
+ {trunkQuarantine.truncated && (
+ <div className="mt-2 text-xs text-tertiary">
+ Showing quarantined tests from the oldest {trunkQuarantine.limit} in the
+ repository. This team may have more.
+ </div>
+ )}
+ </>
+ )}
+ </Section>
+ </>
+ )}
</SceneContent>
)
}
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx
index 816d0076e397..4966cfc7ecc1 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx
@@ -1,5 +1,4 @@
import { useActions, useValues } from 'kea'
-import { combineUrl } from 'kea-router'
import { LemonTable, LemonTableColumns, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
@@ -11,13 +10,14 @@ import { CountCell } from '../components/CountCell'
import { ScopeBar, SourceScopeChip } from '../components/ScopeBar'
import { Section } from '../components/Section'
import { rowNavigationProps } from '../lib/rowNavigation'
+import { withCurrentScope } from '../lib/scope'
import { DEFAULT_TEAMS_WINDOW, TEAMS_WINDOW_LABELS, TeamCIHealthRow, UNOWNED_TEAM, teamsLogic } from './teamsLogic'
const FIXED_WINDOW = TEAMS_WINDOW_LABELS[DEFAULT_TEAMS_WINDOW].current.toLowerCase()
-/** The team's detail page, carrying the active source so it opens scoped the same. */
+/** The team's detail page, carrying the current scope so it opens scoped the same. */
function detailUrlOf(ownerTeam: string, sourceId: string | null): string {
- return combineUrl(urls.engineeringAnalyticsTeam(ownerTeam), sourceId ? { source: sourceId } : {}).url
+ return withCurrentScope(urls.engineeringAnalyticsTeam(ownerTeam), sourceId)
}
export function EngineeringAnalyticsTeams(): JSX.Element {
@@ -91,7 +91,7 @@ export function EngineeringAnalyticsTeams(): JSX.Element {
return (
<div className="flex flex-col gap-4">
<ScopeBar repoSlot={<SourceScopeChip />} showDate={false} />
- <Section id="team-ci-health" title="Team CI health">
+ <Section id="team-ci-health" title="Owned tests by team">
{teamsFailed ? (
<CIAnalyticsLoadError onRetry={loadTeams} loading={teamsLoading} />
) : (
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTests.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTests.tsx
index fcd408f7f224..4b30675c11e7 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTests.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTests.tsx
@@ -14,10 +14,7 @@ import { StatCard } from '../components/StatCard'
import { TeamQuarantinedTestsTable } from '../components/TeamQuarantinedTestsTable'
import { withCurrentScope } from '../lib/scope'
import { TrunkQuarantineTeamRow, engineeringAnalyticsLogic } from './engineeringAnalyticsLogic'
-
-function teamLabel(ownerTeam: string): string {
- return ownerTeam === 'unowned' ? 'Unowned' : ownerTeam
-}
+import { teamLabel } from './teamsLogic'
function TrunkQuarantineDebtBoard(): JSX.Element {
const {
diff --git a/products/engineering_analytics/frontend/scenes/TeamDeliveryPanel.tsx b/products/engineering_analytics/frontend/scenes/TeamDeliveryPanel.tsx
index 84c14ec4ae0f..a81e28794312 100644
--- a/products/engineering_analytics/frontend/scenes/TeamDeliveryPanel.tsx
+++ b/products/engineering_analytics/frontend/scenes/TeamDeliveryPanel.tsx
@@ -1,17 +1,31 @@
import { useValues } from 'kea'
+import { ReactNode } from 'react'
-import { DELIVERY_DATE_OPTIONS, ScopeDateFilter } from '../components/ScopeBar'
import { ScopePanel } from '../components/ScopePanel'
import { DeliveryScope } from '../lib/deliveryScope'
import { DeliverySections } from './DeliverySections'
import { deliverySummaryLogic } from './deliverySummaryLogic'
-export function TeamDeliveryPanel({ scope, sourceId }: { scope: DeliveryScope; sourceId: string | null }): JSX.Element {
- const { summary, summaryLoading } = useValues(deliverySummaryLogic({ scope, sourceId }))
+/** The team page's window panel with the team's delivery figures on top, so a delivery reload spins the rim too. */
+export function TeamDeliveryPanel({
+ scope,
+ sourceId,
+ busy,
+ controls,
+ children,
+}: {
+ scope: DeliveryScope
+ sourceId: string | null
+ busy: boolean
+ controls: ReactNode
+ children: ReactNode
+}): JSX.Element {
+ const { summary, summaryFailed, summaryLoading } = useValues(deliverySummaryLogic({ scope, sourceId }))
+
return (
- <ScopePanel busy={summaryLoading} controls={<ScopeDateFilter dateOptions={DELIVERY_DATE_OPTIONS} />}>
- {/* Without the members table a team matches no author, so every figure would be a false zero. */}
- {summary && !summary.has_membership_data ? (
+ <ScopePanel busy={busy || summaryLoading} controls={controls}>
+ {summary && !summaryFailed && !summary.has_membership_data ? (
+ // Without the members table a team matches no author, so every figure would be a false zero.
<div className="py-8 text-center text-sm text-secondary">
No team membership data. Sync the team members table on this GitHub source to see this team's
delivery figures.
@@ -19,6 +33,7 @@ export function TeamDeliveryPanel({ scope, sourceId }: { scope: DeliveryScope; s
) : (
<DeliverySections scope={scope} scopeLabel="This team" sourceId={sourceId} />
)}
+ {children}
</ScopePanel>
)
}
diff --git a/products/engineering_analytics/frontend/scenes/teamDetailLogic.test.ts b/products/engineering_analytics/frontend/scenes/teamDetailLogic.test.ts
new file mode 100644
index 000000000000..03fceca898ef
--- /dev/null
+++ b/products/engineering_analytics/frontend/scenes/teamDetailLogic.test.ts
@@ -0,0 +1,146 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { ApiConfig } from 'lib/api'
+
+import { initKeaTests } from '~/test/init'
+
+import {
+ engineeringAnalyticsCiCards,
+ engineeringAnalyticsPullRequests,
+ engineeringAnalyticsQuarantine,
+ engineeringAnalyticsSources,
+ engineeringAnalyticsTeamCiActivity,
+ engineeringAnalyticsTeamCiHealth,
+ engineeringAnalyticsTeamMergeTrend,
+ engineeringAnalyticsTrunkQuarantine,
+ engineeringAnalyticsWorkflowHealth,
+} from '../generated/api'
+import { engineeringAnalyticsFiltersLogic } from './engineeringAnalyticsFiltersLogic'
+import { teamDetailLogic } from './teamDetailLogic'
+
+jest.mock('../generated/api', () => ({
+ engineeringAnalyticsCiCards: jest.fn(),
+ engineeringAnalyticsPullRequests: jest.fn(),
+ engineeringAnalyticsQuarantine: jest.fn(),
+ engineeringAnalyticsSources: jest.fn(),
+ engineeringAnalyticsTeamCiActivity: jest.fn(),
+ engineeringAnalyticsTeamCiHealth: jest.fn(),
+ engineeringAnalyticsTeamMergeTrend: jest.fn(),
+ engineeringAnalyticsTrunkQuarantine: jest.fn(),
+ engineeringAnalyticsWorkflowHealth: jest.fn(),
+}))
+
+const mockCards = engineeringAnalyticsCiCards as jest.MockedFunction<typeof engineeringAnalyticsCiCards>
+const mockPullRequests = engineeringAnalyticsPullRequests as jest.MockedFunction<
+ typeof engineeringAnalyticsPullRequests
+>
+const mockQuarantine = engineeringAnalyticsQuarantine as jest.MockedFunction<typeof engineeringAnalyticsQuarantine>
+const mockSources = engineeringAnalyticsSources as jest.MockedFunction<typeof engineeringAnalyticsSources>
+const mockActivity = engineeringAnalyticsTeamCiActivity as jest.MockedFunction<
+ typeof engineeringAnalyticsTeamCiActivity
+>
+const mockHealth = engineeringAnalyticsTeamCiHealth as jest.MockedFunction<typeof engineeringAnalyticsTeamCiHealth>
+const mockMergeTrend = engineeringAnalyticsTeamMergeTrend as jest.MockedFunction<
+ typeof engineeringAnalyticsTeamMergeTrend
+>
+const mockTrunkQuarantine = engineeringAnalyticsTrunkQuarantine as jest.MockedFunction<
+ typeof engineeringAnalyticsTrunkQuarantine
+>
+const mockWorkflowHealth = engineeringAnalyticsWorkflowHealth as jest.MockedFunction<
+ typeof engineeringAnalyticsWorkflowHealth
+>
+
+describe('teamDetailLogic', () => {
+ let logic: ReturnType<typeof teamDetailLogic.build>
+ let unmountFilters: (() => void) | undefined
+
+ beforeEach(() => {
+ initKeaTests()
+ ApiConfig.setCurrentProjectId(1)
+ jest.clearAllMocks()
+ mockCards.mockResolvedValue({ open_prs: 0, repos: 1, stuck: 0, failing_ci: 0 })
+ mockPullRequests.mockResolvedValue({ items: [], truncated: false, limit: 1000 })
+ mockQuarantine.mockResolvedValue({
+ available: false,
+ entries: [],
+ parse_errors: [],
+ parse_warnings: [],
+ repo: null,
+ source_url: '',
+ generated_at: '',
+ })
+ mockSources.mockResolvedValue([])
+ mockActivity.mockResolvedValue({ owner_team: 'team-replay', tests: [], truncated_tests: false })
+ mockHealth.mockResolvedValue({ items: [], truncated: false, limit: 100 })
+ mockMergeTrend.mockResolvedValue({ owner_team: 'team-replay', has_membership_data: true, points: [] })
+ mockTrunkQuarantine.mockResolvedValue({
+ available: false,
+ owners_resolved: false,
+ ttl_days: 15,
+ repository: '',
+ trunk_url: null,
+ truncated: false,
+ limit: 500,
+ teams: [],
+ tests: [],
+ })
+ mockWorkflowHealth.mockResolvedValue([])
+ })
+
+ afterEach(() => {
+ logic?.unmount()
+ unmountFilters?.()
+ unmountFilters = undefined
+ })
+
+ it('reloads team CI health and merge trend for the shared date range', async () => {
+ const filters = engineeringAnalyticsFiltersLogic()
+ unmountFilters = filters.mount()
+ logic = teamDetailLogic({ ownerTeam: 'team-replay', sourceId: 'source-1' })
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActionsInAnyOrder([
+ 'loadActivitySuccess',
+ 'loadHealthRowSuccess',
+ 'loadMergeTrendSuccess',
+ ])
+ expect(mockActivity).toHaveBeenCalledTimes(1)
+
+ filters.actions.setDateRange('2026-06-01', '2026-06-30')
+ await expectLogic(logic).toDispatchActionsInAnyOrder(['loadHealthRowSuccess', 'loadMergeTrendSuccess'])
+
+ expect(mockHealth).toHaveBeenLastCalledWith('1', {
+ date_from: '2026-06-01',
+ date_to: '2026-06-30',
+ owner_team: 'team-replay',
+ limit: 1,
+ source_id: 'source-1',
+ })
+ expect(mockMergeTrend).toHaveBeenLastCalledWith('1', {
+ owner_team: 'team-replay',
+ date_from: '2026-06-01',
+ date_to: '2026-06-30',
+ source_id: 'source-1',
+ })
+ expect(mockActivity).toHaveBeenCalledTimes(1)
+ })
+
+ it.each([
+ ['a preset over 30 days', '-90d', null],
+ ['a fixed range over 30 days', '2026-05-01', '2026-06-30'],
+ ])('resets %s to the team default instead of requesting it', async (_label, dateFrom, dateTo) => {
+ const filters = engineeringAnalyticsFiltersLogic()
+ unmountFilters = filters.mount()
+ filters.actions.setDateRange(dateFrom, dateTo)
+ logic = teamDetailLogic({ ownerTeam: 'team-replay', sourceId: 'source-1' })
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActionsInAnyOrder(['loadHealthRowSuccess', 'loadMergeTrendSuccess'])
+
+ expect(filters.values.dateFrom).toEqual('-14d')
+ expect(filters.values.dateTo).toBeNull()
+ for (const mock of [mockHealth, mockMergeTrend]) {
+ expect(mock.mock.calls.map(([, params]) => params?.date_from)).toEqual(['-14d'])
+ }
+ })
+})
diff --git a/products/engineering_analytics/frontend/scenes/teamDetailLogic.ts b/products/engineering_analytics/frontend/scenes/teamDetailLogic.ts
index be84afd6540d..d68bd136096f 100644
--- a/products/engineering_analytics/frontend/scenes/teamDetailLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/teamDetailLogic.ts
@@ -1,8 +1,12 @@
-import { MakeLogicType, actions, afterMount, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
+import { router } from 'kea-router'
import { ApiConfig } from 'lib/api'
import { Dayjs, dayjs } from 'lib/dayjs'
+import { urls } from 'scenes/urls'
+
+import { Breadcrumb } from '~/types'
import {
engineeringAnalyticsTeamCiActivity,
@@ -11,14 +15,28 @@ import {
} from '../generated/api'
import type { TeamTestSignalApi } from '../generated/api.schemas'
import { DeliveryScope } from '../lib/deliveryScope'
-import { DEFAULT_TEAMS_WINDOW, TeamCIHealthRow, TeamsWindow, UNOWNED_TEAM, toTeamCIHealthRow } from './teamsLogic'
+import { withScope } from '../lib/scope'
+import { engineeringAnalyticsFiltersLogic } from './engineeringAnalyticsFiltersLogic'
+import {
+ LoaderStatus,
+ TrunkQuarantinedTestRow,
+ engineeringAnalyticsLogic,
+ loaderStatusFromError,
+} from './engineeringAnalyticsLogic'
+import {
+ DEFAULT_TEAMS_WINDOW,
+ TeamCIHealthRow,
+ UNOWNED_TEAM,
+ isTeamsDateRange,
+ teamLabel,
+ toTeamCIHealthRow,
+} from './teamsLogic'
const projectId = (): string => String(ApiConfig.getCurrentProjectId())
export interface TeamDetailLogicProps {
ownerTeam: string
sourceId: string | null
- window: TeamsWindow | null
}
export interface TeamTestSignalRow {
@@ -47,11 +65,17 @@ export interface TeamMergeTrendData {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface teamDetailLogicValues {
+ dateFrom: string | null // engineeringAnalyticsFiltersLogic
+ dateTo: string | null // engineeringAnalyticsFiltersLogic
+ trunkQuarantineTestsByTeam: Record<string, TrunkQuarantinedTestRow[]> // engineeringAnalyticsLogic
activity: TeamActivityData | null
activityLoading: boolean
+ activityStatus: LoaderStatus
+ breadcrumbs: Breadcrumb[]
deliveryScope: DeliveryScope | null
healthRow: TeamCIHealthRow | null
healthRowLoading: boolean
+ healthRowStatus: LoaderStatus
mergeTrend: TeamMergeTrendData | null
mergeTrendLoading: boolean
mergeTrendSeries: {
@@ -59,13 +83,21 @@ export interface teamDetailLogicValues {
labels: string[]
median: number[]
} | null
+ mergeTrendStatus: LoaderStatus
ownerTeam: string
+ quarantinedTests: TrunkQuarantinedTestRow[]
sourceId: string | null
- window: TeamsWindow
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface teamDetailLogicActions {
+ setDateRange: (
+ dateFrom: string | null,
+ dateTo: string | null
+ ) => {
+ dateFrom: string | null
+ dateTo: string | null
+ } // engineeringAnalyticsFiltersLogic
loadActivity: () => any
loadActivityFailure: (
error: string,
@@ -111,8 +143,8 @@ export interface teamDetailLogicActions {
mergeTrend: TeamMergeTrendData | null
payload?: any
}
- setWindow: (window: TeamsWindow) => {
- window: TeamsWindow
+ loadWindowedSections: () => {
+ value: true
}
}
@@ -123,6 +155,11 @@ export interface teamDetailLogicMeta {
ownerTeam: (ownerTeam: string) => string
sourceId: (sourceId: string | null) => string | null
deliveryScope: (ownerTeam: string) => DeliveryScope | null
+ quarantinedTests: (
+ trunkQuarantineTestsByTeam: Record<string, TrunkQuarantinedTestRow[]>,
+ ownerTeam: string
+ ) => TrunkQuarantinedTestRow[]
+ breadcrumbs: (ownerTeam: string, sourceId: string | null, searchParams: Record<string, any>) => Breadcrumb[]
mergeTrendSeries: (mergeTrend: TeamMergeTrendData | null) => {
average: number[]
labels: string[]
@@ -142,12 +179,20 @@ export const teamDetailLogic = kea<teamDetailLogicType>([
path(['products', 'engineering_analytics', 'frontend', 'scenes', 'teamDetailLogic']),
props({} as TeamDetailLogicProps),
key((props) => `${props.ownerTeam}@${props.sourceId ?? ''}`),
+
+ connect(() => ({
+ values: [
+ engineeringAnalyticsFiltersLogic,
+ ['dateFrom', 'dateTo'],
+ engineeringAnalyticsLogic,
+ ['trunkQuarantineTestsByTeam'],
+ ],
+ actions: [engineeringAnalyticsFiltersLogic, ['setDateRange']],
+ })),
actions({
- setWindow: (window: TeamsWindow) => ({ window }),
+ loadWindowedSections: true,
}),
- reducers(({ props }) => ({
- window: [(props.window ?? DEFAULT_TEAMS_WINDOW) as TeamsWindow, { setWindow: (_, { window }) => window }],
- })),
+
loaders(({ props, values }) => ({
activity: [
null as TeamActivityData | null,
@@ -178,7 +223,8 @@ export const teamDetailLogic = kea<teamDetailLogicType>([
{
loadHealthRow: async (): Promise<TeamCIHealthRow | null> => {
const data = await engineeringAnalyticsTeamCiHealth(projectId(), {
- date_from: values.window,
+ date_from: values.dateFrom ?? DEFAULT_TEAMS_WINDOW,
+ date_to: values.dateTo ?? undefined,
owner_team: props.ownerTeam,
limit: 1,
source_id: props.sourceId ?? undefined,
@@ -198,7 +244,8 @@ export const teamDetailLogic = kea<teamDetailLogicType>([
}
const data = await engineeringAnalyticsTeamMergeTrend(projectId(), {
owner_team: props.ownerTeam,
- date_from: values.window,
+ date_from: values.dateFrom ?? DEFAULT_TEAMS_WINDOW,
+ date_to: values.dateTo ?? undefined,
source_id: props.sourceId ?? undefined,
})
return {
@@ -213,6 +260,32 @@ export const teamDetailLogic = kea<teamDetailLogicType>([
},
],
})),
+ reducers({
+ activityStatus: [
+ 'ok' as LoaderStatus,
+ {
+ loadActivity: () => 'ok',
+ loadActivitySuccess: () => 'ok',
+ loadActivityFailure: (_, { errorObject }) => loaderStatusFromError(errorObject),
+ },
+ ],
+ healthRowStatus: [
+ 'ok' as LoaderStatus,
+ {
+ loadHealthRow: () => 'ok',
+ loadHealthRowSuccess: () => 'ok',
+ loadHealthRowFailure: (_, { errorObject }) => loaderStatusFromError(errorObject),
+ },
+ ],
+ mergeTrendStatus: [
+ 'ok' as LoaderStatus,
+ {
+ loadMergeTrend: () => 'ok',
+ loadMergeTrendSuccess: () => 'ok',
+ loadMergeTrendFailure: (_, { errorObject }) => loaderStatusFromError(errorObject),
+ },
+ ],
+ }),
selectors({
ownerTeam: [(_, p) => [p.ownerTeam], (ownerTeam: string) => ownerTeam],
sourceId: [(_, p) => [p.sourceId], (sourceId: string | null) => sourceId],
@@ -223,6 +296,39 @@ export const teamDetailLogic = kea<teamDetailLogicType>([
(ownerTeam: string): DeliveryScope | null =>
ownerTeam === UNOWNED_TEAM ? null : { kind: 'github_team', githubTeam: ownerTeam },
],
+ quarantinedTests: [
+ (s) => [s.trunkQuarantineTestsByTeam, s.ownerTeam],
+ (
+ trunkQuarantineTestsByTeam: Record<string, TrunkQuarantinedTestRow[]>,
+ ownerTeam: string
+ ): TrunkQuarantinedTestRow[] => trunkQuarantineTestsByTeam[ownerTeam] ?? [],
+ ],
+ breadcrumbs: [
+ (s) => [s.ownerTeam, s.sourceId, router.selectors.searchParams],
+ (
+ ownerTeam: string,
+ sourceId: string | null,
+ searchParams: Record<string, string | undefined>
+ ): Breadcrumb[] => [
+ {
+ key: 'EngineeringAnalytics',
+ name: 'Engineering analytics',
+ path: withScope(urls.engineeringAnalytics(), searchParams, sourceId),
+ iconType: 'health',
+ },
+ {
+ key: 'EngineeringAnalyticsTeams',
+ name: 'Teams',
+ path: withScope(urls.engineeringAnalyticsTeams(), searchParams, sourceId),
+ iconType: 'health',
+ },
+ {
+ key: ['EngineeringAnalyticsTeam', ownerTeam],
+ name: teamLabel(ownerTeam),
+ iconType: 'health',
+ },
+ ],
+ ],
/** Quill-ready daily series on the backend's own day buckets. Gaps carry the last values
* forward: a day without merges means "nothing merged", not instant merges, so
* zero-filling would draw a false dip. Null when nothing merged in the window. */
@@ -265,15 +371,23 @@ export const teamDetailLogic = kea<teamDetailLogicType>([
},
],
}),
- listeners(({ actions }) => ({
- setWindow: () => {
+ listeners(({ actions, values }) => ({
+ loadWindowedSections: () => {
+ // The team endpoints reject windows over 30 days, so reset the shared picker rather than
+ // show a window the sections cannot load.
+ if (!isTeamsDateRange(values.dateFrom, values.dateTo)) {
+ actions.setDateRange(DEFAULT_TEAMS_WINDOW, null)
+ return
+ }
actions.loadMergeTrend()
actions.loadHealthRow()
},
+ setDateRange: () => {
+ actions.loadWindowedSections()
+ },
})),
afterMount(({ actions }) => {
actions.loadActivity()
- actions.loadMergeTrend()
- actions.loadHealthRow()
+ actions.loadWindowedSections()
}),
])
diff --git a/products/engineering_analytics/frontend/scenes/teamsLogic.ts b/products/engineering_analytics/frontend/scenes/teamsLogic.ts
index 5c523ffec662..495d2832883d 100644
--- a/products/engineering_analytics/frontend/scenes/teamsLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/teamsLogic.ts
@@ -2,6 +2,7 @@ import { MakeLogicType, afterMount, connect, kea, listeners, path, reducers, sel
import { loaders } from 'kea-loaders'
import { ApiConfig } from 'lib/api'
+import { dayjs } from 'lib/dayjs'
import { dateMapping } from 'lib/utils/dateFilters'
import { engineeringAnalyticsTeamCiHealth } from '../generated/api'
@@ -21,15 +22,33 @@ export const TEAMS_WINDOW_LABELS: Record<TeamsWindow, { prior: string; current:
'-30d': { prior: 'Previous 30 days', current: 'Last 30 days' },
}
-export function isTeamsWindow(value: unknown): value is TeamsWindow {
+function isTeamsWindow(value: unknown): value is TeamsWindow {
return typeof value === 'string' && value in TEAMS_WINDOW_LABELS
}
+const MAX_TEAMS_WINDOW_DAYS = 30
+
+/** Whether the team page can show this range: one of its presets, or a fixed range of at most 30 days. */
+export function isTeamsDateRange(dateFrom: string | null, dateTo: string | null): boolean {
+ if (isTeamsWindow(dateFrom)) {
+ return dateTo === null
+ }
+ if (!dateFrom || dateFrom.startsWith('-') || !dayjs(dateFrom).isValid()) {
+ return false
+ }
+ const span = (dateTo ? dayjs(dateTo) : dayjs()).diff(dayjs(dateFrom), 'day')
+ return span >= 0 && span <= MAX_TEAMS_WINDOW_DAYS
+}
+
// date_from presets the team endpoints accept (max 30d; an equal-length prior twin is scanned).
export const TEAMS_WINDOW_DATE_OPTIONS = dateMapping.filter(({ values }) => isTeamsWindow(values[0]))
export const UNOWNED_TEAM = 'unowned'
+export function teamLabel(ownerTeam: string): string {
+ return ownerTeam === UNOWNED_TEAM ? 'Unowned' : ownerTeam
+}
+
export interface TeamCIHealthRow {
ownerTeam: string
/** Owned tests an in-job retry recovered in the window: the queue's `confirmed_flake`. */