tighten / nova-google-analytics

Google Analytics integration with Laravel Nova
MIT License
165 stars 30 forks source link

exception with new analytics - without data #18

Closed veneliniliev closed 3 years ago

veneliniliev commented 4 years ago

Trying to access array offset on value of type null {"userId":1,"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at /.../vendor/tightenco/nova-google-analytics/src/PageViewsMetric.php:42)

'previous' => $analyticsData->first()['pageViews'],
'result' => $analyticsData->last()['pageViews'],
dajoeberlei commented 4 years ago

same here

dajoeberlei commented 4 years ago

Not 100% if thats it but i think this error is occuring when you just setup your analytics and Spatie's Package retrieves only one or no datasets. The Metrics card then throws the error because it expects to have values which it doesnt have on the first day.

It worked for me on the 2nd Day without changing anything.

if you dd($analyticsData) in a test for this code which is the same in the metric, you'll see that it throws an empty array which is why it cant have the offset. So im not sure if its a mistake in spaties package or if this has another meaning to it. But if you add more days to Period::days(3) it worked randomely, which unfortunately doesnt help for the metrics error ;-)

$analyticsData = app(Analytics::class)
 ->fetchTotalVisitorsAndPageViews(Period::days(1));

 dd($analyticsData)
veneliniliev commented 4 years ago

yes. on 2nd day working perfectly...