-
Notifications
You must be signed in to change notification settings - Fork 328
Closed
Labels
P0High priorityHigh priorityQA: EngRequires specialized QA by an engineerRequires specialized QA by an engineerTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature
Description
Feature Description
- Improve report request time using the batchRunReports API
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- A new route
GET:batch-reportis implemented which usesbatchRunReportsto batch several requests together
Implementation Brief
- Extract/adapt the
batchRunReportslogic from this PoC - Update
includes/Modules/Analytics_4.php- Include
GET:batch-reportto the list inget_datapoint_definitions- Use
analyticsdataforserviceandtrueforshareable
- Use
- In
create_data_requestmethod:- Add new case for
GET:batch-report- it should expect$data['requests']as an array requestsshould be limited to max 5 items in the array, if more than 5 throw error- Instantiate
Analytics_4_Report_Request- into say$report - Iterate over
$data['requests']and for each request (say$data_request):- Instantiate
Data_Requestfor the report ('GET','modules',$this->slug,'report') and pass current request data as last parameter ($data_request) - Create a report request, eq
$report->create_request(), using$data_requestand$this->is_shared_data_request( $data_request )as parameters - Batch the returned request to an array
- Instantiate
- Instantiate
new Google_Service_AnalyticsData\BatchRunReportsRequest()and push the batched requests array usingsetRequestsmethod ($batch_request->setRequests( $batch_requests )) - Invoke
batchRunReportsvia$this->get_analyticsdata_service()->properties->batchRunReportsand pass property ID and$batch_requestas parameters
- Add new case for
- Include
Test Coverage
- Update
tests/phpunit/integration/Modules/Analytics_4Test.phpto cover new batch request route
QA Brief
QA:Eng
- Connect GA4 module, and edit
Analytics_4.php- withinregistermethod, on the bottom for example, paste this:
$api_configs = array(
array(
'metrics' => array( 'sessions' ),
'dimensions' => array( 'sessionDefaultChannelGroup', 'date' ),
'startDate' => gmdate( 'Y-m-d', strtotime( '-28 days' ) ),
'endDate' => gmdate( 'Y-m-d' ),
'orderBys' => array(
array(
'metric' => array( 'metricName' => 'sessions' ),
'desc' => true,
),
),
'limit' => 3,
),
array(
'metrics' => array( 'activeUsers' ),
'dimensions' => array( 'date', 'newVsReturning' ),
'startDate' => gmdate( 'Y-m-d', strtotime( '-28 days' ) ),
'endDate' => gmdate( 'Y-m-d' ),
'dimensionFilter' => array(
'filter' => array(
'fieldName' => 'newVsReturning',
'stringFilter' => array(
'matchType' => 'EXACT',
'value' => 'returning',
),
),
),
'orderBys' => array(
array(
'dimension' => array( 'dimensionName' => 'date' ),
'desc' => false,
),
),
),
);
$a = $this->get_data( 'batch-report', array(
'requests' => $api_configs,
) );
var_dump( $a );- Verify that request worked and response is output on the dashboard
Changelog entry
- N/A
Metadata
Metadata
Assignees
Labels
P0High priorityHigh priorityQA: EngRequires specialized QA by an engineerRequires specialized QA by an engineerTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature