Search code examples
swiftfirebasecrashanalyticscrashlytics

Firebase Crashlytics reporting with custom keys


I wanted to send some custom keys for each crash, say a crash identifier to identify the user reported crash from crashlytics. I see the Crashlytics API provides a method setObjectValue(forkey:) to do this, but, where in code should this be called ? Do we have any Crashlytics callback that gets triggered when a crash happens? So far I have seen, there is only a callback to know whether crash happened during the last session.

  1. So which would be the best place to add custom keys to be associated for each crash?
  2. Docs say that Crashlytics supports a maximum of 64 such key/value pairs, does it mean that we can add custom keys only for 64 crashes or how does that work ?

Solution

  • You can add custom keys whenever you want, after initializing Crashlytics. The keys would be attached to any future crash during the life of the app.

    You can have up to 64 key/value pairs (after that, they aren't saved). So if you sent into Crashlytics 64 key/value pairs, then later the app crashed, those 64 key/value pairs would be added info in the crash report which is created and sent to Fabric and Firebase at next launch of the app.

    There are no callbacks due to a crash in the app session... the app crashed and thus terminated, after all! :)