Various Sentry configuration tweaks to make it more usable

This commit is contained in:
Stefan Ceriu
2023-08-09 14:28:30 +03:00
committed by Stefan Ceriu
parent 1bfd5e89ca
commit f649d362f5
@@ -61,23 +61,34 @@ class BugReportService: NSObject, BugReportServiceProtocol {
func start() { func start() {
guard !isRunning else { return } guard !isRunning else { return }
SentrySDK.start { options in SentrySDK.start { options in
#if DEBUG #if DEBUG
options.enabled = false options.enabled = false
#endif #endif
options.dsn = self.sentryURL.absoluteString options.dsn = self.sentryURL.absoluteString
// Disabled as it seems to report a lot of false positives
options.enableAppHangTracking = false
// Most of the network requests are made Rust side, this is useless
options.enableNetworkBreadcrumbs = false
// Doesn't seem to work at all well with SwiftUI
options.enableAutoBreadcrumbTracking = false
// Experimental. Stitches stack traces of asynchronous code together
options.stitchAsyncCode = true
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production. // We recommend adjusting this value in production.
options.tracesSampleRate = 1.0 options.tracesSampleRate = 1.0
options.beforeSend = { event in // This callback is only executed once during the entire run of the program to avoid
MXLog.error("Sentry detected crash: \(event.eventId.sentryIdString)") // multiple callbacks if there are multiple crash events to send (see method documentation)
return event
}
options.onCrashedLastRun = { [weak self] event in options.onCrashedLastRun = { [weak self] event in
MXLog.error("Sentry detected application was crashed: \(event.eventId.sentryIdString)") MXLog.error("Sentry detected a crash in the previous run: \(event.eventId.sentryIdString)")
self?.lastCrashEventId = event.eventId.sentryIdString self?.lastCrashEventId = event.eventId.sentryIdString
} }
} }