setAsyncRequest() public méthode

Sets a request to be either synchronous or asynchronous (non-blocking).
public setAsyncRequest ( boolean $isAsyncRequest )
$isAsyncRequest boolean
 /**
  * Initialize Analytics Library with Default Config.
  */
 public function registerAnalytics()
 {
     $this->app->singleton('gamp', function ($app) {
         $config = $app['config'];
         $analytics = new Analytics($config->get('gamp.is_ssl', false));
         $analytics->setProtocolVersion($config->get('gamp.protocol_version', 1))->setTrackingId($config->get('gamp.tracking_id'));
         if ($config->get('gamp.anonymize_ip', false)) {
             $analytics->setAnonymizeIp('1');
         }
         if ($config->get('gamp.async_requests', false)) {
             $analytics->setAsyncRequest(true);
         }
         return $analytics;
     });
 }
 /**
  * Initialize Analytics Library with Default Config.
  */
 public function registerAnalytics()
 {
     $this->app->singleton('gamp', function ($app) {
         $packageNamespace = $this->isLaravel4 ? 'gamp::gamp.' : 'gamp.';
         $config = $app['config'];
         $analytics = new Analytics($config->get($packageNamespace . 'is_ssl', false));
         $analytics->setProtocolVersion($config->get($packageNamespace . 'protocol_version', 1))->setTrackingId($config->get($packageNamespace . 'tracking_id'));
         if ($config->get($packageNamespace . 'anonymize_ip', false)) {
             $analytics->setAnonymizeIp('1');
         }
         if ($config->get($packageNamespace . 'async_requests', false)) {
             $analytics->setAsyncRequest(true);
         }
         return $analytics;
     });
 }
 public function testSendMegaHit()
 {
     $singleParameters = ['v' => (new ProtocolVersion())->setValue('1'), 'tid' => (new TrackingId())->setValue('555'), 'cid' => (new ClientId())->setValue('666'), 't' => (new HitType())->setValue('event'), 'aip' => (new AnonymizeIp())->setValue('1'), 'z' => (new CacheBuster())->setValue('289372387623'), 'ds' => (new DataSource())->setValue('call center'), 'qt' => (new QueueTime())->setValue('560'), 'ni' => (new NonInteractionHit())->setValue('1'), 'dclid' => (new GoogleDisplayAdsId())->setValue('d_click_id'), 'uip' => (new IpOverride())->setValue('202.126.106.175'), 'ti' => (new TransactionId())->setValue('7778922'), 'ta' => (new Affiliation())->setValue('THE ICONIC'), 'tr' => (new Revenue())->setValue(250), 'tt' => (new Tax())->setValue(25), 'ts' => (new Shipping())->setValue(15), 'tcc' => (new CouponCode())->setValue('MY_COUPON'), 'pa' => (new ProductAction())->setValue('purchase')];
     $this->analytics->setAsyncRequest(true)->setProtocolVersion('1')->setTrackingId('555')->setClientId('666')->setAnonymizeIp('1')->setCacheBuster('289372387623')->setDataSource('call center')->setQueueTime('560')->setNonInteractionHit('1')->setGoogleDisplayAdsId('d_click_id')->setIpOverride("202.126.106.175");
     $this->analytics->setTransactionId('7778922')->setAffiliation('THE ICONIC')->setRevenue(250.0)->setTax(25.0)->setShipping(15.0)->setCouponCode('MY_COUPON')->setHitType('event');
     $productData1 = ['sku' => 'AAAA-6666', 'name' => 'Test Product 2', 'brand' => 'Test Brand 2', 'category' => 'Test Category 3/Test Category 4', 'variant' => 'yellow', 'price' => 50.0, 'quantity' => 1, 'coupon_code' => 'TEST 2', 'position' => 2];
     $this->analytics->addProduct($productData1);
     $productData2 = ['sku' => 'AAAA-5555', 'name' => 'Test Product', 'brand' => 'Test Brand', 'category' => 'Test Category 1/Test Category 2', 'variant' => 'blue', 'price' => 85.0, 'quantity' => 2, 'coupon_code' => 'TEST', 'position' => 4];
     $this->analytics->addProduct($productData2);
     $products = new ProductCollection();
     $products->add(new Product($productData1));
     $products->add(new Product($productData2));
     $compoundParameters = ['Product' => $products];
     $this->analytics->setProductActionToPurchase();
     $httpClient = $this->getMock('TheIconic\\Tracking\\GoogleAnalytics\\Network\\HttpClient', ['post']);
     $httpClient->expects($this->once())->method('post')->with($this->equalTo($this->analytics->getUrl()));
     $this->analytics->setHttpClient($httpClient);
     $this->analytics->sendEvent();
 }