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

AI Logo Generator: fix upgrade links #38598

Merged
merged 7 commits into from
Jul 30, 2024

Conversation

lhkowalski
Copy link
Contributor

@lhkowalski lhkowalski commented Jul 29, 2024

Fixes #38596.

Proposed changes:

  • Fix the internal useCheckout hook to work for any site type
  • Update the Generator Modal compoment to use the hook instead of try to build the URL on its own
  • Note: there is a refactoring opportunity here to use the useAICheckout hook already used by some of the other AI tools, but this will demand moving it to the ai-client package, updating the imports over the code and then reusing it here, what is a big change; I added a draft task for it, so we can tackle it when we see this tool gaining traction

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:

There are 4 scenarios to test here:

  • The site has a free plan
  • The site has a paid plan and does not have enough requests to generate logos, with two options:
    • it has a logo history
    • it does not have a logo history
  • The site has a paid plan and has enough requests to generate logos
    • having a logo history does not matter in this case

We need to simulate the scenarios and the best way to do it is using the backend filters that change the active tier of a site; the snippets for the test scenarios are provided at the end of the testing instructions

For any scenario:

  • the upgrade link on Jetpack sites points to the product interstitial
  • the upgrade link on Simple sites points to the checkout page

So it is important to test it on a Jetpack site and a Simple site.

Expected behavior on the free plan:

  • set your site to simulate the free plan
  • go to the block editor, add a site logo block and click the AI extension button
  • an alert message will show up
  • the upgrade button should point to the right page depending on the site type (see above) and should open on a new tab
Screenshot 2024-07-29 at 15 55 26

Expected behavior on the paid plan with enough requests:

  • set your site to simulate a paid plan plan with enough requests
  • go to the block editor, add a site logo block and click the AI extension button
  • the tool should show up correctly (maybe it will generate the first logo if that is the first time you open it)
  • only a small upgrade link should be visible under the prompt field, it should point to the right page and should open on a new tab
Screenshot 2024-07-29 at 15 56 58

Expected behavior on the paid plan without enough requests and with a logo history

  • set your site to simulate a paid plan plan without enough requests
  • go to the block editor, add a site logo block and click the AI extension button
  • the tool should show up correctly, showing you logo history
  • you should see the upgrade nudge under the prompt field, it should point to the right page and should open on a new tab
Screenshot 2024-07-29 at 15 58 15

Expected behavior on the paid plan without enough requests and without a logo history

  • set your site to simulate a paid plan plan without enough requests
  • clean the logo generation history by deleting the logo-history-SITE_ID key on the local storage
  • go to the block editor, add a site logo block and click the AI extension button
  • an alert message will show up, similar to the free one
  • the upgrade button should point to the right page and should open on a new tab
Screenshot 2024-07-29 at 15 59 11

Test it on a Jetpack site and a Simple site.

Simulating the tiers

Use the following snippets on your 0-sandbox.php file to simulate you are using different tiers.

Free plan:

add_filter( 'jetpack_ai_current_period_requests_count', function() { return 0; } );
add_filter( 'jetpack_ai_all_time_requests_count', function() { return 0; } );
add_filter( 'jetpack_ai_tier_licensed_quantity', function() { return 0; } );

Paid plan with enough requests:

add_filter( 'jetpack_ai_current_period_requests_count', function() { return 0; } );
add_filter( 'jetpack_ai_all_time_requests_count', function() { return 0; } );
add_filter( 'jetpack_ai_tier_licensed_quantity', function() { return 100; } );

Paid plan without enough requests:

add_filter( 'jetpack_ai_current_period_requests_count', function() { return 95; } );
add_filter( 'jetpack_ai_all_time_requests_count', function() { return 95; } );
add_filter( 'jetpack_ai_tier_licensed_quantity', function() { return 100; } );

Remember to sandbox the public-api URL on your testing machine.

@lhkowalski lhkowalski requested a review from a team July 29, 2024 18:36
@lhkowalski lhkowalski self-assigned this Jul 29, 2024
Copy link
Contributor

github-actions bot commented Jul 29, 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/ai-logo-generator-fix-upgrade-links branch.

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

    bin/jetpack-downloader test jetpack update/ai-logo-generator-fix-upgrade-links
    

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 the RNA label Jul 29, 2024
Copy link
Contributor

github-actions bot commented Jul 29, 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.


Wpcomsh plugin:

  • Next scheduled release: on demand (usually Mondays if not sooner).

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

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jul 29, 2024
@lhkowalski lhkowalski added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jul 29, 2024
dhasilva
dhasilva previously approved these changes Jul 29, 2024
Copy link
Contributor

@dhasilva dhasilva left a comment

Choose a reason for hiding this comment

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

LGTM, tested on Jetpack and Simple

@lhkowalski lhkowalski merged commit 29b5b82 into trunk Jul 30, 2024
56 checks passed
@lhkowalski lhkowalski deleted the update/ai-logo-generator-fix-upgrade-links branch July 30, 2024 17:22
@github-actions github-actions bot removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI Logo Generator: fix the upgrade links on Jetpack sites
2 participants