Skip to content

Conversation

@zutigrm
Copy link
Collaborator

@zutigrm zutigrm commented Dec 3, 2025

Summary

Addresses issue:

Relevant technical choices

There were more adaptation and adjustment of the pipeline data than anticipated to render all section parts correctly. PR grew quite big, I also refactored several classes for improvement purposes and to simplify them into more leaner classes where possible. All Search Console metrics have been implemented as part of this PR as well.

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 7.4.
  • 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.
  • Ensure there are no unexpected significant changes to file sizes.

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
Copy link

github-actions bot commented Dec 3, 2025

Build files for 857fa3e have been deleted.

@zutigrm zutigrm changed the base branch from develop to enhancement/11550-finish-email-reporting-template December 4, 2025 23:08
Copy link
Collaborator

@benbowler benbowler left a comment

Choose a reason for hiding this comment

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

Hey @zutigrm, alongside @tofumatt's review, I've reviewed the code and have a few comments inline below to look at.

Also, I noticed that the template preview was broken because of all of the data key/structure changes. Rather than have you get up to speed on the preview setup, I updated this for you and pushed a commit here: 1222b54

I have now tested this with the tester plugin updates as well and we're looking good.

// If no conversion data is present in payload it means user do not have conversion tracking set up
// or no data is received yet and we can skip this section.
if ( empty( $this->payload['total_conversion_events'] ) || ! isset( $this->payload['total_conversion_events'] ) ) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should return an empty array otherwise the array_merge above fails with an error if this data is missing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned by Ben: this needs to return an empty array, not null.

Copy link
Collaborator Author

@zutigrm zutigrm Dec 11, 2025

Choose a reason for hiding this comment

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

There is a check for this section being empty in get_sections, so no error would be raised, but thinking about it not sure why I complicated it with that, since empty array would not require additional guard and is more straightforward

*/
protected function get_growth_drivers_section() {
if ( empty( $this->payload['keywords_ctr_increase'] ) && empty( $this->payload['pages_clicks_increase'] ) ) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should return an empty array otherwise the array_merge above fails with an error if this data is missing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Please address this one too.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as above, no error would be raised, but simplified it with empty array

Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

Overall looks good, just a few return values and small things I noticed, though admittedly it's a big PR to take in 😅

// If no conversion data is present in payload it means user do not have conversion tracking set up
// or no data is received yet and we can skip this section.
if ( empty( $this->payload['total_conversion_events'] ) || ! isset( $this->payload['total_conversion_events'] ) ) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned by Ben: this needs to return an empty array, not null.

*/
protected function get_growth_drivers_section() {
if ( empty( $this->payload['keywords_ctr_increase'] ) && empty( $this->payload['pages_clicks_increase'] ) ) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

(Please address this one too.)

</td>
</tr>
</table>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please keep newlines at the end of files. 🙏🏻

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what is weirder, my VS code stripping last line at random on some files, or linter not detecting it 🤔

Comment on lines 59 to 62
* @param Email_Report_Payload_Processor|null $report_processor Optional. Report processor instance.
* @param Report_Data_Processor|null $data_processor Optional. Analytics data processor.
* @param array $audience_display_map Optional. Audience resource => display name map.
* @param Context|null $context Optional. Plugin context for audience lookup.
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should line up; not sure why the linter doesn't catch it 😢

Suggested change
* @param Email_Report_Payload_Processor|null $report_processor Optional. Report processor instance.
* @param Report_Data_Processor|null $data_processor Optional. Analytics data processor.
* @param array $audience_display_map Optional. Audience resource => display name map.
* @param Context|null $context Optional. Plugin context for audience lookup.
* @param Email_Report_Payload_Processor|null $report_processor Optional. Report processor instance.
* @param Report_Data_Processor|null $data_processor Optional. Analytics data processor.
* @param array $audience_display_map Optional. Audience resource => display name map.
* @param Context|null $context Optional. Plugin context for audience lookup.

Comment on lines 186 to 203
protected function format_value( $value ) {
if ( ! is_numeric( $value ) ) {
return $value;
}

$number = (float) $value;
$abs = abs( $number );

if ( $abs >= 1000000 ) {
return round( $number / 1000000, 1 ) . 'M';
}

if ( $abs >= 1000 ) {
return round( $number / 1000, 1 ) . 'K';
}

return (string) round( $number );
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The rest of the reports are translated/localisation; isn't this a bit English-specific and not properly localised? 🤔

Additionally: what happens if there are billions in the number? 😆

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 catch, I updated this to translatable, and added billions abbreviation

@zutigrm
Copy link
Collaborator Author

zutigrm commented Dec 12, 2025

Thanks @benbowler and @tofumatt PR updated

…errors being thrown and us correct context for admin request mocks.
@tofumatt tofumatt merged commit 1ff5ac0 into develop Dec 15, 2025
21 of 22 checks passed
@tofumatt tofumatt deleted the enhancement/11278-worker-email-sending branch December 15, 2025 17:01
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.

3 participants