Log Sentry crash events through MXLog

Mirror crashes into our own logs via Sentry's beforeSend hook so the full crash
log ships with rageshakes. Adds a SentryEvent extension to extract the formatted
crash log from the event.
This commit is contained in:
Stefan Ceriu
2026-06-15 14:30:18 +03:00
parent 434b3aab83
commit 0ce7a5ea13
3 changed files with 46 additions and 0 deletions
@@ -0,0 +1,34 @@
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import MatrixRustSDK
import Sentry
import UIKit
extension Event {
/// A human readable crash log matching the format used by the legacy app.
/// `nil` for non-crash events (handled errors, transactions, etc.).
var crashLog: String? {
guard let exceptions,
exceptions.contains(where: { $0.mechanism?.handled?.boolValue == false }) else {
return nil
}
let reason = exceptions.map { "\($0.type ?? "Unknown"): \($0.value ?? "")" }.joined(separator: "\n")
let infoPlist = InfoPlistReader.main
let device = UIDevice.current
return """
\(reason)
Application: \(infoPlist.bundleExecutable) (\(infoPlist.bundleIdentifier))
Application version: \(infoPlist.bundleShortVersionString) (\(infoPlist.bundleVersion))
Matrix SDK version: \(sdkGitSha())
\(device.model) \(device.systemVersion)
"""
}
}