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

Syncing audiences and custom dimensions in parallel can result in the cached audiences not being persisted #8888

Open
1 task
techanvil opened this issue Jun 17, 2024 · 1 comment
Labels
Module: Analytics Google Analytics module related issues P2 Low priority Team M Issues for Squad 2 Type: Bug Something isn't working

Comments

@techanvil
Copy link
Collaborator

techanvil commented Jun 17, 2024

Bug Description

When making parallel requests to sync both audiences and custom dimensions (POST:sync-audiences and POST:sync-custom-dimensions), it can result in the cached audiences not being persisted. It seems the call to sync-audiences saves the audiences, but the parallel call to sync-custom-dimensions then deletes them.

Steps to reproduce

Here is a straightforward way to exhibit the bug. Please note this was discovered during development of #8160 and so these instructions will only work once that issue's PR is merged (or by checking out the branch for the PR, see #8885).

  1. Set up Site Kit with the audienceSegmentation feature flag enabled, and connect an Analytics property which has some data.
  2. Set up Key Metrics, selecting a metric which depends on a custom dimension.
  3. Click Enable groups on the Audience Segmentation Setup CTA Banner to set up the feature.
  4. Once the dashboard has loaded, use the WP CLI to delete the availableAudiences and availableCustomDimensions settings.
wp option patch delete googlesitekit_analytics-4_settings availableAudiences
wp option patch delete googlesitekit_analytics-4_settings availableCustomDimensions
  1. Reload the dashboard. You should see requests in the network tab being made to the POST:sync-audiences and POST:sync-custom-dimensions endpoints. If the property has got the new/returning visitor audiences set up with data, you may also see a couple of failed requests to the save-resource-data-availability-date endpoint (see screenshot below). Once this bug is fixed these requests should not fail. Note that the bug doesn't occur every time - if you see these calls to save-resource-data-availability-date succeed, try again from point 3.
  2. Query the Analytics settings via the WP CLI. You should see availableAudiences is NULL or empty, rather than being an array of audiences as expected. Again, the bug doesn't occur every time so if you do see an array of audiences, try again from point 3.
# Retrieve all settings.
wp option get googlesitekit_analytics-4_settings

# Retrieve the individual `availableAudiences` setting.
wp option pluck googlesitekit_analytics-4_settings availableAudiences

Screenshots

image

Actual:
image

Expected:
image

Additional Context

  • PHP Version: any
  • OS: any
  • Browser: any
  • Plugin Version: pre-release 1.130.0
  • Device: any

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

Acceptance criteria

  • Parallel requests to POST:sync-audiences and POST:sync-custom-dimensions should not interfere with each other.
  • Specifically, cached audiences should not be deleted by a parallel call to sync-custom-dimensions.
  • It should be ensured the reverse can't happen too, i.e. the available custom dimensions can't be deleted by a parallel call to sync-audiences with different timing.

Implementation Brief

Test Coverage

QA Brief

Changelog entry

@techanvil techanvil added Module: Analytics Google Analytics module related issues P1 Medium priority Type: Bug Something isn't working labels Jun 17, 2024
@benbowler benbowler added the Team M Issues for Squad 2 label Jun 18, 2024
@techanvil techanvil added P2 Low priority and removed P1 Medium priority labels Jun 26, 2024
@techanvil
Copy link
Collaborator Author

Moved to Backlog until we get all the P1 issues done and/or the initial release out.

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 P2 Low priority Team M Issues for Squad 2 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants