2
0

Attempt to fix tolgee random crash due to provider not detected

This commit is contained in:
Baptiste Arnaud
2023-12-29 10:12:13 +01:00
parent 81a70d3b70
commit a235a7accd
11 changed files with 36 additions and 33 deletions

View File

@@ -31,8 +31,8 @@
"@sentry/nextjs": "7.77.0", "@sentry/nextjs": "7.77.0",
"@tanstack/react-query": "4.29.19", "@tanstack/react-query": "4.29.19",
"@tanstack/react-table": "8.9.3", "@tanstack/react-table": "8.9.3",
"@tolgee/format-icu": "5.13.3", "@tolgee/format-icu": "5.19.0",
"@tolgee/react": "5.13.3", "@tolgee/react": "5.19.0",
"@trpc/client": "10.40.0", "@trpc/client": "10.40.0",
"@trpc/next": "10.40.0", "@trpc/next": "10.40.0",
"@trpc/react-query": "10.40.0", "@trpc/react-query": "10.40.0",

View File

@@ -1,12 +1,12 @@
import { DevTools, Tolgee } from '@tolgee/react' import { DevTools, Tolgee } from '@tolgee/react'
import { FormatIcu } from '@tolgee/format-icu' import { FormatIcu } from '@tolgee/format-icu'
import en from '../../public/locales/en.json' import en from '../i18n/en.json'
import fr from '../../public/locales/fr.json' import fr from '../i18n/fr.json'
import de from '../../public/locales/de.json' import de from '../i18n/de.json'
import pt from '../../public/locales/pt.json' import pt from '../i18n/pt.json'
import ptBR from '../../public/locales/pt-BR.json' import ptBR from '../i18n/pt-BR.json'
import es from '../../public/locales/es.json' import es from '../i18n/es.json'
import ro from '../../public/locales/ro.json' import ro from '../i18n/ro.json'
import { env } from '@typebot.io/env' import { env } from '@typebot.io/env'
export const tolgee = Tolgee() export const tolgee = Tolgee()

View File

@@ -28,22 +28,26 @@ initPostHogIfEnabled()
const { ToastContainer, toast } = createStandaloneToast(customTheme) const { ToastContainer, toast } = createStandaloneToast(customTheme)
const App = ({ Component, pageProps }: AppProps) => { const App = ({ Component, pageProps }: AppProps) => {
const router = useRouter()
const ssrTolgee = useTolgeeSSR(tolgee, router.locale)
useRouterProgressBar() useRouterProgressBar()
const { query, pathname, locale } = useRouter()
const ssrTolgee = useTolgeeSSR(tolgee, locale)
useEffect(() => { useEffect(() => {
if (pathname.endsWith('/edit') || pathname.endsWith('/analytics')) { if (
router.pathname.endsWith('/edit') ||
router.pathname.endsWith('/analytics')
) {
document.body.style.overflow = 'hidden' document.body.style.overflow = 'hidden'
document.body.classList.add('disable-scroll-x-behavior') document.body.classList.add('disable-scroll-x-behavior')
} else { } else {
document.body.style.overflow = 'auto' document.body.style.overflow = 'auto'
document.body.classList.remove('disable-scroll-x-behavior') document.body.classList.remove('disable-scroll-x-behavior')
} }
}, [pathname]) }, [router.pathname])
useEffect(() => { useEffect(() => {
const newPlan = query.stripe?.toString() const newPlan = router.query.stripe?.toString()
if (newPlan === Plan.STARTER || newPlan === Plan.PRO) if (newPlan === Plan.STARTER || newPlan === Plan.PRO)
toast({ toast({
position: 'top-right', position: 'top-right',
@@ -51,9 +55,9 @@ const App = ({ Component, pageProps }: AppProps) => {
title: 'Upgrade success!', title: 'Upgrade success!',
description: `Workspace upgraded to ${toTitleCase(newPlan)} 🎉`, description: `Workspace upgraded to ${toTitleCase(newPlan)} 🎉`,
}) })
}, [query.stripe]) }, [router.query.stripe])
const typebotId = query.typebotId?.toString() const typebotId = router.query.typebotId?.toString()
return ( return (
<> <>
@@ -65,9 +69,8 @@ const App = ({ Component, pageProps }: AppProps) => {
<TypebotProvider typebotId={typebotId}> <TypebotProvider typebotId={typebotId}>
<WorkspaceProvider typebotId={typebotId}> <WorkspaceProvider typebotId={typebotId}>
<Component {...pageProps} /> <Component {...pageProps} />
{!pathname.endsWith('edit') && isCloudProdInstance() && ( {!router.pathname.endsWith('edit') &&
<SupportBubble /> isCloudProdInstance() && <SupportBubble />}
)}
<NewVersionPopup /> <NewVersionPopup />
</WorkspaceProvider> </WorkspaceProvider>
</TypebotProvider> </TypebotProvider>

28
pnpm-lock.yaml generated
View File

@@ -87,11 +87,11 @@ importers:
specifier: 8.9.3 specifier: 8.9.3
version: 8.9.3(react-dom@18.2.0)(react@18.2.0) version: 8.9.3(react-dom@18.2.0)(react@18.2.0)
'@tolgee/format-icu': '@tolgee/format-icu':
specifier: 5.13.3 specifier: 5.19.0
version: 5.13.3 version: 5.19.0
'@tolgee/react': '@tolgee/react':
specifier: 5.13.3 specifier: 5.19.0
version: 5.13.3(react@18.2.0) version: 5.19.0(react@18.2.0)
'@trpc/client': '@trpc/client':
specifier: 10.40.0 specifier: 10.40.0
version: 10.40.0(@trpc/server@10.40.0) version: 10.40.0(@trpc/server@10.40.0)
@@ -7563,27 +7563,27 @@ packages:
- typescript - typescript
dev: true dev: true
/@tolgee/core@5.13.3: /@tolgee/core@5.19.0:
resolution: {integrity: sha512-w6O+HVMOci6zqUPjuvY+o1aNfKxEMaHvKn6Px5aELAhhM0McNxVfHdfGMaTsfYvcQT/1UfjIqctLtTOqKaylsw==} resolution: {integrity: sha512-5zOkxjtxUBEC8xTWtYU5r6bvwHK80s95zH4Y4uLkTcIYTRvn4kY7Z5/Hg5/hyIApA6P8taOrNy/m5favxCmREQ==}
dev: false dev: false
/@tolgee/format-icu@5.13.3: /@tolgee/format-icu@5.19.0:
resolution: {integrity: sha512-TyyeHRskPhVCcaZ1Ns/JKR7scy2AIOYVt+uOZ3wHn9FXN67F1+9Xgf/WnYB6+F47l7Cp719kWnB+uovIoIZNeg==} resolution: {integrity: sha512-hV8MJEFrN90nAWNWHsz7RZy7S/23cIuETZ3exKGlu7m397BTtqT/52eE3bh4lcAeKwvhfF+v/hWT+vZrkNxmwA==}
dev: false dev: false
/@tolgee/react@5.13.3(react@18.2.0): /@tolgee/react@5.19.0(react@18.2.0):
resolution: {integrity: sha512-zWbQZDsdU0GYqCDVq7YASLiMQkMpMvumjOIcucCHk8VS6EIBxAJq/cSelT+3iUXVNtgGHEe+GGZp1MGune67gA==} resolution: {integrity: sha512-FYQyymza7NQ/aqPZqpm/7ErHI7T8QeptbjKDSekomaN6nxifumSzYpuvjhBX+y2o/z1HGdqWZR9sc1IJU0VAwQ==}
peerDependencies: peerDependencies:
react: ^16.14.0 || ^17.0.1 || ^18.1.0 react: ^16.14.0 || ^17.0.1 || ^18.1.0
dependencies: dependencies:
'@tolgee/web': 5.13.3 '@tolgee/web': 5.19.0
react: 18.2.0 react: 18.2.0
dev: false dev: false
/@tolgee/web@5.13.3: /@tolgee/web@5.19.0:
resolution: {integrity: sha512-CwOyRQl+V21QhGFNWPmSV8L7cIhxsOeU5ivLyO6YXV9LWnTXNxHlS5apDzfXR2RCGbwHHYAsii7bghXn77pNhA==} resolution: {integrity: sha512-a57howuvHz6KGDg8wu6K1KxuBlTUD/AV0+1UKj+2xiFECNQSqwP8/bGO+9Hb9xkNqVxx+l1R13xK9XSZMGXNhw==}
dependencies: dependencies:
'@tolgee/core': 5.13.3 '@tolgee/core': 5.19.0
dev: false dev: false
/@tootallnate/once@2.0.0: /@tootallnate/once@2.0.0: