Skip to content

Log wordpress-rs request errors via AppLog and centralize WpComApiClient construction#22979

Draft
oguzkocer wants to merge 2 commits into
trunkfrom
wpcom-api-client-error-logging
Draft

Log wordpress-rs request errors via AppLog and centralize WpComApiClient construction#22979
oguzkocer wants to merge 2 commits into
trunkfrom
wpcom-api-client-error-logging

Conversation

@oguzkocer

@oguzkocer oguzkocer commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Description

Failed wordpress-rs requests were not surfaced anywhere in the app's own diagnostics. This PR routes them to AppLog (so they appear in the in-app log viewer and crash-reporting breadcrumbs under the API tag) and, as a follow-up, consolidates WpComApiClient construction 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 AppLog

  • Bump wordpress-rs to the unescape blogName when it's going to be displayed to the user #1398 build that exposes RequestErrorLogger.
  • Pass RequestErrorLogger { AppLog.e(AppLog.T.API, it) } into every WpComApiClient / WpApiClient construction site (WpComApiClientProvider, the three constructions in fluxc's WpApiClientProvider, and the two ViewModels that built clients directly).

Self-contained and shippable on its own.

2. Centralize WpComApiClient construction

  • Route DataViewViewModel (and its SubscribersViewModel, TermsViewModel, ApplicationPasswordsViewModel subclasses) and AddSubscribersViewModel through WpComApiClientProvider.getWpComApiClient(token) instead of constructing WpComApiClient directly.
  • Drops the per-call auth/interceptor/logger boilerplate and the now-unused trackNetworkRequestsInterceptor / networkAvailabilityProvider constructor params from those ViewModels (a net simplification).
  • WpComApiClientProvider now attaches TrackNetworkRequestsInterceptor itself, so the moved clients keep their network-inspector behavior.

Behavior change

Because WpComApiClientProvider now attaches TrackNetworkRequestsInterceptor, 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

  1. Error logging — trigger a failed WP.com request (e.g. temporarily force the Me → Domains → Find a domain request to fail) and confirm a WordPress-API-tagged error appears in logcat / the in-app log viewer, e.g. E/WordPress-API: UnknownError(status=400, method=GET, url=…, response=…).
  2. Migrated screens — verify the screens backed by the migrated ViewModels still work end to end: Me → Subscribers (and Add subscribers), Terms (categories/tags), and Application Passwords.
  3. Network tracker (optional) — enable Track network requests in debug settings and confirm WP.com requests from the above flows show up.

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.
@oguzkocer oguzkocer added this to the 26.9 milestone Jun 13, 2026
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Error
🚫 This PR includes a PR version of wordpress-rs (1398-ba6481de5f07565a6c69442f2d3a77b2c12f6d89). Please merge the corresponding wordpress-rs PR and update to a trunk version before merging.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot

Copy link
Copy Markdown
Contributor

Project dependencies changes

list
! 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

@wpmobilebot

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22979-7495634
Build Number1493
Application IDorg.wordpress.android.prealpha
Commit7495634
Installation URL2cl1v37lcijs0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22979-7495634
Build Number1493
Application IDcom.jetpack.android.prealpha
Commit7495634
Installation URL7i8pus4l9oldo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants