[pref][ios] Implement performance monitoring
This commit is contained in:
parent
c5d14a85ec
commit
66df0b0463
|
@ -0,0 +1,18 @@
|
|||
#ifndef RNFirebasePerformance_h
|
||||
#define RNFirebasePerformance_h
|
||||
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface RNFirebasePerformance : NSObject <RCTBridgeModule> {
|
||||
|
||||
}
|
||||
|
||||
@property NSMutableDictionary *traces;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
|
@ -0,0 +1,47 @@
|
|||
#import "RNFirebasePerformance.h"
|
||||
#import "FirebasePerformance/FIRPerformance.h"
|
||||
|
||||
@implementation RNFirebasePerformance
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_traces = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (FIRTrace *)getOrCreateTrace:(NSString *)identifier {
|
||||
if (_traces[identifier]) {
|
||||
return _traces[identifier];
|
||||
}
|
||||
FIRTrace *trace = [FIRPerformance startTraceWithName:identifier];
|
||||
_traces[identifier] = trace;
|
||||
return trace;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setPerformanceCollectionEnabled:
|
||||
(BOOL *) enabled) {
|
||||
[FIRPerformance sharedInstance].dataCollectionEnabled = (BOOL) enabled;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(start:
|
||||
(NSString *) identifier) {
|
||||
[[self getOrCreateTrace:identifier] start];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(stop:
|
||||
(NSString *) identifier) {
|
||||
[[self getOrCreateTrace:identifier] stop];
|
||||
_traces[identifier] = nil;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(incrementCounter:
|
||||
(NSString *) identifier
|
||||
event:
|
||||
(NSString *) event) {
|
||||
[[self getOrCreateTrace:identifier] incrementCounterNamed:event];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,6 +1,6 @@
|
|||
install! 'cocoapods', :deterministic_uuids => false
|
||||
# Uncomment this line to define a global platform for your project
|
||||
# platform :ios, '9.0'
|
||||
# platform :ios, '8.0'
|
||||
|
||||
target 'ReactNativeFirebaseDemo' do
|
||||
platform :ios, '8.0'
|
||||
|
@ -15,7 +15,6 @@ target 'ReactNativeFirebaseDemo' do
|
|||
|
||||
pod 'Firebase/Auth'
|
||||
pod 'Firebase/Analytics'
|
||||
pod 'Firebase/AppIndexing'
|
||||
pod 'Firebase/Core'
|
||||
pod 'Firebase/Crash'
|
||||
pod 'Firebase/Database'
|
||||
|
@ -23,6 +22,7 @@ target 'ReactNativeFirebaseDemo' do
|
|||
pod 'Firebase/Messaging'
|
||||
pod 'Firebase/RemoteConfig'
|
||||
pod 'Firebase/Storage'
|
||||
pod 'Firebase/Performance'
|
||||
|
||||
|
||||
pod 'RNFirebase', :path => './../../'
|
||||
|
|
|
@ -1059,7 +1059,7 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
|
||||
|
|
Loading…
Reference in New Issue