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