简体   繁体   中英

Crashlytics - How to add Custom Keys - Eclipse

I am trying to work with Crashlytics. The setup is done with eclipse and the sessions are logging in fine. But the sessions are get logged for Activities. For ex., com.xxx.xx.MainActivity, com.xxx.xx.SplashActivity and so on. What should i do to make Custom Event logs? For ex., log the event when user clicks on a button in an activity?

I tried

Crashlytics.log(0, "MainActivity", "Button Clicked");

Crashlytics.setString("MainActivity", "logged_in");

but i don't see any reports in my dashboard with name "MainActivity" or "Button Clicked" or "logged_in". Is there a way to set these custom events?

I don't believe Crashlytics has that capability yet. I asked support in late November about this and they said that is was on the roadmap. This is a quote from one of their support emails.

Custom events is definitely on our roadmap for Answers, the team is heads down on it right now.

You may have to use another provider for now until they implement this.

First of all, you need to initialize Crashlytics when your app is launched.

Crashlytics.start(this);

After that you can log your custom events. These will appear in your issues list as "non-fatals". I do it like this:

Crashlytics.logException(new Exception("Error: Something bad happened!!!"));

You can set your Custom Keys as well. CrashlyticsCustomKeys is my custom class where I have defined all my keys for a project as String constants. For example:

Crashlytics.setString(CrashlyticsCustomKeys.CRASHLYTICS_SOME_STRING_KEY, "text");

When some exception or your custom log would appear after you've set some custom key, you'll see these keys and their values in issue detail after click on "(More details...)" link.

Just adding information for the answer above, there is another way to do that if you are using CrashlyticsCore :

As noticed on the Fabric documentation :

If you are using CrashlyticsCore instead of Crashlytics, then you'll use its instance below. For example: CrashlyticsCore.getInstance().log.

So, to set one key value using setString using CrashlyticsCore , you can use the code below:

CrashlyticsCore.getInstance().setString("Key", "value");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM