Skip to content

Commit 5dcbcc0

Browse files
committed
ref: SentryTrackingProvider
1 parent 742f7b1 commit 5dcbcc0

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

static/app/main.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import {useMemo, useState} from 'react';
1+
import {useState} from 'react';
22
import {createBrowserRouter, RouterProvider} from 'react-router-dom';
33
import {wrapCreateBrowserRouterV6} from '@sentry/react';
44
import {ReactQueryDevtools} from '@tanstack/react-query-devtools';
55

66
import {AppQueryClientProvider} from 'sentry/appQueryClient';
7-
import {TrackingContextProvider} from 'sentry/components/core/trackingContext';
87
import {OnboardingContextProvider} from 'sentry/components/onboarding/onboardingContext';
98
import {ThemeAndStyleProvider} from 'sentry/components/themeAndStyleProvider';
109
import {USE_REACT_QUERY_DEVTOOL} from 'sentry/constants';
1110
import {routes} from 'sentry/routes';
12-
import HookStore from 'sentry/stores/hookStore';
11+
import {SentryTrackingProvider} from 'sentry/tracking';
1312
import {DANGEROUS_SET_REACT_ROUTER_6_HISTORY} from 'sentry/utils/browserHistory';
1413

1514
import {buildReactRouter6Routes} from './utils/reactRouter6Compat/router';
@@ -24,16 +23,14 @@ function buildRouter() {
2423

2524
function Main() {
2625
const [router] = useState(buildRouter);
27-
const useButtonTracking = HookStore.get('react-hook:use-button-tracking')[0];
28-
const trackingContextValue = useMemo(() => ({useButtonTracking}), [useButtonTracking]);
2926

3027
return (
3128
<AppQueryClientProvider>
3229
<ThemeAndStyleProvider>
3330
<OnboardingContextProvider>
34-
<TrackingContextProvider value={trackingContextValue}>
31+
<SentryTrackingProvider>
3532
<RouterProvider router={router} />
36-
</TrackingContextProvider>
33+
</SentryTrackingProvider>
3734
</OnboardingContextProvider>
3835
{USE_REACT_QUERY_DEVTOOL && (
3936
<ReactQueryDevtools initialIsOpen={false} buttonPosition="bottom-left" />

static/app/tracking.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {useMemo} from 'react';
2+
3+
import {TrackingContextProvider} from 'sentry/components/core/trackingContext';
4+
import HookStore from 'sentry/stores/hookStore';
5+
6+
export function SentryTrackingProvider({children}: {children: React.ReactNode}) {
7+
const useButtonTracking = HookStore.get('react-hook:use-button-tracking')[0];
8+
const trackingContextValue = useMemo(() => ({useButtonTracking}), [useButtonTracking]);
9+
10+
return (
11+
<TrackingContextProvider value={trackingContextValue}>
12+
{children}
13+
</TrackingContextProvider>
14+
);
15+
}

0 commit comments

Comments
 (0)