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

Newsletter imports: Handle errors correctly #99162

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

Conversation

spsiddarthan
Copy link
Contributor

Manual imports and CSV imports error handling is incorrect, the UI always assumes the imports are successful. This PR adds error handling for imports

Proposed Changes

  • Added the useImportError hook to see if the API call to import subscribers returns an error.

Why are these changes being made?

  • To handle the errors from the endpoint that handles subscriber imports.

Testing Instructions

Happy Case

  • On a free account with no subscribers, ensure you're able to add a subscriber manually and with a CSV file of 5 emails. You can ask Chatgpt to generate a csv of emails specyfing the format of the email.
  • On a paid account, ensure you're able to add a subscriber manually and with a CSV file of 100+ emails.

Testing this bug

  • Cancel the subscription on your paid account from payments admin where you have 100+ subscribers, and try adding a subscriber manually. You should the error being shown in a notice.
  • Try importing a CSV file. You will see the error being shown in a notice.
Screenshot 2025-01-31 at 6 25 55 PM

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@matticbot
Copy link
Contributor

matticbot commented Jan 31, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~68 bytes added 📈 [gzipped])

name         parsed_size           gzip_size
subscribers       +312 B  (+0.0%)      +68 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~34 bytes added 📈 [gzipped])

name                                                 parsed_size           gzip_size
async-load-calypso-my-sites-stats-pages-subscribers       +171 B  (+0.1%)      +34 B  (+0.1%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@spsiddarthan spsiddarthan changed the title Newsleterr imports: Handle errors correctly Newsletter imports: Handle errors correctly Jan 31, 2025
@matticbot
Copy link
Contributor

matticbot commented Jan 31, 2025

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug add/error-handling on your sandbox.

@spsiddarthan spsiddarthan requested a review from a team January 31, 2025 14:47
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 31, 2025
@allilevine
Copy link
Member

Hey @spsiddarthan do you mind if I merge #98562? There might be some conflicts.

@spsiddarthan
Copy link
Contributor Author

Of course - feel free to merge that PR. Thanks for checking in, @allilevine. And going forward with other PRs as well, feel free to merge, I will happy to rebase my PRs whenever I begin work the next day :)

Copy link
Member

@allilevine allilevine left a comment

Choose a reason for hiding this comment

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

I rebased and tested (thanks for the CSV tip!) and this is working well. Can we also change the message on the back-end (fbhepr%2Skers%2Sjcpbz%2Sjc%2Qpbagrag%2Serfg%2Qncv%2Qcyhtvaf%2Sraqcbvagf%2Sfhofpevoref.cuc%3Se%3Q604q8o54%231072-og)? It has a typo and it's not very informative. Here's the message for the same error in the Substack importer:

Screen Shot 2025-01-31 at 1 57 27 PM

Something like this? "You've reached the 100-email limit on our free plan, so we couldn't import your subscriber list. Upgrade to any paid plan to upload without limits."

Also, what do you think of leaving the notification in place until the user dismisses it? A link to upgrade would also be great, but I'm not sure if we can pass one to a notice. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants