-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathFeatureFlags.swift
332 lines (294 loc) · 12.1 KB
/
FeatureFlags.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
//
// FeatureFlags.swift
// Loop
//
// Created by Michael Pangburn on 5/19/19.
// Copyright © 2019 LoopKit Authors. All rights reserved.
//
import Foundation
let FeatureFlags = FeatureFlagConfiguration()
struct FeatureFlagConfiguration: Decodable {
let automaticBolusEnabled: Bool
let cgmManagerCategorizeManualGlucoseRangeEnabled: Bool
let criticalAlertsEnabled: Bool
let entryDeletionEnabled: Bool
let fiaspInsulinModelEnabled: Bool
let lyumjevInsulinModelEnabled: Bool
let afrezzaInsulinModelEnabled: Bool
let includeServicesInSettingsEnabled: Bool
let manualDoseEntryEnabled: Bool
let insulinDeliveryReservoirViewEnabled: Bool
let mockTherapySettingsEnabled: Bool
let nonlinearCarbModelEnabled: Bool
let observeHealthKitCarbSamplesFromOtherApps: Bool
let observeHealthKitDoseSamplesFromOtherApps: Bool
let observeHealthKitGlucoseSamplesFromOtherApps: Bool
let remoteCommandsEnabled: Bool
let predictedGlucoseChartClampEnabled: Bool
let scenariosEnabled: Bool
let sensitivityOverridesEnabled: Bool
let showEventualBloodGlucoseOnWatchEnabled: Bool
let simulatedCoreDataEnabled: Bool
let siriEnabled: Bool
let simpleBolusCalculatorEnabled: Bool
let usePositiveMomentumAndRCForManualBoluses: Bool
let adultChildInsulinModelSelectionEnabled: Bool
let profileExpirationSettingsViewEnabled: Bool
let missedMealNotifications: Bool
let allowAlgorithmExperiments: Bool
let isInvestigationalDevice: Bool
fileprivate init() {
// Swift compiler config is inverse, since the default state is enabled.
#if AUTOMATIC_BOLUS_DISABLED
self.automaticBolusEnabled = false
#else
self.automaticBolusEnabled = true
#endif
#if CGM_MANAGER_CATEGORIZE_GLUCOSE_RANGE_ENABLED
self.cgmManagerCategorizeManualGlucoseRangeEnabled = true
#else
self.cgmManagerCategorizeManualGlucoseRangeEnabled = false
#endif
#if CRITICAL_ALERTS_ENABLED
self.criticalAlertsEnabled = true
#else
self.criticalAlertsEnabled = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if ENTRY_DELETION_DISABLED
self.entryDeletionEnabled = false
#else
self.entryDeletionEnabled = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if FEATURE_OVERRIDES_DISABLED
self.sensitivityOverridesEnabled = false
#else
self.sensitivityOverridesEnabled = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if FIASP_INSULIN_MODEL_DISABLED
self.fiaspInsulinModelEnabled = false
#else
self.fiaspInsulinModelEnabled = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if LYUMJEV_INSULIN_MODEL_DISABLED
self.lyumjevInsulinModelEnabled = false
#else
self.lyumjevInsulinModelEnabled = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if AFREZZA_INSULIN_MODEL_DISABLED
self.afrezzaInsulinModelEnabled = false
#else
self.afrezzaInsulinModelEnabled = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if INCLUDE_SERVICES_IN_SETTINGS_DISABLED
self.includeServicesInSettingsEnabled = false
#else
self.includeServicesInSettingsEnabled = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if MANUAL_DOSE_ENTRY_DISABLED
self.manualDoseEntryEnabled = false
#else
self.manualDoseEntryEnabled = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if INSULIN_DELIVERY_RESERVOIR_VIEW_DISABLED
self.insulinDeliveryReservoirViewEnabled = false
#else
self.insulinDeliveryReservoirViewEnabled = true
#endif
#if MOCK_THERAPY_SETTINGS_ENABLED
self.mockTherapySettingsEnabled = true
#else
self.mockTherapySettingsEnabled = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if NONLINEAR_CARB_MODEL_DISABLED
self.nonlinearCarbModelEnabled = false
#else
self.nonlinearCarbModelEnabled = true
#endif
#if OBSERVE_HEALTH_KIT_CARB_SAMPLES_FROM_OTHER_APPS_ENABLED
self.observeHealthKitCarbSamplesFromOtherApps = true
#else
self.observeHealthKitCarbSamplesFromOtherApps = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if OBSERVE_HEALTH_KIT_SAMPLES_FROM_OTHER_APPS_DISABLED
self.observeHealthKitDoseSamplesFromOtherApps = false
self.observeHealthKitGlucoseSamplesFromOtherApps = false
#else
self.observeHealthKitDoseSamplesFromOtherApps = true
self.observeHealthKitGlucoseSamplesFromOtherApps = true
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if OBSERVE_HEALTH_KIT_DOSE_SAMPLES_FROM_OTHER_APPS_DISABLED
self.observeHealthKitDoseSamplesFromOtherApps = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if OBSERVE_HEALTH_KIT_GLUCOSE_SAMPLES_FROM_OTHER_APPS_DISABLED
self.observeHealthKitGlucoseSamplesFromOtherApps = false
#endif
#if PREDICTED_GLUCOSE_CHART_CLAMP_ENABLED
self.predictedGlucoseChartClampEnabled = true
#else
self.predictedGlucoseChartClampEnabled = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if REMOTE_COMMANDS_DISABLED || REMOTE_OVERRIDES_DISABLED //REMOTE_OVERRIDES_DISABLED: backwards compatibility of Loop 3 & prior
self.remoteCommandsEnabled = false
#else
self.remoteCommandsEnabled = true
#endif
#if SCENARIOS_ENABLED
self.scenariosEnabled = true
#else
self.scenariosEnabled = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if SHOW_EVENTUAL_BLOOD_GLUCOSE_ON_WATCH_DISABLED
self.showEventualBloodGlucoseOnWatchEnabled = false
#else
self.showEventualBloodGlucoseOnWatchEnabled = true
#endif
#if SIMULATED_CORE_DATA_ENABLED
self.simulatedCoreDataEnabled = true
#else
self.simulatedCoreDataEnabled = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if SIRI_DISABLED
self.siriEnabled = false
#else
self.siriEnabled = true
#endif
#if SIMPLE_BOLUS_CALCULATOR_ENABLED
self.simpleBolusCalculatorEnabled = true
#else
self.simpleBolusCalculatorEnabled = false
#endif
// Swift compiler config is inverse, since the default state is enabled.
#if DISABLE_POSITIVE_MOMENTUM_AND_RC_FOR_MANUAL_BOLUSES
self.usePositiveMomentumAndRCForManualBoluses = false
#else
self.usePositiveMomentumAndRCForManualBoluses = true
#endif
#if ADULT_CHILD_INSULIN_MODEL_SELECTION_ENABLED
self.adultChildInsulinModelSelectionEnabled = true
#else
self.adultChildInsulinModelSelectionEnabled = false
#endif
// ProfileExpirationSettingsView is inverse, since the default state is enabled.
#if PROFILE_EXPIRATION_SETTINGS_VIEW_DISABLED
self.profileExpirationSettingsViewEnabled = false
#else
self.profileExpirationSettingsViewEnabled = true
#endif
// Missed meal notifications compiler flag is inverse, since the default state is enabled.
#if MISSED_MEAL_NOTIFICATIONS_DISABLED
self.missedMealNotifications = false
#else
self.missedMealNotifications = true
#endif
#if ALLOW_ALGORITHM_EXPERIMENTS
self.allowAlgorithmExperiments = true
#else
self.allowAlgorithmExperiments = false
#endif
#if INVESTIGATIONAL_DEVICE
self.isInvestigationalDevice = true
#else
self.isInvestigationalDevice = false
#endif
}
}
extension FeatureFlagConfiguration : CustomDebugStringConvertible {
var debugDescription: String {
return [
"* cgmManagerCategorizeManualGlucoseRangeEnabled: \(cgmManagerCategorizeManualGlucoseRangeEnabled)",
"* criticalAlertsEnabled: \(criticalAlertsEnabled)",
"* entryDeletionEnabled: \(entryDeletionEnabled)",
"* fiaspInsulinModelEnabled: \(fiaspInsulinModelEnabled)",
"* lyumjevInsulinModelEnabled: \(lyumjevInsulinModelEnabled)",
"* afrezzaInsulinModelEnabled: \(afrezzaInsulinModelEnabled)",
"* includeServicesInSettingsEnabled: \(includeServicesInSettingsEnabled)",
"* mockTherapySettingsEnabled: \(mockTherapySettingsEnabled)",
"* nonlinearCarbModelEnabled: \(nonlinearCarbModelEnabled)",
"* observeHealthKitCarbSamplesFromOtherApps: \(observeHealthKitCarbSamplesFromOtherApps)",
"* observeHealthKitDoseSamplesFromOtherApps: \(observeHealthKitDoseSamplesFromOtherApps)",
"* observeHealthKitGlucoseSamplesFromOtherApps: \(observeHealthKitGlucoseSamplesFromOtherApps)",
"* predictedGlucoseChartClampEnabled: \(predictedGlucoseChartClampEnabled)",
"* remoteCommandsEnabled: \(remoteCommandsEnabled)",
"* scenariosEnabled: \(scenariosEnabled)",
"* sensitivityOverridesEnabled: \(sensitivityOverridesEnabled)",
"* showEventualBloodGlucoseOnWatchEnabled: \(showEventualBloodGlucoseOnWatchEnabled)",
"* simulatedCoreDataEnabled: \(simulatedCoreDataEnabled)",
"* siriEnabled: \(siriEnabled)",
"* automaticBolusEnabled: \(automaticBolusEnabled)",
"* manualDoseEntryEnabled: \(manualDoseEntryEnabled)",
"* allowDebugFeatures: \(allowDebugFeatures)",
"* simpleBolusCalculatorEnabled: \(simpleBolusCalculatorEnabled)",
"* usePositiveMomentumAndRCForManualBoluses: \(usePositiveMomentumAndRCForManualBoluses)",
"* adultChildInsulinModelSelectionEnabled: \(adultChildInsulinModelSelectionEnabled)",
"* profileExpirationSettingsViewEnabled: \(profileExpirationSettingsViewEnabled)",
"* missedMealNotifications: \(missedMealNotifications)",
"* allowAlgorithmExperiments: \(allowAlgorithmExperiments)",
"* allowExperimentalFeatures: \(allowExperimentalFeatures)",
"* isInvestigationalDevice: \(isInvestigationalDevice)"
].joined(separator: "\n")
}
}
extension FeatureFlagConfiguration {
var allowDebugFeatures: Bool {
#if DEBUG_FEATURES_ENABLED
return true
#elseif DEBUG_FEATURES_ENABLED_CONDITIONALLY
if debugEnabled {
return true
} else {
if UserDefaults.appGroup?.allowDebugFeatures ?? false {
return true
} else {
return false
}
}
#else
return false
#endif
}
var allowExperimentalFeatures: Bool {
#if EXPERIMENTAL_FEATURES_ENABLED
return true
#elseif EXPERIMENTAL_FEATURES_ENABLED_CONDITIONALLY
if debugEnabled {
return true
} else {
return UserDefaults.appGroup?.allowExperimentalFeatures ?? false
}
#else
return false
#endif
}
var allowSimulators: Bool {
#if SIMULATORS_ENABLED
return true
#elseif SIMULATORS_ENABLED_CONDITIONALLY
if debugEnabled {
return true
} else {
if UserDefaults.appGroup?.allowSimulators ?? false {
return true
} else {
return false
}
}
#else
return false
#endif
}
}