Add selectors for centralized support links
See original GitHub issueFeature Description
For the new Notifications MVP features to be properly implemented, we need a way to get correct support links for different documentation pages and errors that may appear when users operate on the dashboard or settings pages. The new support links use the same centralized endpoint on the proxy service to jump to actual documentation pages, the only difference between documentation and errors links is the name of the parameter that is used to identify a document (doc for the documentation slugs, and error or error_id for errors).
These support links will be used by different components and we need a way to allow components to get support links for different documentation pages and errors. For this purpose we need to create three new selectors in the site datastore: getProxySupportLinkURL(), getDocumentationLinkURL( slug ) and getErrorTroubleshootingLinkURL( error ). The first selector will just return an URL to the proxy support link endpoint. The second and third selectors will use the first one and add the appropriate parameters to the URL and return it.
The proxy support link URL should be composed on the backend and returned as part of the _googlesitekitBaseData global object.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
Google_Proxyclass should have a new constantSUPPORT_LINK_URIwith/support/value. - The
_googlesitekitBaseDataglobal object should include the newproxySupportLinkURLproperty that contains an URL of the support link endpoint on the proxy side. - The
core/sitedatastore should be updated as following:- The
infopartial datastore should be extended to include the newgetProxySupportLinkURLselector that returns theproxySupportLinkURLfrom the_googlesitekitBaseDataglobal object. - The
urlspartial datastore should be extended to include newgetDocumentationLinkURL( slug )andgetErrorTroubleshootingLinkURL( error )selectors.- The
getDocumentationLinkURL( slug )selector should return support link URL returned from thegetProxySupportLinkURLselector withdoc={ slug }query parameter. - The
getErrorTroubleshootingLinkURL( error )selector should also return support link URL returned from thegetProxySupportLinkURLselector witherror_id={ error.id || error.code }query parameter if the error has eitheridorcodeproperties with non-numeric value (in other words it should be textual slug, not a number). Otherwise the link URL should haveerror={ error.message }parameter.
- The
- The
Implementation Brief
-
In
includes/Core/Authentication/Google_Proxy.php:- Add a constant
SUPPORT_LINK_URIwith the value/support.
- Add a constant
-
In
includes/Core/Authentication/Authentication.php:- Create a private method
get_proxy_support_link_url. - Return the composed URL using the
urlmethod from theGoogle_Proxyclass and pass theSUPPORT_LINK_URIas an argument. - In the
inline_js_base_datamethod:- Add the
proxySupportLinkURLproperty with an empty string as the value, - Within the
$this->credentials->using_proxy()condition, add theproxySupportLinkURLproperty that should obtain the value from theget_proxy_support_link_urlmethod.
- Add the
- Create a private method
-
In
assets/js/googlesitekit/datastore/site/info.js:- Destructure the
proxySupportLinkURLproperty fromglobal._googlesitekitBaseData. - Pass
proxySupportLinkURLto thereceiveSiteInfoaction. - In the
RECEIVE_SITE_INFOreducer, get theproxySupportLinkURLfrom the payload and return it within thesiteInfoobject. - Add
getProxySupportLinkURLselector that calls thegetSiteInfoPropertyhelper function by passing theproxySupportLinkURLas an argument.
- Destructure the
-
In
assets/js/googlesitekit/datastore/site/urls.js:- Add
getDocumentationLinkURLselector that receivesslugas a required parameter. - Get the
proxySupportLinkURLfromgetProxySupportLinkURLselector. - Return the URL string by concatenating the
proxySupportLinkURLand?doc={slug}. - Add
getErrorTroubleshootingLinkURLselector that receiveserrorobject as a required parameter. - Get the
proxySupportLinkURLfromgetProxySupportLinkURLselector. - Check if the
errorobject’sidORcodeproperty is a non-numeric text value. - Return the URL string by concatenating the
proxySupportLinkURLwith the appropriate?error_id={error.id}OR?error_id={error.code}. - Otherwise, return the URL string by concatenating the
proxySupportLinkURLand?error={error.message}.
- Add
Test Coverage
- Add tests for the new selectors
getProxySupportLinkURL,getDocumentationLinkURL, andgetErrorTroubleshootingLinkURL.
QA Brief
- Verify that the changes meet AC & IB
- Run unit tests, verify that they all pass, and cover the changes.
- For extra manual testing, call the following selectors in your browser console when observing the dashboard page:
googlesitekit.data.select('core/site').getDocumentationLinkURL('not-enough-traffic')- should return an URL to the support endpoint that redirects you to the correct documentation page.googlesitekit.data.select('core/site').getErrorTroubleshootingLinkURL({id: 'nonce_expired' })andgooglesitekit.data.select('core/site').getErrorTroubleshootingLinkURL({ message: 'Curl error: host timed out.' })- should return URLs to the support endpoint that redirects you to the correct error troubleshooting page.
Changelog entry
- N/A
Issue Analytics
- State:
- Created a year ago
- Comments:12 (3 by maintainers)

Top Related StackOverflow Question
@eugene-manuilov Please keep in mind to update the ACs here to use
error_idbased on the service code updates. cc @hussain-t@mohitwp there is another ticket #5507 that adds the get help link after the retry button. That ticket is not implemented yet, thus it’s a bit early to verify it on the frontend.
I have updated QAB a bit to explain how you can test it manually on your end, see the last section with selectors that you can run in your browser console.