diff --git a/ui/.env.development b/ui/.env.development index 219dea656b..4f6940ba96 100644 --- a/ui/.env.development +++ b/ui/.env.development @@ -3,3 +3,4 @@ REACT_APP_VERSION=$npm_package_version REACT_APP_NAME=$npm_package_name REACT_APP_SENTRY_DSN=https://10930d3b0a8d427cad2147d6d845be56@o226447.ingest.sentry.io/5721090 REACT_APP_SENTRY_ENABLED=false +RELEASE_VERSION=$set_by_config_overrides diff --git a/ui/.env.production b/ui/.env.production index 774cdc1e16..75f58e9189 100644 --- a/ui/.env.production +++ b/ui/.env.production @@ -4,3 +4,4 @@ REACT_APP_VERSION=$npm_package_version REACT_APP_NAME=$npm_package_name REACT_APP_SENTRY_DSN=https://10930d3b0a8d427cad2147d6d845be56@o226447.ingest.sentry.io/5721090 REACT_APP_SENTRY_ENABLED=true +RELEASE_VERSION=$set_by_config_overrides diff --git a/ui/config-overrides.js b/ui/config-overrides.js index c9fb7c84d6..6b53df6727 100644 --- a/ui/config-overrides.js +++ b/ui/config-overrides.js @@ -106,17 +106,19 @@ const supportDynamicPublicPathPrefix = () => (config) => { return config } -const overrideProcessEnv = value => config => { - const plugin = config.plugins.find(plugin => plugin.constructor.name === 'DefinePlugin'); - const processEnv = plugin.definitions['process.env'] || {}; +const overrideProcessEnv = (value) => (config) => { + const plugin = config.plugins.find( + (plugin) => plugin.constructor.name === 'DefinePlugin' + ) + const processEnv = plugin.definitions['process.env'] || {} plugin.definitions['process.env'] = { ...processEnv, ...value, - }; + } - return config; -}; + return config +} const getInternalVersion = () => { const out = execSync(`grep -v '^\#' ../release-version`) @@ -171,6 +173,6 @@ module.exports = override( addExtraEntries(), supportDynamicPublicPathPrefix(), overrideProcessEnv({ - INTERNAL_VERSION: JSON.stringify(getInternalVersion()) - }), + RELEASE_VERSION: JSON.stringify(getInternalVersion()), + }) ) diff --git a/ui/lib/utils/useCompatibilityLocalstorage.ts b/ui/lib/utils/useCompatibilityLocalstorage.ts index 61a18b4d41..cbf26f9844 100644 --- a/ui/lib/utils/useCompatibilityLocalstorage.ts +++ b/ui/lib/utils/useCompatibilityLocalstorage.ts @@ -1,11 +1,12 @@ import { useLocalStorageState } from 'ahooks' +// we can **update version field in package.json** to upgrade local storage version key export function useCompatibilityLocalstorage( key: string, defaultValue: T | (() => T) ) { return useLocalStorageState( - `${key}_${process.env.INTERNAL_VERSION}`, + `${key}.v${process.env.REACT_APP_VERSION}`, defaultValue ) } diff --git a/ui/src/sentry.ts b/ui/src/sentry.ts index e77f19eb43..c4433e5164 100644 --- a/ui/src/sentry.ts +++ b/ui/src/sentry.ts @@ -4,7 +4,7 @@ import { Integrations } from '@sentry/tracing' import { sentryEnabled } from '@lib/utils/sentryHelpers' if (sentryEnabled) { - const version = process.env.REACT_APP_VERSION + const version = process.env.RELEASE_VERSION const name = process.env.REACT_APP_NAME const hash = process.env.REACT_APP_COMMIT_HASH const release = `${name}@${version}+${hash}`