From dd47a7682fddedd15562e32841a61b3825a65a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Francisco?= <4301103+tomasfrancisco@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:32:05 +0200 Subject: [PATCH] fix env vars (#38) --- apps/dashboard/.env | 4 +- apps/dashboard/globals.d.ts | 7 ---- apps/dashboard/next.config.mjs | 11 ++++- apps/dashboard/sentry.client.config.ts | 2 +- apps/dashboard/sentry.edge.config.ts | 4 +- apps/dashboard/sentry.server.config.ts | 4 +- apps/dashboard/src/app/layout.tsx | 5 ++- .../src/components/favicon/favicon.tsx | 4 +- .../src/components/json-block/json-block.tsx | 2 +- apps/dashboard/src/config.ts | 7 ++-- apps/dashboard/src/env/client-env.ts | 16 +++++++ apps/dashboard/src/env/client.ts | 26 ------------ .../src/env/{server.ts => server-env.ts} | 6 +++ apps/dashboard/src/instrumentation.ts | 8 +++- apps/dashboard/src/lib/analytics/provider.tsx | 42 ++++++++++--------- apps/dashboard/src/lib/figma/figma.ts | 2 +- apps/dashboard/src/lib/metadata.ts | 6 +-- apps/dashboard/src/middleware.ts | 6 +-- packages/auth/src/client/client.ts | 5 +-- packages/auth/src/config.ts | 4 +- packages/auth/src/server/client.ts | 38 ++++++++--------- turbo.json | 5 ++- 22 files changed, 108 insertions(+), 106 deletions(-) create mode 100644 apps/dashboard/src/env/client-env.ts delete mode 100644 apps/dashboard/src/env/client.ts rename apps/dashboard/src/env/{server.ts => server-env.ts} (71%) diff --git a/apps/dashboard/.env b/apps/dashboard/.env index 787a424..f7321ea 100644 --- a/apps/dashboard/.env +++ b/apps/dashboard/.env @@ -1,2 +1,2 @@ -NEXT_PUBLIC_SUPABASE_URL= -NEXT_PUBLIC_SUPABASE_ANON_KEY= \ No newline at end of file +SUPABASE_URL= +SUPABASE_ANON_KEY= \ No newline at end of file diff --git a/apps/dashboard/globals.d.ts b/apps/dashboard/globals.d.ts index 3fafc0e..f824a2f 100644 --- a/apps/dashboard/globals.d.ts +++ b/apps/dashboard/globals.d.ts @@ -6,11 +6,4 @@ declare module '*.svg' { export default content; } -declare global { - namespace globalThis { - // eslint-disable-next-line no-var - var EdgeRuntime: string; - } -} - export {}; diff --git a/apps/dashboard/next.config.mjs b/apps/dashboard/next.config.mjs index c3205db..eb0fe09 100644 --- a/apps/dashboard/next.config.mjs +++ b/apps/dashboard/next.config.mjs @@ -5,8 +5,8 @@ const jiti = createJiti(fileURLToPath(import.meta.url)); import { rewrites } from './src/lib/rewrites.mjs'; import { headers } from './src/lib/headers.mjs'; -jiti('./src/env/client'); -jiti('./src/env/server'); +jiti('./src/env/client-env'); +const serverEnv = jiti('./src/env/server-env'); /** @type {import('next').NextConfig} */ const nextConfig = { @@ -43,6 +43,8 @@ export default withSentryConfig(nextConfig, { org: 'ds-pro', project: 'engine', + authToken: serverEnv.SENTRY_AUTH_TOKEN, + // Only print logs for uploading source maps in CI silent: !process.env.CI, @@ -69,4 +71,9 @@ export default withSentryConfig(nextConfig, { // https://docs.sentry.io/product/crons/ // https://vercel.com/docs/cron-jobs automaticVercelMonitors: true, + + sourcemaps: { + // Only upload source maps in production + disable: serverEnv.VERCEL_ENV !== 'production', + }, }); diff --git a/apps/dashboard/sentry.client.config.ts b/apps/dashboard/sentry.client.config.ts index e478b68..6cc451a 100644 --- a/apps/dashboard/sentry.client.config.ts +++ b/apps/dashboard/sentry.client.config.ts @@ -2,7 +2,7 @@ // The config you add here will be used whenever a users loads a page in their browser. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import { clientEnv } from '@/env/client'; +import { clientEnv } from '@/env/client-env'; import * as Sentry from '@sentry/nextjs'; Sentry.init({ diff --git a/apps/dashboard/sentry.edge.config.ts b/apps/dashboard/sentry.edge.config.ts index 9c3e91e..4bdb87b 100644 --- a/apps/dashboard/sentry.edge.config.ts +++ b/apps/dashboard/sentry.edge.config.ts @@ -3,11 +3,11 @@ // Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import { clientEnv } from '@/env/client'; +import { serverEnv } from '@/env/server-env'; import * as Sentry from '@sentry/nextjs'; Sentry.init({ - enabled: clientEnv.NEXT_PUBLIC_VERCEL_ENV === 'production', + enabled: serverEnv.VERCEL_ENV === 'production', dsn: 'https://bee796b3d7d7f0364e1dc326183331f0@o4507860870299648.ingest.de.sentry.io/4507860871872592', // Adjust this value in production, or use tracesSampler for greater control diff --git a/apps/dashboard/sentry.server.config.ts b/apps/dashboard/sentry.server.config.ts index 61250bd..21ba4ad 100644 --- a/apps/dashboard/sentry.server.config.ts +++ b/apps/dashboard/sentry.server.config.ts @@ -2,11 +2,11 @@ // The config you add here will be used whenever the server handles a request. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import { clientEnv } from '@/env/client'; +import { serverEnv } from '@/env/server-env'; import * as Sentry from '@sentry/nextjs'; Sentry.init({ - enabled: clientEnv.NEXT_PUBLIC_VERCEL_ENV === 'production', + enabled: serverEnv.VERCEL_ENV === 'production', dsn: 'https://bee796b3d7d7f0364e1dc326183331f0@o4507860870299648.ingest.de.sentry.io/4507860871872592', // Adjust this value in production, or use tracesSampler for greater control diff --git a/apps/dashboard/src/app/layout.tsx b/apps/dashboard/src/app/layout.tsx index 626501f..31c86bd 100644 --- a/apps/dashboard/src/app/layout.tsx +++ b/apps/dashboard/src/app/layout.tsx @@ -6,6 +6,7 @@ import { Toaster } from '@ds-project/components'; import { Favicon } from '@/components'; import dynamic from 'next/dynamic'; import { getMetadata } from '@/lib/metadata'; +import { clientEnv } from '@/env/client-env'; const inter = Inter({ subsets: ['latin'] }); @@ -31,7 +32,9 @@ export default function RootLayout({