How to clear/remove firebase Crashlytics custom keys?
Asked Answered
M

2

14

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);
Milurd answered 1/2, 2021 at 13:55 Comment(0)
L
2

Th next code will literally remove the value. You will not see it anymore in reports, it will disappear. It works exactly like Dictionary works, when you set nil value, this key is being removed.

Crashlytics.crashlytics().setCustomValue(nil, forKey: "key")
Lasonde answered 19/12, 2023 at 7:3 Comment(0)
F
0

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.

Fanfaron answered 19/7, 2021 at 17:26 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.