react-native-firebase-compiled
Version:
A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto
98 lines (78 loc) • 2.4 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.statics = exports.default = exports.NAMESPACE = exports.MODULE_NAME = void 0;
var _Trace = _interopRequireDefault(require("./Trace"));
var _HttpMetric = _interopRequireDefault(require("./HttpMetric"));
var _ModuleBase = _interopRequireDefault(require("../../utils/ModuleBase"));
var _native = require("../../utils/native");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
*
* Performance monitoring representation wrapper
*/
const MODULE_NAME = 'RNFirebasePerformance';
exports.MODULE_NAME = MODULE_NAME;
const NAMESPACE = 'perf';
exports.NAMESPACE = NAMESPACE;
const HTTP_METHODS = {
CONNECT: true,
DELETE: true,
GET: true,
HEAD: true,
OPTIONS: true,
PATCH: true,
POST: true,
PUT: true,
TRACE: true
};
class PerformanceMonitoring extends _ModuleBase.default {
constructor(app) {
super(app, {
moduleName: MODULE_NAME,
hasMultiAppSupport: false,
hasCustomUrlSupport: false,
namespace: NAMESPACE
});
}
/**
* Globally enable or disable performance monitoring
* @param enabled
* @returns {*}
*/
setPerformanceCollectionEnabled(enabled) {
if (typeof enabled !== 'boolean') {
throw new Error('firebase.perf().setPerformanceCollectionEnabled() requires a boolean value');
}
return (0, _native.getNativeModule)(this).setPerformanceCollectionEnabled(enabled);
}
/**
* Returns a new trace instance
* @param trace
*/
newTrace(trace) {
if (typeof trace !== 'string') {
throw new Error('firebase.perf().newTrace() requires a string value');
}
return new _Trace.default(this, trace);
}
/**
* Return a new HttpMetric instance
* @param url
* @param httpMethod
* @returns {HttpMetric}
*/
newHttpMetric(url, httpMethod) {
if (typeof url !== 'string' || typeof httpMethod !== 'string') {
throw new Error('firebase.perf().newHttpMetric() requires url and httpMethod string values');
}
if (!HTTP_METHODS[httpMethod]) {
throw new Error(`firebase.perf().newHttpMetric() httpMethod should be one of ${Object.keys(HTTP_METHODS).join(', ')}`);
}
return new _HttpMetric.default(this, url, httpMethod);
}
}
exports.default = PerformanceMonitoring;
const statics = {};
exports.statics = statics;
;