Skip to content

Commit

Permalink
Fixed userIp check
Browse files Browse the repository at this point in the history
  • Loading branch information
baibaratsky committed Apr 18, 2015
1 parent b32bd1d commit 2c2580b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions MeasurementProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ public function request()
->setProtocolVersion($this->version)
->setAsyncRequest($this->asyncMode);

if ($this->overrideIp) {
if (isset(\Yii::$app->request)) {
$request->setIpOverride(\Yii::$app->request->userIP);
} else {
\Yii::warning('Cant’t access the request component to override the IP address. Is it a web application?');
}
if ($this->overrideIp && isset(\Yii::$app->request->userIP)) {
$request->setIpOverride(\Yii::$app->request->userIP);
}

if ($this->anonymizeIp) {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ $request->setEventCategory('Checkout')

Asynchronous Mode
-----------------
By default, sending a hit to GA will be a synchronous request, and block the execution of the script until it gets
a response from the server or timeouts after 100 seconds (throwing a Guzzle exception). However, if you turn
By default, sending a hit to Google Analytics will be a synchronous request, and block the execution of the script until
it gets a response from the server or timeouts after 100 seconds (throwing a Guzzle exception). However, if you turn
the asynchronous mode on in the component config, asynchronous non-blocking requests will be used.
```php
'asyncMode' => true,
Expand Down

0 comments on commit 2c2580b

Please sign in to comment.