How to clear/remove firebase Crashlytics custom keys?

Viewed 700

You can associate arbitrary key/value pairs with your crash reports by FirebaseCrashlytics.getInstance().setCustomKey(key, value)

Fine.
But how can I revert those when I don't need anymore?

Consider following code:

// report 'ex_1' with "info" key
FirebaseCrashlytics.getInstance().setCustomKey("info", "abc");
FirebaseCrashlytics.getInstance().recordException(ex_1);

//Now I want to clear custom keys, so I want to report 'ex_2' without "info"
//FirebaseCrashlytics.getInstance().REMOVECustomKey("info");
FirebaseCrashlytics.getInstance().recordException(ex_2);
1 Answers

I don't see anything in the SDK that allows for this. They should really offer some way to clear the Custom Keys but the SDK does not allow for nullable values either.

The way I went around it was just to override the one-shot custom keys with a 0.

// Set key
FirebaseCrashlytics.getInstance().setCustomKey("key", "value")

// Clear key
FirebaseCrashlytics.getInstance().setCustomKey("key", 0)

It is not the cleanest approach but at least you know those values got reset.

Related