diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-04-20 13:02:35 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-04-20 13:02:36 +0400 |
commit | 35f975accb45152dd669e0009237eed3dc6ada2b (patch) | |
tree | 8a0a82519a8a3502ae18c31ae3db7bf2d148af55 /plugins/Live/Visitor.php | |
parent | 6575c1f85e6d4276cbce2d8a22535c6d499cb8ce (diff) |
Fixes #3904:
* new segment 'siteSearchKeyword'
Fixes #3903, #3905:
* adding few fields in the Live API output to accomodate getSuggestedValuesForSegment
* renamed other fields for consistency with segment names
Fixes #3906:
* new API: getSuggestedValuesForSegment which returns top suggested values for a particular segment. It uses the Live.getLastVisitsDetails API to fetch the most recently used values, and will show the most used values first
* Adding tests for everything. The test case actually generates data for all segments so that VisitsSummary.get returns some data for each of the 47 segments being tested returns some data.
How it works:
* generate extended data in fixture
* Tests (1) call getSuggestedValuesForSegment for each segment, check there is some data returned for each segment
* get the first suggested value from the list,
* Tests (2) call VisitsSummary.get with this segment value, eg. countryCode==ru.
* I worked this way for all 47 segments until all tests had some data ==> now we know that all segments have been tested and that the auto suggest works for all segments. TDD FTW!
Diffstat (limited to 'plugins/Live/Visitor.php')
-rw-r--r-- | plugins/Live/Visitor.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index aaa4e8a61d..45a3ec7f08 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -60,6 +60,8 @@ class Piwik_Live_Visitor // all time entries 'serverDate' => $this->getServerDate(), 'visitLocalTime' => $this->getVisitLocalTime(), + 'visitLocalHour' => $this->getVisitLocalHour(), + 'visitServerHour' => $this->getVisitServerHour(), 'firstActionTimestamp' => $this->getTimestampFirstAction(), 'lastActionTimestamp' => $this->getTimestampLastAction(), 'lastActionDateTime' => $this->getDateTimeLastAction(), @@ -77,6 +79,7 @@ class Piwik_Live_Visitor 'countryCode' => $this->getCountryCode(), 'countryFlag' => $this->getCountryFlag(), 'region' => $this->getRegionName(), + 'regionCode' => $this->getRegionCode(), 'city' => $this->getCityName(), 'location' => $this->getPrettyLocation(), 'latitude' => $this->getLatitude(), @@ -93,12 +96,15 @@ class Piwik_Live_Visitor 'referrerSearchEngineUrl' => $this->getSearchEngineUrl(), 'referrerSearchEngineIcon' => $this->getSearchEngineIcon(), 'operatingSystem' => $this->getOperatingSystem(), + 'operatingSystemCode' => $this->getOperatingSystemCode(), 'operatingSystemShortName' => $this->getOperatingSystemShortName(), 'operatingSystemIcon' => $this->getOperatingSystemIcon(), 'browserFamily' => $this->getBrowserFamily(), 'browserFamilyDescription' => $this->getBrowserFamilyDescription(), 'browserName' => $this->getBrowser(), 'browserIcon' => $this->getBrowserIcon(), + 'browserCode' => $this->getBrowserCode(), + 'browserVersion' => $this->getBrowserVersion(), 'screenType' => $this->getScreenType(), 'resolution' => $this->getResolution(), 'screenTypeIcon' => $this->getScreenTypeIcon(), @@ -120,6 +126,16 @@ class Piwik_Live_Visitor return $this->details['visitor_localtime']; } + function getVisitServerHour() + { + return date('G', strtotime($this->details['visit_last_action_time'])); + } + + function getVisitLocalHour() + { + return date('G', strtotime('2012-12-21 ' . $this->details['visitor_localtime'])); + } + function getVisitCount() { return $this->details['visitor_count_visits']; @@ -249,7 +265,7 @@ class Piwik_Live_Visitor public function getRegionName() { - $region = $this->details['location_region']; + $region = $this->getRegionCode(); if ($region != '' && $region != Piwik_Tracker_Visit::UNKNOWN_CODE) { return Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes( $this->details['location_country'], $region); @@ -257,6 +273,11 @@ class Piwik_Live_Visitor return null; } + public function getRegionCode() + { + return $this->details['location_region']; + } + function getPrettyLocation() { $parts = array(); @@ -430,6 +451,11 @@ class Piwik_Live_Visitor return null; } + function getOperatingSystemCode() + { + return $this->details['config_os']; + } + function getOperatingSystem() { return Piwik_getOSLabel($this->details['config_os']); @@ -455,6 +481,16 @@ class Piwik_Live_Visitor return Piwik_getBrowserFamily($this->details['config_browser_name']); } + function getBrowserCode() + { + return $this->details['config_browser_name']; + } + + function getBrowserVersion() + { + return $this->details['config_browser_version']; + } + function getBrowser() { return Piwik_getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']); |