question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add selectors for centralized support links

See original GitHub issue

Feature 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_Proxy class should have a new constant SUPPORT_LINK_URI with /support/ value.
  • The _googlesitekitBaseData global object should include the new proxySupportLinkURL property that contains an URL of the support link endpoint on the proxy side.
  • The core/site datastore should be updated as following:
    • The info partial datastore should be extended to include the new getProxySupportLinkURL selector that returns the proxySupportLinkURL from the _googlesitekitBaseData global object.
    • The urls partial datastore should be extended to include new getDocumentationLinkURL( slug ) and getErrorTroubleshootingLinkURL( error ) selectors.
      • The getDocumentationLinkURL( slug ) selector should return support link URL returned from the getProxySupportLinkURL selector with doc={ slug } query parameter.
      • The getErrorTroubleshootingLinkURL( error ) selector should also return support link URL returned from the getProxySupportLinkURL selector with error_id={ error.id || error.code } query parameter if the error has either id or code properties with non-numeric value (in other words it should be textual slug, not a number). Otherwise the link URL should have error={ error.message } parameter.

Implementation Brief

  • In includes/Core/Authentication/Google_Proxy.php:

    • Add a constant SUPPORT_LINK_URI with the value /support.
  • In includes/Core/Authentication/Authentication.php:

    • Create a private method get_proxy_support_link_url.
    • Return the composed URL using the url method from the Google_Proxy class and pass the SUPPORT_LINK_URI as an argument.
    • In the inline_js_base_data method:
      • Add the proxySupportLinkURL property with an empty string as the value,
      • Within the $this->credentials->using_proxy() condition, add the proxySupportLinkURL property that should obtain the value from the get_proxy_support_link_url method.
  • In assets/js/googlesitekit/datastore/site/info.js:

    • Destructure the proxySupportLinkURL property from global._googlesitekitBaseData.
    • Pass proxySupportLinkURL to the receiveSiteInfo action.
    • In the RECEIVE_SITE_INFO reducer, get the proxySupportLinkURL from the payload and return it within the siteInfo object.
    • Add getProxySupportLinkURL selector that calls the getSiteInfoProperty helper function by passing the proxySupportLinkURL as an argument.
  • In assets/js/googlesitekit/datastore/site/urls.js:

    • Add getDocumentationLinkURL selector that receives slug as a required parameter.
    • Get the proxySupportLinkURL from getProxySupportLinkURL selector.
    • Return the URL string by concatenating the proxySupportLinkURL and ?doc={slug}.
    • Add getErrorTroubleshootingLinkURL selector that receives error object as a required parameter.
    • Get the proxySupportLinkURL from getProxySupportLinkURL selector.
    • Check if the error object’s id OR code property is a non-numeric text value.
    • Return the URL string by concatenating the proxySupportLinkURL with the appropriate ?error_id={error.id} OR ?error_id={error.code}.
    • Otherwise, return the URL string by concatenating the proxySupportLinkURL and ?error={error.message}.

Test Coverage

  • Add tests for the new selectors getProxySupportLinkURL, getDocumentationLinkURL, and getErrorTroubleshootingLinkURL.

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' }) and googlesitekit.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:closed
  • Created a year ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
felixarntzcommented, Jul 6, 2022

@eugene-manuilov Please keep in mind to update the ACs here to use error_id based on the service code updates. cc @hussain-t

1reaction
eugene-manuilovcommented, Jul 26, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complex CSS selector for parent of active child - Stack Overflow
A more advanced selector scheme (such as XPath) would enable more sophisticated stylesheets. However, the major reasons for the CSS Working Group rejecting ......
Read more >
How can CSS attribute selectors be used for web scraping?
To use custom selectors you will need to edit the selector data model (we'll get to that in a second). add multipile custom...
Read more >
CSS selectors - CSS: Cascading Style Sheets - MDN Web Docs
The , selector is a grouping method that selects all the matching nodes. Syntax: A, B. Example: div, span will match both <span>...
Read more >
CSS selectors - Learn web development | MDN
In CSS, selectors are defined in the CSS Selectors specification; like any other part of CSS they need to have support in browsers...
Read more >
CSS Selectors: Should You Optimize Them To Perform Better?
I had originally intended on adding a link or two about selector efficiency in one of the posts, but completely forgot.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found