In #3820 we introduced infrastructure for informing the user when their network connection is lost including periodic checks to confirm.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
The periodic request to check connectivity should not be called immediately on page load (the page load itself is a signal of connectivity); the first request should happen either in response to a detected change in connectivity or it's normal 2 min interval
The user's session expiring should not be treated as being offline
[ ] Remove the connection-check endpoint definition
[ ] Replace the connection-check request in useMonitorInternetConnection with a request to Site Kit's REST index: google-site-kit/v1/ which is publicly accessible so it won't fail if the user's session expires
Use wp.apiFetch({path: '/google-site-kit/v1/'})
Update assets/js/googlesitekit/api/index.js to expose apiFetch on its export rather than rely on external/shared version
The fetch will throw an error if fetch fails due to no connection with the familiar "You are probably offline" error
[ ] Remove other references to connection-check such as in the list of excludedEndpoints
Test Coverage
Update tests for the hook to reference the change of endpoint
QA Brief
Set up Site Kit
Use network tab of developer tools, or WiFi module, to switch offline
Verify that offline notification is showing, and request to the /google-site-kit/v1/ endpoint is being made
Verify that request to the above endpoint is not made on the page load
Verify that switching back to online the notification disappears
Feature Description
In #3820 we introduced infrastructure for informing the user when their network connection is lost including periodic checks to confirm.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
checkInternetConnection
call from the on mount lifecycle callback https://github.com/google/site-kit-wp/blob/c701f21e8c60bb9ad8a953ea9912523403b727d8/assets/js/hooks/useMonitorInternetConnection.js#L80connection-check
endpoint definitionconnection-check
request inuseMonitorInternetConnection
with a request to Site Kit's REST index:google-site-kit/v1/
which is publicly accessible so it won't fail if the user's session expireswp.apiFetch({path: '/google-site-kit/v1/'})
assets/js/googlesitekit/api/index.js
to exposeapiFetch
on its export rather than rely on external/shared versionconnection-check
such as in the list ofexcludedEndpoints
Test Coverage
QA Brief
offline
/google-site-kit/v1/
endpoint is being madeonline
the notification disappearsChangelog entry