views:

148

answers:

4

I am looking for the simplest way to get notified when successful installation of a program takes place somewhere. My application is Java based and has Java installer, I could easily put up a client to do any http call with any parameters, this is not an issue. My problem is on the other side - I've got hosted web site and I want direct all traffic there, but I'm not familiar with that part of the programming world :) It would be nice if each successful installation would dump a records in the database (I've got MySql integrated on site). Another options is to send me an email, or at least tail into a log file. The simpler the better. Either would be fine. Can anybody suggest an approach? I know a little bit of PHP and perhaps would be able to do some simple stuff, but without an example or starting point, it's very easy to get lost in today's web technologies maze :)

+1  A: 

Do you want to count all installations of your application? Then "Calling home" is not the proper way to go about things. Why don't you just count the downloads of your application? If someone downloads it, the one is usually installing it, too.

If you are more interested in potential bugs in your installer, you can compose a report and send it to your server after you ask the user to do this.

Markus Lux
#downloads != #successful installs
Jon Skeet
Answer is very simple as stated by Jon Skeet above. This is exactly my problem. Can you suggest more robust way to know how many successful downloads taken place? It can be even more complicated - not every successful download leads to a successful installation. I've got no intention of spying after my customers, the opposite is true - merely to improve the service.
Dima
Yes, you've got a point there, Markus.I agree, this is a better way. Anyway, lets say user did give OK to call home. How do I handle it on the server? Actually the PHP snippet posted above would probably do. Thanks for your answer !
Dima
Leaving aside bugs in the installer, #downloads != #installs. It makes sense to want to know if a file has been downloaded once but then shared between 100 people in an office who all install it. I agree there's a potential trust issue - so I'd explain that in the installer very clearly. You should also allow the installation to continue in the face of network failures, to allow offline installation.
Jon Skeet
Yes of course the installer would complete its job in any case.
Dima
+6  A: 

Does your web site have logging already? If so, you've already got a log file which you could grep for the appropriate URL. No programming required :) Just don't link to that URL from anywhere else, and you shouldn't end up with any false positives.

Jon Skeet
It has conventional logging facilities like AwStat, but I think I can't use it directly..
Dima
Do you mean you can't get hold of your raw logs, just the analysis? Even the analysis would be useful if you could either specify a particular user agent or something else which would show up in the analysis.
Jon Skeet
user agent is great idea, thanks!
Dima
+2  A: 

Using a PHP script would be pretty simple. You could just pass all the data in the query string:

// For example, just a simple http call to log.example.com/?version=3.4.5b
$version = $_GET['version']; 

$dbh = new PDO('mysql:host=localhost;dbname=mydb', 'myuser', 'mypass');

$sth = $dbh->prepare("INSERT INTO log SET version = :version, installed_at = :installed_at");
$sth->bindParam(':version', $version, PDO::PARAM_STR);
$sth->bindParam(':installed_at', time(), PDO::PARAM_INT);
$sth->exec();
Christopher Nadeau
10ks! i was after something like this..
Dima
You might also want to add in some input validation on the $version value. I think the bindParam/exec sequence will catch a lot of the security issues, but it is usually safer to check the value of the variable to see what is there before you add it to the database.You also might want to add the IP of the installing machine to the log.
kaybenleroll
Right thanks, I'll go about PHP magic to get around.. (never wrote a single line in it) Just wanted a direction, thanks a lot.
Dima
+4  A: 

I think Jon Skeet has already answered the questions well enough but..

If you do phone home - for politeness sake make sure that you inform the user and ask their permission.

If you don't you may find that you get a bad reputation.

Fortyrunner