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

Social: Use core endpoint for dismissing notices #34544

Merged
merged 24 commits into from
Jan 17, 2024

Conversation

gmjuhasz
Copy link
Contributor

@gmjuhasz gmjuhasz commented Dec 8, 2023

This change updates our notice dismissal logic, so it uses register_setting and the core endpoint coming with it.
We have to support the deprecated Jetpack endpoint, so I flagged that with the current versions so we can get rid of it 3 versions later.

Proposed changes:

  • Added the handler class + tests
  • Changed the initial states so they use the new getter

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

https://github.com/orgs/Automattic/projects/733/views/2?pane=issue&itemId=46761193

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

No.

Testing instructions:

  • Delete the dismissed_notices with jetpack docker wp option delete jetpack_social_dismissed_notices
  • With auto-conversion being on, create a new post and upload a 10Mb jpg image which should be invalid but convertible. You should see the notice that it will be converted.
  • Click Got it, then refresh the page and select the image again. You should not see the notice anymore

Remove the advanced plan.

  • Go to the editor and dismiss the advancedPlan upgrade nudge
  • Make sure both are stored correctly in the option

jetpack docker wp option get jetpack_social_dismissed_notices
You can also check it from the console: https://developer.wordpress.com/docs/api/console/
Run a query like this with your site ID:
CleanShot 2024-01-09 at 11 37 16 png

@gmjuhasz gmjuhasz requested a review from a team December 8, 2023 14:19
@gmjuhasz gmjuhasz self-assigned this Dec 8, 2023
Copy link
Contributor

github-actions bot commented Dec 8, 2023

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 refactor/social-dismissed-notices-endpoint branch.

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

    bin/jetpack-downloader test jetpack refactor/social-dismissed-notices-endpoint
    

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 [JS Package] Publicize Components [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin [Tests] Includes Tests RNA labels Dec 8, 2023
Copy link
Contributor

github-actions bot commented Dec 8, 2023

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 February 6, 2024 (scheduled code freeze on February 5, 2024).

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


Social plugin:

  • Next scheduled release: February 6, 2024.
  • Scheduled code freeze: January 29, 2024.

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

manzoorwanijk
manzoorwanijk previously approved these changes Dec 13, 2023
Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This works well. I just have some optional code suggestions/questions.

manzoorwanijk
manzoorwanijk previously approved these changes Dec 15, 2023
Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

Thank you for making the suggested changes. This looks good now.

} ) => {
return (
return shouldAutoConvert ? null : (
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for making this change.

Copy link
Member

Choose a reason for hiding this comment

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

This change was cherry picked in #34730 as a quick fix for the issue

manzoorwanijk
manzoorwanijk previously approved these changes Dec 19, 2023
Copy link
Contributor

@spsiddarthan spsiddarthan left a comment

Choose a reason for hiding this comment

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

This tests well, Geri! Requesting @pablinos to glance over it as well to make sure there is nothing glaring.

spsiddarthan
spsiddarthan previously approved these changes Jan 8, 2024
@@ -62,8 +55,8 @@ public function update_dismissed_notices( $updated, $name, $value ) {
return $updated;
}

$notice = $value['notice'];
$reappearance_time = $value['reappearance_time'];
$notice = key( $value );
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I correct in saying that $updated is true or false, $name is the option name and $value is ['instagram' => 0]?

If that's the case, $notice would be instagram .

reappearance_time would be $value['notice'] which is 0.

I am bit confused by this change, could you please elaborate why we would need this?

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!

The first part of the change (f7eb8bc#diff-b9af7ea1c5d7705e15c3aa19241ee6e3f3b8090af8977a9951def8e88907d2d9R31) is to fix the schema, as the previous one would describe our format poorly. We want the option to store an array with key->value pairs, where the key is the name of the notice, and the value is a numeric value, which is the reappearance time.

The second part (f7eb8bc#diff-5f1e74f983a6c97e6afd793e071e2b976f2f14616174253e77739c59e07de12eR63) was to modify the UI to send the data in this format. That means that for Instagram, it would send jerpack_social_dismissed_notices: { Instagram: 0}, which means that we want to update the registered setting jerpack_social_dismissed_notices, with the value of { Instagram: 0}.

The third part of the change is where your comment lies, where value would be as you said, and the notice variable stores the name, and the reappearance_time is the number. Then we add it to the array $dismissed_notices[ $notice ] = $reappearance_time; and update the option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing it with the API console as in the testing instructions should show if it's working well

@gmjuhasz gmjuhasz merged commit 24f1872 into trunk Jan 17, 2024
56 checks passed
@gmjuhasz gmjuhasz deleted the refactor/social-dismissed-notices-endpoint branch January 17, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[JS Package] Publicize Components [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin RNA [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants