Skip to content

Commit

Permalink
ref(insights): rename resource module to asset module (#70951)
Browse files Browse the repository at this point in the history
Renaming the `resources` module to `assets` resonates better with FE
devs. This does all the renaming in sentry itself, and there's another
PR up for docs getsentry/sentry-docs#10047

---------

Co-authored-by: George Gritsouk <[email protected]>
  • Loading branch information
DominikB2014 and gggritso authored May 29, 2024
1 parent 6bb769e commit e9472ff
Show file tree
Hide file tree
Showing 15 changed files with 507 additions and 387 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import {LinkButton} from 'sentry/components/button';
import type {SpanType} from 'sentry/components/events/interfaces/spans/types';
import {t} from 'sentry/locale';
import {t, tct} from 'sentry/locale';
import type {EventTransaction, Organization} from 'sentry/types';
import {useLocation} from 'sentry/utils/useLocation';
import {
DATA_TYPE as RESOURCE_DATA_TYPE,
PERFORMANCE_DATA_TYPE as PERFORMANCE_RESOURCE_DATA_TYPE,
} from 'sentry/views/performance/browser/resources/settings';
import {
querySummaryRouteWithQuery,
resourceSummaryRouteWithQuery,
} from 'sentry/views/performance/transactionSummary/transactionSpans/spanDetails/utils';
import {useModuleURL} from 'sentry/views/performance/utils/useModuleURL';
import {ModuleName} from 'sentry/views/starfish/types';
import {resolveSpanModule} from 'sentry/views/starfish/utils/resolveSpanModule';

Expand All @@ -18,6 +23,7 @@ interface Props {

function SpanSummaryButton(props: Props) {
const location = useLocation();
const resourceBaseUrl = useModuleURL(ModuleName.RESOURCE);

const {event, organization, span} = props;

Expand All @@ -27,6 +33,11 @@ function SpanSummaryButton(props: Props) {
}

const resolvedModule = resolveSpanModule(sentryTags.op, sentryTags.category);
const isInsightsEnabled = organization.features.includes('performance-insights');

const resourceDataType = isInsightsEnabled
? RESOURCE_DATA_TYPE
: PERFORMANCE_RESOURCE_DATA_TYPE;

if (
organization.features.includes('spans-first-ui') &&
Expand Down Expand Up @@ -56,13 +67,13 @@ function SpanSummaryButton(props: Props) {
<LinkButton
size="xs"
to={resourceSummaryRouteWithQuery({
orgSlug: organization.slug,
baseUrl: resourceBaseUrl,
query: location.query,
group: sentryTags.group,
projectID: event.projectID,
})}
>
{t('View Resource Summary')}
{tct('View [dataType] Summary', {dataType: resourceDataType})}
</LinkButton>
);
}
Expand Down
9 changes: 7 additions & 2 deletions static/app/components/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ import {normalizeUrl} from 'sentry/utils/withDomainRequired';
import MetricsOnboardingSidebar from 'sentry/views/metrics/ddmOnboarding/sidebar';
import {releaseLevelAsBadgeProps as CacheModuleBadgeProps} from 'sentry/views/performance/cache/settings';
import {releaseLevelAsBadgeProps as QueuesModuleBadgeProps} from 'sentry/views/performance/queues/settings';
import {MODULE_TITLES} from 'sentry/views/performance/utils/useModuleTitle';
import {
MODULE_TITLES,
useModuleTitle,
} from 'sentry/views/performance/utils/useModuleTitle';
import {useModuleURLBuilder} from 'sentry/views/performance/utils/useModuleURL';
import {ModuleName} from 'sentry/views/starfish/types';

import {ProfilingOnboardingSidebar} from '../profiling/ProfilingOnboarding/profilingOnboardingSidebar';

Expand Down Expand Up @@ -124,6 +128,7 @@ function Sidebar() {
const activePanel = useLegacyStore(SidebarPanelStore);
const organization = useOrganization({allowNull: true});
const {shouldAccordionFloat} = useContext(ExpandedContext);
const resourceModuleTitle = useModuleTitle(ModuleName.RESOURCE);

const collapsed = !!preferences.collapsed;
const horizontal = useMedia(`(max-width: ${theme.breakpoints.medium})`);
Expand Down Expand Up @@ -358,7 +363,7 @@ function Sidebar() {
<Feature key="resource" features="spans-first-ui">
<SidebarItem
{...sidebarItemProps}
label={<GuideAnchor target="starfish">{MODULE_TITLES.resource}</GuideAnchor>}
label={<GuideAnchor target="starfish">{resourceModuleTitle}</GuideAnchor>}
to={`/organizations/${organization.slug}/${moduleURLBuilder('resource')}/`}
id="performance-browser-resources"
icon={<SubitemDot collapsed />}
Expand Down
17 changes: 17 additions & 0 deletions static/app/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import IssueListOverview from 'sentry/views/issueList/overview';
import OrganizationContainer from 'sentry/views/organizationContainer';
import OrganizationLayout from 'sentry/views/organizationLayout';
import OrganizationRoot from 'sentry/views/organizationRoot';
import {PERFORMANCE_BASE_URL as PERFORMANCE_RESOURCE_BASE_URL} from 'sentry/views/performance/browser/resources/settings';
import {MODULE_BASE_URLS} from 'sentry/views/performance/utils/useModuleURL';
import ProjectEventRedirect from 'sentry/views/projectEventRedirect';
import redirectDeprecatedProjectRoute from 'sentry/views/projects/redirectDeprecatedProjectRoute';
Expand Down Expand Up @@ -1505,6 +1506,22 @@ function buildRoutes() {
)}
/>
</Route>
<Route path={`${PERFORMANCE_RESOURCE_BASE_URL}/`}>
<IndexRoute
component={make(
() => import('sentry/views/performance/browser/resources/index')
)}
/>
<Route
path="spans/span/:groupId/"
component={make(
() =>
import(
'sentry/views/performance/browser/resources/resourceSummaryPage/index'
)
)}
/>
</Route>
<Route path={`${MODULE_BASE_URLS[ModuleName.QUEUE]}/`}>
<IndexRoute
component={make(
Expand Down
14 changes: 11 additions & 3 deletions static/app/views/performance/browser/resources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionT
import {space} from 'sentry/styles/space';
import {RateUnit} from 'sentry/utils/discover/fields';
import {PageAlert, PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
import useOrganization from 'sentry/utils/useOrganization';
import ResourceView, {
DEFAULT_RESOURCE_TYPES,
FilterOptionsContainer,
} from 'sentry/views/performance/browser/resources/resourceView';
import {
MODULE_DESCRIPTION,
MODULE_DOC_LINK,
MODULE_TITLE,
PERFORMANCE_MODULE_DESCRIPTION,
} from 'sentry/views/performance/browser/resources/settings';
import {
BrowserStarfishFields,
Expand All @@ -29,6 +30,8 @@ import {
import {DEFAULT_RESOURCE_FILTERS} from 'sentry/views/performance/browser/resources/utils/useResourcesQuery';
import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
import {useModuleBreadcrumbs} from 'sentry/views/performance/utils/useModuleBreadcrumbs';
import {useModuleTitle} from 'sentry/views/performance/utils/useModuleTitle';
import {ModuleName} from 'sentry/views/starfish/types';
import {DomainSelector} from 'sentry/views/starfish/views/spans/selectors/domainSelector';

const {SPAN_OP, SPAN_DOMAIN} = BrowserStarfishFields;
Expand All @@ -37,8 +40,11 @@ export const RESOURCE_THROUGHPUT_UNIT = RateUnit.PER_MINUTE;

function ResourcesLandingPage() {
const filters = useResourceModuleFilters();
const organization = useOrganization();
const moduleTitle = useModuleTitle(ModuleName.RESOURCE);

const crumbs = useModuleBreadcrumbs('resource');
const isInsightsEnabled = organization.features.includes('performance-insights');

return (
<React.Fragment>
Expand All @@ -48,10 +54,12 @@ function ResourcesLandingPage() {
<Breadcrumbs crumbs={crumbs} />

<Layout.Title>
{MODULE_TITLE}
{moduleTitle}
<PageHeadingQuestionTooltip
docsUrl={MODULE_DOC_LINK}
title={MODULE_DESCRIPTION}
title={
isInsightsEnabled ? MODULE_DESCRIPTION : PERFORMANCE_MODULE_DESCRIPTION
}
/>
</Layout.Title>
</Layout.HeaderContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
import {t} from 'sentry/locale';
import {t, tct} from 'sentry/locale';
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {useParams} from 'sentry/utils/useParams';
import {Referrer} from 'sentry/views/performance/browser/resources/referrer';
import ResourceInfo from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceInfo';
import ResourceSummaryCharts from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceSummaryCharts';
import ResourceSummaryTable from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceSummaryTable';
import SampleImages from 'sentry/views/performance/browser/resources/resourceSummaryPage/sampleImages';
import {FilterOptionsContainer} from 'sentry/views/performance/browser/resources/resourceView';
import {
DATA_TYPE,
PERFORMANCE_DATA_TYPE,
} from 'sentry/views/performance/browser/resources/settings';
import {IMAGE_FILE_EXTENSIONS} from 'sentry/views/performance/browser/resources/shared/constants';
import RenderBlockingSelector from 'sentry/views/performance/browser/resources/shared/renderBlockingSelector';
import {ResourceSpanOps} from 'sentry/views/performance/browser/resources/shared/types';
Expand All @@ -42,6 +47,7 @@ const {

function ResourceSummary() {
const webVitalsModuleURL = useModuleURL('vital');
const organization = useOrganization();
const {groupId} = useParams();
const filters = useResourceModuleFilters();
const selectedSpanOp = filters[SPAN_OP];
Expand Down Expand Up @@ -83,6 +89,9 @@ function ResourceSummary() {

const crumbs = useModuleBreadcrumbs('resource');

const isInsightsEnabled = organization.features.includes('performance-insights');
const resourceDataType = isInsightsEnabled ? DATA_TYPE : PERFORMANCE_DATA_TYPE;

return (
<React.Fragment>
<Layout.Header>
Expand All @@ -91,7 +100,7 @@ function ResourceSummary() {
crumbs={[
...crumbs,
{
label: 'Resource Summary',
label: tct('[dataType] Summary', {dataType: resourceDataType}),
},
]}
/>
Expand Down Expand Up @@ -148,10 +157,14 @@ function ResourceSummary() {
}

function PageWithProviders() {
const organization = useOrganization();

const isInsightsEnabled = organization.features.includes('performance-insights');
const resourceDataType = isInsightsEnabled ? DATA_TYPE : PERFORMANCE_DATA_TYPE;
return (
<ModulePageProviders
moduleName="resource"
pageTitle={t('Resource Summary')}
pageTitle={`${resourceDataType} ${t('Summary')}`}
features="spans-first-ui"
>
<ResourceSummary />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {t} from 'sentry/locale';
import {t, tct} from 'sentry/locale';
import {formatBytesBase2} from 'sentry/utils';
import {formatRate} from 'sentry/utils/formatters';
import getDynamicText from 'sentry/utils/getDynamicText';
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
import useOrganization from 'sentry/utils/useOrganization';
import {RESOURCE_THROUGHPUT_UNIT} from 'sentry/views/performance/browser/resources';
import {Referrer} from 'sentry/views/performance/browser/resources/referrer';
import {
DATA_TYPE,
PERFORMANCE_DATA_TYPE,
} from 'sentry/views/performance/browser/resources/settings';
import {useResourceModuleFilters} from 'sentry/views/performance/browser/resources/utils/useResourceFilters';
import {AVG_COLOR, THROUGHPUT_COLOR} from 'sentry/views/starfish/colors';
import Chart, {ChartType} from 'sentry/views/starfish/components/chart';
Expand All @@ -28,6 +33,10 @@ const {

function ResourceSummaryCharts(props: {groupId: string}) {
const filters = useResourceModuleFilters();
const organization = useOrganization();

const isInsightsEnabled = organization.features.includes('performance-insights');
const resourceDataType = isInsightsEnabled ? DATA_TYPE : PERFORMANCE_DATA_TYPE;

const {data: spanMetricsSeriesData, isLoading: areSpanMetricsSeriesLoading} =
useSpanMetricsSeries(
Expand Down Expand Up @@ -96,7 +105,7 @@ function ResourceSummaryCharts(props: {groupId: string}) {
</ChartPanel>
</Block>
<Block>
<ChartPanel title={t('Average Resource Size')}>
<ChartPanel title={tct('Average [dataType] Size', {dataType: resourceDataType})}>
<Chart
height={160}
aggregateOutputFormat="size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import {browserHistory} from 'sentry/utils/browserHistory';
import {DismissId, usePageAlert} from 'sentry/utils/performance/contexts/pageAlert';
import {decodeScalar} from 'sentry/utils/queryString';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {RESOURCE_THROUGHPUT_UNIT} from 'sentry/views/performance/browser/resources';
import {
DATA_TYPE,
PERFORMANCE_DATA_TYPE,
} from 'sentry/views/performance/browser/resources/settings';
import {
FONT_FILE_EXTENSIONS,
IMAGE_FILE_EXTENSIONS,
Expand Down Expand Up @@ -69,9 +74,13 @@ type Props = {

function ResourceTable({sort, defaultResourceTypes}: Props) {
const location = useLocation();
const organization = useOrganization();
const cursor = decodeScalar(location.query?.[QueryParameterNames.SPANS_CURSOR]);
const {setPageInfo, pageAlert} = usePageAlert();

const isInsightsEnabled = organization.features.includes('performance-insights');
const resourceDataType = isInsightsEnabled ? DATA_TYPE : PERFORMANCE_DATA_TYPE;

const {data, isLoading, pageLinks} = useResourcesQuery({
sort,
defaultResourceTypes,
Expand All @@ -80,7 +89,11 @@ function ResourceTable({sort, defaultResourceTypes}: Props) {
});

const columnOrder: GridColumnOrder<keyof Row>[] = [
{key: SPAN_DESCRIPTION, width: COL_WIDTH_UNDEFINED, name: t('Resource Description')},
{
key: SPAN_DESCRIPTION,
width: COL_WIDTH_UNDEFINED,
name: `${resourceDataType} ${t('Description')}`,
},
{
key: `${SPM}()`,
width: COL_WIDTH_UNDEFINED,
Expand Down
14 changes: 11 additions & 3 deletions static/app/views/performance/browser/resources/settings.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import {t} from 'sentry/locale';

export const MODULE_TITLE = t('Resources');
export const BASE_URL = 'browser/resources';

export const MODULE_TITLE = t('Assets');
export const DATA_TYPE = t('Asset');
export const BASE_URL = 'browser/assets'; // Name of the data shown (singular)
export const MODULE_DESCRIPTION = t(
'Find large and slow-to-load resources used by your application and understand their impact on page performance.'
);

export const PERFORMANCE_MODULE_TITLE = t('Resources');
export const PERFORMANCE_BASE_URL = 'browser/resources';
export const PERFORMANCE_DATA_TYPE = t('Resource');
export const PERFORMANCE_MODULE_DESCRIPTION = t(
'Find large and slow-to-load resources used by your application and understand their impact on page performance.'
);

export const MODULE_DOC_LINK = 'https://docs.sentry.io/product/performance/resources/';
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ describe('Performance > Widgets > WidgetContainer', function () {
});

it('Most time consuming resources widget', async function () {
const data = initializeData();
const data = initializeData(undefined, {features: ['performance-insights']});

wrapper = render(
<MEPSettingProvider forceTransactions>
Expand All @@ -955,11 +955,11 @@ describe('Performance > Widgets > WidgetContainer', function () {
);

expect(await screen.findByTestId('performance-widget-title')).toHaveTextContent(
'Most Time Consuming Resources'
'Most Time-Consuming Assets'
);
expect(await screen.findByRole('button', {name: 'View All'})).toHaveAttribute(
'href',
'/performance/browser/resources/'
'/insights/browser/assets/'
);
expect(eventsMock).toHaveBeenCalledTimes(1);
expect(eventsMock).toHaveBeenNthCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ export function WidgetHeader<T extends WidgetDataConstraint>(
PerformanceWidgetSetting.OVERALL_PERFORMANCE_SCORE,
].includes(chartSetting);

const isResourcesWidget =
chartSetting === PerformanceWidgetSetting.MOST_TIME_CONSUMING_RESOURCES;

const isCacheWidget =
chartSetting === PerformanceWidgetSetting.HIGHEST_CACHE_MISS_RATE_TRANSACTIONS;

const featureBadge =
isWebVitalsWidget || isResourcesWidget || isCacheWidget ? (
<FeatureBadge type="new" />
) : null;
isWebVitalsWidget || isCacheWidget ? <FeatureBadge type="new" /> : null;

return (
<WidgetHeaderContainer>
Expand Down
Loading

0 comments on commit e9472ff

Please sign in to comment.