FPRRemoteConfigFlags.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. #pragma mark - General configs.
  36. /**
  37. * Returns if performance SDK is enabled.
  38. * Name in remote config: "fpr_enabled".
  39. *
  40. * @param sdkEnabled Default value to be returned if values does not exist in remote config.
  41. * @return Specifies if SDK should be enabled or not.
  42. */
  43. - (BOOL)performanceSDKEnabledWithDefaultValue:(BOOL)sdkEnabled;
  44. /**
  45. * Returns set of versions on which SDK is disabled.
  46. * Name in remote config: "fpr_disabled_ios_versions".
  47. *
  48. * @param sdkVersions Default value to be returned if values does not exist in remote config.
  49. * @return SDK versions list where the SDK has to be disabled.
  50. */
  51. - (nullable NSSet<NSString *> *)sdkDisabledVersionsWithDefaultValue:
  52. (nullable NSSet<NSString *> *)sdkVersions;
  53. /**
  54. * Returns the log source against which the events will be recorded.
  55. * Name in remote config: "fpr_log_source"
  56. *
  57. * @param logSource Default value to be returned if values does not exist in remote config.
  58. * @return Log source towards which the events would be logged.
  59. */
  60. - (int)logSourceWithDefaultValue:(int)logSource;
  61. #pragma mark - Rate limiting related configs.
  62. /**
  63. * Returns the time limit for which the event are measured against. Measured in seconds.
  64. * Name in remote config: "fpr_rl_time_limit_sec"
  65. *
  66. * @param durationInSeconds Default value to be returned if values does not exist in remote config.
  67. * @return Time limit used for rate limiting in seconds.
  68. */
  69. - (int)rateLimitTimeDurationWithDefaultValue:(int)durationInSeconds;
  70. /**
  71. * Returns the number of trace events that are allowed when the app is in foreground.
  72. * Name in remote config: "fpr_rl_trace_event_count_fg"
  73. *
  74. * @param eventCount Default value to be returned if values does not exist in remote config.
  75. * @return Trace count limit when the app is in foreground.
  76. */
  77. - (int)rateLimitTraceCountInForegroundWithDefaultValue:(int)eventCount;
  78. /**
  79. * Returns the number of trace events that are allowed when the app is in background.
  80. * Name in remote config: "fpr_rl_trace_event_count_bg"
  81. *
  82. * @param eventCount Default value to be returned if values does not exist in remote config.
  83. * @return Trace count limit when the app is in background.
  84. */
  85. - (int)rateLimitTraceCountInBackgroundWithDefaultValue:(int)eventCount;
  86. /**
  87. * Returns the number of network trace events that are allowed when the app is in foreground.
  88. * Name in remote config: "fpr_rl_network_request_event_count_fg"
  89. *
  90. * @param eventCount Default value to be returned if values does not exist in remote config.
  91. * @return Network request count limit when the app is in foreground.
  92. */
  93. - (int)rateLimitNetworkRequestCountInForegroundWithDefaultValue:(int)eventCount;
  94. /**
  95. * Returns the number of network trace events that are allowed when the app is in background.
  96. * Name in remote config: "fpr_rl_network_request_event_count_bg"
  97. *
  98. * @param eventCount Default value to be returned if values does not exist in remote config.
  99. * @return Network request count limit when the app is in background.
  100. */
  101. - (int)rateLimitNetworkRequestCountInBackgroundWithDefaultValue:(int)eventCount;
  102. #pragma mark - Sampling related configs.
  103. /**
  104. * Returns the sampling rate for traces. A value of 1 means all the events must be sent to the
  105. * backend. A value of 0 means, no data must be sent. Range [0-1]. A value of -1 means the value is
  106. * not found.
  107. * Name in remote config: "fpr_vc_trace_sampling_rate"
  108. *
  109. * @param samplingRate Default value to be returned if values does not exist in remote config.
  110. * @return Sampling rate used for the number of traces.
  111. */
  112. - (float)traceSamplingRateWithDefaultValue:(float)samplingRate;
  113. /**
  114. * Returns the sampling rate for network requests. A value of 1 means all the events must be sent to
  115. * the backend. A value of 0 means, no data must be sent. Range [0-1]. A value of -1 means the value
  116. * is not found.
  117. * Name in remote config: "fpr_vc_network_request_sampling_rate"
  118. *
  119. * @param samplingRate Default value to be returned if values does not exist in remote config.
  120. * @return Sampling rate used for the number of network request traces.
  121. */
  122. - (float)networkRequestSamplingRateWithDefaultValue:(float)samplingRate;
  123. #pragma mark - Session related configs.
  124. /**
  125. * Returns the sampling rate for sessions. A value of 1 means all the events must be sent to the
  126. * backend. A value of 0 means, no data must be sent. Range [0-1]. A value of -1 means the value is
  127. * not found.
  128. * Name in remote config: "fpr_vc_session_sampling_rate"
  129. *
  130. * @param samplingRate Default value to be returned if values does not exist in remote config.
  131. * @return Session sampling rate used for the number of sessions generated.
  132. */
  133. - (float)sessionSamplingRateWithDefaultValue:(float)samplingRate;
  134. /**
  135. * Returns the frequency at which CPU usage is measured when the app is in foreground. Measured in
  136. * milliseconds. Name in remote config: "fpr_session_gauge_cpu_capture_frequency_fg_ms"
  137. *
  138. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  139. * @return Frequency at which CPU information is captured when app is in foreground.
  140. */
  141. - (int)sessionGaugeCPUCaptureFrequencyInForegroundWithDefaultValue:(int)defaultFrequency;
  142. /**
  143. * Returns the frequency at which CPU usage is measured when the app is in background. Measured in
  144. * milliseconds. Name in remote config: "fpr_session_gauge_cpu_capture_frequency_bg_ms"
  145. *
  146. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  147. * @return Frequency at which CPU information is captured when app is in background.
  148. */
  149. - (int)sessionGaugeCPUCaptureFrequencyInBackgroundWithDefaultValue:(int)defaultFrequency;
  150. /**
  151. * Returns the frequency at which memory usage is measured when the app is in foreground. Measured
  152. * in milliseconds. Name in remote config: "fpr_session_gauge_memory_capture_frequency_fg_ms"
  153. *
  154. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  155. * @return Frequency at which memory information is captured when app is in foreground.
  156. */
  157. - (int)sessionGaugeMemoryCaptureFrequencyInForegroundWithDefaultValue:(int)defaultFrequency;
  158. /**
  159. * Returns the frequency at which memory usage is measured when the app is in background. Measured
  160. * in milliseconds. Name in remote config: "fpr_session_gauge_memory_capture_frequency_bg_ms"
  161. *
  162. * @param defaultFrequency Default value to be returned if values does not exist in remote config.
  163. * @return Frequency at which memory information is captured when app is in background.
  164. */
  165. - (int)sessionGaugeMemoryCaptureFrequencyInBackgroundWithDefaultValue:(int)defaultFrequency;
  166. /**
  167. * Returns the maximum allowed duration for the length of a session. Measured in minutes.
  168. * Name in remote config: "fpr_session_max_duration_min"
  169. *
  170. * @param maxDurationInMinutes Default value to be returned if values does not exist in remote
  171. * config.
  172. * @return Duration for which a sessions can be active.
  173. */
  174. - (int)sessionMaxDurationWithDefaultValue:(int)maxDurationInMinutes;
  175. @end