forked from shadowfacts/Tusker
Add Sentry breadcrumb for instance software/version
This commit is contained in:
parent
5f3d9da9f8
commit
581f4b24bd
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
|
import Sentry
|
||||||
|
|
||||||
struct InstanceFeatures {
|
struct InstanceFeatures {
|
||||||
private static let pleromaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; pleroma (.*)\\)", options: .caseInsensitive)
|
private static let pleromaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; pleroma (.*)\\)", options: .caseInsensitive)
|
||||||
|
@ -136,6 +137,8 @@ struct InstanceFeatures {
|
||||||
}
|
}
|
||||||
|
|
||||||
maxStatusChars = instance.maxStatusCharacters ?? 500
|
maxStatusChars = instance.maxStatusCharacters ?? 500
|
||||||
|
|
||||||
|
setInstanceBreadcrumb(instance: instance, nodeInfo: nodeInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasMastodonVersion(_ major: Int, _ minor: Int, _ patch: Int) -> Bool {
|
func hasMastodonVersion(_ major: Int, _ minor: Int, _ patch: Int) -> Bool {
|
||||||
|
@ -244,3 +247,19 @@ extension InstanceFeatures {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func setInstanceBreadcrumb(instance: Instance, nodeInfo: NodeInfo?) {
|
||||||
|
let crumb = Breadcrumb(level: .info, category: "MastodonController")
|
||||||
|
crumb.data = [
|
||||||
|
"instance": [
|
||||||
|
"version": instance.version
|
||||||
|
],
|
||||||
|
]
|
||||||
|
if let nodeInfo {
|
||||||
|
crumb.data!["nodeInfo"] = [
|
||||||
|
"version": nodeInfo.version,
|
||||||
|
"software": nodeInfo.software,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
SentrySDK.addBreadcrumb(crumb: crumb)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue