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

Update/my jetpack status handling #37217

Merged
merged 24 commits into from
May 22, 2024
Merged

Conversation

jboland88
Copy link
Contributor

@jboland88 jboland88 commented May 3, 2024

Proposed changes:

  • This diff updates how the active and inactive statuses are handled for products in My Jetpack
  • More granular checks for paid plans and free offerings are introduced
  • has_required_plan function has been removed in favor of has_paid_plan_for_product, has_free_plan_for_product and has_any_plan_for_product
  • Separate connection statuses are established for site and user connections

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)?

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

No

Testing instructions:

  • Using the Jetpack Beta plugin, apply this PR on a brand new Jetpack site that has the main Jetpack plugin.

  • Before connecting the site, visit My Jetpack. Confirm that all the product cards are showing as "inactive". This should be true since the site has never been connected before.
    Screenshot 2024-05-14 at 5 53 26 PM

  • Now, connect the site

  • Return to My Jetpack. Now, any feature that is contained within the main Jetpack plugin (Creator, Stats) will show as "Active". AI will show as "Needs Sign in". Akismet may be active as well depending on your test site and if an API key has been added for Akismet.
    Screenshot 2024-05-14 at 5 54 11 PM

  • If you connect your user account, the AI product should show as "Active" as well.
    Screenshot 2024-05-14 at 5 54 50 PM

  • If you disconnect Jetpack, all products that were active before will now show "Needs Connection"
    Screenshot 2024-05-14 at 5 55 56 PM

  • Test purchasing and activating other products to make sure that the active/inactive statuses make sense


  • Now, spin up a new test site, but this time, only install the Jetpack Social Standalone plugin (and the beta testing plugin of course)
  • With this PR applied via the Beta Plugin, Jetpack social should show as inactive before the site is connected
    Screenshot 2024-05-15 at 3 11 06 PM
  • If you connect the site but not the user, Social should show as "needs sign-in"
    Screenshot 2024-05-15 at 3 11 26 PM
  • After the site is connected, Jetpack social should show as "active"
    Screenshot 2024-05-15 at 3 12 00 PM

Copy link
Contributor

github-actions bot commented May 3, 2024

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.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


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 June 4, 2024 (scheduled code freeze on June 3, 2024).

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


Backup plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Boost plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Search plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Social plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Starter Plugin plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Protect plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Videopress plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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


Migration plugin:

  • Next scheduled release: June 4, 2024.
  • Scheduled code freeze: May 27, 2024.

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

Copy link
Contributor

github-actions bot commented May 3, 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/my-jetpack-status-handling branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/my-jetpack-status-handling
    

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

@github-actions github-actions bot added [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Migration [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. labels May 14, 2024
@jboland88 jboland88 marked this pull request as ready for review May 14, 2024 21:56
Copy link
Contributor

@robertsreberski robertsreberski left a comment

Choose a reason for hiding this comment

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

The change feels very good 😌 tests without issues, was trying to activate different plugins - all works according to the test plan!

"Inactive" sounds a bit vague, and can hint as plugin being not activated in WordPress (e.g. if you install & activate Jetpack Backup but don't purchase the subscription). No matter the wording, everything seems more consistent than it was before - and that's the point of this PR.

Copy link
Contributor

@CodeyGuyDylan CodeyGuyDylan left a comment

Choose a reason for hiding this comment

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

When the Search standalone plugin is installed with or without the Jetpack plugin and whether or not the user is connected, when I go to My Jetpack, I get a blank screen with an error trying to read properties of null

image

This does not happen with any other standalone plugins, and I did confirm this only happens on this branch

Overall I really like the goal of this PR, the statuses seem to make a lot more sense than they used to and more consistent as well

size: 'small',
variant: 'primary',
weight: 'regular',
label: __( 'Sign In', 'jetpack-my-jetpack' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the wording of "Sign In" much more, but I noticed we've never really called in a sign-in anywhere else

In the connection footer we just call it "Connect"
image

and on the connection screen we say "Connect your user account"
image

on the auth screen if we are already logged in we just say "Approve"
image

and on the login screen we call it "log in" not "sign in"
image

and when connected, in the connection footer we say "Connected as" not "signed in as"
image

Overall it seems like we lack consistency in what we call a user connection on the frontend, and I don't think we'll fix that here, but we might want to go with one of the existing names for it rather than introducing yet another name for it, even though I do like "Sign in" much more than a lot of the others as far as clarity. Maybe we could just have it as "Connect" (since that's most of our messaging around it in My Jetpack) or "Log In" (since we use that on the actual auth screen when logging in)

I may be putting too much thought into this, let me know what you think!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the wording of "Sign In" much more, but I noticed we've never really called in a sign-in anywhere else

Good call - this is probably not the diff to change that in :) I'll update that to use the "connect" and "needs user connection" language.

} else {
}
// Check specifically for inactive modules, which will prevent a product from being active
} elseif ( property_exists( static::class, 'module_name' ) && static::$module_name && ! static::is_module_active() ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you have a few PHP errors here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oopsie :) Thanks.

Comment on lines 467 to 470
$status = 'needs_purchase_or_free';
if ( ! static::$has_free_offering ) {
$status = 'needs_purchase';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: This could be shortened to this

Suggested change
$status = 'needs_purchase_or_free';
if ( ! static::$has_free_offering ) {
$status = 'needs_purchase';
}
$status = static::$has_free_offering ? 'needs_purchase_or_free' : 'needs_purchase';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice optimization 👍

Comment on lines 473 to 477
if ( ! \Jetpack_Options::get_option( 'id' ) ) {
$status = 'needs_first_site_connection';
} else {
$status = 'site_connection_error';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this exact conditional above in the previous if statement. Not sure its necessary since it's only used twice but we could potentially introduce some reusable variable or function for this check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might not be needed at this point - I think I'll leave these duplicated instances for now. Thanks for the suggestion though!

*/
public static function has_required_plan() {
$search_state = static::get_state_from_wpcom();
return ! empty( $search_state->supports_search ) || ! empty( $search_state->supports_instant_search );
Copy link
Contributor

Choose a reason for hiding this comment

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

I see in this PR you're removing these different kind of ways to determine if a site has a required plan to run these products. Are there any instances where, in this case Jetpack Search, would be running without any sort of plan, Free or paid? Or below for VideoPress, would there be any instances where the site does have the feature VideoPress but does not have a plan for it? Just making sure we don't break the functionality in certain situations that we may be only vaguely familiar with

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great question, my goal was to cover those scenarios with the $requires_plan property on the product object. This would indicate if the product needed a plan (free or paid) to run or if it could run in some form with just a plugin installed. $requires_plan is used in the main is_active check on the base product class.

Does this cover the cases you were thinking of?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this does make sense to me, and from all my testing everything mostly makes sense to me 😄

@jboland88
Copy link
Contributor Author

When the Search standalone plugin is installed with or without the Jetpack plugin and whether or not the user is connected, when I go to My Jetpack, I get a blank screen with an error trying to read properties of null

Ahh, good catch. There was an inconsistency in the status slug.
Thanks for the feedback!

CodeyGuyDylan
CodeyGuyDylan previously approved these changes May 22, 2024
Copy link
Contributor

@CodeyGuyDylan CodeyGuyDylan left a comment

Choose a reason for hiding this comment

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

This all looks good to me now. I ran through many different scenarios in my testing and didn't see any glaring issues. It's a shame that Search needs a "Free plan" to run because if it weren't for that, we wouldn't have to have a user connection in order to have it Active here

*/
public static function has_required_plan() {
$search_state = static::get_state_from_wpcom();
return ! empty( $search_state->supports_search ) || ! empty( $search_state->supports_instant_search );
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this does make sense to me, and from all my testing everything mostly makes sense to me 😄

@jboland88 jboland88 merged commit ad40b62 into trunk May 22, 2024
70 checks passed
@jboland88 jboland88 deleted the update/my-jetpack-status-handling branch May 22, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] My Jetpack [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Migration [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants