2017-12-06 17:25:17 +00:00
|
|
|
/**
|
|
|
|
* @flow
|
|
|
|
* Crash Reporting representation wrapper
|
|
|
|
*/
|
2018-04-03 15:51:05 +00:00
|
|
|
import ModuleBase from '../../utils/ModuleBase';
|
|
|
|
import { getNativeModule } from '../../utils/native';
|
2017-12-06 17:25:17 +00:00
|
|
|
|
2018-04-03 15:51:05 +00:00
|
|
|
import type App from '../core/app';
|
2017-12-06 17:25:17 +00:00
|
|
|
|
2018-01-03 20:00:38 +00:00
|
|
|
export const MODULE_NAME = 'RNFirebaseCrashlytics';
|
|
|
|
export const NAMESPACE = 'crashlytics';
|
2017-12-06 17:25:17 +00:00
|
|
|
|
2018-01-03 20:00:38 +00:00
|
|
|
export default class Crashlytics extends ModuleBase {
|
2018-01-05 17:20:02 +00:00
|
|
|
constructor(app: App) {
|
|
|
|
super(app, {
|
2018-01-03 20:00:38 +00:00
|
|
|
moduleName: MODULE_NAME,
|
2018-01-09 17:31:00 +00:00
|
|
|
multiApp: false,
|
2017-11-21 23:37:05 +00:00
|
|
|
hasShards: false,
|
2018-01-03 20:00:38 +00:00
|
|
|
namespace: NAMESPACE,
|
|
|
|
});
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forces a crash. Useful for testing your application is set up correctly.
|
|
|
|
*/
|
|
|
|
crash(): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).crash();
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs a message that will appear in any subsequent crash reports.
|
|
|
|
* @param {string} message
|
|
|
|
*/
|
|
|
|
log(message: string): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).log(message);
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs a non fatal exception.
|
|
|
|
* @param {string} code
|
|
|
|
* @param {string} message
|
|
|
|
*/
|
|
|
|
recordError(code: number, message: string): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).recordError(code, message);
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a boolean value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setBoolValue(key: string, value: boolean): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).setBoolValue(key, value);
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a float value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setFloatValue(key: string, value: number): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).setFloatValue(key, value);
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set an integer value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setIntValue(key: string, value: number): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).setIntValue(key, value);
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a string value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setStringValue(key: string, value: string): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).setStringValue(key, value);
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the user ID to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setUserIdentifier(userId: string): void {
|
2018-01-05 17:20:02 +00:00
|
|
|
getNativeModule(this).setUserIdentifier(userId);
|
2017-12-06 17:25:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const statics = {};
|