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

Plan Checks: store less info locally and simplify logic #38937

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Aug 16, 2024

Proposed changes:

Until now, the jetpack_active_plan option included everything that was retrieved from the API. That made for a really big option, with a lot of data that we do not actually need to use in the codebase today (namely, the available part of the feature list).

With this PR, we remove that array from the data we store in the local option.

Of note, we were using the available part of the feature list in one place: starting in #19762, we introduced logic that would allow us to display an upgrade banner in the block editor, when site owners would try to add a block that was not available with their plan. The banner would tell in what plan the feature was available.
That logic relied on the available array from the jetpack_active_plan option, only to check for eligibility on WoA sites.
Since WoA sites currently include all blocks, we do not currently need to gate access to any blocks on WoA, and thus we can remove that logic.
Some WoA sites, namely eCommerce trial sites, do not support all blocks so we need that logic to remain. We should, however, be able to rely on the get_minimum_plan_for_feature method for WoA sites as well.

Warning

Before we merge this, we want to be absolutely sure available isn't used anywhere.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

See discussion here: p55Cj4-3q6-p2#comment-3642

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Note

I would recommend testing this on all 3 environments: WordPress.com Simple, WoA, and self-hosted.

Since it makes changes to data that is used across the products, I would also recommend diving through the different usages of the Current_Plan class in the monorepo, as well as usages of the jetpack_active_plan option.

  • With different plans, go to Posts > Add New and attempt to insert paid blocks such as the Video block or the Calendly.
    • When your site does not support the block, a banner should be displayed.

Do not attempt to check if a block is available on WoA. We consider that they all are, out of the box. It simplifies a logic, improves performance, and avoids relying on the "available" part of the plan information stored locally in the "jetpack_active_plan" option. This will allow us to remove that part from the local option, since it isn't used elsewhere.

Related conversation: p55Cj4-3q6-p2#comment-3642
Until now, the "jetpack_active_plan" option included everything that was retrieved from the API. That made for a really big option, with a lot of data that we do not actually use in the codebase today (namely, the "available" part of the feature list).

With this commit, we remove that array from the data we store in the local option.

Related conversation: p55Cj4-3q6-p2#comment-3642
@jeherve jeherve added [Focus] Performance [Status] In Progress [Pri] Normal Plans [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Platform] Atomic labels Aug 16, 2024
@jeherve jeherve requested a review from mreishus August 16, 2024 16:45
@jeherve jeherve self-assigned this Aug 16, 2024
Copy link
Contributor

github-actions bot commented Aug 16, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the update/plan-check-storage branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/plan-check-storage
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/plan-check-storage
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for September 3, 2024 (scheduled code freeze on September 2, 2024).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jeherve
Copy link
Member Author

jeherve commented Aug 16, 2024

@sbarbosa I'd like to ask you about the Blaze app. I see we pass this information to be used in the Blaze app:

'features' => array( "$blog_id" => array( 'data' => $this->get_plan_features() ) ),

However, I'm not sure where this is used in the app:
https://github.com/Automattic/wp-calypso/blob/58959def063b17abb107c8d2b3f67465de5130fd/apps/blaze-dashboard/src/app.jsx#L59

Do you rely on features somewhere still? And if so, what part of that array do you use?

It seems that some WoA sites, namely eCommerce trial sites, do not support all blocks so we need to check for that.

Related conversation: p55Cj4-3q6-p2#comment-3667
@sbarbosa
Copy link
Contributor

@jeherve , I checked, and that features list is not used inside the Blaze dashboard. It is there because we based our code on the Stats Admin module (the stats app).

I tested it, and this PR won't affect how Blaze works. We are not actively checking for the features on our page or in the components we use in our module.

But, the sites.features config prop its used on Calypso inside some Jetpack components.
e.g.: BusinessATSwitch | DailyBuckupStatus

It is used in other places, but it's hard to check if a rendered page like Blaze or the stats page uses those components.

Let me tag @kangzj to see if this change may affect the stats app. (That app also passes the list of features to the Calypso app: Code link)

@jeherve
Copy link
Member Author

jeherve commented Aug 16, 2024

Thanks for taking a look!

the sites.features config prop its used on Calypso inside some Jetpack components.
e.g.: BusinessATSwitch | DailyBuckupStatus

This should be fine. We're not making changes to the endpoint, just to the locally stored data.

Let me tag @kangzj to see if this change may affect the stats app. (That app also passes the list of features to the Calypso app: Code link)

That's a good point. I don't see available used anywhere in there, but @kangzj would know best.

@mreishus
Copy link
Contributor

I went looking for places that available features might be used and also found this:

<MyPlanBody
activeFeatures={ activeFeatures }
availableFeatures={ availableFeatures }

But I'm not sure if this would be impacted.

@mreishus
Copy link
Contributor

mreishus commented Aug 16, 2024

I tried this out on an eCommerce trial site (using peapX7-1D4-p2). The videopress block is still restricted, but the message is somewhat awkward:
2024-08-16_14-57

I logged out the $plan and $slug after the Jetpack_Plan::get_minimum_plan_for_feature call and I see:

{"plan":"jetpack_free","slug":"videopress\/video"} 

Not sure what's happening. Maybe the videopress "1 trial video" is involved somehow? Or the "exclude" part of the ecommerce trial is a special case somehow.

For comparison, the message looks like this in prod (although, I could argue this is awkward as well):
2024-08-16_12-01

@jeherve
Copy link
Member Author

jeherve commented Aug 19, 2024

found this:

<MyPlanBody
activeFeatures={ activeFeatures }
availableFeatures={ availableFeatures }

This queries the /features endpoint behind the scenes, so we should be good:

$request = sprintf( '/sites/%d/features', Jetpack_Options::get_option( 'id' ) );

Maybe the videopress "1 trial video" is involved somehow? Or the "exclude" part of the ecommerce trial is a special case somehow.

It must indeed be related to that. The VideoPress block was added as a feature available on free Jetpack plans in #28391 and D98224-code, but I don't know if we were supposed to have a free VideoPress tier on WordPress.com sites.

Right now, on the Jetpack end that plan is supposed to behave like a Business site though:

'ecommerce-trial-bundle-monthly',

@Automattic/jetpack-agora Do y'all know a bit more about this? Should the VideoPress block be available on free Atomic sites like trial eCommerce sites, or sites being migrated? I see some logic was added in D115819-code, but I'm not clear what the behavior is supposed to be for VideoPress and its block?

@CGastrell
Copy link
Contributor

Do y'all know a bit more about this?

Not much, sorry to say.

Should the VideoPress block be available on free Atomic sites like trial eCommerce sites, or sites being migrated? I see some logic was added in D115819-code, but I'm not clear what the behavior is supposed to be for VideoPress and its block?

Off the top of my head, I'd say VideoPress block should be always available and manage its own restrictions for the "1 free upload" tier. That said, I see no reason for VideoPress not to be available on trial eCommerce sites?

For sites being migrated I think the files are likely to be lost in the process (not lost, but remain attached to the old site?), need to confirm this though. Just mentioning it in case it makes it easier for us to make a decision on whether to make it available or not.

@kangzj
Copy link
Contributor

kangzj commented Aug 22, 2024

Sorry for the late response. I looked up the Calypso codebase. It seems there's only one place that references the available key:

https://github.com/Automattic/wp-calypso/blob/e1f240e1fb5a4083592a787b3e6a4f4c9f553692/client/state/selectors/get-plans-for-feature.js#L15

But I don't think Odyssey Stats is using it, so I can confirm removing it won't affect Stats. If Blaze is not using the selector, then I guess it'll be good as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Focus] Performance [Package] Plans Plans [Platform] Atomic [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Status] In Progress [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants