Skip to content

Commit bc79534

Browse files
Fix TypeError in runRealtimeReport after upgrading (#536)
1 parent f63a8e4 commit bc79534

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/AnalyticsClient.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,14 @@ public function getRealtime(
9595

9696
$response = $this->runRealtimeReport([
9797
'property' => "properties/{$propertyId}",
98-
'date_ranges' => [
99-
$period->toDateRange(),
98+
'minute_ranges' => [
99+
$period->toMinuteRange(),
100100
],
101101
'metrics' => $this->getFormattedMetrics($metrics),
102102
'dimensions' => $this->getFormattedDimensions($dimensions),
103103
'limit' => $maxResults,
104-
'offset' => $offset,
105104
'order_bys' => $orderBy,
106105
'dimension_filter' => $dimensionFilter,
107-
'keep_empty_rows' => $keepEmptyRows,
108106
'metric_filter' => $metricFilter,
109107
]);
110108

src/Period.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Carbon\Carbon;
66
use DateTimeInterface;
77
use Google\Analytics\Data\V1beta\DateRange;
8+
use Google\Analytics\Data\V1beta\MinuteRange;
89
use Illuminate\Support\Traits\Macroable;
910
use Spatie\Analytics\Exceptions\InvalidPeriod;
1011

@@ -65,4 +66,11 @@ public function toDateRange(): DateRange
6566
->setStartDate($this->startDate->format('Y-m-d'))
6667
->setEndDate($this->endDate->format('Y-m-d'));
6768
}
69+
70+
public function toMinuteRange(): MinuteRange
71+
{
72+
return (new MinuteRange)
73+
->setStartMinutesAgo($this->endDate->diff($this->startDate)->i)
74+
->setEndMinutesAgo($this->endDate->format('i'));
75+
}
6876
}

0 commit comments

Comments
 (0)