1

Im trying to implement Crashlytics inside my iOS swift project and setting customValue for the crash report. What Im trying to achieve is the following:

  1. The user gets asked for consent for sending crash logs

  2. If the user agrees I set:

    Crashlytics.crashlytics().setUserID("user-id")
    Crashlytics.crashlytics().setCustomValue("hello", forKey: "sayHi")
    Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
    
  3. When the app crashes I want to be able to see the customValue in Crashlytics.

This doesn't seem to work. I get the crash report in Crashlytics but without the customValue.

What does work is if I set the customValue inside my test button like this:

@IBAction func testButtonTapped(_ sender: Any) {
  Crashlytics.crashlytics().setCustomValue("Testing", forKey: "test")
  fatalError() 
}

Is there a way to set a global customValue that gets added to all crashes? (in my case I want to set the identifier of the organization unit that the user is in)

Im also having trouble viewing the userId inside Crashlytics. Is it supposed to be blurred like this? (see screenshot) enter image description here

eric.rl
  • 151
  • 1
  • 7
  • 1
    Can you show the code for setting the Crashlytics customValue in context, i.e. with the code for asking for consent. The customValue needs to be set every time the app starts so if the user has already consented you still need to set them. – samaitch Jun 23 '21 at 09:23
  • @user2042632 Thank you, that solved my issue. I only put the setCustomValue when the user gave consent, but if I put it in for example didFinishLaunchingWithOptions it works like a charm. Thank you! – eric.rl Jun 23 '21 at 09:51

1 Answers1

2

@user2042632 soved the issue:

I had to put the

Crashlytics.crashlytics().setUserID("user-id")

and

Crashlytics.crashlytics().setCustomValue("hello", forKey: "sayHi")

Every time on app-start (inside didFinishLaunchingWithOptions)

eric.rl
  • 151
  • 1
  • 7