diff --git a/README.md b/README.md index 7119e9f..0daf9d3 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ TelemetryDeck will automatically send base parameters, such as: - TelemetryDeck.Accessibility.isVoiceOverEnabled - TelemetryDeck.Accessibility.preferredContentSizeCategory - TelemetryDeck.Accessibility.shouldDifferentiateWithoutColor -- TelemetryDeck.Accessibility.userInterfaceLayoutDirection + - TelemetryDeck.AppInfo.buildNumber - TelemetryDeck.AppInfo.version - TelemetryDeck.Device.architecture @@ -106,6 +106,7 @@ TelemetryDeck will automatically send base parameters, such as: - TelemetryDeck.SDK.version - TelemetryDeck.UserPreference.colorScheme - TelemetryDeck.UserPreference.language +- TelemetryDeck.UserPreference.layoutDirection - TelemetryDeck.UserPreference.region See our [Grand Renaming article](https://telemetrydeck.com/docs/articles/grand-rename/?source=github) for a full list. diff --git a/Sources/TelemetryDeck/Signals/Signal.swift b/Sources/TelemetryDeck/Signals/Signal.swift index 6281d1a..abfa1c5 100644 --- a/Sources/TelemetryDeck/Signals/Signal.swift +++ b/Sources/TelemetryDeck/Signals/Signal.swift @@ -94,9 +94,10 @@ public struct DefaultSignalPayload: Encodable { "TelemetryDeck.SDK.nameAndVersion": "SwiftSDK \(sdkVersion)", "TelemetryDeck.SDK.version": sdkVersion, + "TelemetryDeck.UserPreference.colorScheme": Self.colorScheme, "TelemetryDeck.UserPreference.language": Self.preferredLanguage, + "TelemetryDeck.UserPreference.layoutDirection": Self.layoutDirection, "TelemetryDeck.UserPreference.region": Self.region, - "TelemetryDeck.UserPreference.colorScheme": Self.colorScheme ] parameters.merge(self.accessibilityParameters, uniquingKeysWith: { $1 }) @@ -132,7 +133,6 @@ extension DefaultSignalPayload { } a11yParams["TelemetryDeck.Accessibility.preferredContentSizeCategory"] = UIApplication.shared.preferredContentSizeCategory.rawValue .replacingOccurrences(of: "UICTContentSizeCategory", with: "") // replaces output "UICTContentSizeCategoryL" with "L" - a11yParams["TelemetryDeck.Accessibility.userInterfaceLayoutDirection"] = UIApplication.shared.userInterfaceLayoutDirection == .leftToRight ? "leftToRight" : "rightToLeft" a11yParams["TelemetryDeck.Accessibility.isSwitchControlEnabled"] = "\(UIAccessibility.isSwitchControlRunning)" #elseif os(macOS) a11yParams["TelemetryDeck.Accessibility.isVoiceOverEnabled"] = "\(NSWorkspace.shared.isVoiceOverEnabled)" @@ -399,6 +399,18 @@ extension DefaultSignalPayload { #endif } + /// The user-preferred layout direction (left-to-right or right-to-left) based on the current language/region settings. + @MainActor + static var layoutDirection: String { + #if os(iOS) || os(tvOS) || os(watchOS) + return UIApplication.shared.userInterfaceLayoutDirection == .leftToRight ? "leftToRight" : "rightToLeft" + #elseif os(macOS) + return NSApp.userInterfaceLayoutDirection == .leftToRight ? "leftToRight" : "rightToLeft" + #else + return "N/A" + #endif + } + /// The current devices screen resolution width in points. @MainActor static var screenResolutionWidth: String {