Skip to content

Commit 95a8d16

Browse files
committed
Restructured the docs further
1 parent 32e7493 commit 95a8d16

File tree

2 files changed

+124
-101
lines changed

2 files changed

+124
-101
lines changed

docs/config.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Additional Configuration
2+
========================
3+
4+
These are functions you can call in your javascript code:
5+
6+
.. sourcecode:: javascript
7+
8+
import {
9+
Sentry,
10+
SentrySeverity,
11+
SentryLog
12+
} from 'react-native-sentry';
13+
14+
// disable stacktrace merging
15+
Sentry.config("___DSN___", {
16+
deactivateStacktraceMerging: true, // default: false | Deactivates the stacktrace merging feature
17+
logLevel: SentryLog.Debug, // default SentryLog.None | Possible values: .None, .Error, .Debug, .Verbose
18+
// These two options will only be considered if stacktrace merging is active
19+
// Here you can add modules that should be ignored or exclude modules
20+
// that should no longer be ignored from stacktrace merging
21+
// ignoreModulesExclude: ["I18nManager"], // default: [] | Exclude is always stronger than include
22+
// ignoreModulesInclude: ["RNSentry"], // default: [] | Include modules that should be ignored too
23+
// ---------------------------------
24+
}).install();
25+
26+
// set a callback after an event was successfully sentry
27+
// its only guaranteed that this event contains `event_id` & `level`
28+
Sentry.setEventSentSuccessfully((event) => {
29+
// can also be called outside this block but maybe null
30+
// Sentry.lastEventId(); -> returns the last event_id after the first successfully sent event
31+
// Sentry.lastException(); -> returns the last event after the first successfully sent event
32+
});
33+
34+
// export an extra context
35+
Sentry.setExtraContext({
36+
"a_thing": 3,
37+
"some_things": {"green": "red"},
38+
"foobar": ["a", "b", "c"],
39+
"react": true,
40+
"float": 2.43
41+
});
42+
43+
// set the tag context
44+
Sentry.setTagsContext({
45+
"environment": "production",
46+
"react": true
47+
});
48+
49+
// set the user context
50+
Sentry.setUserContext({
51+
52+
userID: "12341",
53+
username: "username",
54+
extra: {
55+
"is_admin": false
56+
}
57+
});
58+
59+
// set a custom message
60+
Sentry.captureMessage("TEST message", {
61+
level: SentrySeverity.Warning
62+
}); // Default SentrySeverity.Error
63+
64+
// capture an exception
65+
Sentry.captureException(new Error('Oops!'), {
66+
logger: 'my.module'
67+
});
68+
69+
// capture an exception
70+
Sentry.captureBreadcrumb({
71+
message: 'Item added to shopping cart',
72+
category: 'action',
73+
data: {
74+
isbn: '978-1617290541',
75+
cartSize: '3'
76+
}
77+
});
78+
79+
// This will trigger a crash in the native sentry client
80+
//Sentry.nativeCrash();

docs/index.rst

Lines changed: 44 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ Start with adding sentry and linking it::
2424
$ react-native link react-native-sentry
2525

2626
The `link` step will pull in the native dependency. If you are using
27-
Android or expo you don't have to (or can't) run that step. In that case
28-
we fall back automatically.
27+
expo you don't have to (or can't) run that step. In that case we fall
28+
back automatically.
2929

3030
Note that we only support ``react-native >= 0.38`` at the moment.
3131

32-
Xcode Build Settings
33-
--------------------
32+
iOS Specifics
33+
-------------
3434

3535
Since we use our `Swift Client
3636
<https://github.com/getsentry/sentry-swift>`_ in the background, your
@@ -48,18 +48,14 @@ You will get this error message if you forget to set it::
4848
Also note that if you build the project without setting this, you have to
4949
run clean in order to make the change work.
5050

51-
Xcode Build Steps
52-
-----------------
53-
54-
If you are using iOS (and not expo) you can hook directly into the build
55-
process to upload debug symbols.
51+
When you use xcode you can hook directly into the build process to upload
52+
debug symbols. Open up your xcode project in the iOS folder, go to your
53+
project's target and change the "Bundle React Native code and images"
54+
build script. The script that is currently there needs to be adjusted as
55+
follows::
5656

57-
Open up your xcode project in the iOS folder, go to your project's target and
58-
change the "Bundle React Native code and images" build script. The script that
59-
is currently there needs to be adjusted as follows::
60-
61-
export SENTRY_ORG=YOUR_ORG_SLUG
62-
export SENTRY_PROJECT=YOUR_PROJECT_SLUG
57+
export SENTRY_ORG=___ORG_NAME___
58+
export SENTRY_PROJECT=___PROJECT_NAME___
6359
export SENTRY_AUTH_TOKEN=YOUR_AUTH_TOKEN
6460
export NODE_BINARY=node
6561
../node_modules/react-native-sentry/bin/bundle-frameworks
@@ -81,10 +77,38 @@ Note that uploading of debug simulator builds by default is disabled for
8177
speed reasons. If you do want to also generate debug symbols for debug
8278
builds you can pass `--allow-fetch` as a parameter to ``react-native-xcode``.
8379

80+
Android Specifics
81+
-----------------
82+
83+
For Android we hook into gradle for the sourcemap build process. When you
84+
run ``react-native link`` the gradle files are automatically updated but
85+
in case you are not using linked frameworks you might have to do it
86+
manually. Whenever you run ``./gradlew assembleRelease`` sourcemaps are
87+
automatically built and uploaded to Sentry.
88+
89+
To enable the gradle integration you need to change your
90+
``android/app/build.gradle`` file and add the following line after the
91+
``react.gradle`` one::
92+
93+
apply from: "../../node_modules/react-native-sentry/sentry.gradle"
94+
95+
Additionally you need to create an ``android/sentry.properties`` file with
96+
the access credentials:
97+
98+
.. sourcecode:: ini
99+
100+
defaults.org=___ORG_NAME___
101+
defaults.project=___PROJECT_NAME___
102+
auth.token=YOUR_AUTH_TOKEN
103+
84104
Client Configuration
85105
--------------------
86106

87-
Add sentry to your `index.ios.js`:
107+
Note: When you run ``react-native link`` we will attempt to automatically
108+
patch your code so you might notice that some of these changes were
109+
already performed.
110+
111+
Add Sentry to your `index.ios.js` and `index.android.js`:
88112

89113
.. sourcecode:: javascript
90114

@@ -94,7 +118,8 @@ Add sentry to your `index.ios.js`:
94118

95119
If you are using the binary version of the package (eg: you ran
96120
``react-native link``) then you additionally need to register the native
97-
crash handler in your `AppDelegate.m` after the root view was created:
121+
crash handler in your `AppDelegate.m` after the root view was created for
122+
iOS:
98123

99124
.. sourcecode:: objc
100125

@@ -104,98 +129,16 @@ crash handler in your `AppDelegate.m` after the root view was created:
104129
#import "RNSentry.h" // This is used for versions of react < 0.40
105130
#endif
106131

107-
/* ... */
132+
/* in your didFinishLaunchingWithOptions */
108133
[RNSentry installWithRootView:rootView];
109134
110-
111-
Additional Configuration
112-
------------------------
113-
114-
These are functions you can call in your javascript code:
115-
116-
.. sourcecode:: javascript
117-
118-
import {
119-
Sentry,
120-
SentrySeverity,
121-
SentryLog
122-
} from 'react-native-sentry';
123-
124-
// disable stacktrace merging
125-
Sentry.config("___DSN___", {
126-
deactivateStacktraceMerging: true, // default: false | Deactivates the stacktrace merging feature
127-
logLevel: SentryLog.Debug, // default SentryLog.None | Possible values: .None, .Error, .Debug, .Verbose
128-
// These two options will only be considered if stacktrace merging is active
129-
// Here you can add modules that should be ignored or exclude modules
130-
// that should no longer be ignored from stacktrace merging
131-
// ignoreModulesExclude: ["I18nManager"], // default: [] | Exclude is always stronger than include
132-
// ignoreModulesInclude: ["RNSentry"], // default: [] | Include modules that should be ignored too
133-
// ---------------------------------
134-
}).install();
135-
136-
// set a callback after an event was successfully sentry
137-
// its only guaranteed that this event contains `event_id` & `level`
138-
Sentry.setEventSentSuccessfully((event) => {
139-
// can also be called outside this block but maybe null
140-
// Sentry.lastEventId(); -> returns the last event_id after the first successfully sent event
141-
// Sentry.lastException(); -> returns the last event after the first successfully sent event
142-
});
143-
144-
// export an extra context
145-
Sentry.setExtraContext({
146-
"a_thing": 3,
147-
"some_things": {"green": "red"},
148-
"foobar": ["a", "b", "c"],
149-
"react": true,
150-
"float": 2.43
151-
});
152-
153-
// set the tag context
154-
Sentry.setTagsContext({
155-
"environment": "production",
156-
"react": true
157-
});
158-
159-
// set the user context
160-
Sentry.setUserContext({
161-
162-
userID: "12341",
163-
username: "username",
164-
extra: {
165-
"is_admin": false
166-
}
167-
});
168-
169-
// set a custom message
170-
Sentry.captureMessage("TEST message", {
171-
level: SentrySeverity.Warning
172-
}); // Default SentrySeverity.Error
173-
174-
// capture an exception
175-
Sentry.captureException(new Error('Oops!'), {
176-
logger: 'my.module'
177-
});
178-
179-
// capture an exception
180-
Sentry.captureBreadcrumb({
181-
message: 'Item added to shopping cart',
182-
category: 'action',
183-
data: {
184-
isbn: '978-1617290541',
185-
cartSize: '3'
186-
}
187-
});
188-
189-
// This will trigger a crash in the native sentry client
190-
//Sentry.nativeCrash();
191-
192135
More
193136
----
194137

195138
.. toctree::
196139
:maxdepth: 2
197140

141+
config
198142
expo
199143
sourcemaps
200144
cocoapods
201-

0 commit comments

Comments
 (0)