Search code examples
androidfirebaselogginganalyticscrashlytics

Can I do normal logs in Firebase Crashlytics?


If I want to send logs in Firebase Crashlytics, can I do that? For example, I have a fragment and whenever someone goes to that screen, I want to send a log/indicator that this person went to this screen. I just want to see how many people went to the screen. Usually, logs in Crashltyics can be seen when there is a crash but for this case, it is not crashing the app.

Thank you


Solution

  • when you read the Firebase Analytics you can see how to send a log in Firebase without Crash. Actually it's a different way and different product in Firebase.

    If you want you can read the tutorial article in the below https://firebase.google.com/docs/analytics/events?platform=android

    Or you can follow these steps

    1. add in gradlle

      implementation 'com.google.firebase:firebase-analytics:${latestversion}'

    2. Declare the FirebaseAnalytics object at top of your activity

      Kotlin -> private lateinit var firebaseAnalytics: FirebaseAnalytics

      Java -> private FirebaseAnalytics mFirebaseAnalytics;

    3.Initialize it in the onCreate()

    Kotlin -> firebaseAnalytics = FirebaseAnalytics.getInstance(this)

    Java -> mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    1. The following example demonstrates how to log a SELECT_CONTENT event:()

    Kotlin ->

    val bundle = Bundle()
        bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id)
        bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name)
        bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image")
        firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle)
    

    Java ->

     Bundle bundle = new Bundle();
        bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
        bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
        bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
        mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);