firebase-tools
firebase-tools copied to clipboard
Add Remote Config Emulator
Description
Add Remote Config support to the Emulator Suite. The RC Emulator will allow developers to locally emulate different Remote Config parameter values and see the impact on their app.
Goals:
- Allow developers to develop their apps around different RC parameter values.
- Code to interact with the RC emulator should be the same as those to interact with RC production.
Non goals:
- Emulate client side properties to the emulated RC backend. The RC emulator will serve the parameter values that are selected regardless of the client that is fetching. Eg: An Android client app can fetch parameter values meant for the browser if the browser value is selected.
- Handle template versioning.
The RC Emulator is behind an experiment flag rcemulator
Elements added
- Server that reads local template file to populate initial in-memory template and updates in-memory template based on UI changes or changes to the local template file.
- Respond to fetch requests from client apps
- Handle template updates (PUT) requests.
- Function trigger for template updates.
Try it out
To give the RC emulator a try you will have to use changes from a couple other repos namely:
Steps to use:
- Link to RC emulator version of branch.
npm linkfromfirebase-toolsroot. - Build the RC emulator aware JS SDK. using yarn instructions from SDK repo
yarn buildfrom sdk rootcd firebase/packagesyarn linkcd ../packages/remote-configyarn link- from test app root
yarn link firebase @firebase/appyarn link firebase @firebase/remote-config
- Start the emulator from the test app root.
firebase emulators:start --project demo-bess-project - Launch RC aware emulator emulator UI.
http://localhost:3000/remote-config - Start the test app.
npm run dev - Run the RC emulator UI.
GCLOUD_PROJECT=demo-bess-project FIREBASE_EMULATOR_HUB=localhost:4400 npm startfrom thefirebase-tools-uiroot. - The UI of the test app should have a
fetch welcomebutton, if that is clicked it should update thei am working welltext to reflect what the selected parameter value is for thewelcome_messageparameter. It should initially beHi Welcome! - Select the
spending_userscondition of thewelcome_messageparameter and publish the change. Then click thefetch welcomebutton again. The text should update to thespending_users's value.
Codecov Report
Attention: 150 lines in your changes are missing coverage. Please review.
Comparison is base (
27957b3) 54.72% compared to head (36aa731) 54.47%.
Additional details and impacted files
@@ Coverage Diff @@
## master #6045 +/- ##
==========================================
- Coverage 54.72% 54.47% -0.26%
==========================================
Files 346 349 +3
Lines 23723 23915 +192
Branches 4877 4914 +37
==========================================
+ Hits 12983 13027 +44
- Misses 9543 9689 +146
- Partials 1197 1199 +2
| Files | Coverage Δ | |
|---|---|---|
| src/emulator/constants.ts | 76.08% <ø> (ø) |
|
| src/emulator/portUtils.ts | 47.48% <ø> (ø) |
|
| src/emulator/registry.ts | 82.25% <ø> (ø) |
|
| src/emulator/types.ts | 46.73% <100.00%> (+1.18%) |
:arrow_up: |
| src/experiments.ts | 56.81% <ø> (ø) |
|
| src/emulator/controller.ts | 12.56% <12.50%> (-0.01%) |
:arrow_down: |
| src/emulator/functionsEmulator.ts | 7.45% <0.00%> (-0.11%) |
:arrow_down: |
| src/emulator/remoteconfig/server.ts | 11.42% <11.42%> (ø) |
|
| src/emulator/remoteconfig/cloudFunctions.ts | 16.66% <16.66%> (ø) |
|
| src/emulator/remoteconfig/index.ts | 28.86% <28.86%> (ø) |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Any news on this PR? 🤓
I think having an emulator for RC is crucial nowadays.