Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add application version to HeaderEvent #18

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Trap/Constants.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct Constants {
struct App {
static let version = "1.1.4"
struct Trap {
static let version = "1.1.5"
}
}
21 changes: 19 additions & 2 deletions Sources/Trap/Manager/Reporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class TrapReporter {
/// The endpoint of the reporter to use
private let config: TrapConfig

/// Application version (for the embedding application)
private let appVersion: String

/// The streamId of this continuous data stream.
private var streamId = UUID()

Expand All @@ -42,6 +45,7 @@ class TrapReporter {
self.storage = storage
self.config = config
self.transport = nil
self.appVersion = Bundle.main.appVersion
}

deinit {
Expand Down Expand Up @@ -92,7 +96,7 @@ class TrapReporter {
}
let group = DispatchGroup()
group.enter()

let data = this.storage
.sorted { $0.0 < $1.0 }
.map(\.1)
Expand Down Expand Up @@ -140,11 +144,24 @@ class TrapReporter {
DataType.string(streamId.uuidString),
DataType.int(sequenceId),
DataType.dict(["version": DataType.string("20230706T094422Z")]),
DataType.string(Constants.App.version)
DataType.string(Constants.Trap.version),
DataType.string(appVersion)
])

sequenceId += 1

return header
}
}

extension Bundle {
/// Gets the application version
var appVersion: String {
if let infoDictionary = Bundle.main.infoDictionary,
let name = infoDictionary["CFBundleName"],
let version = infoDictionary["CFBundleVersion"] {
return "\(name) (\(version))"
}
return "Unknown"
}
}
Loading