[Added]
Sentry has a complete manual integration guide. It might be waste of time for you to read this article!
https://docs.sentry.io/clients/react-native/manual-setup/
[/Added]
[Added again]
Now we can use fully integrated Sentry SDK for React Native:
https://github.com/getsentry/sentry-react-native
[/Added again]
Sentry is a great tool to collect runtime errors.
react-native-sentry is an official package by Sentry. While it is still in Beta, works well.
https://github.com/getsentry/react-native-sentry
Official document uses react-native link
, but I don't use it as it causes errors very often.
https://docs.sentry.io/clients/react-native/
yarn add react-native-sentry
iOS
open node_modules/react-native-sentry/ios/
Then, manually drug and drop RNSentry.xcodeproj
to Xcode Library. This pattern is commonly used to install native modules to React Native apps.
See my picture here:
https://github.com/kmagiera/react-native-gesture-handler/issues/205#issuecomment-449900414
Then, add libRNSentry.a
to Build phases > Link Binary With Libraries
. Note that you must not add neither libRNSentryStatic.a
nor Sentry.framework
which causes build errors.
Android
Open android/settings.gradle
and add the following lines:
include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')
Then, open android/app/build.gradle
and add the following lines:
dependencies {
compile project(':react-native-sentry')
// other code here
}
Finally, open android/app/src/main/java/com/nupp1/MainApplication.java
and add the package:
package com.your.app;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import io.sentry.RNSentryPackage; // <-- Add this line
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNSentryPackage() // <-- Add this line
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
I hope this helps you.
Top comments (0)