Add scene_view action
This commit is contained in:
1 parent
3214bae157
commit
8c3796605e
4 files changed
+30
-3
No files matched your search
@@ -17,14 +17,32 @@
|
||||
package com.hippo.ehviewer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
|
||||
|
||||
public final class Analytics {
|
||||
|
||||
private static FirebaseAnalytics analytics;
|
||||
|
||||
private Analytics() {}
|
||||
|
||||
public static void start(Context context) {
|
||||
FirebaseAnalytics.getInstance(context).setUserId(Settings.getUserID());
|
||||
analytics = FirebaseAnalytics.getInstance(context);
|
||||
analytics.setUserId(Settings.getUserID());
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return analytics != null && Settings.getEnableAnalytics();
|
||||
}
|
||||
|
||||
public static void onSceneView(SceneFragment scene) {
|
||||
if (isEnabled()) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("scene_simple_class", scene.getClass().getSimpleName());
|
||||
bundle.putString("scene_class", scene.getClass().getName());
|
||||
analytics.logEvent("scene_view", bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user