FPRAppActivityTracker.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/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. @interface FPRAppActivityTracker : NSObject
  36. /** The trace that tracks the currently active session of the app. *Do not stop this trace*. This is
  37. * an active trace that needs to be running. Stopping this trace might impact the overall
  38. * performance metrics captured for the active session. All other operations can be performed.
  39. */
  40. @property(nonatomic, nullable, readonly) FIRTrace *activeTrace;
  41. /** Current running state of the application. */
  42. @property(nonatomic, readonly) FPRApplicationState applicationState;
  43. /** Accesses the singleton instance.
  44. * @return Reference to the shared object if successful; <code>nil</code> if not.
  45. */
  46. + (nullable instancetype)sharedInstance;
  47. - (nullable instancetype)init NS_UNAVAILABLE;
  48. @end