FPRConfigurations.h 7.1 KB

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