diff --git a/src/AnalyticsClient.php b/src/AnalyticsClient.php index aa29abe..dd69b29 100644 --- a/src/AnalyticsClient.php +++ b/src/AnalyticsClient.php @@ -95,16 +95,14 @@ public function getRealtime( $response = $this->runRealtimeReport([ 'property' => "properties/{$propertyId}", - 'date_ranges' => [ - $period->toDateRange(), + 'minute_ranges' => [ + $period->toMinuteRange(), ], 'metrics' => $this->getFormattedMetrics($metrics), 'dimensions' => $this->getFormattedDimensions($dimensions), 'limit' => $maxResults, - 'offset' => $offset, 'order_bys' => $orderBy, 'dimension_filter' => $dimensionFilter, - 'keep_empty_rows' => $keepEmptyRows, 'metric_filter' => $metricFilter, ]); diff --git a/src/Period.php b/src/Period.php index 990e7f0..bde3aa9 100644 --- a/src/Period.php +++ b/src/Period.php @@ -5,6 +5,7 @@ use Carbon\Carbon; use DateTimeInterface; use Google\Analytics\Data\V1beta\DateRange; +use Google\Analytics\Data\V1beta\MinuteRange; use Illuminate\Support\Traits\Macroable; use Spatie\Analytics\Exceptions\InvalidPeriod; @@ -65,4 +66,11 @@ public function toDateRange(): DateRange ->setStartDate($this->startDate->format('Y-m-d')) ->setEndDate($this->endDate->format('Y-m-d')); } + + public function toMinuteRange(): MinuteRange + { + return (new MinuteRange) + ->setStartMinutesAgo($this->endDate->diff($this->startDate)->i) + ->setEndMinutesAgo($this->endDate->format('i')); + } }