FPRAppActivityTracker.h 2.6 KB

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