FPRRemoteConfigFlags.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. /**
  16. * Configuration flags retrieved from Firebase Remote Configuration.
  17. */
  18. @interface FPRRemoteConfigFlags : NSObject
  19. /**
  20. * The name of the name space for which the remote config flags are fetched.
  21. */
  22. @property(nonatomic, readonly, nonnull) NSString *remoteConfigNamespace;
  23. #pragma mark - Instance methods
  24. - (nullable instancetype)init NS_UNAVAILABLE;
  25. /** Singleton instance of Firebase Remote Configuration flags. */
  26. + (nullable instancetype)sharedInstance;
  27. /**
  28. * Initiate a fetch of the flags from Firebase Remote Configuration and updates the configurations
  29. * at the end of the fetch.
  30. *
  31. * @note This method is throttled to initiate a fetch once in 12 hours. So, calling this method does
  32. * not guarantee a fetch from Firebase Remote Config.
  33. */
  34. - (void)update;
  35. /**
  36. * Returns if there was a successful fetch in the past and if any remote config flag exists.
  37. *
  38. * @return YES if any remote config flag exists; NO otherwise.
  39. */
  40. - (BOOL)containsRemoteConfigFlags;
  41. #pragma mark - General configs.
  42. /**
  43. * Returns if performance SDK is enabled.
  44. * Name in remote config: "fpr_enabled".
  45. *
  46. * @param sdkEnabled Default value to be returned if values does not exist in remote config.
  47. * @return Specifies if SDK should be enabled or not.
  48. */
  49. - (BOOL)performanceSDKEnabledWithDefaultValue:(BOOL)sdkEnabled;
  50. /**
  51. * Returns set of versions on which SDK is disabled.
  52. * Name in remote config: "fpr_disabled_ios_versions".
  53. *
  54. * @param sdkVersions Default value to be returned if values does not exist in remote config.
  55. * @return SDK versions list where the SDK has to be disabled.
  56. */
  57. - (nullable NSSet<NSString *> *)sdkDisabledVersionsWithDefaultValue:
  58. (nullable NSSet<NSString *> *)sdkVersions;
  59. /**
  60. * Returns the log source against which the events will be recorded.
  61. * Name in remote config: "fpr_log_source"
  62. *
  63. * @param logSource Default value to be returned if values does not exist in remote config.
  64. * @return Log source towards which the events would be logged.
  65. */
  66. - (int)logSourceWithDefaultValue:(int)logSource;
  67. #pragma mark - Rate limiting related configs.
  68. /**
  69. * Returns the time limit for which the event are measured against. Measured in seconds.
  70. * Name in remote config: "fpr_rl_time_limit_sec"
  71. *
  72. * @param durationInSeconds Default value to be returned if values does not exist in remote config.
  73. * @return Time limit used for rate limiting in seconds.
  74. */
  75. - (int)rateLimitTimeDurationWithDefaultValue:(int)durationInSeconds;
  76. /**
  77. * Returns the number of trace events that are allowed when the app is in foreground.
  78. * Name in remote config: "fpr_rl_trace_event_count_fg"
  79. *
  80. * @param eventCount Default value to be returned if values does not exist in remote config.
  81. * @return Trace count limit when the app is in foreground.
  82. */
  83. - (int)rateLimitTraceCountInForegroundWithDefaultValue:(int)eventCount;
  84. /**
  85. * Returns the number of trace events that are allowed when the app is in background.
  86. * Name in remote config: "fpr_rl_trace_event_count_bg"
  87. *
  88. * @param eventCount Default value to be returned if values does not exist in remote config.
  89. * @return Trace count limit when the app is in background.
  90. */
  91. - (int)rateLimitTraceCountInBackgroundWithDefaultValue:(int)eventCount;
  92. /**
  93. * Returns the number of network trace events that are allowed when the app is in foreground.
  94. * Name in remote config: "fpr_rl_network_request_event_count_fg"
  95. *
  96. * @param eventCount Default value to be returned if values does not exist in remote config.
  97. * @return Network request count limit when the app is in foreground.
  98. */
  99. - (int)rateLimitNetworkRequestCountInForegroundWithDefaultValue:(int)eventCount;
  100. /**
  101. * Returns the number of network trace events that are allowed when the app is in background.
  102. * Name in remote config: "fpr_rl_network_request_event_count_bg"
  103. *
  104. * @param eventCount Default value to be returned if values does not exist in remote config.
  105. * @return Network request count limit when the app is in background.
  106. */
  107. - (int)rateLimitNetworkRequestCountInBackgroundWithDefaultValue:(int)eventCount;
  108. #pragma mark - Sampling related configs.
  109. /**
  110. * Returns the sampling rate for traces. A value of 1 means all the events must be sent to the
  111. * backend. A value of 0 means, no data must be sent. Range [0-1]. A value of -1 means the value is
  112. * not found.
  113. * Name in remote config: "fpr_vc_trace_sampling_rate"
  114. *
  115. * @param samplingRate Default value to be returned if values does not exist in remote config.
  116. * @return Sampling rate used for the number of traces.
  117. */
  118. - (float)traceSamplingRateWithDefaultValue:(float)samplingRate;
  119. /**
  120. * Returns the sampling rate for network requests. A value of 1 means all the events must be sent to
  121. * the backend. A value of 0 means, no data must be sent. Range [0-1]. A value of -1 means the value
  122. * is not found.
  123. * Name in remote config: "fpr_vc_network_request_sampling_rate"
  124. *
  125. * @param samplingRate Default value to be returned if values does not exist in remote config.
  126. * @return Sampling rate used for the number of network request traces.
  127. */
  128. - (float)networkRequestSamplingRateWithDefaultValue:(float)samplingRate;
  129. #pragma mark - Session related configs.
  130. /**
  131. * Returns the sampling rate for sessions. A value of 1 means all the events must be sent to the
  132. * backend. A value of 0 means, no data must be sent. Range [0-1]. A value of -1 means the value is
  133. * not found.
  134. * Name in remote config: "fpr_vc_session_sampling_rate"
  135. *
  136. * @param samplingRate Default value to be returned if values does not exist in remote config.
  137. * @return Session sampling rate used for the number of sessions generated.
  138. */
  139. - (float)sessionSamplingRateWithDefaultValue:(float)samplingRate;
  140. /**
  141. * Returns the frequency at which CPU usage is measured when the app is in foreground. Measured in
  142. * milliseconds. Name in remote config: "fpr_session_gauge_cpu_capture_frequency_fg_ms"
  143. *
  144. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  145. * @return Frequency at which CPU information is captured when app is in foreground.
  146. */
  147. - (int)sessionGaugeCPUCaptureFrequencyInForegroundWithDefaultValue:(int)defaultFrequency;
  148. /**
  149. * Returns the frequency at which CPU usage is measured when the app is in background. Measured in
  150. * milliseconds. Name in remote config: "fpr_session_gauge_cpu_capture_frequency_bg_ms"
  151. *
  152. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  153. * @return Frequency at which CPU information is captured when app is in background.
  154. */
  155. - (int)sessionGaugeCPUCaptureFrequencyInBackgroundWithDefaultValue:(int)defaultFrequency;
  156. /**
  157. * Returns the frequency at which memory usage is measured when the app is in foreground. Measured
  158. * in milliseconds. Name in remote config: "fpr_session_gauge_memory_capture_frequency_fg_ms"
  159. *
  160. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  161. * @return Frequency at which memory information is captured when app is in foreground.
  162. */
  163. - (int)sessionGaugeMemoryCaptureFrequencyInForegroundWithDefaultValue:(int)defaultFrequency;
  164. /**
  165. * Returns the frequency at which memory usage is measured when the app is in background. Measured
  166. * in milliseconds. Name in remote config: "fpr_session_gauge_memory_capture_frequency_bg_ms"
  167. *
  168. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  169. * @return Frequency at which memory information is captured when app is in background.
  170. */
  171. - (int)sessionGaugeMemoryCaptureFrequencyInBackgroundWithDefaultValue:(int)defaultFrequency;
  172. /**
  173. * Returns the maximum allowed duration for the length of a session. Measured in minutes.
  174. * Name in remote config: "fpr_session_max_duration_min"
  175. *
  176. * @param maxDurationInMinutes Default value to be returned if values does not exist in remote
  177. * config.
  178. * @return Duration for which a sessions can be active.
  179. */
  180. - (int)sessionMaxDurationWithDefaultValue:(int)maxDurationInMinutes;
  181. #pragma mark - Google Data Transport related configs.
  182. /**
  183. * Returns the fll event transport percentage. A value of 100 means all the events are sent to
  184. * Fll. A value of 0 means, event are not sent to FLL. Range [0-100]. A value of -1 means
  185. * the value is not found. Name in remote config: "fpr_log_transport_ios_percent"
  186. *
  187. * @param percentage Default value of the transport rate to be returned if value does not exist
  188. * in remote config.
  189. * @return FLL transport percentage.
  190. */
  191. - (float)fllTransportPercentageWithDefaultValue:(float)percentage;
  192. @end