FPRClient.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #import "FirebasePerformance/Sources/FPRConfiguration.h"
  16. #import "FirebasePerformance/Sources/Gauges/FPRGaugeManager.h"
  17. #import "FirebasePerformance/Sources/Instrumentation/FPRNetworkTrace.h"
  18. /** NSError codes for FPRClient related errors */
  19. typedef NS_ENUM(NSInteger, FPRClientErrorCode) {
  20. // Generic Error.
  21. FPRClientErrorCodeUnknown,
  22. // Error starting the client.
  23. FPRClientErrorCodeStartupError
  24. };
  25. /** This class is not exposed to the public and internally provides the primary entry point into
  26. * the Firebase Performance module's functionality.
  27. */
  28. @interface FPRClient : NSObject
  29. /** YES if SDK is configured, otherwise NO. */
  30. @property(nonatomic, getter=isConfigured, readonly) BOOL configured;
  31. /** YES if methods have been swizzled, NO otherwise. */
  32. @property(nonatomic, getter=isSwizzled) BOOL swizzled;
  33. /** Accesses the singleton instance. All Firebase Performance methods should be managed via this
  34. * shared instance.
  35. * @return Reference to the shared object if successful; <code>nil</code> if not.
  36. */
  37. + (nonnull FPRClient *)sharedInstance;
  38. /** Enables performance reporting. This installs auto instrumentation and configures metric
  39. * uploading.
  40. *
  41. * @param config Configures perf reporting behavior.
  42. * @param error Populated with an NSError instance on failure.
  43. * @return <code>YES</code> if successful; <code>NO</code> if not.
  44. */
  45. - (BOOL)startWithConfiguration:(nonnull FPRConfiguration *)config
  46. error:(NSError *__autoreleasing _Nullable *_Nullable)error;
  47. /** Logs a trace event.
  48. *
  49. * @param trace Trace event that needs to be logged to Google Data Transport.
  50. */
  51. - (void)logTrace:(nonnull FIRTrace *)trace;
  52. /** Logs a network trace event.
  53. *
  54. * @param trace Network trace event that needs to be logged to Google Data Transport.
  55. */
  56. - (void)logNetworkTrace:(nonnull FPRNetworkTrace *)trace;
  57. /** Logs a gauge metric event.
  58. *
  59. * @param gaugeData Gauge metric event that needs to be logged to Google Data Transport.
  60. * @param sessionId SessionID with which the gauge data will be logged.
  61. */
  62. - (void)logGaugeMetric:(nonnull NSArray *)gaugeData forSessionId:(nonnull NSString *)sessionId;
  63. /** Checks if the instrumentation of the app is enabled. If enabled, setup the instrumentation. */
  64. - (void)checkAndStartInstrumentation;
  65. /** Unswizzles any existing methods that have been instrumented and stops automatic instrumentation
  66. * for all future app starts unless explicitly enabled.
  67. */
  68. - (void)disableInstrumentation;
  69. @end