Commit bbc35bb
feat(replay): Adding OkHttp Request/Response bodies (#4796)
* Add HTTP Request Trigger to sentry-samples-android app
* [replay] Make DefaultReplayBreadcrumbConverter the default BeforeBreadcrumbCallback to extract NetworkRequestData from Hint
-> NetworkRequestData is landing on DefaultReplayBreadcrumbConverter via Hint.get(replay:networkDetails)
* [replay] Add data classes for NetworkDetails
These get set on the breadcrumb Hint, and then hang around in DefaultReplayBreadcrumbConverter until the replay segment has been sent off
See
https://github.com/getsentry/sentry-javascript/blob/632f0b953d99050c11b0edafb9f80b5f3ba88045/packages/replay-internal/src/types/performance.ts#L133-L140
https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-internal/src/types/request.ts#L12
* [DNL] Force dashboard to show request/response bodies
Manually set networkDetailHasUrls to pass this check
https://github.com/getsentry/sentry-javascript/blob/d1646c8a281dd8795c5a6a3b8e18f2e7069e7fa9/packages/replay-internal/src/util/handleRecordingEmit.ts#L134
https://github.com/getsentry/sentry/blob/master/static/app/views/replays/detail/network/details/getOutputType.tsx#L33
https://github.com/getsentry/sentry/blob/master/static/app/views/replays/detail/network/details/content.tsx#L55-L56
* Move BeforeBreadcrumbCallback initialization to after user config
added some unit tests:
./gradlew :sentry-android-replay:testDebugUnitTest --tests="*DefaultReplayBreadcrumbConverterTest*"
* bugfix: Update Breadcrumb #hashcode to be consistent with #equals
Breadcrumb.java has several timestamp fields:
`timestamp: Date`, `timestampMs: Long`, `nanos: Long`
`hashcode` was relying solely on `timestamp`, which can be null depending on which constructor was used.
=> Change to use getTimestamp as 1. this is what equals does (consistency) 2. getTimestamp initialises timestamp if null.
* Initial NetworkDetails extraction logic
Entrypoint is NetworkDetailCaptureUtils (initializeForUrl) called from SentryOkHttpInterceptor
- common logic to handle checking sdk options.
- Accept data from http client via NetworkBodyExtractor, NetworkHeaderExtractor interfaces
that can be reused in future (if needed)
Placeholder impl for req/resp bodies.
From https://docs.sentry.io/platforms/javascript/session-replay/configuration/
- networkDetailAllowUrls, networkDetailDenyUrls,
- networkCaptureBodies
- networkRequestHeaders, networkResponseHeaders
These SDKOptions don't exist yet => impl acts as if they do, but have not been enabled.
* DefaultReplayBreadcrumbConverter properly manages NetworkRequestData entries
Removes entry when creating RRWebSpanEvent
Uses syncrhonized LinkedHashMap with impl to cap size of map (avoid
memory bloat)
* Extract bodies of okhttp requests/responses
Replaces previous placeholder logic.
Now NetworkBodyParser uses io.sentry.JsonObjectReader
to extract body into JSONObject, JSONArray, with fallback to plain-text String (or nothing)
* Check-in sentry-android-replay.api
* Add additional http request types to sentry-samples app for testing
One-shot bodies
Form bodies
plain text bodies
binary bodies
* Add body too large http request types to sentry-samples app
* Properly handle content bodies that are too large
based on cursor[bot] feedback -
https://github.com/getsentry/sentry-java/pull/4796/files#r2466871208
* Disable Network Detail extraction
Initialize the values in FAKE_OPTIONS so that implementation acts as if dev never turned it on.
Leaves in the FAKE_OPTIONS variable to be easy to update reference to real `options` later on.
* Modify ReplayBreadcrumbConverter API to avoid breaking flutter/RN SDKs
use composition via optional constructor on DefaultReplayBreadcrumbConverter
Instead of modifying the parent interface ReplayBreadcrumbConverter to force all subclasses to implement BeforeBreadcrumbCallback (breaking / harder to manage change)
* Move ReplayBreadcrumbConverter initialization after SDKOptions initialization
DefaultReplayBreadcrumbConverter depends on SDKOptions as it now
needs to delegate to any user-provided BeforeBreadcrumbCallback
* Custom #equals/#hashcode for http breadcrumbs
review thread - https://github.com/getsentry/sentry-java/pull/4796/files#r2461102218
* ./gradlew apiDump
---------
Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>1 parent 7c81e67 commit bbc35bb
File tree
20 files changed
+2180
-32
lines changed- sentry-android-core/src/main/java/io/sentry/android/core
- sentry-android-replay
- api
- src
- main/java/io/sentry/android/replay
- test/java/io/sentry/android/replay
- sentry-okhttp/src/main/java/io/sentry/okhttp
- sentry-samples/sentry-samples-android/src/main
- java/io/sentry/samples/android
- res
- layout
- values
- sentry
- api
- src/main/java/io/sentry
- util/network
20 files changed
+2180
-32
lines changedLines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
256 | 264 | | |
257 | 265 | | |
258 | 266 | | |
| |||
406 | 414 | | |
407 | 415 | | |
408 | 416 | | |
409 | | - | |
410 | 417 | | |
411 | 418 | | |
412 | 419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
Lines changed: 133 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
13 | 27 | | |
| 28 | + | |
14 | 29 | | |
| 30 | + | |
15 | 31 | | |
16 | 32 | | |
17 | 33 | | |
| |||
23 | 39 | | |
24 | 40 | | |
25 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
26 | 78 | | |
27 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
28 | 91 | | |
29 | 92 | | |
30 | | - | |
| 93 | + | |
31 | 94 | | |
32 | 95 | | |
| 96 | + | |
33 | 97 | | |
34 | 98 | | |
35 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
36 | 104 | | |
37 | 105 | | |
38 | 106 | | |
| |||
42 | 110 | | |
43 | 111 | | |
44 | 112 | | |
| 113 | + | |
45 | 114 | | |
46 | 115 | | |
47 | 116 | | |
| |||
53 | 122 | | |
54 | 123 | | |
55 | 124 | | |
56 | | - | |
| 125 | + | |
57 | 126 | | |
| 127 | + | |
58 | 128 | | |
59 | 129 | | |
60 | 130 | | |
| |||
67 | 137 | | |
68 | 138 | | |
69 | 139 | | |
| 140 | + | |
70 | 141 | | |
71 | 142 | | |
72 | 143 | | |
| |||
75 | 146 | | |
76 | 147 | | |
77 | 148 | | |
78 | | - | |
| 149 | + | |
79 | 150 | | |
80 | 151 | | |
81 | 152 | | |
82 | 153 | | |
83 | 154 | | |
84 | | - | |
| 155 | + | |
85 | 156 | | |
86 | 157 | | |
87 | 158 | | |
88 | 159 | | |
89 | | - | |
| 160 | + | |
90 | 161 | | |
91 | 162 | | |
92 | 163 | | |
| |||
105 | 176 | | |
106 | 177 | | |
107 | 178 | | |
| 179 | + | |
108 | 180 | | |
109 | 181 | | |
110 | 182 | | |
| |||
120 | 192 | | |
121 | 193 | | |
122 | 194 | | |
123 | | - | |
124 | | - | |
| 195 | + | |
| 196 | + | |
125 | 197 | | |
126 | 198 | | |
| 199 | + | |
127 | 200 | | |
128 | | - | |
129 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
130 | 204 | | |
131 | 205 | | |
132 | 206 | | |
133 | 207 | | |
134 | 208 | | |
| 209 | + | |
135 | 210 | | |
136 | 211 | | |
137 | 212 | | |
138 | 213 | | |
139 | | - | |
| 214 | + | |
| 215 | + | |
140 | 216 | | |
141 | 217 | | |
142 | 218 | | |
143 | 219 | | |
144 | 220 | | |
145 | 221 | | |
| 222 | + | |
146 | 223 | | |
147 | 224 | | |
148 | 225 | | |
| |||
151 | 228 | | |
152 | 229 | | |
153 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
154 | 271 | | |
155 | 272 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
159 | 276 | | |
160 | 277 | | |
| 278 | + | |
161 | 279 | | |
162 | 280 | | |
163 | 281 | | |
| |||
0 commit comments