Downloading file from osmand is market as event 2.
This commit is contained in:
parent
dc3a3b8808
commit
acf9a6fcee
3 changed files with 15 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue