����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 216.73.216.203 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/public_html/vendor/spatie/laravel-analytics/src/ |
Upload File : |
<?php namespace Spatie\Analytics; use DateTimeInterface; use Google_Service_Analytics; use Illuminate\Contracts\Cache\Repository; class AnalyticsClient { /** @var \Google_Service_Analytics */ protected $service; /** @var \Illuminate\Contracts\Cache\Repository */ protected $cache; /** @var int */ protected $cacheLifeTimeInMinutes = 0; public function __construct(Google_Service_Analytics $service, Repository $cache) { $this->service = $service; $this->cache = $cache; } /** * Set the cache time. * * @param int $cacheLifeTimeInMinutes * * @return self */ public function setCacheLifeTimeInMinutes(int $cacheLifeTimeInMinutes) { $this->cacheLifeTimeInMinutes = $cacheLifeTimeInMinutes * 60; return $this; } /** * Query the Google Analytics Service with given parameters. * * @param string $viewId * @param \DateTimeInterface $startDate * @param \DateTimeInterface $endDate * @param string $metrics * @param array $others * * @return array|null */ public function performQuery(string $viewId, DateTimeInterface $startDate, DateTimeInterface $endDate, string $metrics, array $others = []) { $cacheName = $this->determineCacheName(func_get_args()); if ($this->cacheLifeTimeInMinutes == 0) { $this->cache->forget($cacheName); } return $this->cache->remember($cacheName, $this->cacheLifeTimeInMinutes, function () use ($viewId, $startDate, $endDate, $metrics, $others) { $result = $this->service->data_ga->get( "ga:{$viewId}", $startDate->format('Y-m-d'), $endDate->format('Y-m-d'), $metrics, $others ); while ($nextLink = $result->getNextLink()) { if (isset($others['max-results']) && count($result->rows) >= $others['max-results']) { break; } $options = []; parse_str(substr($nextLink, strpos($nextLink, '?') + 1), $options); $response = $this->service->data_ga->call('get', [$options], 'Google_Service_Analytics_GaData'); if ($response->rows) { $result->rows = array_merge($result->rows, $response->rows); } $result->nextLink = $response->nextLink; } return $result; }); } public function getAnalyticsService(): Google_Service_Analytics { return $this->service; } /* * Determine the cache name for the set of query properties given. */ protected function determineCacheName(array $properties): string { return 'spatie.laravel-analytics.'.md5(serialize($properties)); } }