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

Add-Ons: Round dynamically generated add-on monthly price #95369

Merged
merged 6 commits into from
Oct 15, 2024

Conversation

jeyip
Copy link
Contributor

@jeyip jeyip commented Oct 14, 2024

Related to #95370

Proposed Changes

  • Round dynamically generated monthly price ( something already being done behind-the-scenes with the format currency library )

Why are these changes being made?

Screenshot 2024-10-14 at 5 07 19 PM

Although memoized, it appears that add-on prices are unnecessarily recalculated dozens of
times when invoked as part of the PlansFeaturesMain component.

When we format the cost before displaying it to the end user, the formatting library warns us
that it will round floats and their decimal values for smallest currency unit calculations. Because of the
unnecessary recalculations, this warning is repeated and floods the console.

The ideal answer is to trace the root cause of the recalculations and prevent them, but after
taking a cursory look, it seems as if this will require deeper investigation. Tracking issue for this here #95416

Because we always work with smallest currency units for add-ons, the currency formatter will always round our floats. To address the warnings, we explicitly round add-on monthly price floats ( something that was already happening in the library ) before feeding the formatter our data . This suppresses the warnings.

Testing Instructions

  • Navigate to any page with the plans grid Ex. /start/plans or /plans/{site_slug}

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

@jeyip jeyip self-assigned this Oct 14, 2024
@matticbot
Copy link
Contributor

matticbot commented Oct 14, 2024

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

Sections (~45 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
update-design-flow          +38 B  (+0.0%)      +20 B  (+0.0%)
plugins                     +38 B  (+0.0%)      +20 B  (+0.0%)
plans                       +38 B  (+0.0%)      +20 B  (+0.0%)
link-in-bio-tld-flow        +38 B  (+0.0%)      +20 B  (+0.0%)
jetpack-app                 +38 B  (+0.0%)      +20 B  (+0.0%)
hosting                     +38 B  (+0.0%)      +20 B  (+0.0%)
add-ons                     +38 B  (+0.0%)      +25 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 (~20 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-signup-steps-plans-theme-preselected        +38 B  (+0.0%)      +20 B  (+0.0%)
async-load-signup-steps-plans                          +38 B  (+0.0%)      +20 B  (+0.0%)

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.

@matticbot
Copy link
Contributor

matticbot commented Oct 15, 2024

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

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

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/plans-grid-add-on-currency-formatting-warnings on your sandbox.

@jeyip
Copy link
Contributor Author

jeyip commented Oct 15, 2024

Created a tracking issue to solve the underlying recalculation problem #95416.

@jeyip jeyip merged commit 9c23a17 into trunk Oct 15, 2024
11 checks passed
@jeyip jeyip deleted the fix/plans-grid-add-on-currency-formatting-warnings branch October 15, 2024 23:11
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.

2 participants