diff --git a/static/app/utils/routeAnalytics/withRouteAnalytics.spec.tsx b/static/app/utils/routeAnalytics/withRouteAnalytics.spec.tsx deleted file mode 100644 index 9d9ea217528873..00000000000000 --- a/static/app/utils/routeAnalytics/withRouteAnalytics.spec.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import {useEffect} from 'react'; - -import {render} from 'sentry-test/reactTestingLibrary'; - -import {RouteAnalyticsContext} from 'sentry/views/routeAnalyticsContextProvider'; - -import withRouteAnalytics from './withRouteAnalytics'; - -function TestComponent({setRouteAnalyticsParams}: any) { - useEffect(() => { - setRouteAnalyticsParams({foo: 'bar'}); - }, [setRouteAnalyticsParams]); - return
hi
; -} - -const WrappedComponent = withRouteAnalytics(TestComponent); - -describe('withRouteAnalytics', () => { - it('passes context to children as props', () => { - const setRouteAnalyticsParams = jest.fn(); - render( - - - - ); - expect(setRouteAnalyticsParams).toHaveBeenCalledWith({foo: 'bar'}); - }); -}); diff --git a/static/app/utils/routeAnalytics/withRouteAnalytics.tsx b/static/app/utils/routeAnalytics/withRouteAnalytics.tsx deleted file mode 100644 index eb245260f5b1a5..00000000000000 --- a/static/app/utils/routeAnalytics/withRouteAnalytics.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import {useContext} from 'react'; - -import getDisplayName from 'sentry/utils/getDisplayName'; -import {RouteAnalyticsContext} from 'sentry/views/routeAnalyticsContextProvider'; - -type WithRouteAnalyticsProps = React.ContextType; - -type WrappedProps

= Omit & - Partial; - -const withRouteAnalytics =

( - WrappedComponent: React.ComponentType

-) => { - function ComponentWithRouteAnalytics(props: WrappedProps

) { - const routeAnalyticsContext = useContext(RouteAnalyticsContext); - // TODO(any): HoC prop types not working w/ emotion https://github.com/emotion-js/emotion/issues/3261 - return ; - } - ComponentWithRouteAnalytics.displayName = `withRouteAnalytics(${getDisplayName( - WrappedComponent - )})`; - return ComponentWithRouteAnalytics; -}; - -export default withRouteAnalytics; -export type {WithRouteAnalyticsProps}; diff --git a/static/gsApp/hooks/spendVisibility/enhancedUsageStatsOrganization.tsx b/static/gsApp/hooks/spendVisibility/enhancedUsageStatsOrganization.tsx index 1583be5a02ac91..1331708139c916 100644 --- a/static/gsApp/hooks/spendVisibility/enhancedUsageStatsOrganization.tsx +++ b/static/gsApp/hooks/spendVisibility/enhancedUsageStatsOrganization.tsx @@ -1,4 +1,4 @@ -import {Fragment, useEffect, useMemo} from 'react'; +import {Fragment, useMemo} from 'react'; import styled from '@emotion/styled'; import {getSeriesApiInterval} from 'sentry/components/charts/utils'; @@ -10,8 +10,7 @@ import type {DataCategoryInfo} from 'sentry/types/core'; import type {Project} from 'sentry/types/project'; import {defined} from 'sentry/utils'; import {useApiQuery} from 'sentry/utils/queryClient'; -import type {WithRouteAnalyticsProps} from 'sentry/utils/routeAnalytics/withRouteAnalytics'; -import withRouteAnalytics from 'sentry/utils/routeAnalytics/withRouteAnalytics'; +import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams'; import {useNavigate} from 'sentry/utils/useNavigate'; import withProjects from 'sentry/utils/withProjects'; import type {UsageSeries} from 'sentry/views/organizationStats/types'; @@ -204,9 +203,7 @@ function getSpikeDetails({ return actualSpikes; } -interface EnhancedUsageStatsOrganizationProps - extends WithRouteAnalyticsProps, - UsageStatsOrganizationProps { +interface EnhancedUsageStatsOrganizationProps extends UsageStatsOrganizationProps { isSingleProject: boolean; projects: Project[]; subscription: Subscription; @@ -229,7 +226,6 @@ function EnhancedUsageStatsOrganization({ dataCategory, dataCategoryName, dataCategoryApiName, - setRouteAnalyticsParams, isSingleProject, spikeCursor, clientDiscard, @@ -305,20 +301,12 @@ function EnhancedUsageStatsOrganization({ {staleTime: Infinity, retry: false, enabled: spikeThresholdsQueryEnabled} ); - useEffect(() => { - setRouteAnalyticsParams({ - subscription, - organization, - is_project_stats: isSingleProject, - has_spike_data: isSingleProject && hasAccurateSpikes, - }); - }, [ - hasAccurateSpikes, - isSingleProject, - organization, - setRouteAnalyticsParams, + useRouteAnalyticsParams({ subscription, - ]); + organization, + is_project_stats: isSingleProject, + has_spike_data: isSingleProject && hasAccurateSpikes, + }); const newEndpointQuery = useMemo(() => { const query = endpointQuery; @@ -496,6 +484,4 @@ const DroppedFromSpikesStat = styled('div')` font-size: ${p => p.theme.fontSize.md}; `; -export default withRouteAnalytics( - withProjects(withSubscription(EnhancedUsageStatsOrganization)) -); +export default withProjects(withSubscription(EnhancedUsageStatsOrganization));