Permalink
Browse files

added dashboard api base

  • Loading branch information...
1 parent de092c0 commit 8214d4aaa47a3a5dce1214c752951b66933fda2f @pulse00 pulse00 committed May 11, 2012
View
@@ -1,7 +1,6 @@
<?php
namespace AntiMattr\GoogleBundle;
-
use AntiMattr\GoogleBundle\Analytics\CustomVariable;
use AntiMattr\GoogleBundle\Analytics\Event;
use AntiMattr\GoogleBundle\Analytics\Item;
@@ -10,23 +9,30 @@
class Analytics
{
- const EVENT_QUEUE_KEY = 'google_analytics/event/queue';
+ const EVENT_QUEUE_KEY = 'google_analytics/event/queue';
const CUSTOM_PAGE_VIEW_KEY = 'google_analytics/page_view';
- const PAGE_VIEW_QUEUE_KEY = 'google_analytics/page_view/queue';
- const TRANSACTION_KEY = 'google_analytics/transaction';
- const ITEMS_KEY = 'google_analytics/items';
+ const PAGE_VIEW_QUEUE_KEY = 'google_analytics/page_view/queue';
+ const TRANSACTION_KEY = 'google_analytics/transaction';
+ const ITEMS_KEY = 'google_analytics/items';
private $container;
private $customVariables = array();
private $pageViewsWithBaseUrl = true;
private $trackers;
private $whitelist;
+ private $api_key;
+ private $client_id;
+ private $table_id;
- public function __construct(ContainerInterface $container, array $trackers = array(), array $whitelist = array())
+ public function __construct(ContainerInterface $container,
+ array $trackers = array(), array $whitelist = array(), array $dashboard = array())
{
$this->container = $container;
$this->trackers = $trackers;
$this->whitelist = $whitelist;
+ $this->api_key = isset($dashboard['api_key']) ? $dashboard['api_key'] : '';
+ $this->client_id = isset($dashboard['client_id']) ? $dashboard['client_id'] : '';
+ $this->table_id = isset($dashboard['table_id']) ? $dashboard['table_id'] : '';
}
public function excludeBaseUrl()
@@ -128,7 +134,8 @@ public function getTrackPageLoadTime($trackerKey)
*/
public function getCustomPageView()
{
- $customPageView = $this->container->get('session')->get(self::CUSTOM_PAGE_VIEW_KEY);
+ $customPageView = $this->container->get('session')
+ ->get(self::CUSTOM_PAGE_VIEW_KEY);
$this->container->get('session')->remove(self::CUSTOM_PAGE_VIEW_KEY);
return $customPageView;
}
@@ -146,7 +153,8 @@ public function hasCustomPageView()
*/
public function setCustomPageView($customPageView)
{
- $this->container->get('session')->set(self::CUSTOM_PAGE_VIEW_KEY, $customPageView);
+ $this->container->get('session')
+ ->set(self::CUSTOM_PAGE_VIEW_KEY, $customPageView);
}
/**
@@ -303,7 +311,7 @@ public function getRequestUri()
$query = http_build_query($params);
if (isset($query) && '' != trim($query)) {
- $requestUri .= '?'. $query;
+ $requestUri .= '?' . $query;
}
return $requestUri;
}
@@ -331,13 +339,17 @@ public function getTrackers(array $trackers = array())
*/
public function isTransactionValid()
{
- if (!$this->hasTransaction() || (null === $this->getTransactionFromSession()->getOrderNumber())) {
+ if (!$this->hasTransaction()
+ || (null
+ === $this->getTransactionFromSession()
+ ->getOrderNumber())) {
return false;
}
if ($this->hasItems()) {
$items = $this->getItemsFromSession();
foreach ($items as $item) {
- if (!$item->getOrderNumber() || !$item->getSku() || !$item->getPrice() || !$item->getQuantity()) {
+ if (!$item->getOrderNumber() || !$item->getSku()
+ || !$item->getPrice() || !$item->getQuantity()) {
return false;
}
}
@@ -368,7 +380,8 @@ public function hasTransaction()
*/
public function setTransaction(Transaction $transaction)
{
- $this->container->get('session')->set(self::TRANSACTION_KEY, $transaction);
+ $this->container->get('session')
+ ->set(self::TRANSACTION_KEY, $transaction);
}
/**
@@ -427,4 +440,30 @@ private function getTransactionFromSession()
{
return $this->container->get('session')->get(self::TRANSACTION_KEY);
}
+
+ /**
+ *
+ * @return string
+ */
+ public function getApiKey()
+ {
+ return $this->api_key;
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getClientId()
+ {
+ return $this->client_id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTableId()
+ {
+ return $this->table_id;
+ }
}
@@ -65,6 +65,9 @@ private function analyticsLoad(array $configs, ContainerBuilder $container)
if (isset($config['trackers'])) {
$container->setParameter('google.analytics.trackers', $config['trackers']);
}
+ if (isset($config['dashboard'])) {
+ $container->setParameter('google.analytics.dashboard', $config['dashboard']);
+ }
if (isset($config['whitelist'])) {
$container->setParameter('google.analytics.whitelist', $config['whitelist']);
}
@@ -110,6 +110,21 @@ public function getTrackers(array $trackers = array())
{
return $this->analytics->getTrackers($trackers);
}
+
+ public function getApiKey()
+ {
+ return $this->analytics->getApiKey();
+ }
+
+ public function getClientId()
+ {
+ return $this->analytics->getClientId();
+ }
+
+ public function getTableId()
+ {
+ return $this->analytics->getTableId();
+ }
public function isTransactionValid()
{
@@ -15,6 +15,7 @@
<argument type="service" id="service_container" />
<argument>%google.analytics.trackers%</argument>
<argument>%google.analytics.whitelist%</argument>
+ <argument>%google.analytics.dashboard%</argument>
</service>
<service id="templating.helper.google_analytics" class="AntiMattr\GoogleBundle\Helper\AnalyticsHelper">
Oops, something went wrong.

0 comments on commit 8214d4a

Please sign in to comment.