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

Subscriptions: Add Welcome Overlay behind the feature flag #37372

Merged
merged 26 commits into from
May 17, 2024

Conversation

pkuliga
Copy link
Contributor

@pkuliga pkuliga commented May 14, 2024

Part of #36208

Proposed changes:

This is the first iteration of the Welcome Overlay feature (p1HpG7-so7-p2).

It:

  • opens the Welcome Overlay when a user opens the site home page or front page
  • closes the overlay as soon as the subscription flow starts
  • sets the cookie to prevent the overlay from opening on every page view (expires in 7 days)
  • makes the overlay template editable
Screenshot 2024-05-16 at 16 32 50

The feature is behind the feature flag and if you want to enable it you need to go into your sandbox mu-plugins, and add the following line to your 0-sandbox.php file:

add_filter( 'jetpack_subscribe_overlay_enabled', '__return_true' );

Known issues

There is no way of changing the overlay background color. I'll try to fix in in a follow-up PR.

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

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

Testing instructions:

  1. Test it without the feature flag set and make sure the overlay does not open and there is no suspicious warnings/notices in logs.
  2. Enable the feature flag, visit the site home or front page making sure the overlay works as expected.
  3. Go to /wp-admin/site-editor.php?postType=wp_template_part&postId=visualblocks%2F%2Fjetpack-subscribe-overlay&canvas=edit, edit the overlay content and make sure the changes are visible on the frontend (you'll need to delete the jetpack_post_subscribe_overlay_dismissed cookie to render the overlay again)

Copy link
Contributor

github-actions bot commented May 14, 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/subscribe-welcome-overlay branch.

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

    bin/jetpack-downloader test jetpack update/subscribe-welcome-overlay
    

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 [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels May 14, 2024
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.


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.

@pkuliga pkuliga mentioned this pull request May 14, 2024
13 tasks
public function enqueue_assets() {
if ( $this->should_user_see_overlay() ) {
wp_enqueue_style( 'subscribe-overlay-css', plugins_url( 'subscribe-overlay.css', __FILE__ ), array(), JETPACK__VERSION );
wp_enqueue_script( 'subscribe-overlay-js', plugins_url( 'subscribe-overlay.js', __FILE__ ), array( 'wp-dom-ready' ), JETPACK__VERSION, true );
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we should add the subscriptions module to webpack, build the frontend JS as well and include the JS from jetpack/projects/plugins/jetpack/_inc/build?

Would help with minification and also allow importing from @wordpress/dom-ready directly, and build pipeline "externalizes" WP scripts instead of including them in bundles.

No strong opinion and current way is fine too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like an idea for a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yep sounds good 👍

$template->status = 'publish';
$template->has_theme_file = false;
$template->is_custom = true;
$template->description = __( 'An overlay that shows up when someone visits your site', 'jetpack' );
Copy link
Member

Choose a reason for hiding this comment

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

Is the copy consistent with the toggle setting label from designs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. The toggle label is:

Screenshot 2024-05-15 at 09 49 12

Which IMO is missing the verb, like "Enable" or sth. Now it's a bit mysterious to me, @crisbusquets WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Although I see why it can be helpful, I wouldn't use Enable because then all the toggles will begin the same way, and it'll be repetitive.

Almost none of the Jetpack Settings toggles include a verb, even though all of them are enabling something.

Screenshot 2024-05-16 at 10 52 58

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, what about the template description? It's visible when a user is editing it.

Screenshot 2024-05-16 at 11 01 58

Copy link
Member

Choose a reason for hiding this comment

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

The description needs . at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, the subscribe modal and modal for comments don't have the dot as well. Could add it there as well but it would break translations.

Copy link
Member

@simison simison May 16, 2024

Choose a reason for hiding this comment

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

Translations would continue work — translation team applies "fuzzy" label to strings that change only 1-2 characters, and old translation would continue being used. You can always confirm with them it's the case with this specific string too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, didn't know that, thanks!


Jetpack_Subscribe_Overlay::init();

add_action(
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why we need this action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question! I would also like to know 😄

This is also copy&paste from the Subscribe Modal:

add_action(
'rest_api_switched_to_blog',
function () {
Jetpack_Subscribe_Modal::init();
}
);

@lezama do you remember why we need it for the modal? According to the git blame, you added it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just noticed the Jetpack_Subscription_Modal_On_Comment has it as well.

add_action(
'rest_api_switched_to_blog',
function () {
Jetpack_Subscription_Modal_On_Comment::init();
}
);

Copy link
Contributor

Choose a reason for hiding this comment

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

@lezama do you remember why we need it for the modal? According to the git blame, you added it there.

My guess is that it was there while we had the feature flag: https://github.com/Automattic/jetpack/blame/77189e0a87b3418f2d4d791c1ab83ac7b3f1d4f5/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php

but if we are always calling Jetpack_Subscribe_Overlay::init(); it is probably not needed 🤔

}

function setOverlayDismissedCookie() {
// Expires in 7 days
Copy link
Member

Choose a reason for hiding this comment

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

❤️

@pkuliga pkuliga marked this pull request as ready for review May 16, 2024 13:25
@pkuliga pkuliga requested review from a team, simison, enejb and crisbusquets May 16, 2024 14:28
add_action( 'wp_footer', array( $this, 'add_subscribe_overlay_to_frontend' ) );
}

add_filter( 'get_block_template', array( $this, 'get_block_template_filter' ), 10, 3 );
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be under the feature flag too?

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 think it's safe to leave it as it is. It allows the user to edit an overlay template if he has a link but there is no link to it anywhere.

simison
simison previously approved these changes May 16, 2024
Copy link
Member

@simison simison left a comment

Choose a reason for hiding this comment

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

Code looks good, we can continue iterate and improve behind feature flag.

@simison
Copy link
Member

simison commented May 16, 2024

Looks like there are some build failures for files, so needs looking into.

[plugins/jetpack 37.070] [build-production-client] [css] /home/runner/work/jetpack/jetpack/projects/plugins/jetpack/home/runner/work/jetpack/jetpack/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/subscribe-overlay.css doesn't exist

@pkuliga
Copy link
Contributor Author

pkuliga commented May 16, 2024

Looks like there are some build failures for files, so needs looking into.

Fixed!

@pkuliga pkuliga requested a review from simison May 16, 2024 19:18
@pkuliga pkuliga merged commit a078855 into trunk May 17, 2024
56 checks passed
@pkuliga pkuliga deleted the update/subscribe-welcome-overlay branch May 17, 2024 07:58
@github-actions github-actions bot added this to the jetpack/13.5 milestone May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Comments [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants