Skip to content

Commit b9d1b70

Browse files
authored
feat(starfish): Highlight TTFD and link to docs when 0 (#59997)
Underline instances of 0ms TTFD and prompt user through tooltip to visit docs and learn how to instrument their application. Only highlights the value if there is one project selected, and it is either android or ios.
1 parent 93518b6 commit b9d1b70

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

static/app/views/starfish/views/screens/screensTable.tsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import {Fragment} from 'react';
1+
import {Fragment, useMemo} from 'react';
22
import * as qs from 'query-string';
33

44
import GridEditable, {GridColumnHeader} from 'sentry/components/gridEditable';
55
import SortLink from 'sentry/components/gridEditable/sortLink';
6+
import ExternalLink from 'sentry/components/links/externalLink';
67
import Link from 'sentry/components/links/link';
78
import Pagination from 'sentry/components/pagination';
8-
import {t} from 'sentry/locale';
9+
import {Tooltip} from 'sentry/components/tooltip';
10+
import {t, tct} from 'sentry/locale';
911
import {
1012
TableData,
1113
TableDataRow,
@@ -16,6 +18,8 @@ import {getFieldRenderer} from 'sentry/utils/discover/fieldRenderers';
1618
import {fieldAlignment} from 'sentry/utils/discover/fields';
1719
import {useLocation} from 'sentry/utils/useLocation';
1820
import useOrganization from 'sentry/utils/useOrganization';
21+
import usePageFilters from 'sentry/utils/usePageFilters';
22+
import useProjects from 'sentry/utils/useProjects';
1923
import TopResultsIndicator from 'sentry/views/discover/table/topResultsIndicator';
2024
import {TableColumn} from 'sentry/views/discover/table/types';
2125
import {useReleaseSelection} from 'sentry/views/starfish/queries/useReleases';
@@ -32,11 +36,20 @@ type Props = {
3236

3337
export function ScreensTable({data, eventView, isLoading, pageLinks}: Props) {
3438
const location = useLocation();
39+
const {selection} = usePageFilters();
40+
const {projects} = useProjects();
3541
const organization = useOrganization();
3642
const {primaryRelease, secondaryRelease} = useReleaseSelection();
3743
const truncatedPrimary = formatVersionAndCenterTruncate(primaryRelease ?? '', 15);
3844
const truncatedSecondary = formatVersionAndCenterTruncate(secondaryRelease ?? '', 15);
3945

46+
const project = useMemo(() => {
47+
if (selection.projects.length !== 1) {
48+
return null;
49+
}
50+
return projects.find(p => p.id === String(selection.projects));
51+
}, [projects, selection.projects]);
52+
4053
const eventViewColumns = eventView.getColumns();
4154

4255
const columnNameMap = {
@@ -97,6 +110,34 @@ export function ScreensTable({data, eventView, isLoading, pageLinks}: Props) {
97110
organization,
98111
unit: data?.meta.units?.[column.key],
99112
});
113+
if (
114+
column.key.includes('time_to_full_display') &&
115+
row[column.key] === 0 &&
116+
project?.platform &&
117+
['android', 'apple-ios'].includes(project.platform)
118+
) {
119+
const docsUrl =
120+
project?.platform === 'android'
121+
? 'https://docs.sentry.io/platforms/android/performance/instrumentation/automatic-instrumentation/#time-to-full-display'
122+
: 'https://docs.sentry.io/platforms/apple/guides/ios/performance/instrumentation/automatic-instrumentation/#time-to-full-display';
123+
return (
124+
<div style={{textAlign: 'right'}}>
125+
<Tooltip
126+
title={tct(
127+
'Measuring TTFD requires manual instrumentation in your application. To learn how to collect TTFD, see the documentation [link].',
128+
{
129+
link: <ExternalLink href={docsUrl}>{t('here')}</ExternalLink>,
130+
}
131+
)}
132+
showUnderline
133+
isHoverable
134+
>
135+
{rendered}
136+
</Tooltip>
137+
</div>
138+
);
139+
}
140+
100141
return rendered;
101142
}
102143

0 commit comments

Comments
 (0)