Skip to content

Commit

Permalink
🚸 Skip validation if __ENV.js file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Aug 31, 2023
1 parent 9d29a88 commit dfcfdf2
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 99 deletions.
2 changes: 1 addition & 1 deletion apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@giphy/react-components": "7.1.0",
"@googleapis/drive": "8.0.0",
"@paralleldrive/cuid2": "2.2.1",
"@sentry/nextjs": "7.58.1",
"@sentry/nextjs": "7.66.0",
"@stripe/stripe-js": "1.54.1",
"@t3-oss/env-nextjs": "^0.6.0",
"@tanstack/react-query": "^4.29.19",
Expand Down
12 changes: 0 additions & 12 deletions apps/builder/sentry.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,4 @@ Sentry.init({
"Can't find variable: ResizeObserver",
],
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
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const IconPicker = ({ onIconSelected }: Props) => {
placeholder="Search..."
onChange={searchIcon}
withVariableButton={false}
debounceTimeout={300}
/>
<ColorPicker value={selectedColor} onColorChange={updateColor} />
</HStack>
Expand Down
2 changes: 1 addition & 1 deletion apps/viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@planetscale/database": "^1.8.0",
"@sentry/nextjs": "7.58.1",
"@sentry/nextjs": "7.66.0",
"@trpc/server": "10.34.0",
"@typebot.io/nextjs": "workspace:*",
"@typebot.io/prisma": "workspace:*",
Expand Down
12 changes: 0 additions & 12 deletions apps/viewer/sentry.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,4 @@ Sentry.init({
"Can't find variable: ResizeObserver",
],
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
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const executeScript = async ({ content, args }: ScriptToExecute) => {
)
await func(...args.map((arg) => arg.value))
} catch (err) {
console.error(err)
console.warn('Script threw an error:', err)
}
}

Expand Down
18 changes: 2 additions & 16 deletions packages/env/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createEnv } from '@t3-oss/env-nextjs'
import { ZodError, z } from 'zod'
import { z } from 'zod'
import { getRuntimeVariable } from './getRuntimeVariable'

declare const window: {
Expand Down Expand Up @@ -317,21 +317,7 @@ 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')
},
skipValidation: typeof window !== 'undefined' && window.__ENV === undefined,
onInvalidAccess: (variable: string) => {
throw new Error(
`❌ Attempted to access a server-side environment variable on the client: ${variable}`
Expand Down
5 changes: 2 additions & 3 deletions packages/env/getRuntimeVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ declare const window: {
__ENV?: any
}

const isBrowser = () => Boolean(typeof window !== 'undefined' && window.__ENV)

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
return process.env[key]
}
106 changes: 53 additions & 53 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 comments on commit dfcfdf2

@vercel
Copy link

@vercel vercel bot commented on dfcfdf2 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on dfcfdf2 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

bii.bj
1stop.au
wasap.nl
x.cr8.ai
yobot.me
klujo.com
me.cr8.ai
sifuim.co
wachat.io
wassep.io
247987.com
8jours.top
aginap.com
ai.mprs.in
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
jxi.cr8.ai
nepkit.com
pig.cr8.ai
sat.cr8.ai
typebot.io
wachats.me
wsapio.com
zamrin.net
blogely.com
bot.aipr.kr
bot.kloo.me
broprio.com
bull.cr8.ai
docs.cr8.ai
getyour.sbs
icon.cr8.ai
minipost.uk
mole.cr8.ai
nurraysa.me
team.cr8.ai
wolf.cr8.ai
ai.meant.com
alphamen.pro
bet7k.online
bot.afric.ai
bot.grace.bj
cinecorn.com
ezbooking.ai
gniorder.com
help.taxt.co
kusamint.com
faqs.nigerias.io
feiraodehoje.com
georgemarttt.com
go.chatbotcv.com
haymanevents.com
kw.wpwakanda.com
localamor.online
lojamundobox.com
myrentalhost.com
silvercop.com.br
viewer-v2-typebot-io.vercel.app
mdb.assessoria.desideri.progenbr.com
mdb.assessoria.fernanda.progenbr.com
mdb.assessoria.jbatista.progenbr.com
mdb.assessoria.mauricio.progenbr.com
mdb.evento.autocadastro.progenbr.com
form.shopmercedesbenzsouthorlando.com
mdb.evento.equipeinterna.progenbr.com
bot.studiotecnicoimmobiliaremerelli.it
mdb.assessoria.boaventura.progenbr.com
mdb.assessoria.jtrebesqui.progenbr.com
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
mdb.assessoria.carreirinha.progenbr.com
chrome-os-inquiry-system.itschromeos.com
mdb.assessoria.paulomarques.progenbr.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com
mdb.assessoria.qrcode.ademir.progenbr.com
mdb.assessoria.qrcode.arthur.progenbr.com
mdb.assessoria.qrcode.danilo.progenbr.com
mdb.assessoria.qrcode.marcao.progenbr.com
mdb.assessoria.qrcode.marcio.progenbr.com
mdb.assessoria.qrcode.aloisio.progenbr.com
mdb.assessoria.qrcode.girotto.progenbr.com
mdb.assessoria.qrcode.marinho.progenbr.com
mdb.assessoria.qrcode.rodrigo.progenbr.com
mdb.assessoria.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.desideri.progenbr.com
mdb.assessoria.qrcode.fernanda.progenbr.com
mdb.assessoria.qrcode.jbatista.progenbr.com
mdb.assessoria.qrcode.mauricio.progenbr.com
mdb.assessoria.fernanda.regional.progenbr.com
mdb.assessoria.qrcode.boaventura.progenbr.com
mdb.assessoria.qrcode.jtrebesqui.progenbr.com
mdb.assessoria.qrcode.carreirinha.progenbr.com
mdb.assessoria.qrcode.paulomarques.progenbr.com
mdb.assessoria.qrcode.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.fernanda.regional.progenbr.com

@vercel
Copy link

@vercel vercel bot commented on dfcfdf2 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on dfcfdf2 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

Please sign in to comment.