mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
feat: split Sentry DSN and project by USE_PROD_CONFIG (#9905)
## Summary - Read `sentry_dsn` from remote config at runtime for cloud builds, following the same pattern as `firebase.ts` and `comfyApi.ts` - Upload sourcemaps to both staging (`SENTRY_PROJECT`) and prod (`SENTRY_PROJECT_PROD`) Sentry projects at build time - Remove `SENTRY_DSN_PROD` / `USE_PROD_CONFIG`-based DSN selection — DSN is now delivered per-environment via dynamic config ## Companion PR - https://github.com/Comfy-Org/cloud/pull/2883 (cloud repo: dynamic config + workflow) ## Setup required - Add `SENTRY_PROJECT_PROD` variable (`cloud-frontend-prod`) to GitHub STAGING environment in cloud repo ## Test plan - [ ] Verify staging build reads staging DSN from remote config - [ ] Verify prod build reads prod DSN from remote config - [ ] Confirm sourcemaps are uploaded to both Sentry projects - [ ] Validate fallback to `__SENTRY_DSN__` when remote config is unavailable
This commit is contained in:
@@ -45,3 +45,4 @@ ALGOLIA_API_KEY=684d998c36b67a9a9fce8fc2d8860579
|
||||
# SENTRY_AUTH_TOKEN=private-token # get from sentry
|
||||
# SENTRY_ORG=comfy-org
|
||||
# SENTRY_PROJECT=cloud-frontend-staging
|
||||
# SENTRY_PROJECT_PROD= # prod project slug for sourcemap uploads
|
||||
|
||||
10
src/main.ts
10
src/main.ts
@@ -12,6 +12,10 @@ import { createApp } from 'vue'
|
||||
import { VueFire, VueFireAuth } from 'vuefire'
|
||||
|
||||
import { getFirebaseConfig } from '@/config/firebase'
|
||||
import {
|
||||
configValueOrDefault,
|
||||
remoteConfig
|
||||
} from '@/platform/remoteConfig/remoteConfig'
|
||||
import '@/lib/litegraph/public/css/litegraph.css'
|
||||
import router from '@/router'
|
||||
import { useBootstrapStore } from '@/stores/bootstrapStore'
|
||||
@@ -48,9 +52,13 @@ const firebaseApp = initializeApp(getFirebaseConfig())
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
|
||||
const sentryDsn = isCloud
|
||||
? configValueOrDefault(remoteConfig.value, 'sentry_dsn', __SENTRY_DSN__)
|
||||
: __SENTRY_DSN__
|
||||
|
||||
Sentry.init({
|
||||
app,
|
||||
dsn: __SENTRY_DSN__,
|
||||
dsn: sentryDsn,
|
||||
enabled: __SENTRY_ENABLED__,
|
||||
release: __COMFYUI_FRONTEND_VERSION__,
|
||||
normalizeDepth: 8,
|
||||
|
||||
@@ -54,4 +54,5 @@ export type RemoteConfig = {
|
||||
workflow_sharing_enabled?: boolean
|
||||
comfyhub_upload_enabled?: boolean
|
||||
comfyhub_profile_gate_enabled?: boolean
|
||||
sentry_dsn?: string
|
||||
}
|
||||
|
||||
@@ -424,8 +424,8 @@ export default defineConfig({
|
||||
: []),
|
||||
|
||||
// Sentry sourcemap upload plugin
|
||||
// Only runs during cloud production builds when all Sentry env vars are present
|
||||
// Requires: SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT env vars
|
||||
// Uploads sourcemaps to both staging and prod Sentry projects so that
|
||||
// error stack traces are readable in both environments.
|
||||
...(DISTRIBUTION === 'cloud' &&
|
||||
process.env.SENTRY_AUTH_TOKEN &&
|
||||
process.env.SENTRY_ORG &&
|
||||
@@ -437,10 +437,23 @@ export default defineConfig({
|
||||
project: process.env.SENTRY_PROJECT,
|
||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||
sourcemaps: {
|
||||
// Delete source maps after upload to prevent public access
|
||||
filesToDeleteAfterUpload: ['**/*.map']
|
||||
filesToDeleteAfterUpload: process.env.SENTRY_PROJECT_PROD
|
||||
? []
|
||||
: ['**/*.map']
|
||||
}
|
||||
})
|
||||
}),
|
||||
...(process.env.SENTRY_PROJECT_PROD
|
||||
? [
|
||||
sentryVitePlugin({
|
||||
org: process.env.SENTRY_ORG,
|
||||
project: process.env.SENTRY_PROJECT_PROD,
|
||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||
sourcemaps: {
|
||||
filesToDeleteAfterUpload: ['**/*.map']
|
||||
}
|
||||
})
|
||||
]
|
||||
: [])
|
||||
]
|
||||
: [])
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user