diff --git a/apps/viewer/src/components/Seo.tsx b/apps/viewer/src/components/Seo.tsx index 6594abd78..bf74d3219 100644 --- a/apps/viewer/src/components/Seo.tsx +++ b/apps/viewer/src/components/Seo.tsx @@ -1,9 +1,8 @@ import { gtmHeadSnippet } from '@/lib/google-tag-manager' -import { Metadata } from '@typebot.io/schemas' import Head from 'next/head' import Script from 'next/script' -import React from 'react' import { isNotEmpty } from '@typebot.io/lib' +import { Metadata } from '@typebot.io/schemas/features/typebot/settings' type SEOProps = { url: string diff --git a/apps/viewer/src/components/TypebotPageV3.tsx b/apps/viewer/src/components/TypebotPageV3.tsx index 520c58f43..105fb5d45 100644 --- a/apps/viewer/src/components/TypebotPageV3.tsx +++ b/apps/viewer/src/components/TypebotPageV3.tsx @@ -1,7 +1,8 @@ import { Standard } from '@typebot.io/nextjs' -import { BackgroundType, Typebot } from '@typebot.io/schemas' import { useRouter } from 'next/router' import { SEO } from './Seo' +import { Typebot } from '@typebot.io/schemas/features/typebot/typebot' +import { BackgroundType } from '@typebot.io/schemas/features/typebot/theme/enums' export type TypebotV3PageProps = { url: string diff --git a/packages/env/env.ts b/packages/env/env.ts index f719352d8..3881ba72b 100644 --- a/packages/env/env.ts +++ b/packages/env/env.ts @@ -1,7 +1,11 @@ import { createEnv } from '@t3-oss/env-nextjs' -import { z } from 'zod' +import { ZodError, z } from 'zod' import { getRuntimeVariable } from './getRuntimeVariable' +declare const window: { + __ENV?: any +} + const boolean = z.enum(['true', 'false']).transform((value) => value === 'true') const baseEnv = { @@ -313,6 +317,21 @@ export const env = createEnv({ ...sentryEnv.runtimeEnv, ...posthogEnv.runtimeEnv, }, + onValidationError: (error: ZodError) => { + console.log( + '[DEBUG]', + "typeof window !== 'undefined'", + typeof window !== 'undefined' + ) + if (typeof window !== 'undefined') { + console.log('[DEBUG]', 'window.__ENV', window.__ENV) + } + console.error( + '❌ Invalid environment variables:', + error.flatten().fieldErrors + ) + throw new Error('Invalid environment variables') + }, onInvalidAccess: (variable: string) => { throw new Error( `❌ Attempted to access a server-side environment variable on the client: ${variable}`