FPRAppActivityTracker.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "FirebasePerformance/Sources/Protogen/nanopb/perf_metric.nanopb.h"
  15. #import "FirebasePerformance/Sources/Public/FirebasePerformance/FIRTrace.h"
  16. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppStartTraceName;
  17. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppStartStageNameTimeToUI;
  18. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppStartStageNameTimeToFirstDraw;
  19. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppStartStageNameTimeToUserInteraction;
  20. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppTraceNameForegroundSession;
  21. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppTraceNameBackgroundSession;
  22. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppCounterNameTraceEventsRateLimited;
  23. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppCounterNameNetworkTraceEventsRateLimited;
  24. FOUNDATION_EXTERN NSString *__nonnull const kFPRAppCounterNameTraceNotStopped;
  25. /** Different states of the current application. */
  26. typedef NS_ENUM(NSInteger, FPRApplicationState) {
  27. FPRApplicationStateUnknown,
  28. /** Application in foreground. */
  29. FPRApplicationStateForeground,
  30. /** Application in background. */
  31. FPRApplicationStateBackground,
  32. };
  33. /** This class is used to track the app activity and create internal traces to capture the
  34. * performance metrics.
  35. */
  36. NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
  37. @interface FPRAppActivityTracker : NSObject
  38. /** The trace that tracks the currently active session of the app. *Do not stop this trace*. This is
  39. * an active trace that needs to be running. Stopping this trace might impact the overall
  40. * performance metrics captured for the active session. All other operations can be performed.
  41. */
  42. @property(nonatomic, nullable, readonly) FIRTrace *activeTrace;
  43. /** Current running state of the application. */
  44. @property(nonatomic, readonly) FPRApplicationState applicationState;
  45. /** Current network connection type of the application. */
  46. @property(nonatomic, readonly) firebase_perf_v1_NetworkConnectionInfo_NetworkType networkType;
  47. /** Accesses the singleton instance.
  48. * @return Reference to the shared object if successful; <code>nil</code> if not.
  49. */
  50. + (nullable instancetype)sharedInstance;
  51. - (nullable instancetype)init NS_UNAVAILABLE;
  52. @end