1

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

Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77
calvert
  • 631
  • 10
  • 33

2 Answers2

1

For this, you dont need to use Crashlytics, instead, use Firebase Events

Check: https://firebase.google.com/docs/analytics/events?platform=android

You can also combine, Firebase Events with Funnels

Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77
1

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);
  • Thank you, I will try this in a bit – calvert Oct 24 '19 at 20:12
  • 1
    BTW you can use the this code same time for crashlytics https://firebase.google.com/docs/crashlytics/customize-crash-reports?authuser=2&platform=android Crashlytics.log(Log.DEBUG, "tag", "message"); – Ozan türcan Oct 25 '19 at 07:04