You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/react-native/README.md
+40-1Lines changed: 40 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,7 @@ Enabling this via the Objective-C API is not yet supported if initialization is
166
166
167
167
#### Android
168
168
169
-
To enable network integration in Android a Gradle plugin needs to be added to the project. This can be done by adding a dependency on the `io.bitdrift.capture-plugin` plugin in the `plugins` block of the apps's`build.gradle` file:
169
+
To enable automatic OkHttp instrumentation on Android, add the `io.bitdrift.capture-plugin` plugin in the app`build.gradle` file:
170
170
171
171
```gradle
172
172
plugins {
@@ -176,6 +176,18 @@ plugins {
176
176
177
177
To find the version to use, use the same version of the Capture SDK that is being used in the React Native project. Check the `build.gradle` file in the `node_modules/@bitdrift/react-native/android` directory for the version of the Capture SDK being used.
178
178
179
+
For manual Gradle setup, enable plugin instrumentation:
180
+
181
+
```gradle
182
+
bitdrift {
183
+
instrumentation {
184
+
automaticOkHttpInstrumentation = true
185
+
// Optional. Defaults to PROXY when omitted.
186
+
// okHttpInstrumentationType = OVERWRITE
187
+
}
188
+
}
189
+
```
190
+
179
191
In addition to this the plugin repository needs to be added to the `pluginManagement` block in the `settings.gradle` file:
180
192
181
193
```gradle
@@ -209,3 +221,30 @@ When using Expo to generate the project, this can be achieved by setting the `ne
209
221
}
210
222
}
211
223
```
224
+
225
+
When using the Expo plugin with `networkInstrumentation: true`, the Android Gradle plugin and `bitdrift { instrumentation { ... } }` block are generated automatically.
226
+
227
+
The Android plugin mode can be configured with `okHttpInstrumentationType`:
228
+
229
+
```json
230
+
{
231
+
"expo": {
232
+
"plugins": [
233
+
[
234
+
"@bitdrift/react-native",
235
+
{
236
+
"networkInstrumentation": true,
237
+
"okHttpInstrumentationType": "OVERWRITE"
238
+
}
239
+
]
240
+
]
241
+
}
242
+
}
243
+
```
244
+
245
+
`okHttpInstrumentationType` is Android-only and has no effect on iOS.
246
+
247
+
-`PROXY` (default): preserves existing `EventListener.Factory` behavior in OkHttp clients.
248
+
-`OVERWRITE`: replaces the listener factory and can avoid duplicate network spans in some app setups.
249
+
250
+
If you recently upgraded and started seeing duplicate spans on Android, set `okHttpInstrumentationType` to `OVERWRITE`.
// Add the bitdrift maven repository to the pluginManagement block to allow the plugin to resolve the SDK dependency. This is safe to do regardless of whether the network instrumentation is enabled or not.
0 commit comments