|
1 |
| -## Who am I |
2 |
| - |
3 | 1 | This is demo repo is used by Solution Engineers when demo'ing Sentry's [React Native](https://docs.sentry.io/platforms/react-native) SDK's capabilties.
|
4 | 2 |
|
5 |
| -## Versions Summary: |
| 3 | +## Versions |
6 | 4 |
|
7 | 5 | | dependency | version
|
8 | 6 | | ------------- |:-------------:|
|
9 | 7 | | react-native | 0.64.0 |
|
10 | 8 | | gradle | 6.7 |
|
11 | 9 | | react | 16.13.1 |
|
12 | 10 | | sentry/react-native | 2.4.0 |
|
| 11 | +| npx | 7.8.0 | |
| 12 | +| cocoapods | +1.10.1 | |
13 | 13 |
|
| 14 | +## Setup (Bootstrap) |
14 | 15 |
|
| 16 | +[INSTALL.md](./Install.md) was written by the CreateReactNativeApp maintainers and outlines some things you'll need. |
15 | 17 |
|
16 |
| - |
17 |
| - |
18 |
| - |
19 |
| - |
20 |
| - |
21 |
| -This is demo repo is used by Solution Engineers when demo'ing Sentry's [React Native](https://docs.sentry.io/platforms/react-native) SDK's capabilties. |
22 |
| - |
23 |
| -## Where do I begin |
24 |
| - |
25 |
| -Please see [INSTALL.md](./Install.md) to get started with the setup. |
26 |
| - |
27 |
| -## What next |
28 |
| -* If you are ready to demo: |
| 18 | +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: |
29 | 19 | ```
|
30 |
| -$git clone <this repo> |
31 |
| -Edit App.js to add your Sentry's react-native's project's DSN key |
32 | 20 | $npx @sentry/wizard -i reactNative -p ios android
|
33 | 21 | ```
|
34 |
| -### Above will : |
35 |
| -* Launch the [Sentry wizard](https://github.com/getsentry/sentry-wizard) allowing you to link with the correct Sentry react-native project. |
36 |
| -* Create `ios/sentry.properties` and `android/sentry.properties`. |
37 |
| -### Gotcha: |
38 |
| -At this point, you may get an error like: |
39 |
| -* `TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined |
40 |
| - |
41 |
| -From my test runs I've noted that it is 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` |
42 |
| - |
| 22 | +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. |
| 23 | +From our [documentation](https://docs.sentry.io/platforms/react-native/), the following changes happen which you should be aware of: |
43 | 24 | ```
|
44 |
| -cp andoid/sentry.properties ios/sentry.properties |
45 |
| -cd ios |
46 |
| -pod install |
| 25 | +- add the sentry-android package for native crash reporting on Android |
| 26 | +- add the sentry-cocoa package for native crash reporting on iOS |
| 27 | +- enable the Sentry Gradle build step for Android |
| 28 | +- patch MainApplication.java for Android |
| 29 | +- configure Sentry for the supplied DSN in your index.js/App.js files |
| 30 | +- store build credentials in ios/sentry.properties and android/sentry.properties. |
47 | 31 | ```
|
48 |
| -### Before Launching the Demo apps: |
49 |
| - |
50 |
| -Be sure to export your auth token: `export SENTRY_AUTH_TOKEN=<token>` |
51 | 32 |
|
52 |
| -### Versioning |
| 33 | +## Setup |
53 | 34 |
|
54 |
| -Don't foget to bump your release version depending on platform: |
| 35 | +1. git clone [email protected]:sentry-demos/sentry_react_native.git |
| 36 | +2. Add your DSN and BACKEND_URL for back-end to src/config.ts |
| 37 | +3. `export SENTRY_AUTH_TOKEN=<token>` |
| 38 | +4. Setup a Android Virtual Device via AVD Manager. |
| 39 | +5. If you don't have cocopods or get an error about cocopods out of date, run `gem install cocopods` |
| 40 | +6. `cd ios && pod install` |
| 41 | +7. `npm install` |
55 | 42 |
|
56 |
| -iOS: `Info.plist` `CFBundleShortVersionString` |
57 |
| -android: `app.build.gradle` `versionName` |
| 43 | +Don't forget to bump your release version depending on platform |
| 44 | +iOS: `Info.plist` `CFBundleShortVersionString` |
| 45 | +android: `app.build.gradle` `versionName` |
58 | 46 |
|
59 |
| -Make sure to have Internet access enabled on your Android emulator. If you can't access the browser you may need to launch your emulator with the below commands: |
| 47 | +## Run |
60 | 48 |
|
| 49 | +1. Android (optional) start the emulator by AVD Manager or: |
61 | 50 | ```
|
| 51 | +// emulator executable is at /Users/<user>/Library/Android/sdk/emulator |
62 | 52 | emulator -list-avds
|
63 |
| -
|
64 |
| -emulator @{YourEmulator} -dns-server 8.8.8.8 |
| 53 | +emulator @<YourEmulator> -dns-server 8.8.8.8 |
| 54 | +emulator @Pixel_3_API_30_x86_64 -dns-server 8.8.8.8 |
65 | 55 | ```
|
66 | 56 |
|
67 |
| -If you are experiencing issues with running the following launch command: |
68 |
| - |
69 |
| -If the app launches and suddenly crashes you may need to reinstall your node package with this command: |
70 |
| - |
| 57 | +2. Run Ios or Android app |
| 58 | +* _iOS version_: |
71 | 59 | ```
|
72 |
| -rm -rf node_modules |
| 60 | +# opens the Metro debugger, has hot reload |
| 61 | +npx react-native run-ios --configuration Debug |
73 | 62 |
|
74 |
| -npm install |
| 63 | +## builds a Release (takes longer) |
| 64 | +npx react-native run-ios --configuration Release |
| 65 | +npx react-native run-ios --simulator="iPhone 11" |
75 | 66 | ```
|
76 |
| - |
77 |
| -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): |
78 |
| - |
| 67 | +* _Android version_: |
79 | 68 | ```
|
80 |
| -sudo rm -rf android/ ios/ |
81 |
| -
|
82 |
| -yarn add react-native-eject |
83 |
| -
|
84 |
| -npx react-native eject |
| 69 | +npx react-native run-android --variant Release |
85 | 70 | ```
|
| 71 | +^ this command builds APK for the arch and installs to the emulator. |
| 72 | +^ click 'OK' if you get a pop-up, and it should open Metro |
86 | 73 |
|
87 |
| -### To Launch the Demo apps: |
88 | 74 |
|
89 |
| -* _iOS version_: `npx react-native run-ios --configuration Release` |
90 |
| -* _Android version_: `npx react-native run-android --variant Release` |
91 | 75 |
|
92 |
| -### When Launching Android |
93 |
| -You may run into issues if you haven't added sdk and sdk platform-tools to path: |
94 |
| -`export ANDROID_SDK_ROOT=/Users/dustinbailey/Library/Android/sdk` |
95 |
| -`export PATH=/Users/dustinbailey/Library/Android/sdk/platform-tools:$PATH` |
| 76 | +## Expected Behavior |
96 | 77 |
|
97 | 78 | Toolstore | Checkout
|
98 | 79 | :-------------------------:|:-------------------------:
|
99 | 80 |  | |
|
100 | 81 |
|
| 82 | +## Upgrade path |
| 83 | +1. npm install |
| 84 | +2. SDK Manager -> install 'emulator' or anything missing |
| 85 | +3. Review previous PR so you know what to expect |
101 | 86 |
|
102 |
| -## Why so many files |
| 87 | +## Troubleshooting |
103 | 88 |
|
104 |
| -Actually, its so not that many :-) . The size of this repo is approx. 1.3MB while the size of the [original react-native](https://github.com/sentry-demos/react-native) is approx 350MB. |
105 |
| - |
106 |
| -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. |
| 89 | +#### Repo |
| 90 | +This repo borrowed from [original react-native repo ]( https://github.com/sentry-demos/react-native/commit/269f58d63426065a4de67a3f22d2e774787cd996) |
| 91 | +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) |
107 | 92 |
|
108 | 93 | Please know that react-native generates it own [.gitignore file](https://stackoverflow.com/questions/49099131/recommended-gitignore-for-react-native/49099219
|
109 | 94 | ), 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.
|
110 | 95 |
|
111 |
| -So now we are at point, where one can simply clone, make a few edits and like DSN, project name, auth token and be up and running. |
112 |
| - |
113 |
| -## Where's the "original" code |
114 |
| - |
115 |
| -Adam worked on App.js which I took as-is from him. I also got from him the 2 image files in the assets dir (which are also present in [original react-native repo ]( https://github.com/sentry-demos/react-native) |
116 |
| - |
117 |
| -## What else |
118 |
| - |
119 |
| -It appears to me that we wanted to start fresh to create this demo. And while this was a good learning excercise as we expand our demo offering, I would like to "learn/see" how far off was the [original react-native repo ]( https://github.com/sentry-demos/react-native/commit/269f58d63426065a4de67a3f22d2e774787cd996) |
120 |
| - |
121 |
| -Since the assets are taken from there, and that it has its own App.js, it makes me wonder that a part/whole of it should already be working. I will investigate that as time permits. |
122 |
| - |
123 |
| -### Update |
124 |
| - |
125 |
| -So I took the major files from this working demo viz. `package.json`, `package-lock.json`, `ios/Podfile`, `ios/Podfile.lock`, because it is such files that make the deliverable self-contained, amongst other changes like DSN. When I put them on top of [original react-native repo ]( https://github.com/sentry-demos/react-native/commit/269f58d63426065a4de67a3f22d2e774787cd996) , I am get comile errors for both ios and android versions. |
126 |
| - |
127 |
| -At this time, I propose, we use this very repo (sentry_react_native) as the new working demo for RN stuff and forget about making them work on TOP of [original react-native repo](https://github.com/sentry-demos/react-native) . That to me is now a hacker's or pure development exercise. |
128 |
| - |
129 |
| -## What were the steps again |
| 96 | +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. |
130 | 97 |
|
| 98 | +#### What were the steps again |
131 | 99 | This is just the background steps to answer "How did we get here ?" . Below is not needed/related to the demoing this app.
|
132 | 100 | ```
|
133 |
| -npx react-native init sentry_react_native (where sentry_react_native is the project name) This generates the boiler plate code for the RN app |
| 101 | +// generates boilerplate code |
| 102 | +npx react-native init sentry_react_native |
134 | 103 | cd sentry_react_native
|
135 |
| -git init (Turn folder into a git repo) |
136 | 104 | cd ios
|
137 |
| -Edit Podfile to remove/comment out flipper install as suggested in the comments of the file itself |
| 105 | +// Edit Podfile to remove/comment out flipper install as suggested in the comments of the file itself |
| 106 | +pod install |
| 107 | +// add Sentry SDKs |
| 108 | +npm install --save @sentry/react-native |
| 109 | +npx @sentry/wizard -i reactNative -p ios android (and select you Sentry react native project ) |
| 110 | +cd ios |
138 | 111 | pod install
|
139 |
| -``` |
140 |
| - |
141 |
| -Throw in your changes |
142 |
| -``` |
143 |
| -cd .. |
144 |
| -Make any code changes you need to such as App.js |
145 | 112 | ```
|
146 | 113 |
|
147 |
| -Throw in Sentry SDKs |
| 114 | +#### adding Sentry for first time |
| 115 | +When running npx @sentry/wizard -i reactNative -p ios android |
| 116 | +At this point, you may get an error like: |
| 117 | +`TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined` |
| 118 | +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`: |
148 | 119 | ```
|
149 |
| -npm install --save @sentry/react-native |
150 |
| -npx @sentry/wizard -i reactNative -p ios android (and select you Sentry react native project ) |
| 120 | +cp andoid/sentry.properties ios/sentry.properties |
151 | 121 | cd ios
|
152 | 122 | pod install
|
153 |
| -cd .. |
154 | 123 | ```
|
155 |
| -Ran git commit along the way and finally pushed to this repo. |
156 | 124 |
|
| 125 | +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): |
| 126 | + |
| 127 | +``` |
| 128 | +sudo rm -rf android/ ios/ |
| 129 | +yarn add react-native-eject |
| 130 | +npx react-native eject |
| 131 | +``` |
| 132 | + |
| 133 | +#### Emulators |
| 134 | +When running emulator... |
| 135 | +If the app launches and suddenly crashes you may need to reinstall your node package with this command: |
| 136 | + |
| 137 | +``` |
| 138 | +rm -rf node_modules |
| 139 | +npm install |
| 140 | +``` |
| 141 | + |
| 142 | +Emulator needs Internet access enabled on your Android emulator. Use AVD Manager or: |
| 143 | + |
| 144 | +#### Running |
| 145 | +You may run into issues if you haven't added sdk and sdk platform-tools to path: |
| 146 | +`export ANDROID_SDK_ROOT=/Users/<user>/Library/Android/sdk` |
| 147 | +`export PATH=/Users/<user>/Library/Android/sdk/platform-tools:$PATH` |
| 148 | + |
| 149 | +"error: Can't find the 'node' binary to build the React Native bundle." should be okay |
| 150 | + |
| 151 | +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. |
| 152 | +Could also be a problem with the backend container/app you're requesting the tools from (check that URL/Postman, check TDA job) |
0 commit comments