Skip to content

Commit

Permalink
Merge pull request #218 from TelemetryDeck/feature/fix-appid-crash
Browse files Browse the repository at this point in the history
Migrate appID from UUID type to String to avoid potential for crashes
  • Loading branch information
Jeehut authored Dec 13, 2024
2 parents b5fc168 + 2fcd7c2 commit c78160d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Sources/TelemetryDeck/Signals/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct SignalPostBody: Codable, Equatable {
let receivedAt: Date

/// The App ID of this signal
let appID: UUID
let appID: String

/// A user identifier. This should be hashed on the client, and will be hashed + salted again
/// on the server to break any connection to personally identifiable data.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TelemetryDeck/Signals/SignalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ final class SignalManager: SignalManageable, @unchecked Sendable {

let signalPostBody = SignalPostBody(
receivedAt: Date(),
appID: UUID(uuidString: configuration.telemetryAppID)!,
appID: configuration.telemetryAppID,
clientUser: CryptoHashing.sha256(string: customUserID ?? defaultUserIdentifier, salt: configuration.salt),
sessionID: configuration.sessionID.uuidString,
type: "\(signalName)",
Expand Down
32 changes: 16 additions & 16 deletions Tests/TelemetryDeckTests/TelemetryDeckTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ struct TelemetryDeckTests {
let signalCache = SignalCache<SignalPostBody>(logHandler: nil)

let signals: [SignalPostBody] = [
.init(receivedAt: Date(), appID: UUID(), clientUser: "01", sessionID: "01", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "02", sessionID: "02", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "03", sessionID: "03", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "04", sessionID: "04", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "05", sessionID: "05", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "06", sessionID: "06", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "07", sessionID: "07", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "08", sessionID: "08", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "09", sessionID: "09", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "10", sessionID: "10", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "11", sessionID: "11", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "12", sessionID: "12", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "13", sessionID: "13", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "14", sessionID: "14", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "15", sessionID: "15", type: "test", floatValue: nil, payload: [:], isTestMode: "true")
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "01", sessionID: "01", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "02", sessionID: "02", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "03", sessionID: "03", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "04", sessionID: "04", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "05", sessionID: "05", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "06", sessionID: "06", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "07", sessionID: "07", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "08", sessionID: "08", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "09", sessionID: "09", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "10", sessionID: "10", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "11", sessionID: "11", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "12", sessionID: "12", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "13", sessionID: "13", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "14", sessionID: "14", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "15", sessionID: "15", type: "test", floatValue: nil, payload: [:], isTestMode: "true")
]

for signal in signals {
Expand Down Expand Up @@ -194,7 +194,7 @@ private class FakeSignalManager: @preconcurrency SignalManageable {

let signalPostBody = SignalPostBody(
receivedAt: Date(),
appID: UUID(uuidString: configuration.telemetryAppID)!,
appID: configuration.telemetryAppID,
clientUser: customUserID ?? "no user",
sessionID: configuration.sessionID.uuidString,
type: "\(signalType)",
Expand Down

0 comments on commit c78160d

Please sign in to comment.