[perf][android] Add setPerformanceCollectionEnabled method
This commit is contained in:
parent
4882123912
commit
9ebda147f8
|
@ -29,6 +29,11 @@ public class RNFirebasePerformance extends ReactContextBaseJavaModule {
|
|||
return TAG;
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setPerformanceCollectionEnabled(Boolean enabled) {
|
||||
FirebasePerformance.getInstance().setPerformanceCollectionEnabled(enabled);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void start(String identifier) {
|
||||
Trace trace = getOrCreateTrace(identifier);
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
// @flow
|
||||
import { NativeModules } from 'react-native';
|
||||
import { Base } from './../base';
|
||||
import Trace from './Trace';
|
||||
|
||||
const FirebasePerformance = NativeModules.RNFirebasePerformance;
|
||||
|
||||
export default class PerformanceMonitoring extends Base {
|
||||
|
||||
/**
|
||||
* Globally enable or disable performance monitoring
|
||||
* @param enabled
|
||||
* @returns {*}
|
||||
*/
|
||||
setPerformanceCollectionEnabled(enabled: boolean) {
|
||||
return FirebasePerformance.setPerformanceCollectionEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new trace instance
|
||||
* @param trace
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function messagingTests({ fdescribe, it, firebase }) {
|
||||
function performanceTests({ fdescribe, it, firebase }) {
|
||||
fdescribe('Performance Monitoring', () => {
|
||||
it('it should return a new Task instance', () => {
|
||||
const trace = firebase.native.perf().newTrace('foo');
|
||||
|
@ -19,7 +19,14 @@ function messagingTests({ fdescribe, it, firebase }) {
|
|||
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
it('it should disable and enable performance monitoring', () => {
|
||||
firebase.native.perf().setPerformanceCollectionEnabled(false);
|
||||
firebase.native.perf().setPerformanceCollectionEnabled(true);
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default messagingTests;
|
||||
export default performanceTests;
|
||||
|
|
Loading…
Reference in New Issue