Reputation: 447
I'm new to the Crashlytics
and I have just started using it after Google bought them (aka FirebaseCrashlytics SDK without Fabric). I have tried the documents and emailing Firebase on how to do the customize report, but didn't get an answer I was looking for. Also, the document Crashlytics.sharedInstance()
don't have shareInstance popup when I type Crashlytics. Here is one of the crashes I have and I would like to use the custom log to help me find out more about the crashes.
var sectionHeaderForSelectedDate: [ChartData] = [] //Section Headder
var cellInSectionForSelectedDate: [[ChartData]] = [] //Cell in section
override func viewDidLoad() {
super.viewDidLoad()
setupScreen()
}
func setupScreen() {
if sectionHeaderForSelectedDate[0].value[0].date.convertDateToString(dateFormat: .dayOfWeekMonthDayYear) != "" {
self.title = "\(sectionHeaderForSelectedDate[0].value[0].date.convertDateToString(dateFormat: .dayOfWeekMonthDayYear)) Sums"
}
tableView.delegate = self
tableView.dataSource = self
for (index, metricItem) in sectionHeaderForSelectedDate.enumerated() {
tableViewData.append(cellData(opended: false, title: metricItem.name,
sectionData: cellInSectionForSelectedDate[index]))
}
tableView.reloadData()
}
According to me, the crash has happened in the setupScreen()
and I would like to have a log to actually tell me if my segue
from another viewcontroller
is passing value to my variable (sectionHeaderForSelectedDate
and cellInSectionForSelectedDate
). How do I do it and where should I put the code in the function?
Thank you and please correct me if any of my comments about Crashlytics is incorrect.
Upvotes: 1
Views: 1670
Reputation: 447
I didn't know Crashlytics has the beta version for the crash report with the correct syntax. I found it and tested it out it is working now! I used the debug example codes from Firebase to tested the report. Please check out the codes and the screenshots.
FirebaseCrashlytics Customize Crash Report
override func viewDidLoad() {
super.viewDidLoad()
documentPicker.delegate = self
documentPicker.allowsMultipleSelection = false
if isFromChatBot == true {
showIntakeOptions()
}
let button = UIButton(type: .roundedRect)
button.frame = CGRect(x: 20, y: 50, width: 100, height: 30)
button.setTitle("Crash", for: [])
button.addTarget(self, action: #selector(self.crashButtonTapped(_:)), for: .touchUpInside)
view.addSubview(button)
Crashlytics.crashlytics().setCustomValue("\(isFromChatBot)", forKey: "viewdeloadTest")
Crashlytics.crashlytics().log("viewdeloadTestForCrash")
}
@IBAction func crashButtonTapped(_ sender: AnyObject) {
Crashlytics.crashlytics().setCustomValue("test", forKey: "test1")
Crashlytics.crashlytics().log("crashbuttonTapped")
//Analytics.logEvent("Setup screen", parameters: nil)
fatalError()
}
Upvotes: 2
Reputation: 13281
That's when you will need the good FirebaseAnalytics
.
You can send logs in each of your necessary events, like so:
Analytics.logEvent("Setup screen", parameters: nil)
Make use of the eventName
, and parameters
.
After this, when the crash happens and you have a logged event before that, you will see this information in your LOGS tab.
Upvotes: 0