Manual Configuration
If you can’t (or prefer not to) run the linking step, you can use the instructions below to configure your application.
Prerequisite
Before you begin, you need to have already created a sentry.properties
file at the root of your React Native project. An example of this properties file can be found in
Sentry's GitHub.
iOS
Linking the Native Library via CocoaPods
You must link to the native module in your Podfile. In React Native versions 0.60 and above the podspec should be automatically linked. In earlier versions calling react-native link @sentry/react-native
will add the podspec for you.
Otherwise, you can manually link the native module by adding the RNSentry.podspec
to your podfile like below:
pod 'RNSentry', :path => '../node_modules/@sentry/react-native/RNSentry.podspec'
Upload Debug Symbols
Debug symbols provide information that Sentry displays on the Issue Details page to help you triage an issue. With our React Native SDK, debug symbols are used to symbolicate Native layer (iOS/Android) events. When you use Xcode, you can hook directly into the build process to upload debug symbols. When linking, one build phase script is changed and two more are added.
Bundle React Native Code and Images
We modify the React Native build phase (“Bundle React Native code and images”) slightly from this:
export NODE_BINARY=node
../node_modules/react-native/packager/react-native-xcode.sh
To this:
export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export SENTRY_PROPERTIES=../sentry.properties
# If you are using RN 0.46+
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \
../node_modules/react-native/scripts/react-native-xcode.sh
# For RN < 0.46
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \
../node_modules/react-native/packager/react-native-xcode.sh
Additionally, we add a build script named “Upload Debug Symbols to Sentry” to upload debug symbols to Sentry.
Upload Debug Symbols to Sentry
To upload source maps and symbols to Sentry, create a new Run Script build phase using the following script:
export SENTRY_PROPERTIES=../sentry.properties
../node_modules/@sentry/cli/bin/sentry-cli upload-dif "$DWARF_DSYM_FOLDER_PATH"
For bitcode enabled builds via iTunes Connect, additional steps are required. Follow the instructions in Sentry's bitcode documentation to set up uploads of symbols for all build variants.
By default, uploading of debug simulator builds is disabled for speed reasons. If you want to generate debug symbols for debug builds, you can pass --allow-fetch
as a parameter to react-native-xcode
in the above mentioned build phase.
Using node with nvm or Volta
If you are using nvm or notion, Xcode has trouble locating the default node binary, which can look similar to the troubleshooting example.
Android
For Android, we hook into Gradle for the source map build process. When you run react-native link
or yarn sentry-wizard -i reactNative -p ios android
(if react-native > 0.60
), the Gradle files are automatically updated.
Enable Gradle Integration
We enable the Gradle integration in your android/app/build.gradle
file by adding the following line after the react.gradle
line:
android/app/build.gradle
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
Enable Logging for sentry-cli
You can also enable logging for sentry-cli
by adding this config before the above apply from:
line:
android/app/build.gradle
project.ext.sentryCli = [
logLevel: "debug"
]
Fetch sentry.properties
We also support fetching different sentry.properties
files for different flavors. For that, you need to add:
android/app/build.gradle
project.ext.sentryCli = [
logLevel: "debug",
flavorAware: true
]
The corresponding flavor files should also be placed within the specific build type folder where you intend to use them. For example, the "Android release" flavor would be react-native/android/sentry-release.properties
.
We recommend leaving logLevel: "debug"
since we look for specific sentry.properties
files depending on your flavor's name.
Include the project by adding it to your dependency list in android/app/build.gradle
:
android/app/build.gradle
dependencies {
// ... other dependencies listed here //
implementation project(':@sentry_react-native')
}
MainApplication.java
for React Native < 0.60
For React Native versions < 0.60, make sure your MainApplication.java
is similar to:
import io.sentry.react.RNSentryPackage;
public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNSentryPackage()
);
}
}
Add the following to your settings.gradle
file:
android/settings.gradle
include ':@sentry_react-native'
project(':@sentry_react-native').projectDir = new File(rootProject.projectDir, '../node_modules/@sentry/react-native/android')
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/react-native
- Version:
- 3.4.2
- Repository:
- https://github.com/getsentry/sentry-react-native