public function create($siteId, $userAgent = '', $requestIPAddress = '')
    {
        if (empty($siteId)) {
            throw new \Exception('Cannot create an instance without a site id');
        }

        $cookie = new Cookie();

        $userId = $cookie->getCookie(CookieNames::USER_ID);
        $userId = ! empty($userId) ? $userId : Uuid::v4();

        $payload = new Payload(new Cookie(), $siteId, $userId);

        $requestHeaders = [];

        $browserUserAgent = !empty($userAgent) ? $userAgent : Browser::getUserAgent();
        $browserIPAddress = !empty($requestIPAddress) ? $requestIPAddress : Browser::getRequestIPAddress();

        if (! empty($browserUserAgent)) {
            $requestHeaders['X-Original-User-Agent'] = $browserUserAgent;
        }

        if (! empty($browserIPAddress)) {
            $requestHeaders['X-Original-Request-IP-Address'] = $browserIPAddress;
        }

        $client = new Client([
            'base_uri' => API::ENDPOINT,
            RequestOptions::HEADERS => $requestHeaders,
            RequestOptions::HTTP_ERRORS => false,
            RequestOptions::VERIFY => false
        ]);

        return new Tracker($cookie, $payload, $client);
    }
public function create($siteId, $userAgent = '', $requestIPAddress = '')
    {
        if (empty($siteId)) {
            throw new \Exception('Cannot create an instance without a site id');
        }

        $cookie = new Cookie();

        $userId = $cookie->getCookie(CookieNames::USER_ID);
        $userId = ! empty($userId) ? $userId : Uuid::v4();

        $payload = new Payload(new Cookie(), $siteId, $userId);

        $requestHeaders = [];

        $browserUserAgent = !empty($userAgent) ? $userAgent : Browser::getUserAgent();
        $browserIPAddress = !empty($requestIPAddress) ? $requestIPAddress : Browser::getRequestIPAddress();

        if (! empty($browserUserAgent)) {
            $requestHeaders['X-Original-User-Agent'] = $browserUserAgent;
        }

        if (! empty($browserIPAddress)) {
            $requestHeaders['X-Original-Request-IP-Address'] = $browserIPAddress;
        }

        $client = new Client([
            'base_uri' => API::ENDPOINT,
            RequestOptions::HEADERS => $requestHeaders,
            RequestOptions::HTTP_ERRORS => false,
            RequestOptions::VERIFY => false
        ]);

        return new Tracker($cookie, $payload, $client);
    }
public function create ( $ siteId , $ userAgent = '' , $ requestIPAddress = '' ) { if ( empty ( $ siteId ) ) { throw new \ Exception ( 'Cannot create an instance without a site id' ) ; } $ cookie = new Cookie ( ) ; $ userId = $ cookie -> getCookie ( CookieNames :: USER_ID ) ; $ userId = ! empty ( $ userId ) ? $ userId : Uuid :: v4 ( ) ; $ payload = new Payload ( new Cookie ( ) , $ siteId , $ userId ) ; $ requestHeaders = [ ] ; $ browserUserAgent = ! empty ( $ userAgent ) ? $ userAgent : Browser :: getUserAgent ( ) ; $ browserIPAddress = ! empty ( $ requestIPAddress ) ? $ requestIPAddress : Browser :: getRequestIPAddress ( ) ; if ( ! empty ( $ browserUserAgent ) ) { $ requestHeaders [ 'X-Original-User-Agent' ] = $ browserUserAgent ; } if ( ! empty ( $ browserIPAddress ) ) { $ requestHeaders [ 'X-Original-Request-IP-Address' ] = $ browserIPAddress ; } $ client = new Client ( [ 'base_uri' => API :: ENDPOINT , RequestOptions :: HEADERS => $ requestHeaders , RequestOptions :: HTTP_ERRORS => false , RequestOptions :: VERIFY => false ] ) ; return new Tracker ( $ cookie , $ payload , $ client ) ; }
Creates a Tracker instance

@param string $siteId
@param string $userAgent
@param string $requestIPAddress
@throws \Exception
@return Tracker
Creates a Tracker instance