-
Notifications
You must be signed in to change notification settings - Fork 286
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
Create Scheduled_Events_Check
Class
#9130
Comments
✅ AC Looks good, moving to IB, thanks @zutigrm |
IB looks to be okay-ish, but the ticket says that we need to create the |
@eugene-manuilov I can hop in to answer this, the mentioned class is included in the issue, since when we discussed the initial plan of implementation we though of going with one class to handle the logic. But I split this in IB, to propose using single purpose lean classes, to align with the approach of having leaner classes similarly to what @aaemnnosttv used in Remote Features classes recently. We do not mandatorily need to use the |
@zutigrm this LGTM, thanks for adding the line indicating that we do not inherently need to implement the Moving this to EB. |
@mohitwp I updated QAB, to reflect recent change - |
QA Update ✅
|
|
@aaemnnosttv I've created a follow up PR at #9310 which addresses the code inconsistencies from a check vs sync naming point of view. I've also updated both the AC and IB of the issue to correctly reference |
Feature Description
As part of the initial body of work for the ACR epic is the requirement to ascertain which events are detected within a users GA4 report data, in order to understand the metrics we should make available to them. In order to obtain this data, a single
daily
event will be scheduled in response to dashboard use.Said scheduled event will make a request via the GA4 Data API, asking for data over the past 90 days containing either of the supported event metrics:
addToCarts
ecommercePurchases
submit_lead_form
generate_lead
contact
Based on the results of the report response, an applicable array of events present in the users report data over the past 90 days will be stored in the existing GA4 settings option against a
recentEvents
key.The value of this option (obtained from the
recentEvents
key therein) will be used in various areas of the code to determine what we do and do not show to the end user regarding the Analytics Conversion Reporting metrics.See the relevant section of the design document for more information.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
detectedEvents
which will hold array type value is added to the existing Analytics settingsrecentEvents
setting:add_to_cart
purchase
submit_lead_form
generate_lead
contact
Implementation Brief
Note: Even though issue title mentions the creation of a
Scheduled_Events_Check
, the implementation doesn't have to be done via a single class as long as the event is logically and correctly scheduled.Update
includes/Modules/Analytics_4/Settings.php
get_default
method includerecentEvents
key with an empty arrayAdd
includes/Modules/Analytics_4/Conversion_Reporting/Conversion_Reporting_Cron.php
includes/Core/Remote_Features/Remote_Features_Cron.php
wp_schedule_single_event
)DAY_IN_SECONDS
for timeAdd
includes/Modules/Analytics_4/Conversion_Reporting/Conversion_Reporting_Events_Sync.php
Analytics_4
module instances in constructor and assign it to the class propertycheck_for_events
methodget_data
method ofanalytics_4
instance ($this->analytics_4->get_data( 'report', $options )
). Report options should:eventName
fordimensions
arraygmdate( 'Y-m-d' )
forendDate
gmdate( 'Y-m-d', strtotime( '-90 days' ) )
forstartDate
dimensionFilters
foreventName
and useinListFilter
to filter for the event names array listed in the ACrecentEvents
settings key. Results will contain event names that are present under each returneddimensionValues
in resultingrows
propertyAdd
includes/Modules/Analytics_4/Conversion_Reporting/Conversion_Reporting_Provider.php
includes/Core/Remote_Features/Remote_Features_Provider.php
analytics_4
instances inconstructor
, and assign them to the class propertiesConversion_Reporting_Events_Sync
andConversion_Reporting_Cron
classes and forConversion_Reporting_Cron
usecheck_for_events
method fromConversion_Reporting_Events_Sync
as a callback argument.register
method and invokeregister
method ofConversion_Reporting_Cron
instance, and hook into the dashboard screenload-toplevel_page_googlesitekit-dashboard
. As callback invokemaybe_schedule_cron
method fromConversion_Reporting_Cron
class.Update
includes/Modules/Analytics_4.php
- instantiate newConversion_Reporting_Provider
class and invoke it'sregister
method inAnalytics_4::register
ifconversionReporting
feature flag is enabledTest Coverage
Remote_Features_*
classes for ideasQA Brief
conversionReporting
feature flag enabledWP Crontrol
plugin and triggergooglesitekit_cron_conversion_reporting_events
eventawait googlesitekit.api.get('modules', 'analytics-4', 'settings', {}, {useCache: false});
detectedEvents
key in the outputted array, it should contain['purchase', 'submit_lead_form']
as a valuerecentEvents
has empty array[]
as a value['purchase', 'submit_lead_form']
Changelog entry
The text was updated successfully, but these errors were encountered: