Skip to content

Commit

Permalink
build: move sentry/posthog keys away from .env to a constant in vite.…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rmrt1n committed Oct 8, 2024
1 parent c81c485 commit c0b2cc4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/// <reference types="vite/client" />
declare const __CARDINAL_PROJECT_ID__: string
declare const __SENTRY_DSN__: string
declare const __POSTHOG_KEY__: string
6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit c0b2cc4

Please sign in to comment.