|
5 | 5 | React Native |
6 | 6 | ============ |
7 | 7 |
|
8 | | -This is the documentation for our beta clients for React-Native. This is |
9 | | -an early release with various different levels of support. iOS is best |
10 | | -supported if you are also using the native extension and if not we fall |
11 | | -back to pure JavaScript for basic support. |
12 | | - |
13 | | -We would love to get your feedback! |
| 8 | +This is the documentation for our beta clients for React-Native. The |
| 9 | +React-Native client uses a native extension for iOS and Android but can |
| 10 | +fall back to a pure JavaScript version if needed. |
14 | 11 |
|
15 | 12 | Installation |
16 | 13 | ------------ |
17 | 14 |
|
18 | | -Start with adding sentry and linking it:: |
| 15 | +Start by adding Sentry and then linking it:: |
19 | 16 |
|
20 | 17 | $ npm install react-native-sentry --save |
21 | 18 | $ react-native link react-native-sentry |
22 | 19 |
|
23 | | -The `link` step will pull in the native dependency. If you are using |
24 | | -expo you don't have to (or can't) run that step. In that case we fall |
25 | | -back automatically. |
| 20 | +The `link` step will pull in the native dependency and patch your project |
| 21 | +accordingly. If you are using expo you don't have to (or can't) run that |
| 22 | +link step. For more information about that see :doc:`expo`. |
| 23 | + |
| 24 | +On linking you will automatically be prompted for your DSN and other |
| 25 | +information and we will configure your app automatically for react-native |
| 26 | +and change files accordingly. You will need to provide the following |
| 27 | +data: your DSN, the slug of your organization in Sentry, the slug of your |
| 28 | +project in Sentry as well as the API key. |
| 29 | + |
| 30 | +You can find the slugs in the URL of your project |
| 31 | +(``sentry.io/your-org-slug/your-project-slug``) If you don't have an auth |
| 32 | +token yet you can `create an auth token here <https://sentry.io/api/>`_. |
26 | 33 |
|
27 | | -On linking you will usually be prompted for your DSN and we will configure |
28 | | -your app automatically for react-native and change files accordingly. |
29 | 34 | Upon linking the following changes will be performed: |
30 | 35 |
|
31 | | -* added the raven-java package for native crash reporting on android |
32 | | -* added the sentry-swift package for native crash reporting on iOS |
33 | | -* enabled the sentry gradle build step for android |
| 36 | +* add the raven-java package for native crash reporting on Android |
| 37 | +* add the sentry-swift package for native crash reporting on iOS |
| 38 | +* enable the sentry gradle build step for android |
34 | 39 | * patch `AppDelegate.m` for iOS |
35 | 40 | * patch `MainApplication.java` for Android |
36 | | -* configured Sentry for the supplied DSN in your `index.js` files |
| 41 | +* configure Sentry for the supplied DSN in your `index.js` files |
| 42 | +* store build credentials in `ios/sentry.properties` and |
| 43 | + `android/sentry.properties`. |
| 44 | + |
| 45 | +To see what is happening during linking you can refer to |
| 46 | +:doc:`manual-setup` which will give you all the details. |
37 | 47 |
|
38 | 48 | Note that we only support ``react-native >= 0.38`` at the moment. |
39 | 49 |
|
| 50 | +Upgrading |
| 51 | +--------- |
| 52 | + |
| 53 | +If you are upgrading from an earlier version of sentry-react-native you |
| 54 | +should re-link the package to ensure the generated code is updated to the |
| 55 | +latest version:: |
| 56 | + |
| 57 | + $ react-native unlink react-native-sentry |
| 58 | + $ react-native link react-native-sentry |
| 59 | + |
40 | 60 | iOS Specifics |
41 | 61 | ------------- |
42 | 62 |
|
43 | 63 | Since we use our `Swift Client |
44 | 64 | <https://github.com/getsentry/sentry-swift>`_ in the background, your |
45 | | -project has to embed the swift standard libraries. |
46 | | - |
47 | | -Search for ``ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES`` in your Xcode project |
48 | | -build settings and set it to ``YES``. |
49 | | - |
50 | | -You will get this error message if you forget to set it:: |
51 | | - |
52 | | - dyld: Library not loaded: @rpath/libswiftCore.dylib |
53 | | - Referenced from: [Redacted]/Sentry.framework/Sentry |
54 | | - Reason: image not found |
55 | | - |
56 | | -Also note that if you build the project without setting this, you have to |
57 | | -run clean in order to make the change work. |
| 65 | +project has to embed the swift standard libraries. The link step will do |
| 66 | +this automatically for your project. |
58 | 67 |
|
59 | 68 | When you use xcode you can hook directly into the build process to upload |
60 | | -debug symbols. Open up your xcode project in the iOS folder, go to your |
61 | | -project's target and change the "Bundle React Native code and images" |
62 | | -build script. The script that is currently there needs to be adjusted as |
63 | | -follows:: |
64 | | - |
65 | | - export SENTRY_ORG=___ORG_NAME___ |
66 | | - export SENTRY_PROJECT=___PROJECT_NAME___ |
67 | | - export SENTRY_AUTH_TOKEN=YOUR_AUTH_TOKEN |
68 | | - export NODE_BINARY=node |
69 | | - ../node_modules/react-native-sentry/bin/bundle-frameworks |
70 | | - ../node_modules/sentry-cli-binary/bin/sentry-cli react-native-xcode \ |
71 | | - ../node_modules/react-native/packager/react-native-xcode.sh |
72 | | - ../node_modules/sentry-cli-binary/bin/sentry-cli upload-dsym |
73 | | - |
74 | | -You can find the slugs in the URL of your project |
75 | | -(sentry.io/your-org-slug/your-project-slug) If you don't have an auth |
76 | | -token yet you can `create an auth token here <https://sentry.io/api/>`_. |
77 | | - |
78 | | -This also uploads debug symbols in the last line which however will not |
79 | | -work for bitcode enabled builds. If you are using bitcode you need to |
80 | | -remove that line (``../node_modules/sentry-cli-binary/bin/sentry-cli |
81 | | -upload-dsym``) and consult the documentation on dsym handling instead (see |
82 | | -:ref:`dsym-with-bitcode`). |
83 | | - |
84 | | -Note that uploading of debug simulator builds by default is disabled for |
85 | | -speed reasons. If you do want to also generate debug symbols for debug |
86 | | -builds you can pass `--allow-fetch` as a parameter to ``react-native-xcode``. |
| 69 | +debug symbols and sourcemaps. If you however are using bitcode you will |
| 70 | +need to disable the "Upload Debug Symbols to Sentry" build phase and then |
| 71 | +separately upload debug symbols from iTunes Connect to Sentry. |
87 | 72 |
|
88 | 73 | Android Specifics |
89 | 74 | ----------------- |
90 | 75 |
|
91 | 76 | For Android we hook into gradle for the sourcemap build process. When you |
92 | | -run ``react-native link`` the gradle files are automatically updated but |
93 | | -in case you are not using linked frameworks you might have to do it |
94 | | -manually. Whenever you run ``./gradlew assembleRelease`` sourcemaps are |
95 | | -automatically built and uploaded to Sentry. |
96 | | - |
97 | | -To enable the gradle integration you need to change your |
98 | | -``android/app/build.gradle`` file and add the following line after the |
99 | | -``react.gradle`` one:: |
100 | | - |
101 | | - apply from: "../../node_modules/react-native-sentry/sentry.gradle" |
102 | | - |
103 | | -Additionally you need to create an ``android/sentry.properties`` file with |
104 | | -the access credentials: |
105 | | - |
106 | | -.. sourcecode:: ini |
107 | | - |
108 | | - defaults.org=___ORG_NAME___ |
109 | | - defaults.project=___PROJECT_NAME___ |
110 | | - auth.token=YOUR_AUTH_TOKEN |
| 77 | +run ``react-native link`` the gradle files are automatically updated. |
| 78 | +When you run ``./gradlew assembleRelease`` sourcemaps are automatically |
| 79 | +built and uploaded to Sentry. |
111 | 80 |
|
112 | 81 | Client Configuration |
113 | 82 | -------------------- |
114 | 83 |
|
115 | | -Note: When you run ``react-native link`` we will attempt to automatically |
116 | | -patch your code so you might notice that some of these changes were |
117 | | -already performed. |
118 | | - |
119 | | -Add Sentry to your `index.ios.js` and `index.android.js`: |
| 84 | +Note: When you run ``react-native link`` we will automatically update your |
| 85 | +`index.ios.js` / `index.android.js` with the following changes: |
120 | 86 |
|
121 | 87 | .. sourcecode:: javascript |
122 | 88 |
|
123 | 89 | import { Sentry } from 'react-native-sentry'; |
124 | | - |
125 | 90 | Sentry.config('___DSN___').install(); |
126 | 91 |
|
127 | | -If you are using the binary version of the package (eg: you ran |
128 | | -``react-native link``) then you additionally need to register the native |
129 | | -crash handler in your `AppDelegate.m` after the root view was created for |
130 | | -iOS: |
131 | | - |
132 | | -.. sourcecode:: objc |
133 | | - |
134 | | - #if __has_include(<React/RNSentry.h>) |
135 | | - #import <React/RNSentry.h> // This is used for versions of react >= 0.40 |
136 | | - #else |
137 | | - #import "RNSentry.h" // This is used for versions of react < 0.40 |
138 | | - #endif |
139 | | - |
140 | | - /* in your didFinishLaunchingWithOptions */ |
141 | | - [RNSentry installWithRootView:rootView]; |
| 92 | +You can pass additional configuration options to the `config()` method if |
| 93 | +you want to do so. |
142 | 94 |
|
143 | | -More |
144 | | ----- |
| 95 | +Deep Dive |
| 96 | +--------- |
145 | 97 |
|
146 | 98 | .. toctree:: |
147 | 99 | :maxdepth: 2 |
|
150 | 102 | expo |
151 | 103 | sourcemaps |
152 | 104 | cocoapods |
| 105 | + manual-setup |
0 commit comments