@@ -23,7 +23,6 @@ import type {Organization} from 'sentry/types/organization';
2323import type { Project } from 'sentry/types/project' ;
2424import { defined } from 'sentry/utils' ;
2525import { trackAnalytics } from 'sentry/utils/analytics' ;
26- import { browserHistory } from 'sentry/utils/browserHistory' ;
2726import { DiscoverQuery } from 'sentry/utils/discover/discoverQuery' ;
2827import type { EventView } from 'sentry/utils/discover/eventView' ;
2928import {
@@ -34,6 +33,8 @@ import {PerformanceEventViewProvider} from 'sentry/utils/performance/contexts/pe
3433import { normalizeUrl } from 'sentry/utils/url/normalizeUrl' ;
3534import { useDatePageFilterProps } from 'sentry/utils/useDatePageFilterProps' ;
3635import { useMaxPickableDays } from 'sentry/utils/useMaxPickableDays' ;
36+ import { useNavigate } from 'sentry/utils/useNavigate' ;
37+ import type { ReactRouter3Navigate } from 'sentry/utils/useNavigate' ;
3738import { useTransactionSummaryEAP } from 'sentry/views/performance/eap/useTransactionSummaryEAP' ;
3839import { TransactionSummaryContext } from 'sentry/views/performance/transactionSummary/transactionSummaryContext' ;
3940import {
@@ -97,6 +98,7 @@ export function PageLayout(props: Props) {
9798 }
9899
99100 const theme = useTheme ( ) ;
101+ const navigate = useNavigate ( ) ;
100102 const transactionName = getTransactionName ( location ) ;
101103 const [ error , setError ] = useState < string | undefined > ( ) ;
102104 const metricsCardinality = useMetricsCardinalityContext ( ) ;
@@ -175,15 +177,15 @@ export function PageLayout(props: Props) {
175177 } ) ;
176178 }
177179
178- browserHistory . push ( normalizeUrl ( getNewRoute ( newTab ) ) ) ;
180+ navigate ( normalizeUrl ( getNewRoute ( newTab ) ) ) ;
179181 } ,
180- [ getNewRoute , tab , organization , location , projects ]
182+ [ getNewRoute , tab , organization , location , projects , navigate ]
181183 ) ;
182184
183185 const shouldUseEAP = useTransactionSummaryEAP ( ) ;
184186
185187 if ( ! defined ( transactionName ) ) {
186- redirectToPerformanceHomepage ( organization , location ) ;
188+ redirectToPerformanceHomepage ( organization , location , navigate ) ;
187189 return null ;
188190 }
189191
@@ -222,7 +224,7 @@ export function PageLayout(props: Props) {
222224 { ( { isLoading, tableData, error : discoverQueryError } ) => {
223225 if ( discoverQueryError ) {
224226 addErrorMessage ( t ( 'Unable to get projects associated with transaction' ) ) ;
225- redirectToPerformanceHomepage ( organization , location ) ;
227+ redirectToPerformanceHomepage ( organization , location , navigate ) ;
226228 return null ;
227229 }
228230
@@ -369,15 +371,17 @@ const StyledBody = styled(Layout.Body)<{fillSpace?: boolean; hasError?: boolean}
369371
370372export function redirectToPerformanceHomepage (
371373 organization : Organization ,
372- location : Location
374+ location : Location ,
375+ navigate : ReactRouter3Navigate
373376) {
374377 // If there is no transaction name, redirect to the Performance landing page
375- browserHistory . replace (
378+ navigate (
376379 normalizeUrl ( {
377380 pathname : getPerformanceBaseUrl ( organization . slug , 'backend' ) ,
378381 query : {
379382 ...location . query ,
380383 } ,
381- } )
384+ } ) ,
385+ { replace : true }
382386 ) ;
383387}
0 commit comments