2017-12-04 12:07:41 +00:00
|
|
|
/**
|
|
|
|
* @flow
|
|
|
|
* Performance monitoring representation wrapper
|
|
|
|
*/
|
2017-05-24 11:37:52 +00:00
|
|
|
import Trace from './Trace';
|
2017-06-30 16:23:32 +00:00
|
|
|
import ModuleBase from '../../utils/ModuleBase';
|
2018-01-05 17:20:02 +00:00
|
|
|
import { getNativeModule } from '../../utils/native';
|
2017-05-24 11:37:52 +00:00
|
|
|
|
2018-02-14 13:00:19 +00:00
|
|
|
import type App from '../core/app';
|
2017-12-04 12:07:41 +00:00
|
|
|
|
2018-01-03 20:00:38 +00:00
|
|
|
export const MODULE_NAME = 'RNFirebasePerformance';
|
|
|
|
export const NAMESPACE = 'perf';
|
2017-08-17 16:58:28 +00:00
|
|
|
|
2018-01-03 20:00:38 +00:00
|
|
|
export default class PerformanceMonitoring extends ModuleBase {
|
2018-01-05 17:20:02 +00:00
|
|
|
constructor(app: App) {
|
|
|
|
super(app, {
|
2018-01-03 20:00:38 +00:00
|
|
|
moduleName: MODULE_NAME,
|
2018-01-09 17:31:00 +00:00
|
|
|
multiApp: false,
|
2018-01-03 20:00:38 +00:00
|
|
|
namespace: NAMESPACE,
|
|
|
|
});
|
2017-05-25 22:39:06 +00:00
|
|
|
}
|
2017-05-24 11:37:52 +00:00
|
|
|
|
2017-05-25 07:41:43 +00:00
|
|
|
/**
|
|
|
|
* Globally enable or disable performance monitoring
|
|
|
|
* @param enabled
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2017-12-04 12:07:41 +00:00
|
|
|
setPerformanceCollectionEnabled(enabled: boolean): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).setPerformanceCollectionEnabled(enabled);
|
2017-05-25 07:41:43 +00:00
|
|
|
}
|
|
|
|
|
2017-05-24 11:37:52 +00:00
|
|
|
/**
|
|
|
|
* Returns a new trace instance
|
|
|
|
* @param trace
|
|
|
|
*/
|
2017-12-04 12:07:41 +00:00
|
|
|
newTrace(trace: string): Trace {
|
2017-05-24 11:37:52 +00:00
|
|
|
return new Trace(this, trace);
|
|
|
|
}
|
|
|
|
}
|
2017-11-23 17:29:40 +00:00
|
|
|
|
|
|
|
export const statics = {};
|