Skip to content
Snippets Groups Projects

feat: feature flags for production environment

Merged Sjoerd requested to merge feat/featureFlags into main
1 file
+ 10
5
Compare changes
  • Side-by-side
  • Inline
// Safely retrieve environment variable values with a default fallback
const getEnvVariable = (key: string, defaultValue: string = 'false'): string => {
return import.meta.env[key] ?? defaultValue;
};
// Check if the environment is production
const isProduction = (): boolean => {
return import.meta.env.GRAPHPOLARIS_VERSION === 'prod';
return getEnvVariable('GRAPHPOLARIS_VERSION', 'dev') === 'prod';
};
// Check if the Manage Permissions feature is enabled
const showManagePermissions = (): boolean => {
return !isProduction() || (isProduction() && import.meta.env.WIP_VIEWER_PERMISSIONS === 'false');
return !isProduction() || (isProduction() && getEnvVariable('WIP_VIEWER_PERMISSIONS') === 'false');
};
// Check if the Insight Sharing feature is enabled
const showInsightSharing = (): boolean => {
return !isProduction() || (isProduction() && import.meta.env.WIP_INSIGHT_SHARING === 'false');
return !isProduction() || (isProduction() && getEnvVariable('WIP_INSIGHT_SHARING') === 'false');
};
// Check if the Insight Sharing feature is enabled
const showSharableExploration = (): boolean => {
return !isProduction() || (isProduction() && import.meta.env.WIP_SHARABLE_EXPLORATION === 'false');
return !isProduction() || (isProduction() && getEnvVariable('WIP_SHARABLE_EXPLORATION') === 'false');
};
// Utility to check if a specific visualization is released based on environment variables
const isVisualizationReleased = (visualizationName: string): boolean => {
const visualizationFlag = import.meta.env[`WIP_${visualizationName.toUpperCase()}`] || 'false';
const visualizationFlag = getEnvVariable(`WIP_${visualizationName.toUpperCase()}`, 'false');
return !isProduction() || (isProduction() && visualizationFlag === 'false');
};
Loading