androidcrashlyticscrashlytics-android

Get user information in Crashlytics


I am using Crashlytics in my application and I wanted to get user id and email along with each crash. I did something like this:

Crashlytics.setUserEmail(tokenModel.getEmail());
Crashlytics.setUserIdentifier(String.valueOf(tokenModel.getPk()));

I am doing this in my login screen, after the user has provided his email and successfully registered with the app, so as to get user id. The problem is, I am not getting these data in the crash reports.

What is the lifecycle and working of Crashlytics in above context? Do I need to set these fields every time the app opens?


Solution

  • I am not sure if it needs to be done every time you launch the app and the Crashlytics docs don't explicitly say it neither.

    I know that we do it with every launch and it works - provided user info is displayed properly in the dashboard.

    My suggestion would be to try send this information every time you initalize Crashlytics with Fabric.with(this, new Crashlytics());, as soon as you have your user data provided (for example after fetching his user profile from your server).