firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Add Remote Config Emulator

Open kroikie opened this issue 2 years ago • 2 comments

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:

  1. Link to RC emulator version of branch. npm link from firebase-tools root.
  2. Build the RC emulator aware JS SDK. using yarn instructions from SDK repo
  • yarn build from sdk root
  • cd firebase/packages
  • yarn link
  • cd ../packages/remote-config
  • yarn link
  • from test app root
    • yarn link firebase @firebase/app
    • yarn link firebase @firebase/remote-config
  1. Start the emulator from the test app root. firebase emulators:start --project demo-bess-project
  2. Launch RC aware emulator emulator UI. http://localhost:3000/remote-config
  3. Start the test app. npm run dev
  4. Run the RC emulator UI. GCLOUD_PROJECT=demo-bess-project FIREBASE_EMULATOR_HUB=localhost:4400 npm start from the firebase-tools-ui root.
  5. The UI of the test app should have a fetch welcome button, if that is clicked it should update the i am working well text to reflect what the selected parameter value is for the welcome_message parameter. It should initially be Hi Welcome!
  6. Select the spending_users condition of the welcome_message parameter and publish the change. Then click the fetch welcome button again. The text should update to the spending_users's value.

kroikie avatar Jun 27 '23 22:06 kroikie

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%> (ø)

... and 1 file with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jun 27 '23 23:06 codecov-commenter

Any news on this PR? 🤓

I think having an emulator for RC is crucial nowadays.

saenzramiro avatar Apr 03 '24 19:04 saenzramiro