我正在尝试存储来自' app_remove'的一些数据。数据库中的事件。 它适用于appInfo.appInstanceId等标准信息。
但是如何获取userProperty值,因为它们是对象?
exports.appremoved = functions.analytics.event('app_remove').onLog(event => {
console.log(event.data);
console.log(event.data.user.Selected_Games);
const user = event.data.user;
if (user != null) {
if(user.userId != null){
admin.database().ref('/user_events/'+user.appInfo.appInstanceId + "/" + "deviceId").set(user.userId);
}
admin.database().ref('/user_events/'+user.appInfo.appInstanceId + "/" + "app_remove").set(event.data.logTime);
admin.database().ref('/user_events/'+user.appInfo.appInstanceId + "/" + "app_install").set(user.firstOpenTime);
}
});
这是event.data的console.log
的结果AnalyticsEvent {
params: { firebase_conversion: 1, firebase_event_origin: 'auto' },
name: 'app_remove',
reportingDate: '20170719',
logTime: '2017-07-19T10:57:12.920Z',
user:
UserDimensions {
deviceInfo:
{ deviceCategory: 'mobile',
deviceModel: 'WAS-LX1A',
deviceTimeZoneOffsetSeconds: 7200,
platformVersion: '7.0',
userDefaultLanguage: 'it-it' },
geoInfo:
{ city: 'Milan',
continent: '039',
country: 'Italy',
region: 'Lombardy' },
appInfo:
{ appId: 'com.example.example',
appInstanceId: '000000',
appPlatform: 'ANDROID',
appStore: 'com.android.vending',
appVersion: '1.12' },
firstOpenTime: '2017-07-17T12:37:01.320Z',
userProperties:
{ Active_Notification: [Object],
Referrer: [Object],
Selected_Games: [Object],
Selected_Sources: [Object],
Selected_Topics: [Object],
first_open_time: [Object],
user_id: [Object] },
bundleInfo: ExportBundleInfo { bundleSequenceId: 10, serverTimestampOffset: 693 } } }
答案 0 :(得分:2)
我找到了解决方案。
我做了该对象的console.log(event.data.user.Selected_Games)
UserPropertyValue { value: '4', setTime: '2017-06-27T01:22:25.375Z' }
所以要获得价值
event.data.user.userProperties.Selected_Games.value