FPRConfigurations.h 6.6 KB

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