Skip to content

Commit 851925b

Browse files
feat(preprod): Check for actual build data when showing mobile builds tab
Query the builds endpoint with per_page=1 to check if preprod builds exist for the selected projects and time range. Show the Mobile Builds tab if either actual builds data exists or the project has a mobile platform (existing fallback). The probe query is gated behind the preprod-frontend-routes feature flag and uses a 60s stale time to avoid unnecessary refetches. Refs EME-706 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bd79c6d commit 851925b

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

static/app/views/releases/list/index.tsx

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Fragment, useCallback, useEffect, useMemo} from 'react';
22
import {forceCheck} from 'react-lazyload';
33
import styled from '@emotion/styled';
4+
import {useQuery} from '@tanstack/react-query';
45

56
import {FeatureBadge} from '@sentry/scraps/badge';
67
import {Flex, Stack} from '@sentry/scraps/layout';
@@ -41,6 +42,7 @@ import {useLocation} from 'sentry/utils/useLocation';
4142
import {useNavigate} from 'sentry/utils/useNavigate';
4243
import {useOrganization} from 'sentry/utils/useOrganization';
4344
import {useProjects} from 'sentry/utils/useProjects';
45+
import {buildDetailsApiOptions} from 'sentry/views/preprod/utils/buildDetailsApiOptions';
4446
import {ReleaseArchivedNotice} from 'sentry/views/releases/detail/overview/releaseArchivedNotice';
4547
import {MobileBuilds} from 'sentry/views/releases/list/mobileBuilds';
4648
import {ReleaseHealthCTA} from 'sentry/views/releases/list/releaseHealthCTA';
@@ -232,13 +234,28 @@ export default function ReleasesList() {
232234
: selectedIds.map(id => `${id}`);
233235
}, [selection.projects]);
234236

235-
const shouldShowMobileBuildsTab = useMemo(() => {
236-
if (!organization.features?.includes('preprod-frontend-routes')) {
237-
return false;
238-
}
237+
const hasPreprodFeature = organization.features?.includes('preprod-frontend-routes');
238+
239+
const {statsPeriod, start, end, utc} = normalizeDateTimeParams(location.query);
240+
const buildsProbeQuery = useQuery({
241+
...buildDetailsApiOptions({
242+
organization,
243+
queryParams: {
244+
per_page: 1,
245+
project: selectedProjectIds,
246+
...(statsPeriod && {statsPeriod}),
247+
...(start && {start}),
248+
...(end && {end}),
249+
...(utc && {utc}),
250+
},
251+
}),
252+
staleTime: 60_000,
253+
enabled: !!hasPreprodFeature,
254+
});
239255

240-
// When "All Projects" is selected (represented by [-1]), check all accessible projects
241-
// When specific projects are selected, check only those projects
256+
// When "All Projects" is selected (represented by [-1]), check all accessible projects
257+
// When specific projects are selected, check only those projects
258+
const hasAnyStrictlyMobileProject = useMemo(() => {
242259
const isAllProjects =
243260
selectedProjectIds.length === 1 &&
244261
selectedProjectIds[0] === `${ALL_ACCESS_PROJECTS}`;
@@ -247,13 +264,17 @@ export default function ReleasesList() {
247264
: selectedProjectIds;
248265

249266
// Check if at least one project has a mobile platform
250-
const hasAnyStrictlyMobileProject = projectIdsToCheck
267+
return projectIdsToCheck
251268
.map(id => ProjectsStore.getById(id))
252269
.filter(Boolean)
253270
.some(project => project?.platform && isMobileRelease(project.platform, false));
271+
}, [selectedProjectIds, projects]);
272+
273+
const hasBuildsData =
274+
!buildsProbeQuery.isPending && (buildsProbeQuery.data?.length ?? 0) > 0;
254275

255-
return hasAnyStrictlyMobileProject;
256-
}, [organization.features, selectedProjectIds, projects]);
276+
const shouldShowMobileBuildsTab =
277+
hasPreprodFeature && (hasBuildsData || hasAnyStrictlyMobileProject);
257278

258279
const selectedTab = useMemo(() => {
259280
if (!shouldShowMobileBuildsTab) {

0 commit comments

Comments
 (0)