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

Give DefaultSignalPayload Public Access #126

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
43 changes: 23 additions & 20 deletions Sources/TelemetryClient/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,29 @@ internal struct SignalPostBody: Codable, Equatable {
let isTestMode: String
}

internal struct DefaultSignalPayload: Encodable {
let platform = Self.platform
let systemVersion = Self.systemVersion
let majorSystemVersion = Self.majorSystemVersion
let majorMinorSystemVersion = Self.majorMinorSystemVersion
let appVersion = Self.appVersion
let buildNumber = Self.buildNumber
let isSimulator = "\(Self.isSimulator)"
let isDebug = "\(Self.isDebug)"
let isTestFlight = "\(Self.isTestFlight)"
let isAppStore = "\(Self.isAppStore)"
let modelName = Self.modelName
let architecture = Self.architecture
let operatingSystem = Self.operatingSystem
let targetEnvironment = Self.targetEnvironment
let locale = Self.locale
var extensionIdentifier: String? = Self.extensionIdentifier
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one property was a var before, but I found no existing need to mutate it, the tests pass, and the property was previously internal, so I figured it was safe to change to let.

let telemetryClientVersion = TelemetryClientVersion

func toDictionary() -> [String: String] {
/// The default payload that is included in payloads processed by TelemetryDeck.
public struct DefaultSignalPayload: Encodable {
public let platform = Self.platform
public let systemVersion = Self.systemVersion
public let majorSystemVersion = Self.majorSystemVersion
public let majorMinorSystemVersion = Self.majorMinorSystemVersion
public let appVersion = Self.appVersion
public let buildNumber = Self.buildNumber
public let isSimulator = "\(Self.isSimulator)"
public let isDebug = "\(Self.isDebug)"
public let isTestFlight = "\(Self.isTestFlight)"
public let isAppStore = "\(Self.isAppStore)"
public let modelName = Self.modelName
public let architecture = Self.architecture
public let operatingSystem = Self.operatingSystem
public let targetEnvironment = Self.targetEnvironment
public let locale = Self.locale
public let extensionIdentifier: String? = Self.extensionIdentifier
public let telemetryClientVersion = TelemetryClientVersion

public init() { }

public func toDictionary() -> [String: String] {
do {
let encoder = JSONEncoder()
let data = try encoder.encode(self)
Expand Down