npm.io
0.2.1 • Published 9 years ago

react-native-crasheye

Licence
MIT
Version
0.2.1
Deps
0
Vulns
0
Weekly
0

react-native-crasheye

NPM

Introduction

Crasheye react native module.

Base on:

  • Crasheye Android SDK 2.2.1
  • Crasheye iOS SDK 2.5.1

More infomation: http://www.crasheye.cn/sdk

Getting started

$ npm install react-native-crasheye --save

Mostly automatic installation

$ react-native link react-native-crasheye

You should add crasheye SDK to your iOS project. Official tutorial is here.

Manual installation
iOS
  1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
  2. Go to node_modules ➜ react-native-crasheye and add RNCrasheye.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNCrasheye.a to your project's Build Phases ➜ Link Binary With Libraries
  4. Add crasheye SDK to your iOS project. Official tutorial is here.
  5. Run your project (Cmd+R)
Android
  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.cooclsee.crasheye.RNCrasheyePackage; to the imports at the top of the file
  • Add new RNCrasheyePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-crasheye'
    project(':react-native-crasheye').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-crasheye/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
    compile project(':react-native-crasheye')

Usage

Import
import Crasheye from 'react-native-crasheye';
Initialize SDK
Crasheye.init({
	appKey: 'your appKey', // required
	channelID: '', // option
	appVersion: '', // option
	flushOnlyOverWiFi: false, // default false
	userIdentifier: '', // option
	logging: {
		lines: 1000, // option, less than 1000
		filter: '', // option
	}
});
Get SDK Version
Crasheye.getSDKVersion()
  .then(ver => console.log(ver));
// or
let ver = await Crasheye.getSDKVersion();
Get Device ID
Crasheye.getDeviceId()
  .then(deviceId => console.log(deviceId));
// or
let deviceId = await Crasheye.getDeviceId();
Add Breadcrumb
Crasheye.leaveBreadcrumb('the breadcrumb content');
Send Exception
Crasheye.sendScriptException('errorTitle', 'exception content');
Add Extra Data
Crasheye.addExtraData('key', 'value');

Keywords