diff --git a/lang/en.php b/lang/en.php index d48003f79bd386b3afc8c3183b027b703b7204d5..d36612cc37490720dcfe2dd66ab6203ef27969ca 100644 --- a/lang/en.php +++ b/lang/en.php @@ -1456,7 +1456,7 @@ And thank you for using Piwik!', 'UserCountry_PeclGeoLiteError' => 'Your GeoIP database in %1$s is named %2$s. Unfortunately, the PECL module will not recognize it with this name. Please rename it to %3$s.', 'UserCountry_GeoIpLocationProviderDesc_Pecl1' => 'This location provider uses a GeoIP database and a PECL module to accurately and efficiently determine the location of your visitors.', 'UserCountry_GeoIpLocationProviderDesc_Pecl2' => 'There are no limitations with this provider, so it is the one we recommend using.', - 'UserCountry_CannotFindGeoIPServerVar' => 'The %s $_SERVER variable is not set. Your server may not be configured correctly.', + 'UserCountry_CannotFindGeoIPServerVar' => 'The %s variable is not set. Your server may not be configured correctly.', 'UserCountry_LocationProvider' => 'Location Provider', 'UserCountry_TestIPLocatorFailed' => 'Piwik tried checking the location of a known IP address (%1$s), but your server returned %2$s. If this provider were configured correctly, it would return %3$s.', 'UserCountry_CannotLocalizeLocalIP' => 'IP address %s is a local address and cannot be geolocated.', diff --git a/plugins/UserCountry/LocationProvider.php b/plugins/UserCountry/LocationProvider.php index 8ead0e9f5c5b3fca9c9c949423090c7374abb95b..34124f0d2344482eb7914a9e21db2ba94c0bec68 100755 --- a/plugins/UserCountry/LocationProvider.php +++ b/plugins/UserCountry/LocationProvider.php @@ -290,7 +290,8 @@ abstract class Piwik_UserCountry_LocationProvider $provider = self::getProviderById($providerId); if ($provider === false) { - throw new Exception("Invalid provider ID '$providerId'."); + throw new Exception( + "Invalid provider ID '$providerId'. The provider either does not exist or is not available"); } Piwik_SetOption(self::CURRENT_PROVIDER_OPTION_NAME, $providerId); return $provider; diff --git a/plugins/UserCountry/LocationProvider/GeoIp.php b/plugins/UserCountry/LocationProvider/GeoIp.php index c08e463510283692f0f270e28d0564ee8e154758..9c2d49a4760778f1fe1976a3ffef87c229de67cc 100755 --- a/plugins/UserCountry/LocationProvider/GeoIp.php +++ b/plugins/UserCountry/LocationProvider/GeoIp.php @@ -17,7 +17,7 @@ */ abstract class Piwik_UserCountry_LocationProvider_GeoIp extends Piwik_UserCountry_LocationProvider { - const GEOIP_DATABASE_DIR = 'misc'; + public static $geoIPDatabaseDir = 'misc'; /** * Stores possible database file names categorized by the type of information @@ -176,9 +176,10 @@ abstract class Piwik_UserCountry_LocationProvider_GeoIp extends Piwik_UserCountr */ public static function getPathToGeoIpDatabase( $possibleFileNames ) { + $dir = PIWIK_INCLUDE_PATH.'/'.self::$geoIPDatabaseDir; foreach ($possibleFileNames as $filename) { - $path = PIWIK_INCLUDE_PATH.'/'.self::GEOIP_DATABASE_DIR.'/'.$filename; + $path = $dir.'/'.$filename; if (file_exists($path)) { return $path; diff --git a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php index 116e12e942bc468f99010e605516c488f6070e30..d39aba67565ce972313d27fc30077de90adf6487 100755 --- a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php +++ b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php @@ -13,7 +13,7 @@ /** * A LocationProvider that uses an GeoIP module installed in an HTTP Server. * - * To make this provider available, make sure the GEOIP_COUNTRY_CODE server + * To make this provider available, make sure the GEOIP_ADDR server * variable is set. * * @package Piwik_UserCountry @@ -22,6 +22,7 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou { const ID = 'geoip_serverbased'; const TITLE = 'GeoIP (%s)'; + const TEST_SERVER_VAR = 'GEOIP_ADDR'; private static $geoIpServerVars = array( parent::COUNTRY_CODE_KEY => 'GEOIP_COUNTRY_CODE', @@ -98,15 +99,9 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou * Returns an array describing the types of location information this provider will * return. * - * What this provider supports is dependent on how it is configured. We can't tell - * what databases a server module has access to, so we rely on which $_SERVER - * variables are available. If GEOIP_ISP is available, then we assume we can return - * this information. - * - * Since it's an error if GEOIP_COUNTRY_CODE is not available, we assume country - * info is always supported. - * - * Getting continent info is not dependent on GeoIP, so it is always supported. + * There's no way to tell exactly what database the HTTP server is using, so we just + * assume country and continent information is available. This can make diagnostics + * a bit more difficult, unfortunately. * * @return array */ @@ -114,15 +109,6 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou { $result = array(); - // set supported info based on what $_SERVER variables are available - foreach (self::$geoIpServerVars as $locKey => $serverVarName) - { - if (isset($_SERVER[$serverVarName])) - { - $result[$locKey] = true; - } - } - // assume country info is always available. it's an error if it's not. $result[self::COUNTRY_CODE_KEY] = true; $result[self::COUNTRY_NAME_KEY] = true; @@ -134,7 +120,7 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou /** * Checks if an HTTP server module has been installed. It checks by looking for - * the GEOIP_COUNTRY_CODE server variable. + * the GEOIP_ADDR server variable. * * There's a special check for the Apache module, but we can't check specifically * for anything else. @@ -155,22 +141,22 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou } } - return !empty($_SERVER['GEOIP_COUNTRY_CODE']); + return !empty($_SERVER[self::TEST_SERVER_VAR]); } /** - * Returns true if the GEOIP_COUNTRY_CODE server variable is defined. + * Returns true if the GEOIP_ADDR server variable is defined. * - * @return true + * @return bool */ public function isWorking() { - if (empty($_SERVER['GEOIP_COUNTRY_CODE'])) + if (empty($_SERVER[self::TEST_SERVER_VAR])) { - return Piwik_Translate("UserCountry_CannotFindGeoIPServerVar", '$_SERVER GEOIP_COUNTRY_CODE'); + return Piwik_Translate("UserCountry_CannotFindGeoIPServerVar", self::TEST_SERVER_VAR.' $_SERVER'); } - return parent::isWorking(); + return true; // can't check for another IP } /** diff --git a/tests/PHPUnit/Integration/ImportLogsTest.php b/tests/PHPUnit/Integration/ImportLogsTest.php index e7767a78e8bce7cf48437e76af01a31e07e49a42..804b848b1bc88a67e71994d82b5c941fc1a65b18 100755 --- a/tests/PHPUnit/Integration/ImportLogsTest.php +++ b/tests/PHPUnit/Integration/ImportLogsTest.php @@ -24,12 +24,25 @@ class Test_Piwik_Integration_ImportLogs extends IntegrationTestCase self::$tokenAuth = self::getTokenAuth(); self::setUpWebsitesAndGoals(); + self::downloadGeoIpDbs(); + + Piwik_UserCountry_LocationProvider::$providers = null; + Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; + Piwik_UserCountry_LocationProvider::setCurrentProvider('geoip_php'); + self::trackVisits(); } catch(Exception $e) { // Skip whole test suite if an error occurs while setup throw new PHPUnit_Framework_SkippedTestSuiteError($e->getMessage()); } } + + public static function tearDownAfterClass() + { + Piwik_UserCountry_LocationProvider::$providers = null; + Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; + Piwik_UserCountry_LocationProvider::setCurrentProvider('default'); + } /** * @dataProvider getApiForTesting diff --git a/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php b/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php index ac90549f449cf42f1fb75dd5873c78befa4c67c0..ccd5df01b1572e324234550437427bb4dd493c3c 100755 --- a/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php +++ b/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php @@ -12,11 +12,13 @@ require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php'; /** * Tests w/ 14 visitors w/ 2 visits each. Uses geoip location provider to test city/region reports. * - * TODO Test ServerBased GeoIP implementation somehow. - * TODO When added, test PECL implementation. + * TODO Test ServerBased GeoIP implementation somehow. (Use X-FORWARDED-FOR?) + * TODO Test PECL implementation somehow. (The PECL module must point to the test dir, not the real one.) */ class Test_Piwik_Integration_ManyVisitorsOneWebsiteTest extends IntegrationTestCase { + const GEOIP_IMPL_TO_TEST = 'geoip_php'; + protected static $idSite = 1; protected static $dateTime = '2010-01-03 11:22:33'; @@ -32,9 +34,6 @@ class Test_Piwik_Integration_ManyVisitorsOneWebsiteTest extends IntegrationTestC '103.29.196.229', // in Indonesia (Bali), (only Indonesia will show up) ); - - public static $geoIpDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoIP.dat.gz'; - public static $geoLiteCityDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoLiteCity.dat.gz'; public static function setUpBeforeClass() { @@ -46,8 +45,9 @@ class Test_Piwik_Integration_ManyVisitorsOneWebsiteTest extends IntegrationTestC self::setMockLocationProvider(); self::trackVisits(9, false); - self::setLocationProvider('GeoLiteCity.dat'); - self::trackVisits(4, true); + self::setLocationProvider('GeoIPCity.dat'); + self::trackVisits(2, true, $useLocal = false); + self::trackVisits(2, true, $useLocal = false, $doBulk = true); self::setLocationProvider('GeoIP.dat'); self::trackVisits(2, true); @@ -112,13 +112,18 @@ class Test_Piwik_Integration_ManyVisitorsOneWebsiteTest extends IntegrationTestC Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'all', 'url', 'http', 'contains', false, 5); } - protected static function trackVisits( $visitorCount, $setIp = false ) + protected static function trackVisits( $visitorCount, $setIp = false, $useLocal = true, $doBulk = false ) { $dateTime = self::$dateTime; $idSite = self::$idSite; // use local tracker so mock location provider can be used - $t = self::getTracker($idSite, $dateTime, $defaultInit = true, $useLocal = true); + $t = self::getTracker($idSite, $dateTime, $defaultInit = true, $useLocal); + if ($doBulk) + { + $t->enableBulkTracking(); + $t->setTokenAuth(self::getTokenAuth()); + } for ($i = 0; $i != $visitorCount; ++$i) { $t->setNewVisitorId(); @@ -136,21 +141,34 @@ class Test_Piwik_Integration_ManyVisitorsOneWebsiteTest extends IntegrationTestC $date = Piwik_Date::factory($dateTime)->addDay($i); $t->setForceVisitDateTime($date->getDatetime()); $t->setUrl("http://piwik.net/grue/lair"); - self::checkResponse($t->doTrackPageView('It\'s pitch black...')); + $r = $t->doTrackPageView('It\'s pitch black...'); + if (!$doBulk) + { + self::checkResponse($r); + } // second visit $date = $date->addHour(1); $t->setForceVisitDateTime($date->getDatetime()); $t->setUrl("http://piwik.net/space/quest/iv"); - self::checkResponse($t->doTrackPageView("Space Quest XII")); + $r = $t->doTrackPageView("Space Quest XII"); + if (!$doBulk) + { + self::checkResponse($r); + } + } + if ($doBulk) + { + self::checkResponse($t->doBulkTrack()); } } public static function setLocationProvider( $file ) { Piwik_UserCountry_LocationProvider_GeoIp::$dbNames['loc'] = array($file); + Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; Piwik_UserCountry_LocationProvider::$providers = null; - Piwik_UserCountry_LocationProvider::setCurrentProvider('geoip_php'); + Piwik_UserCountry_LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST); } public static function setMockLocationProvider() @@ -191,57 +209,6 @@ class Test_Piwik_Integration_ManyVisitorsOneWebsiteTest extends IntegrationTestC Piwik_UserCountry_LocationProvider::setCurrentProvider('default'); } - public static function downloadGeoIpDbs() - { - $geoIpOutputDir = PIWIK_INCLUDE_PATH.'/tests/lib/geoip-files'; - self::downloadAndUnzip(self::$geoIpDbUrl, $geoIpOutputDir, 'GeoIP.dat'); - self::downloadAndUnzip(self::$geoLiteCityDbUrl, $geoIpOutputDir, 'GeoLiteCity.dat'); - } - - public static function downloadAndUnzip( $url, $outputDir, $filename ) - { - $bufferSize = 1024 * 1024; - - try - { - if (!is_dir($outputDir)) - { - mkdir($outputDir); - } - - $deflatedOut = $outputDir.'/'.$filename; - $outfileName = $deflatedOut.'.gz'; - - if (file_exists($deflatedOut)) - { - return; - } - - $dump = fopen($url, 'rb'); - $outfile = fopen($outfileName, 'wb'); - $bytesRead = 0; - while (!feof($dump)) - { - fwrite($outfile, fread($dump, $bufferSize), $bufferSize); - $bytesRead += $bufferSize; - } - fclose($dump); - fclose($outfile); - - // unzip the dump - exec("gunzip -c \"".$outfileName."\" > \"$deflatedOut\"", $output, $return); - if ($return !== 0) - { - throw new Exception("gunzip failed($return): ".implode("\n", $output)); - } - } - catch (Exception $ex) - { - self::markTestSkipped( - "Cannot download GeoIp DBs, skipping: ".$ex->getMessage()."\n".$ex->getTraceAsString()); - } - } - public static function makeLocation( $city, $region, $country ) { return array(Piwik_UserCountry_LocationProvider::CITY_NAME_KEY => $city, diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index 57e3042e121711d03d20790cc4b0124f42143baa..433d8c0f4769729453b7017bc1df4a7f9bdcc055 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -1189,4 +1189,58 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase Piwik_TablePartitioning::$tablesAlreadyInstalled = Piwik::getTablesInstalled($forceReload = true); } + + public static $geoIpDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoIP.dat.gz'; + public static $geoLiteCityDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoLiteCity.dat.gz'; + + public static function downloadGeoIpDbs() + { + $geoIpOutputDir = PIWIK_INCLUDE_PATH.'/tests/lib/geoip-files'; + self::downloadAndUnzip(self::$geoIpDbUrl, $geoIpOutputDir, 'GeoIP.dat'); + self::downloadAndUnzip(self::$geoLiteCityDbUrl, $geoIpOutputDir, 'GeoIPCity.dat'); + } + + public static function downloadAndUnzip( $url, $outputDir, $filename ) + { + $bufferSize = 1024 * 1024; + + try + { + if (!is_dir($outputDir)) + { + mkdir($outputDir); + } + + $deflatedOut = $outputDir.'/'.$filename; + $outfileName = $deflatedOut.'.gz'; + + if (file_exists($deflatedOut)) + { + return; + } + + $dump = fopen($url, 'rb'); + $outfile = fopen($outfileName, 'wb'); + $bytesRead = 0; + while (!feof($dump)) + { + fwrite($outfile, fread($dump, $bufferSize), $bufferSize); + $bytesRead += $bufferSize; + } + fclose($dump); + fclose($outfile); + + // unzip the dump + exec("gunzip -c \"".$outfileName."\" > \"$deflatedOut\"", $output, $return); + if ($return !== 0) + { + throw new Exception("gunzip failed($return): ".implode("\n", $output)); + } + } + catch (Exception $ex) + { + self::markTestSkipped( + "Cannot download GeoIp DBs, skipping: ".$ex->getMessage()."\n".$ex->getTraceAsString()); + } + } } diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php index 43540905afd5693b1ab213c6ebba2622bdccf7f4..e19dba526d59d12bd4c75db78efe1d053788f3d1 100755 --- a/tests/PHPUnit/proxy/piwik.php +++ b/tests/PHPUnit/proxy/piwik.php @@ -25,6 +25,7 @@ require_once PIWIK_INCLUDE_PATH .'/core/Loader.php'; Piwik::createConfigObject(); Piwik_Config::getInstance()->setTestEnvironment(); Piwik_Config::getInstance()->PluginsInstalled['PluginsInstalled'] = array(); +Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; Piwik_Tracker::setTestEnvironment(); Piwik_DataTable_Manager::getInstance()->deleteAll(); diff --git a/tests/integration/expected/test_ImportLogs__UserCountry.getCity_month.xml b/tests/integration/expected/test_ImportLogs__UserCountry.getCity_month.xml index 4a228d8e072e63e75e3d6544bf487e4cb6ceda4b..d141f5b0d5417bf686074f0aa6e9a2d95dac77bf 100755 --- a/tests/integration/expected/test_ImportLogs__UserCountry.getCity_month.xml +++ b/tests/integration/expected/test_ImportLogs__UserCountry.getCity_month.xml @@ -1,22 +1,46 @@ <?xml version="1.0" encoding="utf-8" ?> <result> <row> - <label>Unknown</label> - <nb_visits>22</nb_visits> - <nb_actions>25</nb_actions> + <label>Unknown, Japan</label> + <nb_visits>10</nb_visits> + <nb_actions>13</nb_actions> <max_actions>3</max_actions> <sum_visit_length>305</sum_visit_length> - <bounce_count>20</bounce_count> + <bounce_count>8</bounce_count> <goals> <row idgoal='1'> - <nb_conversions>21</nb_conversions> - <nb_visits_converted>21</nb_visits_converted> - <revenue>105</revenue> + <nb_conversions>9</nb_conversions> + <nb_visits_converted>9</nb_visits_converted> + <revenue>45</revenue> </row> </goals> - <nb_conversions>21</nb_conversions> - <revenue>105</revenue> - <sum_daily_nb_uniq_visitors>22</sum_daily_nb_uniq_visitors> + <nb_conversions>9</nb_conversions> + <revenue>45</revenue> + <sum_daily_nb_uniq_visitors>10</sum_daily_nb_uniq_visitors> + <city_name>Unknown</city_name> + <region>xx</region> + <country>jp</country> + <country_name>Japan</country_name> + <region_name>Unknown</region_name> + <logo>plugins/UserCountry/flags/jp.png</logo> + </row> + <row> + <label>Unknown</label> + <nb_visits>5</nb_visits> + <nb_actions>5</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>5</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>5</nb_conversions> + <nb_visits_converted>5</nb_visits_converted> + <revenue>25</revenue> + </row> + </goals> + <nb_conversions>5</nb_conversions> + <revenue>25</revenue> + <sum_daily_nb_uniq_visitors>5</sum_daily_nb_uniq_visitors> <city_name>Unknown</city_name> <region>xx</region> <country>xx</country> @@ -24,4 +48,54 @@ <region_name>Unknown</region_name> <logo>plugins/UserCountry/flags/xx.png</logo> </row> + <row> + <label>Ashburn, Virginia, United States</label> + <nb_visits>4</nb_visits> + <nb_actions>4</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>4</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>4</nb_conversions> + <nb_visits_converted>4</nb_visits_converted> + <revenue>20</revenue> + </row> + </goals> + <nb_conversions>4</nb_conversions> + <revenue>20</revenue> + <sum_daily_nb_uniq_visitors>4</sum_daily_nb_uniq_visitors> + <city_name>Ashburn</city_name> + <region>VA</region> + <country>us</country> + <lat>39.043701</lat> + <long>-77.487503</long> + <country_name>United States</country_name> + <region_name>Virginia</region_name> + <logo>plugins/UserCountry/flags/us.png</logo> + </row> + <row> + <label>Unknown, Brazil</label> + <nb_visits>3</nb_visits> + <nb_actions>3</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>3</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>3</nb_conversions> + <nb_visits_converted>3</nb_visits_converted> + <revenue>15</revenue> + </row> + </goals> + <nb_conversions>3</nb_conversions> + <revenue>15</revenue> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> + <city_name>Unknown</city_name> + <region>xx</region> + <country>br</country> + <country_name>Brazil</country_name> + <region_name>Unknown</region_name> + <logo>plugins/UserCountry/flags/br.png</logo> + </row> </result> \ No newline at end of file diff --git a/tests/integration/expected/test_ImportLogs__UserCountry.getContinent_month.xml b/tests/integration/expected/test_ImportLogs__UserCountry.getContinent_month.xml index 06b59efbd8ac7a4d4eeca7cfb63d8d0f7b647282..524731358935326c27b2ea11354096aa9e560cc6 100755 --- a/tests/integration/expected/test_ImportLogs__UserCountry.getContinent_month.xml +++ b/tests/integration/expected/test_ImportLogs__UserCountry.getContinent_month.xml @@ -1,22 +1,79 @@ <?xml version="1.0" encoding="utf-8" ?> <result> <row> - <label>Unknown</label> - <nb_visits>22</nb_visits> - <nb_actions>25</nb_actions> + <label>Asia</label> + <nb_visits>10</nb_visits> + <nb_actions>13</nb_actions> <max_actions>3</max_actions> <sum_visit_length>305</sum_visit_length> - <bounce_count>20</bounce_count> + <bounce_count>8</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>9</nb_conversions> + <nb_visits_converted>9</nb_visits_converted> + <revenue>45</revenue> + </row> + </goals> + <nb_conversions>9</nb_conversions> + <revenue>45</revenue> + <sum_daily_nb_uniq_visitors>10</sum_daily_nb_uniq_visitors> + <code>Asia</code> + </row> + <row> + <label>Unknown</label> + <nb_visits>5</nb_visits> + <nb_actions>5</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>5</bounce_count> <goals> <row idgoal='1'> - <nb_conversions>21</nb_conversions> - <nb_visits_converted>21</nb_visits_converted> - <revenue>105</revenue> + <nb_conversions>5</nb_conversions> + <nb_visits_converted>5</nb_visits_converted> + <revenue>25</revenue> </row> </goals> - <nb_conversions>21</nb_conversions> - <revenue>105</revenue> - <sum_daily_nb_uniq_visitors>22</sum_daily_nb_uniq_visitors> + <nb_conversions>5</nb_conversions> + <revenue>25</revenue> + <sum_daily_nb_uniq_visitors>5</sum_daily_nb_uniq_visitors> <code>Unknown</code> </row> + <row> + <label>North America</label> + <nb_visits>4</nb_visits> + <nb_actions>4</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>4</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>4</nb_conversions> + <nb_visits_converted>4</nb_visits_converted> + <revenue>20</revenue> + </row> + </goals> + <nb_conversions>4</nb_conversions> + <revenue>20</revenue> + <sum_daily_nb_uniq_visitors>4</sum_daily_nb_uniq_visitors> + <code>North America</code> + </row> + <row> + <label>South America</label> + <nb_visits>3</nb_visits> + <nb_actions>3</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>3</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>3</nb_conversions> + <nb_visits_converted>3</nb_visits_converted> + <revenue>15</revenue> + </row> + </goals> + <nb_conversions>3</nb_conversions> + <revenue>15</revenue> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> + <code>South America</code> + </row> </result> \ No newline at end of file diff --git a/tests/integration/expected/test_ImportLogs__UserCountry.getCountry_month.xml b/tests/integration/expected/test_ImportLogs__UserCountry.getCountry_month.xml index bddd6d5f7ef06bd567287ab2b5fc642468bdf7a2..06961e716c88aebc92eb72a25934490a52fe527e 100755 --- a/tests/integration/expected/test_ImportLogs__UserCountry.getCountry_month.xml +++ b/tests/integration/expected/test_ImportLogs__UserCountry.getCountry_month.xml @@ -1,25 +1,91 @@ <?xml version="1.0" encoding="utf-8" ?> <result> <row> - <label>Unknown</label> - <nb_visits>22</nb_visits> - <nb_actions>25</nb_actions> + <label>Japan</label> + <nb_visits>10</nb_visits> + <nb_actions>13</nb_actions> <max_actions>3</max_actions> <sum_visit_length>305</sum_visit_length> - <bounce_count>20</bounce_count> + <bounce_count>8</bounce_count> <goals> <row idgoal='1'> - <nb_conversions>21</nb_conversions> - <nb_visits_converted>21</nb_visits_converted> - <revenue>105</revenue> + <nb_conversions>9</nb_conversions> + <nb_visits_converted>9</nb_visits_converted> + <revenue>45</revenue> </row> </goals> - <nb_conversions>21</nb_conversions> - <revenue>105</revenue> - <sum_daily_nb_uniq_visitors>22</sum_daily_nb_uniq_visitors> + <nb_conversions>9</nb_conversions> + <revenue>45</revenue> + <sum_daily_nb_uniq_visitors>10</sum_daily_nb_uniq_visitors> + <code>jp</code> + <logo>plugins/UserCountry/flags/jp.png</logo> + <logoWidth>16</logoWidth> + <logoHeight>11</logoHeight> + </row> + <row> + <label>Unknown</label> + <nb_visits>5</nb_visits> + <nb_actions>5</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>5</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>5</nb_conversions> + <nb_visits_converted>5</nb_visits_converted> + <revenue>25</revenue> + </row> + </goals> + <nb_conversions>5</nb_conversions> + <revenue>25</revenue> + <sum_daily_nb_uniq_visitors>5</sum_daily_nb_uniq_visitors> <code>xx</code> <logo>plugins/UserCountry/flags/xx.png</logo> <logoWidth>16</logoWidth> <logoHeight>11</logoHeight> </row> + <row> + <label>United States</label> + <nb_visits>4</nb_visits> + <nb_actions>4</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>4</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>4</nb_conversions> + <nb_visits_converted>4</nb_visits_converted> + <revenue>20</revenue> + </row> + </goals> + <nb_conversions>4</nb_conversions> + <revenue>20</revenue> + <sum_daily_nb_uniq_visitors>4</sum_daily_nb_uniq_visitors> + <code>us</code> + <logo>plugins/UserCountry/flags/us.png</logo> + <logoWidth>16</logoWidth> + <logoHeight>11</logoHeight> + </row> + <row> + <label>Brazil</label> + <nb_visits>3</nb_visits> + <nb_actions>3</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>3</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>3</nb_conversions> + <nb_visits_converted>3</nb_visits_converted> + <revenue>15</revenue> + </row> + </goals> + <nb_conversions>3</nb_conversions> + <revenue>15</revenue> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> + <code>br</code> + <logo>plugins/UserCountry/flags/br.png</logo> + <logoWidth>16</logoWidth> + <logoHeight>11</logoHeight> + </row> </result> \ No newline at end of file diff --git a/tests/integration/expected/test_ImportLogs__UserCountry.getNumberOfDistinctCountries_month.xml b/tests/integration/expected/test_ImportLogs__UserCountry.getNumberOfDistinctCountries_month.xml index 606fbb524182170284d7f1baad7fce4697d9b8b3..6593897748b0236c1c06d60abaae4b84f84d2213 100755 --- a/tests/integration/expected/test_ImportLogs__UserCountry.getNumberOfDistinctCountries_month.xml +++ b/tests/integration/expected/test_ImportLogs__UserCountry.getNumberOfDistinctCountries_month.xml @@ -1,2 +1,2 @@ <?xml version="1.0" encoding="utf-8" ?> -<result>1</result> \ No newline at end of file +<result>4</result> \ No newline at end of file diff --git a/tests/integration/expected/test_ImportLogs__UserCountry.getRegion_month.xml b/tests/integration/expected/test_ImportLogs__UserCountry.getRegion_month.xml index 82825ce292ddc827e6445b6ec3f68a7ff69edb8a..720b57a800b4649639ea703edecd18825734c5e5 100755 --- a/tests/integration/expected/test_ImportLogs__UserCountry.getRegion_month.xml +++ b/tests/integration/expected/test_ImportLogs__UserCountry.getRegion_month.xml @@ -1,26 +1,95 @@ <?xml version="1.0" encoding="utf-8" ?> <result> <row> - <label>Unknown</label> - <nb_visits>22</nb_visits> - <nb_actions>25</nb_actions> + <label>Unknown, Japan</label> + <nb_visits>10</nb_visits> + <nb_actions>13</nb_actions> <max_actions>3</max_actions> <sum_visit_length>305</sum_visit_length> - <bounce_count>20</bounce_count> + <bounce_count>8</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>9</nb_conversions> + <nb_visits_converted>9</nb_visits_converted> + <revenue>45</revenue> + </row> + </goals> + <nb_conversions>9</nb_conversions> + <revenue>45</revenue> + <sum_daily_nb_uniq_visitors>10</sum_daily_nb_uniq_visitors> + <region>xx</region> + <country>jp</country> + <country_name>Japan</country_name> + <region_name>Unknown</region_name> + <logo>plugins/UserCountry/flags/jp.png</logo> + </row> + <row> + <label>Unknown</label> + <nb_visits>5</nb_visits> + <nb_actions>5</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>5</bounce_count> <goals> <row idgoal='1'> - <nb_conversions>21</nb_conversions> - <nb_visits_converted>21</nb_visits_converted> - <revenue>105</revenue> + <nb_conversions>5</nb_conversions> + <nb_visits_converted>5</nb_visits_converted> + <revenue>25</revenue> </row> </goals> - <nb_conversions>21</nb_conversions> - <revenue>105</revenue> - <sum_daily_nb_uniq_visitors>22</sum_daily_nb_uniq_visitors> + <nb_conversions>5</nb_conversions> + <revenue>25</revenue> + <sum_daily_nb_uniq_visitors>5</sum_daily_nb_uniq_visitors> <region>xx</region> <country>xx</country> <country_name>Unknown</country_name> <region_name>Unknown</region_name> <logo>plugins/UserCountry/flags/xx.png</logo> </row> + <row> + <label>Virginia, United States</label> + <nb_visits>4</nb_visits> + <nb_actions>4</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>4</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>4</nb_conversions> + <nb_visits_converted>4</nb_visits_converted> + <revenue>20</revenue> + </row> + </goals> + <nb_conversions>4</nb_conversions> + <revenue>20</revenue> + <sum_daily_nb_uniq_visitors>4</sum_daily_nb_uniq_visitors> + <region>VA</region> + <country>us</country> + <country_name>United States</country_name> + <region_name>Virginia</region_name> + <logo>plugins/UserCountry/flags/us.png</logo> + </row> + <row> + <label>Unknown, Brazil</label> + <nb_visits>3</nb_visits> + <nb_actions>3</nb_actions> + <max_actions>1</max_actions> + <sum_visit_length>0</sum_visit_length> + <bounce_count>3</bounce_count> + <goals> + <row idgoal='1'> + <nb_conversions>3</nb_conversions> + <nb_visits_converted>3</nb_visits_converted> + <revenue>15</revenue> + </row> + </goals> + <nb_conversions>3</nb_conversions> + <revenue>15</revenue> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> + <region>xx</region> + <country>br</country> + <country_name>Brazil</country_name> + <region_name>Unknown</region_name> + <logo>plugins/UserCountry/flags/br.png</logo> + </row> </result> \ No newline at end of file