Skip to content

Commit 9d05f98

Browse files
Merge remote-tracking branch 'upstream/master' into kw-version-major
2 parents 7cd8213 + 3d130a4 commit 9d05f98

File tree

5 files changed

+210
-113
lines changed

5 files changed

+210
-113
lines changed

README.md

Lines changed: 70 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,25 @@ This is demo repo is used by Solution Engineers when demo'ing Sentry's [React Na
77

88
## Versions
99

10+
The values specified in package.json may be more up to date.
11+
Not all of these have to be used in order to build the app (e.g. Android Virtual Device API) but if you're having problems building, then follow these.
1012
| dependency | version
1113
| ------------- |:-------------:|
12-
| react-native | 0.64.0 |
13-
| gradle | 6.7 |
14-
| react | 16.13.1 |
15-
| sentry/react-native | 2.4.0 |
16-
| npx | 7.8.0 |
17-
| cocoapods | +1.10.1 |
14+
| react-native | 0.72.4 |
15+
| gradle | 8.0.1 |
16+
| react | 18.2.0 |
17+
| sentry/react-native | ^5.9.1 |
18+
| npx | 7.8.0? |
19+
| node | 20.5.0 |
20+
| npm | 9.8.0 |
21+
| java | 17.0.8 |
22+
| ruby | 3.2.2 |
23+
| AndroidStudio | Bumblebee 2021.1.1 Patch 2 |
24+
| Android Virtual Device | Pixel_6_API_30 |
1825

19-
## Setup (Bootstrap)
20-
21-
[INSTALL.md](./Install.md) was written by the CreateReactNativeApp maintainers and outlines some things you'll need.
22-
23-
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:
24-
```
25-
$npx @sentry/wizard -i reactNative -p ios android
26-
```
27-
The above command launches the [Sentry wizard](https://github.com/getsentry/sentry-wizard) allowing you to [link](https://docs.sentry.io/platforms/react-native/#linking) with the correct Sentry react-native project.
28-
From our [documentation](https://docs.sentry.io/platforms/react-native/), the following changes happen which you should be aware of:
29-
```
30-
- add the sentry-android package for native crash reporting on Android
31-
- add the sentry-cocoa package for native crash reporting on iOS
32-
- enable the Sentry Gradle build step for Android
33-
- patch MainApplication.java for Android
34-
- configure Sentry for the supplied DSN in your index.js/App.js files
35-
- store build credentials in ios/sentry.properties and android/sentry.properties.
36-
```
3726

3827
## Setup
28+
See 'Versions' table above for some dependencies you'll need. Recommend using [sdkman](sdkman.io) for easily installing the right Java version. And [rbenv](http://rbenv.org/) or [rvm](https://rvm.io/) to install the right Ruby version.
3929

4030
1. git clone [email protected]:sentry-demos/sentry_react_native.git
4131
2. Add your DSN and BACKEND_URL for back-end to src/config.ts
@@ -46,117 +36,75 @@ From our [documentation](https://docs.sentry.io/platforms/react-native/), the fo
4636
7. `cd ios && pod install`
4737
8. Optional - Create a .env file in project root and add `SE=<value>`
4838

49-
Don't forget to bump your release version depending on platform
50-
iOS: `Info.plist` `CFBundleShortVersionString`
51-
android: `app.build.gradle` `versionName`
52-
53-
## Run
39+
## Run Android
40+
These steps were last tested on Sept 6th, 2023:
5441

55-
1. Android (optional) start the emulator by AVD Manager or:
42+
1.
5643
```
57-
// emulator executable is at /Users/<user>/Library/Android/sdk/emulator
58-
emulator -list-avds
59-
emulator @<YourEmulator> -dns-server 8.8.8.8
60-
emulator @Pixel_3_API_30_x86_64 -dns-server 8.8.8.8
61-
```
62-
63-
2. Run Ios or Android app
64-
* _iOS version_:
44+
// this tends to give errors once you run the app. avoid this.
45+
cd android
46+
npm run android // this command executes `react-native run-android` and does hot-reload
6547
```
66-
# opens the Metro debugger, has hot reload
67-
npx react-native run-ios --configuration Debug
48+
If step 1 is failing, try building a release and running that in the emulator:
6849

69-
## builds a Release (takes longer)
70-
npx react-native run-ios --configuration Release
71-
npx react-native run-ios --simulator="iPhone 11"
72-
```
73-
* _Android version_:
50+
2.
7451
```
75-
npx react-native run-android --variant Release
52+
// Creates the apk of the app in /android/app/build/outputs/apk/release/app-release.apk
53+
cd android
54+
./gradlew assembleRelease // add '--scan' will collect logs and tasks that happen during this
7655
```
77-
^ this command builds APK for the arch and installs to the emulator.
78-
^ click 'OK' if you get a pop-up, and it should open Metro
7956

57+
3.
58+
```
59+
// runs the apk you created in steps1,2
60+
emulator -avd Pixel_6_API_34 -netdelay none -netspeed full -dns-server 8.8.8.8
8061
81-
82-
## Expected Behavior
83-
84-
EmpowerPlant | Checkout
85-
:-------------------------:|:-------------------------:
86-
![list of tools](./img/toolstore.png) | ![checkout cart](./img/cart.png)|
87-
88-
## Upgrade SDK path
89-
1. npm install, then `cd ios && pod update` if `pod install` is failing. The pod updating depends on node_modules/@sentry/react-native being set.
90-
2. Review previous PR so you know what to expect.
91-
92-
## Troubleshooting
93-
94-
#### Repo
95-
This repo borrowed from [original react-native repo ]( https://github.com/sentry-demos/react-native/commit/269f58d63426065a4de67a3f22d2e774787cd996)
96-
The following may have been borrowed: `package.json`, `package-lock.json`, `ios/Podfile`, `ios/Podfile.lock`, see [pull/2](https://github.com/sentry-demos/sentry_react_native/pull/2)
97-
98-
Please know that react-native generates it own [.gitignore file](https://stackoverflow.com/questions/49099131/recommended-gitignore-for-react-native/49099219
99-
), which is of course part of this repo, so only those [autogenerated files](https://stackoverflow.com/questions/48448426/why-dont-we-gitignore-ios-and-android-in-react-native ) that are required for a baseline setup and the original demo code (files) are part of this repo.
100-
101-
Please see [Steps](#what-were-the-steps-again) or go through the [first ten commits](https://github.com/sentry-demos/sentry_react_native/commits/master) (and their git log) messages in chronological order, to see the exact commands that were run and what files that were autogenerated.
102-
103-
#### What were the steps again
104-
This is just the background steps to answer "How did we get here ?" . Below is not needed/related to the demoing this app.
62+
// optional, do this if you think you're not getting the updated app on your emulator
63+
./gradlew installRelease // Installs release build of the app to the currently connected Android device/emulator
10564
```
106-
// generates boilerplate code
107-
npx react-native init sentry_react_native
108-
cd sentry_react_native
109-
cd ios
110-
// Edit Podfile to remove/comment out flipper install as suggested in the comments of the file itself
111-
pod install
112-
// add Sentry SDKs
113-
npm install --save @sentry/react-native
114-
npx @sentry/wizard -i reactNative -p ios android (and select you Sentry react native project )
115-
cd ios
116-
pod install
65+
66+
optional
11767
```
68+
Gradle commands allow you to gradually control what you want to do, like avoiding rebuilding the app if you changed your emulator.
69+
cd android
70+
./gradlew installDebug // Installs debug build of the app to the currently connected Android device/emulator
71+
./gradlew installRelease // Installs release build of the app to the currently connected Android device/emulator
11872
119-
#### adding Sentry for first time
120-
When running npx @sentry/wizard -i reactNative -p ios android
121-
At this point, you may get an error like:
122-
`TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined`
123-
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`:
12473
```
125-
cp android/sentry.properties ios/sentry.properties
126-
cd ios
127-
pod install
74+
75+
Old Steps from before Sept 6th, 2023:
12876
```
77+
Android (optional) start the emulator by AVD Manager or:
12978
130-
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):
79+
// emulator executable is at /Users/<user>/Library/Android/sdk/emulator
80+
emulator -list-avds
81+
emulator @<YourEmulator> -dns-server 8.8.8.8
82+
emulator @Pixel_3_API_30_x86_64 -dns-server 8.8.8.8
13183
132-
```
133-
sudo rm -rf android/ ios/
134-
yarn add react-native-eject
135-
npx react-native eject
84+
// This builds the APK for the arch and installs to the emulator.
85+
npx react-native run-android --variant Release
13686
```
13787

138-
#### Emulators
139-
When running emulator...
140-
If the app launches and suddenly crashes you may need to reinstall your node package with this command:
88+
## Run iOS
14189

14290
```
143-
rm -rf node_modules
144-
npm install
91+
npm run ios -- --mode=Release
14592
```
14693

147-
Emulator needs Internet access enabled on your Android emulator. Use AVD Manager or:
148-
149-
#### Running
150-
You may run into issues if you haven't added sdk and sdk platform-tools to path:
151-
`export ANDROID_SDK_ROOT=/Users/<user>/Library/Android/sdk`
152-
`export PATH=/Users/<user>/Library/Android/sdk/platform-tools:$PATH`
153-
154-
"error: Can't find the 'node' binary to build the React Native bundle." should be okay
94+
These steps were last tested before Sept 6th, 2023:
95+
Deprecation warning on using npx?
96+
```
97+
# opens the Metro debugger, has hot reload
98+
npx react-native run-ios --configuration Debug
15599
156-
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.
157-
Could also be a problem with the backend container/app you're requesting the tools from (check that URL/Postman, check TDA job)
100+
## builds a Release (takes longer)
101+
npx react-native run-ios --configuration Release
102+
npx react-native run-ios --simulator="iPhone 11"
103+
```
158104

159-
When developing locally, must point React Native to http://127.0.0.1:8080/products backend instead of https://localhost:8080/products backend.
105+
## SDK Upgrade Path
106+
1. `rm -rf node_modules && npm install`. For iOS, run `pod install --repo-update`. For Android, it should pull in latest dependenices automatically as you start building again.
107+
2. If you're getting build errors, you may need to upgrade all your Node, npm, Java, VirtualDevices. This is due to either the previously merged PR relying on them, or the next SDK and RN versions you're upgrading to require them, or both.
160108

161109
# How To Create a Release
162110

@@ -248,6 +196,14 @@ Note: do not proceed with this until you have done all the previous steps.
248196

249197
Your new release should be [visible on Github](https://github.com/sentry-demos/sentry_react_native/releases).
250198

199+
### Updating the version of the Demo App itself
200+
Don't forget to bump your release version depending on platform.
201+
iOS: `Info.plist` `CFBundleShortVersionString`
202+
android: `app.build.gradle` `versionName`
203+
204+
## Troubleshooting
205+
[Troubleshooting.md](./troubleshooting.md)
206+
251207
### [Troubleshooting - Locally undoing an accidental increment of the release version]
252208

253209
If you accidentally tick the version forward by running `npm version patch`, and did not intend to do so, you can undo this.
@@ -260,4 +216,5 @@ Let's say we were previously on `2.0.1` and accidentally ran the command twice,
260216
![Screen Shot 2021-12-08 at 12 55 09 PM](https://user-images.githubusercontent.com/12092849/145283369-2130cae7-fe0c-42ff-b826-0015c3cd565b.png)
261217

262218
- run `git reset <the commit hash>`.
263-
- Check out any unwanted files that are no longer staged for commit.
219+
- Check out any unwanted files that are no longer staged for commit.
220+

android/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ sentry {
1515
// Default is disabled.
1616
includeNativeSources = true
1717

18+
includeSourceContext = true
19+
1820
// `@sentry/react-native` ships with compatible `sentry-android`
1921
// This option would install the latest version that ships with the SDK or SAGP (Sentry Android Gradle Plugin)
2022
// which might be incompatible with the React Native SDK

img/cart.png

-511 KB
Binary file not shown.

img/toolstore.png

-604 KB
Binary file not shown.

troubleshooting.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
## Bootstrapping a new React Native App
2+
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.
3+
4+
[INSTALL.md](./Install.md) was written by the CreateReactNativeApp maintainers and outlines some things you'll need.
5+
6+
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:
7+
```
8+
$npx @sentry/wizard -i reactNative -p ios android
9+
```
10+
The above command launches the [Sentry wizard](https://github.com/getsentry/sentry-wizard) allowing you to [link](https://docs.sentry.io/platforms/react-native/#linking) with the correct Sentry react-native project.
11+
From our [documentation](https://docs.sentry.io/platforms/react-native/), the following changes happen which you should be aware of:
12+
```
13+
- add the sentry-android package for native crash reporting on Android
14+
- add the sentry-cocoa package for native crash reporting on iOS
15+
- enable the Sentry Gradle build step for Android
16+
- patch MainApplication.java for Android
17+
- configure Sentry for the supplied DSN in your index.js/App.js files
18+
- store build credentials in ios/sentry.properties and android/sentry.properties.
19+
```
20+
21+
#### Repo
22+
This repo borrowed from [original react-native repo ]( https://github.com/sentry-demos/react-native/commit/269f58d63426065a4de67a3f22d2e774787cd996)
23+
The following may have been borrowed: `package.json`, `package-lock.json`, `ios/Podfile`, `ios/Podfile.lock`, see [pull/2](https://github.com/sentry-demos/sentry_react_native/pull/2)
24+
25+
Please know that react-native generates it own [.gitignore file](https://stackoverflow.com/questions/49099131/recommended-gitignore-for-react-native/49099219
26+
), which is of course part of this repo, so only those [autogenerated files](https://stackoverflow.com/questions/48448426/why-dont-we-gitignore-ios-and-android-in-react-native ) that are required for a baseline setup and the original demo code (files) are part of this repo.
27+
28+
Please see [Steps](#what-were-the-steps-again) or go through the [first ten commits](https://github.com/sentry-demos/sentry_react_native/commits/master) (and their git log) messages in chronological order, to see the exact commands that were run and what files that were autogenerated.
29+
30+
#### What were the steps again
31+
This is just the background steps to answer "How did we get here ?" . Below is not needed/related to the demoing this app.
32+
```
33+
// generates boilerplate code
34+
npx react-native init sentry_react_native
35+
cd sentry_react_native
36+
cd ios
37+
// Edit Podfile to remove/comment out flipper install as suggested in the comments of the file itself
38+
pod install
39+
// add Sentry SDKs
40+
npm install --save @sentry/react-native
41+
npx @sentry/wizard -i reactNative -p ios android (and select you Sentry react native project )
42+
cd ios
43+
pod install
44+
```
45+
46+
#### adding Sentry for first time
47+
When running npx @sentry/wizard -i reactNative -p ios android
48+
At this point, you may get an error like:
49+
`TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined`
50+
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`:
51+
```
52+
cp andoid/sentry.properties ios/sentry.properties
53+
cd ios
54+
pod install
55+
```
56+
57+
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):
58+
59+
```
60+
sudo rm -rf android/ ios/
61+
yarn add react-native-eject
62+
npx react-native eject
63+
```
64+
65+
#### Emulators
66+
When running emulator...
67+
If the app launches and suddenly crashes you may need to reinstall your node package with this command:
68+
69+
```
70+
rm -rf node_modules
71+
npm install
72+
```
73+
74+
Emulator needs Internet access enabled on your Android emulator. Use AVD Manager or:
75+
76+
#### Running
77+
You may run into issues if you haven't added sdk and sdk platform-tools to path:
78+
`export ANDROID_SDK_ROOT=/Users/<user>/Library/Android/sdk`
79+
`export PATH=/Users/<user>/Library/Android/sdk/platform-tools:$PATH`
80+
81+
"error: Can't find the 'node' binary to build the React Native bundle." should be okay
82+
83+
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.
84+
Could also be a problem with the backend container/app you're requesting the tools from (check that URL/Postman, check TDA job)
85+
86+
When developing locally, must point React Native to http://127.0.0.1:8080/products backend instead of https://localhost:8080/products backend.
87+
88+
89+
90+
91+
## Other
92+
update to java 17 or 20
93+
```
94+
sdk man curl -s "https://get.sdkman.io" | bash
95+
sdk install java 17.0.8-zulu
96+
```
97+
98+
upgrade android emulator
99+
100+
101+
```
102+
adb kill-server
103+
adb start-server
104+
```
105+
106+
uninstall the app from the emulator, if you're not sure it's getting refreshed.
107+
108+
TODO?
109+
RN demo: rub 3.2.2 for RN iOS
110+
root folder > bundle install > setups cocopods for ruby
111+
pod install [or pod update first]
112+
113+
114+
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?
115+
116+
117+
TODO: put this in TDA's repo?
118+
```
119+
ngrok http file:///Users/wcap/thinkocapo/sentry_react_native/android/app/build/outputs/apk/release
120+
121+
//or do this if you served the file first via `python3 -m http.server` in the directory with the APK
122+
ngrok http <PORT>
123+
124+
// Appium JSON config....+TDA?
125+
https://1cd3-178-73-4-138.ngrok.io + app-release.apk
126+
https://1cd3-178-73-4-138.ngrok.io/app-release.apk
127+
```
128+
129+
```
130+
//TDA
131+
cd empower/tda
132+
source env_new/bin/activate
133+
py.test -s -n 4 mobile_native/android_react_native/test_checkout_react_native_android.py
134+
135+
// update the url in...empower/tda/conftest.py > android_react_native_emu_driver, with ngrok URL
136+
```
137+
138+
now go check sentry for.... se:will?

0 commit comments

Comments
 (0)