Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(insights): rename resource module to asset module #70951

Merged
merged 28 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,

Check failure on line 7 in static/app/components/events/interfaces/spans/spanSummaryButton.tsx

View workflow job for this annotation

GitHub Actions / typescript and lint

Module '"sentry/views/performance/browser/resources/settings"' has no exported member '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 @@

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

const {event, organization, span} = props;

Expand All @@ -27,6 +33,11 @@
}

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 @@
<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
11 changes: 8 additions & 3 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 @@ -355,10 +360,10 @@ function Sidebar() {
);

const resources = hasOrganization && (
<Feature key="resource" features="spans-first-ui">
<Feature key="assets" features="spans-first-ui">
DominikB2014 marked this conversation as resolved.
Show resolved Hide resolved
<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
21 changes: 20 additions & 1 deletion static/app/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ 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 {MODULE_BASE_URLS} from 'sentry/views/performance/utils/useModuleURL';
import {
MODULE_BASE_URLS,
PERFORMANCE_MODULE_BASE_URLS,
} from 'sentry/views/performance/utils/useModuleURL';
import ProjectEventRedirect from 'sentry/views/projectEventRedirect';
import redirectDeprecatedProjectRoute from 'sentry/views/projects/redirectDeprecatedProjectRoute';
import RouteNotFound from 'sentry/views/routeNotFound';
Expand Down Expand Up @@ -1505,6 +1508,22 @@ function buildRoutes() {
)}
/>
</Route>
<Route path={`${PERFORMANCE_MODULE_BASE_URLS[ModuleName.RESOURCE]}/`}>
<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>
Copy link
Contributor Author

@DominikB2014 DominikB2014 May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/browser/assets and /browser/resources will just route to the same component so we don't have to rely on the organization to setup routes

<Route path={`${MODULE_BASE_URLS[ModuleName.QUEUE]}/`}>
<IndexRoute
component={make(
Expand Down
13 changes: 10 additions & 3 deletions static/app/views/performance/browser/resources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import {
MODULE_DESCRIPTION,
MODULE_DOC_LINK,
MODULE_TITLE,
PERFORMANCE_MODULE_DESCRIPTION,
} from 'sentry/views/performance/browser/resources/settings';
import {
BrowserStarfishFields,
Expand All @@ -29,6 +29,8 @@
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 +39,11 @@

function ResourcesLandingPage() {
const filters = useResourceModuleFilters();
const organization = useOrganization();

Check failure on line 42 in static/app/views/performance/browser/resources/index.tsx

View workflow job for this annotation

GitHub Actions / typescript and lint

Cannot find name 'useOrganization'. Did you mean 'organization'?
const moduleTitle = useModuleTitle(ModuleName.RESOURCE);

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

return (
<React.Fragment>
Expand All @@ -48,10 +53,12 @@
<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 {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,

Check failure on line 24 in static/app/views/performance/browser/resources/resourceSummaryPage/index.tsx

View workflow job for this annotation

GitHub Actions / typescript and lint

Module '"sentry/views/performance/browser/resources/settings"' has no exported member '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 @@

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 @@

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 @@
crumbs={[
...crumbs,
{
label: 'Resource Summary',
label: tct('[dataType] Summary', {dataType: resourceDataType}),
},
]}
/>
Expand Down Expand Up @@ -148,10 +157,14 @@
}

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,

Check failure on line 10 in static/app/views/performance/browser/resources/resourceSummaryPage/resourceSummaryCharts.tsx

View workflow job for this annotation

GitHub Actions / typescript and lint

Module '"sentry/views/performance/browser/resources/settings"' has no exported member '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 @@

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 @@
</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 {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,

Check failure on line 19 in static/app/views/performance/browser/resources/resourceView/resourceTable.tsx

View workflow job for this annotation

GitHub Actions / typescript and lint

Module '"sentry/views/performance/browser/resources/settings"' has no exported member '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 @@

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 @@
});

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
13 changes: 10 additions & 3 deletions static/app/views/performance/browser/resources/settings.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
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 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.'
);
Comment on lines +10 to +15
Copy link
Contributor Author

@DominikB2014 DominikB2014 May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefixed with Performance so that once we move to insights, we just delete these and it all makes sense still. If we prefixed with insights, we would either have to live with it, or refactor this variable.


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/resources/'
);
expect(eventsMock).toHaveBeenCalledTimes(1);
expect(eventsMock).toHaveBeenNthCalledWith(
Expand Down
Loading
Loading