Commit 2ae0e03
Integrate Chucker for network troubleshooting (#22381)
* Add Chucker integration research documentation
Document the plan for integrating Chucker HTTP inspector into the app
for production use (disabled by default, user opt-in for troubleshooting).
Research findings:
- 7 network paths identified, 5 are OkHttp-based (interceptable)
- OkHttpClientModule is the main path covering ~90% of traffic
- 2 HttpURLConnection usages cannot be intercepted (edge cases)
- Wrapper interceptor approach recommended for runtime enable/disable
* Add track network requests interceptor foundation for Chucker integration
Add an OkHttp interceptor that will serve as the foundation for HTTP
traffic inspection via Chucker. The interceptor is disabled by default
and can be toggled by users in the Help screen for troubleshooting.
Changes:
- Add `TrackNetworkRequestsInterceptor` in FluxC with preference interface
- Add `TrackNetworkRequestsModule` to inject interceptor into OkHttpClient
- Add preference `IS_TRACK_NETWORK_REQUESTS_ENABLED` in `AppPrefs`
- Add toggle UI in Help screen below "Contact email"
* Integrate Chucker library into TrackNetworkRequestsInterceptor
Add Chucker v4.2.0 as the HTTP traffic inspection backend for the
Track Network Requests feature. The interceptor now delegates to
ChuckerInterceptor when the feature is enabled.
Configuration:
- 1-hour retention period
- Sensitive headers redacted (Authorization, Cookie, Set-Cookie, X-WP-Nonce)
- Notifications disabled (custom UI entry point to be added)
- Max content length: 250KB
Changes:
- Add Chucker dependency to libs.versions.toml and build.gradle files
- Update TrackNetworkRequestsInterceptor to create and use ChuckerInterceptor
- Simplify TrackNetworkRequestsModule (Chucker is now an implementation detail)
* Add View Network Requests button to launch Chucker UI
Add a button in the Help screen that launches Chucker's traffic
inspector UI. The button is only visible when Track Network Requests
is enabled.
Changes:
- Add `viewNetworkRequestsButton` to help_activity.xml
- Add `view_network_requests` string resource
- Update `setupTrackNetworkRequestsToggle()` to show/hide button and handle click
* Add configurable retention period and dialog-based UX for network tracking
Implement retention period selection when enabling Track Network Requests,
with dialog-based enable/disable flow for better user communication.
Features:
- Retention period options: 1 Hour, 1 Day, 1 Week, Until Cleared
- Enable dialog with privacy explanation and retention picker
- Disable dialog with guidance on clearing logs manually
- "View Network Requests" now shows current retention period
Technical changes:
- Add `NetworkRequestsRetentionPeriod` enum with stable int values for persistence
- Interceptor lazily creates and recreates ChuckerInterceptor when retention changes
- Add `dialog_title_with_message.xml` layout for dialogs with description text
- Use `setSwitchCheckedSilently()` to prevent listener loops on cancel
Changes:
- Add retention period preference to `AppPrefs` and `AppPrefsWrapper`
- Update `TrackNetworkRequestsPreference` interface with `getRetentionPeriod()`
- Add enable/disable dialogs to `HelpActivity`
- Update `help_activity.xml` with container showing retention info
- Add string resources for retention options and dialog messages
* Add login request tracking and make preferences device-level
Enable network request tracking for OAuth login flows by adding
interceptors to WPcomLoginClient. Move tracking preferences to
UndeletablePrefKey so they persist across logout/login cycles,
allowing users to troubleshoot login issues.
Changes:
- Add interceptors to WPcomLoginClient for OAuth token exchange
- Move IS_TRACK_NETWORK_REQUESTS_ENABLED to UndeletablePrefKey
- Move TRACK_NETWORK_REQUESTS_RETENTION_PERIOD to UndeletablePrefKey
- Add documentation for Chucker export API options
* Add GutenbergKit network request logging to Chucker
Integrates GutenbergKit's WebView network requests with Chucker by
replaying them through OkHttp. This allows editor network traffic
to appear alongside native app requests in the unified log.
Changes:
- Add `GutenbergKitNetworkLogger` to replay JS fetch requests through OkHttp
- Add `isNetworkLoggingEnabled` to `FeatureConfig` and `EditorConfiguration`
- Wire up `NetworkRequestListener` in `GutenbergKitActivity`
- Update GutenbergKit to PR #238 branch with network logging support
* Remove debug logs from GutenbergKit network logging
Remove verbose debug logging used during development.
Keep error logging for diagnosing failures.
* Add experimental feature flag for Network Debugging
Hide the Track Network Requests section in Help behind an experimental
feature flag. When the flag is disabled, the section is completely
hidden. When trying to disable the flag while tracking is enabled,
show an error dialog instructing the user to disable tracking first.
Changes:
- Add NETWORK_DEBUGGING to ExperimentalFeatures.Feature enum
- Add validation in ExperimentalFeaturesViewModel to prevent disabling
the flag while tracking is active
- Add NetworkDebuggingErrorDialog composable for the error state
- Update HelpActivity to check the feature flag before showing section
- Wrap track network requests UI in a single container for cleaner
visibility management
* Fix detekt issues in Chucker integration code
Add suppress annotations for:
- LongMethod in ExperimentalFeaturesActivity.onCreate (Compose UI)
- TooGenericExceptionCaught in GutenbergKitNetworkLogger (intentional)
- MagicNumber in GutenbergKitNetworkLogger (HTTP status codes)
* Add network debugging to new Support screen
Duplicate the network tracking functionality from HelpActivity to the
new Compose-based SupportActivity (behind MODERN_SUPPORT flag).
Also update help_activity.xml to show retention info under the toggle
instead of under the view button, for consistency between both UIs.
Changes:
- Add NetworkTrackingState and DialogEvent to SupportViewModel
- Add NetworkTrackingToggleItem composable to SupportScreen
- Add dialog handling and Chucker navigation to SupportActivity
- Restructure help_activity.xml for consistent retention info placement
* Integrate Chucker interceptor into wordpress-rs clients
Wire `TrackNetworkRequestsInterceptor` into all wordpress-rs based
network clients so their requests are captured when network debugging
is enabled.
Changes:
- `WpApiClientProvider`: Accept interceptors via Dagger `@Named` set
- `ApplicationModule`: Pass interceptor to `WpLoginClient`
- `DataViewViewModel`: Inject interceptor for `WpComApiClient`
- `JetpackConnectionHelper`: Inject interceptor for connection client
- `AddSubscribersViewModel`: Inject interceptor for subscriber API
- Child ViewModels: Pass interceptor to parent `DataViewViewModel`
* Update GutenbergKit to v0.11.0 and adapt to API changes
GutenbergKit v0.11.0 renamed `NetworkRequest` to `RecordedNetworkRequest`
and added a `statusText` field, allowing us to remove our custom HTTP
status code mapping.
Changes:
- Update GutenbergKit version to v0.11.0
- Rename NetworkRequest to RecordedNetworkRequest
- Use statusText from RecordedNetworkRequest instead of toStatusMessage()
* Use OkHttpClientQualifiers.INTERCEPTORS constant for @nAmed annotations
Replace hardcoded "interceptors" strings with the constant to prevent
typos and enable easier refactoring.
* Remove research documentation files
* Fix lint warnings and update tests for new constructor parameters
- Add @nonnull annotation to ApplicationModule parameter
- Add @SuppressLint("InflateParams") for AlertDialog custom title inflation
- Update SupportViewModelTest with appPrefsWrapper and experimentalFeatures
- Update DataViewViewModelTest with trackNetworkRequestsInterceptor
- Update ExperimentalFeaturesViewModelTest with appPrefsWrapper
- Update TermsViewModelTest with trackNetworkRequestsInterceptor
* Refactor retention period display string into two methods Split getRetentionPeriodDisplayString into separate methods for better readability and reusability: - getRetentionPeriodStringRes: returns the string resource ID - getRetentionPeriodDisplayString: resolves it to a String Changes: - Extract resource ID mapping to dedicated method - Simplify the display string method to delegate
Co-authored-by: Adalberto Plaza <[email protected]>
* Migrate network tracking dialogs to Compose
Replace View-based AlertDialogs with Compose AlertDialogs in SupportScreen.
This addresses PR feedback about using Compose dialogs in a Compose activity.
Changes:
- Add reusable SingleChoiceAlertDialog component
- Convert DialogEvent (SharedFlow) to DialogState (StateFlow) in ViewModel
- Add EnableTrackingDialog and DisableTrackingDialog composables
- Remove XML layout inflation and View-based dialog code from Activity
* Add tests for network tracking functionality in SupportViewModel
Cover the new network tracking dialog state management with tests for:
- init() network debugging state based on feature flag and preferences
- onNetworkTrackingToggle showing enable/disable dialogs
- onEnableTrackingConfirmed/onDisableTrackingConfirmed state updates
- onDialogDismissed without side effects
- onRetentionPeriodSelected updating dialog state
Changes:
- Add 10 new tests in SupportViewModelTest
- Move init-related tests to existing init() region
- Create new region for dialog interaction tests
* Update GutenbergKit to v0.11.1
---------
Co-authored-by: Adalberto Plaza <[email protected]>1 parent 9b5ab17 commit 2ae0e03
File tree
37 files changed
+1366
-44
lines changed- WordPress
- src
- main
- java/org/wordpress/android
- modules
- support/main/ui
- ui
- accounts
- applicationpassword
- compose/components
- dataview
- jetpackrestconnection
- posts
- editor
- prefs
- experimentalfeatures
- subscribers
- taxonomies
- res
- layout
- values
- test/java/org/wordpress/android
- support/main/ui
- ui
- dataview
- prefs/experimentalfeatures
- taxonomies
- gradle
- libs/fluxc
- src/main/java/org/wordpress/android/fluxc/network
- rest/wpapi
- rs
37 files changed
+1366
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
| 455 | + | |
455 | 456 | | |
456 | 457 | | |
457 | 458 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | | - | |
157 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
158 | 162 | | |
159 | 163 | | |
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
Lines changed: 45 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | | - | |
| 25 | + | |
23 | 26 | | |
24 | | - | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
58 | 68 | | |
| 69 | + | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
64 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
65 | 82 | | |
66 | 83 | | |
67 | 84 | | |
68 | 85 | | |
69 | 86 | | |
70 | 87 | | |
71 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
72 | 107 | | |
73 | 108 | | |
74 | 109 | | |
| |||
81 | 116 | | |
82 | 117 | | |
83 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
84 | 122 | | |
85 | 123 | | |
86 | 124 | | |
| |||
120 | 158 | | |
121 | 159 | | |
122 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
123 | 165 | | |
124 | 166 | | |
125 | 167 | | |
| |||
0 commit comments