I am trying to create a new entry (with userid) in my firebase database as soon as a user removes my app. (Qndroid)
'use strict';
const admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp(functions.config().firebase);
exports.appremoved = functions.analytics.event('app_remove').onLog(event => {
console.log("App remove detected");
var user = admin.auth().currentUser;
var uid;
const uid2 = event.data.user.userId;
console.log("App remove detected2:" + uid2);
if (user != null) {
uid = user.uid;
console.log("User object not empty" );
admin.database().ref('/user_events/'+uid + "/"+Date.now()).set("app_remove");
}
});
I created two variables to get the user id, but both of them are undefined.
uid2 is undefined, and user is null.
I also tried
const user = event.data.user;
But it is also null
How do I get the userid of the user that removed the app?