Skip to content

feat(remote_config): add Firebase Remote Config integration#2170

Open
sharjeelyunus wants to merge 3 commits intomainfrom
firebase-remote-config
Open

feat(remote_config): add Firebase Remote Config integration#2170
sharjeelyunus wants to merge 3 commits intomainfrom
firebase-remote-config

Conversation

@sharjeelyunus
Copy link
Member

@sharjeelyunus sharjeelyunus commented Mar 1, 2026

Firebase Remote Config Module

Summary

Adds an optional ensemble_remote_config module so apps can use Firebase Remote Config for A/B testing, feature flags, and runtime config in YAML. Off by default; enabled from the starter like other optional modules (Analytics, Stripe).

What's in this PR

  • Ensemble core: Stub RemoteConfig / RemoteConfigStub and ensemble.remoteConfig in data context (property access, .get, .refresh, .setDefaults, .all(), .info()). No Firebase dependency in core.
  • Module ensemble_remote_config: Implements Remote Config (fetch on startup, typed getValue, setDefaults, refresh, debug helpers, getAllValues, getInfo).
  • Env-driven settings: remote_config_fetch_timeout and remote_config_minimum_fetch_interval environment variables control fetchTimeout and minimumFetchInterval (with safe defaults). Values are applied on init and re-applied before each fetchAndActivate() / ensemble.remoteConfig.refresh().
  • Starter: useRemoteConfig flag, optional dependency and GetIt registration, enable script that also runs Firebase setup.
  • Docs: README in the module (enable steps, usage, A/B testing guide, env-based settings, setDefaults behavior).

Usage

Method Description Example
Property access Read a key; value is inferred as bool, num, or string. ensemble.remoteConfig.my_key
get Read with a custom default; type follows the default. ensemble.remoteConfig.get('my_key', false)
getBool Read as boolean with optional default. ensemble.remoteConfig.getBool('flag', false)
getInt Read as int with optional default. ensemble.remoteConfig.getInt('max_items', 10)
getDouble Read as double with optional default. ensemble.remoteConfig.getDouble('ratio', 0.5)
getString Read as string with optional default. ensemble.remoteConfig.getString('cta_text', 'Try it now')
setDefaults Register app-side defaults with Firebase; use at startup. ensemble.remoteConfig.setDefaults({ flag: true, max_items: 10 })
all Return a map of all keys to their current values (debug). ensemble.remoteConfig.all()
info Return metadata (initialized, lastFetchStatus, lastFetchTime, etc.). ensemble.remoteConfig.info()
refresh Manually re-fetch and activate Remote Config values (uses current env-based timeout/interval). ensemble.remoteConfig.refresh()

How to enable

  • Script: From starter/ run npm run hasRemoteConfig (or npm run enable and pick remote_config).
  • Manual: Uncomment ensemble_remote_config in starter pubspec.yaml, set useRemoteConfig = true and uncomment the import and GetIt line in ensemble_modules.dart. Ensure Firebase is configured (google-services.json / GoogleService-Info.plist / web config).

Environment variables

remote_config_fetch_timeout: 10 # seconds, default 10
remote_config_minimum_fetch_interval: 3600 # seconds, default 3600 (1h)

  • For local debugging you can temporarily set remote_config_minimum_fetch_interval: 0 to avoid throttling, then call ensemble.remoteConfig.refresh().
  • In production, keep a higher interval to avoid unnecessary fetches.

- Introduced RemoteConfig and RemoteConfigStub classes for handling remote configuration values.
- Implemented RemoteConfigInvokable to expose remote config functionalities.
- Added RemoteConfigService for fetching and activating remote config values.
- Updated pubspec.yaml and README.md for the new module.
- Enabled configuration through starter files for optional integration.
- Added enable_remote_config.dart script for configuring Firebase Remote Config.
- Updated package.json to include the new script.
- Registered the remote_config module in modules_scripts.ts for integration.
@sharjeelyunus sharjeelyunus self-assigned this Mar 1, 2026
…Config

- Added optional environment variables for configuring fetch timeout and minimum fetch interval.
- Updated README.md to document new environment variable settings and their usage.
- Modified RemoteConfigService to apply settings from environment variables during initialization and fetch operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant