Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 当用户卸载应用程序时,如何在云功能中获取firebase UID?_Node.js_Firebase_Google Cloud Functions_Firebase Analytics - Fatal编程技术网

Node.js 当用户卸载应用程序时,如何在云功能中获取firebase UID?

Node.js 当用户卸载应用程序时,如何在云功能中获取firebase UID?,node.js,firebase,google-cloud-functions,firebase-analytics,Node.js,Firebase,Google Cloud Functions,Firebase Analytics,我想通过firebase分析触发器功能检测应用程序卸载事件。Firebase功能如下所示 exports.appUninstall = functions.analytics.event('app_remove').onLog(event => { const user = event.user; const uid = user.userId; var time = Date.now(); var order

我想通过firebase分析触发器功能检测应用程序卸载事件。Firebase功能如下所示

   exports.appUninstall = functions.analytics.event('app_remove').onLog(event => {
    
     const user = event.user;    
     const uid = user.userId; 

     var time = Date.now();      
     var orderKey = 9999999999999 - Date.now();  
         
     var updateMap = {};
     
     updateMap["time"] = time;
     updateMap["orderKey"] = orderKey;
     updateMap["uid"] = uid;
                          
     updateMap['/Uninstalls/'+ uid] = updateMap;
                           
     return admin.database().ref().update(updateMap);
      
     
});
但它显示了以下错误属性“uid”中未定义

Error: Reference.update failed: First argument contains undefined in property 'uid'
at validateFirebaseData (/workspace/node_modules/@firebase/database/dist/index.node.cjs.js:1481:15)
at /workspace/node_modules/@firebase/database/dist/index.node.cjs.js:1601:9
at each (/workspace/node_modules/@firebase/database/dist/index.node.cjs.js:554:13)
at validateFirebaseMergeDataArg (/workspace/node_modules/@firebase/database/dist/index.node.cjs.js:1599:5)
at Reference.update (/workspace/node_modules/@firebase/database/dist/index.node.cjs.js:13838:9)
at exports.appUninstall.functions.analytics.event.onLog.event (/workspace/index.js:1012:36)
at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:134:23)
at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:199:28)
at process._tickCallback (internal/process/next_tick.js:68:7) 

我知道我做错了什么。如何正确操作?

如果我没有弄错,您需要使用
setUserId
API设置用户ID。有关如何为每个平台(Android、iOS等)执行此操作的更多详细信息,请参阅。然后,你将能够在你的云函数中得到它,以及你问题的代码