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

Refactor the Audience Tiles to use new pivot report infrastructure #8726

Open
15 tasks
benbowler opened this issue May 17, 2024 · 4 comments
Open
15 tasks

Refactor the Audience Tiles to use new pivot report infrastructure #8726

benbowler opened this issue May 17, 2024 · 4 comments
Labels
Module: Analytics Google Analytics module related issues Next Up Issues to prioritize for definition P1 Medium priority Squad 2 (Team M) Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@benbowler
Copy link
Collaborator

benbowler commented May 17, 2024

Feature Description

As discussed on Slack, while we are initially implementing the Audience Tiles to use separate, per-audience reports to retrieve the cities and "top content" metrics (one report per audience per metric), we can reduce the number of reports needed by using pivot reports. This will allow us to retrieve metric data for all of the audiences in a single report (i.e., one report per metric).

We should add support for running pivot reports, and refactor the Audience Tiles to use them.

This is not critical to the release and can be done post-launch, hence the P2 priority.

Please also note this comment relating to the AudienceTile and AudienceTiles refactoring: #8484 (comment)

This ticket has been split from #8484, and only concerns updating the Audience Tiles to use the new pivot report infrastructure, which will be completed in that ticket.


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

Acceptance criteria

  • The AudienceTiles component (introduced via Add the Audience Tiles widget (Storybook) #8136) should be refactored to use pivot reports for the "top cities" and "top content" metrics, thus reducing the corresponding request count by a factor of the number of selected audiences.
  • The AudienceTiles and AudienceTile components should be further refactored so the reports that are retrieved in AudienceTiles are passed directly to AudienceTile, and the corresponding data parsing/extraction logic is moved from AudienceTiles to AudienceTile. Hopefully this logic can be simplified in the process.
  • Additionally, refactor the AudienceTile stories to replace the hardwired mock data with generated mock report data.

Implementation Brief

Audience Segmentation Report Updates

  • Update the assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTilesWidget.js component:

    • Update topCitiesReportOptions to the following report structure:
      startDate,
      endDate,
      dimensions: [ { name: 'city' }, { name: 'audienceResourceName' } ],
      dimensionFilters: {
      	audienceResourceName: configuredAudiences,
      },
      metrics: [ { name: 'totalUsers' } ],
      pivots: [
      	{
      		fieldNames: [ 'city' ],
      		orderby: [
      			{ metric: { metricName: 'totalUsers' }, desc: true },
      		],
      		limit: 3,
      	},
      	{
      		fieldNames: [ 'audienceResourceName' ],
      	},
      ],
      
    • Update the topCitiesReport to use the new getPivotReport selector instead of getReportForAllAudiences, passing topCitiesReportOptions as the only prop.
    • Update topContentReportOptions to the following report structure:
      startDate,
      endDate,
      dimensions: [ { name: 'pagePath' }, { name: 'audienceResourceName' } ],
      dimensionFilters: {
      	audienceResourceName: configuredAudiences,
      },
      metrics: [ { name: 'screenPageViews' } ],
      pivots: [
      	{
      		fieldNames: [ 'pagePath' ],
      		orderby: [
      			{ metric: { metricName: 'screenPageViews' }, desc: true },
      		],
      		limit: 3,
      	},
      	{
      		fieldNames: [ 'audienceResourceName' ],
      	},
      ],
      
    • Update the topContentReport to use the new getPivotReport selector instead of getReportForAllAudiences, passing topContentReportOptions as the only prop.
    • Update topContentPageTitlesReportOptions to the following report structure:
      startDate,
      endDate,
      dimensions: [ { name: 'pagePath' }, { name: 'pageTitle' }, { name: 'audienceResourceName' } ],
      dimensionFilters: {
      	audienceResourceName: configuredAudiences,
      },
      metrics: [ { name: 'screenPageViews' } ],
      pivots: [
      	{
      		fieldNames: [ 'pagePath' , 'pageTitle' ],
      		orderby: [
      			{ metric: { metricName: 'screenPageViews' }, desc: true },
      		],
      		limit: 15,
      	},
      	{
      		fieldNames: [ 'audienceResourceName' ],
      	},
      ],
      
    • Update the topContentPageTitlesReport to use the new getPivotReport selector instead of getReportForAllAudiences, passing topContentPageTitlesReportOptions as the only prop.
  • Remove the getReportForAllAudiences selector and all related code/tests.

  • Update assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTiles.js:

AudienceTile Updates

Test Coverage

  • Confirm existing tests pass, along with VRTs.

QA Brief

Changelog entry

@benbowler
Copy link
Collaborator Author

FYI, this ticket was split from #8484 on 17 May 2024. #8484 is a blocker.

@techanvil techanvil added P1 Medium priority Type: Enhancement Improvement of an existing feature Module: Analytics Google Analytics module related issues Squad 2 (Team M) Issues for Squad 2 labels May 17, 2024
@techanvil
Copy link
Collaborator

Hey @benbowler, thanks for drafting this IB. A few points:

  • The first report in AudienceTiles doesn't seem to need the update - it's already being retrieved via getReport() rather than getReportForAllAudiences(), and seems fine as it is AFAICT.
  • The remaining reports should be updated to use the getPivotReport() selector in line with the proposed changes to Add support for GA4 pivot reports #8484, assuming they have been made.
  • The report with options topContentPageTitlesReportOptions should also be covered in the IB (including the refactoring of the restructuring code).
  • A minor point but the report option code blocks are slightly misaligned in places.
  • Another minor one, I think the point in Data Mock Updates about updating "AudienceTile stories to use this new data-mock functionality" should refer to "the new data-mock functionality introduced in Add support for GA4 pivot reports #8484" for the sake of clarity.

@techanvil
Copy link
Collaborator

Thanks for the update @benbowler. It looks like these two points have been missed, though, please can you take a look?

  • The report with options topContentPageTitlesReportOptions should also be covered in the IB (including the refactoring of the restructuring code).
  • A minor point but the report option code blocks are slightly misaligned in places.

@techanvil techanvil assigned benbowler and unassigned techanvil May 30, 2024
@benbowler benbowler assigned techanvil and unassigned benbowler May 30, 2024
@techanvil
Copy link
Collaborator

Thanks Ben! This IB LGTM. ✅

@techanvil techanvil removed their assignment May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Analytics Google Analytics module related issues Next Up Issues to prioritize for definition P1 Medium priority Squad 2 (Team M) Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants