From acf9a6fcee0d0fa3ad6a2ed99c33076e1e5246bd Mon Sep 17 00:00:00 2001 From: Pavol Zibrita Date: Fri, 20 Apr 2012 04:12:50 +0200 Subject: [PATCH] Downloading file from osmand is market as event 2. --- OsmAnd/src/net/osmand/Version.java | 2 +- .../osmand/plus/activities/DownloadFileHelper.java | 4 ++-- config/site/download.php | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/Version.java b/OsmAnd/src/net/osmand/Version.java index 324573ea5f..efed7d815b 100644 --- a/OsmAnd/src/net/osmand/Version.java +++ b/OsmAnd/src/net/osmand/Version.java @@ -46,7 +46,7 @@ public class Version { public static String getVersionAsURLParam(Context ctx) { try { - return "osmandver=" + URLEncoder.encode(getFullVersion(ctx), "UTF-8"); + return "osmandver=" + URLEncoder.encode(getVersionForTracker(ctx), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java b/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java index 9dacc13177..9fcef26836 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java @@ -137,11 +137,11 @@ public class DownloadFileHelper { out = new FileOutputStream(fileToDownload); try { if(parts == 1){ - URL url = new URL("http://download.osmand.net/download?file="+fileName + "&" + Version.getVersionAsURLParam(ctx)); //$NON-NLS-1$ + URL url = new URL("http://download.osmand.net/download?event=2&file="+fileName + "&" + Version.getVersionAsURLParam(ctx)); //$NON-NLS-1$ downloadFile(fileName, out, url, null, indexOfAllFiles, progress, forceWifi); } else { for(int i=1; i<=parts; i++){ - URL url = new URL("http://download.osmand.net/download?file="+fileName+"-"+i + "&" + Version.getVersionAsURLParam(ctx)); //$NON-NLS-1$ + URL url = new URL("http://download.osmand.net/download?event=2&file="+fileName+"-"+i + "&" + Version.getVersionAsURLParam(ctx)); //$NON-NLS-1$ downloadFile(fileName, out, url, " ["+i+"/"+parts+"]", indexOfAllFiles, progress, forceWifi); } } diff --git a/config/site/download.php b/config/site/download.php index a73f991327..7b12f42608 100755 --- a/config/site/download.php +++ b/config/site/download.php @@ -72,7 +72,6 @@ function update_count_of_downloads($file) { } } - if(!isset($_GET['file']) ) { header('HTTP/1.0 404 Not Found'); die(1); @@ -82,6 +81,17 @@ function update_count_of_downloads($file) { if(!isset($_SERVER['HTTP_RANGE']) ) { // old version // update_count_of_downloads($file) ; + + if (!isset($_GET['event']) { + $eventno = 1; + } else { + $eventno = $_GET['event']; + } + if (isset($_GET['osmandver']) { + $app = $_GET['osmandver']; + } else { + $app = 'Download '.$_SERVER['HTTP_USER_AGENT']; + } $tracker = new GoogleAnalytics\Tracker('UA-28342846-1', 'download.osmand.net'); $visitor = new GoogleAnalytics\Visitor(); @@ -99,7 +109,7 @@ function update_count_of_downloads($file) { // Track page view $tracker->trackPageview($page, $session, $visitor); - $event = new GoogleAnalytics\Event('Download '.$_SERVER['HTTP_USER_AGENT'], 'App', $file,1); + $event = new GoogleAnalytics\Event($app, 'App', $file, $eventno); $tracker->trackEvent($event, $session, $visitor); } set_time_limit(0);