theiconic / php-ga-measurement-protocol

Send data to Google Analytics from the server using PHP. Implements GA measurement protocol.
MIT License
655 stars 136 forks source link

Call to undefined function GuzzleHttp\Promise\unwrap() #109

Open sunnysideup opened 1 year ago

sunnysideup commented 1 year ago

I am getting this error.

Call to undefined function GuzzleHttp\Promise\unwrap()

in

TheIconic\Tracking\GoogleAnalytics\Network\HttpClient::__destruct at line 51

This is what I am sending:

            $analytics = new Analytics();
            $analytics->setProtocolVersion('1')
                ->setTrackingId($this->getTrackingID())
                ->setUserId(base64_encode($memberID))
            ;

            $analytics
                ->setTransactionId($orderID) // transaction id. required
                ->setRevenue($total)
                ->setDebug($this->isTestMode())
                ->sendTransaction()
            ;

            $orderItems = $order->OrderItems();
            foreach ($orderItems as $orderItem) {
                $analytics->setTransactionId($orderID)
                    ->setItemName($orderItem->TableTitle()) // required
                    ->setItemPrice($orderItem->CalculatedTotal)
                    ->setItemQuantity($this->negateValue($orderItem->Quantity))
                    ->setDebug($this->isTestMode())
                    ->sendItem()
                ;
            }

Here are some of the packages we use:

guzzlehttp/guzzle                                 7.7.0              Guzzle is a PHP HTTP client library
guzzlehttp/promises                               2.0.0              Guzzle promises library
guzzlehttp/psr7                                   2.5.0              PSR-7 message implementation that also provides common utility methods
http-interop/http-factory-guzzle                  1.2.0              An HTTP Factory using Guzzle PSR7
php-http/promise                                  1.1.0              Promise used for asynchronous HTTP requests
phpspec/prophecy                                  dev-master 84c9814 Highly opinionated mocking framework for PHP 5.3+
spomky-labs/otphp                                 v10.0.3            A PHP library for generating one time passwords according to RFC 4226 (HOTP Algorithm) and the RFC 6238 (TOTP Algorithm) and compatible...
swiftmailer/swiftmailer                           v6.3.0             Swiftmailer, free feature-rich PHP mailer
theiconic/php-ga-measurement-protocol             v2.9.0             Send data to Google Analytics from the server using PHP. This library fully implements GA measurement protocol.
ana-lisboa commented 1 year ago

This is the fix: on TheIconic\Tracking\GoogleAnalytics\Network\HttpClient


use GuzzleHttp\Promise;
// ... 

  /**
     * We have to unwrap and send all promises at the end before analytics objects is destroyed.
     */
    public function __destruct()
    {
        Promise\Utils::unwrap(self::$promises);
        //Promise\unwrap(self::$promises); > deprecated
    }
sakacjakub commented 1 year ago

same error, can you fix this please?

ahmad-gelato commented 1 year ago

Hi We have the exact same issue. When this fix will be released? Thanks

ahmad-gelato commented 1 year ago

This is the fix: on TheIconic\Tracking\GoogleAnalytics\Network\HttpClient

use GuzzleHttp\Promise;
// ... 

  /**
     * We have to unwrap and send all promises at the end before analytics objects is destroyed.
     */
    public function __destruct()
    {
        Promise\Utils::unwrap(self::$promises);
        //Promise\unwrap(self::$promises); > deprecated
    }

Hi We have the exact same issue. When this fix will be released? Thanks