diff --git a/lib/index.d.ts b/lib/index.d.ts index b89da276..9294e5a2 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -25,10 +25,8 @@ declare module "react-native-firebase" { auth: FirebaseModuleAndStatics; // config: FirebaseModule; crash: FirebaseModuleAndStatics; + crashlytics: FirebaseModuleAndStatics; database: FirebaseModuleAndStatics; - fabric: { - crashlytics: FirebaseModuleAndStatics; - }; firestore: FirebaseModuleAndStatics; iid: FirebaseModuleAndStatics // invites: FirebaseModuleAndStatics @@ -64,10 +62,8 @@ declare module "react-native-firebase" { auth(): RNFirebase.auth.Auth; // config(): RNFirebase.config.Config; crash(): RNFirebase.crash.Crash; + crashlytics(): RNFirebase.crashlytics.Crashlytics; database(): RNFirebase.database.Database; - fabric: { - crashlytics(): RNFirebase.crashlytics.Crashlytics, - }; firestore(): RNFirebase.firestore.Firestore; iid(): RNFirebase.iid.InstanceId; // invites(): RNFirebase.invites.Invites; diff --git a/lib/modules/core/app.js b/lib/modules/core/app.js index 2d225544..82ea6230 100644 --- a/lib/modules/core/app.js +++ b/lib/modules/core/app.js @@ -13,9 +13,7 @@ import Auth, { NAMESPACE as AuthNamespace } from '../auth'; import Analytics, { NAMESPACE as AnalyticsNamespace } from '../analytics'; import Config, { NAMESPACE as ConfigNamespace } from '../config'; import Crash, { NAMESPACE as CrashNamespace } from '../crash'; -import Crashlytics, { - NAMESPACE as CrashlyticsNamespace, -} from '../fabric/crashlytics'; +import Crashlytics, { NAMESPACE as CrashlyticsNamespace } from '../crashlytics'; import Database, { NAMESPACE as DatabaseNamespace } from '../database'; import Firestore, { NAMESPACE as FirestoreNamespace } from '../firestore'; import InstanceId, { NAMESPACE as InstanceIdNamespace } from '../iid'; @@ -44,10 +42,8 @@ export default class App { auth: () => Auth; config: () => Config; crash: () => Crash; + crashlytics: () => Crashlytics; database: () => Database; - fabric: { - crashlytics: () => Crashlytics, - }; firestore: () => Firestore; iid: () => InstanceId; invites: () => Invites; @@ -86,10 +82,8 @@ export default class App { this.auth = APPS.appModule(this, AuthNamespace, Auth); this.config = APPS.appModule(this, ConfigNamespace, Config); this.crash = APPS.appModule(this, CrashNamespace, Crash); + this.crashlytics = APPS.appModule(this, CrashlyticsNamespace, Crashlytics); this.database = APPS.appModule(this, DatabaseNamespace, Database); - this.fabric = { - crashlytics: APPS.appModule(this, CrashlyticsNamespace, Crashlytics), - }; this.firestore = APPS.appModule(this, FirestoreNamespace, Firestore); this.iid = APPS.appModule(this, InstanceIdNamespace, InstanceId); this.invites = APPS.appModule(this, InvitesNamespace, Invites); diff --git a/lib/modules/core/firebase.js b/lib/modules/core/firebase.js index a4f7d43c..a1eefd3d 100644 --- a/lib/modules/core/firebase.js +++ b/lib/modules/core/firebase.js @@ -29,7 +29,7 @@ import { import { statics as CrashlyticsStatics, MODULE_NAME as CrashlyticsModuleName, -} from '../fabric/crashlytics'; +} from '../crashlytics'; import { statics as DatabaseStatics, MODULE_NAME as DatabaseModuleName, @@ -77,8 +77,8 @@ import type { AuthModule, ConfigModule, CrashModule, + CrashlyticsModule, DatabaseModule, - FabricModule, FirebaseOptions, FirestoreModule, InstanceIdModule, @@ -99,8 +99,8 @@ class Firebase { auth: AuthModule; config: ConfigModule; crash: CrashModule; + crashlytics: CrashlyticsModule; database: DatabaseModule; - fabric: FabricModule; firestore: FirestoreModule; iid: InstanceIdModule; invites: InvitesModule; @@ -131,18 +131,16 @@ class Firebase { ConfigModuleName ); this.crash = APPS.moduleAndStatics('crash', CrashStatics, CrashModuleName); + this.crashlytics = APPS.moduleAndStatics( + 'crashlytics', + CrashlyticsStatics, + CrashlyticsModuleName + ); this.database = APPS.moduleAndStatics( 'database', DatabaseStatics, DatabaseModuleName ); - this.fabric = { - crashlytics: APPS.moduleAndStatics( - 'crashlytics', - CrashlyticsStatics, - CrashlyticsModuleName - ), - }; this.firestore = APPS.moduleAndStatics( 'firestore', FirestoreStatics, diff --git a/lib/modules/crash/index.js b/lib/modules/crash/index.js index 2d9a0a8f..2d8eeeff 100644 --- a/lib/modules/crash/index.js +++ b/lib/modules/crash/index.js @@ -19,6 +19,9 @@ export default class Crash extends ModuleBase { hasShards: false, namespace: NAMESPACE, }); + console.warn( + 'Crash Reporting is deprecated, consider switching to Crashlytics which is now the primary crash reporter for Firebase.' + ); } /** diff --git a/lib/modules/fabric/crashlytics/index.js b/lib/modules/crashlytics/index.js similarity index 92% rename from lib/modules/fabric/crashlytics/index.js rename to lib/modules/crashlytics/index.js index 7e797774..0f97a144 100644 --- a/lib/modules/fabric/crashlytics/index.js +++ b/lib/modules/crashlytics/index.js @@ -2,10 +2,10 @@ * @flow * Crash Reporting representation wrapper */ -import ModuleBase from '../../../utils/ModuleBase'; -import { getNativeModule } from '../../../utils/native'; +import ModuleBase from '../../utils/ModuleBase'; +import { getNativeModule } from '../../utils/native'; -import type App from '../../core/app'; +import type App from '../core/app'; export const MODULE_NAME = 'RNFirebaseCrashlytics'; export const NAMESPACE = 'crashlytics'; diff --git a/lib/types/index.js b/lib/types/index.js index cce17c8b..3257b6ac 100644 --- a/lib/types/index.js +++ b/lib/types/index.js @@ -9,8 +9,8 @@ import type Config from '../modules/config'; import { typeof statics as ConfigStatics } from '../modules/config'; import type Crash from '../modules/crash'; import { typeof statics as CrashStatics } from '../modules/crash'; -import type Crashlytics from '../modules/fabric/crashlytics'; -import { typeof statics as CrashlyticsStatics } from '../modules/fabric/crashlytics'; +import type Crashlytics from '../modules/crashlytics'; +import { typeof statics as CrashlyticsStatics } from '../modules/crashlytics'; import type Database from '../modules/database'; import { typeof statics as DatabaseStatics } from '../modules/database'; import type Firestore from '../modules/firestore'; @@ -141,6 +141,12 @@ export type CrashModule = { nativeModuleExists: boolean, } & CrashStatics; +/* Crashlytics types */ +export type CrashlyticsModule = { + (): Crashlytics, + nativeModuleExists: boolean, +} & CrashlyticsStatics; + /* Database types */ export type DatabaseModule = { @@ -158,16 +164,6 @@ export type DatabaseModifier = { valueType?: string, }; -/* Fabric types */ -export type CrashlyticsModule = { - (): Crashlytics, - nativeModuleExists: boolean, -} & CrashlyticsStatics; - -export type FabricModule = { - crashlytics: CrashlyticsModule, -}; - /* Firestore types */ export type FirestoreModule = { diff --git a/lib/utils/apps.js b/lib/utils/apps.js index 57ac16ea..01c37fa7 100644 --- a/lib/utils/apps.js +++ b/lib/utils/apps.js @@ -188,9 +188,6 @@ export default { // default to the 'DEFAULT' app if no arg provided - will throw an error // if default app not initialized _app = this.app(DEFAULT_APP_NAME); - if (namespace === 'crashlytics') { - return _app.fabric[namespace](); - } // $FlowExpectedError: Flow doesn't support indexable signatures on classes: https://github.com/facebook/flow/issues/1323 const module = _app[namespace]; return module(_serviceUrl); diff --git a/tests/src/tests/crashlytics/crashlyticsTests.js b/tests/src/tests/crashlytics/crashlyticsTests.js index 3cb4472a..c2586ced 100644 --- a/tests/src/tests/crashlytics/crashlyticsTests.js +++ b/tests/src/tests/crashlytics/crashlyticsTests.js @@ -2,45 +2,43 @@ export default function addTests({ describe, it, firebase }) { describe('Crashlytics', () => { it('log: it should log without error', () => new Promise(resolve => { - firebase.native.fabric.crashlytics().log('Test log'); + firebase.native.crashlytics().log('Test log'); resolve(); })); it('recordError: it should record an error without error', () => new Promise(resolve => { - firebase.native.fabric.crashlytics().recordError(1234, 'Test error'); + firebase.native.crashlytics().recordError(1234, 'Test error'); resolve(); })); it('setBoolValue: it should set a boolean value without error', () => new Promise(resolve => { - firebase.native.fabric.crashlytics().setBoolValue('boolKey', true); + firebase.native.crashlytics().setBoolValue('boolKey', true); resolve(); })); it('setFloatValue: it should set a float value without error', () => new Promise(resolve => { - firebase.native.fabric.crashlytics().setFloatValue('floatKey', 1.23); + firebase.native.crashlytics().setFloatValue('floatKey', 1.23); resolve(); })); it('setIntValue: it should set an integer value without error', () => new Promise(resolve => { - firebase.native.fabric.crashlytics().setIntValue('intKey', 123); + firebase.native.crashlytics().setIntValue('intKey', 123); resolve(); })); it('setStringValue: it should set a string value without error', () => new Promise(resolve => { - firebase.native.fabric - .crashlytics() - .setStringValue('stringKey', 'test'); + firebase.native.crashlytics().setStringValue('stringKey', 'test'); resolve(); })); it('setUserIdentifier: it should set the user ID without error', () => new Promise(resolve => { - firebase.native.fabric.crashlytics().setUserIdentifier('1234'); + firebase.native.crashlytics().setUserIdentifier('1234'); resolve(); })); }); diff --git a/tests/src/tests/crashlytics/index.js b/tests/src/tests/crashlytics/index.js index cb18b392..882c1f77 100644 --- a/tests/src/tests/crashlytics/index.js +++ b/tests/src/tests/crashlytics/index.js @@ -2,11 +2,7 @@ import firebase from '../../firebase'; import TestSuite from '../../../lib/TestSuite'; import crashlyticsTests from './crashlyticsTests'; -const suite = new TestSuite( - 'Crashlytics', - 'firebase.fabric.crashlytics()', - firebase -); +const suite = new TestSuite('Crashlytics', 'firebase.crashlytics()', firebase); // bootstrap tests suite.addTests(crashlyticsTests);