import { Feature, FeatureFlags } from '../../types/types'; /** * Predefined feature flags for __DEV__ mode. * * In general we can keep all Features enabled for the development mode. * Adjust as needed. */ const developmentFeatureFlagConfiguration: FeatureFlags = Object.freeze({ [Feature.checkFeatureFlagImplementation]: false, [Feature.crashReporter]: false, }); /** * Predefined feature flags for **PROD** mode. * * Keep in mind that during the **development**, **Alpha** and **Beta** phases all flags should be set to false. */ const productionFeatureFlagConfiguration: FeatureFlags = Object.freeze({ [Feature.checkFeatureFlagImplementation]: false, [Feature.crashReporter]: false, }); const defaultFeatureFlagConfiguration = __DEV__ ? developmentFeatureFlagConfiguration : productionFeatureFlagConfiguration; /** * Singleton class to manage feature flags. */ class FeatureFlagManager { private _featureFlags: FeatureFlags = { ...defaultFeatureFlagConfiguration }; private constructor() {} public static getInstance(): FeatureFlagManager { return FeatureFlagManager._instance; } private static _instance: FeatureFlagManager = new FeatureFlagManager(); /** * Sets a specific feature flag. * @param name - The name of the feature flag. * @param enabled - Whether the feature flag should be enabled. */ public setFeatureFlag(name: Feature, enabled: boolean): void { this._featureFlags[name] = enabled; } /** * Set feature flags object * @param values */ public set featureFlags(values: FeatureFlags) { this._featureFlags = values; } /** * Get direct access to the feature flags object. */ public get featureFlags(): FeatureFlags { return this._featureFlags; } } export default FeatureFlagManager.getInstance();