Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"pest_3.7.4","defects":{"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_file":8,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_to_be_array":8},"times":{"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_will_throw_an_exception_if_the_property_id_is_not_set":0.013,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_file":0.026,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_will_throw_an_exception_if_the_credentials_json_does_not_exist":0,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_to_be_array":0.001,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_visitor_and_page_views":0.003,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_visitor_and_page_views_by_date":0.012,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_total_visitor_and_page_views":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_most_visited_pages":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_referrers":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_browsers":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_countries":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_operating_systems":0,"P\\Tests\\OrderByTest::__pest_evaluable_it_should_create_GoogleOrderBy_objects_for_dimensions":0,"P\\Tests\\OrderByTest::__pest_evaluable_it_should_create_GoogleOrderBy_objects_for_metrics":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_can_create_a_period_for_a_given_amount_of_days":0.006,"P\\Tests\\PeriodTest::__pest_evaluable_it_can_create_a_period_for_a_given_amount_of_months":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_can_create_a_period_for_a_given_amount_of_years":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_provides_a_create_method":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_accepts_datetime_immutable_instances":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_will_throw_an_exception_if_the_start_date_comes_after_the_end_date":0,"P\\Tests\\TypeCasterTest::__pest_evaluable_it_should_cast_a_date_to_a_Carbon_object":0,"P\\Tests\\TypeCasterTest::__pest_evaluable_it_should_cast_integers":0,"P\\Tests\\TypeCasterTest::__pest_evaluable_it_should_return_a_string_as_a_default":0}}
{"version":"pest_3.7.4","defects":{"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_file":8,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_to_be_array":8},"times":{"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_will_throw_an_exception_if_the_property_id_is_not_set":0.019,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_file":0.028,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_will_throw_an_exception_if_the_credentials_json_does_not_exist":0,"P\\Tests\\AnalyticsServiceProviderTest::__pest_evaluable_it_allows_credentials_json_to_be_array":0.001,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_visitor_and_page_views":0.002,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_visitor_and_page_views_by_date":0.013,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_total_visitor_and_page_views":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_most_visited_pages":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_referrers":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_browsers":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_countries":0,"P\\Tests\\AnalyticsTest::__pest_evaluable_it_can_fetch_the_top_operating_systems":0,"P\\Tests\\OrderByTest::__pest_evaluable_it_should_create_GoogleOrderBy_objects_for_dimensions":0,"P\\Tests\\OrderByTest::__pest_evaluable_it_should_create_GoogleOrderBy_objects_for_metrics":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_can_create_a_period_for_a_given_amount_of_days":0.005,"P\\Tests\\PeriodTest::__pest_evaluable_it_can_create_a_period_for_a_given_amount_of_months":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_can_create_a_period_for_a_given_amount_of_years":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_provides_a_create_method":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_accepts_datetime_immutable_instances":0,"P\\Tests\\PeriodTest::__pest_evaluable_it_will_throw_an_exception_if_the_start_date_comes_after_the_end_date":0,"P\\Tests\\TypeCasterTest::__pest_evaluable_it_should_cast_a_date_to_a_Carbon_object":0,"P\\Tests\\TypeCasterTest::__pest_evaluable_it_should_cast_integers":0,"P\\Tests\\TypeCasterTest::__pest_evaluable_it_should_return_a_string_as_a_default":0}}
26 changes: 14 additions & 12 deletions src/AnalyticsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
use Google\Analytics\Data\V1beta\Dimension;
use Google\Analytics\Data\V1beta\FilterExpression;
use Google\Analytics\Data\V1beta\Metric;
use Google\Analytics\Data\V1beta\RunRealtimeReportRequest;
use Google\Analytics\Data\V1beta\RunRealtimeReportResponse;
use Google\Analytics\Data\V1beta\RunReportRequest;
use Google\Analytics\Data\V1beta\RunReportResponse;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -43,17 +45,17 @@ public function get(

$response = $this->runReport([
'property' => "properties/{$propertyId}",
'dateRanges' => [
'date_ranges' => [
$period->toDateRange(),
],
'metrics' => $this->getFormattedMetrics($metrics),
'dimensions' => $this->getFormattedDimensions($dimensions),
'limit' => $maxResults,
'offset' => $offset,
'orderBys' => $orderBy,
'dimensionFilter' => $dimensionFilter,
'keepEmptyRows' => $keepEmptyRows,
'metricFilter' => $metricFilter,
'order_bys' => $orderBy,
'dimension_filter' => $dimensionFilter,
'keep_empty_rows' => $keepEmptyRows,
'metric_filter' => $metricFilter,
]);

$result = collect();
Expand Down Expand Up @@ -93,17 +95,17 @@ public function getRealtime(

$response = $this->runRealtimeReport([
'property' => "properties/{$propertyId}",
'dateRanges' => [
'date_ranges' => [
$period->toDateRange(),
],
'metrics' => $this->getFormattedMetrics($metrics),
'dimensions' => $this->getFormattedDimensions($dimensions),
'limit' => $maxResults,
'offset' => $offset,
'orderBys' => $orderBy,
'dimensionFilter' => $dimensionFilter,
'keepEmptyRows' => $keepEmptyRows,
'metricFilter' => $metricFilter,
'order_bys' => $orderBy,
'dimension_filter' => $dimensionFilter,
'keep_empty_rows' => $keepEmptyRows,
'metric_filter' => $metricFilter,
]);

$result = collect();
Expand Down Expand Up @@ -138,7 +140,7 @@ public function runReport(array $request): RunReportResponse
return $this->cache->remember(
$cacheName,
$this->cacheLifeTimeInMinutes,
fn () => $this->service->runReport($request),
fn () => $this->service->runReport(new RunReportRequest($request)),
);
}

Expand All @@ -153,7 +155,7 @@ public function runRealtimeReport(array $request): RunRealtimeReportResponse
return $this->cache->remember(
$cacheName,
$this->cacheLifeTimeInMinutes,
fn () => $this->service->runRealtimeReport($request),
fn () => $this->service->runRealtimeReport(new RunRealtimeReportRequest($request)),
);
}

Expand Down