Skip to content

Commit

Permalink
Refs #3089, initial visitor profile integration with UserCountryMap..
Browse files Browse the repository at this point in the history
  • Loading branch information
Benaka Moorthi committed Aug 10, 2013
1 parent a3bc697 commit 050fd0a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 22 deletions.
4 changes: 1 addition & 3 deletions core/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,4 @@ public function __construct($module)
{
parent::__construct("The plugin $module is not enabled. You can activate the plugin on Settings > Plugins page in Piwik.");
}
}


}
8 changes: 4 additions & 4 deletions plugins/Live/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
*/
class Piwik_Live_API
{
const VISITOR_PROFILE_MAX_VISITS_TO_AGGREGATE = 100;
const VISITOR_PROFILE_MAX_VISITS_TO_SHOW = 10;
const VISITOR_PROFILE_DATE_FORMAT = '%day% %shortMonth% %longYear%';

static private $instance = null;

/**
Expand Down Expand Up @@ -155,10 +159,6 @@ public function getLastVisitsDetails($idSite, $period, $date, $segment = false,
return $dataTable;
}

const VISITOR_PROFILE_MAX_VISITS_TO_AGGREGATE = 100;
const VISITOR_PROFILE_MAX_VISITS_TO_SHOW = 10;
const VISITOR_PROFILE_DATE_FORMAT = '%day% %shortMonth% %longYear%';

/**
* TODO
* TODO: add abandoned cart info.
Expand Down
20 changes: 20 additions & 0 deletions plugins/Live/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Piwik\Controller;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\FrontController;

/**
* @package Piwik_Live
Expand Down Expand Up @@ -143,6 +144,25 @@ public function getVisitorProfilePopup()
$view->idSite = $idSite;
$view->goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
$view->visitorData = Request::processRequest('Live.getVisitorProfile');
$view->userCountryMap = $this->getUserCountryMapForVisitorProfile();
echo $view->render();
}

private function getUserCountryMapForVisitorProfile()
{
if (empty($_GET['segment'])) {
$_GET['segment'] = '';
$originalSegment = '';
} else {
$_GET['segment'] .= '&';
$originalSegment = $_GET['segment'];
}
$_GET['segment'] .= 'visitorId==' . Common::getRequestVar('idVisitor');

$result = FrontController::getInstance()->fetchDispatch('UserCountryMap', 'visitorMap', array('fetch' => true)); // TODO: check if plugin is enabled?
$_GET['segment'] = $originalSegment;

return $result;
}
}
14 changes: 8 additions & 6 deletions plugins/Live/stylesheets/visitor_profile.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// TODO: use less variables for height & width
.visitor-profile {
position:relative;
width:1149px;
height:758px;
height:844px;
border:1px solid #a19e96;
border-radius:5px;
background:url(../images/visitor_profile_background.jpg) repeat;
Expand Down Expand Up @@ -66,7 +67,7 @@
}

.visitor-profile-info {
height:705px;
height:791px;
border-top:2px solid #f6f6f6;
border-bottom:1px solid #d1cec8;
border-radius:5px 5px 0 0;
Expand Down Expand Up @@ -187,11 +188,11 @@
padding:19px 0 18px 19px;
}

.visitor-profile-map * {
.visitor-profile-map > div {
border-radius:2px;
background-color:#fff;
width:532px;
height:243px;
height:334px;
padding:2px;
}

Expand Down Expand Up @@ -244,7 +245,7 @@
}

.visitor-profile-actions {
height:460px;
height:550px;
overflow-y:auto;
position:relative;
margin-right:10px;
Expand Down Expand Up @@ -359,7 +360,8 @@
}
}

.visitor-profile-goal-name {
span.visitor-profile-goal-name {
font-weight:bold;
font-style:italic;
font-size:13px;
}
12 changes: 6 additions & 6 deletions plugins/Live/templates/getVisitorProfilePopup.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@
</div>
<div style="clear:both; border:none!important;"></div>
<div class="visitor-profile-map">
<img alt="" src="plugins/Live/images/REMOVE_ME_map.jpg"/> {# TODO: map #}
{{ userCountryMap|raw }}
</div>
<div class="visitor-profile-important-visits">
<div>
<h1>First visit</h1>
<div>
<p><strong>{{ visitorData.firstVisit.prettyDate }}</strong><span> - {{ visitorData.firstVisit.daysAgo }} days ago</span></p>
<p><span>from:</span></p>
<p><strong>{{ visitorData.firstVisit.referralSummary }}</strong></p>
<p><strong>{{ visitorData.firstVisit.prettyDate }}</strong><span>&nbsp;- {{ visitorData.firstVisit.daysAgo }} days ago</span></p>
<p><span>from:</span>
<strong>{{ visitorData.firstVisit.referralSummary }}</strong></p>
</div>
</div>
<div>
<h1>Last visit</h1>
<div>
<p><strong>{{ visitorData.lastVisit.prettyDate }}</strong><span> - {{ visitorData.lastVisit.daysAgo }} days ago</span></p>
<p><span>from:</span></p>
<p><strong>{{ visitorData.lastVisit.referralSummary }}</strong></p>
<p><span>from:</span>
<strong>{{ visitorData.lastVisit.referralSummary }}</strong></p>
</div>
</div>
</div>
Expand Down
12 changes: 9 additions & 3 deletions plugins/UserCountryMap/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Piwik_UserCountryMap_Controller extends Controller
// By default plot up to the last 30 days of visitors on the map, for low traffic sites
const REAL_TIME_WINDOW = 'last30';

public function visitorMap()
public function visitorMap($fetch = false)
{
$this->checkUserCountryPluginEnabled();

Expand All @@ -36,6 +36,7 @@ public function visitorMap()

$period = Common::getRequestVar('period');
$date = Common::getRequestVar('date');
$segment = Common::getRequestVar('segment', '', 'string');
$token_auth = Piwik::getCurrentUserTokenAuth();

$view = new View('@UserCountryMap/visitorMap');
Expand Down Expand Up @@ -78,6 +79,7 @@ public function visitorMap()
'period' => $period,
'idSite' => $idSite,
'date' => $date,
'segment' => $segment,
'token_auth' => $token_auth,
'enable_filter_excludelowpop' => 1,
'filter_excludelowpop_value' => -1
Expand All @@ -89,7 +91,11 @@ public function visitorMap()
$view->config = Common::json_encode($config);
$view->noData = empty($config['visitsSummary']['nb_visits']);

echo $view->render();
if ($fetch) {
return $view->render();
} else {
echo $view->render();
}
}

/**
Expand Down Expand Up @@ -207,7 +213,7 @@ private function getApiRequestUrl($module, $action, $idSite, $period, $date, $to
. "&period=" . $period
. "&date=" . $date
. "&token_auth=" . $token_auth
. "&segment=" . \Piwik\API\Request::getRawSegmentFromRequest()
. "&segment=" . Common::getRequestVar('segment', '', 'string')
. "&enable_filter_excludelowpop=1"
. "&showRawMetrics=1";

Expand Down

0 comments on commit 050fd0a

Please sign in to comment.