2
0
mirror of synced 2025-01-18 10:22:35 +00:00

[android][ios][js][tests] remove deprecated .crash()

This commit is contained in:
Salakar 2018-08-04 22:41:39 +01:00
parent edf28b9a6d
commit 1777e80427
15 changed files with 1 additions and 352 deletions

View File

@ -1,52 +0,0 @@
package io.invertase.firebase.crash;
import android.util.Log;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.google.firebase.crash.FirebaseCrash;
public class RNFirebaseCrash extends ReactContextBaseJavaModule {
private static final String TAG = "RNFirebaseCrash";
public RNFirebaseCrash(ReactApplicationContext reactContext) {
super(reactContext);
Log.d(TAG, "New instance");
}
@Override
public String getName() {
return TAG;
}
@ReactMethod
public void log(final String message) {
FirebaseCrash.log(message);
}
@ReactMethod
public void logcat(final int level, final String tag, final String message) {
FirebaseCrash.logcat(level, tag, message);
}
@ReactMethod
public void report(String message) {
FirebaseCrash.report(new Exception(message));
}
@ReactMethod
public void setCrashCollectionEnabled(Boolean enabled) {
FirebaseCrash.setCrashCollectionEnabled(enabled);
}
@ReactMethod
public void isCrashCollectionEnabled(Promise promise) {
Boolean isEnabled = FirebaseCrash.isCrashCollectionEnabled();
promise.resolve(isEnabled);
}
}

View File

@ -1,39 +0,0 @@
package io.invertase.firebase.crash;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("unused")
public class RNFirebaseCrashPackage implements ReactPackage {
public RNFirebaseCrashPackage() {
}
/**
* @param reactContext react application context that can be used to create modules
* @return list of native modules to register with the newly created catalyst instance
*/
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new RNFirebaseCrash(reactContext));
return modules;
}
/**
* @param reactContext
* @return a list of view managers that should be registered with {@link UIManagerModule}
*/
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}

View File

@ -99,7 +99,6 @@ dependencies {
implementation "com.google.firebase:firebase-ads:15.0.1"
implementation "com.google.firebase:firebase-auth:16.0.2"
implementation "com.google.firebase:firebase-config:16.0.0"
implementation "com.google.firebase:firebase-crash:16.0.1"
implementation "com.google.firebase:firebase-database:16.0.1"
implementation "com.google.firebase:firebase-firestore:17.0.2"
implementation "com.google.firebase:firebase-functions:16.0.1"

View File

@ -1,52 +0,0 @@
describe('crash()', () => {
describe('setCrashCollectionEnabled()', () => {
it('true', async () => {
await firebase.crash().setCrashCollectionEnabled(true);
await sleep(100);
const enabled = await firebase.crash().isCrashCollectionEnabled();
should.equal(enabled, true, 'collection enabled boolean should be true');
});
it('false', async () => {
await firebase.crash().setCrashCollectionEnabled(false);
// does not exist on ios
if (device.getPlatform() === 'android') {
await sleep(150);
const enabled = await firebase.crash().isCrashCollectionEnabled();
should.equal(
enabled,
false,
'collection enabled boolean should be false'
);
}
});
});
describe('log()', () => {
it('accepts a string log', async () => {
await firebase.crash().log('hello world');
await sleep(50);
});
});
describe('logcat()', () => {
it('accepts a log level, log tag and message', async () => {
await firebase.crash().logcat(0, 'HELLO_TAG', 'hello world');
await sleep(50);
});
});
describe('report()', () => {
it('accepts an error with customisable stack size', async () => {
const error = new Error('Oh noes!');
await firebase.crash().report(error);
await firebase.crash().report(error, 5);
error.code = 'NETWORK_ERROR';
await firebase.crash().report(error);
delete error.message;
await firebase.crash().report(error);
await sleep(50);
});
});
});

View File

@ -21,7 +21,6 @@ target 'testing' do
pod 'Firebase/AdMob', '~> 5.3.0'
pod 'Firebase/Auth', '~> 5.3.0'
pod 'Firebase/Core', '~> 5.3.0'
pod 'Firebase/Crash', '~> 5.3.0'
pod 'Firebase/Database', '~> 5.3.0'
pod 'Firebase/Functions', '~> 5.3.0'
pod 'Firebase/DynamicLinks', '~> 5.3.0'

View File

@ -212,7 +212,7 @@ PODS:
- React/Core
- React/fishhook
- React/RCTBlob
- RNFirebase (4.2.0):
- RNFirebase (4.3.8):
- Firebase/Core
- React
- yoga (0.55.3.React)

View File

@ -27,7 +27,6 @@
839D916F1EF3E20B0077C7C8 /* RNFirebaseAnalytics.m in Sources */ = {isa = PBXBuildFile; fileRef = 839D91561EF3E20A0077C7C8 /* RNFirebaseAnalytics.m */; };
839D91701EF3E20B0077C7C8 /* RNFirebaseAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = 839D91591EF3E20A0077C7C8 /* RNFirebaseAuth.m */; };
839D91711EF3E20B0077C7C8 /* RNFirebaseRemoteConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 839D915C1EF3E20A0077C7C8 /* RNFirebaseRemoteConfig.m */; };
839D91721EF3E20B0077C7C8 /* RNFirebaseCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = 839D915F1EF3E20A0077C7C8 /* RNFirebaseCrash.m */; };
839D91731EF3E20B0077C7C8 /* RNFirebaseDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 839D91621EF3E20A0077C7C8 /* RNFirebaseDatabase.m */; };
839D91751EF3E20B0077C7C8 /* RNFirebasePerformance.m in Sources */ = {isa = PBXBuildFile; fileRef = 839D91681EF3E20A0077C7C8 /* RNFirebasePerformance.m */; };
83AAA0792063DEC2007EC5F7 /* RNFirebaseInvites.m in Sources */ = {isa = PBXBuildFile; fileRef = 83AAA0772063DEC2007EC5F7 /* RNFirebaseInvites.m */; };
@ -90,8 +89,6 @@
839D91591EF3E20A0077C7C8 /* RNFirebaseAuth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFirebaseAuth.m; sourceTree = "<group>"; };
839D915B1EF3E20A0077C7C8 /* RNFirebaseRemoteConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFirebaseRemoteConfig.h; sourceTree = "<group>"; };
839D915C1EF3E20A0077C7C8 /* RNFirebaseRemoteConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFirebaseRemoteConfig.m; sourceTree = "<group>"; };
839D915E1EF3E20A0077C7C8 /* RNFirebaseCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFirebaseCrash.h; sourceTree = "<group>"; };
839D915F1EF3E20A0077C7C8 /* RNFirebaseCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFirebaseCrash.m; sourceTree = "<group>"; };
839D91611EF3E20A0077C7C8 /* RNFirebaseDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFirebaseDatabase.h; sourceTree = "<group>"; };
839D91621EF3E20A0077C7C8 /* RNFirebaseDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFirebaseDatabase.m; sourceTree = "<group>"; };
839D91671EF3E20A0077C7C8 /* RNFirebasePerformance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFirebasePerformance.h; sourceTree = "<group>"; };
@ -160,7 +157,6 @@
839D91541EF3E20A0077C7C8 /* analytics */,
839D91571EF3E20A0077C7C8 /* auth */,
839D915A1EF3E20A0077C7C8 /* config */,
839D915D1EF3E20A0077C7C8 /* crash */,
839D91601EF3E20A0077C7C8 /* database */,
8376F70D1F7C141500D45A85 /* firestore */,
839D91631EF3E20A0077C7C8 /* messaging */,
@ -277,16 +273,6 @@
path = RNFirebase/config;
sourceTree = "<group>";
};
839D915D1EF3E20A0077C7C8 /* crash */ = {
isa = PBXGroup;
children = (
839D915E1EF3E20A0077C7C8 /* RNFirebaseCrash.h */,
839D915F1EF3E20A0077C7C8 /* RNFirebaseCrash.m */,
);
name = crash;
path = RNFirebase/crash;
sourceTree = "<group>";
};
839D91601EF3E20A0077C7C8 /* database */ = {
isa = PBXGroup;
children = (
@ -416,7 +402,6 @@
83AAA0792063DEC2007EC5F7 /* RNFirebaseInvites.m in Sources */,
8323CF071F6FBD870071420B /* NativeExpressComponent.m in Sources */,
83C3EEEE1FA1EACC00B64D3C /* RNFirebaseUtil.m in Sources */,
839D91721EF3E20B0077C7C8 /* RNFirebaseCrash.m in Sources */,
839D91751EF3E20B0077C7C8 /* RNFirebasePerformance.m in Sources */,
8323CF061F6FBD870071420B /* BannerComponent.m in Sources */,
839D916D1EF3E20B0077C7C8 /* RNFirebaseAdMobInterstitial.m in Sources */,
@ -520,7 +505,6 @@
"$(SRCROOT)/../../../ios/Pods/FirebaseAnalytics/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseAuth/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseCore/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseCrash/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseDatabase/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseDynamicLinks/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseFirestore/Frameworks",
@ -564,7 +548,6 @@
"$(SRCROOT)/../../../ios/Pods/FirebaseAnalytics/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseAuth/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseCore/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseCrash/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseDatabase/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseDynamicLinks/Frameworks",
"$(SRCROOT)/../../../ios/Pods/FirebaseFirestore/Frameworks",

View File

@ -1,19 +0,0 @@
#ifndef RNFirebaseCrash_h
#define RNFirebaseCrash_h
#import <Foundation/Foundation.h>
#if __has_include(<FirebaseCrash/FIRCrashLog.h>)
#import <React/RCTBridgeModule.h>
@interface RNFirebaseCrash : NSObject <RCTBridgeModule> {
}
@end
#else
@interface RNFirebaseCrash : NSObject
@end
#endif
#endif

View File

@ -1,35 +0,0 @@
#import "RNFirebaseCrash.h"
#if __has_include(<FirebaseCrash/FIRCrashLog.h>)
#import <FirebaseCrash/FIRCrashLog.h>
@implementation RNFirebaseCrash
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(log:(NSString *)message) {
FIRCrashLog(@"%@", message);
}
RCT_EXPORT_METHOD(logcat:(nonnull NSNumber *) level tag:(NSString *) tag message:(NSString *) message) {
FIRCrashLog(@"%@", message);
}
RCT_EXPORT_METHOD(report:(NSString *) message) {
FIRCrashLog(@"%@", message);
}
RCT_EXPORT_METHOD(setCrashCollectionEnabled:(BOOL *) enabled) {
// Not available yet
}
RCT_EXPORT_METHOD(isCrashCollectionEnabled:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
// Not available yet
resolve(@YES);
}
@end
#else
@implementation RNFirebaseCrash
@end
#endif

23
lib/index.d.ts vendored
View File

@ -26,7 +26,6 @@ declare module 'react-native-firebase' {
RNFirebase.auth.AuthStatics
>;
config: FirebaseModuleAndStatics<RNFirebase.config.Config>;
crash: FirebaseModuleAndStatics<RNFirebase.crash.Crash>;
crashlytics: FirebaseModuleAndStatics<RNFirebase.crashlytics.Crashlytics>;
database: FirebaseModuleAndStatics<
RNFirebase.database.Database,
@ -82,7 +81,6 @@ declare module 'react-native-firebase' {
analytics(): RNFirebase.Analytics;
auth(): RNFirebase.auth.Auth;
config(): RNFirebase.config.Config;
crash(): RNFirebase.crash.Crash;
crashlytics(): RNFirebase.crashlytics.Crashlytics;
database(): RNFirebase.database.Database;
firestore(): RNFirebase.firestore.Firestore;
@ -1548,27 +1546,6 @@ declare module 'react-native-firebase' {
}
}
namespace crash {
interface Crash {
/** Logs a message that will appear in a subsequent crash report. */
log(message: string): void;
/**
* Android: Logs a message that will appear in a subsequent crash report as well as in logcat.
* iOS: Logs the message in the subsequest crash report only (same as log).
*/
logcat(level: number, tag: string, message: string): void;
/**
* Files a crash report, along with any previous logs to Firebase.
* An Error object must be passed into the report method.
*/
report(error: RnError, maxStackSize: Number): void;
[key: string]: any;
}
}
namespace crashlytics {
interface Crashlytics {
/**

View File

@ -12,7 +12,6 @@ import AdMob, { NAMESPACE as AdmobNamespace } from '../admob';
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 '../crashlytics';
import Database, { NAMESPACE as DatabaseNamespace } from '../database';
import Firestore, { NAMESPACE as FirestoreNamespace } from '../firestore';
@ -42,7 +41,6 @@ export default class App {
analytics: () => Analytics;
auth: () => Auth;
config: () => Config;
crash: () => Crash;
crashlytics: () => Crashlytics;
database: () => Database;
firestore: () => Firestore;
@ -83,7 +81,6 @@ export default class App {
this.analytics = APPS.appModule(this, AnalyticsNamespace, Analytics);
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.firestore = APPS.appModule(this, FirestoreNamespace, Firestore);

View File

@ -22,10 +22,6 @@ import {
statics as ConfigStatics,
MODULE_NAME as ConfigModuleName,
} from '../config';
import {
statics as CrashStatics,
MODULE_NAME as CrashModuleName,
} from '../crash';
import {
statics as CrashlyticsStatics,
MODULE_NAME as CrashlyticsModuleName,
@ -80,7 +76,6 @@ import type {
AnalyticsModule,
AuthModule,
ConfigModule,
CrashModule,
CrashlyticsModule,
DatabaseModule,
FirebaseOptions,
@ -103,7 +98,6 @@ class Firebase {
analytics: AnalyticsModule;
auth: AuthModule;
config: ConfigModule;
crash: CrashModule;
crashlytics: CrashlyticsModule;
database: DatabaseModule;
firestore: FirestoreModule;
@ -136,7 +130,6 @@ class Firebase {
ConfigStatics,
ConfigModuleName
);
this.crash = APPS.moduleAndStatics('crash', CrashStatics, CrashModuleName);
this.crashlytics = APPS.moduleAndStatics(
'crashlytics',
CrashlyticsStatics,

View File

@ -1,90 +0,0 @@
/**
* @flow
* Crash Reporting representation wrapper
*/
import ModuleBase from '../../utils/ModuleBase';
import { getNativeModule } from '../../utils/native';
import type App from '../core/app';
import type { FirebaseError } from '../../types';
export const MODULE_NAME = 'RNFirebaseCrash';
export const NAMESPACE = 'crash';
export default class Crash extends ModuleBase {
constructor(app: App) {
super(app, {
moduleName: MODULE_NAME,
multiApp: false,
hasShards: false,
namespace: NAMESPACE,
});
console.warn(
'Crash Reporting is deprecated, consider switching to Crashlytics which is now the primary crash reporter for Firebase.'
);
}
/**
* Enables/Disables crash reporting
* @param enabled
*/
setCrashCollectionEnabled(enabled: boolean): void {
getNativeModule(this).setCrashCollectionEnabled(enabled);
}
/**
* Returns whether or not crash reporting is currently enabled
* @returns {Promise.<boolean>}
*/
isCrashCollectionEnabled(): Promise<boolean> {
return getNativeModule(this).isCrashCollectionEnabled();
}
/**
* Logs a message that will appear in a subsequent crash report.
* @param {string} message
*/
log(message: string): void {
getNativeModule(this).log(message);
}
/**
* Logs a message that will appear in a subsequent crash report as well as in logcat.
* NOTE: Android only functionality. iOS will just log the message.
* @param {string} message
* @param {number} level
* @param {string} tag
*/
logcat(level: number, tag: string, message: string): void {
getNativeModule(this).logcat(level, tag, message);
}
/**
* Generates a crash report for the given message. This method should be used for unexpected
* exceptions where recovery is not possible.
* NOTE: on iOS, this will cause the app to crash as it's the only way to ensure the exception
* gets sent to Firebase. Otherwise it just gets lost as a log message.
* @param {Error} error
* @param maxStackSize
*/
report(error: FirebaseError, maxStackSize: number = 10): void {
if (!error || !error.message) return;
let errorMessage = `Message: ${error.message}\r\n`;
if (error.code) {
errorMessage = `${errorMessage}Code: ${error.code}\r\n`;
}
const stackRows = error.stack.split('\n');
errorMessage = `${errorMessage}\r\nStack: \r\n`;
for (let i = 0, len = stackRows.length; i < len; i++) {
if (i === maxStackSize) break;
errorMessage = `${errorMessage} - ${stackRows[i]}\r\n`;
}
getNativeModule(this).report(errorMessage);
}
}
export const statics = {};

View File

@ -7,8 +7,6 @@ import type Auth from '../modules/auth';
import { typeof statics as AuthStatics } from '../modules/auth';
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/crashlytics';
import { typeof statics as CrashlyticsStatics } from '../modules/crashlytics';
import type Database from '../modules/database';
@ -61,7 +59,6 @@ export type FirebaseModuleName =
| 'RNFirebaseAnalytics'
| 'RNFirebaseAuth'
| 'RNFirebaseRemoteConfig'
| 'RNFirebaseCrash'
| 'RNFirebaseCrashlytics'
| 'RNFirebaseDatabase'
| 'RNFirebaseFirestore'
@ -80,7 +77,6 @@ export type FirebaseNamespace =
| 'analytics'
| 'auth'
| 'config'
| 'crash'
| 'crashlytics'
| 'database'
| 'firestore'
@ -138,13 +134,6 @@ export type AuthModule = {
nativeModuleExists: boolean,
} & AuthStatics;
/* Crash types */
export type CrashModule = {
(): Crash,
nativeModuleExists: boolean,
} & CrashStatics;
/* Crashlytics types */
export type CrashlyticsModule = {
(): Crashlytics,

View File

@ -8,7 +8,6 @@ const NAMESPACE_PODS = {
analytics: 'Firebase/Analytics',
auth: 'Firebase/Auth',
config: 'Firebase/RemoteConfig',
crash: 'Firebase/Crash',
database: 'Firebase/Database',
links: 'Firebase/DynamicLinks',
messaging: 'Firebase/Messaging',