-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
Link to Calypso live: https://calypso.live?image=registry.a8c.com/calypso/app:build-18752 |
There was a problem hiding this 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` ) |
There was a problem hiding this comment.
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.
wpcom.undocumented()
site products to wpcom.req
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~19 bytes removed 📉 [gzipped])
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])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
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! |
c38895c
to
c9d9e70
Compare
Changes proposed in this Pull Request
This PR migrates all the
wpcom.undocumented()
site products method towpcom.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
/plans/:site
where:site
is one of your Jetpack sites./sites/:site/products
is still successful.