@@ -17,51 +17,38 @@ import Foundation
1717
1818/// Class that manages the local overrides configs related to the library.
1919class LocalOverrideSettings : SettingsProvider {
20- // This will disable Sessions SDK Events, but not Settings requests.
21- // If any apps use this flag to disable the Firebase Sessions SDK,
22- // keep in mind this may break metrics future features with products like
23- // FirePerf and Crashlytics. As a result, we would recommend apps
24- // use another way to disable data collection (like disabling it via
25- // the product public data collection APIs themselves).
26- // This flag is internal and may break in the future.
27- static let PlistKey_sessions_enabled = " FirebaseSessionsEnabled "
28- static let PlistKey_sessions_timeout = " FirebaseSessionsTimeout "
29- static let PlistKey_sessions_samplingRate = " FirebaseSessionsSampingRate "
20+ private enum PlistKey : String {
21+ /// This will disable Sessions SDK Events, but not Settings requests.
22+ /// If any apps use this flag to disable the Firebase Sessions SDK,
23+ /// keep in mind this may break metrics future features with products like
24+ /// FirePerf and Crashlytics. As a result, we would recommend apps
25+ /// use another way to disable data collection (like disabling it via
26+ /// the product public data collection APIs themselves).
27+ /// This flag is internal and may break in the future.
28+ case sessionsEnabled = " FirebaseSessionsEnabled "
29+ case sessionsTimeout = " FirebaseSessionsTimeout "
30+ case sessionsSamplingRate = " FirebaseSessionsSampingRate "
31+ }
3032
3133 var sessionsEnabled : Bool ? {
32- let session_enabled = plistValueForConfig ( configName: LocalOverrideSettings
33- . PlistKey_sessions_enabled) as? Bool
34- if session_enabled != nil {
35- return Bool ( session_enabled!)
36- }
37- return nil
34+ let isEnabled = plistValue ( for: . sessionsEnabled)
35+ return isEnabled as? Bool
3836 }
3937
4038 var sessionTimeout : TimeInterval ? {
41- let timeout = plistValueForConfig ( configName: LocalOverrideSettings
42- . PlistKey_sessions_timeout) as? Double
43- if timeout != nil {
44- return Double ( timeout!)
45- }
46- return nil
39+ let timeout = plistValue ( for: . sessionsTimeout)
40+ return timeout as? Double
4741 }
4842
4943 var samplingRate : Double ? {
50- let rate = plistValueForConfig ( configName: LocalOverrideSettings
51- . PlistKey_sessions_samplingRate) as? Double
52- if rate != nil {
53- return Double ( rate!)
54- }
55- return nil
44+ let rate = plistValue ( for: . sessionsSamplingRate)
45+ return rate as? Double
5646 }
5747
58- private func plistValueForConfig ( configName : String ) -> Any ? {
59- return Bundle . main. infoDictionary ? [ configName ]
48+ private func plistValue ( for key : PlistKey ) -> Any ? {
49+ return Bundle . main. infoDictionary ? [ key . rawValue ]
6050 }
61- }
6251
63- typealias LocalOverrideSettingsProvider = LocalOverrideSettings
64- extension LocalOverrideSettingsProvider {
6552 func updateSettings( ) {
6653 // Nothing to be done since there is nothing to be updated.
6754 }
0 commit comments