Skip to content

Commit

Permalink
add enabled option - new in 2.6.0 (#12)
Browse files Browse the repository at this point in the history
* add enabled option - new in 2.6.0

* rename to sandbox

* disable by default
  • Loading branch information
ivan1986 authored and foaly-nr1 committed Apr 22, 2017
1 parent 607fae1 commit 3f6164b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function getConfigTreeBuilder()
->booleanNode('async_requests')
->defaultTrue()
->end()
->booleanNode('sandbox')
->defaultFalse()
->end()
->end()
;

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Example of configuration in `app/config.yml`:
use_ssl: true
anonymize_ip: false
async_requests: true
sandbox: true

Set your Google Analytics Tracking / Web Property ID in `tracking_id` key **[REQUIRED]**

Expand Down Expand Up @@ -127,6 +128,12 @@ To Make Async Requests, set `async_requests` to true. Default: true
async_requests: true
```

When sandbox mode is enabled, no hits are actually sent to GA. In this case the library returns a AnalyticsResponseInterface object that with empty values. Default: false

``` yaml
sandbox: true
```

## To Do
- Unit tests

Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<argument>%gamp.anonymize_ip%</argument>
<argument>%gamp.async_requests%</argument>
<argument>%kernel.debug%</argument>
<argument>%gamp.sandbox%</argument>
</service>
</services>
</container>
5 changes: 3 additions & 2 deletions Service/AnalyticsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ class AnalyticsFactory
* @param bool $anonymize
* @param bool $async
* @param bool $debug
* @param bool $sandbox
*
* @return Analytics
*/
public function createAnalytics(RequestStack $requestStack, $version, $trackingId, $ssl, $anonymize, $async, $debug)
public function createAnalytics(RequestStack $requestStack, $version, $trackingId, $ssl, $anonymize, $async, $debug, $sandbox)
{
$analytics = new Analytics($ssl);
$analytics = new Analytics($ssl, $sandbox);

$analytics
->setProtocolVersion($version)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": ">=5.5",
"theiconic/php-ga-measurement-protocol": "^2.5.1",
"theiconic/php-ga-measurement-protocol": "^2.6",
"symfony/framework-bundle": "~2.4 || ~3.0"
},
"autoload": {
Expand Down

0 comments on commit 3f6164b

Please sign in to comment.