In my android application, I have an Activity that has 3 or 4 fragments that can be attached in sequence based on some user or server events.
在我的Android应用程序中,我有一个Activity,它有3个或4个片段,可以根据某些用户或服务器事件按顺序连接。
I would like to track all these fragments as screens in firebase.
我想跟踪所有这些片段作为firebase中的屏幕。
So ideally, if possible, is there an API i can invoke in the onCreate of the fragments, and tell firebase that user is currently in fragment1, fragment2 or fragment3?
理想情况下,如果可能的话,是否有一个我可以在片段的onCreate中调用的API,并告诉firebase用户当前是在fragment1,fragment2还是fragment3?
1 个解决方案
#1
29
There is a special method to set a current screen - setCurrentScreen
有一种特殊的方法来设置当前屏幕--setCurrentScreen
I used it as follows
我用它如下
mFirebaseAnalytics.setCurrentScreen(this, fragment.getClass().getSimpleName(), fragment.getClass().getSimpleName());
Once the method is called, the following message appears in the LogCat
调用该方法后,LogCat中将显示以下消息
Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=HomeFragment, firebase_previous_id(_pi)=4121566113087629222, firebase_previous_screen(_pn)=HomeFragment, firebase_screen_class(_sc)=StatisticsFragment, firebase_screen_id(_si)=4121566113087629223, firebase_screen(_sn)=StatisticsFragment}]
记录事件(FE):screen_view(_vs),Bundle [{firebase_event_origin(_o)= auto,firebase_previous_class(_pc)= HomeFragment,firebase_previous_id(_pi)= 4121566113087629222,firebase_previous_screen(_pn)= HomeFragment,firebase_screen_class(_sc)= StatisticsFragment,firebase_screen_id (_si)= 4121566113087629223,firebase_screen(_sn)= StatisticsFragment}]
The following event appears on auto activity tracking:
自动活动跟踪中会显示以下事件:
Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=StatisticsFragment, firebase_previous_id(_pi)=4121566113087629223, firebase_previous_screen(_pn)=StatisticsFragment, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=4121566113087629224}]
记录事件(FE):screen_view(_vs),Bundle [{firebase_event_origin(_o)= auto,firebase_previous_class(_pc)= StatisticsFragment,firebase_previous_id(_ pi)= 4121566113087629223,firebase_previous_screen(_pn)= StatisticsFragment,firebase_screen_class(_sc)= LoginActivity,firebase_screen_id (_si)= 4121566113087629224}]
As you see, they are almost the same, so setCurrentScreen
is working.
如您所见,它们几乎相同,因此setCurrentScreen正在工作。
I'm able to see those classes in Firebase Console only on the next day. It is normal for Firebase - it takes time to process such amounts of data.
我只能在第二天在Firebase Console中看到这些类。 Firebase是正常的 - 处理此类数据需要时间。
#1
29
There is a special method to set a current screen - setCurrentScreen
有一种特殊的方法来设置当前屏幕--setCurrentScreen
I used it as follows
我用它如下
mFirebaseAnalytics.setCurrentScreen(this, fragment.getClass().getSimpleName(), fragment.getClass().getSimpleName());
Once the method is called, the following message appears in the LogCat
调用该方法后,LogCat中将显示以下消息
Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=HomeFragment, firebase_previous_id(_pi)=4121566113087629222, firebase_previous_screen(_pn)=HomeFragment, firebase_screen_class(_sc)=StatisticsFragment, firebase_screen_id(_si)=4121566113087629223, firebase_screen(_sn)=StatisticsFragment}]
记录事件(FE):screen_view(_vs),Bundle [{firebase_event_origin(_o)= auto,firebase_previous_class(_pc)= HomeFragment,firebase_previous_id(_pi)= 4121566113087629222,firebase_previous_screen(_pn)= HomeFragment,firebase_screen_class(_sc)= StatisticsFragment,firebase_screen_id (_si)= 4121566113087629223,firebase_screen(_sn)= StatisticsFragment}]
The following event appears on auto activity tracking:
自动活动跟踪中会显示以下事件:
Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=StatisticsFragment, firebase_previous_id(_pi)=4121566113087629223, firebase_previous_screen(_pn)=StatisticsFragment, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=4121566113087629224}]
记录事件(FE):screen_view(_vs),Bundle [{firebase_event_origin(_o)= auto,firebase_previous_class(_pc)= StatisticsFragment,firebase_previous_id(_ pi)= 4121566113087629223,firebase_previous_screen(_pn)= StatisticsFragment,firebase_screen_class(_sc)= LoginActivity,firebase_screen_id (_si)= 4121566113087629224}]
As you see, they are almost the same, so setCurrentScreen
is working.
如您所见,它们几乎相同,因此setCurrentScreen正在工作。
I'm able to see those classes in Firebase Console only on the next day. It is normal for Firebase - it takes time to process such amounts of data.
我只能在第二天在Firebase Console中看到这些类。 Firebase是正常的 - 处理此类数据需要时间。