feat: conditionally enable recording studio and feedback tool via env vars
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Failing after 1m12s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Failing after 1m12s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
This commit is contained in:
@@ -15,6 +15,11 @@ function createConfig() {
|
||||
|
||||
const target = env.NEXT_PUBLIC_TARGET || env.TARGET;
|
||||
|
||||
console.log('[Config] Initializing Toggles:', {
|
||||
feedbackEnabled: env.NEXT_PUBLIC_FEEDBACK_ENABLED,
|
||||
recordModeEnabled: env.NEXT_PUBLIC_RECORD_MODE_ENABLED,
|
||||
});
|
||||
|
||||
return {
|
||||
env: env.NODE_ENV,
|
||||
target,
|
||||
@@ -23,6 +28,7 @@ function createConfig() {
|
||||
isTesting: target === 'testing',
|
||||
isDevelopment: target === 'development',
|
||||
feedbackEnabled: env.NEXT_PUBLIC_FEEDBACK_ENABLED,
|
||||
recordModeEnabled: env.NEXT_PUBLIC_RECORD_MODE_ENABLED,
|
||||
gatekeeperUrl: env.GATEKEEPER_URL,
|
||||
|
||||
baseUrl: env.NEXT_PUBLIC_BASE_URL,
|
||||
@@ -144,6 +150,9 @@ export const config = {
|
||||
get feedbackEnabled() {
|
||||
return getConfig().feedbackEnabled;
|
||||
},
|
||||
get recordModeEnabled() {
|
||||
return getConfig().recordModeEnabled;
|
||||
},
|
||||
get infraCMS() {
|
||||
return getConfig().infraCMS;
|
||||
},
|
||||
|
||||
23
lib/env.ts
23
lib/env.ts
@@ -1,6 +1,18 @@
|
||||
import { z } from 'zod';
|
||||
import { validateMintelEnv, mintelEnvSchema, withMintelRefinements } from '@mintel/next-utils';
|
||||
|
||||
/**
|
||||
* Robust boolean preprocessor for environment variables.
|
||||
* Handles strings 'true'/'false' and actual booleans.
|
||||
*/
|
||||
const booleanSchema = z.preprocess((val) => {
|
||||
if (typeof val === 'string') {
|
||||
if (val.toLowerCase() === 'true') return true;
|
||||
if (val.toLowerCase() === 'false') return false;
|
||||
}
|
||||
return val;
|
||||
}, z.boolean());
|
||||
|
||||
/**
|
||||
* Environment variable schema.
|
||||
* Extends the default Mintel environment schema.
|
||||
@@ -11,14 +23,9 @@ const envExtension = {
|
||||
|
||||
// Gatekeeper specifics not in base
|
||||
GATEKEEPER_URL: z.string().url().default('http://gatekeeper:3000'),
|
||||
GATEKEEPER_BYPASS_ENABLED: z.preprocess(
|
||||
(val) => val === 'true' || val === true,
|
||||
z.boolean().default(false),
|
||||
),
|
||||
NEXT_PUBLIC_FEEDBACK_ENABLED: z.preprocess(
|
||||
(val) => val === 'true' || val === true,
|
||||
z.boolean().default(false),
|
||||
),
|
||||
GATEKEEPER_BYPASS_ENABLED: booleanSchema.default(false),
|
||||
NEXT_PUBLIC_FEEDBACK_ENABLED: booleanSchema.default(false),
|
||||
NEXT_PUBLIC_RECORD_MODE_ENABLED: booleanSchema.default(false),
|
||||
|
||||
INFRA_DIRECTUS_URL: z.string().url().optional(),
|
||||
INFRA_DIRECTUS_TOKEN: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user