Skip to main content

Feature Flags Module

The Feature Flags Module provides access to feature flags (settings) that control the behavior and appearance of the application. Feature flags allow for dynamic configuration without requiring code changes or redeployment.

Accessing the Module

The Feature Flags Module is accessible through the GamanzaEngageWebClientSDK instance:

const sdk = GamanzaEngageWebClientSDK.getInstance();
const featureFlags = sdk.FeatureFlags;

Methods

getFeatureFlagValue

Returns the value for a specific feature flag identified by its key.

getFeatureFlagValue(featureFlagKey)

Parameters

NameTypeDescription
featureFlagKeystringThe unique identifier for the feature flag

Returns

  • Promise<T | null>: A promise that resolves to the value of the feature flag with the specified type, or null if the feature flag is not found.

Example

// Get a boolean feature flag
const isFeatureEnabled = await sdk.FeatureFlags.getFeatureFlagValue('my-feature-enabled');

// Get a string feature flag
const featureConfig = await sdk.FeatureFlags.getFeatureFlagValue('feature-config');

// Get a complex object feature flag
const featureSettings = await sdk.FeatureFlags.getFeatureFlagValue('feature-settings');
// featureSettings might contain: { enabled: true, maxAttempts: 3, displayName: "Feature Name" }

getFeatureFlags (Deprecated)

Returns all feature flags available for the current instance.

getFeatureFlags()

Note: This method is deprecated. Please use getFeatureFlagValue instead.

Returns

  • Promise<Array>: A promise that resolves to an array of all available feature flags.

Example

// Get all feature flags (deprecated)
const allFlags = await sdk.FeatureFlags.getFeatureFlags();

Interfaces

FeatureFlag

Represents a feature flag with its metadata and value.

The FeatureFlag object has the following structure:

PropertyTypeDescription
keystringUnique identifier for the feature flag
scopestringScope of the feature flag (e.g., "global", "user", etc.)
descriptionstringDetailed description of what the feature flag controls
displayNamestringHuman-readable name for the feature flag
hiddenbooleanIndicates whether the feature flag should be hidden from user interfaces
staticbooleanIndicates whether the feature flag value is static (unchangeable)
typestringData type of the feature flag value (e.g., "boolean", "string", "object")
valueanyThe current value of the feature flag
defaultanyThe default value of the feature flag if no value is set

Caching Behavior

The Feature Flags Module implements caching to improve performance:

  • Feature flag values are cached in IndexedDB for 30 minutes
  • When requesting a specific feature flag value, the module first checks the cache
  • If the value is not in the cache, it will be fetched from the server and then cached
  • The cache is automatically cleared when the SDK session is closed

Error Handling

If a feature flag is not found, the getFeatureFlagValue method returns null. Your application should handle this case appropriately, typically by falling back to a default behavior.