Skip to content

Commit

Permalink
refactor: move plausible context on top of feedback (#5824)
Browse files Browse the repository at this point in the history
We were unable to send plausible events from feedback. Now we can.
  • Loading branch information
sjaanus authored Jan 10, 2024
1 parent 17fe264 commit d770f62
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 79 deletions.
123 changes: 55 additions & 68 deletions frontend/src/component/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Loader from 'component/common/Loader/Loader';
import NotFound from 'component/common/NotFound/NotFound';
import { ProtectedRoute } from 'component/common/ProtectedRoute/ProtectedRoute';
import { SWRProvider } from 'component/providers/SWRProvider/SWRProvider';
import { PlausibleProvider } from 'component/providers/PlausibleProvider/PlausibleProvider';
import ToastRenderer from 'component/common/ToastRenderer/ToastRenderer';
import { routes } from 'component/menu/routes';
import { useAuthDetails } from 'hooks/api/getters/useAuth/useAuthDetails';
Expand Down Expand Up @@ -52,76 +51,64 @@ export const App = () => {

return (
<ErrorBoundary FallbackComponent={LayoutError}>
<PlausibleProvider>
<ErrorBoundary FallbackComponent={LayoutError}>
<SWRProvider>
<Suspense fallback={<Loader />}>
<ConditionallyRender
condition={!hasFetchedAuth}
show={<Loader />}
elseShow={
<Demo>
<>
<ConditionallyRender
condition={Boolean(
uiConfig?.maintenanceMode,
)}
show={<MaintenanceBanner />}
/>
<LicenseBanner />
<ExternalBanners />
<InternalBanners />
<StyledContainer>
<ToastRenderer />
<Routes>
{availableRoutes.map(
(route) => (
<Route
key={route.path}
path={
route.path
}
element={
<LayoutPicker
isStandalone={
route.isStandalone ===
true
}
>
<ProtectedRoute
route={
route
}
/>
</LayoutPicker>
}
<SWRProvider>
<Suspense fallback={<Loader />}>
<ConditionallyRender
condition={!hasFetchedAuth}
show={<Loader />}
elseShow={
<Demo>
<>
<ConditionallyRender
condition={Boolean(
uiConfig?.maintenanceMode,
)}
show={<MaintenanceBanner />}
/>
<LicenseBanner />
<ExternalBanners />
<InternalBanners />
<StyledContainer>
<ToastRenderer />
<Routes>
{availableRoutes.map((route) => (
<Route
key={route.path}
path={route.path}
element={
<LayoutPicker
isStandalone={
route.isStandalone ===
true
}
>
<ProtectedRoute
route={route}
/>
),
)}
<Route
path='/'
element={
<InitialRedirect />
}
/>
<Route
path='*'
element={<NotFound />}
/>
</Routes>
</LayoutPicker>
}
/>
))}
<Route
path='/'
element={<InitialRedirect />}
/>
<Route
path='*'
element={<NotFound />}
/>
</Routes>

<FeedbackNPS openUrl='http://feedback.unleash.run' />
<FeedbackNPS openUrl='http://feedback.unleash.run' />

<SplashPageRedirect />
</StyledContainer>
</>
</Demo>
}
/>
</Suspense>
</SWRProvider>
</ErrorBoundary>
</PlausibleProvider>
<SplashPageRedirect />
</StyledContainer>
</>
</Demo>
}
/>
</Suspense>
</SWRProvider>
</ErrorBoundary>
);
};
29 changes: 18 additions & 11 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { AnnouncerProvider } from 'component/common/Announcer/AnnouncerProvider/
import { InstanceStatus } from 'component/common/InstanceStatus/InstanceStatus';
import { UIProviderContainer } from 'component/providers/UIProvider/UIProviderContainer';
import { StickyProvider } from 'component/common/Sticky/StickyProvider';
import { FeedbackProvider } from './component/feedbackNew/FeedbackProvider';
import { FeedbackProvider } from 'component/feedbackNew/FeedbackProvider';
import { PlausibleProvider } from 'component/providers/PlausibleProvider/PlausibleProvider';
import { Error as LayoutError } from './component/layout/Error/Error';
import { ErrorBoundary } from 'react-error-boundary';

window.global ||= window;

Expand All @@ -27,16 +30,20 @@ ReactDOM.render(
<QueryParamProvider adapter={ReactRouter6Adapter}>
<ThemeProvider>
<AnnouncerProvider>
<FeedbackProvider>
<FeedbackCESProvider>
<StickyProvider>
<InstanceStatus>
<ScrollTop />
<App />
</InstanceStatus>
</StickyProvider>
</FeedbackCESProvider>
</FeedbackProvider>
<ErrorBoundary FallbackComponent={LayoutError}>
<PlausibleProvider>
<FeedbackProvider>
<FeedbackCESProvider>
<StickyProvider>
<InstanceStatus>
<ScrollTop />
<App />
</InstanceStatus>
</StickyProvider>
</FeedbackCESProvider>
</FeedbackProvider>
</PlausibleProvider>
</ErrorBoundary>
</AnnouncerProvider>
</ThemeProvider>
</QueryParamProvider>
Expand Down

0 comments on commit d770f62

Please sign in to comment.