FPRConfigurations.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. NS_ASSUME_NONNULL_BEGIN
  16. /**
  17. * Different modes of prewarm-detection
  18. * KeepNone = No app start events are allowed
  19. * ActivePrewarm = Only detect prewarming using ActivePrewarm environment
  20. * DoubleDispatch = Only detect prewarming using double dispatch method
  21. * ActivePrewarmOrDoubleDispatch = Detect prewarming using both ActivePrewarm and double dispatch
  22. * KeepAll = All app start events are allowed
  23. */
  24. typedef NS_ENUM(NSInteger, PrewarmDetectionMode) {
  25. PrewarmDetectionModeKeepNone = 0,
  26. PrewarmDetectionModeActivePrewarm = 1,
  27. PrewarmDetectionModeDoubleDispatch = 2,
  28. PrewarmDetectionModeActivePrewarmOrDoubleDispatch = 3,
  29. PrewarmDetectionModeKeepAll = 4
  30. };
  31. /** A typedef for ensuring that config names are one of the below specified strings. */
  32. typedef NSString* const FPRConfigName;
  33. /**
  34. * Class that manages the configurations used by firebase performance SDK. This class abstracts the
  35. * configuration flags from different configuration sources.
  36. */
  37. @interface FPRConfigurations : NSObject
  38. /** Enables or disables performance data collection in the SDK. If the value is set to 'NO' none of
  39. * the performance data will be sent to the server. Default is YES. */
  40. @property(nonatomic, getter=isDataCollectionEnabled) BOOL dataCollectionEnabled;
  41. /** The config KVC name string for the dataCollectionEnabled property. */
  42. FOUNDATION_EXTERN FPRConfigName kFPRConfigDataCollectionEnabled;
  43. /** Enables or disables instrumenting the app to collect performance data (like app start time,
  44. * networking). Default is YES. */
  45. @property(nonatomic, getter=isInstrumentationEnabled) BOOL instrumentationEnabled;
  46. /** The config KVC name string for the instrumentationEnabled property. */
  47. FOUNDATION_EXTERN FPRConfigName kFPRConfigInstrumentationEnabled;
  48. /** Log source against which the Fireperf events are recorded. */
  49. @property(nonatomic, readonly) int logSource;
  50. /** Specifies if the SDK is enabled. */
  51. @property(nonatomic, readonly) BOOL sdkEnabled;
  52. /** Specifies if the diagnostic log messages should be enabled. */
  53. @property(nonatomic, readonly) BOOL diagnosticsEnabled;
  54. - (nullable instancetype)init NS_UNAVAILABLE;
  55. /** Singleton instance of FPRConfigurations. */
  56. + (nullable instancetype)sharedInstance;
  57. /**
  58. * Updates all the configurations flags relevant to Firebase Performance.
  59. *
  60. * This call blocks until the update is done.
  61. */
  62. - (void)update;
  63. #pragma mark - Configuration fetcher methods.
  64. /**
  65. * Returns the mode that prewarm-detection should drop events in.
  66. *
  67. * @see PrewarmDetectionMode
  68. * @return filter mode of app start traces prewarm-detection
  69. */
  70. - (PrewarmDetectionMode)prewarmDetectionMode;
  71. /**
  72. * Returns the percentage of instances that would send trace events. Range [0-1].
  73. *
  74. * @return The percentage of instances that would send trace events.
  75. */
  76. - (float)logTraceSamplingRate;
  77. /**
  78. * Returns the percentage of instances that would send network request events. Range [0-1].
  79. *
  80. * @return The percentage of instances that would send network request events.
  81. */
  82. - (float)logNetworkSamplingRate;
  83. /**
  84. * Returns the foreground event count/burst size. This is the number of events that are allowed to
  85. * flow in burst when the app is in foreground.
  86. *
  87. * @return The foreground event count as determined from configs.
  88. */
  89. - (uint32_t)foregroundEventCount;
  90. /**
  91. * Returns the foreground time limit to allow the foreground event count. This is specified in
  92. * number of minutes.
  93. *
  94. * @return The foreground event time limit as determined from configs.
  95. */
  96. - (uint32_t)foregroundEventTimeLimit;
  97. /**
  98. * Returns the background event count/burst size. This is the number of events that are allowed to
  99. * flow in burst when the app is in background.
  100. *
  101. * @return The background event count as determined from configs.
  102. */
  103. - (uint32_t)backgroundEventCount;
  104. /**
  105. * Returns the background time limit to allow the background event count. This is specified in
  106. * number of minutes.
  107. *
  108. * @return The background event time limit as determined from configs.
  109. */
  110. - (uint32_t)backgroundEventTimeLimit;
  111. /**
  112. * Returns the foreground network event count/burst size. This is the number of network events that
  113. * are allowed to flow in burst when the app is in foreground.
  114. *
  115. * @return The foreground network event count as determined from configs.
  116. */
  117. - (uint32_t)foregroundNetworkEventCount;
  118. /**
  119. * Returns the foreground time limit to allow the foreground network event count. This is specified
  120. * in number of minutes.
  121. *
  122. * @return The foreground network event time limit as determined from configs.
  123. */
  124. - (uint32_t)foregroundNetworkEventTimeLimit;
  125. /**
  126. * Returns the background network event count/burst size. This is the number of network events that
  127. * are allowed to flow in burst when the app is in background.
  128. *
  129. * @return The background network event count as determined from configs.
  130. */
  131. - (uint32_t)backgroundNetworkEventCount;
  132. /**
  133. * Returns the background time limit to allow the background network event count. This is specified
  134. * in number of minutes.
  135. *
  136. * @return The background network event time limit as determined from configs.
  137. */
  138. - (uint32_t)backgroundNetworkEventTimeLimit;
  139. /**
  140. * Returns a float specifying the percentage of device instances on which session feature is
  141. * enabled. Range [0-100].
  142. *
  143. * @return The percentage of devices on which session feature should be enabled.
  144. */
  145. - (float_t)sessionsSamplingPercentage;
  146. /**
  147. * Returns the maximum length of a session in minutes. Default is 240 minutes.
  148. *
  149. * @return Maximum allowed length of the session in minutes.
  150. */
  151. - (uint32_t)maxSessionLengthInMinutes;
  152. /**
  153. * Returns the frequency at which the CPU usage metrics are to be collected when the app is in the
  154. * foreground. Frequency is specified in milliseconds. A value of '0' means do not capture.
  155. *
  156. * @return An integer value specifying the frequency of capture in milliseconds.
  157. */
  158. - (uint32_t)cpuSamplingFrequencyInForegroundInMS;
  159. /**
  160. * Returns the frequency at which the CPU usage metrics are to be collected when the app is in the
  161. * background. Frequency is specified in milliseconds. A value of '0' means do not capture.
  162. *
  163. * @return An integer value specifying the frequency of capture in milliseconds.
  164. */
  165. - (uint32_t)cpuSamplingFrequencyInBackgroundInMS;
  166. /**
  167. * Returns the frequency at which the memory usage metrics are to be collected when the app is in
  168. * the foreground. Frequency is specified in milliseconds. A value of '0' means do not capture.
  169. *
  170. * @return An integer value specifying the frequency of capture in milliseconds.
  171. */
  172. - (uint32_t)memorySamplingFrequencyInForegroundInMS;
  173. /**
  174. * Returns the frequency at which the memory usage metrics are to be collected when the app is in
  175. * the background. Frequency is specified in milliseconds. A value of '0' means do not capture.
  176. *
  177. * @return An integer value specifying the frequency of capture in milliseconds.
  178. */
  179. - (uint32_t)memorySamplingFrequencyInBackgroundInMS;
  180. @end
  181. NS_ASSUME_NONNULL_END