Skip to content

feat(releases): Use routing for charts inside of Releases Drawer #88864

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

14 changes: 11 additions & 3 deletions static/app/utils/useReleaseStats.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useEffect} from 'react';
import {useEffect, useMemo} from 'react';

import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
import {useInfiniteApiQuery} from 'sentry/utils/queryClient';
Expand Down Expand Up @@ -27,7 +27,10 @@ interface UseReleaseStatsParams {
*/
export function useReleaseStats(
{datetime, environments, projects, maxPages = 10}: UseReleaseStatsParams,
queryOptions: {staleTime: number} = {staleTime: Infinity}
queryOptions: {enabled?: boolean; staleTime?: number} = {
staleTime: Infinity,
enabled: true,
}
) {
const organization = useOrganization();

Expand Down Expand Up @@ -62,11 +65,16 @@ export function useReleaseStats(
}
}, [isFetching, hasNextPage, fetchNextPage, maxPages, currentNumberPages]);

const releases = useMemo(
() => data?.pages.flatMap(([pageData]) => pageData) ?? [],
[data]
);

return {
isLoading,
isPending,
isError,
error,
releases: data?.pages.flatMap(([pageData]) => pageData),
releases,
};
}
17 changes: 10 additions & 7 deletions static/app/views/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import type {InstallWizardProps} from 'sentry/views/admin/installWizard';
import {AsyncSDKIntegrationContextProvider} from 'sentry/views/app/asyncSDKIntegrationProvider';
import LastKnownRouteContextProvider from 'sentry/views/lastKnownRouteContextProvider';
import {OrganizationContextProvider} from 'sentry/views/organizationContext';
import {ReleasesDrawerProvider} from 'sentry/views/releases/drawer/releasesDrawerContext';
import RouteAnalyticsContextProvider from 'sentry/views/routeAnalyticsContextProvider';

type Props = {
Expand Down Expand Up @@ -257,13 +258,15 @@ function App({children, params}: Props) {
{renderOrganizationContextProvider(
<AsyncSDKIntegrationContextProvider>
<GlobalFeedbackForm>
<GlobalDrawer>
<MainContainer tabIndex={-1} ref={mainContainerRef}>
<GlobalModal onClose={handleModalClose} />
<Indicators className="indicators-container" />
<ErrorBoundary>{renderBody()}</ErrorBoundary>
</MainContainer>
</GlobalDrawer>
<ReleasesDrawerProvider>
<GlobalDrawer>
<MainContainer tabIndex={-1} ref={mainContainerRef}>
<GlobalModal onClose={handleModalClose} />
<Indicators className="indicators-container" />
<ErrorBoundary>{renderBody()}</ErrorBoundary>
</MainContainer>
</GlobalDrawer>
</ReleasesDrawerProvider>
</GlobalFeedbackForm>
</AsyncSDKIntegrationContextProvider>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useCallback, useRef} from 'react';
import {useCallback, useMemo, useRef} from 'react';
import {useNavigate} from 'react-router-dom';
import {useTheme} from '@emotion/react';
import styled from '@emotion/styled';
Expand Down Expand Up @@ -31,6 +31,7 @@ import type {AggregationOutputType} from 'sentry/utils/discover/fields';
import {type Range, RangeMap} from 'sentry/utils/number/rangeMap';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import type {ChartRendererProps} from 'sentry/views/releases/releaseBubbles/types';
import {useReleaseBubbles} from 'sentry/views/releases/releaseBubbles/useReleaseBubbles';
import {makeReleasesPathname} from 'sentry/views/releases/utils/pathnames';

Expand All @@ -49,6 +50,8 @@ import {TimeSeriesWidgetYAxis} from './timeSeriesWidgetYAxis';
const {error, warn, info} = Sentry.logger;

export interface TimeSeriesWidgetVisualizationProps {
chartId: string;

/**
* An array of `Plottable` objects. This can be any object that implements the `Plottable` interface.
*/
Expand Down Expand Up @@ -124,29 +127,33 @@ export function TimeSeriesWidgetVisualization(props: TimeSeriesWidgetVisualizati
const earliestTimeStamp = allBoundaries.at(0);
const latestTimeStamp = allBoundaries.at(-1);

const chartRenderer = useMemo(
() =>
function ({ref: chartRendererRef}: ChartRendererProps) {
return (
<DrawerWidgetWrapper>
<TimeSeriesWidgetVisualization
{...props}
ref={chartRendererRef}
disableReleaseNavigation
onZoom={() => {}}
showReleaseAs="line"
/>
</DrawerWidgetWrapper>
);
},
[props]
);

const {
connectReleaseBubbleChartRef,
releaseBubbleEventHandlers,
releaseBubbleSeries,
releaseBubbleXAxis,
releaseBubbleGrid,
} = useReleaseBubbles({
chartRenderer: ({start: trimStart, end: trimEnd, ref: chartRendererRef}) => {
return (
<DrawerWidgetWrapper>
<TimeSeriesWidgetVisualization
{...props}
ref={chartRendererRef}
disableReleaseNavigation
onZoom={() => {}}
plottables={props.plottables.map(plottable =>
plottable.constrain(trimStart, trimEnd)
)}
showReleaseAs="line"
/>
</DrawerWidgetWrapper>
);
},
chartId: props.chartId,
chartRenderer,
minTime: earliestTimeStamp ? new Date(earliestTimeStamp).getTime() : undefined,
maxTime: latestTimeStamp ? new Date(latestTimeStamp).getTime() : undefined,
releases: hasReleaseBubbles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type {DiscoverSeries} from '../queries/useDiscoverSeries';
import {convertSeriesToTimeseries} from '../utils/convertSeriesToTimeseries';

export interface InsightsTimeSeriesWidgetProps extends WidgetTitleProps {
chartId: string;
error: Error | null;
isLoading: boolean;
series: DiscoverSeries[];
Expand All @@ -59,6 +60,7 @@ export function InsightsTimeSeriesWidget(props: InsightsTimeSeriesWidgetProps) {
})) ?? [];

const visualizationProps: TimeSeriesWidgetVisualizationProps = {
chartId: props.chartId,
plottables: (props.series.filter(Boolean) ?? [])?.map(serie => {
const timeSeries = convertSeriesToTimeseries(serie);
const PlottableDataConstructor =
Expand Down
3 changes: 3 additions & 0 deletions static/app/views/insights/http/views/httpLandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export function HTTPLandingPage() {
<ModulesOnboarding moduleName={ModuleName.HTTP}>
<ModuleLayout.Third>
<InsightsLineChartWidget
chartId={Referrer.LANDING_THROUGHPUT_CHART}
title={getThroughputChartTitle('http')}
series={[throughputData['epm()']]}
isLoading={isThroughputDataLoading}
Expand All @@ -192,6 +193,7 @@ export function HTTPLandingPage() {

<ModuleLayout.Third>
<InsightsLineChartWidget
chartId={Referrer.LANDING_DURATION_CHART}
title={getDurationChartTitle('http')}
series={[durationData['avg(span.self_time)']]}
isLoading={isDurationDataLoading}
Expand All @@ -201,6 +203,7 @@ export function HTTPLandingPage() {

<ModuleLayout.Third>
<InsightsLineChartWidget
chartId={Referrer.LANDING_RESPONSE_CODE_CHART}
title={DataTitles.unsuccessfulHTTPCodes}
series={[
responseCodeData[`http_response_rate(3)`],
Expand Down
50 changes: 24 additions & 26 deletions static/app/views/issueDetails/streamline/eventGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,15 @@ export function EventGraph({
}
);

const {releases = []} = useReleaseStats(
{
projects: eventView.project,
environments: eventView.environment,
datetime: {
start: eventView.start,
end: eventView.end,
period: eventView.statsPeriod,
},
const {releases} = useReleaseStats({
projects: eventView.project,
environments: eventView.environment,
datetime: {
start: eventView.start,
end: eventView.end,
period: eventView.statsPeriod,
},
{
staleTime: 0,
}
);
});

const releaseSeries = useReleaseMarkLineSeries({
group,
Expand All @@ -270,26 +265,29 @@ export function EventGraph({
penultEventSeriesTimestamp &&
lastEventSeriesTimestamp - penultEventSeriesTimestamp;

const chartRenderer = useCallback(
() => (
<EventGraph
group={group}
event={event}
showSummary={false}
showReleasesAs="line"
disableZoomNavigation
{...styleProps}
/>
),
[group, event, styleProps]
);

const {
connectReleaseBubbleChartRef,
releaseBubbleEventHandlers,
releaseBubbleSeries,
releaseBubbleXAxis,
releaseBubbleGrid,
} = useReleaseBubbles({
chartRenderer: ({ref: chartRef}) => {
return (
<EventGraph
ref={chartRef}
group={group}
event={event}
showSummary={false}
showReleasesAs="line"
disableZoomNavigation
{...styleProps}
/>
);
},
chartId: 'issue-details-event-graph',
chartRenderer,
alignInMiddle: true,
legendSelected: legendSelected.Releases,
desiredBuckets: eventSeries.length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import ProjectIcon from 'sentry/views/nav/projectIcon';
import {SecondaryNav} from 'sentry/views/nav/secondary/secondary';
import {PrimaryNavGroup} from 'sentry/views/nav/types';
import {isLinkActive} from 'sentry/views/nav/utils';
import {useReleasesDrawer} from 'sentry/views/releases/drawer/useReleasesDrawer';

import {MODULE_BASE_URLS} from '../../../../insights/common/utils/useModuleURL';
import {ModuleName} from '../../../../insights/types';
Expand All @@ -42,6 +43,7 @@ export function InsightsSecondaryNav() {
const location = useLocation();
const baseUrl = `/organizations/${organization.slug}/${DOMAIN_VIEW_BASE_URL}`;
const [isLaravelInsightsEnabled] = useIsLaravelInsightsEnabled();
useReleasesDrawer();

const {projects} = useProjects();

Expand Down
Loading
Loading