Only do this if you're having trouble upgrading the Sentry SDK or existing RN version. Sometimes it's more efficient to bootstrap a new app from scratch, but you'll have a ton of app source code to port over. Consider that state management could work differently in a newer version of RN.
INSTALL.md was written by the CreateReactNativeApp maintainers and outlines some things you'll need.
This step was already performed for adding the sdk to sentry_react_native, but it's good to know it was used as customers will use it:
$npx @sentry/wizard -i reactNative -p ios android
The above command launches the Sentry wizard allowing you to link with the correct Sentry react-native project. From our documentation, the following changes happen which you should be aware of:
- add the sentry-android package for native crash reporting on Android
- add the sentry-cocoa package for native crash reporting on iOS
- enable the Sentry Gradle build step for Android
- patch MainApplication.java for Android
- configure Sentry for the supplied DSN in your index.js/App.js files
- store build credentials in ios/sentry.properties and android/sentry.properties.
This repo borrowed from original react-native repo
The following may have been borrowed: package.json
, package-lock.json
, ios/Podfile
, ios/Podfile.lock
, see pull/2
Please know that react-native generates it own .gitignore file, which is of course part of this repo, so only those autogenerated files that are required for a baseline setup and the original demo code (files) are part of this repo.
Please see Steps or go through the first ten commits (and their git log) messages in chronological order, to see the exact commands that were run and what files that were autogenerated.
This is just the background steps to answer "How did we get here ?" . Below is not needed/related to the demoing this app.
// generates boilerplate code
npx react-native init sentry_react_native
cd sentry_react_native
cd ios
// Edit Podfile to remove/comment out flipper install as suggested in the comments of the file itself
pod install
// add Sentry SDKs
npm install --save @sentry/react-native
npx @sentry/wizard -i reactNative -p ios android (and select you Sentry react native project )
cd ios
pod install
When running npx @sentry/wizard -i reactNative -p ios android
At this point, you may get an error like:
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
It should be safe to look past this error. A minor issue is that it blocks creation of ios/sentry.properties
. So simply make a copy of android/sentry.properties
and put it in ios/sentry.properties
:
cp andoid/sentry.properties ios/sentry.properties
cd ios
pod install
If all else fails and you seem to be getting a weird error related to IllegalAccessErrors or anything else you may need to rebuild your Android and iOS folders using the following (just make sure to grab the sentry.properties files, build.gradle files, and pod files from Github afterwards):
sudo rm -rf android/ ios/
yarn add react-native-eject
npx react-native eject
When running emulator... If the app launches and suddenly crashes you may need to reinstall your node package with this command:
rm -rf node_modules
npm install
Emulator needs Internet access enabled on your Android emulator. Use AVD Manager or:
You may run into issues if you haven't added sdk and sdk platform-tools to path:
export ANDROID_SDK_ROOT=/Users/<user>/Library/Android/sdk
export PATH=/Users/<user>/Library/Android/sdk/platform-tools:$PATH
"error: Can't find the 'node' binary to build the React Native bundle." should be okay
If tools don't load, then swipe-away (kill) the app, then relaunch from app menu in the emulator. If still fails, then go to AVD Manager and 'wipe' the device and run the emulator again. Could also be a problem with the backend container/app you're requesting the tools from (check that URL/Postman, check TDA job)
When developing locally, must point React Native to http://127.0.0.1:8080/products backend instead of https://localhost:8080/products backend.
update to java 17 or 20
sdk man curl -s "https://get.sdkman.io" | bash
sdk install java 17.0.8-zulu
upgrade android emulator
adb kill-server
adb start-server
uninstall the app from the emulator, if you're not sure it's getting refreshed.
TODO? RN demo: rub 3.2.2 for RN iOS root folder > bundle install > setups cocopods for ruby pod install [or pod update first]
how do you NOT have to uninstall the app from the virtualdevice, and have to re-build, then installRelease. is there a more streamlined way to do it, that does not involve npm run android
which has known issues?
TODO: put this in TDA's repo?
ngrok http file:///Users/wcap/thinkocapo/sentry_react_native/android/app/build/outputs/apk/release
//or do this if you served the file first via `python3 -m http.server` in the directory with the APK
ngrok http <PORT>
// Appium JSON config....+TDA?
https://1cd3-178-73-4-138.ngrok.io + app-release.apk
https://1cd3-178-73-4-138.ngrok.io/app-release.apk
//TDA
cd empower/tda
source env_new/bin/activate
py.test -s -n 4 mobile_native/android_react_native/test_checkout_react_native_android.py
// update the url in...empower/tda/conftest.py > android_react_native_emu_driver, with ngrok URL
now go check sentry for.... se:will?