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?
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).
You need to select the issue, click in more details and at the top right corner you can see a label with Identifier.
You need to set it every time you initialise the Crashlytics. At least doing this it works.
if you are using this Crashlytics.setUserIdentifier(""); you can check in data tab in firebase. Fabric.with(this, new Crashlytics()); working fine.
If you look into codes of FirebaseCrashlytics than you can see that userId is being saved into the session. So I am sure that after restarting application your id will be restored.
Related
Sorry for the ambiguity in the question but it is actually quite a simple one.
When my android Application boots up I initialize AppCenter as follows:
AppCenter.start(
this, BuildConfig.APP_CENTER_SECRET,
Analytics::class.java, Crashes::class.java, Distribute::class.java
)
if(BuildConfig.FLAVOR != ApplicationVariants.ProductFlavors.PRODUCTION){
AppCenter.setLogLevel(Log.VERBOSE)
}
AppCenter.setUserId(UUID.randomUUID().toString())
Distribute.setUpdateTrack(UpdateTrack.PUBLIC)
Distribute.checkForUpdate()
However, when the user logs into the application I would like to set the UserId to the users email as follows once the user logs in:
JwtUtils.getIdentityTokenModel(requireContext())?.let {
AppCenter.setUserId(it.email)
}
Lastly when the user logs out I reset the user Id to a random guid. The reason for this is visibility on which user has which crash logs. This is a requirement from business.
However, in the app center crash logs, it seems the UserId never changes to the email even if an error occurs while the user is logged in.
My question is simple. Is there a restriction on how many times I am allowed to change the AppCenter User Id? I cannot seem to find it anywhere in the docs.
Thanks in advance
Please see these docs about userId API:
The value for the user ID is limited to 256 characters. It will be
shown with your crash reports but not used for aggregation or counts
of affected users. In case you set user ID multiple times, only the
last user ID will be used. You need to set the user ID yourself before
each application launch, because this value isn't stored by the SDK
between launches.
A useful feature from Crashlytics by Firebase is to set a userID for a session, to later look up that particular user's crash events.
It doesn't seem to be working in my Android app however. I am debugging with my device. Here is the DebugView of my device:
Where the user_id is properly set via setUserID on the Firebase Analytics object.
I then triggered a crash. But...
It can't find my userID? (I can find the crash I triggered though.)
I don't even know what else to try, according to DebugView the userID was properly set?
Well, it was as simple as:
FirebaseAnalytics.getInstance(this).setUserId(uuid); // wrong
Crashlytics.setUserIdentifier(uuid); // correct
Was overlooking "FirebaseCrashlytics" vs "FirebaseAnalytics" https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android
After getting first crash on installed application, you can search with the user id in Firebase Crashlytics
FirebaseCrashlytics.getInstance().setUserId(uuid);
Add FirebaseCrashlytics.getInstance().setUserId(uuid); in all screens (activities). If you add only in login screen then userid will not share to crashlytics, when app is crashed after reopening. Since we will ask user to login only once.
In Sep 2021 using -
com.google.firebase:firebase-bom - version 28.4.0
com.google.firebase:firebase-analytics-ktx - version 19.0.1
com.google.firebase:firebase-crashlytics-ktx - version 18.2.1
I resolved this with : FirebaseCrashlytics.getInstance().setUserId();
I have an Android app, which the user can link to Spotify, with :
AuthenticationClient.openLoginActivity(getActivity(), SPOTIFY_REQUEST_CODE, request);
The problem is that I want the user to change his Spotify account so I want to logout the user from Spotify to log with another account. But the data of the connection are saved in the cache and when I use this line again :
"AuthenticationClient.openLoginActivity(getActivity(), SPOTIFY_REQUEST_CODE, request);", it does not show the connection dialog because the user is already connected.
In the doc, it says :
"To log out and clear all stored tokens, use the AuthenticationClient#clearCookies method. Both Spotify and Facebook tokens will be removed."
But the method clearCookies does not exist anymore. What can I do to logout the user and allow him to connect on another account ?
I've searched on the net and seems that this code
AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID, type, redirectUri)
.setShowDialog(true)
.setScopes(scopes).build();
took from this post it's your only choice to try to logout a user.
I can't test it, so you should try it yourself and see if works.
The documentation on the Spotify Android SDK is outdated and is not reflecting the new Spotify auth library on GitHub.
Spotify's Android SDK documentation is definitely outdated. My observation is that when you call
AuthorizationClient.clearCookies(context)
directly before starting Spotify's auth activity, it just works fine. But if you call it once and then expect that the user is logged out, when you start the activity later in the future, cached credentials keep messing around.
I do not prefer
builder.setScopes(arrayOf("")).setShowDialog(false).build()
as it shows you a "not you? Click to log out" option. So basically you need to log out on the Spotify UI, cannot do it from code.
In my case, the application saves the logged in user's email (I need that to show on the UI, anyway). When I want to log the user out programmatically, I just delete the saved email from the app and call
clearCookies()
when I start Spotify's Activity if the variable is empty.
A bit late, but you can use this AuthorizationClient.clearCookies(this) as
AuthenticationClient no longer exists
I'm using this code to analyse the sign_up method user is using:
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.SIGN_UP_METHOD, "sign_up_method");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SIGN_UP, bundle);
as soon as the user sign up, above given code is supposed to save the event in the Firebase console.
The problem is that the event is getting created but the there's nothing under the value column, i.e., sign_up_method is not getting shown.
Here's a snapshot from the console (event name: sign_up is there but in place of the sign_up_method, there is a -):
What's going wrong here?
Please let me know.
I asked the same question from the Firebase Support Team and they told me that
Unfortunately, not all parameters are represented directly in your
Analytics reports. It is only available on a subset of suggested
events. But they can be used as filters in Audience definitions for
every report. They are also included in data exported to BigQuery if
your app is linked to a BigQuery project.
So, either link your app to BigQuery or get satisfied with what Firebase has to provide.
Please check the Firebase Analytics docs for this. Looks like you are incorrectly setting the parameter as FirebaseAnalytics.Param.SIGN_UP_METHOD
It should be FirebaseAnalytics.Param.METHOD instead
I am trying to set user information to crash reports in crashlytics in Android App, so that it will help me to find out which of our users experienced a given crash. I have explored and found there are 3 APIs can set user information in crash report.
Those are,
void Crashlytics.setUserIdentifier(String identifier);
void Crashlytics.setUserName(String name);
void Crashlytics.setUserEmail(String email);
It is recommended to use all the APIs. All documented at http://support.crashlytics.com/knowledgebase/articles/120548-how-do-i-set-user-information-
But I have no idea,
1. How to get user-identifier, name and email details, which are input to those APIs?
2. Which place in program to call these crashlytics APIs?
Please share some ideas, how to implement this.
Regards
Annada
Looks like detail UI in Fabric has been changed.
Select one of crash issue.
Click Version in Recently Activity
On detail page top right hand corner, you should see affected user information.
If your application uses some form of user identification (i.e. login, email, phone, device specific id) you can use that as crashlitics user information. I suppose you can generate user id when your app is first launched and save it in shared preferences, for example. It'll be shown at top-right corner of detailed crash view.
i.e. I set ID and name as soon as user authenticates in my app.
You typically want to set them as soon as possible (as your data arrives) and all info has been initialized.
For new Firebase api
FirebaseCrashlytics.getInstance().setUserId("12345")
For More
Customize your Firebase Crashlytics crash reports