2
0

🚸 Skip validation if __ENV.js file does not exist

This commit is contained in:
Baptiste Arnaud
2023-08-31 09:57:54 +02:00
parent 9d29a88ed3
commit dfcfdf2138
9 changed files with 61 additions and 99 deletions

View File

@ -26,7 +26,7 @@
"@giphy/react-components": "7.1.0", "@giphy/react-components": "7.1.0",
"@googleapis/drive": "8.0.0", "@googleapis/drive": "8.0.0",
"@paralleldrive/cuid2": "2.2.1", "@paralleldrive/cuid2": "2.2.1",
"@sentry/nextjs": "7.58.1", "@sentry/nextjs": "7.66.0",
"@stripe/stripe-js": "1.54.1", "@stripe/stripe-js": "1.54.1",
"@t3-oss/env-nextjs": "^0.6.0", "@t3-oss/env-nextjs": "^0.6.0",
"@tanstack/react-query": "^4.29.19", "@tanstack/react-query": "^4.29.19",

View File

@ -9,16 +9,4 @@ Sentry.init({
"Can't find variable: ResizeObserver", "Can't find variable: ResizeObserver",
], ],
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-builder', release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-builder',
beforeBreadcrumb(breadcrumb, hint) {
try {
if (breadcrumb.category.startsWith('ui')) {
breadcrumb.message = `${hint.event.target.tagName.toLowerCase()}: ${
hint.event.target.innerText
}`
}
} catch (e) {
/* empty */
}
return breadcrumb
},
}) })

View File

@ -108,6 +108,7 @@ export const IconPicker = ({ onIconSelected }: Props) => {
placeholder="Search..." placeholder="Search..."
onChange={searchIcon} onChange={searchIcon}
withVariableButton={false} withVariableButton={false}
debounceTimeout={300}
/> />
<ColorPicker value={selectedColor} onColorChange={updateColor} /> <ColorPicker value={selectedColor} onColorChange={updateColor} />
</HStack> </HStack>

View File

@ -12,7 +12,7 @@
}, },
"dependencies": { "dependencies": {
"@planetscale/database": "^1.8.0", "@planetscale/database": "^1.8.0",
"@sentry/nextjs": "7.58.1", "@sentry/nextjs": "7.66.0",
"@trpc/server": "10.34.0", "@trpc/server": "10.34.0",
"@typebot.io/nextjs": "workspace:*", "@typebot.io/nextjs": "workspace:*",
"@typebot.io/prisma": "workspace:*", "@typebot.io/prisma": "workspace:*",

View File

@ -9,16 +9,4 @@ Sentry.init({
"Can't find variable: ResizeObserver", "Can't find variable: ResizeObserver",
], ],
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-viewer', release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-viewer',
beforeBreadcrumb(breadcrumb, hint) {
try {
if (breadcrumb.category.startsWith('ui')) {
breadcrumb.message = `${hint.event.target.tagName.toLowerCase()}: ${
hint.event.target.innerText
}`
}
} catch (e) {
/* empty */
}
return breadcrumb
},
}) })

View File

@ -11,7 +11,7 @@ export const executeScript = async ({ content, args }: ScriptToExecute) => {
) )
await func(...args.map((arg) => arg.value)) await func(...args.map((arg) => arg.value))
} catch (err) { } catch (err) {
console.error(err) console.warn('Script threw an error:', err)
} }
} }

18
packages/env/env.ts vendored
View File

@ -1,5 +1,5 @@
import { createEnv } from '@t3-oss/env-nextjs' import { createEnv } from '@t3-oss/env-nextjs'
import { ZodError, z } from 'zod' import { z } from 'zod'
import { getRuntimeVariable } from './getRuntimeVariable' import { getRuntimeVariable } from './getRuntimeVariable'
declare const window: { declare const window: {
@ -317,21 +317,7 @@ export const env = createEnv({
...sentryEnv.runtimeEnv, ...sentryEnv.runtimeEnv,
...posthogEnv.runtimeEnv, ...posthogEnv.runtimeEnv,
}, },
onValidationError: (error: ZodError) => { skipValidation: typeof window !== 'undefined' && window.__ENV === undefined,
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) => { onInvalidAccess: (variable: string) => {
throw new Error( throw new Error(
`❌ Attempted to access a server-side environment variable on the client: ${variable}` `❌ Attempted to access a server-side environment variable on the client: ${variable}`

View File

@ -2,10 +2,9 @@ declare const window: {
__ENV?: any __ENV?: any
} }
const isBrowser = () => Boolean(typeof window !== 'undefined' && window.__ENV)
export const getRuntimeVariable = (key: string) => { export const getRuntimeVariable = (key: string) => {
if (isBrowser()) return window.__ENV[key] if (typeof window !== 'undefined')
return window.__ENV ? window.__ENV[key] : undefined
if (typeof process === 'undefined') return undefined if (typeof process === 'undefined') return undefined
return process.env[key] return process.env[key]
} }

106
pnpm-lock.yaml generated
View File

@ -72,8 +72,8 @@ importers:
specifier: 2.2.1 specifier: 2.2.1
version: 2.2.1 version: 2.2.1
'@sentry/nextjs': '@sentry/nextjs':
specifier: 7.58.1 specifier: 7.66.0
version: 7.58.1(next@13.4.3)(react@18.2.0) version: 7.66.0(next@13.4.3)(react@18.2.0)
'@stripe/stripe-js': '@stripe/stripe-js':
specifier: 1.54.1 specifier: 1.54.1
version: 1.54.1 version: 1.54.1
@ -519,8 +519,8 @@ importers:
specifier: ^1.8.0 specifier: ^1.8.0
version: 1.8.0 version: 1.8.0
'@sentry/nextjs': '@sentry/nextjs':
specifier: 7.58.1 specifier: 7.66.0
version: 7.58.1(next@13.4.3)(react@18.2.0) version: 7.66.0(next@13.4.3)(react@18.2.0)
'@trpc/server': '@trpc/server':
specifier: 10.34.0 specifier: 10.34.0
version: 10.34.0 version: 10.34.0
@ -7822,25 +7822,25 @@ packages:
resolution: {integrity: sha512-0xd7qez0AQ+MbHatZTlI1gu5vkG8r7MYRUJAHPAHJBmGLs16zpkrpAVLvjQKQOqaXPDUBwOiJzNc00znHSCVBw==} resolution: {integrity: sha512-0xd7qez0AQ+MbHatZTlI1gu5vkG8r7MYRUJAHPAHJBmGLs16zpkrpAVLvjQKQOqaXPDUBwOiJzNc00znHSCVBw==}
dev: false dev: false
/@sentry-internal/tracing@7.58.1: /@sentry-internal/tracing@7.66.0:
resolution: {integrity: sha512-kOWKqyjYdDgvO6CacXneE9UrFQHT3BXF1UpCAlnHchW/TqRFmg89sJAEUjEPGzN7y6IaX1G4j2dBPDE0OFQi3w==} resolution: {integrity: sha512-3vCgC2hC3T45pn53yTDVcRpHoJTBxelDPPZVsipAbZnoOVPkj7n6dNfDhj3I3kwWCBPahPkXmE+R4xViR8VqJg==}
engines: {node: '>=8'} engines: {node: '>=8'}
dependencies: dependencies:
'@sentry/core': 7.58.1 '@sentry/core': 7.66.0
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
tslib: 2.6.0 tslib: 2.6.0
dev: false dev: false
/@sentry/browser@7.58.1: /@sentry/browser@7.66.0:
resolution: {integrity: sha512-7+6Z/T7m0A/2/ImMCakpMOaWTPxmENzTdaojhkyVQKuYUZr7mCe4nco0jsongwY634zSUziuVsibi0jxMMTdBA==} resolution: {integrity: sha512-rW037rf8jkhyykG38+HUdwkRCKHJEMM5NkCqPIO5zuuxfLKukKdI2rbvgJ93s3/9UfsTuDFcKFL1u43mCn6sDw==}
engines: {node: '>=8'} engines: {node: '>=8'}
dependencies: dependencies:
'@sentry-internal/tracing': 7.58.1 '@sentry-internal/tracing': 7.66.0
'@sentry/core': 7.58.1 '@sentry/core': 7.66.0
'@sentry/replay': 7.58.1 '@sentry/replay': 7.66.0
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
tslib: 2.6.0 tslib: 2.6.0
dev: false dev: false
@ -7861,27 +7861,27 @@ packages:
- supports-color - supports-color
dev: false dev: false
/@sentry/core@7.58.1: /@sentry/core@7.66.0:
resolution: {integrity: sha512-hpeB5fZ5T6Jg1CBqz486jHgWuJ5R/HD0wyYX+S3LDDsHCJo6V3TxNuoxYDlTTerRRfZdTwr9GYJXskehpU26IA==} resolution: {integrity: sha512-WMAEPN86NeCJ1IT48Lqiz4MS5gdDjBwP4M63XP4msZn9aujSf2Qb6My5uT87AJr9zBtgk8MyJsuHr35F0P3q1w==}
engines: {node: '>=8'} engines: {node: '>=8'}
dependencies: dependencies:
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
tslib: 2.6.0 tslib: 2.6.0
dev: false dev: false
/@sentry/integrations@7.58.1: /@sentry/integrations@7.66.0:
resolution: {integrity: sha512-fKZV/QDPM7rIZhaJpFwgxD4rzWLtRuag7cOWfvHCsezJnhXEF8u45sBak/VWmSr8SbcvJAIJSZbWYi0N91hNHQ==} resolution: {integrity: sha512-2PNEnihG9e9Rjbz205+A4BYtFcS2XdgwsN6obAU6Yir7VIbskwZXxx87lKZuz6S53sOWPHleC7uvUBjL+Q6vYg==}
engines: {node: '>=8'} engines: {node: '>=8'}
dependencies: dependencies:
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
localforage: 1.10.0 localforage: 1.10.0
tslib: 2.6.0 tslib: 2.6.0
dev: false dev: false
/@sentry/nextjs@7.58.1(next@13.4.3)(react@18.2.0): /@sentry/nextjs@7.66.0(next@13.4.3)(react@18.2.0):
resolution: {integrity: sha512-/wNVWNJ4vdVHBAvbnjbrRfAX3YhGvdC/CR9IAN5h0tTNjD/LFaHUN97/MUn9oZ7FpFgOOveM5bqK/5b6QRCBCg==} resolution: {integrity: sha512-CJwl3/rIJRR1isqWjGEE8CYiNUndvRksp7l0/75tfe4JoKTk+XS3tXcXVZyyXh34GU5San1c46ctiyodaGGIeg==}
engines: {node: '>=8'} engines: {node: '>=8'}
peerDependencies: peerDependencies:
next: ^10.0.8 || ^11.0 || ^12.0 || ^13.0 next: ^10.0.8 || ^11.0 || ^12.0 || ^13.0
@ -7892,12 +7892,12 @@ packages:
optional: true optional: true
dependencies: dependencies:
'@rollup/plugin-commonjs': 24.0.0(rollup@2.78.0) '@rollup/plugin-commonjs': 24.0.0(rollup@2.78.0)
'@sentry/core': 7.58.1 '@sentry/core': 7.66.0
'@sentry/integrations': 7.58.1 '@sentry/integrations': 7.66.0
'@sentry/node': 7.58.1 '@sentry/node': 7.66.0
'@sentry/react': 7.58.1(react@18.2.0) '@sentry/react': 7.66.0(react@18.2.0)
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
'@sentry/webpack-plugin': 1.20.0 '@sentry/webpack-plugin': 1.20.0
chalk: 3.0.0 chalk: 3.0.0
next: 13.4.3(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) next: 13.4.3(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0)
@ -7910,14 +7910,14 @@ packages:
- supports-color - supports-color
dev: false dev: false
/@sentry/node@7.58.1: /@sentry/node@7.66.0:
resolution: {integrity: sha512-XsSu0xg5SYcltMbatnRBcIZw9pXwGJoGbYDLuPhhuqBz2mnQ0mQ9Try9dn/agDU7KZzT0IyA1qkPXk0NkMe3rw==} resolution: {integrity: sha512-PxqIqLr4Sh5xcDfECiBQ4PuZ7v8yTgLhaRkruWrZPYxQrcJFPkwbFkw/IskzVnhT2VwXUmeWEIlRMQKBJ0t83A==}
engines: {node: '>=8'} engines: {node: '>=8'}
dependencies: dependencies:
'@sentry-internal/tracing': 7.58.1 '@sentry-internal/tracing': 7.66.0
'@sentry/core': 7.58.1 '@sentry/core': 7.66.0
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
cookie: 0.4.2 cookie: 0.4.2
https-proxy-agent: 5.0.1 https-proxy-agent: 5.0.1
lru_map: 0.3.3 lru_map: 0.3.3
@ -7926,39 +7926,39 @@ packages:
- supports-color - supports-color
dev: false dev: false
/@sentry/react@7.58.1(react@18.2.0): /@sentry/react@7.66.0(react@18.2.0):
resolution: {integrity: sha512-0fh2JfKBxPU6Pm11PBt/5DgDg+l0cKcOf1WGhCWsBcFmRE2gAax+Q09+1fWm6+dqtg3piVR8AEEU6ZCBk3l4OQ==} resolution: {integrity: sha512-TC7kCkLoo+Klp9uywdV6tg8DDyn1CrTdndJghO6PoGz6sCa9k+t7K+z4E7MlgDoh3wiZwS2G2zhkT/xVeDRvJA==}
engines: {node: '>=8'} engines: {node: '>=8'}
peerDependencies: peerDependencies:
react: 15.x || 16.x || 17.x || 18.x react: 15.x || 16.x || 17.x || 18.x
dependencies: dependencies:
'@sentry/browser': 7.58.1 '@sentry/browser': 7.66.0
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
hoist-non-react-statics: 3.3.2 hoist-non-react-statics: 3.3.2
react: 18.2.0 react: 18.2.0
tslib: 2.6.0 tslib: 2.6.0
dev: false dev: false
/@sentry/replay@7.58.1: /@sentry/replay@7.66.0:
resolution: {integrity: sha512-KKlpIxGrH1deTr/R3BErX8y16MnOzEylBVVn2I31BglLoZETFS9JAle6JNOgGxS5apFjwdQmD+69vX/mlVhMow==} resolution: {integrity: sha512-5Y2SlVTOFTo3uIycv0mRneBakQtLgWkOnsJaC5LB0Ip0TqVKiMCbQ578vvXp+yvRj4LcS1gNd98xTTNojBoQNg==}
engines: {node: '>=12'} engines: {node: '>=12'}
dependencies: dependencies:
'@sentry/core': 7.58.1 '@sentry/core': 7.66.0
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
'@sentry/utils': 7.58.1 '@sentry/utils': 7.66.0
dev: false dev: false
/@sentry/types@7.58.1: /@sentry/types@7.66.0:
resolution: {integrity: sha512-OnKG+yrilPBeVNQK3biF0u/4IDjwH+boJU1XzJOnYdMRO8uzTWxvaRqpt0C8sVE9VAetRi2eutkzOgCXZISRrw==} resolution: {integrity: sha512-uUMSoSiar6JhuD8p7ON/Ddp4JYvrVd2RpwXJRPH1A4H4Bd4DVt1mKJy1OLG6HdeQv39XyhB1lPZckKJg4tATPw==}
engines: {node: '>=8'} engines: {node: '>=8'}
dev: false dev: false
/@sentry/utils@7.58.1: /@sentry/utils@7.66.0:
resolution: {integrity: sha512-iC9xZJBHp4+MDrZjKwcmMUhI5sTmpUcttwmsJL9HA6ACW+L1XX2eGSDky5pSlhhVFR7q7jJnQ7YUlMQ/jcd8eQ==} resolution: {integrity: sha512-9GYUVgXjK66uXXcLXVMXVzlptqMtq1eJENCuDeezQiEFrNA71KkLDg00wESp+LL+bl3wpVTBApArpbF6UEG5hQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
dependencies: dependencies:
'@sentry/types': 7.58.1 '@sentry/types': 7.66.0
tslib: 2.6.0 tslib: 2.6.0
dev: false dev: false