Log wordpress-rs request errors via AppLog and centralize WpComApiClient construction#22979
Draft
oguzkocer wants to merge 2 commits into
Draft
Log wordpress-rs request errors via AppLog and centralize WpComApiClient construction#22979oguzkocer wants to merge 2 commits into
wordpress-rs request errors via AppLog and centralize WpComApiClient construction#22979oguzkocer wants to merge 2 commits into
Conversation
Bump wordpress-rs to the PR #1398 build that adds RequestErrorLogger, and wire RequestErrorLogger { AppLog.e(T.API, it) } into every WpComApiClient and WpApiClient construction site. Failed requests are now logged under the API tag (and crash-reporting breadcrumbs) instead of going unlogged.
Route DataViewViewModel (with its SubscribersViewModel, TermsViewModel, and ApplicationPasswordsViewModel subclasses) and AddSubscribersViewModel through WpComApiClientProvider instead of constructing WpComApiClient directly. Keeps the RequestErrorLogger wiring in one place and drops the per-call auth/ interceptor/logger boilerplate. The provider now attaches TrackNetworkRequestsInterceptor, so all its consumers (previously only these ViewModels) become inspectable via the in-app network tracker when that debug setting is enabled.
Collaborator
Generated by 🚫 Danger |
Contributor
Project dependencies changeslist! Upgraded Dependencies
com.squareup.okhttp3:okhttp:5.4.0, (changed from 5.3.2)
com.squareup.okhttp3:okhttp-android:5.4.0, (changed from 5.3.2)
com.squareup.okhttp3:okhttp-tls:5.4.0, (changed from 5.3.2)
com.squareup.okio:okio:3.17.0, (changed from 3.16.4)
com.squareup.okio:okio-jvm:3.17.0, (changed from 3.16.4)
net.java.dev.jna:jna:5.19.0, (changed from 5.18.1)
rs.wordpress.api:android:1398-ba6481de5f07565a6c69442f2d3a77b2c12f6d89, (changed from 0.4.0)
rs.wordpress.api:kotlin:1398-ba6481de5f07565a6c69442f2d3a77b2c12f6d89, (changed from 0.4.0)tree +--- project :libs:image-editor
| \--- com.automattic:ucrop:2.2.11
-| \--- com.squareup.okhttp3:okhttp:3.12.13 -> 5.3.2
-| \--- com.squareup.okhttp3:okhttp-android:5.3.2
-| +--- androidx.annotation:annotation:1.9.1 -> 1.10.0 (*)
-| +--- androidx.startup:startup-runtime:1.2.0 (*)
-| +--- com.squareup.okio:okio:3.16.4
-| | \--- com.squareup.okio:okio-jvm:3.16.4
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.2.20 -> 2.3.21 (*)
-| \--- org.jetbrains.kotlin:kotlin-stdlib:2.2.21 -> 2.3.21 (*)
+| \--- com.squareup.okhttp3:okhttp:3.12.13 -> 5.4.0
+| \--- com.squareup.okhttp3:okhttp-android:5.4.0
+| +--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.21 (*)
+| +--- com.squareup.okio:okio:3.17.0
+| | \--- com.squareup.okio:okio-jvm:3.17.0
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.21 (*)
+| +--- org.jetbrains.kotlin:kotlin-stdlib:2.2.21 -> 2.3.21 (*)
+| +--- androidx.annotation:annotation:1.10.0 (*)
+| \--- androidx.startup:startup-runtime:1.2.0 (*)
+--- project :libs:editor
| +--- com.facebook.react:react-android:0.73.3
| | +--- com.facebook.fresco:imagepipeline-okhttp3:3.1.3
-| | | \--- com.squareup.okhttp3:okhttp:3.12.1 -> 5.3.2 (*)
+| | | \--- com.squareup.okhttp3:okhttp:3.12.1 -> 5.4.0 (*)
| | +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.2 -> 5.3.2
-| | | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| | | +--- com.squareup.okhttp3:okhttp:5.3.2 -> 5.4.0 (*)
| | | \--- com.squareup.okhttp3:okhttp-java-net-cookiejar:5.3.2
-| | | \--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| | | \--- com.squareup.okhttp3:okhttp:5.3.2 -> 5.4.0 (*)
-| | +--- com.squareup.okhttp3:okhttp:4.9.2 -> 5.3.2 (*)
+| | +--- com.squareup.okhttp3:okhttp:4.9.2 -> 5.4.0 (*)
-| | \--- com.squareup.okio:okio:2.9.0 -> 3.16.4 (*)
+| | \--- com.squareup.okio:okio:2.9.0 -> 3.17.0 (*)
| +--- org.wordpress.gutenberg-mobile:react-native-gutenberg-bridge:v1.121.0
| | +--- com.github.wordpress-mobile:react-native-video:5.2.0-wp-7
| | | +--- com.google.android.exoplayer:extension-okhttp:2.13.3
-| | | | \--- com.squareup.okhttp3:okhttp:3.12.11 -> 5.3.2 (*)
+| | | | \--- com.squareup.okhttp3:okhttp:3.12.11 -> 5.4.0 (*)
-| | | \--- com.squareup.okhttp3:okhttp:${OKHTTP_VERSION} -> 5.3.2 (*)
+| | | \--- com.squareup.okhttp3:okhttp:${OKHTTP_VERSION} -> 5.4.0 (*)
| | \--- org.wordpress.react-native-libraries.v6:react-native-fast-image:8.5.11
| | \--- com.github.bumptech.glide:okhttp3-integration:4.12.0 -> 5.0.7
-| | \--- com.squareup.okhttp3:okhttp:3.10.0 -> 5.3.2 (*)
+| | \--- com.squareup.okhttp3:okhttp:3.10.0 -> 5.4.0 (*)
| +--- org.wordpress.gutenbergkit:android:v0.17.2
-| | \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| | \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
| \--- com.automattic.tracks:crashlogging:6.0.6
-| \--- com.squareup.okhttp3:okhttp:4.9.0 -> 5.3.2 (*)
+| \--- com.squareup.okhttp3:okhttp:4.9.0 -> 5.4.0 (*)
+--- project :libs:fluxc
-| +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| +--- com.squareup.okhttp3:okhttp:5.3.2 -> 5.4.0 (*)
| +--- com.github.chuckerteam.chucker:library:4.2.0
-| | +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| | +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
-| | \--- com.squareup.okhttp3:okhttp -> 5.3.2 (*)
+| | \--- com.squareup.okhttp3:okhttp -> 5.4.0 (*)
-| \--- rs.wordpress.api:android:0.4.0
-| +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| +--- com.squareup.okhttp3:okhttp-tls:5.3.2
-| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| | +--- com.squareup.okio:okio:3.16.4 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.2.21 -> 2.3.21 (*)
-| +--- net.java.dev.jna:jna:5.18.1
-| +--- rs.wordpress.api:kotlin:0.4.0
-| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| | +--- com.squareup.okhttp3:okhttp-tls:5.3.2 (*)
-| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 -> 1.11.0 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.21 (*)
-| \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.21 (*)
+| \--- rs.wordpress.api:android:1398-ba6481de5f07565a6c69442f2d3a77b2c12f6d89
+| +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+| +--- com.squareup.okhttp3:okhttp-tls:5.4.0
+| | +--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.21 (*)
+| | +--- com.squareup.okio:okio:3.17.0 (*)
+| | \--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+| +--- net.java.dev.jna:jna:5.19.0
+| +--- rs.wordpress.api:kotlin:1398-ba6481de5f07565a6c69442f2d3a77b2c12f6d89
+| | +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+| | +--- com.squareup.okhttp3:okhttp-tls:5.4.0 (*)
+| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 -> 1.11.0 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.21 (*)
+| \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.21 (*)
+--- com.gravatar:gravatar:2.5.0
| +--- com.squareup.moshi:moshi:1.15.1
-| | \--- com.squareup.okio:okio:3.7.0 -> 3.16.4 (*)
+| | \--- com.squareup.okio:okio:3.7.0 -> 3.17.0 (*)
-| \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
+--- com.gravatar:gravatar-quickeditor:2.5.0
| +--- com.gravatar:gravatar-ui:2.5.0
| | \--- io.coil-kt:coil-compose:2.7.0
| | \--- io.coil-kt:coil-compose-base:2.7.0
| | \--- io.coil-kt:coil-base:2.7.0
-| | +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| | +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
-| | \--- com.squareup.okio:okio:3.9.0 -> 3.16.4 (*)
+| | \--- com.squareup.okio:okio:3.9.0 -> 3.17.0 (*)
| \--- io.github.osipxd:security-crypto-datastore-preferences:1.1.1-beta03
| +--- io.github.osipxd:encrypted-datastore-preferences:1.1.1-beta03
| | \--- androidx.datastore:datastore-preferences-core:1.1.1 -> 1.1.7
| | \--- androidx.datastore:datastore-preferences-core-android:1.1.7
| | +--- androidx.datastore:datastore-core-okio:1.1.7
| | | \--- androidx.datastore:datastore-core-okio-jvm:1.1.7
-| | | \--- com.squareup.okio:okio:3.4.0 -> 3.16.4 (*)
+| | | \--- com.squareup.okio:okio:3.4.0 -> 3.17.0 (*)
-| | \--- com.squareup.okio:okio:3.4.0 -> 3.16.4 (*)
+| | \--- com.squareup.okio:okio:3.4.0 -> 3.17.0 (*)
| \--- io.github.osipxd:security-crypto-datastore:1.1.1-beta03
| \--- androidx.datastore:datastore:1.1.1 -> 1.1.7
| \--- androidx.datastore:datastore-android:1.1.7
-| \--- com.squareup.okio:okio:3.4.0 -> 3.16.4 (*)
+| \--- com.squareup.okio:okio:3.4.0 -> 3.17.0 (*)
+--- com.squareup.retrofit2:retrofit:3.0.0
-| \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
+--- com.airbnb.android:lottie:6.7.1
-| \--- com.squareup.okio:okio:{require 1.17.6; reject _} -> 3.16.4 (*)
+| \--- com.squareup.okio:okio:{require 1.17.6; reject _} -> 3.17.0 (*)
+--- com.zendesk:support:5.5.3
| +--- com.squareup.picasso:picasso:2.8
-| | \--- com.squareup.okhttp3:okhttp:3.10.0 -> 5.3.2 (*)
+| | \--- com.squareup.okhttp3:okhttp:3.10.0 -> 5.4.0 (*)
| \--- com.zendesk:guide:1.5.3
-| +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
| \--- com.zendesk:guide-providers:1.3.2
| \--- com.zendesk:core:4.2.2
-| +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
| \--- com.squareup.okhttp3:logging-interceptor:4.12.0
-| \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+| \--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.4.0 (*)
-+--- rs.wordpress.api:android:0.4.0 (*)
++--- rs.wordpress.api:android:1398-ba6481de5f07565a6c69442f2d3a77b2c12f6d89 (*)
\--- com.automattic:encryptedlogging:1.1.1
- \--- net.java.dev.jna:jna:5.17.0 -> 5.18.1
+ \--- net.java.dev.jna:jna:5.17.0 -> 5.19.0 |
Contributor
|
|
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Failed
wordpress-rsrequests were not surfaced anywhere in the app's own diagnostics. This PR routes them toAppLog(so they appear in the in-app log viewer and crash-reporting breadcrumbs under theAPItag) and, as a follow-up, consolidatesWpComApiClientconstruction so that wiring lives in a single place.The PR is split into two independent commits. The second is a cleanup and can be dropped without affecting the first.
Changes
1. Route request errors to
AppLogwordpress-rsto the unescape blogName when it's going to be displayed to the user #1398 build that exposesRequestErrorLogger.RequestErrorLogger { AppLog.e(AppLog.T.API, it) }into everyWpComApiClient/WpApiClientconstruction site (WpComApiClientProvider, the three constructions in fluxc'sWpApiClientProvider, and the two ViewModels that built clients directly).Self-contained and shippable on its own.
2. Centralize
WpComApiClientconstructionDataViewViewModel(and itsSubscribersViewModel,TermsViewModel,ApplicationPasswordsViewModelsubclasses) andAddSubscribersViewModelthroughWpComApiClientProvider.getWpComApiClient(token)instead of constructingWpComApiClientdirectly.trackNetworkRequestsInterceptor/networkAvailabilityProviderconstructor params from those ViewModels (a net simplification).WpComApiClientProvidernow attachesTrackNetworkRequestsInterceptoritself, so the moved clients keep their network-inspector behavior.Behavior change
Because
WpComApiClientProvidernow attachesTrackNetworkRequestsInterceptor, all of its consumers (StatsDataSourceImpl,NewDomainsSearchRepository,HESupportRepository,AIBotSupportRepository, plus the migrated ViewModels) become inspectable via the in-app Track network requests debug tool. This is preference-gated (off unless the user enables it) and makes coverage uniform across WP.com clients.Testing instructions
Me → Domains → Find a domainrequest to fail) and confirm aWordPress-API-tagged error appears in logcat / the in-app log viewer, e.g.E/WordPress-API: UnknownError(status=400, method=GET, url=…, response=…).Me → Subscribers(and Add subscribers), Terms (categories/tags), and Application Passwords.