-
Notifications
You must be signed in to change notification settings - Fork 279
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 “partial data” states infrastructure #8141
Comments
AC ✔️ |
I think the file should be renamed to be more generic, something like
The "determining" part is missing in IB. We need to add instructions how to detect and save partial data information for all three matters. |
Thank you @eugene-manuilov for the review!
Correct! I've updated the file name accordingly.
The My thinking here is that something can be in partial data state for a 28-day range, but still can have all the data it needs for a 7-day range and thus not being in partial data. So by saving the first available date for a 90 day report instead, we can recompute the partial data state for all our supported date range. Let me know what you think! |
Hey @kuasha420 @eugene-manuilov, just chipping in here as I had imagined we'd probably want to take the approach of requesting a report with a start date of the property creation time, that way we could get a definitive first-event-date and not keep requesting reports if say a property's events are all prior to the current 90 window. WDYT? |
QA Update ❌Great work, @kuasha420. The functionalities work as expected except for an issue regarding removing the transient when disconnecting Analytics.
|
Excellent catch, thank you @hussain-t! The follow-up PR has been merged and this is now back with you for another QA:Eng round. |
QA Verified ✅
|
Feature Description
Add the full infrastructure for determining and exposing the "partial data" states for audiences, custom dimensions and properties.
See partial data states in the design doc.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Note: the following IB is heavily based on and inspired by Data_Available state for modules and custom dimensions. Any gap in the IB may be filled in by reassessing the implementation and comparing with the aforementioned infrastructure.
PHP
Google\Site_Kit\Modules\Analytics_4\Resource_Data_Availability_Date
.Transients $transients
in the constructor and initialize as a field.VALID_CUSTOM_DIMENSION_SLUGS
andVALID_AUDIENCE_SLUGS
to store valid and allowed custom dimensions and slugs.RESOURCE_TYPE_**
consts for audience, custom dimension and property resources.get_resource_transient_name
takes resource name and resource type parameters and returns the computed transient name. ie.return "googlesitekit_{$resource_type}_{$resource_name}_data_availability_date";
get_resource_dates
should return an associative array of the data availability date of resources. This can be multi dimensional array or the resources can be prefixed with the resource type.get_resource_date
,set_resource_date
,reset_resource_date
etc should be implemented similarly to how it is done onGoogle\Site_Kit\Modules\Analytics_4\Custom_Dimensions_Data_Available
class.Google\Site_Kit\Modules\Analytics_4
class:$resource_data_available_date
field and instantiate it withResource_Data_Availability_Date
in the constructor.POST:save-resource-data-availability-date
inAnalytics_4
module.audience
,customDimension
orproperty
) are valid, and then persist the date values as a timestamp in the DB using the$this->resource_data_available_date->set_resource_date
method.googlesitekit_inline_modules_data
filter in theregister
method.$resource_data_available_date->reset_resource_date()
inon_deactivation
method to reset all persisted dates on module deactivation.$resource_data_available_date->reset_resource_date()
in the$this->get_settings()->on_change()
when property ID or measurement ID is different, similarly to how it's done with$this->custom_dimensions_data_available->reset_data_available()
to reset the persisted dates when analytics property/measurement ID changes.JS
assets/js/modules/analytics-4/datastore/partial-data.js
file.saveResourceDataAvailabilityDate
takes an array of the object{resource name, resource type and date}
and save it to the server using the fetch store.getResourceDataAvailabilityDate(resourceName, resourceTyoe)
: returns the date associated with the given resource if available, otherwise resolves to the first date in the last 90 days that the report data became available using the associated resolver (described below). The 90 days is chosen because that's the longest date range available in Site Kit.is{audience|customDimension|Property}PartialData(resourceName)
:true
when GA4 is in gathering Data state.false
when thedataAvailabilityDate
for the is same or earlier than thestartDate
of currently selected date range.true
. This also handles the case wheredataAvailabilityDate
for a given resource can not be determined due to errors or being in the shared dashboard.getResourceDataAvailabilityDate
:reportArgs
for the given resource.ReportArgs
is similar to one returned bygetSampleReportArgs
fromassets/js/modules/analytics-4/utils/report-args.js
, while the change here being:reportArgs
will includeaudienceResourceName
as an additionaldimension
.date
for property resource, andcustomEvent:${ resourceName }
eventCount
.getDataAvailabilityReportOptions
selector inassets/js/modules/analytics-4/datastore/custom-dimensions-gathering-data.js
andgetSampleReportArgs
inassets/js/modules/analytics-4/datastore/report.js
for more complete example. The implementation can largely be followed.null
and do not persist anything.saveResourceDataAvailabilityDate
and return the date.assets/js/modules/analytics-4/datastore/index.js
.Test Coverage
QA Brief
As discussed in Slack, due to the nature of this issue, QA has to be performed by an engineer.
googlesitekit_post_type
custom dimension.oi.ie
property we use has data for audience.isAudiencePartialData
,isCustomDimensionPartialData
andisPropertyPartialData
and ensure their behavior aligns with the AC.getResourceDataAvailabilityDate
selector and ensures that if the date is resolved, it is being persisted to WP Transients viaPOST:save-resource-data-availability-date
.googlesitekit_**_**__data_availability_date
transients are getting wiped.Changelog entry
The text was updated successfully, but these errors were encountered: