[crashlytics] Add first version of crashlytics functionality

This commit is contained in:
Chris Bianca
2017-12-06 17:25:17 +00:00
parent e697f11641
commit efeb24d168
19 changed files with 406 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ import Auth, { statics as AuthStatics } from '../auth';
import Analytics, { statics as AnalyticsStatics } from '../analytics';
import Config, { statics as ConfigStatics } from '../config';
import Crash, { statics as CrashStatics } from '../crash';
import Crashlytics, { statics as CrashlyticsStatics } from '../fabric/crashlytics';
import Database, { statics as DatabaseStatics } from '../database';
import Firestore, { statics as FirestoreStatics } from '../firestore';
import Links, { statics as LinksStatics } from '../links';
@@ -26,6 +27,7 @@ import type {
ConfigModule,
CrashModule,
DatabaseModule,
FabricModule,
FirebaseModule,
FirebaseModuleAndStatics,
FirebaseOptions,
@@ -54,6 +56,7 @@ export default class FirebaseApp {
config: ConfigModule;
crash: CrashModule;
database: DatabaseModule;
fabric: FabricModule;
firestore: FirestoreModule;
links: LinksModule;
messaging: MessagingModule;
@@ -77,6 +80,9 @@ export default class FirebaseApp {
this.config = this._staticsOrModuleInstance(ConfigStatics, Config);
this.crash = this._staticsOrModuleInstance(CrashStatics, Crash);
this.database = this._staticsOrModuleInstance(DatabaseStatics, Database);
this.fabric = {
crashlytics: this._staticsOrModuleInstance(CrashlyticsStatics, Crashlytics),
};
this.firestore = this._staticsOrModuleInstance(FirestoreStatics, Firestore);
this.links = this._staticsOrModuleInstance(LinksStatics, Links);
this.messaging = this._staticsOrModuleInstance(MessagingStatics, Messaging);

View File

@@ -14,6 +14,7 @@ import Auth, { statics as AuthStatics } from '../auth';
import Analytics, { statics as AnalyticsStatics } from '../analytics';
import Config, { statics as ConfigStatics } from '../config';
import Crash, { statics as CrashStatics } from '../crash';
import Crashlytics, { statics as CrashlyticsStatics } from '../fabric/crashlytics';
import Database, { statics as DatabaseStatics } from '../database';
import Firestore, { statics as FirestoreStatics } from '../firestore';
import Links, { statics as LinksStatics } from '../links';
@@ -29,6 +30,7 @@ import type {
ConfigModule,
CrashModule,
DatabaseModule,
FabricModule,
FirebaseModule,
FirebaseModuleAndStatics,
FirebaseOptions,
@@ -52,6 +54,7 @@ class FirebaseCore {
config: ConfigModule;
crash: CrashModule;
database: DatabaseModule;
fabric: FabricModule;
firestore: FirestoreModule;
links: LinksModule;
messaging: MessagingModule;
@@ -76,6 +79,9 @@ class FirebaseCore {
this.config = this._appNamespaceOrStatics(ConfigStatics, Config);
this.crash = this._appNamespaceOrStatics(CrashStatics, Crash);
this.database = this._appNamespaceOrStatics(DatabaseStatics, Database);
this.fabric = {
crashlytics: this._appNamespaceOrStatics(CrashlyticsStatics, Crashlytics),
};
this.firestore = this._appNamespaceOrStatics(FirestoreStatics, Firestore);
this.links = this._appNamespaceOrStatics(LinksStatics, Links);
this.messaging = this._appNamespaceOrStatics(MessagingStatics, Messaging);

View File

@@ -0,0 +1,77 @@
/**
* @flow
* Crash Reporting representation wrapper
*/
import ModuleBase from '../../../utils/ModuleBase';
import type FirebaseApp from '../../core/firebase-app';
export default class Crashlytics extends ModuleBase {
static _NAMESPACE = 'crashlytics';
static _NATIVE_MODULE = 'RNFirebaseCrashlytics';
constructor(firebaseApp: FirebaseApp, options: Object = {}) {
super(firebaseApp, options);
}
/**
* Forces a crash. Useful for testing your application is set up correctly.
*/
crash(): void {
this._native.crash();
}
/**
* Logs a message that will appear in any subsequent crash reports.
* @param {string} message
*/
log(message: string): void {
this._native.log(message);
}
/**
* Logs a non fatal exception.
* @param {string} code
* @param {string} message
*/
recordError(code: number, message: string): void {
this._native.recordError(code, message);
}
/**
* Set a boolean value to show alongside any subsequent crash reports.
*/
setBoolValue(key: string, value: boolean): void {
this._native.setBoolValue(key, value);
}
/**
* Set a float value to show alongside any subsequent crash reports.
*/
setFloatValue(key: string, value: number): void {
this._native.setFloatValue(key, value);
}
/**
* Set an integer value to show alongside any subsequent crash reports.
*/
setIntValue(key: string, value: number): void {
this._native.setIntValue(key, value);
}
/**
* Set a string value to show alongside any subsequent crash reports.
*/
setStringValue(key: string, value: string): void {
this._native.setStringValue(key, value);
}
/**
* Set the user ID to show alongside any subsequent crash reports.
*/
setUserIdentifier(userId: string): void {
this._native.setUserIdentifier(userId);
}
}
export const statics = {};

View File

@@ -9,6 +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 Database from '../modules/database';
import { typeof statics as DatabaseStatics } from '../modules/database';
import type Firestore from '../modules/firestore';
@@ -38,8 +40,9 @@ export type FirebaseError = {
export type FirebaseModule = $Subtype<ModuleBase>;
export type FirebaseModuleName = 'admob' | 'analytics' | 'auth' | 'config' | 'crash' | 'database'
| 'firestore' | 'links' | 'messaging' | 'perf' | 'storage' | 'utils';
export type FirebaseModuleName = 'admob' | 'analytics' | 'auth' | 'config' | 'crash'
| 'crashlytics' | 'database' | 'firestore' | 'links' | 'messaging' | 'perf' | 'storage'
| 'utils';
export type FirebaseOptions = {
apiKey: string,
@@ -115,6 +118,16 @@ export type DatabaseModifier = {
valueType?: string;
}
/* Fabric types */
export type CrashlyticsModule = {
(): Crashlytics,
nativeModuleExists: boolean,
} & CrashlyticsStatics;
export type FabricModule = {
crashlytics: CrashlyticsModule,
}
/* Firestore types */
export type FirestoreModule = {