-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up sentry + adjust app hanging detection
Lower app hanging error level and increase timeout for x86
- Loading branch information
1 parent
27c6372
commit 0e27b3a
Showing
5 changed files
with
89 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// ProcessInfo.swift | ||
// Calendr | ||
// | ||
// Created by Paker on 15/08/2024. | ||
// | ||
|
||
import Foundation | ||
|
||
extension ProcessInfo { | ||
|
||
enum Architecture: String { | ||
case x86_64 | ||
case arm64 | ||
} | ||
|
||
var architecture: Architecture? { _architecture } | ||
} | ||
|
||
/// Equivalent to running `uname -m` in shell | ||
private var _architecture: ProcessInfo.Architecture? = { | ||
var sysinfo = utsname() | ||
let result = uname(&sysinfo) | ||
guard result == EXIT_SUCCESS else { return nil } | ||
let data = Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)) | ||
guard let identifier = String(bytes: data, encoding: .ascii) else { return nil } | ||
return .init(rawValue: identifier.trimmingCharacters(in: .controlCharacters)) | ||
}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Sentry.swift | ||
// Calendr | ||
// | ||
// Created by Paker on 15/08/2024. | ||
// | ||
|
||
import Sentry | ||
|
||
func startSentry() -> Span? { | ||
guard let dsn = Environment.SENTRY_DSN else { return nil } | ||
SentrySDK.start { configureSentry(dsn, $0) } | ||
return SentrySDK.startTransaction(transactionContext: .appLaunch) | ||
} | ||
|
||
private func configureSentry(_ dsn: String, _ options: Options) { | ||
options.dsn = dsn | ||
|
||
if ProcessInfo.processInfo.architecture == .x86_64 { | ||
options.appHangTimeoutInterval += 1 | ||
} | ||
|
||
options.beforeSend = { event in | ||
if (event.exceptions?.first?.type == "App Hanging") { | ||
event.level = .debug | ||
} | ||
return event | ||
} | ||
} | ||
|
||
/// Prevents reporting false hangings for known blocking operations (i.e. context menus) | ||
func blocking<T>(operation: () -> T) -> T { | ||
SentrySDK.pauseAppHangTracking() | ||
defer { SentrySDK.resumeAppHangTracking() } | ||
return operation() | ||
} | ||
|
||
extension TransactionContext { | ||
static let appLaunch = TransactionContext(name: "app", operation: "launch", sampled: .yes) | ||
} |
File renamed without changes.