From 91b7281d45e769f8b97148c0b5021a2198b6999c Mon Sep 17 00:00:00 2001 From: Salakar Date: Wed, 12 Jul 2017 16:11:07 +0100 Subject: [PATCH] [both] re-enabled analytics, admob, crash & perf modules --- lib/firebase-app.js | 27 +++++++++++++++++++-------- lib/firebase.js | 22 +++++++++++++++++++++- lib/modules/perf/index.js | 2 +- tests/src/main.js | 2 -- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/lib/firebase-app.js b/lib/firebase-app.js index 54264a1d..f5fdded6 100644 --- a/lib/firebase-app.js +++ b/lib/firebase-app.js @@ -2,16 +2,11 @@ import { NativeModules } from 'react-native'; import INTERNALS from './internals'; -// modules -// todo +import AdMob, { statics as AdMobStatics } from './modules/admob'; +import Auth, { statics as AuthStatics } from './modules/auth'; +import Analytics from './modules/analytics'; import Crash from './modules/crash'; import Performance from './modules/perf'; -import Analytics from './modules/analytics'; -import AdMob, { statics as AdMobStatics } from './modules/admob'; -// ---- - - -import Auth, { statics as AuthStatics } from './modules/auth'; import RemoteConfig from './modules/config'; import Storage, { statics as StorageStatics } from './modules/storage'; import Database, { statics as DatabaseStatics } from './modules/database'; @@ -56,14 +51,26 @@ export default class FirebaseApp { * MODULES */ + get admob() { + return this._staticsOrModuleInstance('admob', AdMobStatics, AdMob); + } + get auth() { return this._staticsOrModuleInstance('auth', AuthStatics, Auth); } + get analytics() { + return this._staticsOrModuleInstance('analytics', {}, Analytics); + } + get config() { return this._staticsOrModuleInstance('config', {}, RemoteConfig); } + get crash() { + return this._staticsOrModuleInstance('crash', {}, Crash); + } + get database() { return this._staticsOrModuleInstance('database', DatabaseStatics, Database); } @@ -72,6 +79,10 @@ export default class FirebaseApp { return this._staticsOrModuleInstance('messaging', MessagingStatics, Messaging); } + get perf() { + return this._staticsOrModuleInstance('perf', {}, Performance); + } + get storage() { return this._staticsOrModuleInstance('storage', StorageStatics, Storage); } diff --git a/lib/firebase.js b/lib/firebase.js index 07759d6d..456547ab 100644 --- a/lib/firebase.js +++ b/lib/firebase.js @@ -11,7 +11,11 @@ import PACKAGE from './../package.json'; import FirebaseApp from './firebase-app'; // module imports +import AdMob, { statics as AdMobStatics } from './modules/admob'; import Auth, { statics as AuthStatics } from './modules/auth'; +import Analytics from './modules/analytics'; +import Crash from './modules/crash'; +import Performance from './modules/perf'; import RemoteConfig from './modules/config'; import Storage, { statics as StorageStatics } from './modules/storage'; import Database, { statics as DatabaseStatics } from './modules/database'; @@ -92,7 +96,7 @@ class FirebaseCore { * @android * @return {RNFirebase.GoogleApiAvailabilityType|{isAvailable: boolean, status: number}} */ - get googleApiAvailabilty(): GoogleApiAvailabilityType { + get googleApiAvailability(): GoogleApiAvailabilityType { return FirebaseCoreModule.googleApiAvailability || { isAvailable: true, status: 0 }; } @@ -100,14 +104,26 @@ class FirebaseCore { * MODULES */ + get admob() { + return this._appNamespaceOrStatics('admob', AdMobStatics, AdMob); + } + get auth() { return this._appNamespaceOrStatics('auth', AuthStatics, Auth); } + get analytics() { + return this._appNamespaceOrStatics('analytics', {}, Analytics); + } + get config() { return this._appNamespaceOrStatics('config', {}, RemoteConfig); } + get crash() { + return this._appNamespaceOrStatics('crash', {}, Crash); + } + get database() { return this._appNamespaceOrStatics('database', DatabaseStatics, Database); @@ -117,6 +133,10 @@ class FirebaseCore { return this._appNamespaceOrStatics('messaging', MessagingStatics, Messaging); } + get perf() { + return this._appNamespaceOrStatics('perf', DatabaseStatics, Performance); + } + get storage() { return this._appNamespaceOrStatics('storage', StorageStatics, Storage); } diff --git a/lib/modules/perf/index.js b/lib/modules/perf/index.js index 69121a5e..43e42c8f 100644 --- a/lib/modules/perf/index.js +++ b/lib/modules/perf/index.js @@ -4,7 +4,7 @@ import ModuleBase from '../../utils/ModuleBase'; export default class PerformanceMonitoring extends ModuleBase { constructor(firebaseApp: Object, options: Object = {}) { - super(firebaseApp, options, 'Perf'); + super(firebaseApp, options, 'Performance'); } /** diff --git a/tests/src/main.js b/tests/src/main.js index e871e2b9..3bf208c0 100644 --- a/tests/src/main.js +++ b/tests/src/main.js @@ -3,7 +3,6 @@ import { Provider } from 'react-redux'; import CoreContainer from './containers/CoreContainer'; import setupStore from './store/setup'; import { setupSuites } from './tests/index'; -import { NativeModules } from 'react-native'; global.Promise = require('bluebird'); @@ -36,7 +35,6 @@ function bootstrap() { state: State; componentDidMount() { - console.warn(JSON.stringify(Object.keys(NativeModules))); setupStore((store) => { setupSuites(store); this.setState({