From c3d38276758e12b6d80254d8b710cacc1d713a7d Mon Sep 17 00:00:00 2001 From: Matt Hayashida Date: Thu, 23 May 2024 09:09:35 -0400 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Set=20push=20environment?= =?UTF-8?q?=20only=20when=20value=20is=20determined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppcuesKit/Data/Analytics/AutoPropertyDecorator.swift | 7 +++++-- Sources/AppcuesKit/Push/PushEnvironment.swift | 7 +++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/AppcuesKit/Data/Analytics/AutoPropertyDecorator.swift b/Sources/AppcuesKit/Data/Analytics/AutoPropertyDecorator.swift index 6ab6a11f4..98718ed4c 100644 --- a/Sources/AppcuesKit/Data/Analytics/AutoPropertyDecorator.swift +++ b/Sources/AppcuesKit/Data/Analytics/AutoPropertyDecorator.swift @@ -147,10 +147,13 @@ internal class AutoPropertyDecorator: AnalyticsDecorating { "_deviceId": storage.deviceID, "_pushToken": pushToken, "_pushEnabled": pushMonitor.pushEnabled, - "_pushEnabledBackground": pushMonitor.pushBackgroundEnabled, - "_pushEnvironment": pushMonitor.pushEnvironment.environmentValue + "_pushEnabledBackground": pushMonitor.pushBackgroundEnabled ] + if let environment = pushMonitor.pushEnvironment.environmentValue { + properties["_pushEnvironment"] = environment + } + if let language = deviceLanguage { properties["_language"] = language } diff --git a/Sources/AppcuesKit/Push/PushEnvironment.swift b/Sources/AppcuesKit/Push/PushEnvironment.swift index 26d9f727d..3a4b7d771 100644 --- a/Sources/AppcuesKit/Push/PushEnvironment.swift +++ b/Sources/AppcuesKit/Push/PushEnvironment.swift @@ -37,12 +37,11 @@ internal enum PushEnvironment { } } - var environmentValue: String { - // The environment to request from the backend must be "development" or "production". - // If we haven't been able to determine the environment, default to "production". + var environmentValue: String? { switch self { case .development: return "development" - case .unknown, .production: return "production" + case .production: return "production" + case .unknown: return nil } }