Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPCOM: Migrate wpcom.undocumented() site products to wpcom.req #57765

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Nov 8, 2021

Changes proposed in this Pull Request

This PR migrates all the wpcom.undocumented() site products method to wpcom.req.get().

The PR also simplifies the code a little bit - we don't need to encode the site fragment, because anywhere in the code where we're making requests to this endpoint, we pass the numeric site ID. I think there was no reason to have support for anything else than a numeric site ID in the first place TBH (see #40306 and cc @DavidRothstein just in case). We're also removing an unnecessary wrapping Promise - wpcom.req.get() already returns a promise.

Part of the ongoing effort to get rid of wpcom.undocumented().

Testing instructions

  • Go to /plans/:site where :site is one of your Jetpack sites.
  • Verify that the request to /sites/:site/products is still successful.

@tyxla tyxla added [Type] Enhancement Framework [Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. State labels Nov 8, 2021
@tyxla tyxla requested review from DavidRothstein and a team November 8, 2021 15:58
@tyxla tyxla self-assigned this Nov 8, 2021
@github-actions
Copy link

github-actions bot commented Nov 8, 2021

Copy link
Member

@jsnajdr jsnajdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if ( error ) {
debug( 'Fetching site products failed: ', error );
return wpcom.req
.get( `/sites/${ siteId }/products` )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice that because siteId is always a number, we don't need to encodeURIComponent like the original method did.

@tyxla tyxla changed the title WPCOM: Migrate wpcom.undocumented() site products to wpcom.req WPCOM: Migrate wpcom.undocumented() site products to wpcom.req Nov 8, 2021
@matticbot
Copy link
Contributor

matticbot commented Nov 8, 2021

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~19 bytes removed 📉 [gzipped])

name                   parsed_size           gzip_size
entry-main                  -182 B  (-0.0%)      -19 B  (-0.0%)
entry-login                 -182 B  (-0.0%)      -19 B  (-0.0%)
entry-gutenboarding         -182 B  (-0.0%)      -19 B  (-0.0%)
entry-domains-landing       -182 B  (-0.0%)      -19 B  (-0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~11 bytes removed 📉 [gzipped])

name                   parsed_size           gzip_size
plans                        -21 B  (-0.0%)      -11 B  (-0.0%)
jetpack-connect              -21 B  (-0.0%)      -11 B  (-0.0%)
jetpack-cloud-pricing        -21 B  (-0.0%)      -11 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@DavidRothstein
Copy link
Contributor

DavidRothstein commented Nov 9, 2021

I think there was no reason to have support for anything else than a numeric site ID in the first place TBH (see #40306 and cc @DavidRothstein just in case)

I think the only reason I did it was to make this code an exact copy of the equivalent getSitePlans(). But since you're fixing that one in #57766 also, it seems fine to do it here too!

@tyxla tyxla force-pushed the migrate/undocumented-site-products branch from c38895c to c9d9e70 Compare November 9, 2021 10:57
@tyxla tyxla merged commit 3a7f4f9 into trunk Nov 9, 2021
@tyxla tyxla deleted the migrate/undocumented-site-products branch November 9, 2021 11:27
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans. Framework State [Type] Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants