0

I am looking for a way where i can count user firebase calls made to user node in firebase or to it's child nodes. my Firebase structure looks like below:

users/uid1/xyz - user 1
users/uid2/abc - user 2

is there a way to count calls made by web app to access uid1 node or it's below child nodes done for any read , write operation for user 1.

kapoorji
  • 158
  • 12

1 Answers1

1

There is no public API to count the number of Firebase API calls. You could wrap the API with you own function to do the counting.

var ref = firebase.database().ref();
function updateUser(uid, userObj) {
    ref.child('users').child(uid).set(userObj);
    ref.child('userUpdateCount').transaction(function(currentValue) {
        return (currentValue || 0) + 1;
    });
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks Frank, yes i was thinking to wrap my firebase calls for update and read but using transactions sometimes i face transaction Disconnect issue and was thinking to replace all transactions with once followed by update? Would it have some performance impact as i cannot take risk of transactions in production.. – kapoorji Jul 26 '16 at 07:54
  • Frank, wouldn't this be making another call just to count one? In a traditional analytics based API, count the data points is mandate, and one cannot burden their users, with this transaction each time data interaction happens. Any other way of doing this in firebase? – anshulix Jul 31 '16 at 10:53