From e6b845ff4555a7a8c090c6394b895d44d4741e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihat=20Gu=CC=88ndu=CC=88z?= Date: Sun, 1 Dec 2024 17:13:58 +0100 Subject: [PATCH] Move UI layout direction to user preference parameters --- README.md | 3 ++- Sources/TelemetryDeck/Signals/Signal.swift | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) 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..78385bb 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,12 @@ 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 { + UIApplication.shared.userInterfaceLayoutDirection == .leftToRight ? "leftToRight" : "rightToLeft" + } + /// The current devices screen resolution width in points. @MainActor static var screenResolutionWidth: String {