How can I get the total number of active installs for my app on firebase?

3.8k Views Asked by At

The first display in the Analytics Dashboard on Firebase shows total active users.

My understanding is that this is showing the amount of users who use the app within a given period. However, some of these users may have since uninstalled the app. Is there a separate number which shows the number of total installs? I simply need to know the number of users who have my app actively installed at any given time.

Active installs of the app, not necessarily the number of authenticated users.

1

There are 1 best solutions below

4
Sean Rahman On BEST ANSWER

Looking through the firebase API, this webpage will be you're best bet

https://firebase.google.com/docs/auth/admin/manage-users

Scrolling down it has a section labled "List all users" not for sure what language you're using but in Node.js it is

function listAllUsers(nextPageToken) {
  // List batch of users, 1000 at a time.
  admin.auth().listUsers(1000, nextPageToken)
    .then(function(listUsersResult) {
      listUsersResult.users.forEach(function(userRecord) {
        console.log('user', userRecord.toJSON());
      });
      if (listUsersResult.pageToken) {
        // List next batch of users.
        listAllUsers(listUsersResult.pageToken);
      }
    })
    .catch(function(error) {
      console.log('Error listing users:', error);
    });
}
// Start listing users from the beginning, 1000 at a time.
listAllUsers();

The above will make sure you have a list off all authenticated users. Simply combine that with

exports.appUninstall = functions.analytics.event('app_remove').onLog(event => {
  const user = event.user; // structure of event was changed            
  const uid = user.userId; // The user ID set via the setUserId API.

  // add code for removing data
});

And remove the userID and decrement the active users by 1 to have a general sense of installed apps.

hopefully this works better.