-
Notifications
You must be signed in to change notification settings - Fork 57
Env by app #3303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Env by app #3303
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { SentryConfig } from '@/setup/sentry' | ||
|
|
||
| export type AccountEnv = { | ||
| defaultLang: string | ||
| sentry: SentryConfig | ||
| } | ||
|
|
||
| function parseSampleRate(value: string, fallback: number) { | ||
| return parseFloat(value) || fallback | ||
| } | ||
|
|
||
| export const accountEnv: AccountEnv = { | ||
| defaultLang: (import.meta.env.VITE_ACCOUNT_DEFAULT_LANG as string) || 'en', | ||
| sentry: { | ||
| dsn: (import.meta.env.VITE_ACCOUNT_SENTRY_DSN as string) || '', | ||
| tracesSampleRate: parseSampleRate(import.meta.env.VITE_ACCOUNT_SENTRY_TRACES_SAMPLE_RATE as string, 0.1), | ||
| lspSampleRate: parseSampleRate(import.meta.env.VITE_ACCOUNT_SENTRY_LSP_SAMPLE_RATE as string, 0.1) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { XBuilderEnv } from './env' | ||
|
|
||
| let xbuilderConfig: XBuilderEnv | null = null | ||
|
|
||
| export function configureXBuilder(config: XBuilderEnv) { | ||
| xbuilderConfig = config | ||
| } | ||
|
|
||
| export function getXBuilderConfig() { | ||
| if (xbuilderConfig == null) throw new Error('XBuilder config is not set') | ||
| return xbuilderConfig | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||
| import type { SentryConfig } from '@/setup/sentry' | ||||||||||||||||
|
|
||||||||||||||||
| export type XBuilderEnv = { | ||||||||||||||||
| apiBaseUrl: string | ||||||||||||||||
| usercontentBaseUrl: string | ||||||||||||||||
| usercontentBucket: string | ||||||||||||||||
| disableAIGC: boolean | ||||||||||||||||
| spxVersion: string | ||||||||||||||||
| showLicense: boolean | ||||||||||||||||
| showTutorialsEntry: boolean | ||||||||||||||||
| defaultLang: string | ||||||||||||||||
| accountOAuthClientId: string | ||||||||||||||||
| sentry: SentryConfig | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function parseSampleRate(value: string, fallback: number) { | ||||||||||||||||
| return parseFloat(value) || fallback | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+16
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Use
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| export const xbuilderEnv: XBuilderEnv = { | ||||||||||||||||
| apiBaseUrl: import.meta.env.VITE_API_BASE_URL as string, | ||||||||||||||||
| usercontentBaseUrl: import.meta.env.VITE_USERCONTENT_BASE_URL as string, | ||||||||||||||||
| usercontentBucket: import.meta.env.VITE_USERCONTENT_BUCKET as string, | ||||||||||||||||
| disableAIGC: import.meta.env.VITE_DISABLE_AIGC === 'true', | ||||||||||||||||
| spxVersion: import.meta.env.VITE_SPX_VERSION as string, | ||||||||||||||||
| showLicense: import.meta.env.VITE_SHOW_LICENSE === 'true', | ||||||||||||||||
| showTutorialsEntry: import.meta.env.VITE_SHOW_TUTORIALS_ENTRY === 'true', | ||||||||||||||||
| defaultLang: (import.meta.env.VITE_DEFAULT_LANG as string) || 'en', | ||||||||||||||||
| accountOAuthClientId: import.meta.env.VITE_ACCOUNT_OAUTH_CLIENT_ID as string, | ||||||||||||||||
| sentry: { | ||||||||||||||||
| dsn: (import.meta.env.VITE_SENTRY_DSN as string) || '', | ||||||||||||||||
| tracesSampleRate: parseSampleRate(import.meta.env.VITE_SENTRY_TRACES_SAMPLE_RATE as string, 0.1), | ||||||||||||||||
| lspSampleRate: parseSampleRate(import.meta.env.VITE_SENTRY_LSP_SAMPLE_RATE as string, 0.1) | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,7 +165,7 @@ import { type SpxProject } from '@/models/spx/project' | |
| import { useSignedInUser } from '@/stores/user' | ||
| import { Visibility } from '@/apis/common' | ||
| import { getProjectPageRoute } from '@/apps/xbuilder/router' | ||
| import { showTutorialsEntry } from '@/utils/env' | ||
| import { getXBuilderConfig } from '@/apps/xbuilder/config' | ||
| import { useModifyProjectName, usePublishProject, useRemoveProject, useUnpublishProject } from '@/components/project' | ||
| import { useLoadFromScratchModal } from '@/components/asset' | ||
| import { xbpHelpers } from '@/models/common/xbp' | ||
|
|
@@ -178,6 +178,8 @@ import EditorAutoSaveStateIcon from './EditorAutoSaveStateIcon.vue' | |
| import EditorProjectDisplayName from './EditorProjectDisplayName.vue' | ||
| import EditorCheckoutReleaseButton from './EditorCheckoutReleaseButton.vue' | ||
| import { EditMode, type EditorState } from '../editor-state' | ||
|
|
||
| const { showTutorialsEntry } = getXBuilderConfig() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable declaration Please move this statement below all the |
||
| import { isDeveloperMode } from '@/utils/developer-mode' | ||
| import importProjectSvg from './icons/import-project.svg' | ||
| import exportProjectSvg from './icons/export-project.svg' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
parseSampleRatefunction usesparseFloat(value) || fallback. If the sample rate is explicitly configured as0(which is a valid setting to disable tracing/sampling),parseFloat(value)evaluates to0, causing the function to incorrectly fall back to the default value (0.1).Use
isNaNto check if the parsed value is valid instead.