Skip to content

Commit

Permalink
♻️ Set push environment only when value is determined
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt authored and iujames committed Sep 17, 2024
1 parent 56f93cf commit c3d3827
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Sources/AppcuesKit/Data/Analytics/AutoPropertyDecorator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 3 additions & 4 deletions Sources/AppcuesKit/Push/PushEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit c3d3827

Please sign in to comment.