Firebase user count per provider
In this post, I want to share a tiny NodeJS based tool for getting quick statistics on how many users are signed up with what provider in your firebase project.
If you want to get right into it, check out the repository:
GitHub - ddikman/firebase-provider-stats: Tiny nodejs based tool to calculate some quick stats…
Tiny nodejs based tool to calculate some quick stats based on Firebase Auth. Because I needed to figure out if my…
Save time with Firebase authentication
One of the core features I love with Firebase the authentication system which mostly removes the need to code this yourself. Something is usually a core requirement but rarely a core feature can now be done in an hour or less.
With Firebase auth you configure the login provider you want to use and usually there is only a few lines of code and a button to do the rest.
Firebase auth has support for Google, Apple, Facebook, Twitter, and Github authentication out of the box. It is possible to support other OAuth solutions as well but it will require a bit more work.
But more is not always better
Since it is relatively easy to adding providers, when I first built my app I thought I would add every provider. The idea was to make signing up as easy as possible instead of being a point of friction. I added email, Google and Apple login as well as Facebook straight away.
However, as time went by I was influenced by the Apply Guidelines that state that as much as possible of the functionality ought to be accessible to everyone without login.
Ask people to create an account only if your app’s core functionality requires it; otherwise, let people enjoy your app without one.
Also, in our team building FACY, we had another related discussion about the need for social logins. We concluded that if you have an Android device, you will most likely have a Google account and similarly if you have an iOS device you will have to have an Apple account. So really, all you need to support are these two. They area also by far the quickest and easiest ways to sign up as it is a single button tap (and sometimes a thumbprint) away.
More options make it harder for a user to choose and even if it is simple, any configuration needs maintenance.
Time to reduce the number of providers?
The other day I received a warning that the Facebook provider package I was using was getting out of date. I’ve also got intermittent notices from Facebook Developers to keep my information up to date. This made me question the benefit of supporting Facebook.
How many registered users do I actually have? If there aren’t too many, perhaps I can ditch it.
Checking provider user count
The Firebase auth works very well in what it does but it will not allow you to easily query the information. You can loop through users but you can’t do any queries on the data such as you would in SQL, like
select count(*) from users where provider = ‘facebook’.
But the Firebase CLI comes with tools to download all registered users and their provider info, using this we can query it locally.
⚠️ Note! The files downloaded will contain user emails and phone numbers so be careful, you don’t want this to get in the wrong hands.
The CLI tool allows downloading data in either CSV or JSON however, the CSV version doesn’t contain the provider information (as one user may have more than one provider). So, even though it would be easy to sum the user count in CSV using Excel or Google Sheets, I had to parse the JSON data.
So for this reason, I put together the firebase-provider-stats CLI. With this tool, in three lines you’ll have your provider usage:
This will give you not only the total provider registrations but also, how many were active in the past month.
The output you need
In your specific case, you may want to use this data differently so fork the repository and you can format the data as you like.
You will find a small section in the index.js that pulls out the user-specific data:
I hope the above helps and if nothing else, can be an example on how to use Firebase authentication and the data stored inside.
If you are using Firebase and found this helpful, you might also be interested in my other Firebase related stories, check them out!
Thank you for reading.