FPRClient.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #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. NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
  29. @interface FPRClient : NSObject
  30. /** YES if SDK is configured, otherwise NO. */
  31. @property(nonatomic, getter=isConfigured, readonly) BOOL configured;
  32. /** YES if methods have been swizzled, NO otherwise. */
  33. @property(nonatomic, getter=isSwizzled) BOOL swizzled;
  34. /** Accesses the singleton instance. All Firebase Performance methods should be managed via this
  35. * shared instance.
  36. * @return Reference to the shared object if successful; <code>nil</code> if not.
  37. */
  38. + (nonnull FPRClient *)sharedInstance;
  39. /** Enables performance reporting. This installs auto instrumentation and configures metric
  40. * uploading.
  41. *
  42. * @param config Configures perf reporting behavior.
  43. * @param error Populated with an NSError instance on failure.
  44. * @return <code>YES</code> if successful; <code>NO</code> if not.
  45. */
  46. - (BOOL)startWithConfiguration:(nonnull FPRConfiguration *)config
  47. error:(NSError *__autoreleasing _Nullable *_Nullable)error;
  48. /** Logs a trace event.
  49. *
  50. * @param trace Trace event that needs to be logged to Google Data Transport.
  51. */
  52. - (void)logTrace:(nonnull FIRTrace *)trace;
  53. /** Logs a network trace event.
  54. *
  55. * @param trace Network trace event that needs to be logged to Google Data Transport.
  56. */
  57. - (void)logNetworkTrace:(nonnull FPRNetworkTrace *)trace;
  58. /** Logs a gauge metric event.
  59. *
  60. * @param gaugeData Gauge metric event that needs to be logged to Google Data Transport.
  61. * @param sessionId SessionID with which the gauge data will be logged.
  62. */
  63. - (void)logGaugeMetric:(nonnull NSArray *)gaugeData forSessionId:(nonnull NSString *)sessionId;
  64. /** Checks if the instrumentation of the app is enabled. If enabled, setup the instrumentation. */
  65. - (void)checkAndStartInstrumentation;
  66. /** Unswizzles any existing methods that have been instrumented and stops automatic instrumentation
  67. * for all future app starts unless explicitly enabled.
  68. */
  69. - (void)disableInstrumentation;
  70. @end