Repository navigation
RTC: add jetpack_rtc_connection_error Tracks event - #49617
Conversation
Record a jetpack_rtc_connection_error Tracks event on a genuine (non-limit) sync connection error. The per-room-limit case is skipped — it is already reported as jetpack_rtc_blocked, so counting it here too would double-count. Hooks the sync.providers filter (priority 30, outside the room-limit wrapper) and subscribes to provider status events, mirroring the join-tracking wrapper: transport-agnostic, ignores collection rooms, records once per provider. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
The PingHub transport emits a bare { status: 'disconnected' } with no
error object on connection loss, so requiring status.error meant the event
never fired there (the connection-lost modal showed but nothing tracked).
Record on any non-limit 'disconnected' status regardless of an error field,
and guard against the 'disconnected' a provider emits during a clean
teardown (navigation / switching posts) so it is not counted as an error.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes # N/A
Proposed changes
jetpack_rtc_connection_errorTracks event, recorded the first time a client loses its real-time-collaboration sync connection (genuine, non-limit) in the WordPress.com block editor.connection-limit-exceededcode /isRoomLimitBreached()) — it is already reported asjetpack_rtc_blocked, so recording it here too would double-count.sync.providersfilter at priority 30 (outside the room-limit wrapper at priority 20) and subscribe to the provider'sstatusevents, mirroring the existingwithJoinTrackingwrapper.Why the provider status, not the error modal
The connection-error modal is shown via a Gutenberg filter whose API has changed across versions — the original
editor.SyncConnectionErrorModalcomponent filter (#76554) was replaced by theeditor.isSyncConnectionErrorHandledvalue filter (#76853), and the component variant is additionally gated behindIS_GUTENBERG_PLUGIN(a no-op in production builds). The providerstatusis the transport-agnostic source of truth that drives that modal, so hooking it works regardless of which Gutenberg the site runs.Notes on the implementation:
{ status: 'disconnected' }with noerrorobject, so anerroris not required to record.error_codeis included only when the transport supplies one (e.g.authentication-failed,protocol-mismatch);recordRtcEventdrops it when absent.disconnected; atearingDownguard set in the wrapper'sdestroy()keeps that from counting as an error.disconnectedevents), ignores collection rooms (objectId === null), and runs on every RTC site regardless of the limit-notices feature flag — matching the room-limit and join-tracking wrappers.recordRtcEvent, sotransport,post_id,post_type, andwp_user_idcome from the server-injectedwindow.jetpackRtcNoticesconfig wired up in RTC: add jetpack_rtc_blocked Tracks event #49579 — no PHP changes needed.Third of the RTC Tracks PRs. PR 1 (#49559) added
jetpack_rtc_join; PR 2 (#49579) addedjetpack_rtc_blocked. A final PR will remove the inaccurate PingHub-onlyroom_peerspixel()telemetry these events replace (the existinglogConnectionEvent()connection logging stays).Related product discussion/links
Does this pull request change what data or activity we track or use?
Yes — this PR adds a new Tracks event. Adding the "[Status] Needs Privacy Updates" label.
The
jetpack_rtc_connection_errorevent is recorded in the WordPress.com block editor when a logged-in user editing a post loses the real-time-collaboration sync connection for a genuine (non-limit) reason. The per-room contributor-limit disconnection is deliberately excluded (reported separately asjetpack_rtc_blocked). Properties:transport—pinghuborhttp-pollingpost_id,post_type— the post being editedwp_user_id— the WordPress user id of the affected user (site-local id; equals the WordPress.com id on Simple sites)error_code— the syncConnectionErrorCodewhen the transport supplies one (e.g.authentication-failed,connection-expired,protocol-mismatch,unknown-error); omitted for a bare disconnect (e.g. PingHub);connection-limit-exceededis never recorded hereblog_idis attached automatically by the analytics library. No new persistent storage is introduced; the event is sent to Tracks. Purpose: measure how often RTC connections fail for genuine (non-limit) reasons.Testing instructions
Unit tests:
cd projects/packages/rtc && pnpm test— all suites should pass (39 tests).Functional (requires a WordPress.com environment with RTC enabled; depends on wpcom Tracks + RTC infrastructure):
POST /wpcom/v2/rtc/pinghub-tokenrequest (PingHub) or the polling endpoint — so the editor surfaces the "Connection lost" modal.jetpack_rtc_connection_errorTracks beacon fires (filter the Network tab forpixel.wp.com) withtransport,post_id,post_type,wp_user_id, and — when the transport provides one — anerror_codethat is notconnection-limit-exceeded.jetpack_rtc_blockedand notjetpack_rtc_connection_error.