Safeguarding App Integrity: Monitoring Firebase Config Updates with Slack

Pallav Trivedi
We Are BookMyShow
Published in
5 min readJan 10, 2024

--

In the dynamic world of mobile app development, Firebase Remote Config has revolutionized how developers fine-tune app features on the fly. Yet, with this capability comes the responsibility of managing changes effectively. This article explores how our team seamlessly integrated Firebase Remote Config with Slack, establishing a robust system that ensures transparency and accountability in our update processes.

The Crucial Role of Firebase Remote Config:

Firebase Remote Config serves as the backbone of our app development, providing the means to control various features without the need for a new release. As a result, keeping a watchful eye on any modifications becomes imperative to maintaining a stable and reliable user experience.

Further, our development process heavily relies on A/B tests to refine user experience continually, and Firebase Remote Config plays a pivotal role in orchestrating these tests. Monitoring changes takes on added significance in this context, as even the slightest unintended alteration could disrupt ongoing tests and compromise the reliability of collected data.

So with multiple team members having the access to make changes, maintaining control and oversight becomes paramount. Unreviewed modifications to Firebase Remote Config settings pose the risk of disrupting production, potentially leading to business losses and adverse effects on user satisfaction.

Leveraging Google Cloud Functions for Seamless Integration:

To address these challenges, we utilised the capabilities of Google Cloud Functions, and integrated them with Firebase for listening to Remote Config changes. In brief, we used Firebase Admin SDK for authentication, and wrote a function in Node.js which gets triggered by the onConfigUpdate event from Firebase.

Let’s delve into the specifics -

Firebase stores our remote configuration in templates, associating each with a version. Put simply, these templates consist of JSON structures containing parameters and conditions that you define.

When a configuration is updated, the corresponding template undergoes a change, updating the version as well. Utilizing this version-template mapping, we can detect differences and disseminate them through emails, Slack channels, or other chosen platforms.

The challenge now is determining when a change occurred, enabling the execution of the previously mentioned logic for template comparisons.

For this, Firebase provides APIs for automating the updating of remote configurations programmatically, allowing you to monitor changes effectively. Explore more about it here.

However, utilizing these APIs requires authentication. This is where the Firebase Admin SDK comes into the play. Detailed setup instructions can be found here.

By leveraging the Firebase Admin SDK, you can obtain the necessary authentication tokens essential for utilizing these APIs and remotely reading the configurations. Furthermore, the Firebase Admin SDK is versatile and can seamlessly integrate with backend APIs, custom tools, and even Google Cloud Functions for convenience.

https://firebase.google.com/docs/remote-config/automate-rc

Let’s break down the process step by step:

  • Install Firebase CLI:
    Execute the command: npm install -g firebase-tools
  • Log in to Firebase:
    Use the command: firebase login
  • Initialize Firebase Project:
    Execute firebase init

This prompts for essential inputs:
- Select the Firebase feature, opting for Configuring a Cloud function.

Choose an existing project or select from the list.

Specify your preferred language: JavaScript, TypeScript, or Python.

Upon completion, Firebase automatically generates files in the project directory. For JavaScript, you’ll find a ‘function’ directory containing index.js, package.json, package-lock.json, and the ‘node_module’ directory for dependencies.

  • Write the Code:
  • Open index.js in your preferred IDE and write code for:
    - Initializing the app using Firebase Admin SDK.
    - Creating a function to listen for onConfigUpdate.
    - Inside the function, retrieve the access token from the Admin SDK.
    - Make calls to fetch remote config.
    - Conduct two calls, one for the current version and one for the previous version.
    - Compare the responses to identify differences. External dependencies like json-diff can be utilized for this purpose.

Integrating Slack for Real-time Awareness:

Ensuring real-time awareness became achievable through the integration of a Slack app into our chosen channels for monitoring updates. This app, linked via a webhook, delivers prompt notifications about differences in Firebase Remote Config versions. This instantaneous alert system enables our team to swiftly review and validate any modifications.

  • If you have the slack app already setup, get its web hook URL, and send a post request to it with your stringified differences as the body.
  • In case you don’t have the slack app, you can create it following these steps, install it in the channel where you want the notifications, and can use its web hook URL.

And it’s done 🍻

In the ever-evolving landscape of mobile app development, our integration of Firebase Remote Config with Slack has proven to be a crucial asset.

This streamlined process for monitoring and notifying changes has significantly mitigated the risks associated with unintended alterations. Our proactive approach not only safeguards our production environment but also ensures the reliability of A/B tests, contributing to a more robust and stable user experience. As we grow and adapt, this integration serves as a clear testament to how crucial it is to uphold integrity in our app development practices.

🍻 Here’s to smooth sailing with your configuration updates! Happy Coding :)

--

--

Engineering Manager @BookMyShow ; Previously @ Hungama Digital Media, Built.io, Reliance Jio