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

Enhancement/6243 loyal visitors #7126

Merged
merged 15 commits into from
Jun 8, 2023
Merged

Conversation

eugene-manuilov
Copy link
Collaborator

@eugene-manuilov eugene-manuilov commented Jun 2, 2023

Summary

Addresses issue:

Relevant technical choices

  • Updated the MetricTileNumeric component to allow percentage styles.
  • Updated the New Visitors widget to pull report data only when it's needed.
  • Updated VRT images for existing Key Metrics related components to share the same prefix.

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 5.6.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@github-actions

This comment was marked as resolved.

@github-actions
Copy link

github-actions bot commented Jun 2, 2023

Build files for df6558f have been deleted.

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Thanks @eugene-manuilov – this looks good to me, just a few points to consider.

@@ -262,7 +296,7 @@ export const readableLargeNumber = ( number ) => {
* or a currency code.
* @return {string} The formatted number.
*/
export const numFmt = ( number, options = {} ) => {
export function numFmt( number, options = {} ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer this form as well and I'm not sure if there is a better reason for one or the other, but we should add a linting rule for this to avoid various forms throughout.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is no benefits in using arrow functions for top level functions. IMO it just makes it harder to read. Created a ticket to add an eslint rule: #7146

assets/js/util/i18n.js Outdated Show resolved Hide resolved
Comment on lines 44 to 49
select( CORE_USER ).isKeyMetricsWidgetHidden()
);

const dates = useSelect( ( select ) =>
select( CORE_USER ).getDateRangeDates( {
offsetDays: DATE_RANGE_OFFSET,
compare: true,
} )
);
// One combined select hook is used to prevent unnecessary selects
// if the key metrics widget is hidden.
const [ report, loading ] =
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not against doing this kind of thing, but having the condition to return WidgetNull if KMW is hidden is something that each tile will need no? This seems like it would be better handled by an HOC (similar to whenActive for widgets), that way the inner component is never rendered / hooks invoked if the main requirement isn't met. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. Added a new HOC.

// Prevent divide by zero errors.
if ( '0' === previous || 0 === previous || isNaN( previous ) ) {
if ( '0' === previous || 0 === previous || Number.isNaN( previous ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like a good change, however the two are not identical in behavior. This should be covered by our tests but I wanted to highlight this:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN#description

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Great, thanks @eugene-manuilov !

@aaemnnosttv aaemnnosttv merged commit 8fe4cfb into develop Jun 8, 2023
@aaemnnosttv aaemnnosttv deleted the enhancement/6243-loyal-visitors branch June 8, 2023 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants