google-cloud-php icon indicating copy to clipboard operation
google-cloud-php copied to clipboard

Google Analytics Data API v1 - GPBDecodeException: Error occurred during parsing: Fail to push limit.

Open Aljnk opened this issue 3 years ago • 1 comments

Can't Migrate to the Google Analytics Data API v1.

  • OS: Linux
  • PHP version: 7.3.28
  • Package name and version: "google/analytics-data": "0.8.2"

My steps

  1. I crate GA4 property.
  2. Activate "Google Analytics Data API" on "Google Cloud Platform"
  3. Create Service account on "Google Cloud Platform"
  4. Generate JSON key
  5. Add Service account email to Google Analitics 4 Property access manager as Viewer
  6. Download Data API v1 (PHP) by composer
  7. Write PHP code:
require '/lib_way/vendor/autoload.php';
use Google\Analytics\Data\V1beta\BetaAnalyticsDataClient;
use Google\Analytics\Data\V1beta\DateRange;
use Google\Analytics\Data\V1beta\Dimension;
use Google\Analytics\Data\V1beta\Metric;

$keyfile=$_SERVER['DOCUMENT_ROOT'].'/GoogleAPI.json';
$client=new BetaAnalyticsDataClient(['credentials'=>$keyfile]);

at this step everything is working. but when I'm tring to make an API call:

$propery_id="3*nums*6";
$response = $client->runReport([
	'property' => 'properties/' . $propery_id,
	'dateRanges' => [new DateRange(['start_date' => '2022-03-31','end_date' => 'today'])],
	'dimensions' => [new Dimension(['name' => 'city'])],
	'metrics' => [new Metric(['name' => 'activeUsers'])]
]);

I recive this error: Fatal error: Uncaught Google\Protobuf\Internal\GPBDecodeException: Error occurred during parsing: Fail to push limit. in .../vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php on line 340

Google\Analytics\Data\V1beta\DateRange->__construct( ) .../ga4_analytics_get_data.php:49 GPBMetadata\Google\Analytics\Data\V1Beta\Data::initOnce( ) .../DateRange.php:71 Google\Protobuf\Internal\DescriptorPool->internalAddGeneratedFile( ) .../Data.php:285 Google\Protobuf\Internal\FileDescriptorSet->mergeFromString( ) .../DescriptorPool.php:61 Google\Protobuf\Internal\FileDescriptorSet->parseFromStream( ) .../Message.php:775 Google\Protobuf\Internal\FileDescriptorSet->parseFieldFromStream( ) .../Message.php:811 Google\Protobuf\Internal\Message::parseFieldFromStreamNoTag( ) .../Message.php:515 Google\Protobuf\Internal\GPBWire::readMessage( ) .../Message.php:435 Google\Protobuf\Internal\CodedInputStream->incrementRecursionDepthAndPushLimit( ) .../GPBWire.php:286 Google\Protobuf\Internal\CodedInputStream->pushLimit( ) .../CodedInputStream.php:363

Tried many other "runReport" parameters - same result

Any information on how to solve it? Thanks.

Aljnk avatar May 04 '22 17:05 Aljnk

@Aljnk (untested) can you try changing to 'date_ranges' from 'dateRanges' in runReport args?

vishwarajanand avatar Aug 31 '22 17:08 vishwarajanand

Closing due to no repro

vishwarajanand avatar May 17 '23 19:05 vishwarajanand