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 Site Health section for sitekit created audiences. #8710

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

ankitrox
Copy link
Collaborator

Summary

Addresses issue:

Relevant technical choices

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.

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.

@ankitrox ankitrox marked this pull request as ready for review May 14, 2024 14:18
Copy link

github-actions bot commented May 14, 2024

Build files for 343ce5c are ready:

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

Thanks @ankitrox, this is a good start. I've left a few comments, please take a look.


$debug_fields['analytics_4_site_kit_audience'] = array(
'label' => __( 'Analytics site created audiences', 'google-site-kit' ),
'value' => $site_kit_audiences,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, we missed this when writing the IB, but please can you ensure the comma is translated for the value version of the string? For example:

'value' => empty( $settings['availableCustomDimensions'] )
? __( 'None', 'google-site-kit' )
: join(
/* translators: used between list items, there is a space after the comma */
__( ', ', 'google-site-kit' ),
$settings['availableCustomDimensions']
),
'debug' => empty( $settings['availableCustomDimensions'] )
? 'none'
: join( ', ', $settings['availableCustomDimensions'] ),

includes/Modules/Analytics_4.php Outdated Show resolved Hide resolved
includes/Modules/Analytics_4.php Outdated Show resolved Hide resolved
includes/Modules/Analytics_4.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

Hi @ankitrox, thanks for the update. I've left a few more minor comments, please take a look.

includes/Modules/Analytics_4.php Outdated Show resolved Hide resolved
includes/Modules/Analytics_4.php Outdated Show resolved Hide resolved
Comment on lines 2424 to 2437
$created_audiences = array();

// Ensure that audiences are available, otherwise return an empty array.
if ( empty( $audiences ) || ! is_array( $audiences ) ) {
return $created_audiences;
}

$created_audiences = array_filter( $audiences, fn( $audience ) => ! empty( $audience['audienceType'] ) && ( 'SITE_KIT_AUDIENCE' === $audience['audienceType'] ) );

if ( empty( $created_audiences ) ) {
return array();
}

return wp_list_pluck( $created_audiences, 'displayName' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest a small refactor here, note that wp_list_pluck() will return an empty array when passed one so there's no need for the explicit check:

Suggested change
$created_audiences = array();
// Ensure that audiences are available, otherwise return an empty array.
if ( empty( $audiences ) || ! is_array( $audiences ) ) {
return $created_audiences;
}
$created_audiences = array_filter( $audiences, fn( $audience ) => ! empty( $audience['audienceType'] ) && ( 'SITE_KIT_AUDIENCE' === $audience['audienceType'] ) );
if ( empty( $created_audiences ) ) {
return array();
}
return wp_list_pluck( $created_audiences, 'displayName' );
// Ensure that audiences are available, otherwise return an empty array.
if ( empty( $audiences ) || ! is_array( $audiences ) ) {
return array();
}
$site_kit_audiences = array_filter( $audiences, fn( $audience ) => ! empty( $audience['audienceType'] ) && ( 'SITE_KIT_AUDIENCE' === $audience['audienceType'] ) );
return wp_list_pluck( $site_kit_audiences, 'displayName' );

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

Thanks @ankitrox! There are two more comments to address - one is a new one that I meant to add before, the other is one that was missed from my previous review: #8710 (comment)

includes/Modules/Analytics_4.php Outdated Show resolved Hide resolved
ankitrox and others added 3 commits May 23, 2024 21:46
Co-authored-by: Tom Rees-Herdman <tom.rees-herdman@10up.com>
…ub.com:google/site-kit-wp into enhancement/8181-site-health-created-audiences.
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.

None yet

2 participants