From c0b2cc4e03fd2bcf347ca1c044ccc2d28a9b2126 Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Tue, 8 Oct 2024 22:46:10 +0700 Subject: [PATCH] build: move sentry/posthog keys away from .env to a constant in vite.config.js there's an issue in the release ci where the env vars aren't found by the build. opting for hardcoding as the values are public and this way is more straightforward. --- .env.example | 2 -- .github/workflows/build.yaml | 3 --- src/main.tsx | 4 ++-- src/vite-env.d.ts | 2 ++ vite.config.ts | 6 ++++++ 5 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index c130e40..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -VITE_SENTRY_DSN= -VITE_POSTHOG_KEY= diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f32a121..a41e989 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,9 +36,6 @@ jobs: run: pnpm install - name: Build run: pnpm build - env: - VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - VITE_POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} - name: Archive Release uses: thedoctor0/zip-release@0.7.6 with: diff --git a/src/main.tsx b/src/main.tsx index c529546..116eb9d 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -27,7 +27,7 @@ declare module '@tanstack/react-router' { } Sentry.init({ - dsn: import.meta.env.VITE_SENTRY_DSN as string, + dsn: __SENTRY_DSN__, integrations: [ Sentry.browserTracingIntegration(), Sentry.browserProfilingIntegration(), @@ -55,7 +55,7 @@ Sentry.init({ }) const postHogConfig = { - apiKey: import.meta.env.VITE_POSTHOG_KEY as string, + apiKey: __POSTHOG_KEY__, options: { person_profiles: 'identified_only', capture_pageview: false, diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 5d3662e..521a920 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,2 +1,4 @@ /// declare const __CARDINAL_PROJECT_ID__: string +declare const __SENTRY_DSN__: string +declare const __POSTHOG_KEY__: string diff --git a/vite.config.ts b/vite.config.ts index ec8352f..fd6bacc 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -21,8 +21,14 @@ export default defineConfig({ }, }, + // defining sentry dsn and posthog key here since they're public anyways and + // is more straightforward than putting them in github secrets. note the + // backticks (`) surrounding the single quotes (') is required as the values + // must be JSON serializable define: { __CARDINAL_PROJECT_ID__: `'__CARDINAL_PROJECT_ID__'`, + __SENTRY_DSN__: `'https://731f7b8388eaf882bb175a8e548404ef@o4506475620204544.ingest.us.sentry.io/4507899857534976'`, + __POSTHOG_KEY__: `'phc_nkoe1cRzoBD3JUNX7ZKFC1M9wUV189UMc9ZhXAq56ts'`, }, build: {