index.tsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. import {useCallback, useMemo} from 'react';
  2. import {browserHistory} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import type {Location} from 'history';
  5. import {Button, LinkButton} from 'sentry/components/button';
  6. import {CompactSelect} from 'sentry/components/compactSelect';
  7. import type {SelectOption} from 'sentry/components/compactSelect/types';
  8. import Count from 'sentry/components/count';
  9. import DatePageFilter from 'sentry/components/datePageFilter';
  10. import DateTime from 'sentry/components/dateTime';
  11. import EnvironmentPageFilter from 'sentry/components/environmentPageFilter';
  12. import ErrorBoundary from 'sentry/components/errorBoundary';
  13. import SearchBar from 'sentry/components/events/searchBar';
  14. import IdBadge from 'sentry/components/idBadge';
  15. import * as Layout from 'sentry/components/layouts/thirds';
  16. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  17. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  18. import PerformanceDuration from 'sentry/components/performanceDuration';
  19. import {AggregateFlamegraph} from 'sentry/components/profiling/flamegraph/aggregateFlamegraph';
  20. import {AggregateFlamegraphTreeTable} from 'sentry/components/profiling/flamegraph/aggregateFlamegraphTreeTable';
  21. import {FlamegraphSearch} from 'sentry/components/profiling/flamegraph/flamegraphToolbar/flamegraphSearch';
  22. import {
  23. ProfilingBreadcrumbs,
  24. ProfilingBreadcrumbsProps,
  25. } from 'sentry/components/profiling/profilingBreadcrumbs';
  26. import {SegmentedControl} from 'sentry/components/segmentedControl';
  27. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  28. import type {SmartSearchBarProps} from 'sentry/components/smartSearchBar';
  29. import SmartSearchBar from 'sentry/components/smartSearchBar';
  30. import {MAX_QUERY_LENGTH} from 'sentry/constants';
  31. import {t} from 'sentry/locale';
  32. import {space} from 'sentry/styles/space';
  33. import type {Organization, PageFilters, Project} from 'sentry/types';
  34. import {DeepPartial} from 'sentry/types/utils';
  35. import {defined} from 'sentry/utils';
  36. import EventView from 'sentry/utils/discover/eventView';
  37. import {isAggregateField} from 'sentry/utils/discover/fields';
  38. import {
  39. CanvasPoolManager,
  40. CanvasScheduler,
  41. useCanvasScheduler,
  42. } from 'sentry/utils/profiling/canvasScheduler';
  43. import {FlamegraphState} from 'sentry/utils/profiling/flamegraph/flamegraphStateProvider/flamegraphContext';
  44. import {FlamegraphStateProvider} from 'sentry/utils/profiling/flamegraph/flamegraphStateProvider/flamegraphContextProvider';
  45. import {FlamegraphThemeProvider} from 'sentry/utils/profiling/flamegraph/flamegraphThemeProvider';
  46. import {Frame} from 'sentry/utils/profiling/frame';
  47. import {useAggregateFlamegraphQuery} from 'sentry/utils/profiling/hooks/useAggregateFlamegraphQuery';
  48. import {useCurrentProjectFromRouteParam} from 'sentry/utils/profiling/hooks/useCurrentProjectFromRouteParam';
  49. import {useProfileEvents} from 'sentry/utils/profiling/hooks/useProfileEvents';
  50. import {useProfileFilters} from 'sentry/utils/profiling/hooks/useProfileFilters';
  51. import {decodeScalar} from 'sentry/utils/queryString';
  52. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  53. import {useLocalStorageState} from 'sentry/utils/useLocalStorageState';
  54. import {useLocation} from 'sentry/utils/useLocation';
  55. import useOrganization from 'sentry/utils/useOrganization';
  56. import {transactionSummaryRouteWithQuery} from 'sentry/views/performance/transactionSummary/utils';
  57. import {
  58. FlamegraphProvider,
  59. useFlamegraph,
  60. } from 'sentry/views/profiling/flamegraphProvider';
  61. import {ProfilesSummaryChart} from 'sentry/views/profiling/landing/profilesSummaryChart';
  62. import {ProfileGroupProvider} from 'sentry/views/profiling/profileGroupProvider';
  63. import {ProfilingFieldType} from 'sentry/views/profiling/profileSummary/content';
  64. import {LegacySummaryPage} from 'sentry/views/profiling/profileSummary/legacySummaryPage';
  65. import {DEFAULT_PROFILING_DATETIME_SELECTION} from 'sentry/views/profiling/utils';
  66. import {MostRegressedProfileFunctions} from './regressedProfileFunctions';
  67. import {SlowestProfileFunctions} from './slowestProfileFunctions';
  68. const DEFAULT_FLAMEGRAPH_PREFERENCES: DeepPartial<FlamegraphState> = {
  69. preferences: {
  70. sorting: 'alphabetical' satisfies FlamegraphState['preferences']['sorting'],
  71. },
  72. };
  73. interface ProfileSummaryHeaderProps {
  74. location: Location;
  75. organization: Organization;
  76. project: Project | null;
  77. query: string;
  78. transaction: string;
  79. }
  80. function ProfileSummaryHeader(props: ProfileSummaryHeaderProps) {
  81. const breadcrumbTrails: ProfilingBreadcrumbsProps['trails'] = useMemo(() => {
  82. return [
  83. {
  84. type: 'landing',
  85. payload: {
  86. query: props.location.query,
  87. },
  88. },
  89. {
  90. type: 'profile summary',
  91. payload: {
  92. projectSlug: props.project?.slug ?? '',
  93. query: props.location.query,
  94. transaction: props.transaction,
  95. },
  96. },
  97. ];
  98. }, [props.location.query, props.project?.slug, props.transaction]);
  99. const transactionSummaryTarget =
  100. props.project &&
  101. props.transaction &&
  102. transactionSummaryRouteWithQuery({
  103. orgSlug: props.organization.slug,
  104. transaction: props.transaction,
  105. projectID: props.project.id,
  106. query: {query: props.query},
  107. });
  108. return (
  109. <ProfilingHeader>
  110. <ProfilingHeaderContent>
  111. <ProfilingBreadcrumbs
  112. organization={props.organization}
  113. trails={breadcrumbTrails}
  114. />
  115. <Layout.Title>
  116. <ProfilingTitleContainer>
  117. {props.project ? (
  118. <IdBadge
  119. hideName
  120. project={props.project}
  121. avatarSize={22}
  122. avatarProps={{hasTooltip: true, tooltip: props.project.slug}}
  123. />
  124. ) : null}
  125. {props.transaction}
  126. </ProfilingTitleContainer>
  127. </Layout.Title>
  128. </ProfilingHeaderContent>
  129. {transactionSummaryTarget && (
  130. <Layout.HeaderActions>
  131. <LinkButton to={transactionSummaryTarget} size="sm">
  132. {t('View Transaction Summary')}
  133. </LinkButton>
  134. </Layout.HeaderActions>
  135. )}
  136. </ProfilingHeader>
  137. );
  138. }
  139. const ProfilingHeader = styled(Layout.Header)`
  140. padding: ${space(1)} ${space(2)} ${space(0)} ${space(2)} !important;
  141. `;
  142. const ProfilingHeaderContent = styled(Layout.HeaderContent)`
  143. h1 {
  144. line-height: normal;
  145. }
  146. `;
  147. const ProfilingTitleContainer = styled('div')`
  148. display: flex;
  149. align-items: center;
  150. gap: ${space(1)};
  151. font-size: ${p => p.theme.fontSizeLarge};
  152. `;
  153. interface ProfileFiltersProps {
  154. location: Location;
  155. organization: Organization;
  156. projectIds: EventView['project'];
  157. query: string;
  158. selection: PageFilters;
  159. transaction: string | undefined;
  160. usingTransactions: boolean;
  161. }
  162. function ProfileFilters(props: ProfileFiltersProps) {
  163. const filtersQuery = useMemo(() => {
  164. // To avoid querying for the filters each time the query changes,
  165. // do not pass the user query to get the filters.
  166. const search = new MutableSearch('');
  167. if (defined(props.transaction)) {
  168. search.setFilterValues('transaction_name', [props.transaction]);
  169. }
  170. return search.formatString();
  171. }, [props.transaction]);
  172. const profileFilters = useProfileFilters({
  173. query: filtersQuery,
  174. selection: props.selection,
  175. disabled: props.usingTransactions,
  176. });
  177. const handleSearch: SmartSearchBarProps['onSearch'] = useCallback(
  178. (searchQuery: string) => {
  179. browserHistory.push({
  180. ...props.location,
  181. query: {
  182. ...props.location.query,
  183. query: searchQuery || undefined,
  184. cursor: undefined,
  185. },
  186. });
  187. },
  188. [props.location]
  189. );
  190. return (
  191. <ActionBar>
  192. <PageFilterBar condensed>
  193. <EnvironmentPageFilter />
  194. <DatePageFilter alignDropdown="left" />
  195. </PageFilterBar>
  196. {props.usingTransactions ? (
  197. <SearchBar
  198. searchSource="profile_summary"
  199. organization={props.organization}
  200. projectIds={props.projectIds}
  201. query={props.query}
  202. onSearch={handleSearch}
  203. maxQueryLength={MAX_QUERY_LENGTH}
  204. />
  205. ) : (
  206. <SmartSearchBar
  207. organization={props.organization}
  208. hasRecentSearches
  209. searchSource="profile_summary"
  210. supportedTags={profileFilters}
  211. query={props.query}
  212. onSearch={handleSearch}
  213. maxQueryLength={MAX_QUERY_LENGTH}
  214. />
  215. )}
  216. </ActionBar>
  217. );
  218. }
  219. const ActionBar = styled('div')`
  220. display: grid;
  221. gap: ${space(1)};
  222. grid-template-columns: min-content auto;
  223. padding: ${space(1)} ${space(1)};
  224. background-color: ${p => p.theme.background};
  225. `;
  226. interface ProfileSummaryPageProps {
  227. location: Location;
  228. params: {
  229. projectId?: Project['slug'];
  230. };
  231. selection: PageFilters;
  232. }
  233. function ProfileSummaryPage(props: ProfileSummaryPageProps) {
  234. const organization = useOrganization();
  235. const project = useCurrentProjectFromRouteParam();
  236. const profilingUsingTransactions = organization.features.includes(
  237. 'profiling-using-transactions'
  238. );
  239. const transaction = decodeScalar(props.location.query.transaction);
  240. if (!transaction) {
  241. throw new TypeError(
  242. `Profile summary requires a transaction query params, got ${
  243. transaction?.toString() ?? transaction
  244. }`
  245. );
  246. }
  247. const rawQuery = decodeScalar(props.location?.query?.query, '');
  248. const projectIds: number[] = useMemo(() => {
  249. if (!defined(project)) {
  250. return [];
  251. }
  252. const projects = parseInt(project.id, 10);
  253. if (isNaN(projects)) {
  254. return [];
  255. }
  256. return [projects];
  257. }, [project]);
  258. const projectSlugs: string[] = useMemo(() => {
  259. return defined(project) ? [project.slug] : [];
  260. }, [project]);
  261. const query = useMemo(() => {
  262. const search = new MutableSearch(rawQuery);
  263. if (defined(transaction)) {
  264. search.setFilterValues('transaction', [transaction]);
  265. }
  266. // there are no aggregations happening on this page,
  267. // so remove any aggregate filters
  268. Object.keys(search.filters).forEach(field => {
  269. if (isAggregateField(field)) {
  270. search.removeFilter(field);
  271. }
  272. });
  273. return search.formatString();
  274. }, [rawQuery, transaction]);
  275. const {data} = useAggregateFlamegraphQuery({transaction});
  276. const [visualization, setVisualization] = useLocalStorageState<
  277. 'flamegraph' | 'call tree'
  278. >('flamegraph-visualization', 'flamegraph');
  279. const onVisualizationChange = useCallback(
  280. (value: 'flamegraph' | 'call tree') => {
  281. setVisualization(value);
  282. },
  283. [setVisualization]
  284. );
  285. const [frameFilter, setFrameFilter] = useLocalStorageState<
  286. 'system' | 'application' | 'all'
  287. >('flamegraph-frame-filter', 'application');
  288. const onFrameFilterChange = useCallback(
  289. (value: 'system' | 'application' | 'all') => {
  290. setFrameFilter(value);
  291. },
  292. [setFrameFilter]
  293. );
  294. const flamegraphFrameFilter: ((frame: Frame) => boolean) | undefined = useMemo(() => {
  295. if (frameFilter === 'all') {
  296. return () => true;
  297. }
  298. if (frameFilter === 'application') {
  299. return frame => frame.is_application;
  300. }
  301. return frame => !frame.is_application;
  302. }, [frameFilter]);
  303. const canvasPoolManager = useMemo(() => new CanvasPoolManager(), []);
  304. const scheduler = useCanvasScheduler(canvasPoolManager);
  305. return (
  306. <SentryDocumentTitle
  307. title={t('Profiling \u2014 Profile Summary')}
  308. orgSlug={organization.slug}
  309. >
  310. <ProfileSummaryContainer>
  311. <PageFiltersContainer
  312. shouldForceProject={defined(project)}
  313. forceProject={project}
  314. specificProjectSlugs={projectSlugs}
  315. defaultSelection={
  316. profilingUsingTransactions
  317. ? {datetime: DEFAULT_PROFILING_DATETIME_SELECTION}
  318. : undefined
  319. }
  320. >
  321. <ProfileSummaryHeader
  322. organization={organization}
  323. location={props.location}
  324. project={project}
  325. query={query}
  326. transaction={transaction}
  327. />
  328. <ProfileFilters
  329. projectIds={projectIds}
  330. organization={organization}
  331. location={props.location}
  332. query={rawQuery}
  333. selection={props.selection}
  334. transaction={transaction}
  335. usingTransactions={profilingUsingTransactions}
  336. />
  337. <ProfilesSummaryChart
  338. referrer="api.profiling.profile-summary-chart"
  339. query={query}
  340. hideCount
  341. />
  342. <ProfileVisualizationContainer>
  343. <ProfileVisualization>
  344. <ProfileGroupProvider
  345. traceID=""
  346. type="flamegraph"
  347. input={data ?? null}
  348. frameFilter={flamegraphFrameFilter}
  349. >
  350. <FlamegraphStateProvider initialState={DEFAULT_FLAMEGRAPH_PREFERENCES}>
  351. <FlamegraphThemeProvider>
  352. <FlamegraphProvider>
  353. <AggregateFlamegraphContainer>
  354. <AggregateFlamegraphToolbar
  355. scheduler={scheduler}
  356. canvasPoolManager={canvasPoolManager}
  357. visualization={visualization}
  358. onVisualizationChange={onVisualizationChange}
  359. frameFilter={frameFilter}
  360. onFrameFilterChange={onFrameFilterChange}
  361. hideSystemFrames={false}
  362. setHideSystemFrames={() => void 0}
  363. />
  364. {visualization === 'flamegraph' ? (
  365. <AggregateFlamegraph
  366. canvasPoolManager={canvasPoolManager}
  367. scheduler={scheduler}
  368. />
  369. ) : (
  370. <AggregateFlamegraphTreeTable
  371. recursion={null}
  372. expanded={false}
  373. frameFilter={frameFilter}
  374. canvasScheduler={scheduler}
  375. canvasPoolManager={canvasPoolManager}
  376. />
  377. )}
  378. </AggregateFlamegraphContainer>
  379. </FlamegraphProvider>
  380. </FlamegraphThemeProvider>
  381. </FlamegraphStateProvider>
  382. </ProfileGroupProvider>
  383. </ProfileVisualization>
  384. <ProfileDigestContainer>
  385. <ProfileDigestScrollContainer>
  386. <ProfileDigest />
  387. <MostRegressedProfileFunctions transaction={transaction} />
  388. <SlowestProfileFunctions transaction={transaction} />
  389. </ProfileDigestScrollContainer>
  390. </ProfileDigestContainer>
  391. </ProfileVisualizationContainer>
  392. </PageFiltersContainer>
  393. </ProfileSummaryContainer>
  394. </SentryDocumentTitle>
  395. );
  396. }
  397. const AggregateFlamegraphContainer = styled('div')`
  398. display: flex;
  399. flex-direction: column;
  400. flex: 1 1 100%;
  401. height: 100%;
  402. width: 100%;
  403. overflow: hidden;
  404. position: absolute;
  405. left: 0px;
  406. top: 0px;
  407. `;
  408. interface AggregateFlamegraphToolbarProps {
  409. canvasPoolManager: CanvasPoolManager;
  410. frameFilter: 'system' | 'application' | 'all';
  411. hideSystemFrames: boolean;
  412. onFrameFilterChange: (value: 'system' | 'application' | 'all') => void;
  413. onVisualizationChange: (value: 'flamegraph' | 'call tree') => void;
  414. scheduler: CanvasScheduler;
  415. setHideSystemFrames: (value: boolean) => void;
  416. visualization: 'flamegraph' | 'call tree';
  417. }
  418. function AggregateFlamegraphToolbar(props: AggregateFlamegraphToolbarProps) {
  419. const flamegraph = useFlamegraph();
  420. const flamegraphs = useMemo(() => [flamegraph], [flamegraph]);
  421. const spans = useMemo(() => [], []);
  422. const frameSelectOptions: SelectOption<'system' | 'application' | 'all'>[] =
  423. useMemo(() => {
  424. return [
  425. {value: 'system', label: t('System Frames')},
  426. {value: 'application', label: t('Application Frames')},
  427. {value: 'all', label: t('All Frames')},
  428. ];
  429. }, []);
  430. const onResetZoom = useCallback(() => {
  431. props.scheduler.dispatch('reset zoom');
  432. }, [props.scheduler]);
  433. const onFrameFilterChange = useCallback(
  434. (value: {value: 'application' | 'system' | 'all'}) => {
  435. props.onFrameFilterChange(value.value);
  436. },
  437. [props]
  438. );
  439. return (
  440. <AggregateFlamegraphToolbarContainer>
  441. <ViewSelectContainer>
  442. <SegmentedControl
  443. aria-label={t('View')}
  444. size="xs"
  445. value={props.visualization}
  446. onChange={props.onVisualizationChange}
  447. >
  448. <SegmentedControl.Item key="flamegraph">
  449. {t('Flamegraph')}
  450. </SegmentedControl.Item>
  451. <SegmentedControl.Item key="call tree">{t('Call Tree')}</SegmentedControl.Item>
  452. </SegmentedControl>
  453. </ViewSelectContainer>
  454. <AggregateFlamegraphSearch
  455. spans={spans}
  456. canvasPoolManager={props.canvasPoolManager}
  457. flamegraphs={flamegraphs}
  458. />
  459. <Button size="xs" onClick={onResetZoom}>
  460. {t('Reset Zoom')}
  461. </Button>
  462. <CompactSelect
  463. onChange={onFrameFilterChange}
  464. value={props.frameFilter}
  465. size="xs"
  466. options={frameSelectOptions}
  467. />
  468. </AggregateFlamegraphToolbarContainer>
  469. );
  470. }
  471. const ViewSelectContainer = styled('div')`
  472. min-width: 160px;
  473. `;
  474. const AggregateFlamegraphToolbarContainer = styled('div')`
  475. display: flex;
  476. justify-content: space-between;
  477. gap: ${space(1)};
  478. padding: ${space(0.5)};
  479. background-color: ${p => p.theme.background};
  480. `;
  481. const AggregateFlamegraphSearch = styled(FlamegraphSearch)`
  482. max-width: 300px;
  483. `;
  484. const ProfileVisualization = styled('div')`
  485. grid-area: visualization;
  486. position: relative;
  487. height: 100%;
  488. `;
  489. const ProfileDigestContainer = styled('div')`
  490. grid-area: digest;
  491. border-left: 1px solid ${p => p.theme.border};
  492. background-color: ${p => p.theme.background};
  493. display: flex;
  494. flex: 1 1 100%;
  495. flex-direction: column;
  496. position: relative;
  497. overflow: hidden;
  498. `;
  499. const ProfileDigestScrollContainer = styled('div')`
  500. padding: ${space(0.5)};
  501. position: absolute;
  502. left: 0;
  503. right: 0;
  504. top: 0;
  505. bottom: 0;
  506. display: flex;
  507. flex-direction: column;
  508. `;
  509. const ProfileVisualizationContainer = styled('div')`
  510. display: grid;
  511. grid-template-areas: 'visualization digest';
  512. grid-template-columns: 60% 40%;
  513. flex: 1 1 100%;
  514. `;
  515. const ProfileSummaryContainer = styled('div')`
  516. display: flex;
  517. flex-direction: column;
  518. flex: 1 1 100%;
  519. /*
  520. * The footer component is a sibling of this div.
  521. * Remove it so the flamegraph can take up the
  522. * entire screen.
  523. */
  524. ~ footer {
  525. display: none;
  526. }
  527. `;
  528. const PROFILE_DIGEST_FIELDS = [
  529. 'last_seen()',
  530. 'p75()',
  531. 'p95()',
  532. 'p99()',
  533. 'count()',
  534. ] satisfies ProfilingFieldType[];
  535. const percentiles = ['p75()', 'p95()', 'p99()'] as const;
  536. function ProfileDigest() {
  537. const location = useLocation();
  538. const profilesCursor = useMemo(
  539. () => decodeScalar(location.query.cursor),
  540. [location.query.cursor]
  541. );
  542. const profiles = useProfileEvents<ProfilingFieldType>({
  543. cursor: profilesCursor,
  544. fields: PROFILE_DIGEST_FIELDS,
  545. query: '',
  546. sort: {key: 'last_seen()', order: 'desc'},
  547. referrer: 'api.profiling.profile-summary-table',
  548. });
  549. const data = profiles.data?.data?.[0];
  550. return (
  551. <ProfileDigestHeader>
  552. <div>
  553. <ProfileDigestLabel>{t('Last Seen')}</ProfileDigestLabel>
  554. <div>
  555. {profiles.isLoading ? (
  556. ''
  557. ) : profiles.isError ? (
  558. ''
  559. ) : (
  560. <DateTime date={new Date(data?.['last_seen()'] as string)} />
  561. )}
  562. </div>
  563. </div>
  564. {percentiles.map(p => {
  565. return (
  566. <ProfileDigestColumn key={p}>
  567. <ProfileDigestLabel>{p}</ProfileDigestLabel>
  568. <div>
  569. {profiles.isLoading ? (
  570. ''
  571. ) : profiles.isError ? (
  572. ''
  573. ) : (
  574. <PerformanceDuration nanoseconds={data?.[p] as number} abbreviation />
  575. )}
  576. </div>
  577. </ProfileDigestColumn>
  578. );
  579. })}
  580. <ProfileDigestColumn>
  581. <ProfileDigestLabel>{t('profiles')}</ProfileDigestLabel>
  582. <div>
  583. {profiles.isLoading ? (
  584. ''
  585. ) : profiles.isError ? (
  586. ''
  587. ) : (
  588. <Count value={data?.['count()'] as number} />
  589. )}
  590. </div>
  591. </ProfileDigestColumn>
  592. </ProfileDigestHeader>
  593. );
  594. }
  595. const ProfileDigestColumn = styled('div')`
  596. text-align: right;
  597. `;
  598. const ProfileDigestHeader = styled('div')`
  599. display: flex;
  600. justify-content: space-between;
  601. `;
  602. const ProfileDigestLabel = styled('span')`
  603. color: ${p => p.theme.textColor};
  604. font-size: ${p => p.theme.fontSizeSmall};
  605. font-weight: 600;
  606. text-transform: uppercase;
  607. `;
  608. export default function ProfileSummaryPageToggle(props: ProfileSummaryPageProps) {
  609. const organization = useOrganization();
  610. if (organization.features.includes('profiling-summary-redesign')) {
  611. return (
  612. <ProfileSummaryContainer data-test-id="profile-summary-redesign">
  613. <ErrorBoundary>
  614. <ProfileSummaryPage {...props} />
  615. </ErrorBoundary>
  616. </ProfileSummaryContainer>
  617. );
  618. }
  619. return (
  620. <div data-test-id="profile-summary-legacy">
  621. <LegacySummaryPage {...props} />
  622. </div>
  623. );
  624. }