I'm looking for a method to see how often people use my application and some small usage stats about that usage, e.g. Time Of Day (derived from the message time), duration of usage (program statistic), etc.
The application is written in Java and already connects to the internet, so I know I can send/request information from websites.
My question, is how best to do this? I know I could use Google Analytics and "ping" a specific web page, but ideally I'd like the extra statistics too, can that be done with GA? How do I separate that traffic out of the other GA stats?
Are there existing code snippets I could utilise?
What do I need the server to do? I have hosting with SSH access, MySQL, etc. So can install packages if needed.
Edited to add
This is not a web application, it's a local program that runs on a client machine and connects to the internet to gather data. So there's no web pages that I can insert java code or other scripts into for true web analytics.
This is why I was thinking that I would have to "ping" or "poke" (No idea what the correct terms are) a specific web address, perhaps a PHP page that would record the statistics.
The statistics that I would like to gather are:
IP Address (ONLY to determine the unique visitor and perhaps country of origin)
Time of execution (from the time the statistic was generated)
Number of items processed (program statistic)
Execution duration (program generated statistic)
As the program is usually run by the user an average of once per day, I don't anticipate massive load on the server (famous last words!)
Edited for clarification
The application is a CLI based (no GUI or web browser, web server, or other web application technologies are used). The application runs locally on a user's machine, collects information on various files, downloads information on those files from the internet (yes, using a URL connection), and compiles that information into a database.
I have no view of or access to, the users of the application. I do have a website that I use Google Analytics to see who visits and where from, all the usually stats.
I want to be able to capture a small bunch of stats (explained above) each time the application is run so I know that the application is being used and by how many users and what for.
I had thought I might be able to call a PHP web page with some arguments that could then be added to a database, e.g. http://omertron.com/stats?IP=192.168.2.0|processed=23|duration=270
Or can Google Analytics be used to log that information some how? I can't find much in the documentation about how I would do that.
Check out this list of web analytics software. Lots of free packages there, and once you find one that suits your needs, you'll be able to frame your question specifically to the challenges in using that particular package.
Your options are:
Tagging Systems (like Google Analytics)
Access Log File Analysis
With tagging you create an account with Google Analytics and add some specific JavaScript code you will get from Google, into the relevant places of your code, this allows the browser of your visitors to connect to GA and get captured there.
The Access log file can hold all information about all sessions. There is a lot of detail data generated, so data has to be Extracted, Transformed and Loaded (ETL) to a database. The evaluation can be then performed in nearly real-time. You can create some dashboard application that does the ETL and displays the status of you application.
A third option would be to combine tagging and log file analysis. This will give you more precise results.
Interesting, my thoughts are you would need a framework to accomplish this.
The java application should be able to asynchronously log every event that is happening in the application.
In google analytics you can define names and push events for those specific names. If you would be able to use the following api, I dont think you need to ping a specific web page to use google analytics.
http://download.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html
I have not used this api, hope this helps!
Related
This is my first time working on a solo Java project that would generate income from direct sales (meaning I would sell the product instead of a third-party platform).
I was curious as to the following: How can a developer prevent a customer to simply distribute his/her software?
I realize that there are always ways to bypass any sort of security that a developer can put into their project. However, seeing that my product will be run locally (.exe or jar file) there is no way for me to monitor what my client is doing after I sell the product.
Is there a way to put some sort of "illusionary wall" that someone without more advanced knowledge cannot bypass?
Any tips, suggestion or references are greatly appreciated.
I have a server. Some actions within some of my apps will call to the server with some status info. So I know who uses my software. This is plainly stated in the contracts, so no secret stuff.
If I want to limit my software, I do the following:
when my app starts, it collects some system infos and hashes/CRCs them
if there's a matching file, whose contents match the system infos hash, I unlock the app
if there's no such file, or the hash inside it does not match (different system, manipulated, etc) I will (re-)register
registering is either done
by showing the client the hash, forcing him to call/email me, or
the app connects to my server, checks registration infos, shows the page, and then forces user to pay, or unlocks, depending on some other infos i gathered.
on the server side (or manually) I create a key matching the system info hash key
that key gets back into the app (internet or typed manually) and the app checks if that new code matches its system info hash
if keys match, write key to file, and unlock the app
2 downsides:
java is really easy to reverse-engineer:
someone could create a hash generator and create the missing/wrong system info hash file
if you connect through the internet, you should use SSL/TLS, because in other cases, someone could just reverse-engineer (telnet) the answer the app needs to unlock
a good method to prevent reversen-engineering or to make it a lot lot harder is to create pure .exe/elf files. GraalVM native-image is one of those tools that can accomplish such feats. (only using an exe wrapper is rather pointless when it comes to code security, but i good for users)
whenever the client changes things in his hardware, he has to register/reconnect again
All the software i bought for my pc has to be registered once with a license key via internet or has a usb licenser. So maybe this are some ideas something for you. The disadvantages, running a server for product registration or sending an usb-licenser to the costumer. But i'm interested if there are any other solutions
I want to write a client application for a site (e.g. to read smth from site, add some comments, likes etc). I haven't got access to site sources and there isn't any API for work with it. So at my Android application I decided to parse this site (it has static pages) using : JSOUP Library
And using this library I'm going to write unofficial, but API for my purposes to work with this site, and then use it in my Android application.
Can somebody tell me, is this good practice or there are better ways to do? Is this good idea at all to parse site in Android device.
As I wrote in comment - in general building your own application on top of the third party www service is not a good idea. If you want to do it anyway you have 2 options:
Use jSoup (or any other html parser if exists) and parse third party content on the device
Set up some middleware server to parse content and serve it in some more convenient way.
The second option has a little advantages - you can fix application without forcing users to update it and probably you'll save a bit of device's bandwidth. Of course disadvantage is that you have to pay for server.
General problem with applications like that is that every single change with layout, skin, server configuration can cause your application to stop working, as well as parsing html needs much more work that just connect to existing API.
More over - publishing your application can cause some legal issues (copyright) and is against Google Play's policy:
Do not post an app where the primary functionality is to: Drive
affiliate traffic to a website or Provide a webview of a website not
owned or administered by you (unless you have permission from the
website owner/administrator to do so)
I need to understand the directions in need to look into to Writing a program that figures out what all websites have been hit by a user using his browser. I want to write a standalone program. Can anybody direct me to some API which may help me figure this out.
Well, first of all that depends on which browser do you need to check. I'm guessing that you need to check the currently set default system browser. Anyway, that will require a lot of browser research and few JNI calls.
To find a default browser you would need to check HKEY_CLASSES_ROOT\http\shell\open\command (for Windows) and various configuration files under different linux for different window managers.
Then you would need to read the history of the specific browser from the format of that browser. For example, Firefox stores it's history in sqlite format in the profile directory in places.sqlite file. Chrome on other hand stores it in %home%/User Data/Default/history. So you would need a separate parser for each browser.
Basically, if you need a universal browser history reader - it's a load of work and research.
As it was clarified by the author in his comments - he needs to check what is user currently browsing.
The only truly browser and OS independent way is through proxy. You need to create a HTTP(S) proxy with Java (there are some implementations out there already) and then reconfigure the desired browser to use the proxy running at localhost. When your proxy is used - it will be able to track every bit of traffic the user tries to load.
This information is stored in a SQLite database in firefox:
The file "places.sqlite" stores the annotations, bookmarks, favorite
icons, input history, keywords, and browsing history (a record of
visited pages).
http://kb.mozillazine.org/Places.sqlite
Other browsers probably have similar approaches.
Any language with drivers for SQLite, and that includes Java, C, C#, C++, ruby, and, yes, even javascript, should be equally capable of accessing this database.
Speaking for myself, I would be interested collaborating on such a stand-alone program in Java should the OP put his code on github.
We have a web application which which is deployed and used within an intranet. The application reads in text files from a specified location on the web server itself.
Now we have a requirement of reading in text files from other machines as well, so i'm exploring possible options to implement this. Possible options i've been thinking of are:
Maybe start a ftp server on each local machine and then write a servlet to ftp given machines n read-in data.
Maybe run some utility program thats would read in file contents and push it back to the server using xml etc ?)
Ne help about above/or new ideas would be highly appreciated!
Technologies i'm using are :
Tomcat/Struts/JSP/AJAX.
P.S i want to handle non NFS situations as well!
Thanks,
Abhishek.
apart from the fact that I don't know whats the purpose of the application you're building, and knowing it is a Web-app, why not have users upload the specific files you want to process?, or even better, if they are configuration files, you might put them all in one single location, let's say just one machine. That might be better than having your app stuck just because some machine is not accessible.
I have an idea for you.... You may expose web service on each machine where from you want to get logs.These web services will read log files and send to your web application in bytes. You web application will call these service periodically and will take latest data. your entire system would work like a distributed system. you need to ensure that log file should generate with the name in uniform format - for eg.. log-24-12-2010.log or log24122010.log (if your log file generates on daily basis) - so that web services can form the right name of log and access it.
I recommand you to use RESTful web services because they are pretty easy for such purposes. Use JAX-RS APIs to develop such services.
I hope you would get my idea a little bit.
~~ Priyanjan
I am really looking for implementation advice as I have entered a new realm that I am not familiar with.
At the simplest level, I would like to find a way that I can read/write to a users machine from my web server. For this to work, I think I will have to install some sort of "plugin" on the users machine which can receive (or poll?) the server for instructions.
The above is the line of thought that I currently have, maybe using JAVA to do this. This needs to work on Linux, Mac and Windows OS.
I am really looking for advice on the above, is it a good idea? Is there a better way of doing this? Is there something out there already that I can build on top of?
I really appreciate all input and advice as this is something I have not done before.
Thanks all
For Java, you could launch a client application via Java Web Start that will be able to perform a limited set of operations on the file system.
If this is too restrictive, then you would need to provide a link to a download of a client application that would be installed / executed on the user's desktop machine.
I'm assuming you want to read and write specific files on the users' machine that are not normally accessible (i.e. not temp files, or files in a sandbox). And you want to do this from your webserver.
As you looking for cross platform, I'd go with java. Given that your needs are simple (read/write files from remote commands) you could probably target JRE 1.4, which is now many years old, but is installed on ca. 98% of desktops (source).
Here's an overview of how you can approach this:
Create a java applet or Java Web Start application that fetches a list of commands from a URL. The URL can contain any specific identification that you need to identify the machine, such as the users ID (see below for alternatives.)
Your webserver generates the list of commands that the applet should execute - create file, read file, write file and sends these as the response.
Sign the applet/application, so that it can escape the restrictions of the sandbox. To do this, you need to obtain a certificate. More on this later.
Inform and educate your users about what the applet is doing. E.g. a page on your site about why they are being asked to trust your certificate and what the implications are.
You can implement this as an applet or an application, the bulk of the work is pretty much the same. I talk about applet, but remember it applies equally to application.
In more detail:
The applet requests a list of commands from a URL. To hamper attempts at using your applet on another malicious site, you should use HTTPS to fetch the list of commands so that the server is authenticated. The URL should be hard-coded into your applet, so that any attempts to change this will break the signing. How you communicate the commands to the applet via the URL is up to you, e.g. you can use XML or use RMI and simply send over the list of commands as an object.
I mentioned using the userid to identify the machine - using the machine's MAC address is also a possibility. See how to get the mac address of the host.
Once you have the list of commands, your applet executes these using java file I/O apis. See File, FileReader/FileWriter in the javadocs. You include appropriate logging so the applets actions can be audited later if necessary. Once the applet has executed the commands, it sends the result of the commands back to the server, either as a POST operation, or another RMI method call, if you settle on RMI.
If you want to continually send commands from the server, then the applet can poll the URL/invoke the RMI method regularly. A Timer can help with this.
With communciation errors, it will be necessary for the client to request the list of commands more than once. Thus each time you produce a list of commands from the server, it is given an id. The server gives out the same list with the same id until it receives acknowledgement from the applet that the commands have been executed.
To sign the applet, you should obtain an rsa certificate from a certficiate authority. You can self-sign, but then you are opening the door to others modifying your app and impersonating your certificate. Details on obtaining and using certificates are given here.
If you don't know java, then all of this may not make a huge amount of sense, and it's not a trivial project to get started on, particularly considering the implications for your users if your implementation has holes and defects.
It may be wise to exercise caution: although you can do this, doesn't necessarily mean you should. I imagine that most expert users would frown on the use of this app, and would not accept the certificate. And then there is culpability - if your app accidentally deletes a critical file through a bug, misconfiguration, human error etc, how will you be prepared for that?
For the user, a web browser plugin may be the easiest, since the user won't have to manage yet another running application, however it has its limitation such as having to develop a plugin for each browser. In addition, the user would need their browser running.
You could have the user install a desktop application, which they would have to keep running, so installing it as a service might be ideal.
You could also use a plugin as a wedge between the web browser and a desktop application, which is how Flash works.
To really know you will have to answer the "why" question, why do you wan tot do this.
If you are just trying to store some state on the user's machine that you need to have locally then for small things you can fall back on cookies, or for larger needs you can use the new Web Database features in HTML5 http://dev.w3.org/html5/webdatabase/
If you need to access specific files then you are actually going to have to circumvent the security sand boxing that Java does when run on a webpage. I will leave that for others to go into, I don't know how to do it off hand myself.
In my opinion, Applet will be a better solution. I have made one applet which downloads a zip file from the server on client machine into temp folder, extracts the zip file into a directory specified by client (browser user) and then deletes the zip file.
thanks.
The lowest hanging fruit might be to provide WebDAV access through your web server to a given set of files, as this allows the users to see the files as a part of their usual filesystem with all their usual tools. You then do not have to do all that functionality.
Looks like Slide can deploy on Tomcat, and JBoss has ModeShape.
Will that be useful enough?