[crashlytics] Move to top level crashlytics namespace
This commit is contained in:
parent
90d35ef6e9
commit
b21e7d0eab
|
@ -25,10 +25,8 @@ declare module "react-native-firebase" {
|
|||
auth: FirebaseModuleAndStatics<RNFirebase.auth.Auth, RNFirebase.auth.AuthStatics>;
|
||||
// config: FirebaseModule<RNFirebase.config.Config>;
|
||||
crash: FirebaseModuleAndStatics<RNFirebase.crash.Crash>;
|
||||
crashlytics: FirebaseModuleAndStatics<RNFirebase.crashlytics.Crashlytics>;
|
||||
database: FirebaseModuleAndStatics<RNFirebase.database.Database, RNFirebase.database.DatabaseStatics>;
|
||||
fabric: {
|
||||
crashlytics: FirebaseModuleAndStatics<RNFirebase.crashlytics.Crashlytics>;
|
||||
};
|
||||
firestore: FirebaseModuleAndStatics<RNFirebase.firestore.Firestore, RNFirebase.firestore.FirestoreStatics>;
|
||||
iid: FirebaseModuleAndStatics<RNFirebase.iid.InstanceId>
|
||||
// invites: FirebaseModuleAndStatics<RNFirebase.invites.Invites>
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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';
|
|
@ -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 = {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue